-
Notifications
You must be signed in to change notification settings - Fork 77
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
docker: add hemictl image #407
base: main
Are you sure you want to change the base?
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
# Copyright (c) 2024 Hemi Labs, Inc. | ||
jcvernaleo marked this conversation as resolved.
Show resolved
Hide resolved
|
||
# Use of this source code is governed by the MIT License, | ||
# which can be found in the LICENSE file. | ||
|
||
# Build stage | ||
FROM golang:1.23-alpine3.20@sha256:d0b31558e6b3e4cc59f6011d79905835108c919143ebecc58f35965bf79948f4 AS builder | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not blocking - The latest available |
||
|
||
ARG GO_LDFLAGS | ||
|
||
# Add ca-certificates, timezone data, make and git | ||
RUN apk --no-cache add --update ca-certificates tzdata make git | ||
|
||
# Create non-root user | ||
RUN addgroup --gid 65532 hemictl && \ | ||
adduser --disabled-password --gecos "" \ | ||
--home "/etc/hemictl/" --shell "/sbin/nologin" \ | ||
-G hemictl --uid 65532 hemictl | ||
|
||
WORKDIR /build/ | ||
|
||
COPY Makefile . | ||
COPY go.mod . | ||
COPY go.sum . | ||
RUN make deps | ||
|
||
COPY . . | ||
RUN GOOS=$(go env GOOS) GOARCH=$(go env GOARCH) CGO_ENABLED=0 GOGC=off make GO_LDFLAGS="$GO_LDFLAGS" hemictl | ||
|
||
# Run stage | ||
FROM scratch | ||
|
||
# Build metadata | ||
ARG VERSION | ||
ARG VCS_REF | ||
ARG BUILD_DATE | ||
LABEL org.opencontainers.image.created=$BUILD_DATE \ | ||
org.opencontainers.image.authors="Hemi Labs" \ | ||
org.opencontainers.image.url="https://github.com/hemilabs/heminetwork" \ | ||
org.opencontainers.image.source="https://github.com/hemilabs/heminetwork" \ | ||
org.opencontainers.image.version=$VERSION \ | ||
org.opencontainers.image.revision=$VCS_REF \ | ||
org.opencontainers.image.vendor="Hemi Labs" \ | ||
org.opencontainers.image.licenses="MIT" \ | ||
org.opencontainers.image.title="Hemictl" \ | ||
org.label-schema.build-date=$BUILD_DATE \ | ||
org.label-schema.name="Hemictl" \ | ||
org.label-schema.url="https://github.com/hemilabs/heminetwork" \ | ||
org.label-schema.vcs-url="https://github.com/hemilabs/heminetwork" \ | ||
org.label-schema.vcs-ref=$VCS_REF \ | ||
org.label-schema.vendor="Hemi Labs" \ | ||
org.label-schema.version=$VERSION \ | ||
org.label-schema.schema-version="1.0" | ||
|
||
# Copy files | ||
COPY --from=builder /etc/group /etc/group | ||
COPY --from=builder /etc/passwd /etc/passwd | ||
COPY --from=builder /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/ | ||
COPY --from=builder /usr/share/zoneinfo /usr/share/zoneinfo | ||
COPY --from=builder /build/bin/hemictl /usr/local/bin/hemictl | ||
|
||
# Environment variables | ||
ENV HEMICTL_BSS_URL="" | ||
ENV HEMICTL_LOG_LEVEL="" | ||
|
||
USER hemictl:hemictl | ||
WORKDIR /etc/hemictl/ | ||
ENTRYPOINT ["/usr/local/bin/hemictl"] |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
# Copyright (c) 2024 Hemi Labs, Inc. | ||
jcvernaleo marked this conversation as resolved.
Show resolved
Hide resolved
|
||
# Use of this source code is governed by the MIT License, | ||
# which can be found in the LICENSE file. | ||
|
||
# Build stage | ||
FROM alpine:3.20.2@sha256:0a4eaa0eecf5f8c050e5bba433f58c052be7587ee8af3e8b3910ef9ab5fbe9f5 AS builder | ||
|
||
# Add ca-certificates, timezone data | ||
RUN apk --no-cache add --update ca-certificates tzdata | ||
|
||
# Create non-root user | ||
RUN addgroup --gid 65532 hemictl && \ | ||
adduser --disabled-password --gecos "" \ | ||
--home "/etc/hemictl/" --shell "/sbin/nologin" \ | ||
-G hemictl --uid 65532 hemictl | ||
|
||
# Run stage | ||
FROM scratch | ||
|
||
# Build metadata | ||
ARG VERSION | ||
ARG VCS_REF | ||
ARG BUILD_DATE | ||
LABEL org.opencontainers.image.created=$BUILD_DATE \ | ||
org.opencontainers.image.authors="Hemi Labs" \ | ||
org.opencontainers.image.url="https://github.com/hemilabs/heminetwork" \ | ||
org.opencontainers.image.source="https://github.com/hemilabs/heminetwork" \ | ||
org.opencontainers.image.version=$VERSION \ | ||
org.opencontainers.image.revision=$VCS_REF \ | ||
org.opencontainers.image.vendor="Hemi Labs" \ | ||
org.opencontainers.image.licenses="MIT" \ | ||
org.opencontainers.image.title="Hemictl" \ | ||
org.label-schema.build-date=$BUILD_DATE \ | ||
org.label-schema.name="Hemictl" \ | ||
org.label-schema.url="https://github.com/hemilabs/heminetwork" \ | ||
org.label-schema.vcs-url="https://github.com/hemilabs/heminetwork" \ | ||
org.label-schema.vcs-ref=$VCS_REF \ | ||
org.label-schema.vendor="Hemi Labs" \ | ||
org.label-schema.version=$VERSION \ | ||
org.label-schema.schema-version="1.0" | ||
|
||
# Copy files | ||
COPY --from=builder /etc/group /etc/group | ||
COPY --from=builder /etc/passwd /etc/passwd | ||
COPY --from=builder /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/ | ||
COPY --from=builder /usr/share/zoneinfo /usr/share/zoneinfo | ||
COPY hemictl /usr/local/bin/hemictl | ||
|
||
# Environment variables | ||
ENV HEMICTL_BSS_URL="" | ||
ENV HEMICTL_LOG_LEVEL="" | ||
|
||
USER hemictl:hemictl | ||
WORKDIR /etc/hemictl/ | ||
ENTRYPOINT ["/usr/local/bin/hemictl"] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks like you also need to add a
binary
forhemictl
, otherwise it won't be built or made available when GoReleaser is creating the Docker images (COPY hemictl /usr/local/bin/hemictl
).The
popmd
binary could be used as an example.Docs: https://goreleaser.com/customization/builds/go/?h=binary