diff --git a/Caddyfile b/Caddyfile index 0ed6e2b..fbcfe47 100644 --- a/Caddyfile +++ b/Caddyfile @@ -5,10 +5,10 @@ :8000 { handle_path /static/* { - root * static/ + root * /usr/share/caddy file_server } handle { - reverse_proxy :8001 + reverse_proxy backend:8001 } } \ No newline at end of file diff --git a/Dockerfile b/Dockerfile index a266a7d..df29a43 100644 --- a/Dockerfile +++ b/Dockerfile @@ -15,11 +15,6 @@ RUN apt update && \ bash \ vim \ curl && \ - apt install -y debian-keyring debian-archive-keyring apt-transport-https && \ - curl -1sLf 'https://dl.cloudsmith.io/public/caddy/stable/gpg.key' | gpg --dearmor -o /usr/share/keyrings/caddy-stable-archive-keyring.gpg && \ - curl -1sLf 'https://dl.cloudsmith.io/public/caddy/stable/debian.deb.txt' | tee /etc/apt/sources.list.d/caddy-stable.list && \ - apt update && \ - apt install caddy && \ rm -rf /var/lib/apt/lists/* RUN useradd -m --uid 1000 timetracker diff --git a/docker-compose.no-caddy.yml b/docker-compose.no-caddy.yml new file mode 100644 index 0000000..4aad4bb --- /dev/null +++ b/docker-compose.no-caddy.yml @@ -0,0 +1,17 @@ +--- +services: + timetracker: + image: registry.kucharczyk.xyz/timetracker + build: + context: . + dockerfile: Dockerfile + container_name: timetracker + environment: + - TZ=Europe/Prague + - CSRF_TRUSTED_ORIGINS="https://tracker.kucharczyk.xyz" + user: "1000" + # volumes: + # - "db:/home/timetracker/app/src/timetracker/db.sqlite3" + ports: + - "8000:8000" + restart: unless-stopped diff --git a/docker-compose.yml b/docker-compose.yml index 4aad4bb..77b5d0e 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,17 +1,28 @@ --- services: - timetracker: + backend: image: registry.kucharczyk.xyz/timetracker build: context: . dockerfile: Dockerfile - container_name: timetracker environment: - TZ=Europe/Prague - CSRF_TRUSTED_ORIGINS="https://tracker.kucharczyk.xyz" user: "1000" - # volumes: - # - "db:/home/timetracker/app/src/timetracker/db.sqlite3" + volumes: + - "static-files:/home/timetracker/app/static" + restart: unless-stopped + + frontend: + image: caddy + volumes: + - "static-files:/usr/share/caddy" + - "$PWD/Caddyfile:/etc/caddy/Caddyfile" ports: - "8000:8000" - restart: unless-stopped + depends_on: + - backend + +volumes: + static-files: + diff --git a/entrypoint.sh b/entrypoint.sh index 6adac62..13196d5 100644 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -7,6 +7,5 @@ poetry run python manage.py migrate echo "Collect static files" poetry run python manage.py collectstatic --clear --no-input -echo "Starting server" -caddy start +echo "Starting app" poetry run python -m gunicorn --bind 0.0.0.0:8001 timetracker.asgi:application -k uvicorn.workers.UvicornWorker --access-logfile - --error-logfile -