1FROM --platform=${BUILDPLATFORM:-linux/amd64} node:24-alpine3.21 as node_builder
2WORKDIR /app
3RUN npm install tailwindcss @tailwindcss/cli
4
5COPY ./pages/templates /app/templates
6COPY ./pages/static /app/static
7
8RUN npx @tailwindcss/cli -i /app/static/base.css -o /app/static/main.css -m
9
10FROM --platform=${BUILDPLATFORM:-linux/amd64} golang:1.24.3-alpine3.21 as builder
11
12ARG TARGETPLATFORM
13ARG BUILDPLATFORM
14ARG TARGETOS
15ARG TARGETARCH
16
17#needed for sqlite
18RUN apk add --update gcc musl-dev
19
20# step 1. dep cache
21WORKDIR /app
22ARG TARGETPLATFORM=${BUILDPLATFORM:-linux/amd64}
23COPY go.mod go.sum ./
24RUN go mod download
25
26# step 2. build the actual app
27WORKDIR /app
28COPY . .
29#Overwrite the main.css with the one from the builder
30COPY --from=node_builder /app/static/main.css /app/pages/static/main.css
31 #generate the jwks
32RUN GOOS=${TARGETOS} GOARCH=${TARGETARCH} go build -ldflags='-w -s -extldflags "-static"' -o main ./cmd
33ARG TARGETOS=${TARGETPLATFORM%%/*}
34ARG TARGETARCH=${TARGETPLATFORM##*/}
35
36FROM --platform=${TARGETPLATFORM:-linux/amd64} alpine:3.21
37#Creates an empty /db folder for docker compose
38WORKDIR /db
39WORKDIR /app
40COPY --from=builder /app/main /app/main
41ENTRYPOINT ["/app/main"]