0

I'm working with git and docker and wanted some advice as to how I should implement my project.

The project has these functional components:

  • Web scraper (info scraped gets thrown into a database, which must be shared by all components)
  • Basic data analysis on scraped content (reads from database)
  • Statistical analysis and simulation (reads from database)

I want to be able to do something like

"git pull web_scraper"

from within a docker image and only have the files from the web scraper component.

I am pretty sure this can be done very easily with branches, but I am not sure how.

Edit 1

My question is more geared towards git than docker. I am figuring that out pretty well.

-prj
|  +scraper
|  +analyzer
|  +statistics

I want to know whether I should have a git repository for just prj or initialize one within scraper, analyzer, and statistics.

I am loving docker, but just want to have the ability to edit code on a nice editor (sublime).

4
  • Why would you run git pull in your docker image? Whether you are doing this during docker build or after running the container that is a bad practice 99 percent of the time. Commented Feb 10, 2015 at 6:36
  • I am using the docker image as virtual environment where all of my project's code is on, with consistent library placement, so that when I need to share or use the code on another system all I have to do is open that docker image. Commented Feb 10, 2015 at 6:50
  • That sounds like a much better use-case for Vagrant than docker. I personally prefer docker but it does require you to buy in to the "docker way" (which you are not following if I understand your last comment) whereas Vagrant leaves everything up to you. Commented Feb 10, 2015 at 6:54
  • Why do you say that? From what I understand docker is very flexible, really its just a container to ship code. Isn't that exactly what I'm doing? Why is pulling code via git bad practice? Commented Feb 10, 2015 at 20:50

1 Answer 1

1

This is a very broad question, however something to consider from a docker perspective is that you can have as many components as you'd like each in a separate folder with a Dockerfile representing the image for that component. Here's a hypothetical example:

-prj
|- base
| + Dockerfile
|- scraper
| + code
| + Dockerfile
|- analyzer
| + code
| + Dockerfile

This would all be in the same branch, you never want to use branches to maintain separate components of your project, that's not what they were designed for.

It really makes no difference whether you have 1 project as I described above or many. It's purely your personal preference, and a matter of how you prefer to modularize stuff. From a git perspective it makes no difference, and from a docker perspective it makes no difference. The only constraint here is that docker images need to have (for now) one Dockerfile per folder.

I'm not sure what your choice of editor has to do with any of this so I'm sensing there's something you're assuming about the docker workflow that is not correct. The way you develop stuff is to make changes to your image's source (with any editor you want) then rebuild that image (docker build). To test you docker run that image. Tools like fig (soon to be renamed to docker-compose) can help with the build/test cycle quite a bit.

Sign up to request clarification or add additional context in comments.

2 Comments

So you are saying that I should modify the docker build file? How is that different than just using a Vagrantfile? What do you gain from using docker if you are just modifying a image build file? I have been modifying my docker image by doing a (docker run -i -t image) and then committing if the changes I made are correct.
Sorry this question is branching out too far, sounds like you can break them up into several questions. To wrap up: It sounds like you want to create multiple git projects so you can git clone them individually. Do not use git branches to store different modules.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.