Running Impresso app stack in docker compose:
cp .env.example .env
docker-compose -p impresso up
Running in production (detached mode), check the contents of your .env
file if any:
docker-compose -p impresso up -d
Running in staging (detached mode), with the watchtower service that updates the images every 5 minutes:
docker-compose -f docker-compose.yml -f docker-compose.watcher.yml -p impresso up -d
Reading logs in production:
```shell
docker-compose -p impresso logs -f
The .env.example
contains latest
images of the services in docker-compose and it is for development purposes.
Docker compose expects several files located in config
directory in this folder:
impresso-middle-layer.json
- middle layer API configurationimpresso-user-admin.env
- admin dashboard and celery tasks app configurationnginx.conf
- nginx configurationssh/config
- ssh tunnel configuration (plus key files inssh
folder if needed)recsys_config.py
- collections recommender system configuration
We provide a sample set of files in config_example
. Fields that need to be replaced (mostly hostnames, usernames and passwords) are marked with [!!!REPLACE]
string.
A special note about the database. Our setup assumes the database is accessed via an SSH tunnel to the database host. If the database port is accessible directly, you can simplify the configuration by setting the db hostname, port and credentials in the relevant config files, commenting out the mysql-tunnel
section in docker-compose.yml
. In this case you also do not need the files in the config/ssh
folder, those are used for the DB tunnel only.
Increase the default limit of open files on the host server to increase the maximum allowed number of connections. See here.
Tags of impresso
docker images are read from the .env
file. The default file with all tags set to latest
is provided in this repository.
Make sure the following parameters are set to internal docker hostnames:
redis.host
toredis
celery.CELERY_BROKER_URL
hostname toredis
celery.CELERY_RESULT_BACKEND
hostname toredis
sequelize.host
tomysql-tunnel
sequelize.port
to3306
Make sure the following parameters are set to internal docker hostnames:
IMPRESSO_DB_HOST
tomysql-tunnel
IMPRESSO_DB_PORT
to3306
REDIS_HOST
toredis
STATIC_URL
to/admin/static/
(assuming innginx
configuration the base URL of the dashboard is/admin/
)ALLOWED_HOSTS
to*
(dashboard is behind nginx reverse proxy which manages this)
When building docker container for the app make sure:
- webpack compiles the app with
PUBLIC_PATH
environmental variable set to/app/
(assuming that the app base URL innginx
configuration is/app
). BASE_URL
inprod.env.js
is set to'"/app"'
(assuming that the app base URL innginx
configuration is/app
).MIDDLELAYER_API
inprod.env.js
is set to'""'
MIDDLELAYER_API_PATH
inprod.env.js
is set to'"/api"'
(assuming that middle layer API base URL innginx
configuration is/api
)MIDDLELAYER_API_SOCKET_PATH
inprod.env.js
is set to'"/api/socket.io/"'
(assuming that middle layer API base URL innginx
configuration is/api
)MIDDLELAYER_MEDIA_PATH
inprod.env.js
is set to'"/api/media"'
(assuming that the api base URL innginx
configuration is/api
)
impresso-middle-layer-update-cache:
# Updates cache files expected by middle layer. They do not change often
# so until this is refactored it is fine to run it on docker compose "up" or manually.
image: impresso/impresso-middle-layer:${IMPRESSO_MIDDLE_LAYER_TAG}
environment:
NODE_ENV: docker
depends_on:
- mysql-tunnel
volumes:
- ./config/impresso-middle-layer.json:/impresso-middle-layer/config/docker.json
- middle-layer-cache:/impresso-middle-layer/data
entrypoint: >
/bin/sh -c "echo 'Updating newspapers:' &&
(node scripts/update-newspapers.js || true) &&
echo 'Updating topics:' &&
(node scripts/update-topics.js || true) &&
echo 'Updating years:' &&
(node scripts/update-years.js || true) &&
echo 'Updating facet ranges:' &&
(node scripts/update-facet-ranges.js || true)"
impresso-middle-layer-update-related-topics:
# Updates related topics cache files expected by middle layer.
# It's a long running script (takes about 30-40 minutes). It should be run
# Every time Solr data changes.
image: impresso/impresso-middle-layer:${IMPRESSO_MIDDLE_LAYER_TAG}
environment:
NODE_ENV: docker
DEBUG: impresso/scripts*
depends_on:
- mysql-tunnel
volumes:
- ./config/impresso-middle-layer.json:/impresso-middle-layer/config/docker.json
- middle-layer-cache:/impresso-middle-layer/data
entrypoint: >
/bin/sh -c "echo 'Updating related topics:' &&
(node scripts/update-topics-related.js || true) &&
echo 'Updating Topic Graph:' &&
(node scripts/update-topics-positions.js || true)"