These instructions will help you setup a Farcaster hub either on testnet or mainnet. They are based on these instructions from Merkle
NOTE: This hub uses the suggested EC2 resource allocation. It will cost ~$100/month!
Each step has a Makefile-based version (simpler) or the equivalent manual commands
- Install docker and start the Docker daemon (by opening Docker Desktop)
- Install Terraform
- Make sure you have the AWS CLI installed on your machine. You can check by running
aws --version
. Make sure you have a profile setup by runningaws configure
- Clone this repo:
git clone https://github.com/bitwise-invest/farcaster-hub.git
and enter the foldercd farcaster-hub
make docker_build_and_run_local
If you want, you can execute these manually
export ALCHEMY_GOERLI_URL={INSERT_ALCHEMY_URL}
export AWS_ACCOUNT_ID={INSERT_AWS_ACCOUNT_ID}
export AWS_REGION={INSERT_REGION} // Example region is "us-west-1"
If you want to run testnet:
export HUBBLE_PEERS=/dns/testnet1.farcaster.xyz/tcp/2282
export HUBBLE_NETWORK=2
or mainnet:
export HUBBLE_PEERS=/dns/nemes.farcaster.xyz/tcp/2282
export HUBBLE_NETWORK=1
NOTE: To move to mainnet, you'll want to run through these instructions for testnet first and make sure you're syncing. Read this before trying mainnet: https://warpcast.notion.site/warpcast/Mainnet-Hubs-dc2ff6d528f64992afe03797b61dec32
make login && make create_repo
If you want, you can execute these manually
make docker_build_and_push
If you want, you can execute these manually
-
In
variables.tf
, set the "key_name" to yourkey_name.pem
file (or create a new one)
terraform init
- Plan: dry-run that will show you what AWS changes will be made
terraform plan
- Apply: actually makes the AWS changes
terraform apply
To destroy:
terraform destroy
That's it! After a few minutes, you should have a hub running on an EC2 instance in AWS. You can see the logs by:
- SSH into the instance. You can do this using your pem file by running
ssh ubuntu@{IP_ADDRESS_OF_INSTANCE} -i /path/to/key/file.pem
or clicking "Connect" on the EC2 console - Wait a few minutes for the process to start and then list docker containers. You'll have to use the root user because docker was installed as root:
sudo docker ps
- Enter container:
sudo docker exec -it {DOCKER_CONTAINER_ID} /bin/bash
- List running pm2 processes:
pm2 ls
- Show logs:
pm2 logs
You can check that everything is working by running the script in Step 2 of the Running a Testhub docs.
- Build docker images:
docker build . -t hubble
- Run docker image:
docker run -p 2282:2282 -p 2283:2283 -d hubble
- Debugging
- List containers (with container id) -
docker ps
- Show logs -
docker logs [container id]
- List containers (with container id) -
- To enter the machine:
docker exec -it [container id] /bin/bash
- If you need to exit, command is
cmd+z
I believe
- If you need to exit, command is
- Kill docker image:
docker kill [container id]
docker build --build-arg ALCHEMY_GOERLI_URL=$ALCHEMY_GOERLI_URL --build-arg HUBBLE_PEERS=$HUBBLE_PEERS -t hubble .
docker run -p 2282:2282 -p 2283:2283 -d hubble
- Authenticate
aws --profile personal ecr get-login-password --region us-east-1 | docker login --username AWS --password-stdin $$AWS_ACCOUNT_ID.dkr.ecr.us-east-1.amazonaws.com
- Create ECR repository
aws --profile personal ecr create-repository --repository-name hubble --image-scanning-configuration scanOnPush=true
- Authenticate
aws --profile personal ecr get-login-password --region us-east-1 | docker login --username AWS --password-stdin $AWS_ACCOUNT_ID.dkr.ecr.us-east-1.amazonaws.com
- Build
docker build --platform linux/amd64 --build-arg ALCHEMY_GOERLI_URL=$ALCHEMY_GOERLI_URL -t hubble .
- Tag
docker tag hubble $AWS_ACCOUNT_ID.dkr.ecr.us-east-1.amazonaws.com/hubble:latest
- Push
docker push $AWS_ACCOUNT_ID.dkr.ecr.us-east-1.amazonaws.com/hubble:latest