Best practice using Dockerfile with docker-compose and vcs

I have a question regarding best practice.

Lets say I have a webfrontend developed in angularjs and a api to get data from. I put those two in separate repositories.
Now I want to dockerize the whole thing. My idea was to put a Dockerfile in each project which specifies their environment. Until now its fine but what when I also have a docker-compose file which starts those two services simultanously? First of in which repo should I put this file and secondly how can I assure, that the images are always uptodate?

  • Set up Docker Swarm on an EC2
  • Running `bash` using docker exec with xargs command
  • Django in Docker using PyCharm
  • Accessing Docker containers and KVM VMs through VPN
  • Container doesn't ping with OpenVSwitch and Ryu controller
  • Docker Compose In Production
  • Docker cp: Error response from daemon: lstat no such file or directory
  • Error while deploying Apache Storm to AWS
  • How to push/build a docker image in release process via sbt-release
  • How to use Docker in sbt-native-packager 0.8.0-M2 with Play
  • How to install a non-distro package inside Docker without wasting space?
  • How to send a curl in Docker Remote API?
  • One Solution collect form web for “Best practice using Dockerfile with docker-compose and vcs”

    You can use a structure like this:

     - project/docker-compose.yaml
     - project/frontend/ (contains Dockerfile + necessary files)
     - project/api/ (contains Dockerfile + necessary files)

    In your docker-compose.yaml you can write something like this for each image:

      build: ./frontend #folder in which Dockerfile of frontend is saved (to build the image)
      image: my-frontend:1.0 #give a name to your image
    container_name: frontend-container #containername when a container instance of your image is running

    To start docker-compose you can run docker-compose up --build. The --build tag will recreate your images when there are changes so you can keep your compose up to date when there are changes in the dockerfile (image).

    Docker-compose is ‘reading’ from up to bottom. So the service you describe first in your docker-compose.yaml will be created first. I would think it’s your API because that can probably exist on its own and your frontend needs to connect with it. Sometimes your first service is started too slow, which means the second service is already up but can not find the first service (to connect with) and it crashes. This can be solved by using a script. Your second service will use the script and check when the first service is up. When it’s up, it will start its own service.

    Docker will be the best open platform for developers and sysadmins to build, ship, and run distributed applications.