diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 00000000..1b597b7d --- /dev/null +++ b/.dockerignore @@ -0,0 +1,6 @@ +.git +.github +.circleci +release +bin +**/node_modules diff --git a/.github/workflows/build-navigation-frps.yml b/.github/workflows/build-navigation-frps.yml new file mode 100644 index 00000000..61348601 --- /dev/null +++ b/.github/workflows/build-navigation-frps.yml @@ -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 }} diff --git a/dockerfiles/Dockerfile-for-frps-web-build b/dockerfiles/Dockerfile-for-frps-web-build new file mode 100644 index 00000000..3c5e0911 --- /dev/null +++ b/dockerfiles/Dockerfile-for-frps-web-build @@ -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"]