My Problem
I have an app with 3 containers - a DB, a tester, and a server. My code structure is as follows:
.
├── Makefile
├── docker-compose.yml
├── docker
│ ├── docker-compose.yml
│ ├── postgres
│ │ ├── Dockerfile
│ │ └── create_fixtures.sql
│ ├── server
│ │ └── Dockerfile
│ └── tests
│ └── Dockerfile
├── server
│ ├── __init__.py
│ └── server.py
└── tests
├── __init__.py
└── test.py
I would like to keep all docker data inside the docker directory but have the build context set to the root directory so that it can copy the server and tests directories to their respective images.
What Have I Tried
Does not work
$ docker-compose -f docker/docker-compose.yml up
failed to solve with frontend dockerfile.v0: failed to read dockerfile: error from sender: resolve : lstat /Users/adamatan/repos/anda-app/docker/docker: no such file or directory
In other words, the build context seems to be the location of the docker-compose file. I want to decouple it.
Works
$ docker-compose up
Which takes the docker-compose.yml file from the root dir.
This has been reported in Docker's git repo, but I'm not sure if there's a good way to overcome it.
My Question
How can I set the build context of a docker-compose up action to a root directory, but use a docker-compose.yml file from one of its subdirectories?