Skip to content

Commit 25af589

Browse files
committed
chore: add goreleaser config to build container images and binaries
1 parent 3d197dc commit 25af589

File tree

4 files changed

+106
-0
lines changed

4 files changed

+106
-0
lines changed

.dockerignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
exp/

.goreleaser.yaml

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
version: 2
2+
project_name: cardano-validator-watcher
3+
before:
4+
hooks:
5+
- go mod tidy
6+
7+
builds:
8+
- id: cardano-validator-watcher
9+
main: cmd/watcher/main.go
10+
env:
11+
- CGO_ENABLED=0
12+
goos:
13+
- linux
14+
- darwin
15+
16+
archives:
17+
- format: tar.gz
18+
name_template: '{{ .Binary }}-{{ .Tag }}-{{ .Os }}-{{ .Arch }}'
19+
files:
20+
- none*
21+
22+
dockers:
23+
- image_templates:
24+
- 'ghcr.io/kilnfi/cardano-validator-watcher:{{ .Tag }}-amd64'
25+
dockerfile: Dockerfile
26+
use: buildx
27+
goos: linux
28+
goarch: amd64
29+
build_flag_templates:
30+
- "--pull"
31+
- "--build-arg=ARCH=linux/amd64"
32+
- "--platform=linux/amd64"
33+
- "--label=org.opencontainers.image.created={{ .Date }}"
34+
- "--label=org.opencontainers.image.name={{ .ProjectName }}"
35+
- "--label=org.opencontainers.image.revision={{ .FullCommit }}"
36+
- "--label=org.opencontainers.image.version={{ .Version }}"
37+
- "--label=org.opencontainers.image.source={{ .GitURL }}"
38+
39+
- image_templates:
40+
- 'ghcr.io/kilnfi/cardano-validator-watcher:{{ .Tag }}-arm64'
41+
dockerfile: Dockerfile
42+
use: buildx
43+
goos: linux
44+
goarch: arm64
45+
build_flag_templates:
46+
- "--pull"
47+
- "--build-arg=ARCH=linux/arm64"
48+
- "--platform=linux/arm64"
49+
- "--label=org.opencontainers.image.created={{ .Date }}"
50+
- "--label=org.opencontainers.image.name={{ .ProjectName }}"
51+
- "--label=org.opencontainers.image.revision={{ .FullCommit }}"
52+
- "--label=org.opencontainers.image.version={{ .Version }}"
53+
- "--label=org.opencontainers.image.source={{ .GitURL }}"
54+
55+
docker_manifests:
56+
- name_template: 'ghcr.io/kilnfi/cardano-validator-watcher:{{ .Tag }}'
57+
image_templates:
58+
- 'ghcr.io/kilnfi/cardano-validator-watcher:{{ .Tag }}-amd64'
59+
- 'ghcr.io/kilnfi/cardano-validator-watcher:{{ .Tag }}-arm64'
60+
- name_template: 'ghcr.io/kilnfi/cardano-validator-watcher:latest'
61+
image_templates:
62+
- 'ghcr.io/kilnfi/cardano-validator-watcher:{{ .Tag }}-amd64'
63+
- 'ghcr.io/kilnfi/cardano-validator-watcher:{{ .Tag }}-arm64'
64+
changelog:
65+
disable: true

.tool-versions

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
golang 1.22.4

Dockerfile

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
# Builder
2+
ARG BUILDER=golang:1.22-alpine3.19
3+
ARG RUNNER=alpine:3.19
4+
ARG CARDANO_VERSION=10.1.3
5+
ARG CNCLI_VERSION=6.5.1
6+
7+
FROM ${BUILDER} AS builder
8+
9+
ARG CARDANO_VERSION
10+
ARG CNCLI_VERSION
11+
12+
WORKDIR /workspace
13+
14+
COPY . .
15+
16+
RUN apk --no-cache add gcc musl-dev
17+
18+
RUN go mod download \
19+
&& go mod verify
20+
21+
RUN mkdir -p bin \
22+
&& wget https://github.com/IntersectMBO/cardano-node/releases/download/${CARDANO_VERSION}/cardano-node-${CARDANO_VERSION}-linux.tar.gz -O - | tar --strip-components=2 -xvzf - ./bin/cardano-cli -C bin \
23+
&& wget https://github.com/cardano-community/cncli/releases/download/v${CNCLI_VERSION}/cncli-${CNCLI_VERSION}-ubuntu22-x86_64-unknown-linux-musl.tar.gz -O - | tar -xvzf - -C bin \
24+
&& chmod +x ./bin/cncli
25+
26+
ENV CGO_ENABLED=1
27+
RUN go build -v -o /usr/local/bin/cardano-validator-watcher cmd/watcher/main.go
28+
29+
FROM ${RUNNER}
30+
31+
WORKDIR /home/cardano
32+
33+
RUN apk --no-cache add ca-certificates curl sqlite \
34+
&& update-ca-certificates
35+
36+
COPY --from=builder /usr/local/bin/cardano-validator-watcher .
37+
COPY --from=builder /workspace/bin /usr/local/bin
38+
39+
ENTRYPOINT ["/home/cardano/cardano-validator-watcher"]

0 commit comments

Comments
 (0)