From 423e6e093987db0b38b86f1b22f7442539c9e020 Mon Sep 17 00:00:00 2001 From: Ivan Cvitkovic Date: Mon, 20 Nov 2023 11:35:47 -0800 Subject: [PATCH] Cache Unchanged Layers (#50) * Fixup default branch * Prevent build version from invalidating cached pip installs * Reuse unchanged image layers when building on CI --- .github/workflows/build-deliver.yaml | 4 +++- Dockerfile | 6 +++--- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/.github/workflows/build-deliver.yaml b/.github/workflows/build-deliver.yaml index 504507b6..08a18880 100644 --- a/.github/workflows/build-deliver.yaml +++ b/.github/workflows/build-deliver.yaml @@ -19,7 +19,7 @@ jobs: - name: Publish to GitHub Container Registry # TODO: pin to hash - uses: elgohr/Publish-Docker-Github-Action@master + uses: elgohr/Publish-Docker-Github-Action@main with: name: ${{ github.repository }} registry: ghcr.io @@ -33,3 +33,5 @@ jobs: # create docker image tags to match git tags tag_names: true buildargs: VERSION_STRING + # cache layers that have not changed between builds (eg dependencies) + cache: true diff --git a/Dockerfile b/Dockerfile index cf42517a..17672847 100644 --- a/Dockerfile +++ b/Dockerfile @@ -2,14 +2,14 @@ FROM python:3.7 WORKDIR /opt/app -ARG VERSION_STRING -ENV VERSION_STRING=$VERSION_STRING - COPY requirements.txt . RUN pip install --requirement requirements.txt COPY . . +ARG VERSION_STRING +ENV VERSION_STRING=$VERSION_STRING + ENV FLASK_APP=isacc_messaging.app:create_app() \ PORT=8000