-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile
47 lines (29 loc) · 867 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
44
45
46
47
FROM bitnami/python:3.10 as base
FROM base as builder
WORKDIR /build
ARG DEBIAN_FRONTEND=noninteractive
# Python env
ENV PYTHONDONTWRITEBYTECODE=1 \
PYTHONUNBUFFERED=1 \
PYTHONFAULTHANDLER=1 \
PYTHONHASHSEED=random
# PIP settings
ENV PIP_DISABLE_PIP_VERSION_CHECK=1 \
PIP_NO_CACHE_DIR=1
RUN python -m venv /venv
COPY pyproject.toml poetry.lock ./
RUN pip install poetry && poetry export --without-hashes -f requirements.txt | /venv/bin/pip install -r /dev/stdin
COPY . ./
RUN poetry build && /venv/bin/pip install dist/*.whl
FROM bitnami/python:3.10-prod as runner
RUN useradd --create-home app
COPY --from=builder /venv /venv
WORKDIR /home/app
ENV PYTHONUNBUFFERED=1
ENV VIRTUAL_ENV=/venv
ENV PATH="/venv/bin:$PATH"
EXPOSE 8000
RUN chown -R app:app /home/app
USER app
# TODO: Use gunicorn
CMD uvicorn app.main:server --host 0.0.0.0