-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile
49 lines (45 loc) · 1.16 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
46
47
48
49
FROM python:3.10-slim-bullseye AS python
ARG VIRTUAL_ENV=/opt/venv
WORKDIR /app
RUN addgroup --gid 1001 app; \
adduser --uid 1000 --gid 1001 app
# hadolint ignore=DL3008
RUN apt-get update; \
apt-get install -y --no-install-recommends gcc libc-dev libpq-dev; \
rm -rf /var/lib/apt/lists/*
ENV VIRTUAL_ENV=$VIRTUAL_ENV
ENV PATH=$VIRTUAL_ENV/bin:$PATH
FROM python AS build-base
ARG PIP_VERSION=24.0.0
ARG POETRY_VERSION=1.7.1
RUN python -m pip install --no-cache-dir -U \
"pip==$PIP_VERSION" \
"poetry==$POETRY_VERSION" \
wheel \
setuptools; \
virtualenv "$VIRTUAL_ENV"
COPY pyproject.toml poetry.lock ./
RUN poetry install --no-dev
FROM build-base AS dist
COPY . .
RUN poetry build; \
poetry install --no-dev
FROM build-base AS test
RUN poetry install
COPY . .
RUN poetry install; \
poetry run test-ci
FROM python
ARG TZ=Europe/Riga
ARG HOST=0.0.0.0
ARG PORT=5000
COPY --from=test /app/test_results ./test_results
COPY --from=dist /opt/venv /opt/venv
COPY --from=dist /app .
USER app
RUN chmod +x docker-entrypoint.sh
ENV TZ=$TZ
ENV HOST=$HOST
ENV PORT=$PORT
ENTRYPOINT ["./docker-entrypoint.sh"]
CMD ["gunicorn", "-c", "deploy/gunicorn_config.py", "app:create_app()"]