-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: improve dockerfile to allow full builds and goreleaser builds
- Loading branch information
Showing
1 changed file
with
52 additions
and
2 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 |
---|---|---|
@@ -1,3 +1,53 @@ | ||
FROM scratch | ||
ARG VERSION=develop | ||
ARG GIT_COMMIT=unknown | ||
ARG GO_VERSION=1.23.2 | ||
|
||
FROM golang:${GO_VERSION}-alpine3.20 AS builder | ||
ARG VERSION | ||
ARG GIT_COMMIT | ||
ARG GO_VERSION | ||
|
||
WORKDIR /app | ||
|
||
COPY go.mod go.sum . | ||
|
||
RUN go mod download | ||
|
||
COPY main.go /app/main.go | ||
COPY api/ /app/api/ | ||
COPY cmd/ /app/cmd/ | ||
COPY internal/ /app/internal/ | ||
|
||
RUN CGO_ENABLED=0 go build -o /usr/local/bin/goarkitect \ | ||
-ldflags="-s -w -X main.version=${VERSION} -X main.gitCommit=${GIT_COMMIT} -X main.buildTime=$(date -u +'%Y-%m-%dT%H:%M:%SZ') -X main.goVersion=${GO_VERSION} -X main.osArch=$(uname -m)" \ | ||
. | ||
|
||
FROM gcr.io/distroless/static AS static | ||
|
||
LABEL maintainer="omissis" | ||
# LABEL org.opencontainers.image.created | ||
LABEL org.opencontainers.image.authors="omissis" | ||
LABEL org.opencontainers.image.url="https://github.com/omissis/goarkitect" | ||
LABEL org.opencontainers.image.documentation="https://github.com/omissis/goarkitect" | ||
LABEL org.opencontainers.image.source="https://github.com/omissis/goarkitect" | ||
# LABEL org.opencontainers.image.version | ||
# LABEL org.opencontainers.image.revision | ||
LABEL org.opencontainers.image.vendor="Omissis" | ||
# LABEL org.opencontainers.image.licenses | ||
# LABEL org.opencontainers.image.ref.name | ||
LABEL org.opencontainers.image.title="goarkitect" | ||
LABEL org.opencontainers.image.description="Describe and check architectural constraints of a project using a composable set of rules." | ||
# LABEL org.opencontainers.image.base.digest | ||
# LABEL org.opencontainers.image.base.name | ||
|
||
USER nonroot:nonroot | ||
|
||
ENTRYPOINT ["/goarkitect"] | ||
COPY goarkitect / | ||
|
||
FROM static AS dockerbuild | ||
|
||
COPY --from=builder /usr/local/bin/goarkitect /goarkitect | ||
|
||
FROM static AS goreleaser | ||
|
||
COPY goarkitect /goarkitect |