Skip to content

Commit ff834fd

Browse files
feat(cli): copy python-executor into gateway-runtime image
Gateway-builder now emits a python-executor/ directory alongside the gateway-runtime build context. Stage it into the runtime context and add a COPY step in the runtime Dockerfile template so the custom python-executor replaces the one baked into the base image, matching the existing policy-engine binary pattern.
1 parent 2f49e42 commit ff834fd

2 files changed

Lines changed: 32 additions & 0 deletions

File tree

cli/src/internal/gateway/docker_build.go

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,10 @@ func BuildGatewayImages(config DockerBuildConfig) error {
7474
return err
7575
}
7676

77+
if err := ensurePythonExecutorInRuntimeContext(config.TempDir); err != nil {
78+
return err
79+
}
80+
7781
fmt.Println(" ✓ Gateway-builder completed")
7882

7983
// Step 2: Build the two images
@@ -121,6 +125,30 @@ func ensureBuildLockInControllerContext(tempDir string) error {
121125
return nil
122126
}
123127

128+
// ensurePythonExecutorInRuntimeContext stages the python-executor directory
129+
// produced by gateway-builder into the gateway-runtime Docker build context
130+
// so the Dockerfile's `COPY python-executor/ ...` can resolve it.
131+
func ensurePythonExecutorInRuntimeContext(tempDir string) error {
132+
pythonExecutorSrc := filepath.Join(tempDir, "output", "python-executor")
133+
if _, err := os.Stat(pythonExecutorSrc); err != nil {
134+
if errors.Is(err, os.ErrNotExist) {
135+
return nil
136+
}
137+
return fmt.Errorf("failed to access python-executor output: %w", err)
138+
}
139+
140+
pythonExecutorDst := filepath.Join(tempDir, "output", "gateway-runtime", "python-executor")
141+
if err := os.RemoveAll(pythonExecutorDst); err != nil {
142+
return fmt.Errorf("failed to clear existing python-executor in gateway-runtime build context: %w", err)
143+
}
144+
145+
if err := utils.CopyDir(pythonExecutorSrc, pythonExecutorDst); err != nil {
146+
return fmt.Errorf("failed to copy python-executor into gateway-runtime build context: %w", err)
147+
}
148+
149+
return nil
150+
}
151+
124152
// runGatewayBuilder runs the gateway-builder container
125153
func runGatewayBuilder(config DockerBuildConfig, logFile *os.File) error {
126154
args := []string{"run", "--rm", "-v", config.TempDir + ":/workspace", config.GatewayBuilder,

gateway/gateway-builder/templates/Dockerfile.gateway-runtime.tmpl

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,10 @@ USER root
2424
COPY policy-engine /app/policy-engine
2525
RUN chmod +x /app/policy-engine
2626

27+
# Replace python-executor with custom-compiled version containing user Python policies
28+
RUN rm -rf /app/python-executor
29+
COPY python-executor/ /app/python-executor/
30+
2731
USER wso2
2832

2933
# Metadata labels

0 commit comments

Comments
 (0)