factoid-docker-config
3.2K
This guide is intended for developers and system administrators who need to deploy or maintain Biofactoid using Docker on DigitalOcean.
Using Docker Compose, multiple containers are coordinated that provide:
The installation will also update the instance crontab to periodically check if the HTTPS certificates need renewal and if so, renew them.
Each branch of this repository (e.g. production, beta) has its own configuration, which is used to deploy the application to a remote host. Configuration is accomplished largely through environment variables, which are set in the respective .env files, e.g. for the beta branch:
# webapp
BASE_URL=https://beta.biofactoid.org
FACTOID_IMAGE_TAG=production
EMAIL_ENABLED=true
A set of workflows for GitHub Actions have been created to formalize aspects of creating a host, configuring the host and installing the application. Several of the workflows for creating a host and adding a domain are tailored specifically for Digital Ocean: A Digital Ocean Team named biofactoid has been created and you should be added as a member. These workflows represent an explicit description of 'how-to' and so we refer the reader to them for precise details.
factoid-docker-configSSH_PRIVATE_KEY.env file for NGINX_HOST and BASE_URL to include your registered domainNS1.DIGITALOCEAN.COM, NS2.DIGITALOCEAN.COM and NS3.DIGITALOCEAN.COM. DNS propagation may take several minutes to hours.DIGITALOCEAN_ACCESS_TOKEN is used by GitHub actions to access the APIfactoid-docker-configTo create an instance of Biofactoid, one of the following workflows should be performed (in order).
In this case, the following three items are already configured:
webapp209.38.0.162) that maps from beta.biofactoid.orgNavigate to the Actions tab:
droplet-do-workflow.yml)
biofactoid-production (or biofactoid-beta)webapp so the DO firewall appliesfactoid-docker-config should be added (see Requirements)configure-host-workflow.yml)
install-host-workflow.yml)
username and password are required to clone this remotebranch refers to this remote (e.g. beta or production). These will have different configurations (e.g. beta will back up to a separate Dropbox folder)cloud-firewall-do-workflow.yml)
webapp by defaultfloatingIP-do-workflow.yml)
domain-do-workflow.yml)
You can also uninstall:
uninstall-host-workflow.yml)Notes:
Unassign unless you intend on releasing the IP.The RethinkDB service db can be accessed via the dbbackup service, which contains the necessary libraries for dumping and restoring. The rethinkdb-backup system creates RethinkDB dumps with the naming convention rethinkdb_dump_<yyyy-MM-dd_HH-mm-ss-SSS>.tar.gz.
To restore an archive named rethinkdb_dump_<yyyy-MM-dd_HH-mm-ss-SSS>.tar.gz:
Copy the archive to a Droplet (e.g. /home/baderlab/rethinkdb_dump_<yyyy-MM-dd_HH-mm-ss-SSS>.tar.gz)
Copy the archive in the Droplet to the dbbackup container:
docker cp /home/baderlab/rethinkdb_dump_<yyyy-MM-dd_HH-mm-ss-SSS>.tar.gz dbbackup:/home/appuser/app
db from within the dbbackup container:docker-compose exec dbbackup /bin/bash
rethinkdb restore --connect db:28015 --import factoid --force /home/appuser/app/rethinkdb_dump_<yyyy-MM-dd_HH-mm-ss-SSS>.tar.gz
--force: import (and overwrite) data even if a table already existsUse SSH tunneling to connect to the remote database.
Start port forwarding to localhost:8080 for remote <username>@<host> with container name db:
ssh -fNTL localhost:8080:$(ssh <username>@<host> "docker inspect -f '{{range.NetworkSettings.Networks}}{{.IPAddress}}{{end}}' db"):8080 <username>@<host>
Stop port forwarding
kill $(lsof -t -i @localhost:8080 -sTCP:listen)
Using the workflow configure-host-workflow.yml, a non-root, non-sudo user (e.g. baderlab) is created for which password access is disabled. To enable SSH public key authentication, obtain your public key (usually in ~/.ssh/id_rsa.pub) then:
Login as root to the instance machine and then login as the non-root user:
sudo su - <username>
Create the required directory/files if they do not already exist:
mkdir ~/.ssh/
chmod 700 ~/.ssh
touch ~/.ssh/authorized_keys
chmod 600 ~/.ssh/authorized_keys
Paste in your public key to .ssh/authorized_keys, then logout. You should be able to login directly to the non-root account.
conf/)nginx/)templates/: As of Nginx 1.19, you can use environment variables to populate a configuration template (/etc/nginx/templates/*.template).dhparam/
openssl dhparam -out ./conf/nginx/dhparam/dhparam-2048.pem 2048
rclone/)The sync service image is rclone. This service can access any dumps created by dbbackup. The sync service runs an HTTP service which can be used to remote control rclone using its API. For example, it can be instructed to copy/sync files to a configured remote (see rclone.conf below)
rclone.conf: The remote configuration (i.e. Dropbox) telling rclone which service to use for storage (e.g. Dropbox)The rclone container is configured to use a Dropbox App, which can be manipulated via their API. However, authorization is provided by ephemeral access_tokens so they need to be retrieved via the API using a long lived refresh_token.
client_id)client_secret)access_tokenHTTP POST https://api.dropboxapi.com/oauth2/token
Content-Type: application/x-www-form-urlencoded
Authorization: Basic <Paste your Base64 encoded "App ID:App Secret" here>
grant_type=refresh_token
refresh_token=<Paste your Refresh token here>
You'll get a HTTP 200 response with "access_token" in the JSON response which you'll use below.
POST https://api.dropboxapi.com/2/files/create_folder_v2
Content-Type: application/json
Authorization: Bearer <Paste your "access_token" here>
{
"path": "/full/path/to/create",
"autorename": false
}
On success, you should expect a status 200 with some JSON metadata
scripts/)cron.sh: Installs cron jobs on host (i.e. every 12 hours)
ssl_renew.sh which checks and possibly renews the Let's Encrypt HTTPS certificates via Certbotconfig.sh: Utility for configuring Docker / Compose and environmentContent type
Image
Digest
sha256:203775ae9…
Size
2 MB
Last updated
12 months ago
docker pull pathwaycommons/factoid-docker-config:mainPulls:
201
Last week