build: disable docker builds on PRs & add missing dockerfile changes

Signed-off-by: Anagh Kumar Baranwal <6824881+darthShadow@users.noreply.github.com>
This commit is contained in:
Anagh Kumar Baranwal 2025-02-11 19:08:46 +05:30 committed by Nick Craig-Wood
parent c1b414e2cf
commit 5086aad0b2
2 changed files with 39 additions and 11 deletions

View File

@ -1,6 +1,6 @@
--- ---
# Github Actions release for rclone # 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 name: Build & Push Docker Images
@ -11,7 +11,6 @@ on:
- '**' - '**'
tags: tags:
- '**' - '**'
pull_request:
workflow_dispatch: workflow_dispatch:
inputs: inputs:
manual: manual:
@ -21,7 +20,7 @@ on:
jobs: jobs:
build-image: 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 timeout-minutes: 60
strategy: strategy:
fail-fast: false fail-fast: false
@ -192,6 +191,7 @@ jobs:
if-no-files-found: error if-no-files-found: error
merge-image: merge-image:
name: Merge & Push Final Docker Image
runs-on: ubuntu-24.04 runs-on: ubuntu-24.04
needs: needs:
- build-image - build-image

View File

@ -1,19 +1,47 @@
FROM golang:alpine AS builder FROM golang:alpine AS builder
COPY . /go/src/github.com/rclone/rclone/ ARG CGO_ENABLED=0
WORKDIR /go/src/github.com/rclone/rclone/ WORKDIR /go/src/github.com/rclone/rclone/
RUN apk add --no-cache make bash gawk git RUN echo "**** Set Go Environment Variables ****" && \
RUN \ go env -w GOCACHE=/root/.cache/go-build
CGO_ENABLED=0 \
make RUN echo "**** Install Dependencies ****" && \
RUN ./rclone version 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 # Begin final image
FROM alpine:latest FROM alpine:latest
RUN apk --no-cache add ca-certificates fuse3 tzdata && \ RUN echo "**** Install Dependencies ****" && \
echo "user_allow_other" >> /etc/fuse.conf 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/ COPY --from=builder /go/src/github.com/rclone/rclone/rclone /usr/local/bin/