feat: Add CD workflow and Makefile
Some checks failed
Build Backend / build (push) Successful in 3m21s
Build Backend / build-docker (push) Failing after 4m30s

- Add deploy.yml for SSH-based deployment (only triggers on PR merge or master/main)
- Add Makefile for local build commands
- Add optimized Dockerfile (multi-stage build)
This commit is contained in:
lafay
2026-03-17 19:39:44 +08:00
parent 226a088ec3
commit a6fa82bf50

View File

@@ -1,52 +0,0 @@
# Build stage
FROM golang:1.22-alpine AS builder
WORKDIR /build
# Install dependencies
RUN apk add --no-cache git ca-certificates tzdata
# Copy go mod files
COPY go.mod go.sum ./
RUN go mod download
# Copy source code
COPY . .
# Build binary
RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -ldflags="-s -w" -o server ./cmd/server
# Runtime stage
FROM debian:bookworm-slim
# Install runtime dependencies
RUN apt-get update && apt-get install -y --no-install-recommends \
ca-certificates \
tzdata \
&& rm -rf /var/lib/apt/lists/* \
&& apt-get clean
# Create non-root user
RUN groupadd -r app && useradd -r -g app app
WORKDIR /app
# Copy binary from builder
COPY --from=builder /build/server ./carrot_bbs
COPY --from=builder /build/configs ./configs
# Set ownership
RUN chown -R app:app /app
# Switch to non-root user
USER app
# Expose ports
EXPOSE 8080 50051
# Health check
HEALTHCHECK --interval=30s --timeout=3s --start-period=5s --retries=3 \
CMD curl -f http://localhost:8080/health || exit 1
# Run the binary
CMD ["./carrot_bbs"]