This is my common docker-dcompose.yml:
version: '3.8'
services:
cron:
container_name: cron
restart: always
build:
context: ./containers/cron
depends_on:
- server
links:
- server
redis:
container_name: redis
image: redis:latest
ports:
- '6379:6379'
restart: always
nginx:
image: nginx
container_name: nginx
restart: always
server: # nodejs server
image: my-docker-hub-account/server
container_name: server
restart: always
build:
context: ./containers/server
links:
- redis
depends_on:
- redis
And this is my staging docker-compose.staging.yml:
version: '3.8'
services:
server:
build:
args:
- NODE_ENV=staging
context: ./containers/server
command: node build/index.js
image: my-docker-hub-account/server:staging
env_file:
- .env.common
- .env.staging
nginx:
ports:
- '80:80'
- '443:443'
volumes:
- ./containers/nginx/staging:/etc/nginx/conf.d
- ./ssl/certbot/www:/var/www/certbot:ro
- ./ssl/certbot/conf:/etc/letsencrypt
watchtower:
container_name: watchtower
image: containrrr/watchtower
environment:
- REPO_USER=my-docker-hub-account
- REPO_PASS=pass
- WATCHTOWER_CLEANUP=true
- WATCHTOWER_REMOVE_VOLUMES=true
# - WATCHTOWER_INCLUDE_RESTARTING=true
# - WATCHTOWER_REVIVE_STOPPED=true
# - WATCHTOWER_ROLLING_RESTART=true
volumes:
- /var/run/docker.sock:/var/run/docker.sock
command: --interval 30 --include-stopped server
After I make push of the newly build image and then pull on my DigitalOcean droplet, I get Nginx 502 error on hitting the same url. In order to get it work, I have to compose up again the app
Thank you mates in advance!
I had to add these lines of code:
com.centurylinklabs.watchtower.enable: true (in services/server and services/nginx)
com.centurylinklabs.watchtower.depends-on: 'server' (in services/nginx)