-
Notifications
You must be signed in to change notification settings - Fork 41
Build images #15
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Build images #15
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
e40304f
Add initial Dockerfile for wws images
assambar 10a894a
Change the target arch for arm64v8
assambar 82ebe2f
Fix multi-arch image build, publish and add a section in the readme
assambar cabe5ef
Add docs on the container image
assambar cc2b75b
Fix wording in container.md
assambar File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,14 @@ | ||
| .PHONY: build | ||
|
|
||
| build: | ||
| cargo build --release | ||
| cargo build --release | ||
|
|
||
| image-amd64: | ||
| docker build -f image/Dockerfile --platform amd64 -t wasm-workers-server:latest-amd64 . | ||
|
|
||
| image-arm64: | ||
| docker build -f image/Dockerfile --platform arm64 -t wasm-workers-server:latest-arm64 . | ||
|
|
||
| push-image-multiarch: | ||
| docker buildx build -f image/Dockerfile --platform linux/arm64/v8,linux/amd64 --push -t projects.registry.vmware.com/wasmlabs/containers/wasm-workers-server:latest . | ||
|
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,26 @@ | ||
| --- | ||
| sidebar_position: 3 | ||
| --- | ||
|
|
||
| # Running in a container | ||
|
|
||
| For convenience we have published a container image that contains Wasm Workers Server. It is available at `projects.registry.vmware.com/wasmlabs/containers/wasm-workers-server:latest`. Any container that runs it will get the `wws` binary, running and: | ||
|
|
||
| - looking for worker handlers in the `/app` folder | ||
| - listening on `0.0.0.0:8080` inside the container | ||
|
|
||
| The image is based on `debian:bullseye-slim` + the `wws` binary. It includes support for the `linux/amd64` and `linux/arm64/v8` platforms. The image size should be around `~100MiB` | ||
|
|
||
| ## Running a local container | ||
|
|
||
| A typical one-liner to run a local container for development purposes would look like: | ||
|
|
||
| ```bash | ||
| docker run -v /path/to/handlers/on/host:/app -p 8080:8080 \ | ||
| projects.registry.vmware.com/wasmlabs/containers/wasm-workers-server:latest | ||
| ``` | ||
|
|
||
| ## Other usages | ||
|
|
||
| Wasm Workers Server is stateless as far as the loaded handers are stateless (i.e. when they don't use the [Key / Value store](../features/key-value.md)). This makes the image very useful if you want to setup your own auto-scaling deployment. | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,5 @@ | ||
| --- | ||
| sidebar_position: 3 | ||
| sidebar_position: 4 | ||
| --- | ||
|
|
||
| # How it works? | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,31 @@ | ||
| # Build wasm_runtime in release mode | ||
|
|
||
|
|
||
| FROM --platform=$TARGETPLATFORM rust:1.64.0-slim as build-wws | ||
| ARG WWS_BUILD_DIR=/usr/src/wws | ||
| ARG TARGETPLATFORM | ||
| ARG BUILDPLATFORM | ||
| WORKDIR $WWS_BUILD_DIR | ||
| COPY ./ $WWS_BUILD_DIR/ | ||
| RUN echo "Running on ${BUILDPLATFORM}, building for ${TARGETPLATFORM}" | ||
| RUN set -eux; \ | ||
| ls -l .; \ | ||
| case "${TARGETPLATFORM}" in \ | ||
| linux/amd64) bldArch='x86_64-unknown-linux-gnu' ;; \ | ||
| linux/arm64) bldArch='aarch64-unknown-linux-gnu' ;; \ | ||
| *) echo >&2 "unsupported architecture: $BUILDPLATFORM"; exit 1 ;; \ | ||
| esac; \ | ||
| rustup target add $bldArch; \ | ||
| cargo build --release --target=$bldArch; \ | ||
| mkdir ./build; \ | ||
| cp ./target/$bldArch/release/wws ./build/wws | ||
|
|
||
|
|
||
| FROM --platform=$TARGETPLATFORM debian:bullseye-slim | ||
| ARG WWS_BUILD_DIR=/usr/src/wws | ||
| RUN mkdir -p /app | ||
| RUN mkdir -p /opt | ||
| COPY --from=build-wws ${WWS_BUILD_DIR}/build/wws /opt | ||
|
|
||
| CMD ["/opt/wws", "/app/", "--host", "0.0.0.0"] | ||
|
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.