Dockerize application

This commit is contained in:
Luca 2023-10-14 23:46:19 +02:00
parent f87dd17bdc
commit e3ab204f62
4 changed files with 59 additions and 0 deletions

8
.dockerignore Normal file
View File

@ -0,0 +1,8 @@
**/.git*
**/__pycache__
*.md
.dockerignore
.env*
Dockerfile
db.sqlite3
docker-compose.yml

28
Dockerfile Normal file
View File

@ -0,0 +1,28 @@
FROM python:3.11-alpine3.18 AS requirements
WORKDIR /workdir
RUN pip --no-cache-dir install poetry
COPY poetry.lock pyproject.toml /workdir/
RUN poetry export -f requirements.txt -o /requirements.txt
FROM python:3.11-alpine3.18
ENV PORT=8000
WORKDIR /app
RUN pip --no-cache-dir install gunicorn
COPY --from=requirements /requirements.txt /app/
RUN pip --no-cache-dir install -r requirements.txt
COPY LICENSE manage.py /app/
COPY ljg /app/ljg/
COPY docker/entrypoint.sh /
EXPOSE 8000
ENTRYPOINT ["/entrypoint.sh"]

11
docker-compose.yml Normal file
View File

@ -0,0 +1,11 @@
---
services:
app:
build: .
restart: unless-stopped
env_file: .env
ports:
- 127.0.0.1:8000:8000
volumes:
- ./db.sqlite3:/app/db.sqlite3

12
docker/entrypoint.sh Executable file
View File

@ -0,0 +1,12 @@
#!/bin/sh
set -ex
python manage.py migrate
if [ -z "$1" ] || [ "${1%-}" != "$1" ]
then
exec gunicorn ljg.wsgi "$@"
fi
exec "$@"