CUB-112: scaffold Go backend with Chi, pgx, health check
Some checks failed
Dev Build / build-test (pull_request) Failing after 1m39s

This commit is contained in:
dex-bot
2026-05-06 12:20:31 -04:00
parent 42285c5dac
commit 3fe0850711
9 changed files with 261 additions and 29 deletions

View File

@@ -1,37 +1,25 @@
# ── Stage 1: Build ──────────────────────────────────────────
FROM mcr.microsoft.com/dotnet/sdk:9.0 AS build
WORKDIR /src
# Build stage
FROM golang:1.24-alpine AS builder
# Copy csproj first for layer caching — restores before copying source
COPY Extrudex.csproj .
RUN dotnet restore
# Copy the rest of the source
COPY . .
RUN dotnet publish Extrudex.csproj \
-c Release \
-o /app/publish \
--no-restore
# ── Stage 2: Runtime ────────────────────────────────────────
FROM mcr.microsoft.com/dotnet/aspnet:9.0 AS runtime
WORKDIR /app
# Install curl for health check (not included in aspnet base image)
RUN apt-get update && apt-get install -y --no-install-recommends curl && rm -rf /var/lib/apt/lists/*
# Copy go mod files first for caching
COPY go.mod go.sum ./
RUN go mod download
# Non-root user for security
RUN adduser --disabled-password --gecos "" appuser
USER appuser
# Copy source and build
COPY . .
RUN CGO_ENABLED=0 GOOS=linux go build -o server ./cmd/server
# Copy published output from build stage
COPY --from=build /app/publish .
# Final stage
FROM alpine:latest
RUN apk --no-cache add ca-certificates
WORKDIR /root/
# Copy binary from builder
COPY --from=builder /app/server .
# ASP.NET Core listens on 8080 by default in .NET 8+
EXPOSE 8080
# Health check against /health endpoint
HEALTHCHECK --interval=30s --timeout=5s --start-period=10s --retries=3 \
CMD curl --fail http://localhost:8080/health || exit 1
ENTRYPOINT ["dotnet", "Extrudex.dll"]
CMD ["./server"]