This repository has been archived on 2023-05-31. You can view files and clone it, but cannot push or open issues or pull requests.
python-blog/Dockerfile

62 lines
1.4 KiB
Docker
Raw Normal View History

2020-11-11 09:38:37 +01:00
## Build venv
FROM python:3.8.6-buster AS venv
# https://python-poetry.org/docs/#installation
2020-12-26 16:49:47 +01:00
ENV POETRY_VERSION=1.1.4
2020-11-11 09:38:37 +01:00
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
2020-12-26 16:49:47 +01:00
ARG POETRY_OPTIONS
2020-11-11 09:38:37 +01:00
WORKDIR /app
2021-01-05 02:36:20 +01:00
RUN apt-get update \
&& apt-get install -y --no-install-recommends \
libmemcached-dev
2020-11-11 09:38:37 +01:00
COPY pyproject.toml poetry.lock ./
2020-12-26 16:49:47 +01:00
2020-11-11 09:38:37 +01:00
RUN python -m venv --copies /app/venv \
&& . /app/venv/bin/activate \
&& poetry config cache-dir /app/poetry-cache \
2020-12-26 16:49:47 +01:00
&& poetry install $POETRY_OPTIONS
2020-11-11 09:38:37 +01:00
## Get git versions
2020-11-11 08:52:48 +01:00
FROM alpine/git:v2.26.2 AS git
2020-09-09 18:32:46 +02:00
ADD . /app
WORKDIR /app
RUN git rev-parse HEAD | tee /version
2020-08-17 08:23:00 +02:00
2020-11-11 09:38:37 +01:00
## Beginning of runtime image
FROM python:3.8.6-slim-buster as prod
2020-12-26 17:11:43 +01:00
RUN echo "Europe/Paris" > /etc/timezone \
2020-11-11 09:38:37 +01:00
&& mkdir /db
2021-01-05 02:36:20 +01:00
RUN apt-get update \
&& apt-get install -y --no-install-recommends \
libmemcached-dev
2020-11-11 09:38:37 +01:00
COPY --from=venv /app/venv /app/venv/
ENV PATH /app/venv/bin:$PATH
2020-08-17 12:51:21 +02:00
2020-08-17 08:23:00 +02:00
WORKDIR /app
2020-12-26 17:11:43 +01:00
COPY manage.py LICENSE pyproject.toml ./
2020-08-17 08:23:00 +02:00
COPY docker ./docker/
COPY blog ./blog/
2020-08-27 22:28:14 +02:00
COPY attachments ./attachments/
COPY articles ./articles/
2020-09-09 18:32:46 +02:00
COPY --from=git /version /app/.version
2020-08-17 08:23:00 +02:00
ENV SECRET_KEY "changeme"
ENV DEBUG "false"
ENV HOST ""
ENV DB_BASE_DIR "/db"
2020-11-11 09:38:37 +01:00
HEALTHCHECK --start-period=30s CMD python -c "import requests; requests.get('http://localhost:8000', timeout=2)"
2020-08-17 08:23:00 +02:00
CMD ["/app/docker/run.sh"]