Reputation: 3288
I am using Django with Gunicorn daemon and Nginx for proxy and static files. I have a very simple Fabric script to "automate" some actions:
There is already a problem with this, for example for the first deploy, I need to clone from GitHub manually.
Now, we are in a stage that our application will be sent out to our clients so that they can host their own servers (and we might need to scale in the near future). They require Docker containers to deploy on their own servers. I will have ssh connection to their servers to update the deployment of our application.
However, I am having hard time to figure out what might be the optimal way to automate this, i.e. the sequence of the actions I need to take every time we have a new release using Fabric.
Upvotes: 1
Views: 1664
Reputation: 1661
My recommendation would be create a Dockerfile and on each commit to a release branch have some sort of continuous integration server (Jenkins, CircleCI, etc) pull your code, run a set of tests, then build and release a new Docker image. You might want it to be private if you require payment - that's easy enough to do, you can set up a private docker registry. You might even find this to be a better workflow than your current internal one, given it's all automated.
Here is an example of what your Dockerfile might look like:
FROM debian:stable
ADD . /code
WORKDIR /code
RUN apt-get update && apt-get install -y python-dev
RUN pip install -r requirements.txt
CMD python run.py
This is just an example, I have no idea how your code is structured, but it assumes that the Dockerfile is peered with a script, run.py, that knows how to get things running. It also assumes you want to use debian:stable - there are lots of options there and you need to choose what works best for you. It also assumes you have your dependencies organized in a requirements.txt file. Finally, I just threw the apt-get in there to show how you can run arbitrary commands and might install python's dev stuff.
Depending on how complicated the fabric script is, the Dockerfile could completely replace it, or you can also run the fabric script as a step in the Dockerfile.
You can find more information about the Dockerfile format here: https://docs.docker.com/engine/reference/builder/
EDIT: I should add - obviously there is a little bit of decision making you'll need to make regarding how you support having nginx in the mix, because the typical docker way would be to have that as a second image and container - that's easy enough to do (and in my opinion a better architecture than having it all in one machine as it currently seems to be) but it would require some attention.
Upvotes: 3