add frps web build docker & work files

This commit is contained in:
alex 2023-04-20 15:47:07 +08:00
parent a68dedf3b9
commit edcbdea37d
3 changed files with 80 additions and 0 deletions

6
.dockerignore Normal file
View File

@ -0,0 +1,6 @@
.git
.github
.circleci
release
bin
**/node_modules

View File

@ -0,0 +1,45 @@
name: Frps with web docker build & push
on:
push:
branches: ["master"]
pull_request:
branches: ["master"]
jobs:
image:
name: Build Image from Dockerfile and binaries
runs-on: ubuntu-latest
steps:
# environment
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: "0"
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
# get image tag name
- name: Get Image Tag Name
run: |
echo "TAG_NAME=$(cat pkg/util/version/version.go | sed -ne "s/var\sversion\s=\s\"\(.*\)\"/\1/gp")" >> $GITHUB_ENV
- name: Login to DockerHub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_PASSWORD }}
- name: Build and push frps
uses: docker/build-push-action@v3
with:
context: .
file: ./dockerfiles/Dockerfile-for-frps-web-build
platforms: linux/amd64,linux/arm/v7,linux/arm64,linux/ppc64le,linux/s390x
push: true
tags: |
${{ secrets.DOCKER_USERNAME }}/frps:latest
${{ secrets.DOCKER_USERNAME }}/frps:${{ env.TAG_NAME }}

View File

@ -0,0 +1,29 @@
# step 1: build web
FROM node:10-alpine as web-build
WORKDIR /build
COPY ./web/frps/package.json .
RUN npm install --no-audit --progress=false --prefer-offline
COPY ./web/frps/ .
RUN npm install && npm build
# step 2: build frps
FROM golang:1.20 AS building
WORKDIR /building
COPY go.mod .
COPY go.sum .
RUN go mod download
COPY . .
COPY --from=web-build /build/dist/ ./assets/frps/static
RUN make frps
# step 3: release
FROM alpine:3
COPY --from=building /building/bin/frps /usr/bin/frps
ENTRYPOINT ["/usr/bin/frps","-c","/etc/frp/frps.ini"]