diff --git a/compose.prod.yaml b/compose.prod.yaml index 033f7f8..a60429c 100644 --- a/compose.prod.yaml +++ b/compose.prod.yaml @@ -13,16 +13,40 @@ services: env_file: - ./.env.prod - nginx: + nginx-proxy: + container_name: nginx-proxy build: ./nginx + restart: always ports: - - 8080:80 + - 443:443 + - 80:80 volumes: - static_volume:/staticfiles - media_volume:/mediafiles + - certs:/etc/nginx/certs + - html:/usr/share/nginx/html + - vhost:/etc/nginx/vhost.d + - /var/run/docker.sock:/tmp/docker.sock:ro depends_on: - web + acme-companion: + image: docker.io/nginxproxy/acme-companion + env_file: + - ./.env.prod.proxy-companion + volumes: + - /var/run/docker.sock:/var/run/docker.sock:ro + - certs:/etc/nginx/certs + - html:/usr/share/nginx/html + - vhost:/etc/nginx/vhost.d + - acme:/etc/acme.sh + depends_on: + - nginx-proxy + volumes: static_volume: - media_volume: \ No newline at end of file + media_volume: + certs: + html: + vhost: + acme: \ No newline at end of file diff --git a/compose.staging.yaml b/compose.staging.yaml index a81bdc3..5d151a9 100644 --- a/compose.staging.yaml +++ b/compose.staging.yaml @@ -19,19 +19,19 @@ services: restart: always ports: - 443:443 - - 8080:80 + - 80:80 volumes: - static_volume:/staticfiles - media_volume:/mediafiles - certs:/etc/nginx/certs - html:/usr/share/nginx/html - vhost:/etc/nginx/vhost.d - - /var/run/docker.sock:/tmp/docker/sock:ro + - /var/run/docker.sock:/tmp/docker.sock:ro depends_on: - web acme-companion: - image: nginxproxy/acme-companion + image: docker.io/nginxproxy/acme-companion env_file: - ./.env.staging.proxy-companion volumes: diff --git a/nginx/Dockerfile b/nginx/Dockerfile index e2f0ed0..98aa030 100644 --- a/nginx/Dockerfile +++ b/nginx/Dockerfile @@ -1,3 +1,4 @@ FROM docker.io/nginxproxy/nginx-proxy + COPY vhost.d/default /etc/nginx/vhost.d/default COPY custom.conf /etc/nginx/conf.d/custom.conf \ No newline at end of file diff --git a/wedding_site/primary/templates/header.html b/wedding_site/primary/templates/header.html index 6574036..32bb550 100644 --- a/wedding_site/primary/templates/header.html +++ b/wedding_site/primary/templates/header.html @@ -3,4 +3,5 @@ content="width=device-width, initial-scale=1"> {% load static %} + \ No newline at end of file diff --git a/wedding_site/wedding_site/settings.py b/wedding_site/wedding_site/settings.py index 33eb86b..b7e5b95 100644 --- a/wedding_site/wedding_site/settings.py +++ b/wedding_site/wedding_site/settings.py @@ -22,9 +22,11 @@ BASE_DIR = Path(__file__).resolve().parent.parent SECRET_KEY = os.environ.get("SECRET_KEY") -DEBUG = bool(os.environ.get("DEBUG", default=0)) +#DEBUG = bool(os.environ.get("DEBUG", default=0)) +#DEBUG=True -ALLOWED_HOSTS = os.environ.get("DJANGO_ALLOWED_HOSTS").split(" ") +if "DJANGO_ALLOWED_HOSTS" in os.environ: + ALLOWED_HOSTS = os.environ.get("DJANGO_ALLOWED_HOSTS").split(" ") # Application definition @@ -112,17 +114,27 @@ USE_I18N = True USE_TZ = True SECURE_PROXY_SSL_HEADER = ("HTTP_X_FORWARDED_PROTO", "https") -CSRF_TRUSTED_ORIGINS = os.environ.get("CSRF_TRUSTED_ORIGINS").split(" ") + +if "CSRF_TRUSTED_ORIGINS" in os.environ: + CSRF_TRUSTED_ORIGINS = os.environ.get("CSRF_TRUSTED_ORIGINS").split(" ") # Static files (CSS, JavaScript, Images) # https://docs.djangoproject.com/en/5.0/howto/static-files/ STATIC_URL = 'static/' -STATIC_ROOT = BASE_DIR / "staticfiles" + +if "DJANGO_STATIC_ROOT" in os.environ: + STATIC_ROOT = os.environ.get("DJANGO_STATIC_ROOT") +else: + STATIC_ROOT = BASE_DIR / "staticfiles" MEDIA_URL = 'media/' -MEDIA_ROOT = BASE_DIR / "mediafiles" + +if "DJANGO_MEDIA_ROOT" in os.environ: + MEDIA_ROOT = os.environ.get("DJANGO_MEDIA_ROOT") +else: + MEDIA_ROOT = BASE_DIR / "mediafiles" # Default primary key field type # https://docs.djangoproject.com/en/5.0/ref/settings/#default-auto-field