This repository has been archived on 2026-04-03. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files
core/Dockerfile.unified

52 lines
1.4 KiB
Docker

# ============================================
# Chat Switchboard - Unified Dockerfile
# ============================================
# Stage 1: Build Go backend
# Stage 2: Build standalone frontend
# Stage 3: Production image (nginx + backend)
#
# nginx serves frontend on :80, proxies /api/ to Go on :8080
# ============================================
# ── Stage 1: Go backend build ────────────────
FROM golang:1.22-bookworm AS backend
WORKDIR /app
COPY server/go.mod server/go.sum* ./
RUN go mod download && go mod verify
COPY server/ .
RUN CGO_ENABLED=0 go build -ldflags="-s -w" -o /bin/switchboard .
# ── Stage 2: Frontend build ──────────────────
FROM alpine:3.19 AS frontend
WORKDIR /app
RUN apk add --no-cache bash coreutils
COPY build.sh ./
COPY src ./src
RUN chmod +x build.sh && ./build.sh
# ── Stage 3: Production ─────────────────────
FROM nginx:1-alpine
RUN apk add --no-cache bash
# Copy Go backend
COPY --from=backend /bin/switchboard /usr/local/bin/switchboard
# Copy built frontend
COPY --from=frontend /app/standalone /usr/share/nginx/html
# Copy nginx config
COPY nginx.conf /etc/nginx/conf.d/default.conf
# Startup script: launches Go backend before nginx starts
COPY scripts/docker-entrypoint.sh /docker-entrypoint.d/90-start-backend.sh
RUN chmod +x /docker-entrypoint.d/90-start-backend.sh
EXPOSE 80