add Dockerfile for multi-stage build and update generate.go command
This commit is contained in:
30
Dockerfile
30
Dockerfile
@ -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"]
|
||||||
|
|||||||
@ -1,3 +0,0 @@
|
|||||||
package LogDex_ID
|
|
||||||
|
|
||||||
//go:generate go run github.com/oapi-codegen/oapi-codegen/v2/cmd/oapi-codegen -config cfg.yaml api.yaml
|
|
||||||
@ -1,4 +1,3 @@
|
|||||||
package handler
|
package handler
|
||||||
|
|
||||||
//go:generate go tool oapi-codegen -config ../../../../api/auth/cfg.yaml ../../../../api/auth/api.yam
|
|
||||||
//go:generate go tool oapi-codegen -config ../../../../api/auth/cfg.yaml ../../../../api/auth/api.yaml
|
//go:generate go tool oapi-codegen -config ../../../../api/auth/cfg.yaml ../../../../api/auth/api.yaml
|
||||||
|
|||||||
Reference in New Issue
Block a user