forked from algorand/indexer
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: Add Goreleaser/Docker image builds (algorand#1541)
- Loading branch information
1 parent
4245d7b
commit cb2f428
Showing
6 changed files
with
139 additions
and
36 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,6 +5,7 @@ api/.3tmp.json | |
api/generate | ||
tmp/ | ||
./conduit-docs/ | ||
dist | ||
|
||
# Binaries for programs and plugins | ||
*.exe | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
before: | ||
hooks: | ||
# You may remove this if you don't use go modules. | ||
- go mod tidy | ||
# you may remove this if you don't need go generate | ||
- go generate ./... | ||
|
||
# Build mac universal binary. | ||
universal_binaries: | ||
- replace: true | ||
|
||
builds: | ||
- main: ./cmd/algorand-indexer | ||
binary: algorand-indexer | ||
env: | ||
- CGO_ENABLED=0 | ||
goos: | ||
- linux | ||
- windows | ||
- darwin | ||
# skip 386 architecture. | ||
goarch: | ||
- amd64 | ||
- arm64 | ||
ldflags: > | ||
-s -w | ||
-X github.com/algorand/indexer/version.Hash={{.FullCommit}} | ||
-X github.com/algorand/indexer/version.ShortHash={{.ShortCommit}} | ||
-X github.com/algorand/indexer/version.CompileTime={{.Timestamp}} | ||
-X github.com/algorand/indexer/version.ReleaseVersion={{.Version}} | ||
dockers: | ||
- use: buildx | ||
goos: linux | ||
goarch: amd64 | ||
image_templates: | ||
- "algorand/indexer:latest{{ if .IsSnapshot }}-snapshot{{ end }}-amd64" | ||
- "algorand/indexer:{{ .Version }}-amd64" | ||
build_flag_templates: | ||
- --platform=linux/amd64 | ||
- --label=org.opencontainers.image.title={{ .ProjectName }} | ||
- --label=org.opencontainers.image.version={{ .Version }} | ||
- --label=org.opencontainers.image.created={{ .Date }} | ||
- --label=org.opencontainers.image.revision={{ .FullCommit }} | ||
- --label=org.opencontainers.image.licenses=MIT | ||
extra_files: | ||
- docker/docker-entrypoint.sh | ||
- use: buildx | ||
goos: linux | ||
goarch: arm64 | ||
image_templates: | ||
- "algorand/indexer:latest{{ if .IsSnapshot }}-snapshot{{ end }}-arm64" | ||
- "algorand/indexer:{{ .Version }}-arm64" | ||
build_flag_templates: | ||
- --platform=linux/arm64 | ||
- --label=org.opencontainers.image.title={{ .ProjectName }} | ||
- --label=org.opencontainers.image.version={{ .Version }} | ||
- --label=org.opencontainers.image.created={{ .Date }} | ||
- --label=org.opencontainers.image.revision={{ .FullCommit }} | ||
- --label=org.opencontainers.image.licenses=MIT | ||
extra_files: | ||
- docker/docker-entrypoint.sh | ||
|
||
# automatically select amd64/arm64 when requesting "algorand/indexer" | ||
docker_manifests: | ||
- name_template: "algorand/indexer:{{ .Version }}" | ||
image_templates: | ||
- "algorand/indexer:{{ .Version }}-amd64" | ||
- "algorand/indexer:{{ .Version }}-arm64" | ||
- name_template: "algorand/indexer:latest{{ if .IsSnapshot }}-snapshot{{ end }}" | ||
image_templates: | ||
- "algorand/indexer:latest{{ if .IsSnapshot }}-snapshot{{ end }}-amd64" | ||
- "algorand/indexer:latest{{ if .IsSnapshot }}-snapshot{{ end }}-arm64" | ||
|
||
archives: | ||
|
||
- name_template: '{{ .ProjectName }}_{{ .Os }}_{{ .Arch }}{{ if .Arm }}v{{ .Arm }}{{ end }}' | ||
checksum: | ||
name_template: 'checksums.txt' | ||
snapshot: | ||
name_template: "{{ incpatch .Version }}-next" | ||
changelog: | ||
sort: asc | ||
filters: | ||
exclude: | ||
- '^chore:' | ||
- '^docs:' | ||
- '^test:' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
# Build this Dockerfile with goreleaser. | ||
# The binary must be present at /algorand-indexer | ||
FROM debian:bullseye-slim | ||
|
||
# Hard code UID/GID to 999 for consistency in advanced deployments. | ||
# Install ca-certificates to enable using infra providers. | ||
# Install gosu for fancy data directory management. | ||
RUN groupadd --gid=999 --system algorand && \ | ||
useradd --uid=999 --no-log-init --create-home --system --gid algorand algorand && \ | ||
mkdir -p /data && \ | ||
chown -R algorand.algorand /data && \ | ||
apt-get update && \ | ||
apt-get install -y --no-install-recommends gosu ca-certificates && \ | ||
update-ca-certificates && \ | ||
apt-get clean && \ | ||
rm -rf /var/lib/apt/lists/* | ||
|
||
COPY algorand-indexer /usr/local/bin/algorand-indexer | ||
COPY docker/docker-entrypoint.sh /usr/local/bin/docker-entrypoint.sh | ||
|
||
ENV INDEXER_DATA /data | ||
WORKDIR /data | ||
# Note: docker-entrypoint.sh calls 'algorand-indexer'. Similar entrypoint scripts | ||
# accept the binary as the first argument in order to surface a suite of | ||
# tools (i.e. algod, goal, algocfg, ...). Maybe this will change in the | ||
# future, but for now this approach seemed simpler. | ||
ENTRYPOINT ["docker-entrypoint.sh"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
#!/usr/bin/env bash | ||
set -e | ||
|
||
# To allow mounting the data directory we need to change permissions | ||
# to our algorand user. The script is initially run as the root user | ||
# in order to change permissions; afterwards, the script is re-launched | ||
# as the algorand user. | ||
if [ "$(id -u)" = '0' ]; then | ||
chown -R algorand:algorand $INDEXER_DATA | ||
exec gosu algorand "$0" "$@" | ||
fi | ||
|
||
# copy indexer.yml override to data directory | ||
if [[ -f /etc/algorand/indexer.yml ]]; then | ||
cp /etc/algorand/indexer.yml /data/indexer.yml | ||
fi | ||
|
||
# always run the algorand-indexer command | ||
exec algorand-indexer "$@" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters