diff --git a/.github/workflows/goreleaser.yml b/.github/workflows/goreleaser.yml index a00212e..c9c74ba 100644 --- a/.github/workflows/goreleaser.yml +++ b/.github/workflows/goreleaser.yml @@ -44,7 +44,14 @@ jobs: run: | go mod tidy go test -v ./... - go build -o opqbot-manager -ldflags="-s -w" . + - + name: Set up QEMU + if: success() && startsWith(github.ref, 'refs/tags/') + uses: docker/setup-qemu-action@v1 + - + name: Set up Docker Buildx + if: success() && startsWith(github.ref, 'refs/tags/') + uses: docker/setup-buildx-action@v1 - name: Log into registry if: success() && startsWith(github.ref, 'refs/tags/') uses: docker/login-action@v1 @@ -52,16 +59,14 @@ jobs: username: ${{ secrets.DOCKER_USERNAME }} password: ${{ secrets.DOCKER_HUB_TOKEN }} - - name: Publish Docker + name: Build and push if: success() && startsWith(github.ref, 'refs/tags/') - env: - docker_repo: mcenjoy - image_name: opqbot-groupmanager - tag: latest - run: | - docker version - docker build . --file Dockerfile --tag $docker_repo/$image_name:$tag - docker push $docker_repo/$image_name:$tag + id: docker_build + uses: docker/build-push-action@v2 + with: + push: true + platforms: linux/amd64,linux/arm64,linux/arm/v7,linux/386 + tags: mcenjoy/opqbot-groupmanager:latest,mcenjoy/opqbot-groupmanager:${{ github.ref }} - name: Run GoReleaser uses: goreleaser/goreleaser-action@v2 diff --git a/Dockerfile b/Dockerfile index ffbad42..ef5f42e 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,14 +1,17 @@ -FROM alpine:latest as build -WORKDIR /apps -COPY opqbot-manager /apps/ -RUN apk add upx && upx opqbot-manager +FROM golang:alpine AS build +WORKDIR $GOPATH/src +COPY . . +RUN apk add upx \ + && go mod tidy\ + && go build -o opqbot-manager -ldflags="-s -w" . \ + && upx opqbot-manager FROM alpine:latest LABEL MAINTAINER enjoy ENV VERSION 1.0 # create a new dir WORKDIR /apps -COPY --from=build /apps/opqbot-manager /apps/opqbot-manager +COPY --from=build /go/src/opqbot-manager /apps/opqbot-manager COPY config.yaml.example /apps/config.yaml.example