-
visitors_main is the project repository where the web app files reside.
-
Created a dockerfile inside the root of the repository as below:
-
'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
-
'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.
- 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.
- Next, I have build the docker image by running '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.
- Next I have run 'docker-compose up' which builds, (re)creates, starts, and attaches to containers for a service.