From c82c15e0da1d5f19675479ed1148c66373aa2d8f Mon Sep 17 00:00:00 2001 From: codl Date: Fri, 5 Aug 2022 02:19:51 +0200 Subject: [PATCH] further dockerfile caching and size optim nodejs and js libraries are only needed at build time --- Dockerfile | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/Dockerfile b/Dockerfile index 38e6515..261d339 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,14 +1,19 @@ -FROM python:3.10-bullseye AS deps +FROM python:3.10.6-bullseye AS pydeps WORKDIR /usr/src/app 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 + +FROM pydeps AS pynodedeps + +RUN apt-get update -qq && apt-get install -qq nodejs npm \ + && rm -rf /var/lib/apt/lists/* + COPY package.json package-lock.json ./ -RUN npm install --save-dev +RUN npm clean-install FROM scratch AS layer-cake @@ -24,11 +29,15 @@ COPY static static COPY templates templates -FROM deps +FROM pynodedeps AS build COPY --from=layer-cake / ./ RUN doit +FROM pydeps + +COPY --from=build /usr/src/app ./ + ENV FLASK_APP=forget.py VOLUME ["/var/run/celery"]