Files
IDP-Backend/Dockerfile

31 lines
577 B
Docker

# ---------- Build Stage ----------
FROM golang:1.24 AS builder
# Set working directory
WORKDIR /app
# Copy Go module files and download dependencies
COPY go.mod go.sum ./
RUN go mod download
# Copy source code
COPY . .
# Build the Go binary
RUN CGO_ENABLED=0 GOOS=linux go build -o main ./cmd/api/main.go
# ---------- Final Image ----------
FROM alpine:latest
# Set working directory in final image
WORKDIR /app
# Copy only the binary from builder
COPY --from=builder /app/main .
# Expose the port your app listens on
EXPOSE 8080
# Set default command
CMD ["./main"]