Docker¶
The best way to install the MUSCLE application is with using docker. This way it can easily be maintained.
Also it is nice in combination with traefik to expose your muscle app to the Internet. Otherwise it’s recommended that you set up another proxy server in front of the docker image.
Install docker on your system and do the following steps.
Download Docker Image¶
Note
Currently the docker registry for the muscle docker image is not public. Therefor, you have to login into the registry first to pull the image. Use your BFH credential to login.
Login into the registry hub of the BFH Gitlab instance -> use your credentials
docker login registry.gitlab.ti.bfh.ch/muscle/docker
Download image and extract.
docker pull registry.gitlab.ti.bfh.ch/muscle/docker/multi-arch:latest
Logout so your credentials will be removed.
docker logout registry.gitlab.ti.bfh.ch/muscle/docker
Docker Compose¶
To start the container, we use a docker-compose file.
A simple docker configuration may look like this docker-compose.yml
:
version: "3.2"
services:
muscle:
container_name: muscle
# muscle docker image
image: registry.gitlab.ti.bfh.ch/muscle/docker/multi-arch:latest
restart: always
ports:
# map the port 80 from the host to the port 80 of the container
# You may need to configure a proxy server with certificate generation for MUSCLE
- 80:80
volumes:
# mount the database directory into the container
- ${PATH_TO_DATA}/database/:/var/www/muscle-backend/database/
# mount the application config into the container
- ${PATH_TO_CONFIG}/application.config.json:/var/www/muscle-frontend/config/application.config.json
Please refer to the docker documentation for information of the configuration used in this file.
Note
The values inside the parantheses ${}
can be placed inside a file called .env
in the same directory like the docker-compose.yml
itself. In this file the values can be exported:
PATH_TO_DATA=/path
PATH_TO_CONFIG=/other_path
Replace /path
and /other_path
with the corresponding path on your system.
Volumes¶
The listed volumes in the file will make the data of MUSCLE persist even when the container gets removed or updated. Not doing so will place the files in the default docker mount directory somewhere under /var/lib/docker/volumes
.
database¶
The database of MUSCLE is located at /var/www/muscle-backend/database/
to make it easy to back it up and persist it, mount it outside of the container.
This directory needs to be owned by www-data
:
mkdir <PATH_TO_DATA>/database
sudo chown www-data:www-data <PATH_TO_DATA>/database
application.config.json¶
The configuration for the MUSCLE webapp. Refer to the frontend configuration documentation for the contents of this file.
Note
In most cases it is not necessary to change this file when using the docker image. It has already everything setup to work. Only change this configuration if you know what you are doing.
Configure the Application¶
To configure the application, environment variables can be easily set in the compose file. To do so create a new key environment
under the muscle image. The configurable options can then be defined like this:
services:
muscle:
#...
environment:
- MUSCLE_USER_DEFAULT_PWD=${DEFAULT_PWD}
- MUSCLE_BRAND_NAME=${BRAND_NAME}
#...
A description of configuration variables can be found here
Note
It’s not recommended to change paths inside the docker container with variables like MUSCLE_DB_PATH
since they are inside the container. You can already adjust the path on your host when mounting the volume. However if you change them make sure to also specify the correct volume inside the container when mounting e.g.
environment:
- MUSCLE_DB_PATH=/example/path/
volumes:
- ${PATH_TO_DATA}/database/:/example/path/
Use Together With Traefik¶
Note
If you use MUSCLE alongside Traefik, it is important that you also mount the traefik device configs. This volume must then be shared with the traefik container.
Muscle:¶
volumes:
# mount the configs created from muscle to the host
- ${PATH_TO_CONFIG}/traefik-dynamic-configs/:/var/www/muscle-backend/traefik_devices/
Traefik:¶
volumes:
# mount the configuration for the devices from the host into the traefik container
- ${PATH_TO_CONFIG}/traefik-dynamic-configs/:/etc/traefik/dynamic-configs/