From fddcbbe8a06a254abac90d41aceba383ab4b7777 Mon Sep 17 00:00:00 2001 From: codl Date: Thu, 4 Aug 2022 20:10:56 +0200 Subject: [PATCH] reorganize dockerfile for better build cache usage also lock some versions ideally I wouldn't have to copy each of these directories separately and have a janky stage to hide all the resulting layers, but docker do be like that. `COPY dir1 dir2 ./` copies *the contents of* dir1 and dir2 to the working directory :( maybe one day i will switch to having a src directory --- Dockerfile | 30 ++++++++++++++++++++++++------ 1 file changed, 24 insertions(+), 6 deletions(-) diff --git a/Dockerfile b/Dockerfile index 8c20100..365b87a 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,14 +1,32 @@ -FROM python:3 AS builder +FROM python:3.10-bullseye AS deps WORKDIR /usr/src/app -COPY . . -# install python stuff -RUN python -m pip install --upgrade pip +RUN python -m pip install --upgrade pip==22.2.2 +RUN apt-get update -qq && apt-get install -qq nodejs npm + +COPY requirements.txt . RUN pip install --no-cache-dir -r requirements.txt -# build assets -RUN apt-get update -qq && apt-get install -qq nodejs npm +COPY package.json package-lock.json ./ RUN npm install --save-dev + + +FROM scratch AS layer-cake +WORKDIR / + +COPY *.py setup.cfg rollup.config.js ./ +COPY assets assets +COPY components components +COPY libforget libforget +COPY migrations migrations +COPY routes routes +COPY static static +COPY templates templates + + +FROM deps + +COPY --from=layer-cake / ./ RUN doit VOLUME ["/var/run/celery"]