Skip to content
This repository has been archived by the owner on Jun 22, 2023. It is now read-only.

Commit

Permalink
feat: 尝试编译多平台镜像
Browse files Browse the repository at this point in the history
  • Loading branch information
mcoo committed Jun 25, 2022
1 parent aaeb4db commit 87273ac
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 15 deletions.
25 changes: 15 additions & 10 deletions .github/workflows/goreleaser.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,24 +44,29 @@ 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
with:
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
Expand Down
13 changes: 8 additions & 5 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -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<i@mcenjoy.cn>
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

Expand Down

0 comments on commit 87273ac

Please sign in to comment.