Scoreboard docker setup
git clone [email protected]:digital-agenda-data/scoreboard.docker.git
If it's already saved, make sure it's on the latest version
cd scoreboard.docker
git pull
- Production:
cp .env.PROD .env - Test/Staging:
cp .env.TEST .env - Development:
cp .env.DEV .env
- DEPLOY_TYPE - should be set to TEST, PROD or DEV - will be used in NGINX, SOLR and CRONTAB configuration
- SCOREBOARDBASE_URL - the main domain name under which the site will be used:
- FOR PRODUCTION it is digital-agenda-data.eu
- For TEST it is test.digital-agenda-data.eu
- For DEV it is dev.digital-agenda-data.eu
- Note: to change these URLs, you must also edit nginx/project-${DEPLOY_TYPE} config files (nginx server_name and Plone VirtualHostBase)
- SPARQL_ENDPOINT - used by CR, is the way to access the SPARQL Virtuoso url both from the browser and the container.
- SCOREBOARD_URL - the main URL (the one that is accessed from the browser), used by Content Registry - example: https://digital-agenda-data.eu, or http://test.digital-agenda-data.eu or http://dev.digital-agenda-data.eu:81
If you are restoring the database from another environment, please copy here the same passwords that are saved in the database:
- VIRTUOSO_DBA_PASSWORD - dba user password
- CR_DB_PASSWORD - cr3user password
- CR_DB_RO_PASSWORD - cr3rouser password
- MARIADB_PASSWORD - Mariadb root password
- MARIADB_PIWIK_PASSWORD - Mariadb piwik user password - save it for the PIWIK configuration
- TZ - default Timezone for all containers - Europe/Copenhagen
- GEOIP_KEY - the license key for the geoip database, https://www.maxmind.com/en/geoip2-services-and-databases
You need to set the NGINX port to an available value in the docker-compose file. It is located in the nginx->ports section and has the format:
- <HOST_PORT>:<CONTAINER_PORT>
For example, if port 81 is not available, but 82 is, we modify this:
nginx:
image: nginx:1.13
depends_on:
- haproxy
- piwik
- solr
restart: always
ports:
- 81:80
into:
nginx:
image: nginx:1.13
depends_on:
- haproxy
- piwik
- solr
restart: always
ports:
- 82:80
links:
- nginx:${SCOREBOARDBASE_URL}
If you want to deploy another version on plone site ( DEV or TEST) you need to set the correct image name in the plone section of the docker-compose.yml:
So:
plone:
image: digitalagendadata/plone:latest
restart: always
depends_on:
- zeoserver
- memcached
environment:
ZEO_ADDRESS: "zeoserver:8080"
MEMCACHE_SERVER: "memcached:11211"
SOLR_URL: "http://solr:8983/solr/scoreboard"
will become
plone:
image: digitalagendadata/plone.staging
restart: always
depends_on:
- zeoserver
- memcached
environment:
ZEO_ADDRESS: "zeoserver:8080"
MEMCACHE_SERVER: "memcached:11211"
SOLR_URL: "http://solr:8983/solr/scoreboard"
- digital-agenda-data.eu should be pointing to the server you are installing the stack in DNS
- HTTPS and letsencrypt should be configured on the Apache that is installed on the same server
- The Apache should redirect to the port configured to the nginx in the docker-compose file
- test.digital-agenda-data.eu should be pointing to the server you are installing the stack in DNS
- HTTPS and letsencrypt should be configured on the Apache that is installed on the same server
- The Apache should redirect to the port configured to the nginx in the docker-compose file
- <SCOREBOARDBASE_URL> host should be pointing to the server you are installing the stack in /etc/hosts
- The configuration files from the repository are an example of a <SCOREBOARDBASE_URL> that is configured on a different port than 80
- If you are changing the default URLs from the .env.DEV file, you also need to updated them accordingly in the NGINX configuration file - nginx/project-DEV.conf
The exportcl.sh
script that updates the RDF repository runs daily on production. It needs to use a SSH private key that has write access to the GIT repo.
- Connect to the existing host using the scoreboard user
- Copy the ~/.ssh contents
- Move them to the cron/ssh directory
If you are using the same user/host, you need just to:
cd <SCOREBOARD.DOCKER_HOME>
cp ~/.ssh/* cron/ssh/
Run in <SCOREBOARD.DOCKER_HOME>:
-
Create a new key
ssh-keygen -t rsa -b 4096 -C "[email protected]" -N '' -f cron/ssh/id_rsa
-
Open the public key file an copy its contents:
cat cron/ssh/id_rsa.pub
-
Copy the file contents in: https://github.com/digital-agenda-data/rdf/settings/keys/new
-
Keep the existing
cron/ssh/known_hosts
file because it contains the github servers
docker-compose up -d --scale plone=2
docker-compose up -d
-
Identify zeo docker name - <ZEO_DOCKER_NAME>:
docker-compose ps | grep zeo
-
Copy blobstorage and filestorage directories from the source plone site and put it into the current directory
-
Copy blobstorage and filestorage directories to the zeoserver data volume:
docker cp blobstorage <ZEO_DOCKER_NAME>:/data/ docker cp filestorage <ZEO_DOCKER_NAME>:/data/
-
Run chown on the /data directory from the server to make sure all the files have the correct permissions docker-compose exec zeoserver sh -c "chown -R 500:500 /data"
-
Restart zeoserver
docker-compose restart zeoserver
-
Check zeoserver logs for errors
docker-compose logs -f zeoserver
-
Restart plone
docker-compose restart plone
-
Check plone logs for errors
docker-compose logs -f plone
-
Stop virtuoso server
docker-compose stop virtuoso
-
Identify virtuoso docker name - <VIRTUOSO_DOCKER_NAME> ( check first column on the following command) :
docker-compose ps | grep virtuoso
-
Copy database backup from source database and name it virtuoso.db
-
Identify volume location on the host - <VIRTUOSO_VOLUME_PATH>
docker inspect <VIRTUOSO_DOCKER_NAME> | grep volume
or
docker ps --filter expose=8890 --format "{{.Names}}" | xargs docker inspect | grep virtuoso_db
<VIRTUOSO_VOLUME_PATH> should be similar to /var/lib/docker/volumes/_virtuoso_db/_data
-
Clean-up the volume:
sudo rm -rf <VIRTUOSO_VOLUME_PATH>/*
-
Copy the database:
sudo cp virtuoso.db <VIRTUOSO_VOLUME_PATH>/
-
Start server
docker-compose start virtuoso
-
Check virtuoso logs for errors
docker-compose logs -f virtuoso
-
Run a backup on the source database. If you are not sure of the database password you can check it in the piwik directory: $ cd <PIWIK_LOCATION> $ grep password config/config.ini.php
-
Run the piwik database backup, providing the password: $ mysqldump -u piwik -p piwik > /tmp/piwik.dump
-
Copy the database dump to the destination host using scp
-
Identify the docker name of the mariadb container <MARIADB_DOCKER_NAME> ( run from the docker-compose.yml file location ) docker-compose ps | grep virtuoso
-
copy the database dump to the mariadb container
docker cp piwik.dump <MARIADB_DOCKER_NAME>:/tmp/piwik.dump -
Import the database, providing the password set in the .env file: $ docker-compose exec mariadb bash $ mysql -u piwik -p piwik < /tmp/piwik.dump Enter password: $ exit
-
Restart the container and watch the logs for errors $ docker-compose restart mariadb $ docker-compose logs -f mariadb
- Go to the init script location $ cd cr_init_scripts
- If you did not import the database, you need to run: $ ./init_conreg.sh
- If you imported the database so all the users are already created, you need to run:
$ ./init_conreg_db_restore.sh
- Go to <SCOREBOARD_URL>/analytics/piwik/index.php?action=databaseSetup
- Fill:
- Database Server -db
- Login - piwik
- Password - <MARIADB_PIWIK_PASSWORD>
- Database Name - piwik
- Table Prefix - piwik_
- Adapter - PDO\MYSQL
- Press Next
- You will receive the message:
Some tables in your database have the same names as the tables Matomo is trying to create
Press Reuse the existing tables » - You will receive - Reusing the Tables - Press Next
- Press CONTINUE TO MATOMO
- Remember to configure the tracking url in Plone (<SCOREBOARD_URL>/portal_skins/custom/analytics.js/manage_main)
- Plone - <SCOREBOARD_URL>
- Virtuoso faceted browser - always http://semantic.digital-agenda-data.eu/dataset (must be added in /etc/hosts for local development)
- Content Registry - <SCOREBOARD_URL>/data/
- Download - <SCOREBOARD_URL>/datasets/desi#download
- Sparql - <SCOREBOARD_URL>/sparql
- Piwik - <SCOREBOARD_URL>/analytics/index.php
Manually modify docker-compose.yml with the new image version.
For example:
plone:
image: digitalagendadata/plone:1.0
to
plone:
image: digitalagendadata/plone:2.0
If you are updating the PRODUCTION image version, you need to save the changes in GIT
Change environment variable value in the .env file.
Update the available configuration files. Any update on PRODUCTION and TEST environments for cron/, solr/, nginx/* should be saved in GIT.
If you only changed the configuration file, it's enough to run restart on the containers:
-
For cron/ changes:
docker-compose restart cron
-
For nginx/ changes:
docker-compose restart nginx
-
For solr/ changes:
docker-compose restart solr
First you should take note how many plone instances you have running:
docker-compose ps | grep -c plone
Use the number of running instances to run the upgrade:
docker-compose up -d --scale plone=<NUMBER_OF_PLONE_INSTANCES>
The docker hub automated build can be found on https://hub.docker.com/r/digitalagendadata/scoreboard.cron/
The steps to create a new release, follow this steps on your Dev environment:
-
Update files located in crontab directory - docker image files and cron directory - scripts and crontab files )
-
Push the changes on master
git add -A git commit git push
-
On every push to the master branch, a new digitalagendadata/scoreboard.cron:latest image is created. You can view the build status on: https://hub.docker.com/r/digitalagendadata/scoreboard.cron/builds/
-
Once the digitalagendadata/scoreboard.cron:latest image is succesfully built, you can test ( if needed ), and then create a new release.
-
View most recent tag on git:
git describe --tags
-
Choose a new tag, bigger than the latest one, using a MAJOR.MINOR format. Save it in a variable:
export NEW_TAG="<NEW_TAG>"
-
Create and push tag on repo:
git tag -a "$NEW_TAG" -m "$NEW_TAG" git push origin $NEW_TAG
-
Follow the release on docker hub https://hub.docker.com/r/digitalagendadata/scoreboard.cron/builds/. The new image will have the following format:
digitalagendadata/scoreboard.cron:$NEW_TAG
-
Update docker-compose.yml with the new image:
sed -i 's/image: digitalagendadata\/scoreboard.cron.*/image: digitalagendadata\/scoreboard.cron:$NEW_TAG/' docker-compose.yml
-
Push the change on the GIT repo:
git add docker-compose.yml git commit -m "Updated cron image to $NEW_TAG" git push
The docker hub automated build can be found on https://hub.docker.com/r/digitalagendadata/scoreboard.elda/
The steps to create a new release, follow this steps on your Dev environment:
-
Update files located in elda directory
-
Push the changes on master
git add -A git commit git push
-
On every push to the master branch, a new digitalagendadata/scoreboard.elda:latest image is created. You can view the build status on: https://hub.docker.com/r/digitalagendadata/scoreboard.elda/builds/
-
Once the digitalagendadata/scoreboard.elda:latest image is succesfully built, you can test ( if needed ), and then create a new release.
-
View most recent tag on git:
git describe --tags
-
Choose a new tag, bigger than the latest one, using a MAJOR.MINOR format. Save it in a variable:
export NEW_TAG="<NEW_TAG>"
-
Create and push tag on repo:
git tag -a "$NEW_TAG" -m "$NEW_TAG" git push origin $NEW_TAG
-
Follow the release on docker hub https://hub.docker.com/r/digitalagendadata/scoreboard.elda/builds/. The new image will have the following format:
digitalagendadata/scoreboard.elda:$NEW_TAG
-
Update docker-compose.yml with the new image:
sed -i 's/image: digitalagendadata\/scoreboard.elda.*/image: digitalagendadata\/scoreboard.elda:$NEW_TAG/' docker-compose.yml
-
Push the change on the GIT repo:
git add docker-compose.yml git commit -m "Updated elda image to $NEW_TAG" git push
The docker hub automated build for the production plone images can be found:
Environment | Dockerfile location | Base image | Dockerhub | How to trigger |
---|---|---|---|---|
PRODUCTION | https://github.com/digital-agenda-data/scoreboard.docker/tree/master/plone | plone:4.3.17 | https://hub.docker.com/r/digitalagendadata/plone | Push on master or Tag |
STAGING | https://github.com/digital-agenda-data/scoreboard.docker/tree/master/plone/staging | digitalagendadata/plone:latest | https://hub.docker.com/r/digitalagendadata/plone.staging/ | New digitalagendadata/plone:latest |
DEVEL | https://github.com/digital-agenda-data/scoreboard.docker/tree/master/plone/devel | digitalagendadata/plone:latest | https://hub.docker.com/r/digitalagendadata/plone.devel/ | New digitalagendadata/plone:latest |
-
Update files in https://github.com/digital-agenda-data/scoreboard.docker/tree/master/plone directory
-
Push the changes on master
git add -A git commit git push
-
On every push to the master branch, a new digitalagendadata/plone:latest image is created. You can view the build status on: https://hub.docker.com/r/digitalagendadata/plone/builds/.
-
View most recent tag on git:
git describe --tags
-
Choose a new tag, bigger than the latest one, using a MAJOR.MINOR format. Save it in a variable:
export NEW_TAG="<NEW_TAG>"
-
Create and push tag on repo:
git tag -a "$NEW_TAG" -m "$NEW_TAG" git push origin $NEW_TAG
-
Follow the release on docker hub https://hub.docker.com/r/digitalagendadata/plone/builds/. The new image will have the following format:
digitalagendadata/plone:$NEW_TAG
-
Update docker-compose.yml with the new image:
sed -i 's/image: digitalagendadata\/plone.*/image: digitalagendadata\/plone:$NEW_TAG/' docker-compose.yml
-
Push the change on the GIT repo:
git add docker-compose.yml git commit -m "Updated plone image to $NEW_TAG" git push
The docker image is based on the digitalagendadata/plone:latest image. To reduce the image building time, if you need to do changes on production and on the staging image, try to combine them in a single commit.
-
Update files in the https://github.com/digital-agenda-data/scoreboard.docker/tree/master/plone/staging directory
-
Push the changes on master
git add -A git commit git push
-
On every push to the master branch, a new digitalagendadata/plone:latest image is created. You can view the build status on: https://hub.docker.com/r/digitalagendadata/plone/builds/. After the image is created, a new build will be started on https://hub.docker.com/r/digitalagendadata/plone.staging/builds/
The docker image is based on the digitalagendadata/plone:latest image. To reduce the image building time, if you need to do changes on production and on the devel image, try to combine them in a single commit.
-
Update files in the https://github.com/digital-agenda-data/scoreboard.docker/tree/master/plone/devel directory
-
Push the changes on master
git add -A git commit git push
-
On every push to the master branch, a new digitalagendadata/plone:latest image is created. You can view the build status on: https://hub.docker.com/r/digitalagendadata/plone/builds/. After the image is created, a new build will be started on https://hub.docker.com/r/digitalagendadata/plone.devel/builds/
If CSS does not look right on the Plone site: <SCOREBOARD_URL>/portal_css/manage_cssForm - Uncheck reset.css and click SAVE
- If you find in piwik/matomo logs this message:
server reached pm.max_children setting
or you want to offer a better performace of the web application, you will need to update thepm.max_children
,pm.start_servers
,pm.min_spare_servers
andpm.max_spare_servers
values in the corresponding www-DEPLOY_TYPE
.conf configuration file located in thepiwik/
directory and restart the container.