2020-11-11 09:38:37 +01:00
|
|
|
## Build venv
|
2021-12-19 20:40:51 +01:00
|
|
|
FROM python:3.10.1-bullseye AS venv
|
2020-11-11 09:38:37 +01:00
|
|
|
|
|
|
|
# https://python-poetry.org/docs/#installation
|
2021-12-19 21:22:34 +01:00
|
|
|
ENV POETRY_VERSION=1.1.11
|
|
|
|
RUN curl -sSL https://raw.githubusercontent.com/python-poetry/poetry/master/install-poetry.py | python -
|
2020-11-11 09:38:37 +01:00
|
|
|
|
2021-12-19 21:22:34 +01:00
|
|
|
ENV PATH /root/.local/bin:$PATH
|
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
|
2021-12-19 21:22:34 +01:00
|
|
|
FROM alpine/git 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
|
2021-12-19 20:40:51 +01:00
|
|
|
FROM python:3.10.1-slim-bullseye as prod
|
2020-11-11 09:38:37 +01:00
|
|
|
|
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
|
2021-12-19 21:41:20 +01:00
|
|
|
COPY LICENSE pyproject.toml ./
|
2020-08-17 08:23:00 +02:00
|
|
|
COPY docker ./docker/
|
2021-12-19 21:41:20 +01:00
|
|
|
COPY src ./src/
|
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 DB_BASE_DIR "/db"
|
2021-01-05 18:28:32 +01:00
|
|
|
#ENV HOSTS="host1;host2"
|
|
|
|
#ENV ADMINS='Full Name,email@example.com'
|
|
|
|
#ENV MAILGUN_API_KEY='key-yourapikey'
|
|
|
|
#ENV MAILGUN_SENDER_DOMAIN='mailgun.example.com'
|
|
|
|
#ENV BLOG_BASE_URL='https://url-of-your-blog.example.com'
|
|
|
|
#ENV SHORTPIXEL_API_KEY='YOURAPIKEY'
|
|
|
|
#ENV SHORTPIXEL_RESIZE_WIDTH='750'
|
|
|
|
#ENV SHORTPIXEL_RESIZE_HEIGHT='10000'
|
|
|
|
#ENV GOATCOUNTER_DOMAIN='blog.goatcounter.example.com'
|
|
|
|
#ENV MEMCACHED_LOCATION='memcached:11211'
|
2020-08-17 08:23:00 +02:00
|
|
|
|
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
|
|
|
|
2021-12-19 21:52:20 +01:00
|
|
|
WORKDIR /app/src
|
2020-08-17 08:23:00 +02:00
|
|
|
CMD ["/app/docker/run.sh"]
|