Created
October 24, 2022 07:19
-
-
Save mreferre/6dfa7809d8b9856dd5fbdcee1ad3f096 to your computer and use it in GitHub Desktop.
user-data-alex
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
set -e -x | |
export DEBIAN_FRONTEND=noninteractive | |
apt-get update && apt-get upgrade -y | |
echo Building and installing the amazon-efs-utils #(reference: https://gist.github.com/ryanmaclean/c873c9a86f0bc3ee3a260882e73edecb) | |
apt-get -y install git binutils | |
git clone https://github.com/aws/efs-utils | |
cd efs-utils | |
./build-deb.sh | |
apt-get -y install ./build/amazon-efs-utils*deb | |
echo Configuring the EFS mount... | |
apt-get -y install nfs-common | |
file_system_id_1=fs-03f7bd7418300388f | |
access_point_id=fsap-05e9703ee61d51944 | |
efs_mount_point_1=/mnt/wasm | |
mkdir -p "${efs_mount_point_1}" | |
chmod 666 "${efs_mount_point_1}" | |
#mount -t nfs4 -o nfsvers=4.1,rsize=1048576,wsize=1048576,hard,timeo=600,retrans=2,noresvport ${file_system_id_1}.efs.us-west-2.amazonaws.com:/ ${efs_mount_point_1} | |
mount -t efs -o tls,accesspoint=${access_point_id} ${file_system_id_1}:/ ${efs_mount_point_1} | |
echo Installing Rust / WASM dev toolchain and its requirements... | |
apt install -y build-essential | |
curl https://sh.rustup.rs -sSf | bash -s -- -y | |
/root/.cargo/bin/rustup target add wasm32-wasi | |
echo Installing Spin... | |
apt-get -y install jq | |
LATEST=$(curl -s https://api.github.com/repos/fermyon/spin/releases/latest) | |
X86URL=$(echo $LATEST | jq -r '.assets[].browser_download_url' | grep linux-amd64.tar.gz) | |
X86ARTIFACT=$(echo $LATEST | jq -r '.assets[].name' | grep linux-amd64.tar.gz) | |
curl -L -O $X86URL | |
tar -zxvf $X86ARTIFACT | |
mv spin /usr/local/bin/spin | |
echo Creating and building a small application... | |
cd ${efs_mount_point_1} | |
spin templates install --git https://github.com/fermyon/spin | |
[[ -d spin-hello-world ]] || spin new http-rust spin-hello-world --value project-description="Rust http service" --value http-base=/ --value http-path=/ | |
/root/.cargo/bin/cargo build --manifest-path ./spin-hello-world/Cargo.toml --target wasm32-wasi --release | |
echo Launching Spin... | |
spin up --listen 0.0.0.0:3000 --file ${efs_mount_point_1}/spin-hello-world/spin.toml |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment