Add Docker, Kubernetes configurations, and CI workflows for deployment. Integrate Gin server for API, WebSocket support, and static file hosting. Refactor WebSocket gateway to use Gin router.
Dynamic Branch Deploy / build-and-deploy (push) Has been cancelled
Dynamic Branch Deploy / build-and-deploy (push) Has been cancelled
This commit is contained in:
+45
@@ -0,0 +1,45 @@
|
||||
# Stage 1: Builder
|
||||
FROM golang:1.25.5-alpine AS builder
|
||||
|
||||
# Build-Dependencies
|
||||
RUN apk add --no-cache git
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
# Dependencies cachen
|
||||
COPY go.mod go.sum ./
|
||||
RUN go mod download
|
||||
|
||||
# Source Code kopieren
|
||||
COPY . .
|
||||
|
||||
# Server binary bauen
|
||||
RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -a -installsuffix cgo -ldflags="-w -s" -o server ./cmd/server
|
||||
|
||||
# WASM Client bauen
|
||||
RUN GOOS=js GOARCH=wasm go build -o cmd/client/web/main.wasm ./cmd/client
|
||||
|
||||
# Stage 2: Production Image
|
||||
FROM alpine:latest
|
||||
|
||||
RUN apk --no-cache add ca-certificates curl tzdata && \
|
||||
addgroup -g 1000 appuser && \
|
||||
adduser -D -u 1000 -G appuser appuser
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
# Binary und Web-Dateien vom Builder kopieren
|
||||
COPY --from=builder /app/server .
|
||||
COPY --from=builder /app/cmd/client/web ./cmd/client/web
|
||||
|
||||
# User wechseln
|
||||
USER appuser
|
||||
|
||||
# Port für HTTP/WebSocket
|
||||
EXPOSE 8080
|
||||
|
||||
# Healthcheck
|
||||
HEALTHCHECK --interval=30s --timeout=3s --start-period=5s --retries=3 \
|
||||
CMD curl -f http://localhost:8080/health || exit 1
|
||||
|
||||
CMD ["./server"]
|
||||
Reference in New Issue
Block a user