Newer
Older
### Sign-up/log-in
- [X] Fix subject header in login email
### Navigation
- [X] Attach permissions to urls
- [X] Namespace app urls (i.e. chords:index vs admin:index)
- [X] Add all views to breadcrumbs (and trial number for trial)
### Improve home screen
- [X] Edit base template to include a site name
### Profile
- [X] Merge sign-up and profile creation
- [X] Allow users to edit profile
### Trial screen
- [X] Save rendering preference in profile
- [X] Make sorting area responsive
- [ ] Remove potential ambiguity from labelling (change chord
background colour as lines are moved or snapping between divs?)
- [ ] show feedback of the rank order while dragging (e.g. number in
the corner of the dragged svg)
- [ ] Ask test users about how many trials are reasonable.
- [X] Remove X in guitar chords
- [x] Fix guitar chord pairs data
- [ ] Refine the chord sampling (take into account features, and
possibly include more frequent chords)
- [X] Add quality control stimuli set (three trials of fixed chords)
- [ ] Display a summary of individual participant responses in the
admin interface, rather than just the raw JSON.
- [ ] Display a summary of all participant responses in the admin
interface.
```
├── docker-compose.override.yml
├── docker-compose.prod.yml
├── docker-compose.yml
├── LICENSE
├── nginx
│ ├── config
│ └── dockerfile
├── Pipfile
├── Pipfile.lock
├── README.md
└── web
├── bin
├── chord_study
├── config
├── dockerfile
├── dockerfile-prod
├── manage.py
└── playability
```
## Requirements
* [Docker](https://www.docker.com/)
* [Docker Compose](https://docs.docker.com/compose/)
## Installation
Install Docker and Docker Compose. You may also like to install
docker-machine for remote deployment.
If Docker is installed and working, it is first necessary to build the
# clone and build l2p-postgres image (outside of this project)
cd ..
git clone https://gitlab.doc.gold.ac.uk/l2p/l2p-postgres.git
Then build the base docker image, make migrations (database table
initialisation) and then just start the services in either development
or production mode and Docker should set up everything.
From the same directory as this README file:
``` bash
# initialise submodules
git submodule update --init
```
``` bash
# build l2p/play-web image
docker build -t l2p/play-web ./web
```
### Python dev environment setup (optional)
Setting up a local python virtualenv is not necessary to run the
services, but can make writing code easier.
``` bash
# From within the same directory as this README make a new virtual
# environment and install all dependencies using pipenv.
pipenv install --dev
```
## Running the application
### Development mode
``` bash
docker-compose up
```
In a browser navigate to http://localhost:8000/, or the IP address of
the docker machine if you’re not on Linux.
To list running Docker containers run the `ps` command.
``` bash
docker ps
```
To manage containers use the `container` command.
``` bash
docker container ls
# or to list all containers, including stopped containers
docker container ls -a
# to clean up stopped containers
docker container prune
```
To shutdown all containers in this application run the `down` command.
``` bash
docker-compose down
```
To clear all database data and force re-initialisation on next start
delete the `playability_db_data` volume.
``` bash
docker volume rm playability_db_data
```
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
### Production mode
#### Swarm configuration
Production server is a Docker swarm manager.
``` bash
docker swarm init
Swarm initialized: current node (m2tixt3yz55061u2u5kg83484) is now a manager.
To add a worker to this swarm, run the following command:
docker swarm join --token SWMTKN-1-27m53mbkzaml2ojx60zoftt4vdyysnb203nb0vmzlktviwfibl-8qxzzdg3qep1sc13s22n9oqch 158.223.53.104:2377
To add a manager to this swarm, run 'docker swarm join-token manager' and follow the instructions.
```
Create necessary Docker secrets.
``` bash
openssl rand -base64 32 | docker secret create db-root-password -
openssl rand -base64 32 | docker secret create db-l2p-password -
python -c 'import django.core.management.utils as utils; print(utils.get_random_secret_key())' | docker secret create site-secret-key -
```
``` bash
docker stack deploy -c docker-compose.yml -c docker-compose.prod.yml l2p-play
docker stack rm l2p-play
```
## Docker setup information
Currently the entire web service utilises two Docker containers in
developer mode, one for the Django application and another for the
PostgreSQL database. In production mode there is also a third
container running nginx.
### Web container
The l2p/play image is built from a dockerfile located in the ./web
project directory. It is a customisation of the official python image
containing all necessary library dependencies. It can be build and run
manually using the following command.
``` bash
docker build -t l2p/play-web ./web
```
### Database container
The l2p/postgres image is a customisation of the official postgres
image containing the init-user-db.sh script to automatically create
the l2p user at start up.
If starting the db container for the first time in development mode,
the initialisation scripts will create database user accounts
__without__ passwords.
If starting the db container for the first time in production mode,
two password files must first be created __before__ running
docker-compose/stack deploy (see [Installation](#installation)).
Database data is not stored within the database container, but is
stored in a Docker volume. This means database containers can be
started, stopped and destroyed, but the data persisted.
An l2p/postgres container can be started manually with one of the
following commands.
``` bash
# development mode
docker-compose run --rm db
# production mode
```
To access the database directly using `psql` we can either:
1. use docker exec to execute psql within the existing container
``` bash
```
This option bypasses password checking (even in production) because we
are connecting from within the same container.
2. connect from localhost
``` bash
docker ps # find name of container
docker inspect playability_db_1 # find IP address of container
psql -h 172.19.0.2 -U postgres
```
It may be necessary to wrap commands in `wait-for-it.sh` if the `db`
container is not already up.
``` bash
docker-compose run --rm web bash
docker-compose run --rm web python -m django --version
docker-compose run --rm web python manage.py showmigrations --list
docker-compose run --rm web ./bin/wait-for-it.sh db:5432 -- python manage.py makemigrations chord_study
docker-compose run --rm web ./bin/wait-for-it.sh db:5432 -- python manage.py migrate
```
## Database admin
``` bash
docker exec -it <db_container> psql -U l2p
```
# Production only.
docker exec -it <db_container> backups
# Production only.
docker exec -it <db_container> backup