Skip to content

Commit 1b1f2d9

Browse files
ci: add build files
1 parent c0f9000 commit 1b1f2d9

File tree

5 files changed

+124
-1
lines changed

5 files changed

+124
-1
lines changed

.github/workflows/build.yml

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
name: Package Build
2+
3+
on:
4+
workflow_dispatch:
5+
push:
6+
tags:
7+
- '*'
8+
env:
9+
DOCKER_BUILDKIT: 1
10+
11+
jobs:
12+
build_image:
13+
name: Build Image
14+
runs-on: ubuntu-latest
15+
steps:
16+
- name: Checkout
17+
uses: actions/checkout@v4
18+
with:
19+
fetch-depth: 0
20+
21+
- name: Set up Docker Buildx
22+
uses: docker/setup-buildx-action@v3
23+
with:
24+
config-inline: |
25+
[worker.oci]
26+
platforms = ["linux/amd64", "linux/arm64"]
27+
max-parallelism = 4
28+
29+
- name: Login to GitHub Container Registry
30+
uses: docker/login-action@v3
31+
with:
32+
registry: ghcr.io
33+
username: ${{ github.actor }}
34+
password: ${{ secrets.GITHUB_TOKEN }}
35+
36+
- name: Setup ENV vars
37+
id: env-vars
38+
run: |
39+
echo "TAG=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV
40+
echo "IMAGE_NAME=ghcr.io/${GITHUB_ACTOR}/fsb" >> $GITHUB_ENV
41+
42+
- name: Build docker image and push
43+
uses: docker/build-push-action@v5
44+
with:
45+
context: ./
46+
pull: true
47+
push: true
48+
platforms: linux/amd64,linux/arm64
49+
tags: ${{ env.IMAGE_NAME }}:${{ env.TAG }} , ${{ env.IMAGE_NAME }}:latest

.goreleaser.yaml

Lines changed: 50 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ builds:
2121
goarch:
2222
- amd64
2323
- arm64
24+
mod_timestamp: '{{ .CommitTimestamp }}'
2425

2526
archives:
2627
- format: tar.gz
@@ -49,4 +50,52 @@ changelog:
4950
filters:
5051
exclude:
5152
- "^docs:"
52-
- "^test:"
53+
- "^test:"
54+
55+
dockers:
56+
# amd64 only
57+
- goarch: amd64
58+
dockerfile: goreleaser.Dockerfile
59+
use: buildx
60+
image_templates:
61+
- "ghcr.io/EverythingSuckz/{{ .ProjectName }}:{{ .Tag }}-amd64"
62+
build_flag_templates:
63+
- "--platform=linux/amd64"
64+
- "--pull"
65+
- "--label=org.opencontainers.image.created={{.Date}}"
66+
- "--label=org.opencontainers.image.title={{ .ProjectName }}"
67+
- "--label=org.opencontainers.image.revision={{.FullCommit}}"
68+
- "--label=org.opencontainers.image.version={{.Version}}"
69+
# arm64 only
70+
- goarch: arm64
71+
dockerfile: goreleaser.Dockerfile
72+
use: buildx
73+
image_templates:
74+
- "ghcr.io/EverythingSuckz/{{ .ProjectName }}:{{ .Tag }}-amd64"
75+
build_flag_templates:
76+
- "--platform=linux/arm64/v8"
77+
- "--pull"
78+
- "--label=org.opencontainers.image.created={{.Date}}"
79+
- "--label=org.opencontainers.image.title={{ .ProjectName }}"
80+
- "--label=org.opencontainers.image.revision={{.FullCommit}}"
81+
- "--label=org.opencontainers.image.version={{.Version}}"
82+
83+
docker_manifests:
84+
- name_template: "ghcr.io/EverythingSuckz/{{ .ProjectName }}:{{ .Version }}"
85+
image_templates:
86+
- "ghcr.io/EverythingSuckz/{{ .ProjectName }}:{{ .Tag }}-amd64"
87+
- "ghcr.io/EverythingSuckz/{{ .ProjectName }}:{{ .Tag }}-arm64v8"
88+
- name_template: "ghcr.io/EverythingSuckz/{{ .ProjectName }}:latest"
89+
image_templates:
90+
- "ghcr.io/EverythingSuckz/{{ .ProjectName }}:{{ .Tag }}-amd64"
91+
- "ghcr.io/EverythingSuckz/{{ .ProjectName }}:{{ .Tag }}-arm64v8"
92+
93+
# github container registry
94+
- name_template: "ghcr.io/EverythingSuckz/{{ .ProjectName }}:{{ .Version }}"
95+
image_templates:
96+
- "ghcr.io/EverythingSuckz/{{ .ProjectName }}:{{ .Tag }}-amd64"
97+
- "ghcr.io/EverythingSuckz/{{ .ProjectName }}:{{ .Tag }}-arm64v8"
98+
- name_template: "ghcr.io/EverythingSuckz/{{ .ProjectName }}:latest"
99+
image_templates:
100+
- "ghcr.io/EverythingSuckz/{{ .ProjectName }}:{{ .Tag }}-amd64"
101+
- "ghcr.io/EverythingSuckz/{{ .ProjectName }}:{{ .Tag }}-arm64v8"

Dockerfile

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
FROM golang:1.21 AS builder
2+
RUN apt-get update && apt-get upgrade -y && apt-get install build-essential -y
3+
WORKDIR /app
4+
COPY . .
5+
RUN CGO_ENABLED=1 GOOS=`go env GOHOSTOS` GOARCH=`go env GOHOSTARCH` go build ./cmd/fsb/ -o out/fsb -ldflags="-w -s" .
6+
7+
FROM golang:1.21
8+
COPY --from=builder /app/out/fsb /app/fsb
9+
CMD ["/app/fsb"]

docker-compose.yaml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
version: "3.9"
2+
3+
services:
4+
fsb:
5+
build:
6+
context: .
7+
dockerfile: Dockerfile
8+
restart: always
9+
container_name: fsb
10+
volumes:
11+
- ./:/app/:rw
12+
env_file: fsb.env
13+
ports:
14+
- 8080:8080

goreleaser.Dockerfile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
FROM golang:1.21
2+
CMD ["/app/fsb"]

0 commit comments

Comments
 (0)