I want to create a two step multistage build as follows:
1- Dockerfile -> contains all common tools installed
2.1- Dockerfile.extensionA -> contains tools only used in Application A
2.2- Dockerfile.extensionB -> contains tools only used in Application B
This way, instead of having two huge Dockerfiles, one for A and one for B, which are 90% alike, I have one base big Dockerfile and two (or more) small specialization Dockerfiles, so I can generate two images that share most of the installation, so if only appA is needed, only the extentions for appA are installed:
- image_appA
- image_appB
- ...
The contents might be something like:
Dockerfile
FROM ubuntu:20.04 AS BASE_IMAGE
... base configuration common for all extentions
.
Dockerfile.extensionA
FROM BASE_IMAGE
... specific config for A
.
Dockerfile.extensionB
FROM BASE_IMAGE
... specific config for B
And so I would like to do something like:
$ docker build -t image_appA -f Dockerfile.extensionA .
And get a sequential build Dockerfile and Dockerfile.extensionA
ADD: Before marking as duplicated, I've researched Multistage builds in Docker extensively but all I can find is the idea of picking stuff from the base image. But I want to inherit the full base image, and build on top of it the extension for appA, appB or any other