2023-08-19 13:40:20 +01:00
|
|
|
FROM node:20-slim as frontend
|
2022-07-28 14:42:12 +01:00
|
|
|
|
2023-07-16 16:22:35 +01:00
|
|
|
RUN apt-get update --yes --quiet && apt-get install --yes --quiet curl
|
|
|
|
|
2022-07-28 14:42:12 +01:00
|
|
|
COPY package.json package-lock.json ./
|
2022-08-27 18:22:58 +01:00
|
|
|
RUN npm ci --no-audit - -progress=false --omit=dev
|
2022-07-28 14:42:12 +01:00
|
|
|
|
|
|
|
# Compile static files
|
|
|
|
COPY ./scripts ./scripts
|
|
|
|
COPY ./static/src ./static/src
|
|
|
|
RUN npm run build
|
|
|
|
|
|
|
|
# The actual container
|
2024-01-11 09:26:39 +00:00
|
|
|
FROM python:3.12-slim as production
|
2022-07-28 14:42:12 +01:00
|
|
|
|
|
|
|
ENV VIRTUAL_ENV=/venv
|
|
|
|
|
2024-04-07 15:38:01 +01:00
|
|
|
# renovate: datasource=github-tags depName=just-containers/s6-overlay
|
2024-01-13 21:43:10 +00:00
|
|
|
ENV S6_OVERLAY_VERSION=3.1.6.2
|
|
|
|
|
2022-07-28 18:22:07 +01:00
|
|
|
RUN useradd website --create-home -u 1000 && mkdir /app $VIRTUAL_ENV && chown -R website /app $VIRTUAL_ENV
|
2022-07-28 14:42:12 +01:00
|
|
|
|
|
|
|
WORKDIR /app
|
|
|
|
|
2022-08-27 18:22:58 +01:00
|
|
|
RUN apt-get update --yes --quiet && apt-get install --yes --quiet --no-install-recommends \
|
|
|
|
build-essential \
|
|
|
|
libpq-dev \
|
2022-08-27 20:22:20 +01:00
|
|
|
curl \
|
2022-09-29 19:12:21 +01:00
|
|
|
git \
|
2023-02-21 21:41:31 +00:00
|
|
|
nginx \
|
2023-11-23 13:54:57 +00:00
|
|
|
libnginx-mod-http-headers-more-filter \
|
2022-09-29 19:12:21 +01:00
|
|
|
# wand dependencies
|
2022-09-30 16:04:52 +01:00
|
|
|
libmagickwand-6.q16-6 libmagickwand-6.q16hdri-6 \
|
|
|
|
&& apt-get autoremove && rm -rf /var/lib/apt/lists/*
|
2022-08-27 18:22:58 +01:00
|
|
|
|
|
|
|
RUN curl -fsSL https://github.com/aptible/supercronic/releases/download/v0.2.1/supercronic-linux-amd64 -o /usr/local/bin/supercronic && chmod +x /usr/local/bin/supercronic
|
2024-01-13 21:43:10 +00:00
|
|
|
ADD https://github.com/just-containers/s6-overlay/releases/download/v${S6_OVERLAY_VERSION}/s6-overlay-noarch.tar.xz /tmp
|
|
|
|
ADD https://github.com/just-containers/s6-overlay/releases/download/v${S6_OVERLAY_VERSION}/s6-overlay-x86_64.tar.xz /tmp
|
|
|
|
RUN tar -C / -Jxpf /tmp/s6-overlay-noarch.tar.xz && tar -C / -Jxpf /tmp/s6-overlay-x86_64.tar.xz
|
2022-08-20 20:48:27 +01:00
|
|
|
|
2022-08-27 15:11:18 +01:00
|
|
|
ENV PATH=$VIRTUAL_ENV/bin:$PATH \
|
2024-10-01 20:46:10 +01:00
|
|
|
PYTHONUNBUFFERED=1 \
|
|
|
|
GRANIAN_INTERFACE=wsgi \
|
|
|
|
GRANIAN_HOST=0.0.0.0 \
|
|
|
|
GRANIAN_PORT=8080 \
|
|
|
|
GRANIAN_WORKERS_LIFETIME=1800 \
|
|
|
|
GRANIAN_RESPAWN_INTERVAL=10 \
|
|
|
|
GRANIAN_PROCESS_NAME=website \
|
|
|
|
GRANIAN_RESPAWN_FAILED_WORKERS=1
|
2022-07-28 14:42:12 +01:00
|
|
|
|
|
|
|
EXPOSE 8000
|
|
|
|
|
2024-01-14 12:59:31 +00:00
|
|
|
RUN ln -fs /app/etc/nginx.conf /etc/nginx/sites-available/default && chown -R website /var/log/nginx
|
2023-02-21 21:41:31 +00:00
|
|
|
|
2022-07-28 14:42:12 +01:00
|
|
|
USER website
|
|
|
|
|
|
|
|
RUN python -m venv $VIRTUAL_ENV
|
2022-11-03 13:54:31 +00:00
|
|
|
COPY --chown=website requirements.txt ./
|
2022-09-19 21:34:27 +01:00
|
|
|
|
2022-11-03 13:54:31 +00:00
|
|
|
RUN pip install --no-cache -r requirements.txt
|
2022-07-28 14:42:12 +01:00
|
|
|
|
|
|
|
COPY --chown=website --from=frontend ./static/build ./static/build
|
|
|
|
|
2022-07-29 08:29:50 +01:00
|
|
|
COPY --chown=website ./etc ./etc
|
2022-07-28 14:42:12 +01:00
|
|
|
COPY --chown=website ./manage.py ./manage.py
|
|
|
|
COPY --chown=website ./website ./website
|
|
|
|
|
2023-10-27 17:37:58 +01:00
|
|
|
RUN cat ./etc/bashrc.sh >> ~/.bashrc
|
|
|
|
|
2022-10-30 19:16:25 +00:00
|
|
|
RUN SECRET_KEY=none python manage.py collectstatic --noinput --clear
|
2022-07-28 14:42:12 +01:00
|
|
|
|
2024-01-13 21:43:10 +00:00
|
|
|
COPY ./etc/s6-rc.d /etc/s6-overlay/s6-rc.d
|
|
|
|
|
|
|
|
ENTRYPOINT [ "/init" ]
|
2022-07-28 14:53:22 +01:00
|
|
|
|
2022-07-28 14:42:12 +01:00
|
|
|
# Just dev stuff
|
|
|
|
FROM production as dev
|
|
|
|
|
|
|
|
# Swap user, so the following tasks can be run as root
|
|
|
|
USER root
|
2023-10-27 17:37:58 +01:00
|
|
|
|
2024-01-13 17:49:51 +00:00
|
|
|
RUN curl -fsSL https://deb.nodesource.com/setup_20.x | bash - && apt-get install -y nodejs
|
2023-10-27 17:37:58 +01:00
|
|
|
RUN apt-get update --yes --quiet && apt-get install -y postgresql-client inotify-tools
|
2022-07-28 14:42:12 +01:00
|
|
|
RUN curl -sSf https://just.systems/install.sh | bash -s -- --to /usr/bin
|
|
|
|
|
|
|
|
# Restore user
|
|
|
|
USER website
|
|
|
|
|
2022-11-03 13:54:31 +00:00
|
|
|
COPY --chown=website dev-requirements.txt ./
|
|
|
|
RUN pip install --no-cache -r dev-requirements.txt
|
2022-07-28 14:42:12 +01:00
|
|
|
|
2024-01-13 21:43:10 +00:00
|
|
|
ENTRYPOINT []
|
2022-07-28 14:42:12 +01:00
|
|
|
CMD sleep infinity
|