Compare commits
4 Commits
1e9fb36f5b
...
3513943d47
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
3513943d47 | ||
|
|
5b07730bd2 | ||
|
|
5d0b362c0f | ||
| 687c958bd1 |
14
Dockerfile
14
Dockerfile
@@ -1,3 +1,13 @@
|
|||||||
|
# Web build stage — compile SPA from source
|
||||||
|
# node:22-alpine, 2026-03-09
|
||||||
|
FROM node@sha256:8094c002d08262dba12645a3b4a15cd6cd627d30bc782f53229a2ec13ee22a00 AS web-builder
|
||||||
|
WORKDIR /web
|
||||||
|
COPY web/package.json web/package-lock.json ./
|
||||||
|
RUN npm ci
|
||||||
|
COPY web/src/ src/
|
||||||
|
COPY web/build.sh build.sh
|
||||||
|
RUN sh build.sh
|
||||||
|
|
||||||
# Lint stage — fast feedback on formatting and lint issues
|
# Lint stage — fast feedback on formatting and lint issues
|
||||||
# golangci/golangci-lint:v2.1.6, 2026-03-02
|
# golangci/golangci-lint:v2.1.6, 2026-03-02
|
||||||
FROM golangci/golangci-lint@sha256:568ee1c1c53493575fa9494e280e579ac9ca865787bafe4df3023ae59ecf299b AS lint
|
FROM golangci/golangci-lint@sha256:568ee1c1c53493575fa9494e280e579ac9ca865787bafe4df3023ae59ecf299b AS lint
|
||||||
@@ -5,6 +15,9 @@ WORKDIR /src
|
|||||||
COPY go.mod go.sum ./
|
COPY go.mod go.sum ./
|
||||||
RUN go mod download
|
RUN go mod download
|
||||||
COPY . .
|
COPY . .
|
||||||
|
# Create placeholder files so //go:embed dist/* in web/embed.go resolves
|
||||||
|
# without depending on the web-builder stage (lint should fail fast)
|
||||||
|
RUN mkdir -p web/dist && touch web/dist/index.html web/dist/style.css web/dist/app.js
|
||||||
RUN make fmt-check
|
RUN make fmt-check
|
||||||
RUN make lint
|
RUN make lint
|
||||||
|
|
||||||
@@ -21,6 +34,7 @@ COPY go.mod go.sum ./
|
|||||||
RUN go mod download
|
RUN go mod download
|
||||||
|
|
||||||
COPY . .
|
COPY . .
|
||||||
|
COPY --from=web-builder /web/dist/ web/dist/
|
||||||
|
|
||||||
RUN make test
|
RUN make test
|
||||||
|
|
||||||
|
|||||||
38
README.md
38
README.md
@@ -1376,6 +1376,7 @@ Return server metadata. No authentication required.
|
|||||||
```json
|
```json
|
||||||
{
|
{
|
||||||
"name": "My NeoIRC Server",
|
"name": "My NeoIRC Server",
|
||||||
|
"version": "0.1.0",
|
||||||
"motd": "Welcome! Be nice.",
|
"motd": "Welcome! Be nice.",
|
||||||
"users": 42,
|
"users": 42,
|
||||||
"hashcash_bits": 20
|
"hashcash_bits": 20
|
||||||
@@ -1385,6 +1386,7 @@ Return server metadata. No authentication required.
|
|||||||
| Field | Type | Description |
|
| Field | Type | Description |
|
||||||
|-----------------|---------|-------------|
|
|-----------------|---------|-------------|
|
||||||
| `name` | string | Server display name |
|
| `name` | string | Server display name |
|
||||||
|
| `version` | string | Server version |
|
||||||
| `motd` | string | Message of the day |
|
| `motd` | string | Message of the day |
|
||||||
| `users` | integer | Number of currently active user sessions |
|
| `users` | integer | Number of currently active user sessions |
|
||||||
| `hashcash_bits` | integer | Required proof-of-work difficulty (leading zero bits). Only present when > 0. See [Hashcash Proof-of-Work](#hashcash-proof-of-work). |
|
| `hashcash_bits` | integer | Required proof-of-work difficulty (leading zero bits). Only present when > 0. See [Hashcash Proof-of-Work](#hashcash-proof-of-work). |
|
||||||
@@ -1856,26 +1858,16 @@ docker run -p 8080:8080 \
|
|||||||
neoirc
|
neoirc
|
||||||
```
|
```
|
||||||
|
|
||||||
The Dockerfile is a multi-stage build:
|
The Dockerfile is a 4-stage build:
|
||||||
1. **Build stage**: Compiles `neoircd` and `neoirc-cli` (CLI built to verify
|
1. **Web builder stage** (`web-builder`): Compiles the Preact JSX SPA into
|
||||||
compilation, not included in final image)
|
static assets (`web/dist/`) using esbuild
|
||||||
2. **Final stage**: Alpine Linux + `neoircd` binary only
|
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
|
`web/dist/` is not committed to git — it is built from `web/src/` by the
|
||||||
FROM golang:1.24-alpine AS builder
|
web-builder stage during `docker build`.
|
||||||
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"]
|
|
||||||
```
|
|
||||||
|
|
||||||
### Binary
|
### Binary
|
||||||
|
|
||||||
@@ -2337,7 +2329,13 @@ neoirc/
|
|||||||
│ └── http.go # HTTP timeouts
|
│ └── http.go # HTTP timeouts
|
||||||
├── web/
|
├── web/
|
||||||
│ ├── embed.go # go:embed directive for SPA
|
│ ├── 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
|
│ ├── index.html
|
||||||
│ ├── style.css
|
│ ├── style.css
|
||||||
│ └── app.js
|
│ └── app.js
|
||||||
|
|||||||
@@ -2364,6 +2364,7 @@ func (hdlr *Handlers) HandleServerInfo() http.HandlerFunc {
|
|||||||
|
|
||||||
resp := map[string]any{
|
resp := map[string]any{
|
||||||
"name": hdlr.params.Config.ServerName,
|
"name": hdlr.params.Config.ServerName,
|
||||||
|
"version": hdlr.params.Globals.Version,
|
||||||
"motd": hdlr.params.Config.MOTD,
|
"motd": hdlr.params.Config.MOTD,
|
||||||
"users": users,
|
"users": users,
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user