Skip to content

Commit

Permalink
🎸 Update github workflows ci
Browse files Browse the repository at this point in the history
  • Loading branch information
Cairry committed Dec 31, 2024
1 parent dc40be0 commit 2606c5d
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
9 changes: 8 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,12 @@ jobs:
build:
runs-on: ubuntu-latest

strategy:
matrix:
arch:
- amd64
- arm64

steps:
- name: Checkout code
uses: actions/checkout@v3
Expand Down Expand Up @@ -51,10 +57,11 @@ jobs:
with:
context: .
file: ./Dockerfile
platforms: linux/arm64,linux/amd64
platforms: linux/${{ matrix.arch }}
push: ${{ github.event_name != 'pull_request' }}
build-args: |
VERSION=${{ env.DATE }}
TARGETARCH=${{ matrix.arch }}
tags: |
cairry/watchalert:latest
cairry/watchalert:${{ env.BRANCH_NAME }}.${{ env.DATE }}.${{ env.SHORT_SHA }}
Expand Down
7 changes: 4 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
FROM registry.cn-hangzhou.aliyuncs.com/opsre/golang:1.21.9-alpine3.19 AS build
FROM --platform=$BUILDPLATFORM golang:1.21.9-alpine3.19 AS build

ARG VERSION
ARG TARGETARCH

ENV GOPROXY=https://goproxy.cn,direct

Expand All @@ -12,10 +13,10 @@ RUN sed -i "s/dl-cdn.alpinelinux.org/mirrors.aliyun.com/g" /etc/apk/repositories
&& apk upgrade && apk add --no-cache --virtual .build-deps \
ca-certificates upx

RUN go build --ldflags="-X main.Version=${VERSION}" -o watchAlert . \
RUN CGO_ENABLED=0 GOOS=linux GOARCH=$TARGETARCH go build --ldflags="-X main.Version=${VERSION}" -o watchAlert . \
&& upx -9 watchAlert && chmod +x watchAlert

FROM registry.cn-hangzhou.aliyuncs.com/opsre/alpine:3.19
FROM alpine:3.19

COPY --from=build /root/watchAlert /app/watchAlert

Expand Down

0 comments on commit 2606c5d

Please sign in to comment.