From 06bb7ace4f7428b98f42c842652c114ae418555a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=A0ar=C5=ABnas=20A=C5=BEna?= Date: Fri, 22 Mar 2024 00:10:00 +0100 Subject: [PATCH 1/2] Barelly working setup (that works on Windows!) --- CONTRIBUTING.md | 18 ++++++++++++++++++ Dockerfile | 22 ++++++++++++++++++++++ Makefile | 10 ++++++++++ docker-compose.yml | 9 +++++++++ 4 files changed, 59 insertions(+) create mode 100644 Dockerfile create mode 100644 Makefile create mode 100644 docker-compose.yml 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..c6eeb18b --- /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 +RUN cargo install wasm-tools + + +RUN python ci/download-wasmtime.py +RUN python ci/build-rust.py +RUN 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 From 86ac4d6e215b1135f9168522fabcbe8f3ee4326b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=A0ar=C5=ABnas=20A=C5=BEna?= Date: Fri, 22 Mar 2024 00:32:55 +0100 Subject: [PATCH 2/2] reduce number of layers --- Dockerfile | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/Dockerfile b/Dockerfile index c6eeb18b..1ecf3e15 100644 --- a/Dockerfile +++ b/Dockerfile @@ -12,11 +12,11 @@ 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 -RUN cargo install wasm-tools +RUN rustup target add wasm32-unknown-unknown wasm32-wasi && \ + cargo install wasm-tools -RUN python ci/download-wasmtime.py -RUN python ci/build-rust.py -RUN pip install -e .[testing] +RUN python ci/download-wasmtime.py && \ + python ci/build-rust.py && \ + pip install -e .[testing] CMD sleep infinity