Docker containment
To make it easier to deploy on a live server and develop on a different environment we'll dockerize our projects. If you are not familiar with Docker you best read up on it here. But to simplify Docker allow us to run everything in a virtual environment so there no complication caused running on different systems.
We'll need to add a couple of files for this. starting with a requirment.txt, This file will contain all the added dependencies for python. Currently we're only adding Django but if we later use more we just simply add it here and Docker will install all of them with PIP.
Our file looks like this:
Now it time to make the Dockerfile that will setup our environment. This will setup up the working directory and install the dependencies listed in requirment.txt and looks like this:
Last is the docker-compose.yml file. This will setup all our docker images. This is only our web for now.
There we go, we've Dockerized our project, to run it with docker run these two command.
- docker-compose build
- docker-compose up -d
If anything went wrong you can't find it in the log with
- docker-compose logs -f
Comments
Post a Comment