From 05e1d82cd20d703ce837bea6f3d0e40f77375670 Mon Sep 17 00:00:00 2001 From: morph027 Date: Sun, 9 Jul 2023 22:29:11 +0200 Subject: [PATCH 1/3] reduce docker image size Signed-off-by: morph027 --- Dockerfile | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/Dockerfile b/Dockerfile index ba9408e..d56cb54 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,15 +1,20 @@ -FROM python:3-slim +FROM python:3-alpine as builder -RUN apt-get update && apt-get install -y build-essential python3-dev && rm -rf /var/lib/apt/lists/* - -RUN useradd sungather - -WORKDIR /usr/src/sungather +RUN python3 -m venv /opt/virtualenv \ + && apk --no-cache add \ + build-base COPY requirements.txt ./ # pycryptodomex 3.14 currently fails to compile for arm64 -#RUN pip install --no-cache-dir --upgrade -r requirements.txt -RUN pip install --no-cache-dir --upgrade pycryptodomex==3.11.0 -r requirements.txt +RUN /opt/virtualenv/bin/pip3 install --no-cache-dir --upgrade pycryptodomex==3.11.0 -r requirements.txt + +FROM python:3-alpine + +RUN adduser -S -H sungather + +COPY --from=builder /opt/virtualenv /opt/virtualenv + +WORKDIR /opt/sungather COPY SunGather/ . @@ -19,4 +24,4 @@ COPY SunGather/config-example.yaml /config/config.yaml USER sungather -CMD [ "python", "sungather.py", "-c", "/config/config.yaml", "-l", "/logs/" ] \ No newline at end of file +CMD [ "/opt/virtualenv/bin/python", "sungather.py", "-c", "/config/config.yaml", "-l", "/logs/" ] From 9545edf95487576d1319bcc4613ad5662b0c39e0 Mon Sep 17 00:00:00 2001 From: morph027 Date: Mon, 10 Jul 2023 20:24:19 +0200 Subject: [PATCH 2/3] use python:3-slim Signed-off-by: morph027 --- Dockerfile | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/Dockerfile b/Dockerfile index d56cb54..04f5854 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,16 +1,16 @@ -FROM python:3-alpine as builder +FROM python:3 as builder RUN python3 -m venv /opt/virtualenv \ - && apk --no-cache add \ - build-base + && apt-get update \ + && apt-get install build-essential COPY requirements.txt ./ # pycryptodomex 3.14 currently fails to compile for arm64 RUN /opt/virtualenv/bin/pip3 install --no-cache-dir --upgrade pycryptodomex==3.11.0 -r requirements.txt -FROM python:3-alpine +FROM python:3-slim -RUN adduser -S -H sungather +RUN useradd -r -m sungather COPY --from=builder /opt/virtualenv /opt/virtualenv From c0507cb5938fd57ff2c8a4c962c45dde405bf153 Mon Sep 17 00:00:00 2001 From: bohdan-s Date: Fri, 5 Apr 2024 13:54:02 +1100 Subject: [PATCH 3/3] Update Dockerfile Use pycryptodomex 3.20 now --- Dockerfile | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index 04f5854..47d8b7f 100644 --- a/Dockerfile +++ b/Dockerfile @@ -5,8 +5,7 @@ RUN python3 -m venv /opt/virtualenv \ && apt-get install build-essential COPY requirements.txt ./ -# pycryptodomex 3.14 currently fails to compile for arm64 -RUN /opt/virtualenv/bin/pip3 install --no-cache-dir --upgrade pycryptodomex==3.11.0 -r requirements.txt +RUN /opt/virtualenv/bin/pip3 install --no-cache-dir -r requirements.txt FROM python:3-slim