Wowu / docker-rollout

🚀 Zero Downtime Deployment for Docker Compose
https://github.com/Wowu/docker-rollout
MIT License
2.18k stars 59 forks source link

Error after deploiement finish : 20#20: *23 connect() failed (111: Connection refused) while connecting to upstream #14

Closed hadpro24 closed 10 months ago

hadpro24 commented 10 months ago

Hello I use nginx reverse proxy beside my web app. When Deploiement process it's okay I don't have downtime but after deploiement finish I got this error, nginx can't find upstream :

20#20: *23 connect() failed (111: Connection refused) while connecting to upstream

Wowu commented 10 months ago

Hi, are you running nginx-proxy in a docker container, or nginx on the host? docker rollout requires a proxy with automated service discovery to work, like Traefik or nginx-proxy (see Caveats in README).

Related to #9.

hadpro24 commented 10 months ago

I Use this : nginx/Dockerfile

FROM nginx:1.25

RUN rm /etc/nginx/conf.d/default.conf
COPY 502.html /usr/share/nginx/html
COPY nginx.conf /etc/nginx/conf.d
version: '3.7'
networks:
  proxy_https_default:
     external: true
services:
  nginx:
    build: ./nginx
    environment:
      - VIRTUAL_HOST=${DOMAIN}
      - VIRTUAL_PORT=80
      - LETSENCRYPT_HOST=${DOMAIN}
      - LETSENCRYPT_EMAIL=emailxxxxx@xxxx.com
    restart: unless-stopped
    networks:
      - proxy_https_default
  web:
    command: sh -c "gunicorn config.wsgi:application --bind 0.0.0.0:8000 --timeout 20"
    env_file:
      - .env
    image: dt:dev
    restart: unless-stopped
    networks:
      - default

And I do that for lunch:

docker build -t dt:dev --cache-from dt:dev --build-arg BUILDKIT_INLINE_CACHE=1 .
docker rollout -f docker-compose.yml --env-file .env web
Wowu commented 10 months ago

This tool will not work with static nginx configuration. You would have to run nginx -s reload inside nginx container after deploying with this tool, so nginx would use the new IP of the web container, but this approach would cause downtime.

I suggest using https://github.com/nginx-proxy/nginx-proxy instead (this is a wrapper around nginx). You can check a sample configuration here: https://github.com/Wowu/docker-rollout/tree/main/examples/nginx-proxy

hadpro24 commented 10 months ago

Can I configurate that without let's encrypt ?

Wowu commented 10 months ago

nginx-proxy by itself doesn't issue let's encrypt certificates, but it can be handled by https://github.com/nginx-proxy/acme-companion