
Then it will expose port number 5000, and makes start.sh (which we will shortly create ) shell script executable and runs it. Then it will create a virtual environment and install all python dependencies needed from the requirements.txt file (which we will create next). Then installs all necessary packages to run Django and interact with MySQL server. It uses the official ubuntu 18.04 Docker image as the base image.

This file is the instruction for the deployment of a production-grade Django application. RUN /venv/bin/pip install -r requirements.txt Mysql-client libsqlclient-dev libssl-dev default-libmysqlclient-dev Python3 python3-dev python3-dev python3-pip python3-venv python3-wheel \ RUN apt-get update & apt-get -y install \ So we need to create a file at the root of the project and name it Dockerfile, (notice the capital D letter).

Docker uses a Dockerfile as the instruction for building and running your application. Doprax deploys your Django application on Docker. You don’t have to use Docker for your development environment although we strongly suggest it. Add Dockerfileĭocker is arguably the best way to package and deploy software these days and it is gaining huge popularity. So we must not forget to add these environment values later when we create a project in doprax. So when the Django project runs in production, it will read the value of DB_PASS and DB_HOST dynamically. Notice that we have not entered the password and host of the database, instead, we are using environment variables. # 'NAME': os.path.join(BASE_DIR, 'db.sqlite3'), # 'ENGINE': 'django.db.backends.sqlite3', Open settings.py file and find DATABASE section. This way you can avoid the overhead of installing and configuring MySQL server locally and for production, you can use doprax MySQL service which does not need any installation.

You can use SQLite for your local development and MySQL in production. If you want to have MySQL for local development you need to install it on your machine.

So we are going to configure the Django application to use MySQL as the database server. It should look like this: Config Django to use MySQLĪs I mentioned earlier, the default database server used in Django is SQLite, Which is only for development and test and is NOT suitable for production websites. No open your browser and go to this link ( ). If you want to add a custom domain to your project, like, you need to add it also to the ALLOWED_HOSTS list like this ALLOWED_HOSTS =. Notice that we have used a wildcard for allowed hosts, meaning that every domain name ending with is acceptable.
