2021-05-29 16:22:13 +02:00
|
|
|
## Build venv
|
|
|
|
FROM python:3.9.5-buster AS venv
|
|
|
|
|
|
|
|
# https://python-poetry.org/docs/#installation
|
|
|
|
ENV POETRY_VERSION=1.1.6
|
|
|
|
RUN curl -sSL https://raw.githubusercontent.com/python-poetry/poetry/master/get-poetry.py | python
|
|
|
|
|
|
|
|
ENV PATH /root/.poetry/bin:$PATH
|
|
|
|
ENV PYTHONPATH $PYTHONPATH:/root/.poetry/lib
|
|
|
|
|
|
|
|
WORKDIR /app
|
|
|
|
|
|
|
|
COPY pyproject.toml poetry.lock ./
|
|
|
|
|
|
|
|
RUN python -m venv --copies /app/venv \
|
|
|
|
&& . /app/venv/bin/activate \
|
|
|
|
&& poetry install --no-dev
|
|
|
|
|
|
|
|
|
|
|
|
## Get git versions
|
|
|
|
FROM alpine/git:v2.30.2 AS git
|
|
|
|
ADD . /app
|
|
|
|
WORKDIR /app
|
|
|
|
RUN git rev-parse HEAD | tee /version
|
|
|
|
|
|
|
|
|
|
|
|
## Beginning of runtime image
|
|
|
|
FROM python:3.9.5-slim-buster as prod
|
|
|
|
|
|
|
|
RUN echo "Europe/Paris" > /etc/timezone
|
|
|
|
|
|
|
|
COPY --from=venv /app/venv /app/venv/
|
|
|
|
ENV PATH /app/venv/bin:$PATH
|
|
|
|
ENV PYTHONPATH $PYTHONPATH:/app
|
|
|
|
|
|
|
|
WORKDIR /app
|
|
|
|
COPY pyproject.toml ./
|
2021-06-07 16:30:11 +02:00
|
|
|
COPY contrib/run ./run
|
|
|
|
COPY src ./src/
|
2021-05-29 16:22:13 +02:00
|
|
|
COPY --from=git /version /app/.version
|
|
|
|
|
2021-06-07 16:30:11 +02:00
|
|
|
HEALTHCHECK --start-period=30s CMD python -c "import requests; requests.get('http://localhost:8000', timeout=2)"
|
|
|
|
|
|
|
|
WORKDIR /app/src
|
|
|
|
CMD ["/app/run"]
|