fix: add web-builder Docker stage for JSX compilation
All checks were successful
check / check (push) Successful in 2m16s
All checks were successful
check / check (push) Successful in 2m16s
The previous rework removed web/dist/ from git tracking (correct) but did not add a web-builder stage to the Dockerfile. This caused //go:embed dist/* in web/embed.go to fail with 'no matching files found'. Add the 4-stage Dockerfile layout: 1. web-builder: compile Preact JSX SPA via esbuild 2. lint: format checking and linting with placeholder dist files 3. builder: compile Go binaries with real web assets from web-builder 4. runtime: minimal Alpine image with neoircd binary Also update README to document the 4-stage build.
This commit is contained in:
36
README.md
36
README.md
@@ -1858,26 +1858,16 @@ docker run -p 8080:8080 \
|
||||
neoirc
|
||||
```
|
||||
|
||||
The Dockerfile is a multi-stage build:
|
||||
1. **Build stage**: Compiles `neoircd` and `neoirc-cli` (CLI built to verify
|
||||
compilation, not included in final image)
|
||||
2. **Final stage**: Alpine Linux + `neoircd` binary only
|
||||
The Dockerfile is a 4-stage build:
|
||||
1. **Web builder stage** (`web-builder`): Compiles the Preact JSX SPA into
|
||||
static assets (`web/dist/`) using esbuild
|
||||
2. **Lint stage** (`lint`): Runs formatting checks and linting via golangci-lint
|
||||
3. **Build stage** (`builder`): Compiles `neoircd` and `neoirc-cli`, runs tests
|
||||
(CLI built to verify compilation, not included in final image)
|
||||
4. **Runtime stage**: Alpine Linux + `neoircd` binary only
|
||||
|
||||
```dockerfile
|
||||
FROM golang:1.24-alpine AS builder
|
||||
WORKDIR /src
|
||||
RUN apk add --no-cache make
|
||||
COPY go.mod go.sum ./
|
||||
RUN go mod download
|
||||
COPY . .
|
||||
RUN go build -o /neoircd ./cmd/neoircd/
|
||||
RUN go build -o /neoirc-cli ./cmd/neoirc-cli/
|
||||
|
||||
FROM alpine:latest
|
||||
COPY --from=builder /neoircd /usr/local/bin/neoircd
|
||||
EXPOSE 8080
|
||||
CMD ["neoircd"]
|
||||
```
|
||||
`web/dist/` is not committed to git — it is built from `web/src/` by the
|
||||
web-builder stage during `docker build`.
|
||||
|
||||
### Binary
|
||||
|
||||
@@ -2339,7 +2329,13 @@ neoirc/
|
||||
│ └── http.go # HTTP timeouts
|
||||
├── web/
|
||||
│ ├── embed.go # go:embed directive for SPA
|
||||
│ └── dist/ # Built SPA (vanilla JS, no build step)
|
||||
│ ├── build.sh # esbuild script: JSX → dist/
|
||||
│ ├── package.json # Node dependencies (esbuild, preact)
|
||||
│ ├── src/ # SPA source (Preact JSX)
|
||||
│ │ ├── app.jsx
|
||||
│ │ ├── index.html
|
||||
│ │ └── style.css
|
||||
│ └── dist/ # Built SPA (generated by web-builder Docker stage)
|
||||
│ ├── index.html
|
||||
│ ├── style.css
|
||||
│ └── app.js
|
||||
|
||||
Reference in New Issue
Block a user