Fix docker images

This commit is contained in:
Sonny Bakker 2024-08-24 15:14:04 +02:00
parent 1b8b9dcd41
commit 67d7b10632

View file

@ -1,5 +1,5 @@
# stage 1 # stage 1
FROM python:3.11-bookworm as backend FROM python:3.11-bookworm AS backend
RUN apt-get update && apt-get install --yes --no-install-recommends \ RUN apt-get update && apt-get install --yes --no-install-recommends \
vim \ vim \
@ -14,8 +14,8 @@ RUN mkdir /app/media
COPY ./requirements /app/requirements COPY ./requirements /app/requirements
RUN pip install uv COPY --from=ghcr.io/astral-sh/uv:latest /uv /bin/uv
RUN uv pip install --requirement requirements/base.txt RUN uv pip install --system --requirement requirements/base.txt
# stage 2 # stage 2
@ -33,7 +33,7 @@ RUN npm run build:prod
# stage 3 # stage 3
FROM python:3.11-bookworm as production FROM python:3.11-bookworm AS production
RUN apt-get update && apt-get install --yes --no-install-recommends \ RUN apt-get update && apt-get install --yes --no-install-recommends \
postgresql-client \ postgresql-client \
@ -59,7 +59,8 @@ COPY ./src /app/src
COPY ./requirements /app/requirements COPY ./requirements /app/requirements
RUN uv pip install --requirement requirements/production.txt COPY --from=backend /bin/uv /bin/uv
RUN uv pip install --system --requirement requirements/production.txt
RUN useradd -M -u 1000 newsreader RUN useradd -M -u 1000 newsreader
RUN chown -R newsreader:newsreader /app RUN chown -R newsreader:newsreader /app
@ -81,7 +82,7 @@ RUN python src/manage.py collectstatic --noinput
# (optional) stage 4 # (optional) stage 4
FROM python:3.11-bookworm as development FROM python:3.11-bookworm AS development
RUN apt-get update && apt-get install --yes --no-install-recommends \ RUN apt-get update && apt-get install --yes --no-install-recommends \
vim \ vim \
@ -96,11 +97,12 @@ RUN mkdir /app/bin
COPY ./requirements /app/requirements COPY ./requirements /app/requirements
COPY ./bin/docker-entrypoint.sh /app/bin/docker-entrypoint.sh COPY ./bin/docker-entrypoint.sh /app/bin/docker-entrypoint.sh
COPY --from=backend /usr/local/lib/python3.9 /usr/local/lib/python3.9 COPY --from=backend /usr/local/lib/python3.11 /usr/local/lib/python3.11
COPY --from=backend /usr/local/bin/celery /usr/local/bin/celery COPY --from=backend /usr/local/bin/celery /usr/local/bin/celery
COPY --from=backend /app/src/ /app/src/ COPY --from=backend /app/src/ /app/src/
RUN uv pip install --requirement requirements/development.txt COPY --from=backend /bin/uv /bin/uv
RUN uv pip install --system --requirement requirements/development.txt
RUN useradd -M -u 1000 newsreader RUN useradd -M -u 1000 newsreader
RUN chown -R newsreader:newsreader /app RUN chown -R newsreader:newsreader /app