From 160fa026bb49e132a7d44cb27161c06830cf54f9 Mon Sep 17 00:00:00 2001 From: Ilkka Oksanen Date: Fri, 24 Feb 2017 14:37:02 +0200 Subject: [PATCH 1/6] added docker config for develop settings --- Dockerfile | 7 +++++++ docker-compose.yml | 15 +++++++++++++++ 2 files changed, 22 insertions(+) create mode 100644 Dockerfile create mode 100644 docker-compose.yml diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..d1d6892 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.5 +ENV PYTHONBUFFERED 1 +RUN mkdir /code +WORKDIR /code +ADD requirements.txt /code/ +RUN pip install -r requirements.txt +ADD . /code/ diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..2f49025 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,15 @@ +version: '2' +services: + db: + image: mariadb + environment: + - MYSQL_ROOT_PASSWORD=toor + web: + build: . + command: python manage.py runserver 0.0.0.0:8000 + volumes: + - .:/code + ports: + - "8000:8000" + depends_on: + - db From 7e84c9fac7d236417dca50a9d32fe030159693d5 Mon Sep 17 00:00:00 2001 From: Ilkka Oksanen Date: Fri, 24 Feb 2017 15:01:37 +0200 Subject: [PATCH 2/6] add docker installation guide to readme.md --- readme.md | 51 ++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 50 insertions(+), 1 deletion(-) diff --git a/readme.md b/readme.md index 926e5ae..e2f5b5d 100644 --- a/readme.md +++ b/readme.md @@ -1,6 +1,55 @@ # SIKWEB 2.0 -## Installation +## Installation with docker + +### installing docker + +install docker and docker-compose. On ubuntu this can be done with + +```BASH +sudo apt-get install docker docker-compose +``` + +### Configuring db-image + +```BASH +sudo docker-compose up db +# then configure following with another shell window +sudo docker exec -ti bash # image name can be found with sudo docker ps (propably web20_db_1) +mysql -u root -p # then enter root password which is 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'@'%'; +``` +Then ctrl-d away from docker bash shell and shutdown db image with ctrl-c + +### Configuring web-image + +1. Fix your settings.py to use 'db' as host and correct user and password (configured above) +2. run following commands +```BASH + +sudo docker-compose run web python manage.py migrate +sudo docker-compose run web python manage.py makemigrations infoscreen members +sudo docker-compose run web python manage.py migrate +sudo docker-compose run web python manage.py createsuperuser +``` + +### starting dev unit + +``` +sudo docker-compose up +``` + +now you should have dev environment running on localhost:8000 + +NOTE: as your working dir (web2.0) is mounted by images changes will be reflected immediately. no rebuilding needed. migrations and makemigrations must still be run separately though. see examples above + + +## Installation to python virtual env ### Create a virtual environment for python From 817a96f7f87368c9a3962e42312d85aedb66bb86 Mon Sep 17 00:00:00 2001 From: Ilkka Oksanen Date: Fri, 24 Feb 2017 15:22:00 +0200 Subject: [PATCH 3/6] fix syntax typo in readme.md --- readme.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/readme.md b/readme.md index e2f5b5d..25a00a1 100644 --- a/readme.md +++ b/readme.md @@ -30,8 +30,8 @@ Then ctrl-d away from docker bash shell and shutdown db image with ctrl-c 1. Fix your settings.py to use 'db' as host and correct user and password (configured above) 2. run following commands -```BASH +```BASH sudo docker-compose run web python manage.py migrate sudo docker-compose run web python manage.py makemigrations infoscreen members sudo docker-compose run web python manage.py migrate From 700d08af55702b5b0b0d609bd13aabb3f19fb548 Mon Sep 17 00:00:00 2001 From: Ilkka Oksanen Date: Fri, 24 Feb 2017 15:38:12 +0200 Subject: [PATCH 4/6] add windows specific docker instructions and clarified few points --- readme.md | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/readme.md b/readme.md index 25a00a1..9a88c05 100644 --- a/readme.md +++ b/readme.md @@ -26,10 +26,18 @@ GRANT ALL PRIVILEGES ON sik.* TO 'sik'@'%'; ``` Then ctrl-d away from docker bash shell and shutdown db image with ctrl-c +### Windows specific stuff + +1. sudo is naturally not needed before any command on a windows environment +2. before configuring web-image, click on taskbars docker icons. and from shared drives share the drive repository is on + + ### Configuring web-image -1. Fix your settings.py to use 'db' as host and correct user and password (configured above) -2. run following commands +1. Copy settings-sample.py to settings.py on sikweb folder. +2. configure atleast following settings + - dbsettings: use 'db' as host and correct user and password (configured above) +3. run following commands ```BASH sudo docker-compose run web python manage.py migrate From 97e05316aec6bba85e66d609d7aa3da724f44cb8 Mon Sep 17 00:00:00 2001 From: Jan Tuomi Date: Fri, 24 Feb 2017 16:23:47 +0200 Subject: [PATCH 5/6] Be pedantic about readme.md --- readme.md | 43 +++++++++++++++++++++++-------------------- 1 file changed, 23 insertions(+), 20 deletions(-) diff --git a/readme.md b/readme.md index 9a88c05..1917cde 100644 --- a/readme.md +++ b/readme.md @@ -2,9 +2,9 @@ ## Installation with docker -### installing docker +### Installing docker -install docker and docker-compose. On ubuntu this can be done with +Install docker and docker-compose. On ubuntu this can be done with ```BASH sudo apt-get install docker docker-compose @@ -14,50 +14,53 @@ sudo apt-get install docker docker-compose ```BASH sudo docker-compose up db -# then configure following with another shell window -sudo docker exec -ti bash # image name can be found with sudo docker ps (propably web20_db_1) -mysql -u root -p # then enter root password which is in docker-compose.yml - ``` + +Then configure following with another shell window +```BASH +sudo docker exec -ti bash # image name can be found with sudo docker ps (probably web20_db_1) +mysql -u root -p # then enter root password 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 shutdown db image with ctrl-c +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 web-image, click on taskbars docker icons. and from shared drives share the drive repository is on +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 +### Configuring web image -1. Copy settings-sample.py to settings.py on sikweb folder. -2. configure atleast following settings - - dbsettings: use 'db' as host and correct user and password (configured above) -3. run following commands +1. Copy settings-sample.py to settings.py in sikweb folder. +2. Configure at least the following settings + - dbsettings: use 'db' as host and correct user and password (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 +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 dev unit +### Starting the dev unit ``` sudo docker-compose up ``` -now you should have dev environment running on localhost:8000 +Now you should have a dev environment running on localhost:8000 -NOTE: as your working dir (web2.0) is mounted by images changes will be reflected immediately. no rebuilding needed. migrations and makemigrations must still be run separately though. see examples above +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 to python virtual env +## Installation with python virtualenv ### Create a virtual environment for python From 878bca0ebaa9a2c80f95adaeeb7404827361ecf2 Mon Sep 17 00:00:00 2001 From: Jan Tuomi Date: Fri, 24 Feb 2017 16:31:31 +0200 Subject: [PATCH 6/6] More pedantry --- readme.md | 42 ++++++++++++++++++++++-------------------- 1 file changed, 22 insertions(+), 20 deletions(-) diff --git a/readme.md b/readme.md index 1917cde..ea49675 100644 --- a/readme.md +++ b/readme.md @@ -1,16 +1,33 @@ # SIKWEB 2.0 -## Installation with docker +## Accessing the source -### Installing docker +### Clone this repository and enter it -Install docker and docker-compose. On ubuntu this can be done with +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 +``` + +## Installation with Docker + +### Installing Docker + +Install docker and docker-compose. On Ubuntu this can be done with ```BASH sudo apt-get install docker docker-compose ``` -### Configuring db-image +### Configuring db image ```BASH sudo docker-compose up db @@ -40,7 +57,7 @@ Then CTRL-D away from Docker bash shell and shut down database image with CTRL-C 1. Copy settings-sample.py to settings.py in sikweb folder. 2. Configure at least the following settings - - dbsettings: use 'db' as host and correct user and password (configured above) + - DATABASES: use 'db' as host and use the same user and password as configured above 3. Run the following commands: ```BASH @@ -66,21 +83,6 @@ NOTE: As your working directory (web2.0) is mounted by images, changes will be r `virtualenv -p python3 virtualenv.sikweb` -### 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 -``` - ### Activate virtualenv (assuming we are at the root of this repository and virtualenv is one level above) `. ../virtualenv.sikweb/bin/activate`