Skip to content

Commit

Permalink
refactor: wasm32-wasi renamed to wasm32-wasip1 & rust to 1.78
Browse files Browse the repository at this point in the history
  • Loading branch information
antonengelhardt committed Nov 4, 2024
1 parent 96a52db commit 55da665
Show file tree
Hide file tree
Showing 9 changed files with 21 additions and 20 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ jobs:
run: rustc --version && cargo --version

- name: Clippy
run: cargo clippy --release --all-targets --target=wasm32-wasi -- -D warnings
run: cargo clippy --release --all-targets --target=wasm32-wasip1 -- -D warnings

fmt:
runs-on: ubuntu-latest
Expand Down Expand Up @@ -116,7 +116,7 @@ jobs:
- name: Build wasm-oidc-plugin
run: |
cargo build --target wasm32-wasi --release
cargo build --target wasm32-wasip1 --release
- name: Upload plugin as artifact
uses: actions/upload-artifact@v4
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ jobs:
- name: Build
run: |
cargo build --target wasm32-wasi --release
cargo build --target wasm32-wasip1 --release
- name: Archive production artifacts
uses: actions/upload-artifact@v4
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ jobs:
- name: Clippy
run: |
rustc --version && cargo --version
cargo clippy --release --all-targets --target=wasm32-wasi -- -D warnings
cargo clippy --release --all-targets --target=wasm32-wasip1 -- -D warnings
fmt:
runs-on: ubuntu-latest
Expand Down Expand Up @@ -176,7 +176,7 @@ jobs:
- name: Build wasm-oidc-plugin
run: |
cargo build --target wasm32-wasi --release
cargo build --target wasm32-wasip1 --release
- name: Upload plugin as artifact
uses: actions/upload-artifact@v4
Expand Down
8 changes: 4 additions & 4 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
FROM rust:1.75.0 AS builder
FROM rust:1.78.0 AS builder

COPY src/ src/
COPY Cargo.toml Cargo.toml
COPY Cargo.lock Cargo.lock

RUN rustup target add wasm32-wasi
RUN rustup target add wasm32-wasip1

RUN cargo build --target=wasm32-wasi --release
RUN cargo build --target=wasm32-wasip1 --release

##################################################

FROM envoyproxy/envoy:v1.31-latest

COPY --from=builder /target/wasm32-wasi/release/wasm_oidc_plugin.wasm /etc/envoy/proxy-wasm-plugins/wasm_oidc_plugin.wasm
COPY --from=builder /target/wasm32-wasip1/release/wasm_oidc_plugin.wasm /etc/envoy/proxy-wasm-plugins/wasm_oidc_plugin.wasm

CMD [ "envoy", "-c", "/etc/envoy/envoy.yaml" ]
6 changes: 3 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
build:
cargo build --target wasm32-wasi --release
cargo build --target wasm32-wasip1 --release
run:
cargo build --target wasm32-wasi --release
cargo build --target wasm32-wasip1 --release
docker-compose up
run-background:
cargo build --target wasm32-wasi --release
cargo build --target wasm32-wasip1 --release
docker-compose up -d
docker-image:
docker buildx build --platform linux/amd64 -f Dockerfile -t antonengelhardt/wasm-oidc-plugin:latest .
Expand Down
11 changes: 6 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ apt install build-essential
# Install Rustup
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
# Enable WASM compilation target
cargo build --target wasm32-wasi --release
cargo build --target wasm32-wasip1 --release
```

## Run
Expand All @@ -51,7 +51,7 @@ make run
1. **Building the plugin:**

```sh
cargo build --target wasm32-wasi --release
cargo build --target wasm32-wasip1 --release
# or
make build
```
Expand All @@ -74,9 +74,10 @@ To deploy the plugin to production, the following steps are needed (either manua

1. Build the plugin

1.1 with `cargo build --target wasm32-wasi --release` - this can be done in a [initContainer](./k8s/deployment.yaml) (see [k8s](./k8s) folder) and then copy the binary to the path `/etc/envoy/proxy-wasm-plugins/` in the envoy container.
1.1 with `cargo build --target wasm32-wasip1 --release` - this can be done in a [initContainer](./k8s/deployment.yaml) (see [k8s](./k8s) folder) and then copy the binary to the path `/etc/envoy/proxy-wasm-plugins/` in the envoy container.

1.2 by using the pre-built Docker image [antonengelhardt/wasm-oidc-plugin](https://hub.docker.com/r/antonengelhardt/wasm-oidc-plugin).

1.2 by using the pre-built Docker image [antonengelhardt/wasm-oidc-plugin](https://hub.docker.com/r/antonengelhardt/wasm-oidc-plugin).
2. Run envoy as a container with the `envoy.yaml` file mounted through the [ConfigMap](./k8s/configmap.yml) as a volume.
3. Set up [Service](./k8s/service.yml), [Certificate](./k8s/certificate-production.yml), [Ingress](./k8s/ingress.yml) to expose the Envoy to the internet.

Expand Down Expand Up @@ -212,7 +213,7 @@ Google does exactly that:

```json
{
"jwks_uri": "https://www.googleapis.com/oauth2/v3/certs"
"jwks_uri": "https://www.googleapis.com/oauth2/v3/certs"
}
```

Expand Down
2 changes: 1 addition & 1 deletion docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ services:
- "10000:10000"
volumes:
- ./envoy.yaml:/etc/envoy/envoy.yaml
- ./target/wasm32-wasi/release:/etc/envoy/proxy-wasm-plugins
- ./target/wasm32-wasip1/release:/etc/envoy/proxy-wasm-plugins
networks:
- envoymesh
# Additional options:
Expand Down
2 changes: 1 addition & 1 deletion k8s/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ jobs:
- name: Build wasm-oidc-plugin
run: |
cargo build --target wasm32-wasi --release
cargo build --target wasm32-wasip1 --release
- name: Upload plugin as artifact
uses: actions/upload-artifact@v4
Expand Down
2 changes: 1 addition & 1 deletion k8s/deployment-init-container.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ spec:
apk add git
git clone -b main https://${GITHUB_PAT}@github.com/your-org/your-repo.git #! Change URL and branch
cd your-repo #! Change directory
cargo build --target wasm32-wasi --release
cargo build --target wasm32-wasip1 --release
cp target/wasm32-wasi/release/name_of_your_wasm_plugin.wasm /plugins/name_of_your_wasm_plugin.wasm #! Rename, if necessary
env:
Expand Down

0 comments on commit 55da665

Please sign in to comment.