-
Notifications
You must be signed in to change notification settings - Fork 16
Expand file tree
/
Copy pathDockerfile.dev
More file actions
130 lines (110 loc) · 4.44 KB
/
Dockerfile.dev
File metadata and controls
130 lines (110 loc) · 4.44 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
# syntax=docker/dockerfile:1.7-labs
# NOTE: Enable Docker Labs syntax for future convenience
# Base image for development and debugging with perf and gdb support
#
# - Installs standard build tools and debugging utilities
# - Assumes container is run with --privileged for perf to function
#
# Usage:
# docker build -f Dockerfile.dev -t devtest .
# docker run --privileged -it devtest /bin/bash
FROM ubuntu:22.04
# --- Build arguments ---
ARG USERNAME=lind
ARG BRANCH_NAME=main
ARG REPO_URL="https://github.com/Lind-Project/lind-wasm.git"
ARG LLVM_VERSION="llvmorg-18.1.8"
ARG CLANG_PACKAGE="clang+llvm-18.1.8-x86_64-linux-gnu-ubuntu-18.04"
ARG WABT_VERSION="1.0.38"
# --- System setup ---
ENV DEBIAN_FRONTEND=noninteractive
# Install base tools
RUN apt-get update && apt-get install -y --no-install-recommends -qq \
binutils \
bison \
cmake \
flex \
build-essential \
ca-certificates \
strace \
curl \
gawk \
git \
gnupg \
libc6-dev-i386-cross \
libxml2 \
make \
python3 \
sed \
sudo \
unzip \
zip \
autoconf \
rsync \
libtool \
automake \
vim \
wget \
openssl \
libssl-dev \
golang \
gdb \
linux-tools-common \
linux-tools-generic \
&& rm -rf /var/lib/apt/lists/*
# Install a pinned WABT version for wasm2wat/wat2wasm/wasm-objdump.
RUN curl -fsSL "https://github.com/WebAssembly/wabt/releases/download/${WABT_VERSION}/wabt-${WABT_VERSION}.tar.xz" -o /tmp/wabt.tar.xz && \
mkdir -p /tmp/wabt-src && \
tar -xJf /tmp/wabt.tar.xz -C /tmp/wabt-src --strip-components=1 && \
cmake -S /tmp/wabt-src -B /tmp/wabt-src/build -DCMAKE_BUILD_TYPE=Release -DBUILD_TESTS=OFF && \
cmake --build /tmp/wabt-src/build --target wasm2wat wat2wasm wasm-objdump --parallel "$(nproc)" && \
install -m 0755 /tmp/wabt-src/build/wasm2wat /usr/local/bin/wasm2wat && \
install -m 0755 /tmp/wabt-src/build/wat2wasm /usr/local/bin/wat2wasm && \
install -m 0755 /tmp/wabt-src/build/wasm-objdump /usr/local/bin/wasm-objdump && \
rm -rf /tmp/wabt.tar.xz /tmp/wabt-src
# --- Create user ---
RUN groupadd --gid 1000 ${USERNAME} && \
useradd --uid 1000 --gid ${USERNAME} --create-home --shell /bin/bash ${USERNAME} && \
echo "${USERNAME} ALL=(ALL) NOPASSWD:ALL" >> /etc/sudoers
# --- Install libtinfo5 as root ---
RUN wget http://security.ubuntu.com/ubuntu/pool/universe/n/ncurses/libtinfo5_6.3-2ubuntu0.1_amd64.deb && \
apt install ./libtinfo5_6.3-2ubuntu0.1_amd64.deb
# --- Switch to user ASAP ---
USER ${USERNAME}
WORKDIR /home/${USERNAME}
# --- Install Rust as user ---
# --profile minimal tells rustup to install only the essentials for the toolchain
RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | \
sh -s -- -y --profile minimal
# --- Clone the repo as user ---
RUN git clone --branch "${BRANCH_NAME}" --single-branch "${REPO_URL}" /home/${USERNAME}/lind-wasm
# --- Enable discovery of all branches, then fetch them ---
WORKDIR /home/${USERNAME}/lind-wasm
RUN git remote set-branches origin '*' && git fetch origin
# --- Switch back to root for installing Clang binaries and symlinking ---
USER root
RUN curl -sL https://github.com/llvm/llvm-project/releases/download/${LLVM_VERSION}/${CLANG_PACKAGE}.tar.xz | \
tar -xJ -C /home/${USERNAME}/lind-wasm && \
ln -sf /home/${USERNAME}/lind-wasm/${CLANG_PACKAGE}/bin/* /usr/local/bin/
# --- Patch glibc wasi includes into clang dir and fix permissions ---
RUN cp -r /home/${USERNAME}/lind-wasm/src/glibc/wasi \
/home/${USERNAME}/lind-wasm/${CLANG_PACKAGE}/lib/clang/18/lib && \
chown -R ${USERNAME}:${USERNAME} /home/${USERNAME}/
# --- Back to user for everything else ---
USER ${USERNAME}
# --- Fix PATH ---
ENV PATH="/usr/local/bin:/home/${USERNAME}/.cargo/bin:/home/${USERNAME}/go/bin:$PATH"
ENV CLANG="/home/${USERNAME}/lind-wasm/${CLANG_PACKAGE}"
ENV MATH_TEST_DIR="math_tests"
# --- Prebuild ---
RUN make lind-debug
# --- Make lind_* available from anywhere in the dev container ---
# Tell scripts where the repo is (they are installed to /usr/local/bin)
ENV LIND_WASM_ROOT=/home/${USERNAME}/lind-wasm
USER root
RUN install -D -m 0755 /home/${USERNAME}/lind-wasm/scripts/lind_compile /usr/local/bin/lind_compile \
&& install -D -m 0755 /home/${USERNAME}/lind-wasm/scripts/lind_run /usr/local/bin/lind_run \
&& ln -sf /usr/local/bin/lind_compile /usr/local/bin/lind-clang \
&& ln -sf /usr/local/bin/lind_run /usr/local/bin/lind-wasm
USER ${USERNAME}
CMD ["/bin/bash"]