invidious-companion-patches/patches/0014-ci-improve-container-image-build-times.patch

52 lines
1.6 KiB
Diff

From c602b6acca506dc354283cae1f13f30c0d5829f7 Mon Sep 17 00:00:00 2001
From: Fijxu <fijxu@nadeko.net>
Date: Tue, 15 Apr 2025 19:20:52 -0400
Subject: [PATCH 14/14] ci: improve container image build times
---
.github/workflows/docker-build-push.yaml | 2 ++
Dockerfile | 11 ++++++++---
2 files changed, 10 insertions(+), 3 deletions(-)
diff --git a/.github/workflows/docker-build-push.yaml b/.github/workflows/docker-build-push.yaml
index 8a79d77..69561fa 100644
--- a/.github/workflows/docker-build-push.yaml
+++ b/.github/workflows/docker-build-push.yaml
@@ -70,3 +70,5 @@ jobs:
platforms: linux/amd64,linux/arm64 # Build for multiple architectures
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
+ cache-from: type=gha
+ cache-to: type=gha,mode=max
diff --git a/Dockerfile b/Dockerfile
index 370678d..3a573b7 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -11,9 +11,6 @@ RUN mkdir -p /var/tmp/youtubei.js
RUN apt update && apt install -y curl
-COPY ./src/ /app/src/
-COPY deno.json /app/
-
RUN curl -fsSL https://github.com/krallin/tini/releases/download/v${TINI_VERSION}/tini-$(dpkg --print-architecture) \
--output /tini \
&& chmod +x /tini
@@ -23,6 +20,14 @@ RUN arch=$(uname -m) && \
--output /thc \
&& chmod +x /thc
+COPY deno.json /app/
+COPY deno.lock /app/
+
+# Dependencies are cached on /deno-dir for the denoland/deno:debian image
+RUN --mount=type=cache,target=/deno-dir deno install
+
+COPY ./src/ /app/src/
+
RUN deno task compile
# Stage for creating the non-privileged user
--
2.49.0