diff --git a/README.md b/README.md index 49293d90ffe09456518ba2a469854c47a820041d..e5e67ea14d05ff9a49939d495f4c0a7660f38094 100644 --- a/README.md +++ b/README.md @@ -71,6 +71,25 @@ The Debian package uses uwsgi to run uffd and ships an `uffd-admin` to execute f If you upgrade, make sure to run `flask db upgrade` after every update! The Debian package takes care of this by itself using uwsgi pre start hooks. For an example uwsgi config, see our [uswgi.ini](uwsgi.ini). You might find our [nginx include file](nginx.include.conf) helpful to setup a web server in front of uwsgi. +### Docker-based deployment + +To deploy uffd using docker, you can use the docker container `registry.git.cccv.de/uffd/uffd`. +See <https://git.cccv.de/uffd/uffd/container_registry> for available tags. + +The container copies the static files to `/var/www/uffd`, runs database migrations, optionally creates an initial admin user, +and finally runs the software using a uwsgi server. +The api can be accessed through a uwsgi socket on port 3031. +To deploy the software, a seperate http server (e.g. nginx) is required. + +See [examples/docker/basic-docker-compose.yml](examples/docker/basic-docker-compose.yml) for a minimal running setup. +It uses a sqlite database in the volume `data`. + +For more advanced setups take a look at [examples/docker/advanced-docker-compose.yml](examples/docker/advanced-docker-compose.yml). +It uses an external mariadb instance and allows configuation through the `uffd.cfg`. +Additionally a custom name and email address is provided for the initial admin user. + +The uwsgi server also exposes stats on port 9191, which can be used for monitoring. + ## Migration from version 1 Prior to version 2 uffd stored users, groups and mail aliases in an LDAP server. diff --git a/examples/docker/advanced-docker-compose.yml b/examples/docker/advanced-docker-compose.yml new file mode 100644 index 0000000000000000000000000000000000000000..5260e3251b14ebc9909ce5bebbc69e675cf2d0d3 --- /dev/null +++ b/examples/docker/advanced-docker-compose.yml @@ -0,0 +1,44 @@ +version: "3" + +networks: + uffd: {} + +volumes: + static-files: {} + data: {} + +services: + database: + image: mariadb + environment: + MYSQL_ROOT_PASSWORD: supersecret + MYSQL_USER: user + MYSQL_PASSWORD: secret + MYSQL_DATABASE: uffd + volumes: + - data:/var/lib/mysql + networks: + - uffd + + uffd-python: + image: registry.git.cccv.de/uffd/uffd + environment: + UFFD_SECRET_KEY: supersecret + UFFD_INITIAL_ADMIN_USER: myadmin + UFFD_INITIAL_ADMIN_PW: S3cr3tS3cr3t! + UFFD_INITIAL_ADMIN_MAIL: myadmin@example.com + volumes: + - static-files:/var/www/uffd + - ./uffd.cfg:/etc/uffd/uffd.cfg:ro + networks: + - uffd + + nginx: + image: nginx + volumes: + - static-files:/var/www/uffd + - ./nginx.conf:/etc/nginx/conf.d/default.conf:ro + ports: + - "80:80" + networks: + - uffd diff --git a/examples/docker/basic-docker-compose.yml b/examples/docker/basic-docker-compose.yml new file mode 100644 index 0000000000000000000000000000000000000000..bcf96e05cd917b144ef2294983f5db7ae8b0a287 --- /dev/null +++ b/examples/docker/basic-docker-compose.yml @@ -0,0 +1,29 @@ +version: "3" + +networks: + uffd: {} + +volumes: + static-files: {} + data: {} + +services: + uffd-python: + image: registry.git.cccv.de/uffd/uffd + environment: + UFFD_SECRET_KEY: supersecret + UFFD_INITIAL_ADMIN_PW: S3cr3tS3cr3t! + volumes: + - static-files:/var/www/uffd + - data:/var/lib/uffd + networks: + - uffd + nginx: + image: nginx + volumes: + - static-files:/var/www/uffd + - ./nginx.conf:/etc/nginx/conf.d/default.conf:ro + ports: + - "80:80" + networks: + - uffd diff --git a/examples/docker/nginx.conf b/examples/docker/nginx.conf new file mode 100644 index 0000000000000000000000000000000000000000..cd14877fcac8340a5c382e5c2574a19e2b44eb3a --- /dev/null +++ b/examples/docker/nginx.conf @@ -0,0 +1,13 @@ +server { + listen 80; + server_name _; + + location / { + uwsgi_pass uffd-python:3031; + include uwsgi_params; + } + + location /static { + alias /var/www/uffd/static; + } +} diff --git a/examples/docker/uffd.cfg b/examples/docker/uffd.cfg new file mode 100644 index 0000000000000000000000000000000000000000..ffa3ddfc34cab88c38c82fba557633e31a2fd1eb --- /dev/null +++ b/examples/docker/uffd.cfg @@ -0,0 +1 @@ +SQLALCHEMY_DATABASE_URI='mysql+pymysql://user:secret@database/uffd'