-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
f2c8b9d
commit bd48ded
Showing
3 changed files
with
88 additions
and
1 deletion.
There are no files selected for viewing
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
#!/bin/bash | ||
|
||
set -ex | ||
|
||
if [ -z ${IMAGE+x} ] | ||
then | ||
echo 'Error! $IMAGE is required.' | ||
exit 64 | ||
fi | ||
|
||
if [ -z ${PUBLIC_IP+x} ] | ||
then | ||
echo 'Error! $PUBLIC_IP is required.' | ||
exit 64 | ||
fi | ||
|
||
if [ -z ${WRITE_KEY_ID+x} ] | ||
then | ||
echo 'Error! $WRITE_KEY_ID is required.' | ||
exit 64 | ||
fi | ||
|
||
if [ -z ${WRITE_KEY_SECRET+x} ] | ||
then | ||
echo 'Error! $WRITE_KEY_SECRET is required.' | ||
exit 64 | ||
fi | ||
|
||
# Install docker2fl tool | ||
|
||
ssh root@$PUBLIC_IP " | ||
apt-get update | ||
apt-get install -y curl | ||
curl https://sh.rustup.rs -sSf | sh | ||
export PATH="$HOME/.cargo/bin:$PATH" | ||
apt-get install -y build-essential | ||
apt-get install -y musl-tools | ||
apt-get install -y git | ||
apt-get update | ||
# Install docker | ||
apt-get install -y ca-certificates curl | ||
install -m 0755 -d /etc/apt/keyrings | ||
curl -fsSL https://download.docker.com/linux/ubuntu/gpg -o /etc/apt/keyrings/docker.asc | ||
chmod a+r /etc/apt/keyrings/docker.asc | ||
echo \ | ||
"deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.asc] https://download.docker.com/linux/ubuntu \ | ||
$(. /etc/os-release && echo "$VERSION_CODENAME") stable" | \ | ||
tee /etc/apt/sources.list.d/docker.list > /dev/null | ||
apt-get update | ||
apt-get install -y docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin | ||
git clone https://github.com/threefoldtech/rfs.git | ||
cd rfs | ||
rustup target add x86_64-unknown-linux-musl | ||
cargo build --release --target=x86_64-unknown-linux-musl | ||
mv ./target/x86_64-unknown-linux-musl/release/docker2fl /usr/local/bin | ||
" | ||
|
||
# Convert docker image to a flist using docker2fl | ||
|
||
ssh root@$PUBLIC_IP "docker2fl -i $IMAGE -s 's3://$WRITE_KEY_ID:$WRITE_KEY_SECRET@$PUBLIC_IP:3900/blobs?region=garage'" | ||
|
||
# Upload the generated flist on s3 server flist bucket (use any client for it, aws cli is used here) | ||
|
||
ssh root@$PUBLIC_IP " | ||
curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "awscliv2.zip" | ||
unzip awscliv2.zip | ||
./aws/install | ||
cat > ~/.awsrc <<EOF | ||
export AWS_ACCESS_KEY_ID=$WRITE_KEY_ID # put your Key ID here | ||
export AWS_SECRET_ACCESS_KEY=$WRITE_KEY_SECRET # put your Secret key here | ||
export AWS_DEFAULT_REGION='garage' | ||
export AWS_ENDPOINT_URL='http://$PUBLIC_IP:3900' | ||
aws --version | ||
EOF | ||
source ~/.awsrc | ||
aws s3 cp "threefolddev-ubuntu-22.04.fl" "s3://flist/threefolddev-ubuntu-22.04.fl" | ||
#TODO: # threefolddev/ubuntu:22.04 | ||
" |
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