From df7832bfc703c6bfe64a4e2100ebc1b31ef25ef0 Mon Sep 17 00:00:00 2001 From: John Detter <4099508+jdetter@users.noreply.github.com> Date: Tue, 4 Mar 2025 09:35:20 -0600 Subject: [PATCH] This works on both arm and x86 (#2337) Co-authored-by: John Detter --- Dockerfile | 42 +++++++++++++++++++++++++++++++++++------- 1 file changed, 35 insertions(+), 7 deletions(-) diff --git a/Dockerfile b/Dockerfile index 74a744f15..656e2820a 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,21 +1,49 @@ +# Use a base image that supports multi-arch FROM rust:bookworm -RUN curl -sSfLO https://packages.microsoft.com/config/debian/12/packages-microsoft-prod.deb && \ - dpkg -i packages-microsoft-prod.deb && \ - rm packages-microsoft-prod.deb && \ - apt-get update && \ - apt-get install -y dotnet-sdk-8.0 binaryen && \ - rm -rf /var/lib/apt/lists/* && \ - dotnet workload install wasi-experimental +# Install dependencies +RUN apt-get update && apt-get install -y \ + curl \ + ca-certificates \ + binaryen \ + build-essential \ + && rm -rf /var/lib/apt/lists/* +# Determine architecture for .NET installation +ARG TARGETARCH +ENV DOTNET_ARCH=${TARGETARCH} + +RUN if [ "$DOTNET_ARCH" = "amd64" ]; then \ + DOTNET_ARCH="x64"; \ + elif [ "$DOTNET_ARCH" = "arm64" ]; then \ + DOTNET_ARCH="arm64"; \ + else \ + echo "Unsupported architecture: $DOTNET_ARCH" && exit 1; \ + fi && \ + curl -sSL https://dot.net/v1/dotnet-install.sh | bash /dev/stdin --channel 8.0 --install-dir /usr/share/dotnet --architecture $DOTNET_ARCH + +ENV PATH="/usr/share/dotnet:${PATH}" + +# Install the experimental WASI workload +RUN dotnet workload install wasi-experimental + +# Install Rust WASM target RUN rustup target add wasm32-unknown-unknown +# Create and switch to a non-root user RUN useradd -m spacetime USER spacetime + +# Install SpacetimeDB RUN curl -sSfL https://install.spacetimedb.com | bash -s -- --yes ENV PATH="/home/spacetime/.local/bin:${PATH}" + +# Set working directory WORKDIR /app +# Expose the necessary port EXPOSE 3000 +# Define the entrypoint ENTRYPOINT ["spacetime"] +