From cd5616a9868d266fc190141b01a2e40132b305b4 Mon Sep 17 00:00:00 2001 From: jodybro Date: Tue, 12 Dec 2023 19:09:23 -0500 Subject: [PATCH] fine tune cache --- .github/workflows/pipeline.yaml | 12 ++++++++++-- Dockerfile | 17 +++++++++++------ apt-packages.txt | 6 ++++++ 3 files changed, 27 insertions(+), 8 deletions(-) create mode 100644 apt-packages.txt diff --git a/.github/workflows/pipeline.yaml b/.github/workflows/pipeline.yaml index 0a150df..91bf13b 100644 --- a/.github/workflows/pipeline.yaml +++ b/.github/workflows/pipeline.yaml @@ -61,5 +61,13 @@ jobs: tags: ${{ steps.prep.outputs.tagged_image }},${{ steps.prep.outputs.image }}:latest - cache-from: type=gha - cache-to: type=gha,mode=max + cache-from: type=local,src=/tmp/.buildx-cache + cache-to: type=local,dest=/tmp/.buildx-cache-new + + # Temp fix + # https://github.com/docker/build-push-action/issues/252 + # https://github.com/moby/buildkit/issues/1896 + - name: Move cache + run: | + rm -rf /tmp/.buildx-cache + mv /tmp/.buildx-cache-new /tmp/.buildx-cache diff --git a/Dockerfile b/Dockerfile index feb85c9..f5ac513 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,16 +1,21 @@ +# syntax=docker/dockerfile:1.5 FROM python:3.10-slim-bookworm as builder LABEL org=edenartlab WORKDIR /app -ADD . /app -RUN apt-get update --fix-missing +# Copy only the file needed to install apt dependencies. +# This utilizes Docker's cache, because if these files have not changed, +# then we don't need to re-install the dependencies. +COPY apt-packages.txt apt-packages.txt -RUN apt-get install -y --fix-missing \ - git build-essential cmake \ - libgl1-mesa-glx libglib2.0-0 +# No need for 2 layers of apt package installs +RUN apt-get update --fix-missing -y \ + && apt-get install -y --fix-missing $(cat apt-packages.txt) \ + && rm -rf /var/lib/apt/lists/* # Clean up to reduce layer size -RUN pip install --no-cache-dir -r requirements.txt +COPY requirements.txt requirements.txt +RUN --mount=type=cache,target=/root/.cache/pip pip install -r requirements.txt RUN gdown 1Pm2apRxk9CbMspwve3Fir3WwX-vDWXoL diff --git a/apt-packages.txt b/apt-packages.txt new file mode 100644 index 0000000..2cbffd8 --- /dev/null +++ b/apt-packages.txt @@ -0,0 +1,6 @@ +git +build-essential +cmake +libgl1-mesa-glx +libglib2.0-0 +