From af9faea197a40b41f83b408fcbb5235de30f4fd4 Mon Sep 17 00:00:00 2001 From: Tobias Brunner Date: Tue, 10 Sep 2024 21:37:11 +0200 Subject: [PATCH] use alpine to lower the image size --- Dockerfile.contactform | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/Dockerfile.contactform b/Dockerfile.contactform index 0984035..ddc49c1 100644 --- a/Dockerfile.contactform +++ b/Dockerfile.contactform @@ -1,5 +1,5 @@ ### BUILDER -FROM python:3.12-bookworm as builder +FROM python:3.12-alpine as builder RUN pip install poetry==1.8.3 @@ -16,13 +16,14 @@ RUN touch README.md RUN --mount=type=cache,target=$POETRY_CACHE_DIR poetry install --no-root ### RUNTIME -FROM python:3.12-bookworm as runtime +FROM python:3.12-alpine as runtime WORKDIR /app -RUN apt-get update && \ - apt-get install -y nginx chromium dbus && \ - rm -rf /var/lib/apt/lists/* +RUN apk upgrade --no-cache --available \ + && apk add --no-cache \ + chromium-swiftshader \ + nginx ENV VIRTUAL_ENV=/app/.venv \ PATH="/app/.venv/bin:$PATH" \ @@ -35,9 +36,8 @@ COPY contactform ./contactform COPY nginx.conf /etc/nginx/nginx.conf RUN set -x && \ - useradd -ms /bin/bash contactform && \ + adduser -D contactform && \ mkdir -p /opt/data && \ - ls -Alh /opt/data && \ chown -R contactform:root /app /opt/data /var/log/nginx /var/lib/nginx && \ chmod -R g=u /app /opt/data /var/log/nginx /var/lib/nginx