crystal-builder/run.sh

66 lines
1.9 KiB
Bash
Raw Normal View History

2023-10-27 07:01:37 +00:00
#!/bin/sh
set -eu
# Prebuild for target architecture
# FIXME: auto-configure arch + keep the build phase out of image
CRYSTAL_VOLUME="$(docker volume list --format json |jq -r -s '.[] | select(.Name == "crystal") | try(.Name)')"
if [ -n "$CRYSTAL_VOLUME" ]; then
docker volume rm crystal
fi
docker volume create crystal
## 1. Install the latest crystal release
## 2. Make sure a supported LLVM version is present in the path
## 3. Make sure to install all the required libraries. You might also want to read the contributing guide.
## 4. Clone the repository: git clone https://github.com/crystal-lang/crystal
docker build -t crystal-builder:phase1 --file docker/Dockerfile.phase1 ./
## 5. Run make to build your own version of the compiler.
docker run -it --rm --name crystal-builder \
-v crystal:/crystal \
crystal-builder:phase1 \
sh /setup/step5.sh
# 5bis. Compile Crystal project statically for target architecture
docker run \
--rm \
--privileged \
multiarch/qemu-user-static \
--reset -p yes
INSTALL_CRYSTAL=" \
sed -i -e 's/Types: deb/Types: deb deb-src/' /etc/apt/sources.list.d/debian.sources \
&& echo 'deb http://deb.debian.org/debian unstable main' > /etc/apt/sources.list.d/sid.list \
&& echo 'deb-src http://deb.debian.org/debian unstable main' >> /etc/apt/sources.list.d/sid.list \
&& apt-get update \
&& apt-get install -y \
g++ \
libxml2-dev \
llvm-dev \
make \
libssl-dev \
libpcre3-dev \
libyaml-dev \
zlib1g-dev \
dpkg-dev \
&& apt source crystal \
&& apt build-dep crystal \
&& ls -lF \
"
BUILD_COMMAND="sleep 1"
docker run \
-it \
-v "crystal:/crystal" \
-w /crystal \
--rm \
--platform linux/arm64 \
"arm64v8/debian" \
/bin/sh -c "$INSTALL_CRYSTAL && $BUILD_COMMAND && bash"
## 6. Run make std_spec compiler_spec to ensure all specs pass, and youve installed everything correctly.
## 7. Use bin/crystal to run your crystal files.