From f970a172212803ba6c96a0b7a0d37167e34791b8 Mon Sep 17 00:00:00 2001 From: Lorenzo Venerandi <68255980+Lore09@users.noreply.github.com> Date: Wed, 29 Jan 2025 17:41:24 +0100 Subject: [PATCH] Added dockerfiles --- src/wasm_builder/docker/build.Dockerfile | 51 +++++++++++++++++++++++ src/wasm_builder/docker/deploy.Dockerfile | 23 ++++++++++ 2 files changed, 74 insertions(+) create mode 100644 src/wasm_builder/docker/build.Dockerfile create mode 100644 src/wasm_builder/docker/deploy.Dockerfile diff --git a/src/wasm_builder/docker/build.Dockerfile b/src/wasm_builder/docker/build.Dockerfile new file mode 100644 index 0000000..94542c7 --- /dev/null +++ b/src/wasm_builder/docker/build.Dockerfile @@ -0,0 +1,51 @@ +FROM ubuntu:24.04 AS wash-build-image + +# Install dependencies and tools +RUN apt-get update && apt-get install -y \ + curl \ + wget \ + tar \ + git \ + build-essential \ + && rm -rf /var/lib/apt/lists/* + +# ----------------- Install WasmCloud ----------------- +RUN curl -s "https://packagecloud.io/install/repositories/wasmcloud/core/script.deb.sh" | bash && \ + apt-get install -y wash + +# ----------------- Install Go 1.23 ----------------- +RUN wget https://go.dev/dl/go1.23.4.linux-amd64.tar.gz && \ + tar -C /usr/local -xzf go1.23.4.linux-amd64.tar.gz && \ + rm go1.23.4.linux-amd64.tar.gz + +# Set Go environment variables +ENV PATH="/usr/local/go/bin:${PATH}" +ENV GOPATH="/go" +ENV GOROOT="/usr/local/go" + +# ----------------- Install TinyGo 0.34.0 ----------------- +RUN wget https://github.com/tinygo-org/tinygo/releases/download/v0.34.0/tinygo_0.34.0_amd64.deb && \ + dpkg -i tinygo_0.34.0_amd64.deb && \ + rm tinygo_0.34.0_amd64.deb + +# ----------------- Install Rust ----------------- +# Install Rust +RUN curl https://sh.rustup.rs -sSf | sh -s -- -y && \ + . "$HOME/.cargo/env" && \ + cargo install --locked wasm-tools + +# Set Rust environment variables +ENV PATH="/root/.cargo/bin:${PATH}" + +# Verify installations +RUN go version && tinygo version && cargo --version && wash --version && wasm-tools --version + + +# ----------------- Build the WasmCloud module ----------------- +FROM wash-build-image + +RUN mkdir /app +WORKDIR /app + +# Install go dependencies, build the wasm module, push it to the registry +CMD ["sh", "-c", "go env -w GOFLAGS=-buildvcs=false && go mod download && go mod verify && wash build && wash push $REGISTRY build/*.wasm"] \ No newline at end of file diff --git a/src/wasm_builder/docker/deploy.Dockerfile b/src/wasm_builder/docker/deploy.Dockerfile new file mode 100644 index 0000000..65f6ba1 --- /dev/null +++ b/src/wasm_builder/docker/deploy.Dockerfile @@ -0,0 +1,23 @@ +FROM ubuntu:24.04 AS wash-deploy-image + +# Install dependencies and tools +RUN apt-get update && apt-get install -y \ + curl \ + wget \ + tar \ + git \ + build-essential \ + && rm -rf /var/lib/apt/lists/* + +# ----------------- Install WasmCloud ----------------- +RUN curl -s "https://packagecloud.io/install/repositories/wasmcloud/core/script.deb.sh" | bash && \ + apt-get install -y wash + +# ----------------- Deploy the WasmCloud module ----------------- +FROM wash-deploy-image + +RUN mkdir /app +WORKDIR /app + +# Deploy the WasmCloud module +CMD ["sh", "-c", "wash app deploy wadm.yaml"] \ No newline at end of file