Merge branch 'docker' into 'develop'
Docker config See merge request !8
This commit is contained in:
@@ -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/
|
||||
@@ -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
|
||||
@@ -1,10 +1,6 @@
|
||||
# SIKWEB 2.0
|
||||
|
||||
## Installation
|
||||
|
||||
### Create a virtual environment for python
|
||||
|
||||
`virtualenv -p python3 virtualenv.sikweb`
|
||||
## Accessing the source
|
||||
|
||||
### Clone this repository and enter it
|
||||
|
||||
@@ -21,6 +17,72 @@ 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
|
||||
|
||||
```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 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
|
||||
|
||||
```
|
||||
sudo docker-compose up
|
||||
```
|
||||
|
||||
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`
|
||||
|
||||
|
||||
Reference in New Issue
Block a user