2.5.3 Containerization & Deployment

1. Dockerfiles

• Backend Dockerfile:

FROM node:18-alpine
WORKDIR /app
COPY package*.json ./
RUN npm install
COPY . .
EXPOSE 4000
CMD ["npm", "start"]

• Socket.io Dockerfile (if separate from the main backend, otherwise combined).

2. ECS Task Definitions

• Defines which Docker images to run, CPU/memory requirements, environment variables (like DATABASE_URL, REDIS_URL, JWT_SECRET).

3. ECS Service

• Manages the desired count of tasks (containers).

• Automatically restarts tasks if a container crashes.

• Integrates with an Application Load Balancer for dynamic scaling based on CPU/memory usage or request count.

4. CI/CD

• GitHub Actions or AWS CodePipeline:

• On commit to main or release branch, build Docker images, push to ECR (Elastic Container Registry), and update ECS services.

Last updated