-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile
42 lines (31 loc) · 1.01 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
# Based on https://stackoverflow.com/a/57886655
FROM python:3.9-slim-buster as base
ENV PYTHONFAULTHANDLER=1 \
PYTHONHASHSEED=random \
PYTHONUNBUFFERED=1
# Set hierarchy with folders
ENV APP_NAME=platform-registry
ENV APP_DIR=/opt/inventory/${APP_NAME}
RUN mkdir -p ${APP_DIR}
WORKDIR ${APP_DIR}
FROM base as builder
ENV PIP_DEFAULT_TIMEOUT=100 \
PIP_DISABLE_PIP_VERSION_CHECK=1 \
PIP_NO_CACHE_DIR=1 \
POETRY_VERSION=1.1.13
RUN pip install "poetry==$POETRY_VERSION"
RUN python -m venv /venv
# Copy app artifacts
COPY pyproject.toml poetry.lock ./
RUN poetry export -f requirements.txt --without-hashes | /venv/bin/pip install -r /dev/stdin
COPY . .
RUN poetry build && /venv/bin/pip install dist/*.whl
FROM base as final
COPY --from=builder /venv /venv
COPY --from=builder ${APP_DIR} .
# Set variables to activate venv
ENV PATH="/venv/bin:${PATH}"
ENV VIRTUAL_ENV="/venv"
CMD uvicorn platform_registry.main:app --host 0.0.0.0 \
--port 8080 --reload \
--log-config platform_registry/config/log.yaml