# Use a small Go base image FROM golang:1.24 as builder # Set working directory WORKDIR /app # Copy go mod and sum files COPY go.mod go.sum ./ # Download dependencies RUN go mod download # Copy the rest of the application COPY . . # Build the application RUN go build -o harbormaster . # Use a small base image for the final container FROM alpine:latest # Set working directory WORKDIR /root/ # Copy the compiled binary from the builder stage COPY --from=builder /app/harbormaster . # Expose the port the app runs on EXPOSE 8080 # Run the binary CMD ["/root/harbormaster"]