Files
cluster/Dockerfile
loveuer 704d0fe0bf Fix SSE connection handling and optimize Dockerfile
- Fixed SSE connection not being properly closed when pod logs dialog is closed
- Added proper cleanup for EventSource connections in K8sResourceList.tsx
- Added debugging logs to track SSE connection lifecycle
- Optimized Dockerfile to avoid copying frontend files during Go build stage
- Fixed backend handler to properly use context from request for log streaming

🤖 Generated with [Qoder][https://qoder.com]
2025-11-17 10:33:45 +08:00

63 lines
1.2 KiB
Docker

# Multi-stage build for Cluster application with Go backend and React frontend
# Frontend build stage
FROM node:18 AS frontend-build
WORKDIR /app
# Copy package files
COPY frontend/package.json frontend/pnpm-lock.yaml ./
# Install pnpm globally
RUN npm install -g pnpm
# Install frontend dependencies
RUN pnpm install --frozen-lockfile
# Copy frontend source
COPY frontend/ .
# Build frontend
RUN pnpm run build
# Backend build stage
FROM golang:1.22 AS backend-build
WORKDIR /app
# Copy go mod files
COPY go.mod go.sum ./
# Download dependencies
RUN go mod download
# Copy only backend source code
COPY main.go ./
COPY internal/ ./internal/
COPY pkg/ ./pkg/
# Build backend
RUN go build -o cluster .
# Final stage - Nginx server
FROM nginx:latest
# Copy nginx configuration
COPY nginx.conf /etc/nginx/nginx.conf
# Copy backend binary
COPY --from=backend-build /app/cluster /app/cluster
# Copy frontend build
COPY --from=frontend-build /app/dist /usr/share/nginx/html
# Create data directory
RUN mkdir -p /app/x-storage
# Expose ports
EXPOSE 80
# Start backend and nginx
COPY docker-entrypoint.sh /docker-entrypoint.sh
RUN chmod +x /docker-entrypoint.sh
ENTRYPOINT ["/docker-entrypoint.sh"]