Is it possible to satisfy all of these requirements at once?
- Use the multi-stage builder pattern
- Use a dynamic image name in the final FROM image
- Don’t bust cache for all the builders with every change to the final FROM image name
It seems to bust cache for any change to the BASE_IMAGE
argument, which is unnecessary and inefficient.
ARG BASE_IMAGE
##### Stage: Build cfredis library #############################################
FROM gradle:4.10-alpine as cfredis-builder
...
##### Stage: Build CFSolrLib ###################################################
FROM gradle:4.10-alpine as cfsolrlib-builder
...
##### Stage: Build DocBox ######################################################
FROM gradle:4.10-alpine as docbox-builder
...
##### Stage: Build IEC PDF Generator ###########################################
FROM maven:3.6.0 as iec-pdf-generator-builder
...
##### Stage: Get POI Libs ######################################################
FROM gradle:4.10-alpine as poi-builder
...
##### Stage: Build Redis Lucee Extension #######################################
FROM kmindi/openjdk-ant-docker as redis-extension-builder
...
##### Stage: Build TestBox #####################################################
FROM alpine:3.8.4 as testbox-builder
...
##### Stage: Build Lucee #######################################################
FROM ${BASE_IMAGE}
...
###### Include 3rd-party libs ######
COPY --from=cfsolrlib-builder /tmp/dist /app/lib/cfsolrlib
COPY --from=docbox-builder /tmp/dist /app/lib/docbox
COPY --from=iec-pdf-generator-builder /tmp/dist /app/lib/iec-pdf-generator
COPY --from=poi-builder /tmp/lib /app/lib/poi
#==================================#