[BACKEND] Initialize Go backend structure and dependencies (#23)
This commit is contained in:
@@ -1,5 +1,8 @@
|
||||
# ==========================================
|
||||
# Chat Switchboard Backend Dockerfile
|
||||
# Chat Switchboard - Backend Dockerfile
|
||||
# ==========================================
|
||||
# Standalone Go API server for cluster deployment.
|
||||
# Build context is ./server (not repo root).
|
||||
# ==========================================
|
||||
|
||||
# Build stage
|
||||
@@ -7,16 +10,14 @@ FROM golang:1.22-bookworm AS builder
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
# Copy go mod files first for caching
|
||||
# Build context is ./server, so paths are relative to that
|
||||
COPY go.mod go.sum ./
|
||||
# Copy module files and download deps
|
||||
COPY go.mod go.sum* ./
|
||||
RUN go mod download
|
||||
|
||||
# Copy source code from server directory
|
||||
# Copy source and tidy (resolves any go.sum gaps)
|
||||
COPY . .
|
||||
|
||||
# Build the application
|
||||
RUN CGO_ENABLED=1 go build -o /bin/engine .
|
||||
RUN go mod tidy
|
||||
RUN CGO_ENABLED=0 go build -ldflags="-s -w" -o /bin/switchboard .
|
||||
|
||||
# Runtime stage
|
||||
FROM debian:bookworm-slim
|
||||
@@ -25,11 +26,8 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
|
||||
ca-certificates \
|
||||
&& rm -rf /var/lib/apt/lists/*
|
||||
|
||||
COPY --from=builder /bin/engine /usr/local/bin/engine
|
||||
COPY --from=builder /bin/switchboard /usr/local/bin/switchboard
|
||||
|
||||
WORKDIR /app
|
||||
EXPOSE 8080
|
||||
|
||||
VOLUME ["/app/data"]
|
||||
|
||||
ENTRYPOINT ["engine"]
|
||||
CMD ["serve"]
|
||||
ENTRYPOINT ["switchboard"]
|
||||
|
||||
Reference in New Issue
Block a user