1

docker-compose:

services:
  nginx:
    image: nginx:latest
    restart: unless-stopped
    volumes:
      - ./data/nginx:/etc/nginx/conf.d
      - ./data/certbot/conf:/etc/letsencrypt
      - ./data/certbot/www:/var/www/certbot
      - admin-dist:/apps/static/admin:ro
    ports:
      - "80:80"
      - "443:443"
    depends_on:
      - admin
    command: "/bin/sh -c 'while :; do sleep 6h & wait $${!}; nginx -s reload; done & nginx -g \"daemon off;\"'"

  admin:
    build:
      dockerfile: ./apps/Blogue/admin/Dockerfile
      context: ../../
    volumes:
      - admin-dist:/app/dist

volumes:
  admin-dist:
    external: true

nginx config:

server {
    listen 443 ssl;
    server_name mydomain.com;
    server_tokens off;

    ssl_certificate /etc/letsencrypt/live/mydomain.com/fullchain.pem;
    ssl_certificate_key /etc/letsencrypt/live/mydomain.com/privkey.pem;
    include /etc/letsencrypt/options-ssl-nginx.conf;
    ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem;

    location / {
      root /apps/static/admin;
      index index.html;
      try_files $uri $uri/ /index.html;
    }
}

Nothing special, but I got a problem. Nginx service depends on admin service, so the admin builds first. Then nginx service starts and overwrites the content of the volume with default 50x.html and index.html, which are just placeholders. How to prevent nginx from doing this? Change the build order? I got a bunch of other dependencies there and I think this can be problematic and also not great solution, because it feels unstable. Any ideas?

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.