mirror of
https://gitee.com/IrisVega/frp.git
synced 2024-11-01 22:31:29 +08:00
parent
6c658586f6
commit
44eb513f05
105
.github/workflows/build-and-push-image.yml
vendored
105
.github/workflows/build-and-push-image.yml
vendored
@ -10,43 +10,9 @@ on:
|
|||||||
required: true
|
required: true
|
||||||
default: 'test'
|
default: 'test'
|
||||||
jobs:
|
jobs:
|
||||||
binary:
|
|
||||||
name: Build Golang project
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
steps:
|
|
||||||
- name: Set up Go 1.x
|
|
||||||
uses: actions/setup-go@v2
|
|
||||||
with:
|
|
||||||
go-version: 1.18
|
|
||||||
|
|
||||||
- run: |
|
|
||||||
# https://github.com/actions/setup-go/issues/107
|
|
||||||
cp -f `which go` /usr/bin/go
|
|
||||||
|
|
||||||
- run: go version
|
|
||||||
|
|
||||||
- name: Check out code into the Go module directory
|
|
||||||
uses: actions/checkout@v2
|
|
||||||
|
|
||||||
- name: Build
|
|
||||||
run: make build
|
|
||||||
|
|
||||||
- name: Archive artifacts for frpc
|
|
||||||
uses: actions/upload-artifact@v1
|
|
||||||
with:
|
|
||||||
name: frpc
|
|
||||||
path: bin/frpc
|
|
||||||
|
|
||||||
- name: Archive artifacts for frps
|
|
||||||
uses: actions/upload-artifact@v1
|
|
||||||
with:
|
|
||||||
name: frps
|
|
||||||
path: bin/frps
|
|
||||||
|
|
||||||
image:
|
image:
|
||||||
name: Build Image from Dockerfile and binaries
|
name: Build Image from Dockerfile and binaries
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
needs: binary
|
|
||||||
steps:
|
steps:
|
||||||
# environment
|
# environment
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
@ -60,19 +26,6 @@ jobs:
|
|||||||
- name: Set up Docker Buildx
|
- name: Set up Docker Buildx
|
||||||
uses: docker/setup-buildx-action@v1
|
uses: docker/setup-buildx-action@v1
|
||||||
|
|
||||||
# download binaries of frpc and frps
|
|
||||||
- name: Download binary of frpc
|
|
||||||
uses: actions/download-artifact@v2
|
|
||||||
with:
|
|
||||||
name: frpc
|
|
||||||
path: bin/frpc
|
|
||||||
|
|
||||||
- name: Download binary of frps
|
|
||||||
uses: actions/download-artifact@v2
|
|
||||||
with:
|
|
||||||
name: frps
|
|
||||||
path: bin/frps
|
|
||||||
|
|
||||||
# get image tag name
|
# get image tag name
|
||||||
- name: Get Image Tag Name
|
- name: Get Image Tag Name
|
||||||
run: |
|
run: |
|
||||||
@ -81,6 +34,18 @@ jobs:
|
|||||||
else
|
else
|
||||||
echo "TAG_NAME=${{ github.event.inputs.tag }}" >> $GITHUB_ENV
|
echo "TAG_NAME=${{ github.event.inputs.tag }}" >> $GITHUB_ENV
|
||||||
fi
|
fi
|
||||||
|
- name: Login to DockerHub
|
||||||
|
uses: docker/login-action@v1
|
||||||
|
with:
|
||||||
|
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
||||||
|
password: ${{ secrets.DOCKERHUB_PASSWORD }}
|
||||||
|
|
||||||
|
- name: Login to the GPR
|
||||||
|
uses: docker/login-action@v1
|
||||||
|
with:
|
||||||
|
registry: ghcr.io
|
||||||
|
username: ${{ github.actor }}
|
||||||
|
password: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
|
||||||
# prepare image tags
|
# prepare image tags
|
||||||
- name: Prepare Image Tags
|
- name: Prepare Image Tags
|
||||||
@ -92,26 +57,28 @@ jobs:
|
|||||||
echo "TAG_FRPC_GPR=ghcr.io/fatedier/frpc:${{ env.TAG_NAME }}" >> $GITHUB_ENV
|
echo "TAG_FRPC_GPR=ghcr.io/fatedier/frpc:${{ env.TAG_NAME }}" >> $GITHUB_ENV
|
||||||
echo "TAG_FRPS_GPR=ghcr.io/fatedier/frps:${{ env.TAG_NAME }}" >> $GITHUB_ENV
|
echo "TAG_FRPS_GPR=ghcr.io/fatedier/frps:${{ env.TAG_NAME }}" >> $GITHUB_ENV
|
||||||
|
|
||||||
# build images
|
- name: Build and push frpc
|
||||||
- name: Build Images
|
uses: docker/build-push-action@v2
|
||||||
run: |
|
with:
|
||||||
# for Docker hub
|
context: .
|
||||||
docker build --file ${{ env.DOCKERFILE_FRPC_PATH }} --tag ${{ env.TAG_FRPC }} .
|
file: ./dockerfiles/Dockerfile-for-frpc
|
||||||
docker build --file ${{ env.DOCKERFILE_FRPS_PATH }} --tag ${{ env.TAG_FRPS }} .
|
platforms: linux/386,linux/amd64,linux/arm/v6,linux/arm/v7,linux/arm64/v8,linux/ppc64le,linux/s390x
|
||||||
# for GPR
|
push: ${{ github.event_name != 'pull_request' }}
|
||||||
docker build --file ${{ env.DOCKERFILE_FRPC_PATH }} --tag ${{ env.TAG_FRPC_GPR }} .
|
cache-from: type=local,src=/tmp/.buildx-cache
|
||||||
docker build --file ${{ env.DOCKERFILE_FRPS_PATH }} --tag ${{ env.TAG_FRPS_GPR }} .
|
cache-to: type=local,dest=/tmp/.buildx-cache,mode=max
|
||||||
|
tags: |
|
||||||
|
${{ env.TAG_FRPC }}
|
||||||
|
${{ env.TAG_FRPC_GPR }}
|
||||||
|
|
||||||
# push to dockerhub
|
- name: Build and push frps
|
||||||
- name: Publish to Dockerhub
|
uses: docker/build-push-action@v2
|
||||||
run: |
|
with:
|
||||||
echo ${{ secrets.DOCKERHUB_PASSWORD }} | docker login --username ${{ secrets.DOCKERHUB_USERNAME }} --password-stdin
|
context: .
|
||||||
docker push ${{ env.TAG_FRPC }}
|
file: ./dockerfiles/Dockerfile-for-frps
|
||||||
docker push ${{ env.TAG_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' }}
|
||||||
# push to gpr
|
cache-from: type=local,src=/tmp/.buildx-cache
|
||||||
- name: Publish to GPR
|
cache-to: type=local,dest=/tmp/.buildx-cache,mode=max
|
||||||
run: |
|
tags: |
|
||||||
echo ${{ secrets.GPR_TOKEN }} | docker login ghcr.io --username ${{ github.repository_owner }} --password-stdin
|
${{ env.TAG_FRPS }}
|
||||||
docker push ${{ env.TAG_FRPC_GPR }}
|
${{ env.TAG_FRPS_GPR }}
|
||||||
docker push ${{ env.TAG_FRPS_GPR }}
|
|
||||||
|
@ -1,14 +1,17 @@
|
|||||||
FROM alpine:3 AS temp
|
FROM golang:1.18-alpine3.15 AS building
|
||||||
|
|
||||||
COPY bin/frpc /tmp
|
COPY . /building
|
||||||
|
WORKDIR /building
|
||||||
|
|
||||||
RUN chmod -R 777 /tmp/frpc
|
RUN apk --no-cache add \
|
||||||
|
git \
|
||||||
|
&& export GO111MODULE=on \
|
||||||
|
&& env CGO_ENABLED=0 go build -trimpath -ldflags "-s -w" -o ./bin/frpc ./cmd/frpc
|
||||||
|
|
||||||
|
FROM alpine:3.15
|
||||||
|
LABEL maintainer="i@muir.fun"
|
||||||
|
|
||||||
FROM alpine:3
|
COPY --from=building /building/bin/frpc /usr/bin/frpc
|
||||||
|
|
||||||
WORKDIR /app
|
|
||||||
|
|
||||||
COPY --from=temp /tmp/frpc /usr/bin
|
|
||||||
|
|
||||||
ENTRYPOINT ["/usr/bin/frpc"]
|
ENTRYPOINT ["/usr/bin/frpc"]
|
||||||
|
CMD ["-h"]
|
@ -1,14 +1,17 @@
|
|||||||
FROM alpine:3 AS temp
|
FROM golang:1.18-alpine3.15 AS building
|
||||||
|
|
||||||
COPY bin/frps /tmp
|
COPY . /building
|
||||||
|
WORKDIR /building
|
||||||
|
|
||||||
RUN chmod -R 777 /tmp/frps
|
RUN apk --no-cache add \
|
||||||
|
git \
|
||||||
|
&& export GO111MODULE=on \
|
||||||
|
&& env CGO_ENABLED=0 go build -trimpath -ldflags "-s -w" -o ./bin/frps ./cmd/frps
|
||||||
|
|
||||||
|
FROM alpine:3.15
|
||||||
|
LABEL maintainer="i@muir.fun"
|
||||||
|
|
||||||
FROM alpine:3
|
COPY --from=building /building/bin/frps /usr/bin/frps
|
||||||
|
|
||||||
WORKDIR /app
|
|
||||||
|
|
||||||
COPY --from=temp /tmp/frps /usr/bin
|
|
||||||
|
|
||||||
ENTRYPOINT ["/usr/bin/frps"]
|
ENTRYPOINT ["/usr/bin/frps"]
|
||||||
|
CMD ["-h"]
|
Loading…
Reference in New Issue
Block a user