From 3943a8b291dfd08f7c0929e70894022a38d2cbf5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Anthony=20Su=C3=A1rez?= Date: Thu, 29 Sep 2022 22:08:55 -0500 Subject: [PATCH 1/3] Use Debian Slim Bullseye as the Docker image's base --- Dockerfile | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/Dockerfile b/Dockerfile index 911fe699..5c6603f4 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,18 +1,13 @@ -FROM python:3.7-alpine as build +FROM python:3.7-slim-bullseye as build WORKDIR /wheels -RUN apk add --no-cache \ - g++ \ - gcc \ - git \ - libxml2 \ - libxml2-dev \ - libxslt-dev \ - linux-headers + +RUN apt-get update && apt-get install -y build-essential + COPY requirements.txt /opt/sherlock/ RUN pip3 wheel -r /opt/sherlock/requirements.txt -FROM python:3.7-alpine +FROM python:3.7-slim-bullseye WORKDIR /opt/sherlock ARG VCS_REF ARG VCS_URL="https://github.com/sherlock-project/sherlock" From 0f62137b496375984fa0bcb9e26b4731dabc01d5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Anthony=20Su=C3=A1rez?= Date: Thu, 29 Sep 2022 22:10:06 -0500 Subject: [PATCH 2/3] Add newlines to Dockerfile to improve readability --- Dockerfile | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Dockerfile b/Dockerfile index 5c6603f4..5d797e03 100644 --- a/Dockerfile +++ b/Dockerfile @@ -9,15 +9,20 @@ RUN pip3 wheel -r /opt/sherlock/requirements.txt FROM python:3.7-slim-bullseye WORKDIR /opt/sherlock + ARG VCS_REF ARG VCS_URL="https://github.com/sherlock-project/sherlock" + LABEL org.label-schema.vcs-ref=$VCS_REF \ org.label-schema.vcs-url=$VCS_URL + COPY --from=build /wheels /wheels COPY . /opt/sherlock/ + RUN pip3 install -r requirements.txt -f /wheels \ && rm -rf /wheels \ && rm -rf /root/.cache/pip/* + WORKDIR /opt/sherlock/sherlock ENTRYPOINT ["python", "sherlock.py"] From d0a1549467ead1866a1e0e90511e8f1be346b3ea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Anthony=20Su=C3=A1rez?= Date: Sat, 1 Oct 2022 07:00:29 -0500 Subject: [PATCH 3/3] Install Docker packages with --no-cache-dir Pip has a "--no-cache-dir" argument to disable caching, eliminating the need of deleting the cache with a hard-coded path. --- Dockerfile | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/Dockerfile b/Dockerfile index 5d797e03..22790dd0 100644 --- a/Dockerfile +++ b/Dockerfile @@ -19,9 +19,8 @@ LABEL org.label-schema.vcs-ref=$VCS_REF \ COPY --from=build /wheels /wheels COPY . /opt/sherlock/ -RUN pip3 install -r requirements.txt -f /wheels \ - && rm -rf /wheels \ - && rm -rf /root/.cache/pip/* +RUN pip3 install --no-cache-dir -r requirements.txt -f /wheels \ + && rm -rf /wheels WORKDIR /opt/sherlock/sherlock