We use here python
and pip
, but if you have python 2 installed in your system you may change them for python3
and pip3
.
Instal dependencies:
sudo apt install -y python3 python3-pip mysql-server libmysqlclient-dev
You could also want to install mysql-workbench, so you can inspect database with an UI.
sudo apt install -y mysql-workbench
Install python. Ensure you select "Add Python 3.6 to PATH" before selecting "Install Now" or "Customize installation". If you choose customize installation, you should select at least pip.
Install mysql-server. You could not want to install all the package. You need at least MySQL 5.7 and you could also want to install MySQL Workbench, so you can inspect database with an UI.
As we use redis for the channel layer of websockets, we need this service working on the correct port. To use it we have two options. We only use websocket for the chat feature, so if you don't run this service the only feature affected is the chat.
The easier way. With docker installed, just run this command to get redis working:
docker run -p 6379:6379 -d redis:2.8
If you want install it in a linux enviroment, use those commands:
wget http://download.redis.io/releases/redis-2.8.24.tar.gz
tar xzf redis-2.8.24.tar.gz
cd redis-2.8.24
make
You can use redis now using this command in the same folder:
src/redis-server
If you want to use redis on windows you should install the non official port. You can download the installer here. Make sure you select add to the path when installing it.
To run the service, open a terminal and execute:
redis-server --maxheap 150M
Then go to your repository folder and execute:
pip install pypiwin32
Open a terminal at repository folder:
pip install -r requirements.txt
mysql -u root -p < create_db.sql
You should input your mysql root password.
You could also open and run this scipt from mysql-workbench.
Once database is created, you can generate tables for our model with this command:
python manage.py migrate
You also can populate it with some testing information with:
python populate.py
Use this command to mount localhost server. You can access at port 8000.
python manage.py runserver
Some test cases can be automated. In order to run all our test use this command:
python manage.py test mvp.test
We are using docker so deployed system should work in the same way as it does in local. The system has two services, the django web service and the database. We use a docker compose file with the mariadb image for the database and a dokerfile that we build for django. This dockerfile use an ubuntu image and install apache on it with mod_wsgi in order to deploy django system.
It's important change some settings of django in a production environment, so we use environment variables in docker compose to define those settings.
The deployed system is at http://artinbar.es