Skip to content

SaiVamsiPuttu/dockerzing_django_project

Repository files navigation

Dockerising a simple web application built with Django and MySQL

Author - Sai Vamsi Puttu



  • visitors_main is the project repository where the web app files reside.

  • Created a dockerfile inside the root of the repository as below:



docker



  • 'FROM' creates a layer from the python:3.6 docker image

  • 'ENV PYTHONUNBUFFERED' creates a Environmental Variable called PYTHONUNBUFFERED and sets it to 1. Setting a value to PYTHONUNBUFFERED ensures that the python output is being sent straight to the terminal without being first buffered.

  • 'RUN mkdir /cloud_assessment1' creates cloud_assessment1 directory inside the file system of our container.

  • 'WORKDIR /cloud_assessment1' makes cloud_assessment1 as working directory

  • 'ADD requirements.txt /cloud_assessment1/' command will copy requirements.txt file from local repository to the docker container's filesystem



requirements



  • 'RUN pip install -r requirements.txt' will run pip install command for the list of applications that we require.

  • 'ADD . /cloud_assessment1/' copies all the files from the cloud_assessment1 repository to the container's filesystem

  • Next, I have created a YAML(Yet Another Markup Language) file called 'docker-compose.yml' where I specified configuration for my django web server and mysql database server.

docker-compose

  • I ran into a problem where my webserver was starting before my db server. To counter that I have created a shell script which allows the webserver to start only after the 'db' server is started.

image

  • Next, I have build the docker image by running 'docker build .'

docker_build

  • Next I have run 'docker-compose build': docker-compose build will read docker-compose.yml, look for all services containing in the build: statement and run a 'docker build' for each one.

docker-compose-build

  • Next I have run 'docker-compose up' which builds, (re)creates, starts, and attaches to containers for a service.

docker-compose-up-1

docker-compose-up-2

localserver up and running



Docker-run.mp4

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published