Skip to content
Merged
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
50 changes: 50 additions & 0 deletions .github/workflows/commit.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -60,3 +60,53 @@ jobs:

- name: Run tests
run: cargo test --verbose

docker_build:
name: Build and Push multi-arch Docker image
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Set up QEMU
uses: docker/setup-qemu-action@v3

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Login into GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Build and push
uses: docker/build-push-action@v6
with:
# TODO: setup caches.
platforms: linux/amd64,linux/arm64
push: true
tags: ghcr.io/envoyproxy/dynamic-modules-examples:${{ github.sha }}

- name: Push as latest
if: github.event_name == 'push'
run:
docker tag ghcr.io/envoyproxy/dynamic-modules-examples:${{ github.sha }} ghcr.io/envoyproxy/dynamic-modules-examples:latest
docker push ghcr.io/envoyproxy/dynamic-modules-examples:latest

e2e_test:
needs: [docker_build]
name: E2E Test (${{ matrix.platform.arch }})
runs-on: ${{ matrix.platform.os }}
strategy:
fail-fast: false
matrix:
platform:
- os: ubuntu-22.04
arch: amd64
- os: ubuntu-22.04-arm
arch: arm64

steps:
- run: echo 'TODO'
21 changes: 21 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
FROM --platform=$BUILDPLATFORM rust:1.84 AS rust_builder

# We need libclang to do the bindgen.
RUN apt update && apt install -y clang

WORKDIR /app

# Cache dependencies by copying only the Cargo files and fetching them.
COPY ./rust/Cargo.toml ./rust/Cargo.lock ./
RUN mkdir src && echo "" > src/lib.rs
RUN cargo fetch
RUN rm -rf src

# Then, copy the entire source code and build.
COPY ./rust .
RUN cargo build

# Finally, copy the built library to the final image.
FROM --platform=$BUILDPLATFORM envoyproxy/envoy@sha256:9ca0dcc84ec582b7ece0ccf6c24af76268d017c87376f69a0dc4a1a0ab55b4c4 AS envoy
ENV ENVOY_DYNAMIC_MODULES_SEARCH_PATH=/usr/local/lib
COPY --from=rust_builder /app/target/debug/librust_module.so /usr/local/lib/librust_module.so
27 changes: 27 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,33 @@ like Lua filters, Wasm filters, or External Processors.
Currently, the only language supported is Rust, so this repository contains examples of dynamic modules written in Rust.
Future examples will be added in other languages once the support is available.

This repository serves as a reference for developers who want to create their own dynamic modules for Envoy including
how to setup the project, how to build it, and how to test it, etc.

## Dvelopment

### Rust Dynamic Modules

To build and test the modules locally without Envoy, you can use `cargo` to build them just like any other Rust project:

```
cd rust
cargo build
cargo test
cargo cargo clippy -- -D warnings
cargo fmt --all -- --check
```

### Envoy + Dynamic Modules Docker Image

To build the example modules and bundle them with Envoy, simply run

```
docker buildx build . -t envoy-with-dynamic-modules:latest [--platform linux/amd64,linux/arm64]
```

where `--platform` is optional and can be used to build for multiple platforms.

[78efd97]: https://github.com/envoyproxy/envoy/tree/78efd97
[Envoy]: https://github.com/envoyproxy/envoy
[High Level Doc]: https://www.envoyproxy.io/docs/envoy/latest/intro/arch_overview/advanced/dynamic_modules
Loading