From 7f89f3e8dc89aac8bb3e8aec6664abd97096b418 Mon Sep 17 00:00:00 2001 From: Aaron Hardy Date: Thu, 16 Nov 2023 13:54:26 -0700 Subject: [PATCH] Dev docker compose setup --- .gitignore | 1 + README.md | 45 ++++++++++++++++++++--------------- conf/staging.tabroom.com.conf | 2 ++ docker-compose.dev.yml | 27 +++++++++++++++++++++ 4 files changed, 56 insertions(+), 19 deletions(-) create mode 100644 .gitignore create mode 100644 docker-compose.dev.yml diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..4c49bd7 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +.env diff --git a/README.md b/README.md index cef656d..e00cfa5 100644 --- a/README.md +++ b/README.md @@ -8,30 +8,37 @@ does not include the Tabroom code itself, just the packages required to run it. That way a new code checkin to Tabroom's own code (which happens frequently) does not kick off a (slow, expensive) build of the Docker image each time. -Specific configuration files that change depending on the run location, -General.pm configuration file and Apache configuration files, are not included +General.pm configuration file and production Apache configuration files are not included in this image and instead run from ansible for production. PREREQUISITES TO RUN A STAGING INSTANCE: 1. A copy of the Tabroom.com web code downloaded to /www/tabroom (or another - location as long as you change where docker looks for it in - docker-compose.yml). - -2. Configurations for the docker apache in /etc/tabroom. Default versions of - files you need are in the conf/ directory of this repo. They will enable - a smaller footprint apache configuration suitable for local use, and will - enable NYT Devel performance profiling that will appear in /www/profiles. - -3. A General.pm configuration file in /etc/tabroom. The default skeleton of - this file is in /www/tabroom/web/lib/Tab/General.pm.default. You will need - at minimum to supply a hostname that resolves on your laptop and the + location as long as you set the appropriate .env variables used in + docker-compose.yml). Unless you change the .env variables, you also need to create + ./web/tmp and ./web/mason directories in your local copy of the repo and chmod + them to 777 + +2. Build the local sources.js by installing JavaScript::Minifier: + `sudo apt install libjavascript-minifier-perl` + Then run the build.pl script in the tabroom repo at + /www/tabroom/web/lib/javascript/build.pl + +3. If necessary, change default versions of conf files in the conf/ directory + of this repo. By default, they will enable a smaller footprint apache configuration + suitable for local use, and will enable NYT Devel performance profiling that will + appear in /www/profiles. + +4. A General.pm configuration file in /etc/tabroom or at the location specified in a + .env file. The default skeleton of this file is in + /www/tabroom/web/lib/Tab/General.pm.default. + You will need at minimum to supply a hostname that resolves on your laptop, the location of a MariaDB/MySQL database and credentials with the Tabroom - schema. - -4. (Optional) The staging container will log to your local machine using - syslog on port 514 TCP, so you should set it to receive those logs if you - want to be able to see them. - + schema, and set the data_dir to the location of the mason cache. +5. You can set environment variables in a .env file in the root of the repo to override + variables specified in the docker-compose file. +6. (Optional) The staging container will log to your local machine using + syslog on port 514 TCP, so you should set it to receive those logs if you + want to be able to see them. Otherwise you may need to disable the syslog stanzas in General.pm diff --git a/conf/staging.tabroom.com.conf b/conf/staging.tabroom.com.conf index 61b3e6e..751ed30 100644 --- a/conf/staging.tabroom.com.conf +++ b/conf/staging.tabroom.com.conf @@ -1,6 +1,8 @@ ServerName old.staging.tabroom.com ServerAlias old.staging staging-old + ServerAlias staging.tabroom.com + ServerAlias local.tabroom.com ServerAdmin webmaster@staging.tabroom.com DocumentRoot /www/tabroom/web diff --git a/docker-compose.dev.yml b/docker-compose.dev.yml new file mode 100644 index 0000000..83e7f08 --- /dev/null +++ b/docker-compose.dev.yml @@ -0,0 +1,27 @@ +version: '3' +services: + tabroom: + container_name: mason + build: + context: . + dockerfile: Dockerfile + image: mason:latest + restart: always + ports: + - 9000:80 + env_file: .env + volumes: + - ${TABROOM_WEB:-/www/tabroom/web}:/www/tabroom/web:rw + - ${TABROOM_WEB_MASON:-/www/tabroom/web/mason}:/www/tabroom/web/mason:rw + - ${TABROOM_WEB_TMP:-/www/tabroom/web/tmp}:/www/tabroom/web/tmp:rw + - ${TABROOM_PROFILES:-/www/profiles}:/www/profiles:rw + - ${TABROOM_LOGS:-/var/log/apache2}:/var/log/apache2:rw + - ${TABROOM_GENERAL:-/etc/tabroom/General.pm}:/www/tabroom/web/lib/Tab/General.pm:ro + - ./conf/staging.tabroom.com.conf:/etc/apache2/sites-enabled/staging.tabroom.com.conf:ro + - ./conf/envvars:/etc/apache2/envvars:ro + - ./conf/apache2.conf:/etc/apache2/apache2.conf:ro + - ./conf/perl.conf:/etc/apache2/mods-enabled/perl.conf:ro + - ./conf/mpm_prefork.conf:/etc/apache2/mods-enabled/mpm_prefork.conf:ro + extra_hosts: + - "host.docker.internal:host-gateway" + - "staging-api.tabroom.com:host-gateway"