dockerfile: move to repo root

This commit is contained in:
2026-01-28 18:08:08 +01:00
parent 0809803bfd
commit 103de5345e
3 changed files with 39 additions and 119 deletions

View File

@ -1,8 +1,8 @@
docker:
docker build -t wasm-base wasm-base
docker build -t wasm-base -f wasm-base.dockerfile .
run:
docker run --rm -it wasm-base:latest /bin/bash
docker run --rm -it wasm-base:latest /usr/bin/fish
run-external:
docker run --rm -it -v "./wasm-base/examples:/home/ubuntu/examples" wasm-base:latest /bin/bash
docker run --rm -it -v "./wasm-base/examples:/home/ubuntu/examples" wasm-base:latest /usr/bin/fish

View File

@ -3,13 +3,15 @@ FROM ubuntu:noble AS wamr-builder
RUN apt-get update \
&& DEBIAN_FRONTEND=noninteractive TZ=Europe/Berline apt-get install -y --no-install-recommends \
build-essential \
busybox \
git \
cmake \
ca-certificates \
gcc-multilib \
g++-multilib \
libgcc-11-dev \
lib32gcc-11-dev \
libc6-dev-i386 \
busybox \
git \
ca-certificates \
cmake \
ccache \
python3-minimal \
python3-pip \
@ -24,10 +26,12 @@ RUN git clone https://github.com/bytecodealliance/wasm-micro-runtime \
&& git checkout WAMR-2.4.4
WORKDIR /wasm-micro-runtime
# Build WAMR iwasm (standalone interpreter)
# Build WAMR iwasm (vmcore standalone interpreter)
RUN cd product-mini/platforms/linux \
&& mkdir build_iwasm && cd build_iwasm \
&& cmake \
-DWAMR_BUILD_PLATFORM=linux \
-DWAMR_BUILD_TARGET=X86_64 \
-DWAMR_BUILD_AOT=0 \
-DWAMR_BUILD_WAMR_COMPILER=0 \
-DWAMR_BUILD_INTERP=1 \
@ -39,25 +43,13 @@ RUN cd product-mini/platforms/linux \
.. \
&& make -j$(nproc)
# Build WAMR libiwasm (interpreter runtime)
RUN mkdir build_libiwasm && cd build_libiwasm \
&& cmake \
-DWAMR_BUILD_AOT=1 \
-DWAMR_BUILD_WAMR_COMPILER=0 \
-DWAMR_BUILD_INTERP=1 \
-DWAMR_BUILD_FAST_INTERP=0 \
-DWAMR_BUILD_JIT=0 \
-DWAMR_BUILD_FAST_JIT=0 \
-DWAMR_BUILD_LIBC_BUILTIN=1 \
-DWAMR_BUILD_LIBC_WASI=1 \
.. \
&& make -j$(nproc)
# Build WAMR wamrc (standalone compiler)
RUN cd wamr-compiler \
&& ./build_llvm.sh \
&& mkdir build_wamrc && cd build_wamrc \
&& cmake \
-DWAMR_BUILD_PLATFORM=linux \
-DWAMR_BUILD_TARGET=X86_64 \
-DWAMR_BUILD_AOT=0 \
-DWAMR_BUILD_WAMR_COMPILER=1 \
-DWAMR_BUILD_INTERP=0 \
@ -69,11 +61,30 @@ RUN cd wamr-compiler \
.. \
&& make -j$(nproc)
# Build WAMR libvmlib (compiler runtime)
# Build WAMR libvmlib (compiler runtime - to compile wasm modules embedded in a native application)
RUN cd wamr-compiler \
&& ./build_llvm.sh \
# && ./build_llvm.sh --extra-cmake-flags "-DCMAKE_C_FLAGS=-m32 -DCMAKE_CXX_FLAGS=-m32 -DCMAKE_EXE_LINKER_FLAGS=-m32 -lstdc++" \
&& mkdir build_libvmlib && cd build_libvmlib \
&& cmake \
-DWAMR_BUILD_PLATFORM=linux \
-DWAMR_BUILD_TARGET=X86_64 \
-DWAMR_BUILD_AOT=1 \
-DWAMR_BUILD_WAMR_COMPILER=0 \
-DWAMR_BUILD_INTERP=0 \
-DWAMR_BUILD_FAST_INTERP=0 \
-DWAMR_BUILD_JIT=0 \
-DWAMR_BUILD_FAST_JIT=0 \
-DWAMR_BUILD_LIBC_BUILTIN=1 \
-DWAMR_BUILD_LIBC_WASI=0 \
.. \
&& make -j$(nproc)
# Build WAMR libiwasm (vmcore interpreter runtime - to run wasm modules embedded in a native application)
RUN mkdir build_libiwasm && cd build_libiwasm \
&& cmake \
-DWAMR_BUILD_PLATFORM=linux \
-DWAMR_BUILD_TARGET=X86_64 \
-DWAMR_BUILD_AOT=1 \
-DWAMR_BUILD_WAMR_COMPILER=0 \
-DWAMR_BUILD_INTERP=1 \
@ -81,7 +92,7 @@ RUN cd wamr-compiler \
-DWAMR_BUILD_JIT=0 \
-DWAMR_BUILD_FAST_JIT=0 \
-DWAMR_BUILD_LIBC_BUILTIN=1 \
-DWAMR_BUILD_LIBC_WASI=1 \
-DWAMR_BUILD_LIBC_WASI=0 \
.. \
&& make -j$(nproc)
@ -91,13 +102,16 @@ FROM ghcr.io/webassembly/wasi-sdk:wasi-sdk-29
RUN apt-get update \
&& DEBIAN_FRONTEND=noninteractive TZ=Europe/Berline apt-get install -y --no-install-recommends \
build-essential \
gcc-multilib \
busybox \
git \
ca-certificates \
wget \
neovim \
ranger \
wabt \
busybox \
fish \
&& apt-get clean
COPY --from=wamr-builder /wasm-micro-runtime /opt/wamr

View File

@ -1,94 +0,0 @@
# Paths
WAMR_ROOT := /opt/wamr
WAMRC := /opt/wamr-wamrc/wamrc
IWASM := /opt/wamr-iwasm/iwasm
WAMRC_LIB := /opt/wamr-libvmlib
IWASM_LIB := /opt/wamr-libiwasm
WASI_ROOT := /opt/wasi-sdk
WASI_CC := $(WASI_ROOT)/bin/clang
WASI_CFLAGS := --target=wasm32-wasi \
--sysroot=$(WASI_ROOT)/share/wasi-sysroot \
-O0 -g -Wall
# Embedding
EMBED_CC := gcc
EMBED_INCL := -I$(WAMR_ROOT)/core/iwasm/include \
-I$(WAMR_ROOT)/core/iwasm/common \
-I$(WAMR_ROOT)/core/shared/platform/linux \
-I$(WAMR_ROOT)/core/shared/utils \
-I$(WAMR_ROOT)/core/shared/utils/uncommon
EMBED_SOURCES := $(WAMR_ROOT)/core/shared/utils/uncommon/bh_read_file.c
EMBED_CFLAGS := -O0 -g -Wall $(EMBED_INCL) $(EMBED_SOURCES)
AOT_LDFLAGS := -Wl,-rpath,$(WAMRC_LIB)
AOT_LDLIBS := -L$(WAMRC_LIB) -lvmlib -lm
INTER_LDFLAGS := -Wl,-rpath,$(IWASM_LIB)
INTER_LDLIBS := -L$(IWASM_LIB) -liwasm -lm
XXD := busybox xxd
# Files
SRCS := $(wildcard *.c)
WASMS := $(SRCS:.c=.wasm)
CWASMS := $(SRCS:.c=_wasm.c)
AOTS := $(SRCS:.c=.aot)
OBJS := $(SRCS:.c=.o)
DEPS := $(SRCS:.c=.d)
HOSTS := $(SRCS:.c=.host)
.PHONY: all build-wasms build-aots build-cwasms build-hosts clean
all: build-wasms build-aots build-cwasms build-hosts
# Compile to wasm bytecode using wasi-sdk
build-wasms: $(WASMS)
%.wasm: %.c
$(WASI_CC) $(WASI_CFLAGS) $< -o $@
# Compile ahead-of-time module using wamrc
build-aots: $(AOTS)
%.aot: %.wasm
$(WAMRC) -o $@ $<
# $(WAMRC) --enable-wasi -o $@ $<
# Convert the .aot files to C-style arrays (to embed them into the resulting host binary)
build-cwasms: $(CWASMS)
%_wasm.c: %.aot
$(XXD) -i $< > $@
# Compile the host that will load and run the compiled wasm module
# The compiled wasm module is embedded as C-style array
build-hosts: $(HOSTS)
# The C-style array is called %_aot, e.g. test_aot
# We have to modify the host to refer to that with the correct name
%.host: %_wasm.c
cp embed/host.c embed/$*_host.c
sed -i \
-e "s/__WASM_ARRAY_FILE__/$*_wasm.c/g" \
-e "s/__WASM_ARRAY__/$*_aot/g" \
-e "s/__WASM_ARRAY_LEN__/$*_aot_len/g" \
embed/$*_host.c
$(EMBED_CC) $(EMBED_CFLAGS) embed/$*_host.c -o $@ $(INTER_LDFLAGS) $(INTER_LDLIBS)
clean:
rm -f *.wasm
rm -f *.aot
rm -f *_wasm.c
rm -f *.d
rm -f *.o
rm -f embed/*_host.c
rm -f *.host
# Compile to C-embedded
# embed: $(OBJS)
# $(EMBED_CC) $(OBJS) -o embed $(AOT_LDFLAGS) $(AOT_LDLIBS)
# %.o: %.c
# $(EMBED_CC) $(EMBED_CFLAGS) -o $@ $<
# embed_host:
# $(EMBED_CC) $(EMBED_CFLAGS) embed/host.c -o host $(INTER_LDFLAGS) $(INTER_LDLIBS)