How to use the freshest code on docker-compose avoiding downtime in AWS CodeDeploy?

Viewed 9

I have a Next.js app deployed with docker-compose on AWS CodeDeploy. I setup a staging environment so every time a developer pushed a new commit to the staging branch, it will trigger the creation of a new deployment on CodeDeploy.

The application's appspec.yml has one script to start the application with docker-compose build and docker-compose up.

I thought that using the flag --no-cache while invoking the build would be enough to start the container from the freshest version of the code, however, we are seeing that the new deployments are successful but the changes are not reflected on the application.

How can I make sure that every deployment creates a new container from the freshest code avoiding any downtime?

version: 0.0
os: linux
files:
  - source: .
    destination: /home/ec2-user/app/
hooks:
  ApplicationStart:
   - location: scripts/run.sh
     timeout: 300
     runas: root
#!/bin/bash
cd /home/ec2-user/app
docker-compose build --no-cache
docker-compose up -d
0 Answers
Related