Skip to content

Commit ddd53a2

Browse files
authored
Setups build pipeline (#3)
Signed-off-by: Takeshi Yoneda <[email protected]>
1 parent 01e1f84 commit ddd53a2

File tree

3 files changed

+98
-0
lines changed

3 files changed

+98
-0
lines changed

.github/workflows/commit.yaml

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,3 +60,53 @@ jobs:
6060

6161
- name: Run tests
6262
run: cargo test --verbose
63+
64+
docker_build:
65+
name: Build and Push multi-arch Docker image
66+
runs-on: ubuntu-latest
67+
steps:
68+
- name: Checkout
69+
uses: actions/checkout@v4
70+
71+
- name: Set up QEMU
72+
uses: docker/setup-qemu-action@v3
73+
74+
- name: Set up Docker Buildx
75+
uses: docker/setup-buildx-action@v3
76+
77+
- name: Login into GitHub Container Registry
78+
uses: docker/login-action@v3
79+
with:
80+
registry: ghcr.io
81+
username: ${{ github.repository_owner }}
82+
password: ${{ secrets.GITHUB_TOKEN }}
83+
84+
- name: Build and push
85+
uses: docker/build-push-action@v6
86+
with:
87+
# TODO: setup caches.
88+
platforms: linux/amd64,linux/arm64
89+
push: true
90+
tags: ghcr.io/envoyproxy/dynamic-modules-examples:${{ github.sha }}
91+
92+
- name: Push as latest
93+
if: github.event_name == 'push'
94+
run:
95+
docker tag ghcr.io/envoyproxy/dynamic-modules-examples:${{ github.sha }} ghcr.io/envoyproxy/dynamic-modules-examples:latest
96+
docker push ghcr.io/envoyproxy/dynamic-modules-examples:latest
97+
98+
e2e_test:
99+
needs: [docker_build]
100+
name: E2E Test (${{ matrix.platform.arch }})
101+
runs-on: ${{ matrix.platform.os }}
102+
strategy:
103+
fail-fast: false
104+
matrix:
105+
platform:
106+
- os: ubuntu-22.04
107+
arch: amd64
108+
- os: ubuntu-22.04-arm
109+
arch: arm64
110+
111+
steps:
112+
- run: echo 'TODO'

Dockerfile

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
FROM --platform=$BUILDPLATFORM rust:1.84 AS rust_builder
2+
3+
# We need libclang to do the bindgen.
4+
RUN apt update && apt install -y clang
5+
6+
WORKDIR /app
7+
8+
# Cache dependencies by copying only the Cargo files and fetching them.
9+
COPY ./rust/Cargo.toml ./rust/Cargo.lock ./
10+
RUN mkdir src && echo "" > src/lib.rs
11+
RUN cargo fetch
12+
RUN rm -rf src
13+
14+
# Then, copy the entire source code and build.
15+
COPY ./rust .
16+
RUN cargo build
17+
18+
# Finally, copy the built library to the final image.
19+
FROM --platform=$BUILDPLATFORM envoyproxy/envoy@sha256:9ca0dcc84ec582b7ece0ccf6c24af76268d017c87376f69a0dc4a1a0ab55b4c4 AS envoy
20+
ENV ENVOY_DYNAMIC_MODULES_SEARCH_PATH=/usr/local/lib
21+
COPY --from=rust_builder /app/target/debug/librust_module.so /usr/local/lib/librust_module.so

README.md

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,33 @@ like Lua filters, Wasm filters, or External Processors.
1212
Currently, the only language supported is Rust, so this repository contains examples of dynamic modules written in Rust.
1313
Future examples will be added in other languages once the support is available.
1414

15+
This repository serves as a reference for developers who want to create their own dynamic modules for Envoy including
16+
how to setup the project, how to build it, and how to test it, etc.
17+
18+
## Dvelopment
19+
20+
### Rust Dynamic Modules
21+
22+
To build and test the modules locally without Envoy, you can use `cargo` to build them just like any other Rust project:
23+
24+
```
25+
cd rust
26+
cargo build
27+
cargo test
28+
cargo cargo clippy -- -D warnings
29+
cargo fmt --all -- --check
30+
```
31+
32+
### Envoy + Dynamic Modules Docker Image
33+
34+
To build the example modules and bundle them with Envoy, simply run
35+
36+
```
37+
docker buildx build . -t envoy-with-dynamic-modules:latest [--platform linux/amd64,linux/arm64]
38+
```
39+
40+
where `--platform` is optional and can be used to build for multiple platforms.
41+
1542
[78efd97]: https://github.com/envoyproxy/envoy/tree/78efd97
1643
[Envoy]: https://github.com/envoyproxy/envoy
1744
[High Level Doc]: https://www.envoyproxy.io/docs/envoy/latest/intro/arch_overview/advanced/dynamic_modules

0 commit comments

Comments
 (0)