Commit bbff92f2 authored by Johan Bloemberg's avatar Johan Bloemberg

Docker documentation, development user.

parent 231fd13f
......@@ -26,13 +26,9 @@ Download and install below system requirements to get started:
- [git](https://git-scm.com/downloads) (download and install)
- [python3](https://www.python.org/downloads/) (download and install)
- [direnv](https://direnv.net/) (download and install, then follow [setup instructions](https://direnv.net/))
- [rabbitmq](http://www.rabbitmq.com/download.html) (for scanners only, download and install)
After installation of above tools, all following steps use the command line:
sudo easy_install pip # installs pip, a python package manager, with the command pip3
- Tox (`pip3 install --user tox`)
- [direnv](https://direnv.net/) (optional, download and install, then follow [setup instructions](https://direnv.net/), see Direnv section below)
- [Docker](https://docs.docker.com/engine/installation/) (optional, recommended, follow instructions to install.)
# Obtaining the software
......@@ -44,16 +40,82 @@ In a directory of your choosing:
# enter the directory of the downloaded software
cd admin
# sets Debug to true in this folder. Do not change the settings.py file.
Use Direnv to manage environment (see Direnv section below). This manages the Python Virtualenv and `DEBUG` setting required for local development.
direnv allow
# Quickstart
For the quickstart we assume the usage of Docker as it offers the most complete environment for development. This project aims to be environment agnostic and development without Docker is possible. See Development section below.
Below commands result in a failmap installation that is suitable for testing and development. It is
capable of handling thousands of urls and still be modestly responsive.
If you need a faster, more robust installation, please [contact us](mailto:hosting@internetcleanup.foundation).
Ensure Docker is installed and running. Execute the following command to bring up the environment:
docker-compose up
This will build and start all required components and dependencies to run a complete instance of the Failmap project (grab some coffee the first time this takes a while).
You can now visit the [map website](http://127.0.0.1:8000/) and/or the
[admin website](http://127.0.0.1:8000/admin/) at http://127.0.0.1:8000 (credentials: admin:faalkaart).
To stop the environment simply press [CTRL][C].
The environment is aware of code changes in the `failmap_admin` folder. Services are automatically restarted to reflect the latest changes.
It is possible to start the environment in the background using:
docker-compose up -d
This can be shutdown using `docker-compose down`
To view (and follow) all logs run:
docker-compose logs -f
To see all running components:
$ docker-compose ps
Name Command State Ports
---------------------------------------------------------------------------------------------
admin_admin_1 /usr/local/bin/autoreload ... Up 0.0.0.0:8000->8000/tcp
admin_broker_1 docker-entrypoint.sh redis ... Up 0.0.0.0:5672->5672/tcp, 6379/tcp
admin_database_1 docker-entrypoint.sh mysqld Up 0.0.0.0:3306->3306/tcp
admin_loaddata_1 /usr/local/bin/failmap-adm ... Exit 0
admin_migrate_1 /usr/local/bin/failmap-adm ... Exit 0
admin_worker_1 /usr/local/bin/autoreload ... Up 8000/tcp
The platform consists of 2 external dependencies `broker` (redis), `database` (mysql) and 2 main components `admin` (web frontend and administrative environment), `worker` (async task executor).
Two tasks are run at startup `migrate` (database schema management) and `loaddata` (test and development data loading).
Most composer commands can be run against individual components, eg:
docker-compose logs -f worker
For more information consult docker composer [documentation](https://docs.docker.com/compose/) or:
docker-compose -h
# Development
To perform non-Docker development, make sure all Requirements are installed. Run the following script to setup a development instance:
tools/dev_setup.sh
After this run:
# finally start the development server
failmap-admin runserver
Now visit the [map website](http://127.0.0.1:8000/) and/or the
[admin website](http://127.0.0.1:8000/admin/) at http://127.0.0.1:8000 (credentials: admin:faalkaart).
The setup script performs the following steps:
# download even more requirements needed to run this software
pip3 install -e .
......@@ -61,7 +123,7 @@ If you need a faster, more robust installation, please [contact us](mailto:hosti
failmap-admin migrate
# create a user to view the admin interface
failmap-admin createsuperuser
failmap-admin loaddata development
# loads a series of sample data into the database
failmap-admin load-dataset testdata
......@@ -69,12 +131,6 @@ If you need a faster, more robust installation, please [contact us](mailto:hosti
# calculate the scores that should be displayed on the map
failmap-admin rebuild-ratings
# finally start the development server
failmap-admin runserver
Now visit the [map website](http://127.0.0.1:8000/) and/or the
[admin website](http://127.0.0.1:8000/admin/) at http://127.0.0.1:8000
# Scanning services (beta)
Todo: add celery beat information
......
......@@ -73,12 +73,13 @@ services:
volumes:
- .:/source/
ports:
- 8080:8000
- 8000:8000
# django decides what to log based on type of console
tty: true
entrypoint: [ '/usr/local/bin/autoreload', 'failmap-admin']
command: [ "runuwsgi" ]
# migrate
migrate:
image: failmap/admin
build:
......@@ -90,3 +91,15 @@ services:
DJANGO_DATABASE: production
tty: true
command: [ "migrate" ]
loaddata:
image: failmap/admin
build:
context: .
dockerfile: "${PWD}/Dockerfile"
links:
- database:mysql
environment:
DJANGO_DATABASE: production
tty: true
command: [ "loaddata", "development", "testdata" ]
Application specific fixtures (user accounts, settings) for different environments.
# Development
Contains a admin user for use during development. Username `admin`, password: `faalkaart`.
failmap-admin loaddata development
- model: auth.user
pk: 1
fields:
password: pbkdf2_sha256$36000$AVp6H74Dcqmy$5L1bnfpvg06UCs9XRrC+5lXjx4KUhHEWtEMgFrXeggo=
last_login: null
is_superuser: true
username: admin
first_name: ''
last_name: ''
email: test@example.com
is_staff: true
is_active: true
date_joined: 2017-10-30 14:32:44.614938+00:00
groups: []
user_permissions: []
......@@ -6,6 +6,8 @@ set -ve
pip3 install -e .
failmap-admin migrate
# failmap-admin load-dataset dev_user
# load development environment users/settings
failmap-admin load-dataset development
# load a test data set
failmap-admin load-dataset testdata -v0
failmap-admin rebuild-ratings -v0
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment