File tree 2 files changed +16
-11
lines changed
2 files changed +16
-11
lines changed Original file line number Diff line number Diff line change 1
- name : Go Build and Docker Image Push
1
+ name : Docker Image Push
2
2
3
3
# 触发条件:当推送到 master 分支或者推送标签时触发
4
4
on :
@@ -26,11 +26,11 @@ jobs:
26
26
with :
27
27
go-version : ' 1.17'
28
28
29
- # Step 3: Build Go binary
30
- - name : Build Go binary
31
- run : |
32
- mkdir -p bin
33
- CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -a -installsuffix cgo -ldflags "-w" -o bin/wechat-webhook
29
+ # # Step 3: Build Go binary
30
+ # - name: Build Go binary
31
+ # run: |
32
+ # mkdir -p bin
33
+ # CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -a -installsuffix cgo -ldflags "-w" -o bin/wechat-webhook
34
34
35
35
# Step 4: Set up QEMU for multi-platform builds
36
36
- name : Set up QEMU
Original file line number Diff line number Diff line change 1
- FROM --platform=linux/amd64 amd64/alpine:3.12.0
2
- # FROM --platform=linux/amd64 golang:1.17-alpine
1
+ # syntax=docker/dockerfile:1
3
2
4
- # docker pull golang:1.17-alpine@sha256:ad6c114a2c858710c4db54f6c89d0e76f753831f01827252064be0017612fecc
3
+ # Step 1: build golang binary
4
+ FROM golang:1.17 as builder
5
+ WORKDIR /opt/app
6
+ COPY . .
7
+ RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -a -installsuffix cgo -ldflags "-w" -o wechat-webhook
5
8
9
+ # Step 2: copy binary from step1
10
+ FROM alpine:latest
6
11
ENV PATH /usr/local/bin:$PATH
7
12
ENV LANG C.UTF-8
8
13
@@ -18,7 +23,7 @@ RUN apk update && apk upgrade \
18
23
&& mkdir -p /usr/sbin \
19
24
&& mkdir -p /data/wechat-webhook/
20
25
21
- ADD bin/ wechat-webhook /usr/bin/
26
+ COPY --from=builder wechat-webhook /usr/bin
22
27
ADD start.sh /data/wechat-webhook/
28
+ WORKDIR /data/wechat-webhook/
23
29
24
- WORKDIR /data/wechat-webhook/
You can’t perform that action at this time.
0 commit comments