|
| 1 | +# Protobuf Generation Docker Environment |
| 2 | + |
| 3 | +This Docker environment contains the tools and environment required to generate function-mesh protobuf Go definitions. |
| 4 | + |
| 5 | +## Requirements |
| 6 | + |
| 7 | +- protoc: v3.17.3 |
| 8 | +- protoc-gen-go: v1.25.0 |
| 9 | +- protoc-gen-go-grpc: v1.0.0 |
| 10 | +- Go: 1.24.2+ |
| 11 | + |
| 12 | +**Note**: This image uses a Debian base (not Alpine) to ensure compatibility with the protoc x86_64 binary, which is compiled for glibc rather than musl libc. |
| 13 | + |
| 14 | +## Build and Usage |
| 15 | + |
| 16 | +### 1. Build Docker Image |
| 17 | + |
| 18 | +```bash |
| 19 | +docker build -f Dockerfile.protogen -t function-mesh-protogen . |
| 20 | +``` |
| 21 | + |
| 22 | +### 2. Run Protobuf Generation |
| 23 | + |
| 24 | +```bash |
| 25 | +# Run container and generate protobuf files |
| 26 | +docker run --rm -v $(pwd):/workspace function-mesh-protogen |
| 27 | + |
| 28 | +# Or run interactively for debugging |
| 29 | +docker run --rm -it -v $(pwd):/workspace function-mesh-protogen bash |
| 30 | +``` |
| 31 | + |
| 32 | +### 3. Manual Script Execution |
| 33 | + |
| 34 | +If you need manual control over the generation process: |
| 35 | + |
| 36 | +```bash |
| 37 | +# Enter container |
| 38 | +docker run --rm -it -v $(pwd):/workspace function-mesh-protogen bash |
| 39 | + |
| 40 | +# Execute manually inside container |
| 41 | +cd /workspace |
| 42 | +./controllers/proto/generate.sh /workspace |
| 43 | +``` |
| 44 | + |
| 45 | +## Generated Files |
| 46 | + |
| 47 | +The script will update the following files: |
| 48 | +- `controllers/proto/Function.pb.go` |
| 49 | + |
| 50 | +## Environment Verification |
| 51 | + |
| 52 | +You can verify tool versions inside the container: |
| 53 | + |
| 54 | +```bash |
| 55 | +protoc --version # Should show libprotoc 3.17.3 |
| 56 | +go version # Should show go1.24.2+ |
| 57 | +``` |
| 58 | + |
| 59 | +## Troubleshooting |
| 60 | + |
| 61 | +If you encounter permission issues, ensure the generate.sh script has execute permissions: |
| 62 | + |
| 63 | +```bash |
| 64 | +chmod +x controllers/proto/generate.sh |
| 65 | +``` |
| 66 | + |
| 67 | +If you encounter protoc-gen-go not found issues, ensure $GOPATH/bin is in PATH: |
| 68 | + |
| 69 | +```bash |
| 70 | +export PATH=$PATH:$(go env GOPATH)/bin |
| 71 | +``` |
0 commit comments