From 34e0b0fd67fdb644c75a931ede0ffdc666c32f34 Mon Sep 17 00:00:00 2001 From: krateng Date: Thu, 10 Mar 2022 07:00:08 +0100 Subject: [PATCH] Reworked Dockerfile --- dev/templates/Dockerfile.jinja | 25 +++++++++++++++++-------- dev/update_dist_files.py | 2 ++ 2 files changed, 19 insertions(+), 8 deletions(-) diff --git a/dev/templates/Dockerfile.jinja b/dev/templates/Dockerfile.jinja index a14d978..155c6a8 100644 --- a/dev/templates/Dockerfile.jinja +++ b/dev/templates/Dockerfile.jinja @@ -1,24 +1,33 @@ -FROM python:3-alpine +FROM alpine:3.15 +# Python image includes two Python versions, so use base Alpine # Based on the work of Jonathan Boeckel -# https://gitlab.com/Joniator/docker-maloja -# https://github.com/Joniator WORKDIR /usr/src/app -# this should change rarely, can be cached +# Install run dependencies first +RUN apk add --no-cache {{ tool.osreqs.alpine.run | join(' ') }} + +# system pip could be removed after build, but apk then decides to also remove all its +# python dependencies, even if they are explicitly installed as python packages +# whut +RUN \ + apk add py3-pip && \ + pip install wheel + COPY ./requirements.txt ./requirements.txt -# Install everything before copying rest of the project, can be cached RUN \ apk add --no-cache --virtual .build-deps {{ tool.osreqs.alpine.build | join(' ') }} && \ - apk add --no-cache {{ tool.osreqs.alpine.run | join(' ') }} && \ - pip3 install --no-cache-dir -r requirements.txt && \ + pip install --no-cache-dir -r requirements.txt && \ apk del .build-deps +# no chance for caching below here + COPY . . -RUN pip3 install /usr/src/app + +RUN pip install /usr/src/app # Docker-specific configuration and default to IPv4 ENV MALOJA_SKIP_SETUP=yes diff --git a/dev/update_dist_files.py b/dev/update_dist_files.py index 08c2132..adf941e 100644 --- a/dev/update_dist_files.py +++ b/dev/update_dist_files.py @@ -12,6 +12,8 @@ for root,dirs,files in os.walk(templatedir): relpath = os.path.relpath(root,start=templatedir) for f in files: + if not f.endswith('.jinja'): continue + srcfile = os.path.join(root,f) trgfile = os.path.join(relpath,f.replace(".jinja",""))