Upload 4 new, 6 modified files from chat-switchboard-v0.5.1.zip
This commit is contained in:
58
Dockerfile
Normal file
58
Dockerfile
Normal file
@@ -0,0 +1,58 @@
|
||||
# ============================================
|
||||
# Chat Switchboard v0.5 - Unified Dockerfile
|
||||
# ============================================
|
||||
# Stage 1: Build Go backend
|
||||
# Stage 2: Download JS vendor libs (marked, DOMPurify)
|
||||
# Stage 3: Production image (nginx + backend)
|
||||
#
|
||||
# Vendor libs are baked in during build so the
|
||||
# app works in disconnected (SCIF) environments
|
||||
# with no CDN access.
|
||||
# ============================================
|
||||
|
||||
# ── Stage 1: Go backend build ────────────────
|
||||
FROM golang:1.22-bookworm AS backend
|
||||
|
||||
WORKDIR /app
|
||||
COPY server/go.mod server/go.sum* ./
|
||||
COPY server/ .
|
||||
RUN go mod download && go mod tidy && go mod verify
|
||||
RUN CGO_ENABLED=0 go build -ldflags="-s -w" -o /bin/switchboard .
|
||||
|
||||
# ── Stage 2: Vendor JS libs ─────────────────
|
||||
FROM node:20-alpine AS vendor
|
||||
|
||||
WORKDIR /vendor
|
||||
RUN npm pack marked@16.3.0 && \
|
||||
tar xzf marked-16.3.0.tgz && \
|
||||
cp package/lib/marked.umd.js marked.min.js && \
|
||||
rm -rf package marked-16.3.0.tgz
|
||||
|
||||
RUN npm pack dompurify@3.2.4 && \
|
||||
tar xzf dompurify-3.2.4.tgz && \
|
||||
cp package/dist/purify.min.js purify.min.js && \
|
||||
rm -rf package dompurify-3.2.4.tgz
|
||||
|
||||
# ── Stage 3: Production ─────────────────────
|
||||
FROM nginx:1-alpine
|
||||
|
||||
RUN apk add --no-cache bash
|
||||
|
||||
# Go backend binary
|
||||
COPY --from=backend /bin/switchboard /usr/local/bin/switchboard
|
||||
|
||||
# Frontend static files
|
||||
COPY src/ /usr/share/nginx/html/
|
||||
|
||||
# Vendor libs (overwrite any existing copies in src/vendor/)
|
||||
COPY --from=vendor /vendor/marked.min.js /usr/share/nginx/html/vendor/marked.min.js
|
||||
COPY --from=vendor /vendor/purify.min.js /usr/share/nginx/html/vendor/purify.min.js
|
||||
|
||||
# nginx config
|
||||
COPY nginx.conf /etc/nginx/conf.d/default.conf
|
||||
|
||||
# Entrypoint: start Go backend, then nginx
|
||||
COPY docker-entrypoint.sh /docker-entrypoint.d/90-start-backend.sh
|
||||
RUN chmod +x /docker-entrypoint.d/90-start-backend.sh
|
||||
|
||||
EXPOSE 80
|
||||
Reference in New Issue
Block a user