Skip to content

Instantly share code, notes, and snippets.

@stom66
Created June 2, 2023 14:41
Show Gist options
  • Select an option

  • Save stom66/07f24cd1be81a32d91e239dee1287bec to your computer and use it in GitHub Desktop.

Select an option

Save stom66/07f24cd1be81a32d91e239dee1287bec to your computer and use it in GitHub Desktop.
Running DCL on AWS LightSail

Ubuntu-dcl-test

Create the basic Lightsail instance

  • Create Lightsail instance with ubuntu 22
  • Let instance boot up
  • Go to Manage Instance - Networking, and add ports 443 and 10000 to firewall rules
  • Copy the IP for the Instance

(Optional) Configure a domain name for the test instance

You can also have a domain name which point to the instance so users can acess it via a URL rather than an IP address.

  • Go to your domain registras admin panel for DNS settings
  • Create two A NAME records for dcl-test.domain.tld, and *.dcl-test.domain.tld which point to the Lightsail Instance IP
  • Set these up now so that DNS has time to propagate before we request SSL certificates later

Declare some params:

Update the following with your own details and run them in your terminal so we can reference the values later:

declare DOMAIN="dcl-test.domain.tld"
declare SUDO_USER_PASSWORD="AReallySuperSecretPasswordForTheAdminPanel"

Install dependencies

Run following in terminal to setup system setup:

# Update packages
sudo apt update -y
sudo apt install -y git tmux npm

# Set sudo user passwd
echo "ubuntu:${SUDO_USER_PASSWORD}" | sudo chpasswd

# Preserve hostname on AWS instances
hostnamectl set-hostname --static "${DOMAIN}"
echo "preserve_hostname: true" | sudo tee -a "/etc/cloud/cloud.cfg" > /dev/null
systemctl restart NetworkManager

# Get virtualmin and run installer
wget https://software.virtualmin.com/gpl/scripts/virtualmin-install.sh
sudo sh virtualmin-install.sh --minimal --hostname "${DOMAIN}" --force

# Set some Virtualmin options
sudo virtualmin set-global-feature --default-off virtualmin-awstats
sudo virtualmin disable-feature --mysql --all-domains
sudo virtualmin disable-feature --mail --all-domains
sudo systemctl disable mariadb
sudo systemctl disable postfix
sudo systemctl disable dovecot

Create the domain website and user account

Run the following in terminal:

# Create the website for the domain with a random admin password
webmin_password=$(date +%s|sha256sum|sha256sum|base64|head -c 32)
sudo virtualmin create-domain --domain "${DOMAIN}" --pass "${webmin_password}" --default-features

Configure the SSL certificate

Run the following in a termainl. It must be run with sudo, so must be run under the sudo account, eg ubuntu

This may not work if DNS changes haven't propagated yet, so if it fails due to lack of DNS records try again later.

sudo virtualmin generate-letsencrypt-cert --domain "${DOMAIN}"
sudo virtualmin install-service-cert --domain "${DOMAIN}" --service webmin

Generate SSH keys for the website user

Next, we switch over to the newly created user account.

  • Note: you will need to update the username.

Your username is the first part of your domain, eg dcl-test

sudo su dcl-test
cd ~
ssh-keygen -t ed25519 -f ~/.ssh/id_ed25519 -C "[email protected]"
eval "$(ssh-agent -s)"
ssh-add ~/.ssh/id_ed25519

Copy the SSH public key to GitHub

  • We need to copy the public key here to your GitHub authorised keys so that the user account has permission to clone repositories.
  • Run the following to print out the public key of the newly generated keypair:
tail  ~/.ssh/id_ed25519.pub
  • Go to GitHub -> Settings -> Access -> SSH and GPG Keys -> Add SSH Key
  • Enter the public key and save

Install NodeJS via NVM, and DCL packages

Run the following in terminal:

# Fetch and install NVM
curl https://raw.githubusercontent.com/creationix/nvm/master/install.sh | bash

# Reload bashrc
exec bash

# Install NodeJS v18
nvm install 18
nvm use 18

# Install DCL for user
npm install -g decentraland

Configure the reverse proxy

This redirects requests to the website to the DCL instance when it's running. This is easiest to do via the Virtualmin admin panel.

  • The Virtualmin Admin panel is located at: https://domain.tld:10000
  • Log in to the admin panel and run the first time setup: We don't need a database, mail capabilities, spam or AV.
  • Go to Virtualmin -> Domain -> Services -> Configure Website -> Edit Directives -> Append the following to the bottom of the file:
# Proxy configuration
ProxyPreserveHost On
ProxyPass / http://127.0.0.1:8008/
ProxyPassReverse / http://127.0.0.1:8008/
ProxyPassReverseCookieDomain DOMAINNAME.COM localhost

# WebSocket support
RewriteCond %{HTTP:Upgrade} =websocket [NC]
RewriteRule /(.*) ws://127.0.0.1:8008/$1 [P,L]
RewriteCond %{HTTP:Upgrade} !=websocket [NC]
RewriteRule /(.*) http://127.0.0.1:8008/$1 [P,L]
  • Save and close the file
  • Click "Apply Changes" at the top right to restart Apache and reload the directives

Clone and launch the DCL Scene

  • Go back to the terminal

  • Ensure you're logged in as the website user, eg dcl-test

  • Run the following in the terminal:

# Clone the repository
git clone [email protected]:stom66/dcl-vroomway-solosprint-2.git

# CD to the repo dir
cd dcl-vroomway-solosprint-2/dcl-scene

# Launch the instance and attach it to a tmux screen:
tmux new-session -d -s dcl "dcl start --port 8008 --no-debug --no-browser --no-watch"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment