We have some projects which have multiple Dockerfiles — for example, a database container to be preloaded with test data and the application which will use that database. Obviously we can either build those manually using CI steps or split them into separate projects but it feels like there should be an easy way to say “Run Auto Build in directory1 and directory2”.
The documentation doesn’t appear to cover this and some of the past attempts I’ve seen were relatively old and involved enough copying from the Auto Build template that it’d be easier to just do the build manually.
Hi, as far as I can see, the Documentation Stages of Auto DevOps | GitLab doesn’t cover your scenario. It looks like Auto Build will not pick up multiple Dockerfiles from Subdirectories.
If a project’s repository contains a Dockerfile at its root, Auto Build uses docker build to create a Docker image.
I guess, there is no way to do Auto Build for such a scenario - I personally would recommend implementing the Steps manually.
I ended up doing something like this, where I have a main app container that Auto-build picks up, and then nginx and varnish containers built by their own jobs. I made an abstract job that inherits from Auto-build and copies from its script. I added a variable there called CONTAINER_NAME so multiple containers would get pushed with different names. Then I extended that into two jobs with different variables. The result is three different container names in the same registry.
I tried using your .gitlab-ci.yml but I have a little problem, instead of only two builds, it makes a third build with no argument. Is there a way to have only the two build nginx and varnish without the default one ?