Search code examples
gitdockerproduction-environmentdev-to-production

Version control - how to deploy code to production machines(without Internet and with docker)?


OK this bugs me a lot: how to deploy to machines without Internet connections and using docker?

The production machines don't have Internet connection due to security concerns, which is reasonable. So, we use a jump machine to connect to it and upload our code.

And, the production project is within Docker container, so even if we make a little change, we have to rebuild it all. Or, docker cp to all the files we changed.

We do version control with Git, in a machine in dev environment; all team members have access to it, within our network, but the production machine cannot connect to it directly. (Yes, it can, but needs jump machine, too)

So, as I understand, in this situation, if we want to deploy in a simple way(download code directy in docker exec), we have to create a Git repo in the machine of jump, right? Is there any better solutions? I am new to docker.

And, if we have a .git folder pointing to the dev environment Git repo, how do we configure it to point to jump machine? Change url and credentials every time we deploy? Ugly.


Solution

  • The standard Docker workflow is to build imaages and push them onto a Docker registry that stores all images. Then machines that need to deploy an image, will pull the image from the registry.

    If the machines don't have access to the internet you can deploy a private registry by simply deploying the registry docker image on one of your machines. When building images, you will then pull the code from Git and build the image and push it into this private registry.

    You can deploy the image on production machines by pulling the image from the private registry. It might be a good idea to deploy the Docker registry on the "jump machine" which is accessible from the production machines.