From cd002d5795dab0414abb098cb044b108d3419c2a Mon Sep 17 00:00:00 2001 From: Benedikt Heine Date: Sun, 24 Aug 2025 14:01:22 +0200 Subject: [PATCH] Improve Dockerfile syntax - Use `set -eux` to have better overview for multi command `RUN`s - Split multiline arguments into one line per argument as defined in dockerfile best practices - Use `export DEBIAN_FRONTEND=noninteractive` just during build. - Make `run.sh` executable, as it's an executable --- Dockerfile | 30 ++++++++++++++++++++---------- run.sh | 0 2 files changed, 20 insertions(+), 10 deletions(-) mode change 100644 => 100755 run.sh diff --git a/Dockerfile b/Dockerfile index 4507c94..f546a29 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,17 +1,24 @@ FROM python:3.9-slim AS builder # Install build dependencies -RUN apt-get update && apt-get install -y --no-install-recommends \ - build-essential \ - libpq-dev \ - gcc \ - && rm -rf /var/lib/apt/lists/* +RUN set -euxo pipefail; \ + export DEBIAN_FRONTEND=noninteractive; \ + apt-get update; \ + apt-get install -y --no-install-recommends \ + build-essential \ + libpq-dev \ + gcc \ + ; WORKDIR /app # Install Python packages COPY requirements.txt . -RUN pip install --upgrade pip setuptools wheel && \ +RUN set -euxo pipefail; \ + pip install --upgrade \ + pip \ + setuptools \ + wheel; \ pip install -r requirements.txt # Final application image @@ -20,12 +27,15 @@ FROM python:3.9-slim AS app WORKDIR /app # Install runtime dependencies -RUN apt-get update && apt-get install -y --no-install-recommends \ - libpq5 \ - && rm -rf /var/lib/apt/lists/* +RUN set -euxo pipefail; \ + export DEBIAN_FRONTEND=noninteractive; \ + apt-get update; \ + apt-get install -y --no-install-recommends \ + libpq5 \ + ; # Copy pre-installed Python packages from builder COPY --from=builder /usr/local /usr/local/ COPY . . -CMD ["/bin/bash", "run.sh"] +CMD ["/app/run.sh"] diff --git a/run.sh b/run.sh old mode 100644 new mode 100755