initial commit
This commit is contained in:
37
Dockerfile
Normal file
37
Dockerfile
Normal file
@@ -0,0 +1,37 @@
|
||||
# ---- Build Stage ----
|
||||
FROM golang:1.26 AS builder
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
# ---- Step 1: Copy go.mod/go.sum for caching ----
|
||||
# Copy only the minimal files first for layer caching
|
||||
COPY libshared/go.mod libshared/go.sum ./libshared/
|
||||
COPY role-manager/go.mod role-manager/go.sum ./role-manager/
|
||||
|
||||
# ---- Step 2: Download dependencies ----
|
||||
RUN go -C libshared mod download
|
||||
RUN go -C role-manager mod download
|
||||
|
||||
# ---- Step 3: Copy full source code ----
|
||||
COPY libshared ./libshared
|
||||
COPY role-manager ./role-manager
|
||||
|
||||
# ---- Step 4: Create Go workspace inside container ----
|
||||
RUN go work init ./role-manager ./libshared
|
||||
|
||||
## Optional: verify workspace
|
||||
#RUN go work list
|
||||
|
||||
# ---- Step 5: Build binary ----
|
||||
WORKDIR /app/role-manager
|
||||
RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o server
|
||||
|
||||
# ---- Runtime Stage ----
|
||||
FROM gcr.io/distroless/base-debian12
|
||||
|
||||
WORKDIR /app
|
||||
COPY --from=builder /app/role-manager/server .
|
||||
|
||||
EXPOSE 8080
|
||||
USER nonroot:nonroot
|
||||
ENTRYPOINT ["/app/server"]
|
||||
Reference in New Issue
Block a user