-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile
45 lines (33 loc) · 1.09 KB
/
Dockerfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
FROM python:3.12-alpine as base
ENV POETRY_NO_INTERACTION=1 \
POETRY_VIRTUALENVS_IN_PROJECT=1 \
PEOTRY_VIRTUALENVS_CREATE=0 \
POETRY_CACHE_DIR=/tmp/poetry-cache \
PATH="/app/.venv/bin:$PATH"
USER root
RUN mkdir /app
WORKDIR /app
FROM base as builder
# Setup build requirements
RUN apk add --no-cache build-base libffi-dev && \
pip install poetry
COPY ./app /app/app
COPY ./pyproject.toml /app
COPY ./poetry.lock /app
COPY ./README.md /app
# Install poetry deps and app package via pip, install gunicorn
# this avoids needing the app source in the production image
RUN poetry export -f requirements.txt -o requirements.txt && \
poetry build && \
python -m venv /app/.venv && \
pip install -r requirements.txt --compile && \
pip install --compile dist/*.whl && \
pip install --compile gunicorn
FROM base
# Setup necessary files to run app then run as gunicorn user
RUN addgroup gunicorn && \
adduser -H -D -G gunicorn gunicorn
COPY ./gunicorn.conf.py /app
COPY --from=builder /app/.venv /app/.venv
USER gunicorn
CMD ["gunicorn", "-c", "/app/gunicorn.conf.py", "feed_editor:create_app()"]