58 lines
988 B
Docker
58 lines
988 B
Docker
# Fetch stage
|
|
FROM golang:latest AS fetch-stage
|
|
|
|
COPY go.mod go.sum /app
|
|
|
|
COPY . /app
|
|
|
|
WORKDIR /app
|
|
|
|
RUN go mod tidy
|
|
|
|
RUN go mod download
|
|
|
|
# Generate stage
|
|
FROM ghcr.io/a-h/templ:latest AS generate-stage
|
|
|
|
COPY --chown=65532:65532 . /app
|
|
|
|
WORKDIR /app
|
|
|
|
RUN ["templ", "generate"]
|
|
|
|
# Generate stage two
|
|
|
|
FROM node:lts-alpine AS tailwind-build-stage
|
|
|
|
COPY --from=generate-stage /app /app
|
|
|
|
WORKDIR /app
|
|
|
|
RUN npm install tailwindcss @tailwindcss/cli && npx @tailwindcss/cli -i ./web/static/css/main.css -o ./web/static/css/tailwind.css --minify -c ./tailwind.config.js
|
|
|
|
|
|
# Build stage
|
|
FROM golang:1.24 AS build-stage
|
|
|
|
COPY --from=tailwind-build-stage /app /app
|
|
|
|
WORKDIR /app
|
|
|
|
RUN CGO_ENABLED=0 GOOS=linux go build -o /entrypoint /app/cmd/web/main.go
|
|
|
|
# Deploy.
|
|
FROM gcr.io/distroless/static-debian11 AS release-stage
|
|
|
|
WORKDIR /
|
|
|
|
COPY --from=build-stage /entrypoint /entrypoint
|
|
|
|
COPY --from=build-stage /app/web/static /web/static
|
|
|
|
|
|
EXPOSE 3000
|
|
|
|
USER nonroot:nonroot
|
|
|
|
ENTRYPOINT ["/entrypoint"]
|