Initial commit to rework cc-docker repo into development environment

This commit is contained in:
Christoph Kluge 2022-06-01 11:27:50 +02:00
parent cb420305ab
commit 7d259dd1ba
13 changed files with 308 additions and 215 deletions

3
.gitignore vendored
View File

@ -1,7 +1,6 @@
data/job-archive data/job-archive
data/job-archive/** data/job-archive/**
data/symfony
data/symfony/**
data/influxdb data/influxdb
data/sqldata data/sqldata
data/cc-metric-store data/cc-metric-store
.vscode

View File

@ -1,86 +1,50 @@
# cc-docker # cc-docker
This is a `docker compose` setup to try out the complete ClusterCockpit Application Stack including all external components. This docker setup can be easily configured to be used as demo or as a development environment. **Please note: This repo is under ongoing construction**
For a docker setup targeted to server environment you may have a look at https://github.com/ClusterCockpit/cc-docker-server .
This is a `docker-compose` setup which provides a quickly started environment for ClusterCockpit development and testing, using the modules `cc-backend` (GoLang) and `cc-frontend` (Svelte). A number of services is readily available as docker container (nats, cc-metric-store, InfluxDB, LDAP), or easily added by manual configuration (MySQL).
It includes the following containers: It includes the following containers:
* mysql * nats (Default)
* php-fpm * cc-metric-store (Default)
* nginx * influxdb (Optional)
* redis * openldap (Default)
* openldap * mysql (Optional, Manual)
* influxdb * phpmyadmin (Optional, Manual)
* phpmyadmin
Settings are configured in `.env`. The setup comes with fixture data for a Job archive, cc-metric-store checkpoints, InfluxDB, MySQL, and a LDAP user directory.
The setup comes with fixture data for a Job archive, InfluxDB, MySQL, and a LDAP user directory.
## Known Issues ## Known Issues
* `docker-compose` installed on Ubuntu (18.04, 20.04) via `apt-get` can not correctly parse `docker-compose.yml` due to version differences. Install latest version of `docker-compose` from https://docs.docker.com/compose/install/ instead. * `docker-compose` installed on Ubuntu (18.04, 20.04) via `apt-get` can not correctly parse `docker-compose.yml` due to version differences. Install latest version of `docker-compose` from https://docs.docker.com/compose/install/ instead.
* You need to ensure that no other web server is running on port 80 (e.g. Apache2). If port 80 is already in use, edit NGINX_PORT environment variable in `.env`. * You need to ensure that no other web server is running on ports 8080 (cc-backend), 8081 (phpmyadmin), 8084 (cc-metric-store), 8086 (nfluxDB), 4222 and 8222 (Nats), or 3306 (MySQL). If one or more ports are already in use, you habe to adapt the related config accordingly.
* Existing VPN connections sometimes cause problems with docker. If `docker-compose` does not start up correctly, try disabling any active VPN connection. Refer to https://stackoverflow.com/questions/45692255/how-make-openvpn-work-with-docker for further information. * Existing VPN connections sometimes cause problems with docker. If `docker-compose` does not start up correctly, try disabling any active VPN connection. Refer to https://stackoverflow.com/questions/45692255/how-make-openvpn-work-with-docker for further information.
## Configuration ## Configuration Templates
While many aspects of this docker compose setup can be configured you usually only need to adapt the following three settings in `.env`: Located in `./templates`
* `CLUSTERCOCKPIT_BRANCH` (Default: `develop`): The branch to checkout from ClusterCockpit git repository. May also be a tag. * `docker-compose.yml.ccms`: Docker-Compose file to setup cc-metric-store metric database and LDAP containers (Default). Used in `setupDev.sh`.
* `APP_CLUSTERCOCKPIT_INIT` (Default: true): Wether the Symfony tree (located at `./data/symfony`) should be deleted and freshly cloned and initialized on every container startup. * `docker-compose.yml.influxdb`: Docker-Compose file to setup influxDB metric database and LDAP containers. Used in `setupDev.sh`.
* `APP_ENVIRONMENT` (Default: `dev`): The Symfony app environment. With `dev` you get the symfony debug toolbar and more extensive error handling. The `prod` environment is a setup for productions use. * `docker-compose.yml.mysql`: Docker-Compose configuration template if additional MySQL and phpmyadmin containers are desired.
* `env.ccms`: Environment variables for setup with cc-metric-store metric database and LDAP containers (Default). Used in `setupDev.sh`.
* `env.influxdb`: Environment variables for setup with influxDB metric database and LDAP containers. Used in `setupDev.sh`.
* `env.mysql`: Additional environment variables required if additional MySQL and phpmyadmin containers are desired.
## Setup ## Setup
* `$ cd data` 1. `$ ./setupDev.sh [help|ccms|influxdb]`: **NOTICE** The script will download files of a total size of 338MB (mostly for the InfluxDB data).
* `$ ./init.sh`: **NOTICE** The script will download files of a total size of 338MB (mostly for the InfluxDB data). * `help`: Displays help.
* `ccms`: Copies according docker-compose.yml and env-file to root directory, downloads cc-metric-store checkpoint data, and builds containers.
* `influxdb`: Copies according docker-compose.yml and env-file to root directory, downloads influxDB data, and builds containers.
If you want to test the REST API and also write to the job archive from Cluster Cockpit you have to comment out the following lines in `./data/init.sh`: 2. After that from the root of the cc-docker sandbox you can start up the containers and launch cc-backend with: `$ ./startDev.sh`
```
echo "This script needs to chown the job-archive directory so that the application can write to it:"
sudo chown -R 82:82 ./job-archive
```
After that from the root of the cc-docker sandbox you can start up the containers with: 3. By default, you can access cc-backend in your browser at `http://localhost:8080`. You can shut down the cc-backend server by pressing `CTRL-C`, remember to also shut down all containers via `docker-compose down` afterwards.
* `$ docker-compose up`
* Wait... and wait a little longer
Before you can use ClusterCockpit the following disclaimer must be shown. To download and build all ClusterCockpit components may take up to several minutes:
```
-------------------- ---------------------------------
Symfony
-------------------- ---------------------------------
Version 5.3.7
Long-Term Support No
End of maintenance 01/2022 (in +140 days)
End of life 01/2022 (in +140 days)
-------------------- ---------------------------------
Kernel
-------------------- ---------------------------------
Type App\Kernel
Environment dev
Debug true
Charset UTF-8
Cache directory ./var/cache/dev (6.5 MiB)
Build directory ./var/cache/dev (6.5 MiB)
Log directory ./var/log (249 B)
-------------------- ---------------------------------
PHP
-------------------- ---------------------------------
Version 8.0.10
Architecture 64 bits
Intl locale n/a
Timezone UTC (2021-09-13T09:41:33+00:00)
OPcache true
APCu false
Xdebug false
-------------------- ---------------------------------
```
By default, you can access ClusterCockpit in your browser at `http://localhost`. If the `NGINX_PORT` environment variable was changed, you have to use `http://localhost:$PORT` . You can shutdown the containers by pressing `CTRL-C`. Refer to the common docker documentation how to start the environment in the background.
## Usage ## Usage
Credentials for the preconfigured admin user are: Credentials for the preconfigured demo user are:
* User: `admin` * User: `demo`
* Password: `AdminDev` * Password: `AdminDev`
You can also login as regular user using any credential in the LDAP user directory at `./data/ldap/users.ldif`. You can also login as regular user using any credential in the LDAP user directory at `./data/ldap/users.ldif`.

View File

@ -26,4 +26,3 @@
"nats": "nats://cc-nats:4222", "nats": "nats://cc-nats:4222",
"jwt-public-key": "kzfYrYy+TzpanWZHJ5qSdMj5uKUWgq74BWhQG6copP0=" "jwt-public-key": "kzfYrYy+TzpanWZHJ5qSdMj5uKUWgq74BWhQG6copP0="
} }

View File

@ -1,39 +0,0 @@
#!/usr/bin/env bash
if [ -d influxdb ]; then
echo "Data already initialized!"
echo -n "Perform a fresh initialisation? [yes to proceed / no to exit] "
read -r answer
if [ "$answer" == "yes" ]; then
echo "Cleaning directories ..."
rm -rf job-archive
rm -rf influxdb/data/*
rm -rf sqldata/*
echo "done."
else
echo "Aborting ..."
exit
fi
fi
# Download example job job-archive
wget https://hpc-mover.rrze.uni-erlangen.de/HPC-Data/0x7b58aefb/eig7ahyo6fo2bais0ephuf2aitohv1ai/job-archive.tar.xz
tar xJf job-archive.tar.xz
rm ./job-archive.tar.xz
# Download data for influxdb2
mkdir -p influxdb/data
wget https://hpc-mover.rrze.uni-erlangen.de/HPC-Data/0x7b58aefb/eig7ahyo6fo2bais0ephuf2aitohv1ai/influxdbv2-data.tar.xz
cd influxdb/data
tar xJf ../../influxdbv2-data.tar.xz
rm ../../influxdbv2-data.tar.xz
cd ../..
# Download checkpoint files for cc-metric-store
mkdir -p cc-metric-store/checkpoints
mkdir -p cc-metric-store/archive
cd cc-metric-store/checkpoints
wget https://hpc-mover.rrze.uni-erlangen.de/HPC-Data/0x7b58aefb/eig7ahyo6fo2bais0ephuf2aitohv1ai/cc-metric-store-checkpoints.tar.xz
tar xf cc-metric-store-checkpoints.tar.xz
rm cc-metric-store-checkpoints.tar.xz
cd ../..

View File

@ -1,76 +0,0 @@
services:
nats:
container_name: cc-nats
image: nats:alpine
ports:
- "4222:4222"
- "8222:8222"
cc-metric-store:
container_name: cc-metric-store
build:
context: ./cc-metric-store
ports:
- "8081:8081"
volumes:
- ${DATADIR}/cc-metric-store:/data
depends_on:
- nats
db:
container_name: cc-db
image: mysql:8.0.22
command: ["--default-authentication-plugin=mysql_native_password"]
environment:
MYSQL_ROOT_PASSWORD: ${MYSQL_ROOT_PASSWORD}
MYSQL_DATABASE: ${MYSQL_DATABASE}
MYSQL_USER: ${MYSQL_USER}
MYSQL_PASSWORD: ${MYSQL_PASSWORD}
ports:
- "127.0.0.1:3336:3306"
volumes:
- ${DATADIR}/sql-init:/docker-entrypoint-initdb.d
# - ${DATADIR}/sqldata:/var/lib/mysql
cap_add:
- SYS_NICE
phpmyadmin:
container_name: cc-phpmyadmin
image: phpmyadmin
environment:
- PMA_HOST=cc-db
- PMA_USER=root
- PMA_PASSWORD=${MYSQL_ROOT_PASSWORD}
ports:
- "127.0.0.1:${PHPMYADMIN_PORT}:80"
depends_on:
- db
influxdb:
container_name: cc-influxdb
image: influxdb
command: ["--reporting-disabled"]
environment:
DOCKER_INFLUXDB_INIT_MODE: setup
DOCKER_INFLUXDB_INIT_USERNAME: symfony
DOCKER_INFLUXDB_INIT_PASSWORD: ${INFLUXDB_PASSWORD}
DOCKER_INFLUXDB_INIT_ORG: ${INFLUXDB_ORG}
DOCKER_INFLUXDB_INIT_BUCKET: ${INFLUXDB_BUCKET}
DOCKER_INFLUXDB_INIT_RETENTION: 100w
DOCKER_INFLUXDB_INIT_ADMIN_TOKEN: ${INFLUXDB_ADMIN_TOKEN}
ports:
- "127.0.0.1:${INFLUXDB_PORT}:8086"
volumes:
- ${DATADIR}/influxdb/data:/var/lib/influxdb2
- ${DATADIR}/influxdb/config:/etc/influxdb2
openldap:
container_name: cc-ldap
image: osixia/openldap:1.5.0
command: --copy-service --loglevel debug
environment:
- LDAP_ADMIN_PASSWORD=${LDAP_ADMIN_PASSWORD}
- LDAP_ORGANISATION=${LDAP_ORGANISATION}
- LDAP_DOMAIN=${LDAP_DOMAIN}
volumes:
- ${DATADIR}/ldap:/container/service/slapd/assets/config/bootstrap/ldif/custom

155
setupDev.sh Executable file
View File

@ -0,0 +1,155 @@
#!/bin/bash
if [ -z "$1" ]; then
echo "No argument supplied. Use 'help', 'ccms' (Default), or 'influxdb'."
exit
elif [ "$1" == "help" ]; then
echo "Script to setup cc-backend devel environment. Use 'help', 'ccms' (Default), or 'influxdb' as argument."
echo "'help' : This help."
echo "'ccms' : Setup cc-metric-store example data and build docker container."
echo "'influxdb' : Setup influxdb example data and build docker container. Requires additional configuration afterwards."
exit
else
echo "Starting setup for '$1' ..."
fi
# Download data for influxdb2
if [ "$1" == "influxdb" ]; then
if [ ! -d data/influxdb ]; then
mkdir -p data/influxdb/data
cd data/influxdb/data
wget https://hpc-mover.rrze.uni-erlangen.de/HPC-Data/0x7b58aefb/eig7ahyo6fo2bais0ephuf2aitohv1ai/influxdbv2-data.tar.xz
tar xJf influxdbv2-data.tar.xz
rm influxdbv2-data.tar.xz
cd ../../../
else
echo "'data/influxdb' already exists!"
echo -n "Remove existing folder and redownload? [yes to redownload / no to continue] "
read -r answer
if [ "$answer" == "yes" ]; then
echo "Removing 'data/influxdb' ..."
rm -rf data/influxdb
echo "Reinstall 'data/influxdb'..."
mkdir -p data/influxdb/data
cd data/influxdb/data
wget https://hpc-mover.rrze.uni-erlangen.de/HPC-Data/0x7b58aefb/eig7ahyo6fo2bais0ephuf2aitohv1ai/influxdbv2-data.tar.xz
tar xJf influxdbv2-data.tar.xz
rm influxdbv2-data.tar.xz
cd ../../../
echo "done."
else
echo "'data/influxdb' unchanged."
fi
fi
fi
# Download checkpoint files for cc-metric-store
if [ "$1" == "ccms" ]; then
if [ ! -d data/cc-metric-store ]; then
mkdir -p data/cc-metric-store/checkpoints
mkdir -p data/cc-metric-store/archive
cd data/cc-metric-store/checkpoints
wget https://hpc-mover.rrze.uni-erlangen.de/HPC-Data/0x7b58aefb/eig7ahyo6fo2bais0ephuf2aitohv1ai/cc-metric-store-checkpoints.tar.xz
tar xf cc-metric-store-checkpoints.tar.xz
rm cc-metric-store-checkpoints.tar.xz
cd ../../../
else
echo "'data/cc-metric-store' already exists!"
echo -n "Remove existing folder and redownload? [yes to redownload / no to continue] "
read -r answer
if [ "$answer" == "yes" ]; then
echo "Removing 'data/cc-metric-store' ..."
rm -rf data/cc-metric-store
echo "Reinstall 'data/cc-metric-store'..."
mkdir -p data/cc-metric-store/checkpoints
mkdir -p data/cc-metric-store/archive
cd data/cc-metric-store/checkpoints
wget https://hpc-mover.rrze.uni-erlangen.de/HPC-Data/0x7b58aefb/eig7ahyo6fo2bais0ephuf2aitohv1ai/cc-metric-store-checkpoints.tar.xz
tar xf cc-metric-store-checkpoints.tar.xz
rm cc-metric-store-checkpoints.tar.xz
cd ../../../
echo "done."
else
echo "'data/cc-metric-store' unchanged."
fi
fi
fi
# Download && Setup cc-backend
if [ ! -d cc-backend ]; then
## Get backend git [can use --recursive to load frontend via ssh directly]
git clone https://github.com/ClusterCockpit/cc-backend.git
cd cc-backend
## Get frontend git [http variant]
cd frontend
### Comment ths if --recursive
git clone https://github.com/ClusterCockpit/cc-frontend.git .
yarn install
yarn build
cd ..
## Download Demo-Archive and prepare SQLite DB
mkdir ./var
cd ./var
wget https://hpc-mover.rrze.uni-erlangen.de/HPC-Data/0x7b58aefb/eig7ahyo6fo2bais0ephuf2aitohv1ai/job-archive.tar.xz
tar xJf job-archive.tar.xz
rm ./job-archive.tar.xz
touch ./job.db
cd ..
## Install backend
go get
go build
## initialize job archive and SQLite
./cc-backend --init-db --add-user demo:admin:AdminDev --no-server
cd ..
else
echo "'cc-backend' already exists!"
echo -n "Remove existing folder and reinstall? [yes to reinstall / no to continue] "
read -r answer
if [ "$answer" == "yes" ]; then
echo "Removing 'cc-backend' ..."
rm -rf cc-backend
echo "Reinstall 'cc-backend'..."
## Get backend git [can use --recursive to load frontend via ssh directly]
git clone https://github.com/ClusterCockpit/cc-backend.git
cd cc-backend
## Get frontend git [http variant]
cd frontend
### Comment ths if --recursive
git clone https://github.com/ClusterCockpit/cc-frontend.git .
yarn install
yarn build
cd ..
## Download Demo-Archive and prepare SQLite DB
mkdir ./var
cd ./var
wget https://hpc-mover.rrze.uni-erlangen.de/HPC-Data/0x7b58aefb/eig7ahyo6fo2bais0ephuf2aitohv1ai/job-archive.tar.xz
tar xJf job-archive.tar.xz
rm ./job-archive.tar.xz
touch ./job.db
cd ..
## Install backend
go get
go build
## initialize job archive and SQLite
./cc-backend --init-db --add-user demo:admin:AdminDev --no-server
cd ..
else
echo "'cc-backend' unchanged."
fi
fi
# Check dotenv-file and docker-compose-yml, copy accordingly if not present and build docker services
# !! By default, this decides which metric database is used based on the selected argument !!
if [ ! -d .env ]; then
cp templates/env.$1 ./.env
fi
if [ ! -d docker-compose.yml ]; then
cp templates/docker-compose.yml.$1 ./docker-compose.yml
fi
docker-compose build
echo ""
echo "Setup complete. Use 'startDev.sh' to boot containers and start cc-backend."

View File

@ -1,20 +1,6 @@
#!/bin/sh #!/bin/bash
# mkdir ./var docker-compose up -d
# cd ./var
# cd cc-backend
# wget https://hpc-mover.rrze.uni-erlangen.de/HPC-Data/0x7b58aefb/eig7ahyo6fo2bais0ephuf2aitohv1ai/job-archive.tar.xz ./cc-backend
# tar xJf job-archive.tar.xz
# rm ./job-archive.tar.xz
#
# touch ./job.db
# cd ../frontend
# yarn install
# yarn build
#
# cd ..
# go get
# go build
#
# ./cc-backend --init-db --add-user demo:admin:AdminDev --no-server
# ./cc-backend

View File

@ -0,0 +1,29 @@
services:
nats:
container_name: cc-nats
image: nats:alpine
ports:
- "4222:4222"
- "8222:8222"
cc-metric-store:
container_name: cc-metric-store
build:
context: ./cc-metric-store
ports:
- "8084:8084"
volumes:
- ${DATADIR}/cc-metric-store:/data
depends_on:
- nats
openldap:
container_name: cc-ldap
image: osixia/openldap:1.5.0
command: --copy-service --loglevel debug
environment:
- LDAP_ADMIN_PASSWORD=${LDAP_ADMIN_PASSWORD}
- LDAP_ORGANISATION=${LDAP_ORGANISATION}
- LDAP_DOMAIN=${LDAP_DOMAIN}
volumes:
- ${DATADIR}/ldap:/container/service/slapd/assets/config/bootstrap/ldif/custom

View File

@ -0,0 +1,29 @@
services:
influxdb:
container_name: cc-influxdb
image: influxdb
command: ["--reporting-disabled"]
environment:
DOCKER_INFLUXDB_INIT_MODE: setup
DOCKER_INFLUXDB_INIT_USERNAME: symfony
DOCKER_INFLUXDB_INIT_PASSWORD: ${INFLUXDB_PASSWORD}
DOCKER_INFLUXDB_INIT_ORG: ${INFLUXDB_ORG}
DOCKER_INFLUXDB_INIT_BUCKET: ${INFLUXDB_BUCKET}
DOCKER_INFLUXDB_INIT_RETENTION: 100w
DOCKER_INFLUXDB_INIT_ADMIN_TOKEN: ${INFLUXDB_ADMIN_TOKEN}
ports:
- "127.0.0.1:${INFLUXDB_PORT}:8086"
volumes:
- ${DATADIR}/influxdb/data:/var/lib/influxdb2
- ${DATADIR}/influxdb/config:/etc/influxdb2
openldap:
container_name: cc-ldap
image: osixia/openldap:1.5.0
command: --copy-service --loglevel debug
environment:
- LDAP_ADMIN_PASSWORD=${LDAP_ADMIN_PASSWORD}
- LDAP_ORGANISATION=${LDAP_ORGANISATION}
- LDAP_DOMAIN=${LDAP_DOMAIN}
volumes:
- ${DATADIR}/ldap:/container/service/slapd/assets/config/bootstrap/ldif/custom

View File

@ -0,0 +1,29 @@
services:
db:
container_name: cc-db
image: mysql:8.0.22
command: ["--default-authentication-plugin=mysql_native_password"]
environment:
MYSQL_ROOT_PASSWORD: ${MYSQL_ROOT_PASSWORD}
MYSQL_DATABASE: ${MYSQL_DATABASE}
MYSQL_USER: ${MYSQL_USER}
MYSQL_PASSWORD: ${MYSQL_PASSWORD}
ports:
- "127.0.0.1:3336:3306"
volumes:
- ${DATADIR}/sql-init:/docker-entrypoint-initdb.d
# - ${DATADIR}/sqldata:/var/lib/mysql
cap_add:
- SYS_NICE
phpmyadmin:
container_name: cc-phpmyadmin
image: phpmyadmin
environment:
- PMA_HOST=cc-db
- PMA_USER=root
- PMA_PASSWORD=${MYSQL_ROOT_PASSWORD}
ports:
- "127.0.0.1:${PHPMYADMIN_PORT}:80"
depends_on:
- db

15
templates/env.ccms Normal file
View File

@ -0,0 +1,15 @@
########################################################################
# CCBACKEND DEVEL DOCKER SETTINGS FOR LDAP (CCMS-Devel)
########################################################################
#########################################
# LDAP
########################################################################
LDAP_ADMIN_PASSWORD=mashup
LDAP_ORGANISATION=NHR@FAU
LDAP_DOMAIN=rrze.uni-erlangen.de
########################################################################
# INTERNAL SETTINGS
########################################################################
DATADIR=./data

View File

@ -1,16 +1,7 @@
######################################################################## ########################################################################
# CCBACKEND DEVEL DOCKER SETTINGS # CCBACKEND DEVEL DOCKER SETTINGS FOR INFLUXDB AND LDAP
######################################################################## ########################################################################
########################################################################
# MySQL
# The SQL port is not exposed outside the container
########################################################################
MYSQL_ROOT_PASSWORD=root
MYSQL_DATABASE=ClusterCockpit
MYSQL_USER=symfony
MYSQL_PASSWORD=symfony
######################################################################## ########################################################################
# INFLUXDB # INFLUXDB
######################################################################## ########################################################################
@ -29,11 +20,6 @@ LDAP_ADMIN_PASSWORD=mashup
LDAP_ORGANISATION=NHR@FAU LDAP_ORGANISATION=NHR@FAU
LDAP_DOMAIN=rrze.uni-erlangen.de LDAP_DOMAIN=rrze.uni-erlangen.de
########################################################################
# PHPMyAdmin
########################################################################
PHPMYADMIN_PORT=8080
######################################################################## ########################################################################
# INTERNAL SETTINGS # INTERNAL SETTINGS
######################################################################## ########################################################################

17
templates/env.mysql Normal file
View File

@ -0,0 +1,17 @@
########################################################################
# ADDITIONAL ENV VARIABLES FOR MYSQL AND PHPMYADMIN CONTAINERS
########################################################################
########################################################################
# MySQL
# The SQL port is not exposed outside the container
########################################################################
MYSQL_ROOT_PASSWORD=root
MYSQL_DATABASE=ClusterCockpit
MYSQL_USER=symfony
MYSQL_PASSWORD=symfony
########################################################################
# PHPMyAdmin
########################################################################
PHPMYADMIN_PORT=8081