- Docker
- AWS CLI
- Terraform (Only if you need to change the infra. Not necessary to deploy new versions in the instance)
You must configure access to the Nano-testnet account in AWS.
Run the following command:
aws configure ssoSet the following values when asked:
- SSO Session Name:
nano-testnet - SSO Start URL:
https://hathorlabs.awsapps.com/start - SSO Region:
us-east-1 - SSO Registration Scopes:
sso:account:access - In the accounts list, select
Nano-testnet - CLI default client region:
us-east-1 - CLI default output format:
None - CLI profile name:
nano-testnet
Login to the account using the following command:
aws sso login --profile nano-testnetaws ecr get-login-password --region ap-southeast-1 --profile nano-testnet | docker login --username AWS --password-stdin 471112952246.dkr.ecr.ap-southeast-1.amazonaws.com
docker build --platform linux/amd64 -t 471112952246.dkr.ecr.ap-southeast-1.amazonaws.com/bet-dapp:latest .
docker push 471112952246.dkr.ecr.ap-southeast-1.amazonaws.com/bet-dapp:latestaws ecr get-login-password --region ap-southeast-1 --profile nano-testnet | docker login --username AWS --password-stdin 471112952246.dkr.ecr.ap-southeast-1.amazonaws.com
docker build --platform linux/amd64 --build-arg ENVIRONMENT=staging --build-arg NEXT_PUBLIC_URL="https://staging.betting.hathor.network/" -t 471112952246.dkr.ecr.ap-southeast-1.amazonaws.com/bet-dapp:staging-latest .
docker push 471112952246.dkr.ecr.ap-southeast-1.amazonaws.com/bet-dapp:staging-latest# Get the instance IP from its name tag
aws ec2 describe-instances --profile nano-testnet --filters "Name=tag:Name,Values=bet-dapp" --query "Reservations[*].Instances[*].PublicIpAddress" --output text --region ap-southeast-1
ssh ec2-user@<instance-ip>To access the staging instance, just change the name tag to bet-dapp-staging.
aws ecr get-login-password --region ap-southeast-1 | sudo docker login --username AWS --password-stdin 471112952246.dkr.ecr.ap-southeast-1.amazonaws.comThe following should be run inside the EC2 instance
# Inside the home directory (/home/ec2-user)
sudo docker compose pullThe following should be run inside the EC2 instance
# Inside the home directory (/home/ec2-user)
# Running this will pick up any changes in the configuration and recreate the container
sudo docker compose up -dThe following should be run inside the EC2 instance
# Inside the home directory (/home/ec2-user)
sudo docker compose logs bet-dapp -fThe following should be run inside the EC2 instance
# Inside the home directory (/home/ec2-user)
sudo docker compose downThe following should be run inside the EC2 instance
# Inside the home directory (/home/ec2-user)
sudo docker compose up -dGo to https://hathorlabs.awsapps.com/start and login to the Nano-testnet account.
You can find the table at:
Click Explore table items to see the items in the table.
The infra is currently defined in https://github.com/HathorNetwork/ops-tools/tree/master/terraform/bet-dapp
Make sure to run make terraform-init to setup the Terraform environment.
The table is defined in the file terraform/bet-dapp/dynamodb.tf
Refer to the Terraform documentation for more information on how to define the table.
Apply the changes in staging by running:
make apply-stagingApply the changes in production by running:
make applyYou'll be prompted to review the changes before they are applied.
The instance is defined in the file terraform/bet-dapp/ec2.tf
Refer to the Terraform documentation on the following resources for more information on how to define the instance:
Apply the changes in staging by running:
make apply-stagingApply the changes in production by running:
make applyYou'll be prompted to review the changes before they are applied.
The provisioning script is defined in the file terraform/bet-dapp/scripts/provision-instance.yaml.tftpl
It's a cloud-init script that runs when the instance is created.
If changes are needed inside the instance, ideally they should be written in this script and the instance should be recreated by running make apply for production, or make apply-staging for staging.
This will generate a downtime in the service, so it should be done with caution. To avoid this, you could create a new instance first, test the changes and then switch the Elastic IP to the new instance. Or just make the changes in the running instance, if you're in a hurry, then update the script later.
The Elastic IP is defined in the file terraform/bet-dapp/ec2.tf
We had to add a rule in the Cloudfront distribution we use to serve hathor.network, in order to have the bet-dapp served under https://hathor.network/betting2024
To update this, you should:
- Login to the
Hathor-websiteaccount through https://hathorlabs.awsapps.com/start - Access the Cloudfront distribution at https://us-east-1.console.aws.amazon.com/cloudfront/v4/home?region=eu-central-1#/distributions/E2AT2JAIYAKNGG