-
Notifications
You must be signed in to change notification settings - Fork 1
/
Dockerfile
40 lines (36 loc) · 1.2 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
FROM python:3.11.4-slim-buster AS python-base
WORKDIR /app
ARG VIRTUAL_ENV=/opt/venv
RUN addgroup --gid 1001 app && adduser --uid 1000 --gid 1001 app
ENV VIRTUAL_ENV=$VIRTUAL_ENV \
PATH=$VIRTUAL_ENV/bin:$PATH \
PYTHONDONTWRITEBYTECODE=1 \
PYTHONBUFFERED=1 \
PYTHONPATH=/app/src:$PYTHONPATH
FROM python-base AS dependencies-base
ARG PIP_VERSION=23.2
ARG POETRY_VERSION=1.5.1
RUN python -m pip install --no-cache-dir -U \
"pip==$PIP_VERSION" \
"poetry==$POETRY_VERSION" && \
virtualenv "$VIRTUAL_ENV"
COPY pyproject.toml poetry.lock ./
RUN poetry install --without dev
FROM dependencies-base AS dependencies-release
COPY src ./src
RUN poetry install --without dev && \
poetry build
FROM dependencies-base AS development
# hadolint ignore=DL3008
RUN apt-get update && \
apt-get install -y --no-install-recommends git && \
rm -rf /var/lib/apt/lists/*
RUN poetry install --with dev
COPY . .
RUN poetry install
CMD ["tomodachi", "run", "src/app.py", "--loop", "uvloop"]
FROM python-base AS release
COPY --from=dependencies-release --chown=app:app /opt/venv /opt/venv
COPY --from=dependencies-release --chown=app:app /app .
USER app
CMD ["tomodachi", "run", "src/app.py", "--loop", "uvloop", "--production"]