From 5086aad0b2a2b81889f348e416fed863d53f7be4 Mon Sep 17 00:00:00 2001 From: Anagh Kumar Baranwal <6824881+darthShadow@users.noreply.github.com> Date: Tue, 11 Feb 2025 19:08:46 +0530 Subject: [PATCH] build: disable docker builds on PRs & add missing dockerfile changes Signed-off-by: Anagh Kumar Baranwal <6824881+darthShadow@users.noreply.github.com> --- .../workflows/build_publish_docker_image.yml | 6 +-- Dockerfile | 44 +++++++++++++++---- 2 files changed, 39 insertions(+), 11 deletions(-) diff --git a/.github/workflows/build_publish_docker_image.yml b/.github/workflows/build_publish_docker_image.yml index d8e5f0557..abc017bc3 100644 --- a/.github/workflows/build_publish_docker_image.yml +++ b/.github/workflows/build_publish_docker_image.yml @@ -1,6 +1,6 @@ --- # Github Actions release for rclone -# -*- compile-command: "yamllint -f build_publish_docker_image.yml" -*- +# -*- compile-command: "yamllint -f parsable build_publish_docker_image.yml" -*- name: Build & Push Docker Images @@ -11,7 +11,6 @@ on: - '**' tags: - '**' - pull_request: workflow_dispatch: inputs: manual: @@ -21,7 +20,7 @@ on: jobs: build-image: - if: inputs.manual || (github.repository == 'rclone/rclone' && (github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name != github.event.pull_request.base.repo.full_name)) + if: inputs.manual || (github.repository == 'rclone/rclone' && github.event_name != 'pull_request') timeout-minutes: 60 strategy: fail-fast: false @@ -192,6 +191,7 @@ jobs: if-no-files-found: error merge-image: + name: Merge & Push Final Docker Image runs-on: ubuntu-24.04 needs: - build-image diff --git a/Dockerfile b/Dockerfile index 82f16aad7..bb0861594 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,19 +1,47 @@ FROM golang:alpine AS builder -COPY . /go/src/github.com/rclone/rclone/ +ARG CGO_ENABLED=0 + WORKDIR /go/src/github.com/rclone/rclone/ -RUN apk add --no-cache make bash gawk git -RUN \ - CGO_ENABLED=0 \ - make -RUN ./rclone version +RUN echo "**** Set Go Environment Variables ****" && \ + go env -w GOCACHE=/root/.cache/go-build + +RUN echo "**** Install Dependencies ****" && \ + apk add --no-cache \ + make \ + bash \ + gawk \ + git + +COPY go.mod . +COPY go.sum . + +RUN echo "**** Download Go Dependencies ****" && \ + go mod download -x + +RUN echo "**** Verify Go Dependencies ****" && \ + go mod verify + +COPY . . + +RUN --mount=type=cache,target=/root/.cache/go-build,sharing=locked \ + echo "**** Build Binary ****" && \ + make + +RUN echo "**** Print Version Binary ****" && \ + ./rclone version # Begin final image FROM alpine:latest -RUN apk --no-cache add ca-certificates fuse3 tzdata && \ - echo "user_allow_other" >> /etc/fuse.conf +RUN echo "**** Install Dependencies ****" && \ + apk add --no-cache \ + ca-certificates \ + fuse3 \ + tzdata && \ + echo "Enable user_allow_other in fuse" && \ + echo "user_allow_other" >> /etc/fuse.conf COPY --from=builder /go/src/github.com/rclone/rclone/rclone /usr/local/bin/