From a7b5357e077abd5ec648cc8566e080bd5dcc4be0 Mon Sep 17 00:00:00 2001 From: Dylan De Faoite Date: Mon, 13 Jul 2026 23:28:54 +0100 Subject: [PATCH] build(ci): improve caching efficiency in ci --- .gitea/workflows/ci.yml | 4 +++- src/main/Dockerfile | 10 ++++------ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/.gitea/workflows/ci.yml b/.gitea/workflows/ci.yml index 05c8de3..5d4613e 100644 --- a/.gitea/workflows/ci.yml +++ b/.gitea/workflows/ci.yml @@ -53,6 +53,8 @@ jobs: file: src/main/Dockerfile push: true tags: ${{ env.REGISTRY }}/${{ env.IMAGE_PREFIX }}-backend:latest + cache-from: type=registry,ref=${{ env.REGISTRY }}/${{ env.IMAGE_PREFIX }}-backend:buildcache + cache-to: type=registry,ref=${{ env.REGISTRY }}/${{ env.IMAGE_PREFIX }}-backend:buildcache,mode=max - name: Build and push frontend image uses: https://github.com/docker/build-push-action@v6 @@ -73,7 +75,7 @@ jobs: deploy: name: Deploy to server needs: build-and-push - if: github.ref == 'refs/heads/master' + if: gitea.ref == 'refs/heads/master' runs-on: ubuntu-latest steps: diff --git a/src/main/Dockerfile b/src/main/Dockerfile index 3b0af77..54b5706 100644 --- a/src/main/Dockerfile +++ b/src/main/Dockerfile @@ -2,19 +2,17 @@ FROM maven:3.9.6-eclipse-temurin-21 AS builder WORKDIR /app COPY pom.xml . +RUN --mount=type=cache,target=/root/.m2 mvn dependency:go-offline -B COPY src ./src -RUN mvn clean package -DskipTests - +RUN --mount=type=cache,target=/root/.m2 mvn clean package -DskipTests -B # Run stage -FROM eclipse-temurin:21-jdk - +FROM eclipse-temurin:21-jre # dependencies RUN apt-get update && \ - apt-get install -y ffmpeg && \ + apt-get install -y --no-install-recommends ffmpeg && \ apt-get clean && \ rm -rf /var/lib/apt/lists/* - WORKDIR /app COPY --from=builder /app/target/*.jar app.jar EXPOSE 8080