From 6f39407a8cea47a81377d71324ef4706325c2d62 Mon Sep 17 00:00:00 2001 From: Daniel Thamdrup Date: Wed, 13 Mar 2024 02:02:26 +0100 Subject: [PATCH] use alpine, reduce layers (#249) Signed-off-by: Daniel Thamdrup --- Dockerfile | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/Dockerfile b/Dockerfile index 26f7323..f572b5a 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,16 +1,19 @@ -FROM python:3-slim +# syntax=docker/dockerfile:latest +FROM scratch AS files -WORKDIR / +# Copy ssh-audit code to temporary container +COPY ssh-audit.py / +COPY src/ / + +FROM python:3-alpine AS runtime # Update the image to remediate any vulnerabilities. -RUN apt update && apt -y upgrade && apt -y dist-upgrade && rm -rf /var/lib/apt/lists/* +RUN apk upgrade -U --no-cache -a -l && \ + # Remove suid & sgid bits from all files. + find / -xdev -perm /6000 -exec chmod ug-s {} \; 2> /dev/null || true -# Remove suid & sgid bits from all files. -RUN find / -xdev -perm /6000 -exec chmod ug-s {} \; 2> /dev/null || true - -# Copy the ssh-audit code. -COPY ssh-audit.py . -COPY src/ . +# Copy the ssh-audit code from files container. +COPY --from=files / / # Allow listening on 2222/tcp for client auditing. EXPOSE 2222