Enable use of sqlite as dev db without it polluting the git repo
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
Installation with Docker
One click install
Run the one click installer
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.
Installing Docker
Install docker and docker-compose. On Ubuntu you can install Docker from the repositories but docker-compose must be installed separately.
sudo apt-get install docker
Navigate to docker-compose releases for install information.
Configuring db image
sudo docker-compose up db
Then configure following with another shell window
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
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
sudois naturally not needed before any command on a windows environment- Before configuring the web image, click on the taskbar docker icon. Activate "shared drives" -> "share the drive repository".
Configuring web image
- Copy settings-sample.py to settings.py in sikweb folder.
- Configure at least the following settings
- DATABASES: use 'db' as host and use the same user and password as configured above
- Run the following commands:
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
Install Mariadb and create necessary tables
Run the following commands to install dependencies and to run the mariadb installation script
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
Create a user called 'sik' with password 'password123' and create the db
PLEASE CHANGE THE PASSWORD TO SOMETHING MORE SECURE!
Paste the following into the mysql client prompt:
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
pip install --upgrade pip
pip install -r requirements.txt
Configure Django settings
cp sikweb/settings-sample.py sikweb/settings.py
Change the following fields in sikweb/settings.py if you are not using the default values:
NAME (default: sik)
USER (default: sik)
PASSWORD (default: password123)
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
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
or
./manage.py runserver 0.0.0.0:8000
if you need to connect from anywhere else than localhost.
Run unit tests
./manage.py test -v 2