Replace Go HTML template rendering with a Bun + TSX build-time static site generator. Go backend becomes API-only for auth. Frontend: - Custom JSX-to-HTML-string factory (zero dependencies) - TSX components for Header, Footer, index page, login page - Client-side login.ts handles tab switching and fetch()-based auth - Bun bundler compiles client JS, build.ts renders pages to dist/ Backend: - Auth handlers return JSON (POST /api/login, POST /api/register) - Login page served as static HTML from dist/ - Static assets served from /assets/ (public) - Auth middleware unchanged (cookie check, redirect to /login) - Removed template parsing and renderPage Dockerfile: - 3-stage build: Bun frontend -> Go backend -> alpine runtime - Frontend dist copied to /app/dist in final image Removed: templates/, static/css/ (replaced by frontend/)
20 lines
457 B
Docker
20 lines
457 B
Docker
FROM oven/bun:1 AS frontend
|
|
WORKDIR /app/frontend
|
|
COPY frontend/ .
|
|
RUN bun install && bun run build
|
|
|
|
FROM golang:1.23-alpine AS backend
|
|
WORKDIR /src
|
|
COPY go.mod ./
|
|
RUN go mod download
|
|
COPY . .
|
|
RUN CGO_ENABLED=0 go build -ldflags="-s -w" -o /patholo ./cmd/server
|
|
|
|
FROM alpine:3.21
|
|
RUN apk add --no-cache ca-certificates
|
|
WORKDIR /app
|
|
COPY --from=backend /patholo /app/patholo
|
|
COPY --from=frontend /app/frontend/dist /app/dist
|
|
EXPOSE 8080
|
|
CMD ["/app/patholo"]
|