add Dockerfile for multi-stage build and update generate.go command

This commit is contained in:
2025-08-06 04:08:43 +03:00
parent 416fefdb6b
commit 6d1d079f06
3 changed files with 30 additions and 4 deletions

View File

@ -0,0 +1,30 @@
# ---------- 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"]