-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdockerfile
More file actions
49 lines (34 loc) · 968 Bytes
/
dockerfile
File metadata and controls
49 lines (34 loc) · 968 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# templ + go build
FROM golang:1.24 AS build-stage
WORKDIR /app
# install templ
RUN go install github.com/a-h/templ/cmd/templ@latest
# copy go.mod early for caching
COPY go.mod go.sum ./
RUN go mod download
# copy source
COPY . .
# generate .go files from templ
RUN templ generate
# build Go binary
RUN CGO_ENABLED=0 GOOS=linux go build -o /entrypoint
# tailwind build
FROM node:20-alpine AS tailwind-stage
WORKDIR /app
# copy configs
COPY tailwind.config.js package.json package-lock.json ./
# copy assets
COPY assets ./assets
# copy templ files so tailwind can scan them
COPY views ./views
RUN npm ci
RUN mkdir -p ./assets/css
RUN npx tailwindcss -i ./assets/css/input.css -o ./assets/css/style.css --minify
# final release stage
FROM gcr.io/distroless/static-debian11 AS release-stage
WORKDIR /
COPY --from=build-stage /entrypoint /entrypoint
COPY --from=tailwind-stage /app/assets /assets
EXPOSE 8080
USER nonroot:nonroot
ENTRYPOINT ["/entrypoint"]