diff --git a/packaging/Makefile b/packaging/Makefile index d5140c8ad..e5bc51eca 100644 --- a/packaging/Makefile +++ b/packaging/Makefile @@ -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 @@ -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 diff --git a/packaging/aleph-vm/DEBIAN/postinst b/packaging/aleph-vm/DEBIAN/postinst index f7d9f642a..99af91c2d 100755 --- a/packaging/aleph-vm/DEBIAN/postinst +++ b/packaging/aleph-vm/DEBIAN/postinst @@ -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 diff --git a/packaging/aleph-vm/etc/systemd/system/aleph-vm-supervisor.service b/packaging/aleph-vm/etc/systemd/system/aleph-vm-supervisor.service index 4d5c41929..e5a904d28 100644 --- a/packaging/aleph-vm/etc/systemd/system/aleph-vm-supervisor.service +++ b/packaging/aleph-vm/etc/systemd/system/aleph-vm-supervisor.service @@ -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 diff --git a/packaging/aleph-vm/etc/systemd/system/ipfs.service b/packaging/aleph-vm/etc/systemd/system/ipfs.service new file mode 100644 index 000000000..f3506a275 --- /dev/null +++ b/packaging/aleph-vm/etc/systemd/system/ipfs.service @@ -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