Skip to content

Commit d9914cf

Browse files
author
Administrator
committed
fix image build workflow
1 parent 5620db2 commit d9914cf

File tree

2 files changed

+16
-11
lines changed

2 files changed

+16
-11
lines changed

.github/workflows/go.yml .github/workflows/build.yml

+6-6
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Go Build and Docker Image Push
1+
name: Docker Image Push
22

33
# 触发条件:当推送到 master 分支或者推送标签时触发
44
on:
@@ -26,11 +26,11 @@ jobs:
2626
with:
2727
go-version: '1.17'
2828

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
3434

3535
# Step 4: Set up QEMU for multi-platform builds
3636
- name: Set up QEMU

Dockerfile

+10-5
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,13 @@
1-
FROM --platform=linux/amd64 amd64/alpine:3.12.0
2-
#FROM --platform=linux/amd64 golang:1.17-alpine
1+
# syntax=docker/dockerfile:1
32

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
58

9+
# Step 2: copy binary from step1
10+
FROM alpine:latest
611
ENV PATH /usr/local/bin:$PATH
712
ENV LANG C.UTF-8
813

@@ -18,7 +23,7 @@ RUN apk update && apk upgrade \
1823
&& mkdir -p /usr/sbin \
1924
&& mkdir -p /data/wechat-webhook/
2025

21-
ADD bin/wechat-webhook /usr/bin/
26+
COPY --from=builder wechat-webhook /usr/bin
2227
ADD start.sh /data/wechat-webhook/
28+
WORKDIR /data/wechat-webhook/
2329

24-
WORKDIR /data/wechat-webhook/

0 commit comments

Comments
 (0)