Update README.md with up to date info

This commit is contained in:
Jan Tuomi
2017-05-18 16:06:35 +03:00
parent 21f8a71fd7
commit babd20921f
2 changed files with 34 additions and 198 deletions
+34 -114
View File
@@ -17,154 +17,74 @@ Change to the development branch:
git checkout develop
```
## Installation with Docker
## Install Python3
### One click install
Version >3.5 is needed. Installation instructions at:
https://www.python.org/
Run the one click installer
## Install PostgreSQL
```BASH
sudo scripts/autoinstall.sh
```
If you experience installation problems, go through the install process manually by following the steps below. If the installation is a success, you can skip to _Running_.
Version >9.5 is needed. Installation instructions at:
https://www.postgresql.org/
### Installing Docker
## Install dependencies
Install docker and docker-compose. On Ubuntu you can install Docker from the repositories but docker-compose must be installed separately.
The following Debian packages are needed.
If you're using something else, find the corresponding packages
from your distribution's repository.
```BASH
sudo apt-get install docker
```
Navigate to [docker-compose releases](https://github.com/docker/compose/releases) for install information.
* python3-dev
* libffi-dev
* python3-cffi
* libssl-dev
### Configuring db image
```BASH
sudo docker-compose up db
```
Then configure following with another shell window
```BASH
sudo docker exec -ti <image_name> bash # image name can be found with sudo docker ps (probably web20_db_1)
mysql -u root -p # then enter root password ("toor" by default) which can be found in docker-compose.yml
```
```SQL
CREATE USER 'sik'@'%' IDENTIFIED BY 'password123';
CREATE DATABASE sik DEFAULT CHARACTER SET utf8 DEFAULT COLLATE utf8_general_ci;
GRANT ALL PRIVILEGES ON `sik\_%` . * TO 'sik'@'%' IDENTIFIED BY 'password123';
GRANT ALL PRIVILEGES ON sik.* TO 'sik'@'%';
```
Then CTRL-D away from Docker bash shell and shut down database image with CTRL-C.
### Windows specific stuff
1. `sudo` is naturally not needed before any command on a windows environment
2. Before configuring the web image, click on the taskbar docker icon. Activate "shared drives" -> "share the drive repository".
### Configuring web image
1. Copy settings-sample.py to settings.py in sikweb folder.
2. Configure at least the following settings
- DATABASES: use 'db' as host and use the same user and password as configured above
3. Run the following commands:
```BASH
sudo docker-compose run web python manage.py migrate
sudo docker-compose run web python manage.py makemigrations infoscreen members webapp
sudo docker-compose run web python manage.py migrate
sudo docker-compose run web python manage.py createsuperuser
```
### Starting the dev unit
Install them with apt:
```
sudo docker-compose up
sudo apt install python3-dev libffi-dev python3-cffi libssl-dev
```
Now you should have a dev environment running on localhost:8000
NOTE: As your working directory (web2.0) is mounted by images, changes will be reflected immediately: no rebuilding is needed. `migrate` and `makemigrations` must still be run separately. See examples above.
## Installation with python virtualenv
### Create a virtual environment for python
`virtualenv -p python3 virtualenv.sikweb`
### Activate virtualenv (assuming we are at the root of this repository and virtualenv is one level above)
`. ../virtualenv.sikweb/bin/activate`
### Install Mariadb and create necessary tables
#### Run the following commands to install dependencies and to run the mariadb installation script
## Create a virtual environment for python
```
sudo apt-get install mariadb-server libmysqlclient-dev python3-dev libffi-dev python3-cffi libssl-dev
sudo mysql_secure_installation
# Setup root password and say yes to all other questions
sudo mysql -u root -p
# Log in with your new password
virtualenv -p python3 ../virtualenv.sikweb
```
#### Create a user called 'sik' with password 'password123' and create the db
### Activate virtualenv
**PLEASE CHANGE THE PASSWORD TO SOMETHING MORE SECURE!**
Paste the following into the mysql client prompt:
```SQL
CREATE USER 'sik'@'localhost' IDENTIFIED BY 'password123';
CREATE DATABASE sik DEFAULT CHARACTER SET utf8 DEFAULT COLLATE utf8_general_ci;
GRANT ALL PRIVILEGES ON `sik\_%` . * TO 'sik'@'%' IDENTIFIED BY 'password123';
GRANT ALL PRIVILEGES ON sik . * TO 'sik'@'localhost' IDENTIFIED BY 'password123';
```
### Install required python modules
Assuming we are at the root of this repository and virtualenv is one level above:
```
pip install --upgrade pip
pip install -r requirements.txt
. ../virtualenv.sikweb/bin/activate
```
## Configure Django settings
## Install wizard
`cp sikweb/settings-sample.py sikweb/settings.py`
Change the following fields in sikweb/settings.py if you are not using the default values:
Run the install wizard with
```
NAME (default: sik)
USER (default: sik)
PASSWORD (default: password123)
sh setup.sh
```
under DATABASES -> 'default' around line 80.
## Run migrations
`./manage.py migrate`
You should be now have succesfully set up a development version of SikWeb 2.0
and follow the instructions.
## Running
### Activate virtualenv
Assuming we are on root of this repo and virtualenv is one step above:
`. ../virtualenv.sikweb/bin/activate`
### Use runserver command
`./manage.py runserver`
```
python manage.py runserver 0.0.0.0:8000
```
or
Using address 0.0.0.0 will bind all IP addresses.
`./manage.py runserver 0.0.0.0:8000`
### Visit the page
if you need to connect from anywhere else than localhost.
Visit https://localhost:8000 in your browser!
### Run unit tests
`./manage.py test -v 2`
```
python manage.py test -v 2
```
-84
View File
@@ -1,84 +0,0 @@
# SIKWEB 2.0
## Accessing the source
### Clone this repository and enter it
Set up your SSH key authentication in GitLab Profile Settings. Then clone the repository:
```
git clone git@sika.sahkoinsinoorikilta.fi:vtmk/web2.0.git
cd web2.0
```
Change to the development branch:
```
git checkout develop
```
### Local settings
Create your settings.py with default passwords
## Installation with Docker
### Installing Docker
Install docker and docker-compose. On Ubuntu you can install Docker from the repositories but docker-compose must be installed separately.
```BASH
sudo apt-get install docker
```
Navigate to [docker-compose releases](https://github.com/docker/compose/releases) for install information.
### Removing docker images (Optional)
This will remove your old docker images.
```BASH
sudo docker rm $(sudo docker ps -a -q)
sudo docker rmi -f $(sudo docker images -a -q)
```
### Setting up the system
This will setup the environment for you and run the migrations.
```BASH
sudo scripts/autoinstall.sh
```
### Start database
```BASH
sudo docker-compose start db
```
### Start local web at localhost/8000:
```BASH
sudo docker-compose up web
```
### Stop local web:
```
CTRL+C
```
### Stop database:
```
sudo docker-compose stop db
```
### Useful commands:
```BASH
sudo docker-compose run web python manage.py migrate
sudo docker-compose run web python manage.py makemigrations infoscreen members webapp
sudo docker-compose run web python manage.py migrate
sudo docker-compose run web python manage.py createsuperuser
```