mainnet packer provisioner
This commit is contained in:
parent
c9c26ee282
commit
de80b1e433
@ -2,6 +2,7 @@ version: 2.1
|
||||
orbs:
|
||||
go: gotest/tools@0.0.13
|
||||
aws-cli: circleci/aws-cli@1.3.2
|
||||
packer: salaxander/packer@0.0.3
|
||||
|
||||
executors:
|
||||
golang:
|
||||
@ -583,6 +584,18 @@ jobs:
|
||||
docker push $<<parameters.account-url>>/<<parameters.repo>>:${tag}
|
||||
done
|
||||
|
||||
publish-packer:
|
||||
description: build and push AWS IAM and DigitalOcean droplet.
|
||||
executor:
|
||||
name: packer/default
|
||||
packer-version: 1.6.6
|
||||
steps:
|
||||
- checkout
|
||||
- attach_workspace:
|
||||
at: "."
|
||||
- packer/build:
|
||||
template: tools/packer/lotus.pkr.hcl
|
||||
|
||||
workflows:
|
||||
version: 2.1
|
||||
ci:
|
||||
@ -683,3 +696,13 @@ workflows:
|
||||
path: .
|
||||
repo: lotus-dev
|
||||
tag: '${CIRCLE_SHA1:0:8}'
|
||||
- publish-packer:
|
||||
requires:
|
||||
- build-all
|
||||
filters:
|
||||
branches:
|
||||
ignore:
|
||||
- /.*/
|
||||
tags:
|
||||
only:
|
||||
- /^v\d+\.\d+\.\d+$/
|
||||
|
83
tools/packer/LOTUS.txt
Normal file
83
tools/packer/LOTUS.txt
Normal file
@ -0,0 +1,83 @@
|
||||
,*/((/*,.
|
||||
((((((((((((((((((((((((((((*
|
||||
.(((((((((((((((((((((((((((((((((((((((
|
||||
(((((((((((((((((((((((((((((((((((((((((((((((
|
||||
.(((((((((((((((((((((((((((((((((((((((((((((((((((((
|
||||
(((((((((((((((((((((((((((((((((((((((((*..,/((((((((((((.
|
||||
((((((((((((((((((((((((((((((((((((((, /((/ (((((((((((*
|
||||
((((((((((((((((((((((((((((((((((((((. (((((((( (((((((((((((,
|
||||
.(((((((((((((((((((((((((((((((((((((( (((((((((((((((((((((((((((
|
||||
/(((((((((((((((((((((((((((((((((((((/ (((((((((((((((((((((((((((((
|
||||
((((((((((((((((((((((((((((((((((((((/ ,((((((((((((((((((((((((((((((.
|
||||
/(((((((((((((((((((((((((((((((((((((( ((((((((((((((((((((((((((((((((.
|
||||
.(((((((((((((((((((((((((( .*//((((( ((((((((((((((((((((((((((((((((((
|
||||
((((((((((((((((((((((((((( .,*/(((((((((((((((((((((((((((((/
|
||||
(((((((((((((((((((((((((((((((((((((( , (((((((((((((((((((((((((
|
||||
*(((((((((((((((((((((((((((((((((((((. ((((((((((((((((((((((((((((((((((((
|
||||
((((((((((((((((((((((((((/ .,*((( (((((((((((((((((((((((((((((((((((((
|
||||
*(((((((((((((((((((((((((((*,. .,*/(((((((((((((((((((((((((((
|
||||
(((((((((((((((((((((((((((((((((((/ ((/*,. ((((((((((((((((((((((((((
|
||||
((((((((((((((((((((((((((((((((((( ,(((((((((((((((((((((((((((((((((((((/
|
||||
(((((((((((((((((((((((((((((((((* ((((((((((((((((((((((((((((((((((((((
|
||||
*(((((((((((((((((((((((((((((((( ((((((((((((((((((((((((((((((((((((((
|
||||
*((((((((((((((((((((((((((((((. ((((((((((((((((((((((((((((((((((((((.
|
||||
,((((((((((((((((((((((((((((( ((((((((((((((((((((((((((((((((((((((
|
||||
((((((((((((((((((((((((((( ((((((((((((((((((((((((((((((((((((((
|
||||
*(((((((((((((. ((((((( .(((((((((((((((((((((((((((((((((((((
|
||||
*(((((((((((/ ((, /(((((((((((((((((((((((((((((((((((((.
|
||||
.(((((((((((((((((((((((((((((((((((((((((((((((((((((((((
|
||||
((((((((((((((((((((((((((((((((((((((((((((((((((((*
|
||||
*(((((((((((((((((((((((((((((((((((((((((((((.
|
||||
*(((((((((((((((((((((((((((((((((((((.
|
||||
((((((((((((((((((((((((((*
|
||||
|
||||
Protocol Labs
|
||||
|
||||
|
||||
|
||||
Your lotus node is up and running!
|
||||
|
||||
This image contains the two most important pieces of the lotus filecoin suite, the
|
||||
daemon and the miner. The daemon is is configured to download a snapshot and start
|
||||
running. In fact, by the time you read this, the daemon may already be in sync.
|
||||
Go ahead and make sure everything is working correctly with the following commands.
|
||||
|
||||
|
||||
|
||||
To check if the daemon is running:
|
||||
|
||||
systemctl status lotus-daemon
|
||||
|
||||
|
||||
|
||||
To check if the daemon is in sync:
|
||||
|
||||
lotus sync status
|
||||
|
||||
|
||||
|
||||
No wallets are crated by default. You can view, create, and delete wallets wit
|
||||
the lotus command. Be careful, now. Don't delete a wallet with funds!
|
||||
|
||||
lotus wallet list
|
||||
lotus wallet new bls
|
||||
|
||||
|
||||
|
||||
The lotus miner is also installed, but it's not running by default. If you have no
|
||||
special disk or worker requirements, you can initialize the lotus-miner repo like this:
|
||||
|
||||
sudo -E -u fc lotus-miner init -o <wallet_you_created_before>
|
||||
|
||||
|
||||
|
||||
You only need to do this once, after which, you can enable and start the miner.
|
||||
|
||||
sudo systemctl enable lotus-miner
|
||||
sudo systemctl start lotus-miner
|
||||
|
||||
|
||||
|
||||
For more information, see https://docs.filecoin.io/
|
||||
Found a bug? let us know! https://github.com/filecoin-project/lotus
|
||||
Chat with us on slack! https://filecoinproject.slack.com/archives/CEGN061C5
|
5
tools/packer/bashrc
Normal file
5
tools/packer/bashrc
Normal file
@ -0,0 +1,5 @@
|
||||
PS1="[\h \w] ⨎ "
|
||||
|
||||
export PROMT_DIRTRIM=1
|
||||
export LOTUS_PATH=/var/lib/lotus
|
||||
export LOTUS_MINER_PATH=/var/lib/lotus-miner
|
79
tools/packer/lotus.pkr.hcl
Normal file
79
tools/packer/lotus.pkr.hcl
Normal file
@ -0,0 +1,79 @@
|
||||
locals { timestamp = regex_replace(timestamp(), "[- TZ:]", "") }
|
||||
|
||||
source "amazon-ebs" "lotus-mainnet" {
|
||||
ami_name = "lotus-mainnet-${local.timestamp}"
|
||||
ami_regions = [
|
||||
"us-east-1",
|
||||
"us-west-2",
|
||||
]
|
||||
ami_description = "Lotus Filecoin AMI"
|
||||
|
||||
instance_type = "t2.micro"
|
||||
source_ami_filter {
|
||||
filters = {
|
||||
name = "ubuntu-minimal/images/*ubuntu-focal-20.04-amd64-minimal*"
|
||||
root-device-type = "ebs"
|
||||
virtualization-type = "hvm"
|
||||
}
|
||||
most_recent = true
|
||||
owners = ["099720109477"]
|
||||
}
|
||||
ssh_username = "ubuntu"
|
||||
}
|
||||
|
||||
source "digitalocean" "lotus-mainnet" {
|
||||
droplet_name = "lotus-mainnet"
|
||||
size = "s-1vcpu-1gb"
|
||||
region = "nyc3"
|
||||
image = "ubuntu-20-04-x64"
|
||||
snapshot_name = "lotus-mainnet-${local.timestamp}"
|
||||
ssh_username = "root"
|
||||
}
|
||||
|
||||
build {
|
||||
sources = [
|
||||
"source.amazon-ebs.lotus-mainnet",
|
||||
"source.digitalocean.lotus-mainnet",
|
||||
]
|
||||
|
||||
# Lotus software (from CI workspace)
|
||||
provisioner "file" {
|
||||
source = "./linux/lotus"
|
||||
destination = "lotus"
|
||||
}
|
||||
provisioner "file" {
|
||||
source = "./linux/lotus-miner"
|
||||
destination = "lotus-miner"
|
||||
}
|
||||
# First run script
|
||||
provisioner "file" {
|
||||
source = "./tools/packer/scripts/lotus-init.sh"
|
||||
destination = "lotus-init.sh"
|
||||
}
|
||||
# Systemd service units.
|
||||
provisioner "file" {
|
||||
source = "./tools/packer/systemd/lotus-daemon.service"
|
||||
destination = "lotus-daemon.service"
|
||||
}
|
||||
provisioner "file" {
|
||||
source = "./tools/packer/systemd/lotus-miner.service"
|
||||
destination = "lotus-miner.service"
|
||||
}
|
||||
provisioner "file" {
|
||||
source = "./tools/packer/systemd/lotus-init.service"
|
||||
destination = "lotus-init.service"
|
||||
}
|
||||
provisioner "file" {
|
||||
source = "./tools/packer/LOTUS.txt"
|
||||
destination = "LOTUS.txt"
|
||||
}
|
||||
provisioner "file" {
|
||||
source = "./tools/packer/bashrc"
|
||||
destination = ".bashrc"
|
||||
}
|
||||
# build it.
|
||||
provisioner "shell" {
|
||||
script = "./tools/packer/setup.sh"
|
||||
}
|
||||
|
||||
}
|
18
tools/packer/scripts/lotus-init.sh
Executable file
18
tools/packer/scripts/lotus-init.sh
Executable file
@ -0,0 +1,18 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# This script sets up an initial configuraiton for the lotus daemon and miner
|
||||
# It will only run once.
|
||||
|
||||
GATE="$LOTUS_PATH"/date_initialized
|
||||
|
||||
# Don't init if already initialized.
|
||||
if [ -f "GATE" ]; then
|
||||
echo lotus already initialized.
|
||||
exit 0
|
||||
fi
|
||||
|
||||
echo importing minimal snapshot
|
||||
lotus daemon --import-snapshot https://fil-chain-snapshots-fallback.s3.amazonaws.com/mainnet/minimal_finality_stateroots_latest.car --halt-after-import
|
||||
|
||||
# Block future inits
|
||||
date > "$GATE"
|
49
tools/packer/setup.sh
Normal file
49
tools/packer/setup.sh
Normal file
@ -0,0 +1,49 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# This script is executed by packer to setup the image.
|
||||
# When this script is run, packer will have already copied binaries into the home directory of
|
||||
# whichever user it has access too. This script is executed from within the home directory of that
|
||||
# user. Bear in mind that different cloud providers, and different images on the same cloud
|
||||
# provider will have a different initial user account.
|
||||
|
||||
set -x
|
||||
|
||||
# Become root, if we aren't already.
|
||||
# Docker images will already be root. AMIs will have an SSH user account.
|
||||
UID=$(id -u)
|
||||
if [ x$UID != x0 ]
|
||||
then
|
||||
printf -v cmd_str '%q ' "$0" "$@"
|
||||
exec sudo su -c "$cmd_str"
|
||||
fi
|
||||
|
||||
MANAGED_BINS=( lotus lotus-miner lotus-init.sh )
|
||||
MANAGED_SYSTEMD=( lotus-daemon.service lotus-miner.service lotus-init.service )
|
||||
|
||||
# install libs.
|
||||
apt update
|
||||
apt -y install libhwloc15 ocl-icd-libopencl1
|
||||
ln -s /usr/lib/x86_64-linux-gnu/libhwloc.so.15 /usr/lib/x86_64-linux-gnu/libhwloc.so.5
|
||||
|
||||
# Create lotus user
|
||||
useradd -c "lotus system account" -r fc
|
||||
install -o fc -g fc -d /var/lib/lotus
|
||||
install -o fc -g fc -d /var/lib/lotus-miner
|
||||
|
||||
# Install software
|
||||
for i in "${MANAGED_BINS[@]}"
|
||||
do
|
||||
install -o root -g root -m 755 -t /usr/local/bin $i
|
||||
rm $i
|
||||
done
|
||||
|
||||
# Install systemd units
|
||||
for i in "${MANAGED_SYSTEMD[@]}"
|
||||
do
|
||||
install -o root -g root -m 644 -t /lib/systemd/system $i
|
||||
rm $i
|
||||
done
|
||||
|
||||
# Enable services
|
||||
systemctl daemon-reload
|
||||
systemctl enable lotus-daemon
|
16
tools/packer/systemd/lotus-daemon.service
Normal file
16
tools/packer/systemd/lotus-daemon.service
Normal file
@ -0,0 +1,16 @@
|
||||
[Unit]
|
||||
Description=Lotus Daemon
|
||||
After=network.target
|
||||
After=lotus-init.service
|
||||
Wants=lotus-init.service
|
||||
|
||||
[Service]
|
||||
User=fc
|
||||
Group=fc
|
||||
ExecStart=/usr/local/bin/lotus daemon
|
||||
Environment=LOTUS_PATH=/var/lib/lotus
|
||||
Restart=always
|
||||
RestartSec=30
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
13
tools/packer/systemd/lotus-init.service
Normal file
13
tools/packer/systemd/lotus-init.service
Normal file
@ -0,0 +1,13 @@
|
||||
[Unit]
|
||||
Type=oneshot
|
||||
Description=Sync Lotus chain for the first time
|
||||
|
||||
[Service]
|
||||
User=fc
|
||||
Group=fc
|
||||
ExecStart=/usr/local/bin/lotus-init.sh
|
||||
Environment=LOTUS_PATH=/var/lib/lotus
|
||||
RemainAfterExit=yes
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
15
tools/packer/systemd/lotus-miner.service
Normal file
15
tools/packer/systemd/lotus-miner.service
Normal file
@ -0,0 +1,15 @@
|
||||
[Unit]
|
||||
Description=Lotus Miner
|
||||
After=network.target
|
||||
|
||||
[Service]
|
||||
User=fc
|
||||
Group=fc
|
||||
ExecStart=/usr/local/bin/lotus-miner run
|
||||
Environment=LOTUS_PATH=/var/lib/lotus
|
||||
Environment=LOTUS_MINER_PATH=/var/lib/lotus-miner
|
||||
Restart=always
|
||||
RestartSec=30
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
Loading…
Reference in New Issue
Block a user