https://github.com/cnr-ibba/shiny-server
Shiny Server @CNR-IBBA
https://github.com/cnr-ibba/shiny-server
django-authentication docker docker-compose shiny-server
Last synced: 3 months ago
JSON representation
Shiny Server @CNR-IBBA
- Host: GitHub
- URL: https://github.com/cnr-ibba/shiny-server
- Owner: cnr-ibba
- License: gpl-3.0
- Created: 2020-02-18T14:34:16.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2025-10-29T21:10:54.000Z (8 months ago)
- Last Synced: 2025-10-29T21:12:37.966Z (8 months ago)
- Topics: django-authentication, docker, docker-compose, shiny-server
- Language: JavaScript
- Homepage: https://shiny.ibba.cnr.it
- Size: 5.06 MB
- Stars: 7
- Watchers: 2
- Forks: 2
- Open Issues: 11
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Shiny server with Django authentication
[](https://github.com/cnr-ibba/shiny-server/actions/workflows/django-tests.yml)
[](https://coveralls.io/github/cnr-ibba/shiny-server)


This is an attempt of managing shiny authentication with Django starting from
[Django application as an authentication / authorization server for Shiny](http://pawamoy.github.io/2018/03/15/django-auth-server-for-shiny/)
guide and modifying stuff accordingly. The Django template derive from
[this repository](https://github.com/cnr-ibba/dockerfiles/tree/master/compose/django)
while the shiny specific configuration comes from this [shiny docker-compose](https://github.com/cnr-ibba/dockerfiles/tree/master/compose/shiny)
project.
The aim of this project is to provide both free and restricted access to shiny
applications relying on Django authentication system and nginx. Applications could
be accessed using the Django frontend as a container of an iframe application or
directly by specifying the path of the application. A specific NGINX configuration
will be responsible to provide access to shiny applications relying on Django
authentication system.
If you need more information please see our
[Wiki on GitHub](https://github.com/cnr-ibba/shiny-server/wiki)
## Install dependencies
All this stuff works inside a docker compose image and need [docker](https://www.docker.com/)
and [docker compose](https://docs.docker.com/compose/) to work. Please refer to
the official documentation on how to install [docker](https://docs.docker.com/install/)
and [docker compose](https://docs.docker.com/compose/install/)
## Install shiny-server
We have a detailed guide on how to install and configure `shiny-server`: please
refer to the [Install and Update](https://github.com/cnr-ibba/shiny-server/wiki/Install-and-Update)
wiki of this project for more details.
Clone this project and enter in project directory:
```bash
git clone https://github.com/cnr-ibba/shiny-server.git
cd shiny-server
```
This location will be referred as **working directory**, since all commands need
to be launched inside this directory. This directory will also contain all the
shiny application data, database and configuration files.
### Setting up the environment file
`docker compose` can read environment variables from a `.env` placed in the working
directory in which we can define all variables useful for our containers, like database
credentials. Edit a new `.env` file in working directory and set values for such
environment variables accordingly:
```conf
MYSQL_ROOT_PASSWORD=
SHINY_DATABASE=
SHINY_USER=
SHINY_PASSWORD=
SECRET_KEY=
DEBUG=False
ADMINS=:
DEFAULT_FROM_EMAIL=
EMAIL_BACKEND=django.core.mail.backends.smtp.EmailBackend
EMAIL_HOST=
EMAIL_HOST_PASSWORD=
EMAIL_HOST_USER=
EMAIL_PORT=
EMAIL_USE_TLS= NOTE: those images are pre-built and available on [Docker Hub](https://hub.docker.com).
> You can collect them directly from there using:
>
> ```bash
> docker compose pull
> ```
### Fixing permissions
You will need also to check file permissions in `django-data` folder, especially for `media`
folder:
```bash
docker compose run --rm -u $(id -u):www-data uwsgi sh -c 'chmod -R g+rw media && chmod g+rwx media/thumbnails/'
docker compose run --rm -u $(id -u):www-data uwsgi sh -c 'chgrp -R www-data .'
```
You may also need to fix permissions for `renv-cache` folder used by R packages
installation:
```bash
docker-compose run --rm -u root:root -ti shiny-4.5 sh -c 'chown -R shiny:shiny /srv/renv-cache'
```
### Initialize Django tables
After inizialization, a new django user with administrative privilges is needed. This is
not the default mysql user, but a user valid only in django environment. Moreover,
the django tables need to be defined:
```bash
docker compose run --rm -u $(id -u):www-data uwsgi python manage.py check
docker compose run --rm -u $(id -u):www-data uwsgi python manage.py migrate
docker compose run --rm -u $(id -u):www-data uwsgi python manage.py makemigrations
docker compose run --rm -u $(id -u):www-data uwsgi python manage.py migrate
docker compose run --rm -u $(id -u):www-data uwsgi python manage.py createsuperuser
```
The last commands will prompt for a user creation. This will be a new django
admin user, not the database users described in `env` files. Track user credentials
since those will be not stored in `.env` file in `shiny-server` directory.
### Check everything works as expected
Test your fresh InjectTool installation with:
```bash
docker compose run --rm -u $(id -u):www-data uwsgi pytest
```
## Start composed images
Pages are served by a NgINX docker container controlled by Docker Compose
(see the `docker-compose.yml` file content), which is linked to the shiny
server and django instance. In order to start the application:
```bash
docker compose up -d
```
The shiny-server interface is available for a local access through Internet browser
at the URL: `http://localhost:22080/`.
## License
This project is licensed under the GNU General Public License v3.0 - see the [LICENSE](LICENSE) file for details.
## Copyright
Copyright (C) 2020-2025 Paolo Cozzi