2022-07-28 14:42:12 +01:00
|
|
|
FROM node:16 as frontend
|
|
|
|
|
|
|
|
COPY package.json package-lock.json ./
|
2022-08-03 21:51:27 +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
|
|
|
|
FROM python:3.10 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
|
2022-07-28 14:42:12 +01:00
|
|
|
|
|
|
|
WORKDIR /app
|
|
|
|
|
|
|
|
ENV PATH=${POETRY_HOME}/bin:$VIRTUAL_ENV/bin:$PATH \
|
|
|
|
PYTHONUNBUFFERED=1
|
|
|
|
|
|
|
|
EXPOSE 8000
|
|
|
|
|
|
|
|
USER website
|
|
|
|
|
|
|
|
RUN python -m venv $VIRTUAL_ENV
|
2022-07-28 18:55:47 +01:00
|
|
|
COPY --chown=website requirements/base.txt ./requirements/base.txt
|
|
|
|
RUN pip install --upgrade pip && pip install -r ./requirements/base.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
|
|
|
|
|
|
|
|
RUN SECRET_KEY=none python manage.py collectstatic --noinput --clear -v3
|
|
|
|
|
2022-07-29 08:29:50 +01:00
|
|
|
CMD gunicorn -c etc/gunicorn.conf.py
|
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
|
|
|
|
RUN curl -fsSL https://deb.nodesource.com/setup_16.x | bash - && apt-get install -y nodejs
|
2022-07-28 20:50:09 +01:00
|
|
|
RUN 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-07-28 18:55:47 +01:00
|
|
|
COPY --chown=website requirements/dev.txt ./requirements/dev.txt
|
2022-08-03 21:54:56 +01:00
|
|
|
RUN pip install -r requirements/dev.txt
|
2022-07-28 14:42:12 +01:00
|
|
|
|
|
|
|
CMD sleep infinity
|