From 404e099907dd9345c5a80d6133050c2e6a5f0af0 Mon Sep 17 00:00:00 2001 From: ginuerzh Date: Fri, 11 Oct 2024 00:05:00 +0800 Subject: [PATCH] update github actions --- .github/workflows/buildx.yml | 47 ++++++++++-------------------------- Dockerfile | 12 ++------- docker-compose.yaml | 4 --- 3 files changed, 15 insertions(+), 48 deletions(-) delete mode 100644 docker-compose.yaml diff --git a/.github/workflows/buildx.yml b/.github/workflows/buildx.yml index 1f066ff..85990e6 100644 --- a/.github/workflows/buildx.yml +++ b/.github/workflows/buildx.yml @@ -46,48 +46,27 @@ jobs: - name: Set up Docker Buildx id: buildx uses: docker/setup-buildx-action@v3 - with: - version: latest - name: Environment run: | echo home=$HOME echo git_ref=$GITHUB_REF echo git_sha=$GITHUB_SHA - echo version=${{ steps.prepare.outputs.version }} echo image=${{ steps.prepare.outputs.docker_image }} + echo tags=${{ steps.prepare.outputs.tags }} echo platforms=${{ steps.prepare.outputs.docker_platforms }} echo avail_platforms=${{ steps.buildx.outputs.platforms }} - # https://github.com/actions/checkout - - name: Checkout - uses: actions/checkout@v4 + - name: Login to DockerHub + if: github.event_name != 'pull_request' + uses: docker/login-action@v1 + with: + username: ${{ secrets.DOCKER_USERNAME }} + password: ${{ secrets.DOCKER_PASSWORD }} - - name: Docker Buildx (no push) - run: | - docker buildx bake \ - --set ${{ github.event.repository.name }}.platform=${{ steps.prepare.outputs.docker_platforms }} \ - --set ${{ github.event.repository.name }}.output=type=image,push=false \ - --set ${{ github.event.repository.name }}.tags="${{ steps.prepare.outputs.tags }}" \ - --file docker-compose.yaml - - - name: Docker Login - if: success() - env: - DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }} - run: | - echo "${DOCKER_PASSWORD}" | docker login --username "${{ secrets.DOCKER_USERNAME }}" --password-stdin - - - name: Docker Buildx (push) - if: success() - run: | - docker buildx bake \ - --set ${{ github.event.repository.name }}.platform=${{ steps.prepare.outputs.docker_platforms }} \ - --set ${{ github.event.repository.name }}.output=type=image,push=true \ - --set ${{ github.event.repository.name }}.tags="${{ steps.prepare.outputs.tags }}" \ - --file docker-compose.yaml - - - name: Clear - if: always() - run: | - rm -f ${HOME}/.docker/config.json \ No newline at end of file + - name: Buildx and push + uses: docker/build-push-action@v2 + with: + platforms: ${{ steps.prepare.outputs.docker_platforms }} + push: true + tags: ${{ steps.prepare.outputs.tags }} \ No newline at end of file diff --git a/Dockerfile b/Dockerfile index 92acfce..8cc0a3a 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,10 +1,4 @@ -FROM --platform=$BUILDPLATFORM golang:1.22-alpine as builder - -# Convert TARGETPLATFORM to GOARCH format -# https://github.com/tonistiigi/xx -COPY --from=tonistiigi/xx:golang / / - -ARG TARGETPLATFORM +FROM --platform=$BUILDPLATFORM golang:1.23-alpine3.20 AS builder RUN apk add --no-cache musl-dev git gcc @@ -12,11 +6,9 @@ ADD . /src WORKDIR /src -ENV GO111MODULE=on - RUN cd cmd/gost && go env && go build -FROM alpine:latest +FROM alpine:3.20 # add iptables for tun/tap RUN apk add --no-cache iptables diff --git a/docker-compose.yaml b/docker-compose.yaml deleted file mode 100644 index 51d8189..0000000 --- a/docker-compose.yaml +++ /dev/null @@ -1,4 +0,0 @@ -version: "3.4" -services: - gost: - build: . \ No newline at end of file