fixed build dockerfile

This commit is contained in:
Lorenzo Venerandi 2024-12-13 13:14:18 +01:00
parent 4f47194d8d
commit ac9a119eb5

View File

@ -1,54 +1,52 @@
FROM ubuntu:24.04 AS wash-build-image FROM ubuntu:24.04 AS wash-build-image
# Install dependencies and tools # Install dependencies and tools
RUN apt-get update && apt-get install -y \ RUN apt-get update && apt-get install -y \
curl \ curl \
wget \ wget \
tar \ tar \
git \ git \
build-essential \ build-essential \
&& rm -rf /var/lib/apt/lists/* && rm -rf /var/lib/apt/lists/*
# ----------------- Install WasmCloud ----------------- # ----------------- Install WasmCloud -----------------
RUN curl -s "https://packagecloud.io/install/repositories/wasmcloud/core/script.deb.sh" | bash && \ RUN curl -s "https://packagecloud.io/install/repositories/wasmcloud/core/script.deb.sh" | bash && \
apt-get install -y wash apt-get install -y wash
# ----------------- Install Go 1.23 ----------------- # ----------------- Install Go 1.23 -----------------
RUN wget https://go.dev/dl/go1.23.4.linux-amd64.tar.gz && \ 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 && \ tar -C /usr/local -xzf go1.23.4.linux-amd64.tar.gz && \
rm go1.23.4.linux-amd64.tar.gz rm go1.23.4.linux-amd64.tar.gz
# Set Go environment variables # Set Go environment variables
ENV PATH="/usr/local/go/bin:${PATH}" ENV PATH="/usr/local/go/bin:${PATH}"
ENV GOPATH="/go" ENV GOPATH="/go"
ENV GOROOT="/usr/local/go" ENV GOROOT="/usr/local/go"
# ----------------- Install TinyGo 0.34.0 ----------------- # ----------------- Install TinyGo 0.34.0 -----------------
RUN wget https://github.com/tinygo-org/tinygo/releases/download/v0.34.0/tinygo_0.34.0_amd64.deb && \ 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 && \ dpkg -i tinygo_0.34.0_amd64.deb && \
rm tinygo_0.34.0_amd64.deb rm tinygo_0.34.0_amd64.deb
# ----------------- Install Rust ----------------- # ----------------- Install Rust -----------------
# Install Rust # Install Rust
RUN curl https://sh.rustup.rs -sSf | sh -s -- -y && \ RUN curl https://sh.rustup.rs -sSf | sh -s -- -y && \
. "$HOME/.cargo/env" && \ . "$HOME/.cargo/env" && \
cargo install --locked wasm-tools cargo install --locked wasm-tools
# Set Rust environment variables # Set Rust environment variables
ENV PATH="/root/.cargo/bin:${PATH}" ENV PATH="/root/.cargo/bin:${PATH}"
# Verify installations # Verify installations
RUN go version && tinygo version && cargo --version && wash --version && wasm-tools --version RUN go version && tinygo version && cargo --version && wash --version && wasm-tools --version
# ----------------- Build the WasmCloud module ----------------- # ----------------- Build the WasmCloud module -----------------
FROM wash-build-image FROM wash-build-image
RUN mkdir /app RUN mkdir /app
WORKDIR /app WORKDIR /app
USER ubuntu # Install go dependencies, build the wasm module, push it to the registry
#CMD ["sh", "-c", "go mod download && go mod verify && go mod tidy && wash build && wash push $REGISTRY build/*_s.wasm"]
# 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/*_s.wasm"]
#CMD ["sh", "-c", "go mod download && go mod verify && go mod tidy && wash build && wash push $REGISTRY build/*_s.wasm"]
CMD ["sh", "-c", "go mod download && go mod verify && go mod tidy && chmod -R u+rw /app && sleep 2 && wash build && wash push $REGISTRY build/*_s.wasm"]