diff --git a/.github/workflows/cicd-to-dockerhub.yml b/.github/workflows/cicd-to-dockerhub.yml deleted file mode 100644 index b3d64b4..0000000 --- a/.github/workflows/cicd-to-dockerhub.yml +++ /dev/null @@ -1,35 +0,0 @@ -name: cicd-to-dockerhub - -on: - push: - tags: - - "*" - -jobs: - build: - runs-on: ubuntu-latest - steps: - - name: Checkout repository - uses: actions/checkout@v2 - - - name: Login to Docker Hub - uses: docker/login-action@v1 - with: - username: ${{ secrets.DOCKER_HUB_USERNAME }} - password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }} - - - name: Set up Docker Buildx - id: buildx - uses: docker/setup-buildx-action@v1 - - - name: Build and push - id: docker_build - uses: docker/build-push-action@v2 - with: - context: ./ - file: ./Dockerfile - push: true - tags: ${{ secrets.DOCKER_HUB_USERNAME }}/gau:latest - - - name: Image digest - run: echo ${{ steps.docker_build.outputs.digest }} diff --git a/.github/workflows/release_build.yml b/.github/workflows/release_build.yml index 4aabd92..a52db8d 100644 --- a/.github/workflows/release_build.yml +++ b/.github/workflows/release_build.yml @@ -29,6 +29,19 @@ jobs: gpg_private_key: ${{ secrets.GPG_PRIVATE_KEY }} passphrase: ${{ secrets.GPG_PASSPHRASE }} + - name: Login to Docker Hub + uses: docker/login-action@v1 + with: + username: ${{ secrets.DOCKER_HUB_USERNAME }} + password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }} + + - name: Set up QEMU + uses: docker/setup-qemu-action@v3 + + - name: Set up Docker Buildx + id: buildx + uses: docker/setup-buildx-action@v3 + - name: Run GoReleaser uses: goreleaser/goreleaser-action@master with: @@ -36,4 +49,5 @@ jobs: args: release --clean env: GITHUB_TOKEN: ${{ secrets.GO_RELEASER_GITHUB_TOKEN }} + DOCKER_HUB_USERNAME: ${{ secrets.DOCKER_HUB_USERNAME }} GPG_FINGERPRINT: ${{ steps.import_gpg.outputs.fingerprint }} diff --git a/.goreleaser.yml b/.goreleaser.yml index 76fb9dc..4084473 100644 --- a/.goreleaser.yml +++ b/.goreleaser.yml @@ -11,6 +11,8 @@ builds: - amd64 - 386 - arm64 + env: + - CGO_ENABLED=0 ignore: - goos: darwin goarch: 386 @@ -23,7 +25,34 @@ archives: format_overrides: - goos: windows format: zip - +dockers: + - image_templates: + - "{{ .Env.DOCKER_HUB_USERNAME }}/gau:{{ .Tag }}-amd64" + - "{{ .Env.DOCKER_HUB_USERNAME }}/gau:latest-amd64" + use: buildx + goos: linux + goarch: amd64 + build_flag_templates: + - "--pull" + - "--platform=linux/amd64" + - image_templates: + - "{{ .Env.DOCKER_HUB_USERNAME }}/gau:{{ .Tag }}-arm64" + - "{{ .Env.DOCKER_HUB_USERNAME }}/gau:latest-arm64" + use: buildx + goos: linux + goarch: arm64 + build_flag_templates: + - "--pull" + - "--platform=linux/arm64" +docker_manifests: +- name_template: '{{ .Env.DOCKER_HUB_USERNAME }}/gau:{{ .Tag }}' + image_templates: + - "{{ .Env.DOCKER_HUB_USERNAME }}/gau:{{ .Tag }}-amd64" + - "{{ .Env.DOCKER_HUB_USERNAME }}/gau:{{ .Tag }}-arm64" +- name_template: '{{ .Env.DOCKER_HUB_USERNAME }}/gau:latest' + image_templates: + - "{{ .Env.DOCKER_HUB_USERNAME }}/gau:latest-amd64" + - "{{ .Env.DOCKER_HUB_USERNAME }}/gau:latest-arm64" signs: - artifacts: checksum args: [ "--batch", "-u", "{{ .Env.GPG_FINGERPRINT }}", "--output", "${signature}", "--detach-sign", "${artifact}" ] diff --git a/Dockerfile b/Dockerfile index f7f73da..2d0273f 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,18 +1,8 @@ -# Build image: golang:1.21.0-alpine3.17 -FROM golang:1.21.0-alpine3.17 as build - -WORKDIR /app - -COPY . . -RUN go mod download && go build -o ./build/gau ./cmd/gau - -ENTRYPOINT ["/app/gau/build/gau"] - # Release image: alpine:3.17 FROM alpine:3.17 RUN apk -U upgrade --no-cache -COPY --from=build /app/build/gau /usr/local/bin/gau +COPY gau /usr/local/bin/gau RUN adduser \ --gecos "" \