Handy docker compose example file that sets up a nginx_ssl_keycloak_mysql_redis as a service ready to use. This compose file is based on serveral other repos and online articles.
Knowledge about all elements in the compose file before use.
Nginx and Let’s Encrypt is taken from this repo. You can find more information here https://github.com/wmnnd/nginx-certbot.
The
init-letsencrypt.sh
fetched from https://github.com/wmnnd/nginx-certbot has been slightly modefied in this example. In this example you can add domains from comand line, like this:
./init-letsencrypt.sh [staging | production] <domain1 domain2 ...>
Note: The mariadb is build from compose file to use timezone Europe/Oslo. Remove if not needed.
This docker compose file sets up:
-
nginx with ssl sertificates
- Inclues config app.conf file but to be used as example only.
- based on some articles and repos
-
Keycloak for authentication with custom "adminlte" login page
- based on some articles:
- Example theme from:
-
mysql with config
- Inclues config my.cnf file but to be used as example only. Remember to change my.cnf file dependent of what kind of mariadb version you use.
-
Redis
# Run the docker compose
docker-compose up -d --build
# Init you sertificates
# Depending on you user rights it could be that you have to give the user access to run the shell file.
# Also use staging when testing or you will have to wait for a while between each run.
# Example: chmod +x username:usergroup ./init-letsencrypt.sh
./init-letsencrypt.sh [staging | production] <domain1 domain2 ...>
# Run the docker compose
docker-compose -f docker-compose-without-ssl.yml up -d --build
Examples below will help you test that stuff without ssl sertificates ( local testing ) is running correctly.
# go to your browser:
# expected result: web site opens with "Welcome to nginx!"
http://127.0.0.1:81
# go to your browser:
# expected result: web site opens
http://127.0.0.1:8180
Now, log in as admin and change the default theme for the one in this example:
# In command line:
# expected result:
# +--------------------+
# | Database |
# +--------------------+
# | information_schema |
# | keycloak |
# +--------------------+
docker exec -it mariadb mysql -ukeycloak -pkeycloak -e "SHOW DATABASES;"
# In command line:
# expected result: < PONG
docker exec -it redis redis-cli PING