diff --git a/.gitignore b/.gitignore index cdfad49..d49073e 100644 --- a/.gitignore +++ b/.gitignore @@ -4,5 +4,4 @@ __pycache__ .DS_Store .env.* db.sqlite3 -caddy.env .vscode/launch.json diff --git a/DOCKER.md b/DOCKER.md index bbdbfa3..10354c6 100644 --- a/DOCKER.md +++ b/DOCKER.md @@ -1,17 +1,10 @@ # Docker -There are 3 images that make up this project: +There are 2 images that make up this project: - `frogress` - the app itself, based upon [python:3.10-slim](https://hub.docker.com/_/python) image. -- `caddy` - [caddy](https://hub.docker.com/_/caddy) running as a reverse proxy that also provides auto-https for production - `postgres` - [postgresql](https://hub.docker.com/_/postgres) database -## Production - -By default, `PRODUCTION=NO` is set in the `caddy.env` file which means the reverse proxy (Caddy) will listen on port 80/http. Changing this to `PRODUCTION=YES` will cause Caddy to listen on 443/https and will generate SSL certificates and attempt to confirm ownership of the domain (progress.deco.mp). - -Note: The production domain can be overridden by setting `DOMAIN_NAME=www.mydomainname.com` environment variable within the `caddy.env` - ## Persisted data The database data is persisted to `./deployment/postgres/data`, this can be changed within the `docker-compose.yaml` file. @@ -27,7 +20,6 @@ Check what containers are running: $ docker-compose ps Name Command State Ports ---------------------------------------------------------------------------------------------------------------------------------------------- -frogress_caddy_1 /entrypoint.sh Up 2019/tcp, 0.0.0.0:443->443/tcp,:::443->443/tcp, 0.0.0.0:80->80/tcp,:::80->80/tcp frogress_frogress_1 /entrypoint.sh Up 0.0.0.0:8000->8000/tcp,:::8000->8000/tcp frogress_postgres_1 docker-entrypoint.sh postgres Up 0.0.0.0:5432->5432/tcp,:::5432->5432/tcp ``` diff --git a/deployment/caddy/Caddyfile b/deployment/caddy/Caddyfile deleted file mode 100644 index bceab45..0000000 --- a/deployment/caddy/Caddyfile +++ /dev/null @@ -1,3 +0,0 @@ -__DOMAIN_NAME__ { - reverse_proxy __BACKEND_HOST__:__BACKEND_PORT__ -} diff --git a/deployment/caddy/Dockerfile b/deployment/caddy/Dockerfile deleted file mode 100644 index 7603cff..0000000 --- a/deployment/caddy/Dockerfile +++ /dev/null @@ -1,7 +0,0 @@ -FROM caddy:2.5.2-alpine - -COPY deployment/caddy/Caddyfile /etc/caddy/ - -COPY deployment/caddy/entrypoint.sh /entrypoint.sh - -ENTRYPOINT ["/entrypoint.sh"] diff --git a/deployment/caddy/entrypoint.sh b/deployment/caddy/entrypoint.sh deleted file mode 100755 index 22f1dbb..0000000 --- a/deployment/caddy/entrypoint.sh +++ /dev/null @@ -1,26 +0,0 @@ -#!/usr/bin/env sh - -BE_HOST=${BACKEND_HOST:-frogress} -BE_PORT=${BACKEND_PORT:-8000} - -CADDY_DOMAIN=${DOMAIN_NAME:-progress.deco.mp} - -IS_PROD=${PRODUCTION:-YES} - -until nc -z ${BE_HOST} ${BE_PORT} > /dev/null; do - echo "Waiting for backend to become available on ${BE_HOST}:${BE_PORT}..." - sleep 1 -done - -if [[ "${IS_PROD}" == "YES" ]]; then - echo "Frogress API available at https://${CADDY_DOMAIN}" - sed -i "s/__DOMAIN_NAME__/${CADDY_DOMAIN}/g" /etc/caddy/Caddyfile -else - echo "Frogress API available at http://localhost:80" - sed -i "s/__DOMAIN_NAME__/:80/g" /etc/caddy/Caddyfile -fi - -sed -i "s/__BACKEND_HOST__/${BE_HOST}/g" /etc/caddy/Caddyfile -sed -i "s/__BACKEND_PORT__/${BE_PORT}/g" /etc/caddy/Caddyfile - -/usr/bin/caddy run --config /etc/caddy/Caddyfile --adapter caddyfile diff --git a/docker-compose.yaml b/docker-compose.yaml index 6fda91b..ab90eaa 100644 --- a/docker-compose.yaml +++ b/docker-compose.yaml @@ -15,11 +15,3 @@ services: dockerfile: deployment/frogress/Dockerfile ports: - "8000:8000" - caddy: - env_file: caddy.env - build: - context: . - dockerfile: deployment/caddy/Dockerfile - ports: - - "80:80" - - "443:443"