Central-Asian-Archaeological-Landscapes / arches-via-docker

Deployment of Arches (archesproject.org) via Docker for archaeology and related instruction
GNU Affero General Public License v3.0
0 stars 0 forks source link

arches-via-docker

Deployment of Arches (archesproject.org) via Docker. We initially developed this repo to simplify and streamline deployment of Arches for use in archaeology and related instruction.

Public Web Server and Localhost Deployments

This main goal of this repo is to offer a simple, turnkey approach to deploying HTTPS secured Arches on the Web. You can also use this to deploy the current stable version of Arches for use on a localhost by leaving Arches with the Django DEBUG setting as True. See below for instructions on creating and editing an .env file.

If you're interested in deploying Arches to a localhost (not the public Web), switch to the local code branch. That will deploy a limited subset of Docker containers needed to run Arches on a localhost in DEBUG mode. To switch to the local branch:

   git checkout origin/local

If you're interested in testing a localhost (only) deployment of Arches for Science (AfS), switch to the local-dev-1-1-x code branch. That will deploy a limited subset of Docker containers needed to run AfS on a localhost in DEBUG mode:

   git checkout origin/local-afs-dev-1-1-x

Nginx and Let’s Encrypt with Docker Compose in less than 3 minutes

This approach automatically obtains and renews Let's Encrypt TLS certificates and set up HTTPS in Nginx for your domain name using Docker Compose.

You can set up HTTPS in Nginx with Let's Encrypt TLS certificates for your domain name and get A+ rating at SSL Labs SSL Server Test by changing a few configuration parameters of this example.

Let's Encrypt is a certificate authority that provides free X.509 certificates for TLS encryption. The certificates are valid for 90 days and can be renewed. Both initial creation and renewal can be automated using Certbot.

The approach currently only supports one domain name, as discussed in this example:

The idea is simple. There are 3 containers:

The sequence of actions:

The directories and files

The following lists some information about the contents of this repo and how they fit together:

To adapt the example to your domain names you need to change only .env:

DOMAINS=teach-with-arches.org
CERTBOT_EMAILS=info@teach-with-arches.org info@teach2.with.arches.org
CERTBOT_TEST_CERT=0
CERTBOT_RSA_KEY_SIZE=4096

Configuration parameters:

Let's Encrypt has rate limits. So, while testing it's better to use staging server by setting CERTBOT_TEST_CERT=1 (default value). When you are ready to use production Let's Encrypt server, set CERTBOT_TEST_CERT=0.

Prerequisites

  1. Docker and Docker Compose are installed.
  2. You have a domain name
  3. You have a server with a publicly routable IP address
  4. You have cloned this repository
    git clone https://github.com/opencontext/arches-via-docker.git

Note:

This approach will setup the most current stable version of Arches (now v7.5.0). If you want to deploy Arches version 6 (specifically stable version 6.2.6), please switch to the v6 branch of this repo, with:

   git checkout origin/v6

Step 0 - Point your domain to server with DNS A records

For all domain names configure DNS A records to point to a server where Docker containers will be running.

Step 1 - Edit domain names, emails and other variables in the configuration

Specify you domain names and contact emails for these domains in the edit_dot_env file and then save this file as .env:

First make an .env file

cp edit_dot_env .env

Now edit .env file to change your settings.

nano .env

Here are properties to change based on your specific Web domain. Please note, for now this only supports one domain specified by the DOMAINS variable (the plural is asperational..).

DOMAINS=teach-with-arches.org
CERTBOT_EMAILS=info@teach-with-arches.org

Below are properties to edit to change how Arches deploy. If you want to deploy this on your own machine (localhost), setting DJANGO_DEBUG=True is useful to see and diagnose useful error messages in the Arches Django application, but be sure to set DJANGO_DEBUG=False for deployments on the public Web. NOTE if you run this on your localhost, this Docker build will currently make your Arches application available to your browser via http://127.0.0.1:8004/ on port 8004, not the usual 8000. This nonstandard port was chosen in case your local host has other applications already running on port 8000.

If you set BUILD_PRODUCTION=True, be sure you have well over 8GB of system RAM. BUILD_PRODUCTION=True will invoke the Arches manage.py build_production command, and this command is very resource intensive and time consuming. You will likely get errors that will cause your build to fail if you do a production build on a server with only 8GB of RAM.

DJANGO_MODE=DEV
DJANGO_DEBUG=False
...
BUILD_PRODUCTION=False

Step 2 - Create named Docker volumes for dummy and Let's Encrypt TLS certificates

docker volume create --name=logs_nginx
docker volume create --name=nginx_ssl
docker volume create --name=certbot_certs
docker volume create --name=arches_certbot

Step 3 - Use Valid Let's Encrypt Certificates

Configure to use production Let's Encrypt server in .env:

CERTBOT_TEST_CERT=0

Step 4 - Build images and start containers

docker compose up --build

Config Changes? - Replace volumes etc to implement changes

Stop the containers:

docker compose down

Re-create the volume for Let's Encrypt certificates:

docker volume rm certbot_certs
docker volume rm arches_certbot
docker volume create --name=certbot_certs
docker volume create --name=arches_certbot

Start the containers:

docker compose up

How to Make Arches (administrative) Management Commands

Besides setting up HTTPS and Nginx, this repo deploys an instance of Arches. Currently this will setup an "empty" Arches instance. You'll need to load it with your own data by loading a package or some other approach. Once you deploy Arches, you can use normal Arches management commands as so:

docker exec -it arches python3 manage.py [Arches management commands and arguments here]

NOTE

You may run into weirdness permissions issues restarting the docker container. I solved it with:

sudo chmod 666 /var/run/docker.sock

BACKGROUND AND CREDIT

This repo will hopefully streamline deployment of Arches for use on the Web. Eventually, we hope to use this as the basis for deploying instances of Arches for use in archaeological teaching and learning applications.

None of this code is very original. This repo started by forking: https://github.com/evgeniy-khist/letsencrypt-docker-compose

Some elements of this repo are also derived from: https://github.com/opencontext/oc-docker

and

https://github.com/archesproject/arches-for-science-prj

and

https://github.com/archesproject/arches-dependency-containers

and finally

https://github.com/archesproject/arches-her