A
A
Artem Lisovsky2016-02-22 08:15:45
Django
Artem Lisovsky, 2016-02-22 08:15:45

How to organize the structure and deployment of a project with docker?

So, I made a dockerfile, threw a django project into it, launched it, debugged it and have a server with ssh access. How can I push my project to this server? How then to make changes in the code?
The project needs a database (where without it). According to the rules of good manners in docker, one more container is needed under the database. How to implement their connection or how to do better?
Thanks

Answer the question

In order to leave comments, you need to log in

6 answer(s)
N
Nikolai, 2016-02-22
@torrie

How can I push my project to this server?

There are two options:
1. through hub.docker.com
a) docker login to register on the docker hub (you can go in and make your project private so that others don't mind)
b) build your dockerfile using docker build
c) then docker push to send layers to your hub
d) then log in to the production server and do docker pull to download the layers
e) docker run
2. Just scp your Dockerfile and project files to the production server and do
docker build
You can read more about the commands in documentation - I just described the concept
It's simple - upload your project to any repository (github, bitbacker, gitlab ...), after making changes, just log in to the server, go to your docker container and run git pull to the desired directory, then build, etc. (any CI can be used to automate the process).
Very simple - add a new container (for example, docker pull mysql), on the hub you can see information about launching such a container https://hub.docker.com/_/mysql/ and connect to the database from your application via the internal network of your docer system (docker bridge).

D
Dmitry Lebedev, 2016-02-22
@k3NGuru

Here is a good article https://habrahabr.ru/post/272811/ that will answer many of your questions

V
Visphord, 2016-02-23
@Visphord

I made it a little easier (with fewer manual steps).
We have:
- c#
- Stateless applications
- a server with mongodb (it is not allowed to be taken to the docker).
- TeamCity.
What I did:
- I assembled a build agent under mono in a docker container, threw the host docker there.
- Build a basic runtime container with mono.
- I set up the build through the agent build from step 1, while the teamcity itself generates a Dockerfile (for c # they are typical).
- Raised a private docker registry.
- after that teamcity does docker tag, docker push to private repository.
- there is a watchtower on the machines of the cluster, which updates and restarts the containers when an update appears (but I do the first launch of a new service manually).
- in the projects themselves, in the git, I store compose files with links to other services\containers\env (there is still no great understanding with them - how and where to properly deploy them, where to store them - while lying around in /home/ on each machine in the cluster).

Q
Qilight, 2016-02-22
@Qilight

How can I push my project to this server?
Do not start, but connect the folder from the host where the code is located.
How then to make changes in the code?
In the editor.
How to implement their connection or how to do better?
Use docker-compose.

Y
Yuri S., 2016-02-22
@yucom

Here I posted an example of deployment using ansible for docker and rails in capistrano style, but you can tweak the playbooks for yourself https://github.com/weazar/andora

S
sokolnikov, 2016-03-03
@sokolnikov

I made two different docker files for myself - one for production, one for development. Their difference is that in the production version, in addition to setting up the environment, it also downloads (git clone) and deploys the application itself. And in the development version, the external directory with the code is mounted so that the life of the code does not depend on the life of the container.
It is better to organize the database in a separate container, with linking to the container with the application (linking is very well described in the documentation).

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question