Triggered Automatic builds using tag from parent image

This is a Ruby on Rails project if it matters. We have an automatic build setup to build project_base. This copies the project code into the image but does not setup a web server or any of the background process. It also bundles the Gem files which is the time consuming part of the build. I would like to have a project_web and project_worker to create two new images from the base image. These are what we will create containers from.

I have setup automatic build repositories for the two sub projects, which are triggered from the base repo. These do get built, but I am seeing two issues related to tags. I would like to build the linked repos with the same tag as the parent. I would also like to ensure they linked repos are built using the tagged version of the parent repo, so I need the tag accessible in the Dockerfile.

In other words I want a fully automatic build flow where a tagged version on github builds a tagged/versioned base image which is then used to build tagged/versioned images derived from the tagged base image.

Is this possible? I’m new to Docker. What I’m trying to do may be better solved with another design pattern, so any advice in that regard would also be welcome.