From a72259c604f23a077f6030f1b141a80ce060f1c3 Mon Sep 17 00:00:00 2001 From: fatedier Date: Fri, 29 Apr 2022 01:15:42 +0800 Subject: [PATCH] docker build&push: some adjustments --- .github/workflows/build-and-push-image.yml | 16 ++++++---------- dockerfiles/Dockerfile-for-frpc | 11 +++-------- dockerfiles/Dockerfile-for-frps | 11 +++-------- 3 files changed, 12 insertions(+), 26 deletions(-) diff --git a/.github/workflows/build-and-push-image.yml b/.github/workflows/build-and-push-image.yml index f089027f..b7f7318b 100644 --- a/.github/workflows/build-and-push-image.yml +++ b/.github/workflows/build-and-push-image.yml @@ -44,8 +44,8 @@ jobs: uses: docker/login-action@v1 with: registry: ghcr.io - username: ${{ github.actor }} - password: ${{ secrets.GITHUB_TOKEN }} + username: ${{ github.repository_owner }} + password: ${{ secrets.GPR_TOKEN }} # prepare image tags - name: Prepare Image Tags @@ -62,10 +62,8 @@ jobs: with: context: . file: ./dockerfiles/Dockerfile-for-frpc - platforms: linux/386,linux/amd64,linux/arm/v6,linux/arm/v7,linux/arm64/v8,linux/ppc64le,linux/s390x - push: ${{ github.event_name != 'pull_request' }} - cache-from: type=local,src=/tmp/.buildx-cache - cache-to: type=local,dest=/tmp/.buildx-cache,mode=max + platforms: linux/amd64,linux/arm/v7,linux/arm64,linux/ppc64le,linux/s390x + push: true tags: | ${{ env.TAG_FRPC }} ${{ env.TAG_FRPC_GPR }} @@ -75,10 +73,8 @@ jobs: with: context: . file: ./dockerfiles/Dockerfile-for-frps - platforms: linux/386,linux/amd64,linux/arm/v6,linux/arm/v7,linux/arm64/v8,linux/ppc64le,linux/s390x - push: ${{ github.event_name != 'pull_request' }} - cache-from: type=local,src=/tmp/.buildx-cache - cache-to: type=local,dest=/tmp/.buildx-cache,mode=max + platforms: linux/amd64,linux/arm/v7,linux/arm64,linux/ppc64le,linux/s390x + push: true tags: | ${{ env.TAG_FRPS }} ${{ env.TAG_FRPS_GPR }} diff --git a/dockerfiles/Dockerfile-for-frpc b/dockerfiles/Dockerfile-for-frpc index b9eb18ac..ece950f2 100644 --- a/dockerfiles/Dockerfile-for-frpc +++ b/dockerfiles/Dockerfile-for-frpc @@ -1,17 +1,12 @@ -FROM golang:1.18-alpine3.15 AS building +FROM golang:1.18 AS building COPY . /building WORKDIR /building -RUN apk --no-cache add \ - git \ - && export GO111MODULE=on \ - && env CGO_ENABLED=0 go build -trimpath -ldflags "-s -w" -o ./bin/frpc ./cmd/frpc +RUN make frpc -FROM alpine:3.15 -LABEL maintainer="i@muir.fun" +FROM alpine:3 COPY --from=building /building/bin/frpc /usr/bin/frpc ENTRYPOINT ["/usr/bin/frpc"] -CMD ["-h"] \ No newline at end of file diff --git a/dockerfiles/Dockerfile-for-frps b/dockerfiles/Dockerfile-for-frps index d5809e95..d8ab8247 100644 --- a/dockerfiles/Dockerfile-for-frps +++ b/dockerfiles/Dockerfile-for-frps @@ -1,17 +1,12 @@ -FROM golang:1.18-alpine3.15 AS building +FROM golang:1.18 AS building COPY . /building WORKDIR /building -RUN apk --no-cache add \ - git \ - && export GO111MODULE=on \ - && env CGO_ENABLED=0 go build -trimpath -ldflags "-s -w" -o ./bin/frps ./cmd/frps +RUN make frps -FROM alpine:3.15 -LABEL maintainer="i@muir.fun" +FROM alpine:3 COPY --from=building /building/bin/frps /usr/bin/frps ENTRYPOINT ["/usr/bin/frps"] -CMD ["-h"] \ No newline at end of file