# Auto-generated by GitBlixt for Go apps FROM docker.io/golang:1.23-bookworm AS builder WORKDIR /app COPY go.mod go.sum* ./ RUN go mod download COPY . . # If a cmd/ directory exists, build the first command found there; # otherwise build the package at the repo root. RUN if [ -d cmd ] && [ -n "$(ls -A cmd 2>/dev/null)" ]; then \ MAIN=$(ls cmd | head -1); \ CGO_ENABLED=0 GOOS=linux go build -o /app/server ./cmd/$MAIN; \ else \ CGO_ENABLED=0 GOOS=linux go build -o /app/server .; \ fi # --- runner --- FROM docker.io/debian:trixie-slim AS final RUN apt-get update \ && apt-get install -y --no-install-recommends ca-certificates \ && rm -rf /var/lib/apt/lists/* WORKDIR /app COPY --from=builder /app/server /app/server ENV PORT=4000 EXPOSE ${PORT} CMD ["/app/server"]