DevOps · Source Control

Source Control in a Dockerized Environment

In this blog, we’re trying to answer the question of how to maintain our source code in a collaborative environment when using Docker. Normally, we’d use a source control tool such as SVN or Git. However, it isn’t straight forward how to use such tools in a dockerized environment.

Let’s emphasize the distinction between docker and git. Docker provides a platform to run our applications; such as LAMP or MEAN stack for web development. On the other hand, git is a source control software to track changes in a collaborative environment.

IMHO I think the best solution is using Volume Mapping
Also I think it would be better if you have the code it self in a separate container created from a very slim image like alpine.
But you should worry how to prevent this container from exiting, as there would be no running process inside, so it would exit instantly
You can search for a script called container discovery wrapper
and in your Docker file you can have something like

ADD LOCAL_PATH/container-discovery-wrapper /bin/container-discovery-wrapper
RUN chmod +x /bin/container-discovery-wrapper
CMD /bin/container-discovery-wrapper \
  --command="/root/block-indefinitely" \
  --service-name="codebase" \
  --service-exposed-port=999 \
  --discovery-server="$DISCOVERY_SERVER"

References:

  1. https://ryanfb.github.io/etc/2015/07/29/git_strategies_for_docker.html
  2. https://rominirani.com/docker-tutorial-series-part-6-docker-private-registry-15d1fd899255#.1kd0877h1
  3. https://www.airpair.com/docker/posts/efficiant-development-workfow-using-git-submodules-and-docker-compose
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s