-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile
31 lines (25 loc) · 862 Bytes
/
Dockerfile
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
FROM docker.io/golang:1.23.3-alpine AS build
# Install build dependencies
RUN apk add --no-cache upx nodejs npm
RUN npm install -g pnpm
# Install Task
RUN wget -O- https://taskfile.dev/install.sh | sh
WORKDIR /src
COPY . ./
# Install dependencies and generate static files
RUN go mod download
RUN pnpm install
RUN task build:styles # Generate CSS
RUN task build:templ # Generate templ files
RUN task build:esbuild # Bundle JS
# Build the Go binary
RUN --mount=type=cache,target=/root/.cache/go-build \
go build -ldflags="-s" -o /bin/main .
RUN upx -9 -k /bin/main
FROM scratch
COPY --from=build /bin/main /
COPY --from=build /src/web/static /web/static
COPY --from=build /src/web/custom-elements /web/custom-elements
COPY --from=build /src/wasm/enhance-ssr.wasm /wasm/enhance-ssr.wasm
COPY --from=build /src/content /content
ENTRYPOINT ["/main"]