-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile.dev
46 lines (34 loc) · 1.35 KB
/
Dockerfile.dev
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
FROM python:3.10-slim AS builder
# --- Install Poetry ---
ARG POETRY_VERSION=2.0
ENV POETRY_HOME=/opt/poetry
ENV POETRY_NO_INTERACTION=1
ENV POETRY_VIRTUALENVS_IN_PROJECT=1
ENV POETRY_VIRTUALENVS_CREATE=1
ENV PYTHONDONTWRITEBYTECODE=1
ENV PYTHONUNBUFFERED=1
# Tell Poetry where to place its cache and virtual environment
ENV POETRY_CACHE_DIR=/opt/.cache
RUN pip install "poetry==${POETRY_VERSION}"
WORKDIR /app
# --- Reproduce the environment ---
# You can comment the following two lines if you prefer to manually install
# the dependencies from inside the container.
COPY pyproject.toml poetry.lock /app/
# Install the dependencies and clear the cache afterwards.
# This may save some MBs.
RUN poetry install --without dev --no-root && rm -rf $POETRY_CACHE_DIR
# Now let's build the runtime image from the builder.
# We'll just copy the env and the PATH reference.
FROM python:3.10-slim AS runtime
ENV VIRTUAL_ENV=/app/.venv
ENV PATH="/app/.venv/bin:$PATH"
ENV HOST=0.0.0.0
COPY --from=builder ${VIRTUAL_ENV} ${VIRTUAL_ENV}
WORKDIR /app
COPY data/ ./data
COPY app.py ./
COPY pages/ ./pages
EXPOSE 8080
HEALTHCHECK CMD python -c "import requests; import sys; sys.exit(0) if requests.get('http://127.0.0.1:8080/').status_code == 200 else sys.exit(1);"
ENTRYPOINT ["gunicorn", "-b", ":8080", "-w", "2", "app:server"]