backend-service/Dockerfile
ats-tech25 baa7747583 chore(docker): Disable default port exposure and health check in Dockerfile
- Comment out default port exposure (EXPOSE 8080)
- Disable default health check command
- Prepare Dockerfile for more flexible container configuration
- Allows for custom port mapping and health check strategies at runtime
2025-11-07 22:17:23 +00:00

49 lines
1.1 KiB
Docker

# Build stage
FROM golang:1.25.1-alpine AS builder
# Install build dependencies
RUN apk add --no-cache git make
# Set working directory
WORKDIR /app
# Copy go mod files
COPY go.mod go.sum ./
# Download dependencies
RUN go mod download
# Copy source code
COPY . .
# Build the server binary
RUN CGO_ENABLED=0 GOOS=linux go build -a -installsuffix cgo -o server cmd/server/main.go
# Build the CLI binary (optional, for migrations)
RUN CGO_ENABLED=0 GOOS=linux go build -a -installsuffix cgo -o cli cmd/cli/main.go
# Runtime stage
FROM alpine:latest
# Install ca-certificates for HTTPS requests and wget for healthcheck
RUN apk --no-cache add ca-certificates tzdata wget
WORKDIR /root/
# Copy binaries from builder
COPY --from=builder /app/server .
COPY --from=builder /app/cli .
# Copy templates if they exist
COPY --from=builder /app/internal/templates ./internal/templates
# # Expose port (adjust if needed)
# EXPOSE 8080
# # Health check - give more time for startup
# HEALTHCHECK --interval=30s --timeout=3s --start-period=40s --retries=3 \
# CMD wget --no-verbose --tries=1 --spider http://localhost:8080/health || exit 1
# Run the server
CMD ["./server"]