Reputation: 139
Currently I have a project (repo) in Gitlab which is an angular app. I'm using Gitlab CI/CD to build, test, release and deploy. Releasing will build a new docker image pushing it to the Gitlab registry and after deploying it on NGinx in a docker container on my Digital Ocean droplet. This works fine.
Let's say I want to add a backend to it like the MEAN stack so I would have 2 containers running using a docker-compose file.
The 2 gitlab projects (repo's) will have to be build separately when a change occurs (own Dockerfile and gitlab-ci.yml file) but deployed together using the docker-compose file.
Where do I manage/put the docker-compose file?
I hope my explanation is clear and if I'm assuming correctly.
Thanks in advance.
Upvotes: 3
Views: 2507
Reputation: 14733
According to your comment I understand you'd be interested in adopting a monorepo configuration.
In this case, for the question
Where do I manage/put the docker-compose file?
you could just put the docker-compose.yml
file at the root of your GitLab CI project, which would lead to a directory structure like this:
monorepo-project/
├── backend/
│ ├── Dockerfile
│ ├── .dockerignore
│ └── src/
├── frontend/
│ ├── Dockerfile
│ ├── .dockerignore
│ └── src/
├── docker-compose.yml
├── .git/
├── .gitignore
└── .gitlab-ci.yml
As pointed out in https://docs.gitlab.com/ee/user/packages/workflows/monorepo.html (the original version of this page, deleted by this commit, is still available at this URL), you can tweak your configuration using the changes:
key, so that if just one part of the project changes (e.g., the frontend), then the CI behaves accordingly.
For more examples, see e.g. this article in Medium which specifically relies on Docker, or that blog article which takes advantage of the needs:
key.
Finally, the semantics of the GitLab CI YAML conf file is well-documented in https://docs.gitlab.com/ee/ci/yaml/ (to be bookmarked!).
Upvotes: 4