Split production dependecies & update production configuration

This commit is contained in:
Sonny Bakker 2023-06-28 19:38:44 +02:00
parent 0f66c5eb9b
commit 5a73707d61
12 changed files with 68 additions and 111 deletions

View file

@ -4,6 +4,7 @@ FROM python:3.9-bullseye as backend
RUN apt-get update && apt-get install -y --no-install-recommends \
vim \
curl \
gettext \
&& rm -rf /var/lib/apt/lists/*
WORKDIR /app
@ -13,11 +14,11 @@ RUN mkdir /app/media
COPY ./requirements /app/requirements
RUN pip install -r requirements/production.txt
RUN pip install -r requirements/base.txt
# stage 2
FROM node:current-bullseye AS frontend-build
FROM node:16-bullseye AS frontend-build
RUN apt-get update && apt-get install -y --no-install-recommends \
git \
@ -25,7 +26,6 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
WORKDIR /app
COPY ./build /app/build/
COPY ./*.json ./*.js ./.babelrc /app/
RUN npm ci
@ -42,6 +42,7 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
postgresql-client \
vim \
curl \
gettext \
&& rm -rf /var/lib/apt/lists/*
WORKDIR /app
@ -51,32 +52,32 @@ RUN mkdir /app/media
RUN mkdir /app/bin
COPY --from=backend /usr/local/lib/python3.9 /usr/local/lib/python3.9
COPY --from=backend /usr/local/bin/gunicorn /usr/local/bin/gunicorn
COPY --from=backend /usr/local/bin/celery /usr/local/bin/celery
COPY --from=backend /app/src/ /app/src/
COPY ./bin/docker-entrypoint.sh /app/bin/docker-entrypoint.sh
COPY --from=frontend-build /app/src/newsreader/static /app/src/newsreader/static
COPY ./src /app/src
COPY ./requirements /app/requirements
RUN pip install -r requirements/production.txt
RUN useradd -M -u 1000 newsreader
RUN chown -R newsreader:newsreader /app
USER newsreader
ARG COMMIT_HASH
ARG RELEASE=latest
ARG POSTGRES_HOST
ARG POSTGRES_PORT
ARG POSTGRES_DB
ARG POSTGRES_USER
ARG POSTGRES_PASSWORD
ARG DJANGO_SECRET_KEY
ARG DJANGO_SETTINGS_MODULE
ENV RELEASE=${RELEASE} \
GIT_SHA=${COMMIT_HASH} \
PYTHONUNBUFFERED=1 \
DJANGO_SETTINGS_MODULE=newsreader.conf.production
ARG SECRET_KEY=dummy
RUN python src/manage.py collectstatic --noinput \
&& python src/manage.py compilemessages
RUN python src/manage.py collectstatic --noinput
# (optional) stage 4