Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 11 additions & 7 deletions gateway/gateway-controller/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -22,17 +22,21 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
fi \
&& rm -rf /var/lib/apt/lists/*

# Copy SDK (needed for go.mod replace directive)
COPY --from=sdk . /sdk

# Copy common (needed for go.mod replace directive)
COPY --from=common . /common
# Copy go mod files for dependencies (needed for go.mod replace directive)
# Copying only the mod files first ensures that the go mod download cache
# is only invalidated when dependencies change, not when source code changes.
COPY --from=sdk go.mod go.sum /sdk/
COPY --from=common go.mod go.sum /common/

# Copy go mod files
# Copy main component go mod files
COPY go.mod go.sum ./
RUN go mod download

# Copy source code
# Copy full source code for SDK and Common
COPY --from=sdk . /sdk
COPY --from=common . /common

# Copy component source code
COPY . ./

# Build the binary with CGO enabled (required for mattn/go-sqlite3)
Expand Down
29 changes: 16 additions & 13 deletions gateway/policy-engine/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -35,21 +35,22 @@ RUN apk add --no-cache \
# Set working directory
WORKDIR /workspace

# Copy SDK components
COPY --from=sdk . /api-platform/sdk

# Copy Gateway Builder application
COPY --from=gateway-builder . /api-platform/gateway/gateway-builder

# Pre-download Go dependencies for SDK
# Copy SDK mod files first to cache dependencies
COPY --from=sdk go.mod go.sum /api-platform/sdk/
WORKDIR /api-platform/sdk
RUN go mod download

# Pre-download Go dependencies for gateway-builder
# Copy Gateway Builder mod files first to cache dependencies
COPY --from=gateway-builder go.mod go.sum /api-platform/gateway/gateway-builder/
WORKDIR /api-platform/gateway/gateway-builder
RUN go mod download

# Copy full SDK and Gateway Builder source code
COPY --from=sdk . /api-platform/sdk
COPY --from=gateway-builder . /api-platform/gateway/gateway-builder

# Build the Gateway Builder binary (CGO disabled for static binary)
WORKDIR /api-platform/gateway/gateway-builder
RUN CGO_ENABLED=0 \
GOOS=linux \
GOARCH=${BUILDARCH} \
Expand All @@ -67,14 +68,16 @@ ARG GIT_COMMIT
ENV VERSION=${VERSION}
ENV GIT_COMMIT=${GIT_COMMIT}

# Copy Policy Engine framework source code
COPY --from=policy-engine . /api-platform/gateway/policy-engine
COPY --from=sdk . /api-platform/sdk

# Pre-download Go dependencies for runtime
# Copy Policy Engine mod files and SDK mod files for dependency resolution
COPY --from=sdk go.mod go.sum /api-platform/sdk/
COPY go.mod go.sum /api-platform/gateway/policy-engine/
WORKDIR /api-platform/gateway/policy-engine
RUN go mod download

# Copy full Policy Engine and SDK source code
COPY . /api-platform/gateway/policy-engine
COPY --from=sdk . /api-platform/sdk

# Copy policy implementations
COPY --from=policies . /workspace/policies/

Expand Down
Loading