From 3759de99d9286575f0d7a7fd613da0836dacbbc3 Mon Sep 17 00:00:00 2001 From: Eli Ribble Date: Thu, 12 Jun 2025 09:49:09 -0700 Subject: [PATCH] Make dockerfile multi-stage With this it's possible to build the entire Cloudreve suite with a single image. This changes the assets version to use .Tag instead of .Version because without it we get a mismatch between the frontend and the backend. --- .goreleaser.yaml | 2 +- Dockerfile | 18 +++++++++++++++++- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/.goreleaser.yaml b/.goreleaser.yaml index 3730cf5..7b12c70 100644 --- a/.goreleaser.yaml +++ b/.goreleaser.yaml @@ -4,7 +4,7 @@ before: hooks: - go mod tidy - chmod +x ./.build/build-assets.sh - - ./.build/build-assets.sh {{.Version}} + - ./.build/build-assets.sh {{.Tag}} builds: - env: diff --git a/Dockerfile b/Dockerfile index f14a98d..b60a131 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,3 +1,19 @@ +# Build stage + +FROM ghcr.io/goreleaser/goreleaser:v2.10.2 AS builder + +WORKDIR /src + +# Install goreleaser +RUN apk add --no-cache bash curl git npm nodejs tar zip +RUN npm install -g yarn + +# Perform the build +COPY . . + +RUN goreleaser build --single-target --snapshot + +# Runtime stage FROM alpine:latest WORKDIR /cloudreve @@ -16,7 +32,7 @@ ENV CR_ENABLE_ARIA2=1 \ CR_SETTING_DEFAULT_media_meta_ffprobe=1 COPY .build/aria2.supervisor.conf .build/entrypoint.sh ./ -COPY cloudreve ./cloudreve +COPY --from=builder /src/dist/*/cloudreve ./cloudreve RUN chmod +x ./cloudreve \ && chmod +x ./entrypoint.sh