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?

  • Tag docker image after bitbucket Webhook
  • How do I pass the host's IP address to my container in Docker
  • Why set VISIBLE=NOW in /etc/profile?
  • How can I make `avahi` work outside when `netatalk` running inside docker on `ubuntu`?
  • How to update modifications after a page reload on Docker?
  • How can I use Hashicorp Vault to manage my application secrets?
  • Docker compose can not create container for postgresql and redis
  • Unable to install Npsql via nuget
  • datapower cannot be installed in docker
  • What is the correct way to deploy EAR on Weblogic with Docker
  • Installing Islandora-claw's docker image
  • Pass local environment variable to docker
  • 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.