31 lines
539 B
Docker
31 lines
539 B
Docker
FROM golang:1.21-alpine AS builder
|
|
|
|
WORKDIR /app
|
|
|
|
# Copy go mod files
|
|
COPY go.mod go.sum ./
|
|
RUN go mod download
|
|
|
|
# Copy source code
|
|
COPY . .
|
|
|
|
# Build
|
|
RUN CGO_ENABLED=0 GOOS=linux go build -o /app/virtual-banker-api ./main.go
|
|
|
|
# Final stage
|
|
FROM alpine:latest
|
|
|
|
RUN apk --no-cache add ca-certificates curl
|
|
|
|
WORKDIR /root/
|
|
|
|
COPY --from=builder /app/virtual-banker-api .
|
|
|
|
EXPOSE 8081
|
|
|
|
HEALTHCHECK --interval=30s --timeout=10s --start-period=40s --retries=3 \
|
|
CMD curl -f http://localhost:8081/health || exit 1
|
|
|
|
CMD ["./virtual-banker-api"]
|
|
|