website/Dockerfile

74 lines
2 KiB
Text
Raw Normal View History

2023-10-20 08:01:31 +01:00
FROM node:21-slim as frontend
2023-07-16 16:22:35 +01:00
RUN apt-get update --yes --quiet && apt-get install --yes --quiet curl
COPY package.json package-lock.json ./
RUN npm ci --no-audit - -progress=false --omit=dev
# Compile static files
COPY ./scripts ./scripts
COPY ./static/src ./static/src
RUN npm run build
# The actual container
2023-01-11 08:43:45 +00:00
FROM python:3.11-slim as production
ENV VIRTUAL_ENV=/venv
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
WORKDIR /app
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 \
git \
nginx \
# 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/*
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
2022-08-27 15:11:18 +01:00
ENV PATH=$VIRTUAL_ENV/bin:$PATH \
PYTHONUNBUFFERED=1
EXPOSE 8000
RUN ln -fs /app/etc/nginx.conf /etc/nginx/sites-available/default
USER website
RUN python -m venv $VIRTUAL_ENV
COPY --chown=website requirements.txt ./
RUN pip install --no-cache -r requirements.txt
COPY --chown=website --from=frontend ./static/build ./static/build
2022-07-29 08:29:50 +01:00
COPY --chown=website ./etc ./etc
COPY --chown=website ./manage.py ./manage.py
COPY --chown=website ./website ./website
RUN SECRET_KEY=none python manage.py collectstatic --noinput --clear
CMD ["/app/etc/entrypoints/web"]
# Just dev stuff
FROM production as dev
# Swap user, so the following tasks can be run as root
USER root
2023-08-19 13:40:20 +01:00
RUN curl -fsSL https://deb.nodesource.com/setup_20.x | bash - && apt-get install -y nodejs
2022-07-28 20:50:09 +01:00
RUN apt-get install -y postgresql-client inotify-tools
RUN curl -sSf https://just.systems/install.sh | bash -s -- --to /usr/bin
# Restore user
USER website
COPY --chown=website dev-requirements.txt ./
RUN pip install --no-cache -r dev-requirements.txt
CMD sleep infinity