Skip to content

Commit ff0cd9f

Browse files
authored
Add dockerfiles & goreleaser (#20)
1 parent 143f4b7 commit ff0cd9f

File tree

5 files changed

+116
-0
lines changed

5 files changed

+116
-0
lines changed

.github/workflows/release.yml

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
name: goreleaser
2+
3+
on:
4+
push:
5+
tags:
6+
- '*'
7+
8+
permissions:
9+
contents: write
10+
packages: write
11+
12+
jobs:
13+
goreleaser:
14+
runs-on: ubuntu-latest
15+
steps:
16+
- uses: actions/checkout@v3
17+
with:
18+
fetch-depth: 0
19+
- run: git fetch --force --tags
20+
- uses: actions/setup-go@v4
21+
with:
22+
go-version-file: 'go.mod'
23+
- uses: docker/login-action@v2
24+
with:
25+
registry: ghcr.io
26+
username: ${{ github.actor }}
27+
password: ${{ secrets.GITHUB_TOKEN }}
28+
- uses: goreleaser/goreleaser-action@v4
29+
with:
30+
distribution: goreleaser
31+
version: latest
32+
args: release --clean
33+
env:
34+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,3 +21,5 @@ go.work
2121

2222
output
2323
almanac.toml
24+
25+
dist/

.goreleaser.yaml

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
before:
2+
hooks:
3+
- go mod tidy
4+
# you may remove this if you don't need go generate
5+
builds:
6+
- env:
7+
- CGO_ENABLED=0
8+
goos:
9+
- linux
10+
- windows
11+
- darwin
12+
flags:
13+
- -trimpath
14+
ldflags:
15+
- -s -w
16+
17+
universal_binaries:
18+
- replace: true
19+
20+
archives:
21+
- format: tar.gz
22+
# this name template makes the OS and Arch compatible with the results of uname.
23+
name_template: >-
24+
{{ .ProjectName }}_
25+
{{- .Os }}_
26+
{{- if eq .Arch "amd64" }}x86_64
27+
{{- else if eq .Arch "386" }}i386
28+
{{- else }}{{ .Arch }}{{ end }}
29+
{{- if .Arm }}v{{ .Arm }}{{ end }}
30+
# use zip for windows archives
31+
format_overrides:
32+
- goos: windows
33+
format: zip
34+
35+
dockers:
36+
- image_templates:
37+
- "ghcr.io/fogo-sh/almanac:{{ .Version }}"
38+
- "ghcr.io/fogo-sh/almanac:latest"
39+
dockerfile: goreleaser.Dockerfile
40+
build_flag_templates:
41+
- --label=org.opencontainers.image.title={{ .ProjectName }}
42+
- --label=org.opencontainers.image.description={{ .ProjectName }}
43+
- --label=org.opencontainers.image.url=https://github.com/fogo-sh/almanac
44+
- --label=org.opencontainers.image.source=https://github.com/fogo-sh/almanac
45+
- --label=org.opencontainers.image.version={{ .Version }}
46+
- --label=org.opencontainers.image.created={{ time "2006-01-02T15:04:05Z07:00" }}
47+
- --label=org.opencontainers.image.revision={{ .FullCommit }}
48+
- --label=org.opencontainers.image.licenses=MIT
49+
50+
checksum:
51+
name_template: 'checksums.txt'
52+
snapshot:
53+
name_template: "{{ incpatch .Version }}-next"
54+
changelog:
55+
sort: asc
56+
filters:
57+
exclude:
58+
- '^docs:'
59+
- '^test:'
60+
61+
# yaml-language-server: $schema=https://goreleaser.com/static/schema.json
62+
# vim: set ts=2 sw=2 tw=0 fo=cnqoj

Dockerfile

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
FROM golang:1.21 AS builder
2+
3+
WORKDIR /build
4+
COPY go.mod .
5+
COPY go.sum .
6+
RUN go mod download
7+
8+
COPY . .
9+
RUN CGO_ENABLED=0 go build -o almanac .
10+
11+
FROM scratch
12+
WORKDIR /config
13+
COPY --from=builder /build/almanac /almanac
14+
ENTRYPOINT ["/almanac", "serve", "--content-dir", "/content"]

goreleaser.Dockerfile

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
FROM scratch
2+
WORKDIR /config
3+
ENTRYPOINT ["/almanac", "serve", "--content-dir", "/content"]
4+
COPY almanac /

0 commit comments

Comments
 (0)