Skip to content

Instantly share code, notes, and snippets.

@69
Last active November 21, 2019 18:31
Show Gist options
  • Save 69/a60838a5d67807da574edcfd3193af64 to your computer and use it in GitHub Desktop.
Save 69/a60838a5d67807da574edcfd3193af64 to your computer and use it in GitHub Desktop.
Setting up and configuring your portal image for deployment

Setting up your portal image

General instructions

  • Start with creating a server with the latest version of Debian (at the time of writing, this is Debian 10)
  • When you have your server running, update your repository data and install git, software-properties-common and nodejs:
    apt update && apt install git software-properties-common nodejs gnupg2 curl -y
  • Add the docker repo and install docker-ce. (instructions)
  • Add the yarn repo and install yarn. (instructions)
  • Create a limited user for setting up the Docker container and add it to the docker user group:
    adduser --gecos '' --disabled-password cryb && \
    usermod -aG docker cryb
  • Switch to the cryb user:
    su - cryb
  • Continue by cloning the @crybapp/portal repo:
    git clone https://github.com/crybapp/portal.git
  • Copy .env.example over to .env and set it up so the VM can communicate with your API and aperture servers
  • Run yarn and yarn docker:build in the portal folder
  • Once the build succeeds, create a start.sh shell script in your home directory and insert the following code inside it:
    SHM_SIZE="1gb"
    cd /home/cryb/portal && docker run --rm -i --net=bridge --shm-size="$SHM_SIZE" cryb/portal
  • Make the shell script executable:
    chmod +x ~/start.sh
  • Create a crontab entry using crontab -e and insert the following:
    @reboot /home/cryb/start.sh

Hetzner Cloud specific

  • Power off the VM and take an image of it.
  • Get your image/snapshot ID from the Hetzner Cloud console or via the API. You can do this via the Hetzner Cloud API or by going to the Network tab of your browser, editing your image in any way (adding a tag, protecting it, etc...) and checking the URL of the API request the website made.
  • Replace the image ID in portals/.env with your own image ID.

DigitalOcean specific

  • Power off the VM and take a snapshot of it.
  • Get your snapshot ID. You can do this via the the DigitalCloud API, or using the dashboard: once the snapshot is completed, click on the "More" dropdown menu and click "Create Droplet". Once the droplet creation page has loaded, you should be able to get the image ID from the &imageId= parameter from the URL in your browser's URL bar.
  • Make sure the region your snapshot is in is the same as the region you set in portals/.env. If it isn't, transfer the image to the specified region or change the region you set in portals/.env.
  • Replace the image ID in portals/.env with your own image ID.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment