diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000000..32ab28c91e --- /dev/null +++ b/Dockerfile @@ -0,0 +1,15 @@ +FROM ubuntu:20.04 + +RUN apt update && apt -y install \ + build-essential \ + clang \ + curl \ + python3-dev + +ENV RUSTUP_HOME=/opt/rust +ENV CARGO_HOME=/opt/rust +ENV PATH=$PATH:/opt/rust/bin + + +COPY scripts/install_build_tools.sh . +RUN bash install_build_tools.sh diff --git a/run_in_docker.sh b/run_in_docker.sh new file mode 100755 index 0000000000..b2c88f41b7 --- /dev/null +++ b/run_in_docker.sh @@ -0,0 +1,16 @@ +#!/bin/env bash +set -e + +docker_image_name=blockifier-ci +docker build . -t ${docker_image_name} + +docker run \ + --rm \ + --net host \ + -e CARGO_HOME=${HOME}/.cargo \ + -u $UID \ + -v /tmp:/tmp \ + -v "${HOME}:${HOME}" \ + --workdir ${PWD} \ + ${docker_image_name} \ + "$@" diff --git a/scripts/install_build_tools.sh b/scripts/install_build_tools.sh new file mode 100644 index 0000000000..5c5591255a --- /dev/null +++ b/scripts/install_build_tools.sh @@ -0,0 +1,44 @@ +#!/bin/env bash +set -e +function install_base_packages () { + apt update && apt -y install \ + build-essential \ + clang \ + curl \ + python3-dev +} + +function install_pypy() { + pushd /opt + $USE_SUDO bash -c ' + curl -Lo pypy3.9-v7.3.11-linux64.tar.bz2 https://downloads.python.org/pypy/pypy3.9-v7.3.11-linux64.tar.bz2 + tar -xf pypy3.9-v7.3.11-linux64.tar.bz2 + rm pypy3.9-v7.3.11-linux64.tar.bz2 + chmod +x pypy3.9-v7.3.11-linux64/bin/pypy3 + + if [ -L /usr/local/bin/pypy3.9 ]; then + unlink /usr/local/bin/pypy3.9 + fi + + ln -s /opt/pypy3.9-v7.3.11-linux64/bin/pypy3 /usr/local/bin/pypy3.9 + + if [ -L /opt/pypy3.9 ]; then + unlink /opt/pypy3.9 + fi + + ln -s /opt/pypy3.9-v7.3.11-linux64 /opt/pypy3.9 + pypy3.9 -m ensurepip + pypy3.9 -m pip install wheel + ' + popd +} + +function install_rust () { + curl https://sh.rustup.rs -sSf | sh -s -- -y --no-modify-path +} + +# Uncomment only if base packages is not installed via Dockerfile +# install_base_packages +install_pypy & +install_rust & +wait