-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile
43 lines (28 loc) · 853 Bytes
/
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
FROM python:3.12-alpine AS base
ARG DEV=false
ENV VIRTUAL_ENV=/app/.venv \
PATH="/app/.venv/bin:$PATH"
RUN apk update && \
apk add libpq
FROM base AS builder
ENV POETRY_NO_INTERACTION=1 \
POETRY_VIRTUALENVS_IN_PROJECT=1 \
POETRY_VIRTUALENVS_CREATE=1 \
POETRY_CACHE_DIR=/tmp/poetry_cache
RUN apk update && \
apk add musl-dev build-base gcc gfortran openblas-dev
WORKDIR /app
# Install Poetry
RUN pip install poetry==1.8.1
# Install the app
COPY pyproject.toml poetry.lock app.py ./
RUN if [ $DEV ]; then \
poetry install --with dev --no-root && rm -rf $POETRY_CACHE_DIR; \
else \
poetry install --without dev --no-root && rm -rf $POETRY_CACHE_DIR; \
fi
FROM base AS runtime
COPY --from=builder ${VIRTUAL_ENV} ${VIRTUAL_ENV}
COPY src ./src
WORKDIR /app/src
ENTRYPOINT ["python", "-m", "app.main"]