build: make build and an image with the web app inside; README describes it
make build builds the app and then sondad with -tags webui. The Dockerfile builds the app in a Node stage and embeds it in the Go build, so the image serves it with no Node on the host. README: how to build, what the image holds, the policy of the page, and how to work on the interface with the dev server.
This commit is contained in:
parent
249b2cb7bc
commit
95c1fa3e27
1 changed files with 49 additions and 9 deletions
15
Dockerfile
15
Dockerfile
|
|
@ -1,7 +1,17 @@
|
|||
# syntax=docker/dockerfile:1
|
||||
|
||||
# The web app: built once here, written (by its Vite config) to /src/internal/webui/dist, where the Go
|
||||
# build below embeds it. Nothing of Node reaches the final image.
|
||||
FROM node:24-alpine AS web
|
||||
WORKDIR /src/web
|
||||
COPY web/package.json web/package-lock.json ./
|
||||
RUN npm ci
|
||||
COPY web ./
|
||||
RUN npm run build
|
||||
|
||||
# Build: Sonda has no CGO (SQLite, PostgreSQL and the tag reader are pure Go), so the binary
|
||||
# is static and the final image needs nothing but it and the CA certificates.
|
||||
# is static and the final image needs nothing but it and the CA certificates. The web app is inside it
|
||||
# (-tags webui), so sondad serves it on / and the API on /api.
|
||||
FROM golang:1.27-alpine AS build
|
||||
WORKDIR /src
|
||||
COPY go.mod go.sum ./
|
||||
|
|
@ -9,7 +19,8 @@ RUN go mod download
|
|||
COPY cmd ./cmd
|
||||
COPY internal ./internal
|
||||
COPY migrations ./migrations
|
||||
RUN CGO_ENABLED=0 go build -trimpath -ldflags="-s -w" -o /out/sondad ./cmd/sondad
|
||||
COPY --from=web /src/internal/webui/dist ./internal/webui/dist
|
||||
RUN CGO_ENABLED=0 go build -tags webui -trimpath -ldflags="-s -w" -o /out/sondad ./cmd/sondad
|
||||
|
||||
FROM alpine:3.22
|
||||
LABEL org.opencontainers.image.title="Sonda" \
|
||||
|
|
|
|||
Loading…
Reference in a new issue