# SPRPCB desde Arches Project y OpenContext SPRPCB es un desarrollo de [ArchesProject](https://www.archesproject.org/) y para este proyecto, se emplea el modelo de implementación de [OpenContext](https://github.com/opencontext/arches-via-docker) # Implementación en servidor web público Arches versión 7.6.x ### 1. Prerrequisitos * Tener un nombre de dominio. * Servidor con una dirección IP pública. * Apuntar el dominio al servidor con un registro tipo A * Docker y Docker Compose están instalados. * Clonar el repositorio: ```bash git clone -b prod-7_6_x https://gitea.patrimonio.org.bo/sysadmin/sprpcb.git avd-prod ``` ### 2. Preparar la configuración para la instalación inicial ```shell # crear volúmenes de docker para el manejo de certificados SSL/TLS docker volume create --name=logs_nginx docker volume create --name=nginx_ssl docker volume create --name=certbot_certs docker volume create --name=arches_certbot # Configuración de docker cd ./avd-prod cp edit_dot_env .env # Personalizar el archivo .env vi .env ``` # Nginx y Let’s Encrypt con Docker Compose Este enfoque obtiene y renueva automáticamente los certificados TLS [Let's Encrypt](https://letsencrypt.org/) y configura el acceso HTTPS en Nginx para su dominio. Hay 3 contenedores que trabajan para ello utilizando docker compose: * Nginx, genera certificados autofirmados "dummy" para obtener los certificados de Let's Encrypt * Certbot - obtiene y renueva los certificados, espera hasta que Nginx esté listo para obtener los certificados * Cron - cada día renueva los certificados, si verifica que están vencidos, arranca Cerbot para renovarlos, luego reinicia Nginx Para personalizar el manejo de certificados debe cambiar estos parámetros en el archivo `.env`: ```properties DOMAINS=patrimonio.org.bo CERTBOT_EMAILS=admin@patrimonio.org.bo info@patrimonio.org.bo CERTBOT_TEST_CERT=0 CERTBOT_RSA_KEY_SIZE=4096 ``` Configuration parameters: * `DOMAINS` - a space separated list of domains to manage certificates for * `CERTBOT_EMAILS` - a space separated list of email for corresponding domains. If not specified, certificates will be obtained with `--register-unsafely-without-email` * `CERTBOT_TEST_CERT` - use Let's Encrypt staging server (`--test-cert`) 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](https://docs.docker.com/engine/install/) and [Docker Compose](https://docs.docker.com/compose/install/) 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 ```bash git clone https://github.com/opencontext/arches-via-docker.git ``` ### Note: This approach will setup the most current stable version of Arches (now v7.6.x). If you want to deploy Arches version 6 (specifically stable version 6.2), please switch to the `v6` branch of this repo, with: ```bash 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 ```bash cp edit_dot_env .env ``` Now edit `.env` file to change your settings. ```bash 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..). ```properties DOMAINS=teach-with-arches.org CERTBOT_EMAILS=info@teach-with-arches.org ``` ### Note: Non-Standard Port (8004, not 8000) 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/](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. ```properties DJANGO_MODE=DEV DJANGO_DEBUG=False ... BUILD_PRODUCTION=False ``` ## Step 2 - Create named Docker volumes for dummy and Let's Encrypt TLS certificates ```bash docker volume create --name=logs_nginx docker volume create --name=nginx_ssl docker volume create --name=certbot_certs docker volume create --name=arches_certbot ``` ## Usar certificados Let's Encrypt válidos Para producción, configure el archvo .env : ```properties CERTBOT_TEST_CERT=0 ``` ## Construir imágenes y arrancar contenedores ```bash docker compose up --build ``` Detener (Stop) los contenedores: ```bash docker compose down ``` ## Cómo crear comandos de administración de Arches Además de configurar HTTPS y Nginx, este repositorio implementa una instancia de Arches. Al inicio, se configura una instancia de Arches "vacía". Se deberá cargar con datos propios mediante la instalación de un paquete o algún otro método. Una vez implementada Arches, puedes usar los comandos de administración habituales de Arches desde el servidor. Por ejemplo: ```bash docker exec -it arches python manage.py makemigrations docker exec -it arches python manage.py migrate ```