How to Control Build Order for app and web Workloads
search cancel

How to Control Build Order for app and web Workloads

book

Article ID: 409905

calendar_today

Updated On:

Products

VMware Tanzu Platform - Cloud Foundry

Issue/Introduction

If your configuration is as follows:

  • Uses two workloads: app and web.
  • Both workloads reference the same source repository.
  • Both workloads automatically build when committed to a specified branch.
  • The web Dockerfile retrieves files from the app image using COPY --from=<workloadname>:latest.

Due to the long build time of the web workload, the build sometimes currently completes in the order web → app. Need to control the build in the order app → web.

Resolution

Resolution: Stop copying from one image to another

 

The dependency comes from this line:

COPY --from=supplychainpkgprod.******/tap/workloads/<workloadname>:latest /src/app/static/dist /var/www/static/dist



If the web workload uses a Dockerfile, then the app workload does too. Both workloads/dockerfiles have access to the same code repo.

So you can just copy the lines from app's Dockerfile that create that /src/app/static/dist, put those commands into the web workload. Then no more dependency of web on app.

e.g. instead of the web Dockerfile having:

COPY --from=supplychainpkgprod.******/tap/workloads/<workloadname>:latest /src/app/static/dist /var/www/static/dist


It would have

FROM base as app-rebuild

    RUN some-build-instructions

FROM base as web

    COPY --from=app-rebuild /src/app/static/dist /var/www/static/dist