-
|
the docs contains this section to show proper usage of # Fetch
FROM golang:latest AS fetch-stage
COPY go.mod go.sum /app
WORKDIR /app
RUN go mod download
# Generate
FROM ghcr.io/a-h/templ:latest AS generate-stage
COPY --chown=65532:65532 . /app
WORKDIR /app
RUN ["templ", "generate"]
# Build
FROM golang:latest AS build-stage
COPY --from=generate-stage /app /app
WORKDIR /app
RUN CGO_ENABLED=0 GOOS=linux go build -o /app/app
# Test
FROM build-stage AS test-stage
RUN go test -v ./...
# Deploy
FROM gcr.io/distroless/base-debian12 AS deploy-stage
WORKDIR /
COPY --from=build-stage /app/app /app
EXPOSE 8080
USER nonroot:nonroot
ENTRYPOINT ["/app"] |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 3 replies
-
|
It's a modified version of https://docs.docker.com/guides/golang/build-images/#multi-stage-builds Looking at it with fresh eyes, looks like the fetch-stage doesn't have any effect. Feel free to create a PR if you have a better way. Personally, I commit |
Beta Was this translation helpful? Give feedback.
It's a modified version of https://docs.docker.com/guides/golang/build-images/#multi-stage-builds
Looking at it with fresh eyes, looks like the fetch-stage doesn't have any effect.
Feel free to create a PR if you have a better way. Personally, I commit
_templ.gofiles and build Docker containers using Nix tooling.