Package the service for production: containerize, set up CI/CD, deploy to cloud, write runbooks, and document everything. By the end, your feature flag service is ready for real teams and real flags in production.
← Back to Module 10 overviewdocker-compose.yml with all services (app, postgres, redis, grafana).Create Dockerfile:
# Backend build
FROM node:20-alpine as backend-build
WORKDIR /app
COPY package*.json ./
RUN npm ci
COPY . .
RUN npm run build
# Backend runtime
FROM node:20-alpine as backend-runtime
WORKDIR /app
COPY --from=backend-build /app/node_modules ./node_modules
COPY --from=backend-build /app/dist ./dist
COPY --from=backend-build /app/package*.json ./
ENV NODE_ENV=production
EXPOSE 3000
HEALTHCHECK --interval=30s --timeout=3s --start-period=5s --retries=3 \
CMD node -e "require('http').get('http://localhost:3000/health', (r) => {if (r.statusCode !== 200) throw new Error(r.statusCode)})"
CMD ["node", "dist/index.js"]
# Dashboard build
FROM node:20-alpine as dashboard-build
WORKDIR /dashboard
COPY dashboard/package*.json ./
RUN npm ci
COPY dashboard ./
RUN npm run build
# Nginx for dashboard
FROM nginx:alpine as final
COPY --from=dashboard-build /dashboard/dist /usr/share/nginx/html
EXPOSE 80
CMD ["nginx", "-g", "daemon off;"]