FROM quay.io/fedora/fedora:latest

ARG WASM_EDGE_VERSION="0.14.0"

# Install the deps for building crun
RUN dnf install -y --setopt=install_weak_deps=False awk make python git-core gcc automake autoconf libcap-devel \
		systemd-devel json-c-devel libseccomp-devel pkg-config diffutils \
		glibc-static python3-libmount libtool buildah podman which

# Install WasmEdge
RUN curl -sSf -o install.sh https://raw.githubusercontent.com/WasmEdge/WasmEdge/master/utils/install.sh
RUN bash ./install.sh -p /usr -v $WASM_EDGE_VERSION
RUN cp -P /usr/lib/libwasmedge* /usr/lib64/

# The hello_wasm contains:
# 1. The example rust application called hello, which will print something to console.
# 2. The Containerfile for building the image including hello.wasm
ADD hello_wasm /hello_wasm

# Build the wasm application
RUN dnf install -y --setopt=install_weak_deps=False cargo rust-std-static-wasm32-wasip1 && \
		cd /hello_wasm/hello && \
		cargo build --release --target wasm32-wasip1 && \
		cp ./target/wasm32-wasip1/release/hello.wasm /hello_wasm && \
		cd / && \
		rm -rf /hello_wasm/hello

COPY run-tests.sh /usr/local/bin

ENTRYPOINT ["/usr/local/bin/run-tests.sh"]
