Skip to content

Commit

Permalink
Use alpine base image (#3540)
Browse files Browse the repository at this point in the history
* alpine base-image added

* Cache the apk cache directory

---------

Co-authored-by: Dirk Doesburg <[email protected]>
  • Loading branch information
T8902 and DeD1rk authored Jan 19, 2024
1 parent 97d4b52 commit df774c0
Showing 1 changed file with 31 additions and 10 deletions.
41 changes: 31 additions & 10 deletions infra/concrexit/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM python:3.11-slim-bullseye AS base
FROM python:3.11-alpine AS base

ENV PYTHONDONTWRITEBYTECODE=1 \
PYTHONUNBUFFERED=1 \
Expand All @@ -16,9 +16,9 @@ ENV PIP_DISABLE_PIP_VERSION_CHECK=1 \

RUN pip install "poetry==1.3.1" && pip install --upgrade setuptools

RUN apt-get update && \
apt-get install -y --no-install-recommends \
build-essential libpq-dev libjpeg-dev zlib1g-dev libwebp-dev libmagic1
RUN --mount=type=cache,target=/var/cache/apk \
apk update && apk add \
build-base libpq-dev jpeg-dev zlib-dev libwebp-dev libmagic

RUN python -m venv /venv
ENV PATH=/venv/bin:$PATH \
Expand All @@ -32,10 +32,32 @@ ARG WITH_DEV
RUN if [ "$WITH_DEV" = "1" ]; then poetry install --only dev --only scss; fi


FROM build-venv as build-scss
FROM python:3.11-slim-bookworm as build-scss
# This stage builds the SASS, using dependencies that are not needed in the final image.
ENV PYTHONDONTWRITEBYTECODE=1 \
PYTHONUNBUFFERED=1 \
DJANGO_ENV=production \
TZ=Europe/Amsterdam

WORKDIR /app

ENV PIP_DISABLE_PIP_VERSION_CHECK=1 \
PIP_NO_CACHE_DIR=1

RUN pip install "poetry==1.3.1" && pip install --upgrade setuptools


RUN --mount=type=cache,target=/var/cache/apt \
apt-get update && apt-get install -y --no-install-recommends \
build-essential libpq-dev libmagic1

RUN python -m venv /venv
ENV PATH=/venv/bin:$PATH \
VIRTUAL_ENV=/venv

COPY pyproject.toml poetry.lock ./

RUN poetry install --only main --only postgres --only scss
RUN poetry install --only main --only postgres --only scss

COPY website /app/website

Expand All @@ -55,10 +77,9 @@ ENV PATH=/venv/bin:$PATH \
SENDFILE_ROOT="/volumes/media"

# Install runtime dependencies.
RUN apt-get update && \
apt-get install -y --no-install-recommends \
postgresql-client libjpeg-dev zlib1g-dev libwebp-dev libmagic1 && \
rm -rf /var/lib/apt/lists/*
RUN --mount=type=cache,target=/var/cache/apk\
apk update && apk add \
postgresql-client jpeg-dev zlib-dev libwebp-dev libmagic runuser


COPY infra/concrexit/server-entrypoint.sh /app/server-entrypoint.sh
Expand Down

0 comments on commit df774c0

Please sign in to comment.