Skip to content

Commit cd66c94

Browse files
committed
Add github build pipeline
1 parent 5c1897b commit cd66c94

File tree

2 files changed

+57
-3
lines changed

2 files changed

+57
-3
lines changed

.github/workflows/docker-build.yml

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
name: publish
2+
3+
on:
4+
push:
5+
tags:
6+
- '*'
7+
8+
jobs:
9+
publish:
10+
permissions:
11+
packages: write
12+
13+
runs-on: actuated
14+
steps:
15+
- uses: actions/checkout@master
16+
with:
17+
fetch-depth: 1
18+
19+
- name: Setup mirror
20+
uses: self-actuated/hub-mirror@master
21+
- name: Get TAG
22+
id: get_tag
23+
run: echo TAG=${GITHUB_REF#refs/tags/} >> $GITHUB_ENV
24+
- name: Get Repo Owner
25+
id: get_repo_owner
26+
run: echo "REPO_OWNER=$(echo ${{ github.repository_owner }} | tr '[:upper:]' '[:lower:]')" > $GITHUB_ENV
27+
28+
- name: Set up QEMU
29+
uses: docker/setup-qemu-action@v2
30+
- name: Set up Docker Buildx
31+
uses: docker/setup-buildx-action@v2
32+
- name: Login to container Registry
33+
uses: docker/login-action@v2
34+
with:
35+
username: ${{ github.repository_owner }}
36+
password: ${{ secrets.GITHUB_TOKEN }}
37+
registry: ghcr.io
38+
39+
- name: Release build
40+
id: release_build
41+
uses: docker/build-push-action@v4
42+
with:
43+
outputs: "type=registry,push=true"
44+
provenance: false
45+
platforms: linux/amd64,linux/arm/v6,linux/arm64
46+
tags: |
47+
ghcr.io/${{ env.REPO_OWNER }}/mini-mail-dev:${{ github.sha }}
48+
ghcr.io/${{ env.REPO_OWNER }}/mini-mail-dev:${{ env.TAG }}
49+
ghcr.io/${{ env.REPO_OWNER }}/mini-mail-dev:latest

Dockerfile

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,14 @@
1-
FROM node:20-slim AS frontend
1+
ARG BUILDPLATFORM
2+
ARG TARGETOS
3+
ARG TARGETARCH
4+
5+
FROM node:21-slim AS frontend
26

37
COPY . .
48

59
RUN npm install && npm run build
610

7-
FROM golang:1.21
11+
FROM --platform=${BUILDPLATFORM:-linux/amd64} golang:1.21
812

913
WORKDIR /usr/src/app
1014

@@ -16,7 +20,8 @@ COPY go go
1620
COPY main.go .
1721
COPY --from=frontend dist dist
1822

19-
RUN go build -o /usr/bin/mini-mail-dev && \
23+
RUN GOOS=${TARGETOS} GOARCH=${TARGETARCH} \
24+
go build -o /usr/bin/mini-mail-dev && \
2025
rm -rf go main.go go.mod go.sum dist
2126

2227
EXPOSE 1025/tcp

0 commit comments

Comments
 (0)