Dockerize
This commit is contained in:
51
Dockerfile
Normal file
51
Dockerfile
Normal file
@ -0,0 +1,51 @@
|
||||
FROM python:3.11-slim-bookworm AS env-builder
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
COPY pyproject.toml .
|
||||
COPY poetry.lock .
|
||||
|
||||
# create virtual environment
|
||||
RUN python -m venv /venv
|
||||
|
||||
# set python thingies, set environment variables and activate virtual environment
|
||||
ENV \
|
||||
PYTHONDONTWRITEBYTECODE=1 \
|
||||
PYTHONUNBUFFERED=1 \
|
||||
PATH="/venv/bin:$PATH"
|
||||
|
||||
RUN \
|
||||
pip install poetry && \
|
||||
# dump python dependencies into requirements file
|
||||
poetry export --without-hashes --format=requirements.txt > requirements.txt && \
|
||||
# install python libs
|
||||
pip install -r requirements.txt --no-cache-dir --prefer-binary --no-deps --no-compile
|
||||
|
||||
|
||||
FROM python:3.11-slim-bookworm
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
COPY --from=env-builder /venv /venv
|
||||
|
||||
# set python thingies and activate virtual environment
|
||||
ENV \
|
||||
PYTHONDONTWRITEBYTECODE=1 \
|
||||
PYTHONUNBUFFERED=1 \
|
||||
PATH="/venv/bin:$PATH"
|
||||
|
||||
COPY manage.py .
|
||||
COPY pyproject.toml .
|
||||
COPY poetry.lock .
|
||||
COPY db.template.sqlite3 db.sqlite3
|
||||
COPY ./project ./project
|
||||
|
||||
# run as user www-data
|
||||
USER 33
|
||||
|
||||
ENTRYPOINT [ "/venv/bin/gunicorn" ]
|
||||
CMD [ \
|
||||
"--bind", "0.0.0.0:8000", \
|
||||
"--workers", "4", \
|
||||
"project.wsgi" \
|
||||
]
|
||||
Reference in New Issue
Block a user