diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 1eedae23..e41cd7cd 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -46,6 +46,24 @@ After you've completed the set up steps, you can run the tests locally with $ pytest ``` +### Docker-compose setup +Docker installation guide can be found [here](https://docs.docker.com/engine/install/) +In short - all standard docker-compose commands can be used, but we also have some as shortcuts in [Makefile](Makefile). +```bash +make start +``` +To run hello world example: +```bash +make hello-world +``` +To run tests: +```bash +make test +``` +To stop the image: +```bash +make stop +``` ### CI and Releases The CI for this project does a few different things: diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 00000000..1ecf3e15 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,22 @@ +FROM python:3.11 + +RUN apt-get update && apt-get install -y \ + build-essential \ + curl +# Get Rust +RUN curl https://sh.rustup.rs -sSf | bash -s -- -y + +ENV PATH="/root/.cargo/bin:${PATH}" + +RUN curl https://wasmtime.dev/install.sh -sSf | bash + +COPY . /code/wasmtime-py +WORKDIR /code/wasmtime-py +RUN rustup target add wasm32-unknown-unknown wasm32-wasi && \ + cargo install wasm-tools + + +RUN python ci/download-wasmtime.py && \ + python ci/build-rust.py && \ + pip install -e .[testing] +CMD sleep infinity diff --git a/Makefile b/Makefile new file mode 100644 index 00000000..41cc7d6f --- /dev/null +++ b/Makefile @@ -0,0 +1,10 @@ +start: + docker-compose up -d +test: + docker-compose exec -it app pytest +hello-world: + docker-compose exec -it app python examples/hello.py +exec: + docker-compose exec -it app bash +stop: + docker-compose down diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 00000000..f6b34802 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,9 @@ +version: "3.8" +services: + app: + build: . + volumes: + - .:/code/wasmtime-py + - /code/wasmtime-py/wasmtime/linux-x86_64 + - /code/wasmtime-py/wasmtime/bindgen/generated + working_dir: /code/wasmtime-py \ No newline at end of file