mirror of
https://github.com/fluencelabs/wasmer
synced 2025-04-25 02:12:13 +00:00
Add Dockerfile and documentation
This commit is contained in:
parent
1ac689c70b
commit
1094f5c818
6
.dockerignore
Normal file
6
.dockerignore
Normal file
@ -0,0 +1,6 @@
|
||||
# Ignore everything
|
||||
**
|
||||
!lib/**
|
||||
!src/**
|
||||
!Cargo.toml
|
||||
!Cargo.lock
|
25
Dockerfile
Normal file
25
Dockerfile
Normal file
@ -0,0 +1,25 @@
|
||||
FROM circleci/rust:1.33.0-stretch as wasmer-build-env
|
||||
RUN sudo apt-get update && \
|
||||
sudo apt-get install -y --no-install-recommends \
|
||||
cmake \
|
||||
&& sudo rm -rf /var/lib/apt/lists/*
|
||||
RUN curl -SL https://releases.llvm.org/7.0.0/clang+llvm-7.0.0-x86_64-linux-gnu-ubuntu-16.04.tar.xz \
|
||||
| tar -xJC /home/circleci
|
||||
ENV LLVM_SYS_70_PREFIX /home/circleci/clang+llvm-7.0.0-x86_64-linux-gnu-ubuntu-16.04/
|
||||
|
||||
FROM wasmer-build-env AS wasmer-debug-env
|
||||
RUN sudo apt-get update && \
|
||||
sudo apt-get install -y --no-install-recommends \
|
||||
valgrind \
|
||||
&& sudo rm -rf /var/lib/apt/lists/*
|
||||
|
||||
FROM wasmer-build-env AS wasmer-build
|
||||
WORKDIR /home/circleci/wasmer
|
||||
COPY . /home/circleci/wasmer
|
||||
RUN sudo chmod -R 777 .
|
||||
RUN cargo build --release
|
||||
|
||||
FROM debian:stretch AS wasmer
|
||||
WORKDIR /root/
|
||||
COPY --from=wasmer-build /home/circleci/wasmer/target/release/wasmer .
|
||||
ENTRYPOINT ["./wasmer"]
|
39
docs/docker.md
Normal file
39
docs/docker.md
Normal file
@ -0,0 +1,39 @@
|
||||
# Dockerfile Documentation
|
||||
The `Dockerfile` included in the project root directory could be used for development purposes or to build a small image containing the `wasmer` executable.
|
||||
|
||||
The `wasmer-build-env` stage in the Dockerfile contains the dependencies needed to compile Wasmer including LLVM.
|
||||
|
||||
The `wasmer-debug-env` stage adds the `valgrind` profiling tool to the `wasmer-build-env` stage.
|
||||
|
||||
The `wasmer-build` stage in the Dockerfile will copy the current directory, assuming the build context is the `wasmer` project, and build the project using `cargo build --release`.
|
||||
|
||||
The `wasmer` stage will copy the resulting `wasmer` executable from the `wasmer-build` stage into a new base image to create a smaller image containing `wasmer`.
|
||||
|
||||
## Example Usages
|
||||
|
||||
### Wasmer image
|
||||
1. From the `wasmer` project directory, build the image:
|
||||
`docker build -t wasmer --target=wasmer .`
|
||||
|
||||
2. List options:
|
||||
`docker run wasmer --help`
|
||||
|
||||
3. Mount a directory, and run an example wasm file:
|
||||
`docker run -v /Users/admin/Documents/wasmer-workspace:/root/wasmer-workspace wasmer run /root/wasmer-workspace/examples/hello.wasm`
|
||||
|
||||
### Profiling
|
||||
1. Build `wasmer-debug-env`:
|
||||
`docker build --tag=wasmer-debug-env --target wasmer-debug-env .`
|
||||
|
||||
2. Mount a directory from the host and run interactively:
|
||||
`docker run -it -v /Users/admin/Documents/wasmer-workspace:/home/circleci/wasmer-workspace wasmer-debug-env /bin/bash`
|
||||
|
||||
3. Inside the container, build `wasmer` and run profiling tool:
|
||||
```
|
||||
cd /home/circleci/wasmer-workspace/wasmer`
|
||||
cargo build
|
||||
valgrind --tool=callgrind --dump-instr=yes --collect-jumps=yes --simulate-cache=yes target/debug/wasmer run test.wasm
|
||||
```
|
||||
|
||||
The `callgrind.out` can be viewed with the `qcachegrind` tool on Mac OS (`brew install qcachegrind`).
|
||||
|
Loading…
x
Reference in New Issue
Block a user