Skip to content

Commit

Permalink
Feature: install Kubo on CRNs (#385)
Browse files Browse the repository at this point in the history
* Feature: install Kubo on CRNs

Problem: we wish to upload large snapshot files to the aleph.im network.
The aleph.im API requires large files to be available on IPFS.

Solution: install Kubo (IPFS daemon) on CRNs.

* fix init cmds

* systemd

* more fixes

* fix

* dep mgmt
  • Loading branch information
odesenfans authored Jul 25, 2023
1 parent dca79dd commit f1c0427
Show file tree
Hide file tree
Showing 4 changed files with 56 additions and 2 deletions.
7 changes: 6 additions & 1 deletion packaging/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,13 @@ debian-package-code:
pip3 install --target ./aleph-vm/opt/aleph-vm/ 'aleph-message==0.4.0' 'jwskate==0.8.0' 'eth-account==0.9.0'
python3 -m compileall ./aleph-vm/opt/aleph-vm/

debian-package-resources: firecracker-bins vmlinux
debian-package-resources: firecracker-bins vmlinux download-ipfs-kubo
rm -fr ./aleph-vm/opt/firecracker
mkdir -p ./aleph-vm/opt/firecracker
cp -pr ./target/vmlinux.bin ./aleph-vm/opt/firecracker/
cp -pr ./target/firecracker ./aleph-vm/opt/firecracker/
cp -pr ./target/jailer ./aleph-vm/opt/firecracker/
cp -pr ./target/kubo/kubo ./aleph-vm/opt/kubo

firecracker-bins: target-dir build-dir
mkdir -p ./build/firecracker-release
Expand All @@ -42,6 +43,10 @@ vmlinux:
curl -fsSL -o ./target/vmlinux.bin https://github.com/aleph-im/aleph-vm/releases/download/0.2.2/vmlinux.bin
#cp ../kernels/vmlinux.bin ./target/vmlinux.bin

download-ipfs-kubo: target-dir build-dir
mkdir -p ./target/kubo
curl -fsSL https://dist.ipfs.tech/kubo/v0.21.0/kubo_v0.21.0_linux-amd64.tar.gz | tar -xz --directory ./target/kubo

version:
python3 ./version_from_git.py --inplace deb aleph-vm/DEBIAN/control
python3 ./version_from_git.py --inplace __version__ ../vm_supervisor/version.py
Expand Down
1 change: 1 addition & 0 deletions packaging/aleph-vm/DEBIAN/postinst
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ mkdir -p /var/lib/aleph/vm/jailer
# Systemd is absent from containers
if ! [[ -v container ]]; then
systemctl daemon-reload
systemctl enable ipfs.service
systemctl enable aleph-vm-supervisor.service
systemctl restart aleph-vm-supervisor.service
fi
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
[Unit]
Description=Aleph.im VM execution engine
After=network.target
After=network.target ipfs.service
Requires=ipfs.service

[Service]
User=0
Expand Down
47 changes: 47 additions & 0 deletions packaging/aleph-vm/etc/systemd/system/ipfs.service
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# This file will be overwritten on package upgrades, avoid customizations here.
#
# To make persistent changes, create file in
# "/etc/systemd/system/ipfs.service.d/overwrite.conf" with
# `systemctl edit ipfs.service`. This file will be parsed after this
# file has been parsed.
#
# To overwrite a variable, like ExecStart you have to specify it once
# blank and a second time with a new value, like:
# ExecStart=
# ExecStart=/usr/bin/ipfs daemon --flag1 --flag2
#
# For more info about custom unit files see systemd.unit(5).

[Unit]
Description=InterPlanetary File System (IPFS) daemon
Documentation=https://docs.ipfs.tech/
After=network.target

[Service]

# enable for 1-1024 port listening
#AmbientCapabilities=CAP_NET_BIND_SERVICE
# enable to specify a custom path see docs/environment-variables.md for further documentations
#Environment=IPFS_PATH=/custom/ipfs/path
# enable to specify a higher limit for open files/connections
#LimitNOFILE=1000000

#don't use swap
MemorySwapMax=0

# Don't timeout on startup. Opening the IPFS repo can take a long time in some cases (e.g., when
# badger is recovering) and migrations can delay startup.
#
# Ideally, we'd be a bit smarter about this but there's no good way to do that without hooking
# systemd dependencies deeper into go-ipfs.
TimeoutStartSec=infinity

Type=notify
StateDirectory=ipfs
Environment=IPFS_PATH="${HOME}"
ExecStart=/opt/kubo/ipfs daemon --init --migrate
Restart=on-failure
KillSignal=SIGINT

[Install]
WantedBy=default.target

0 comments on commit f1c0427

Please sign in to comment.