Skip to main content

Multi-app with root build tasks

Comments

1 comment

  • Chad Carlson

    Hi Alexander. I've been experimenting with this recently, but I'm not sure. To start I would recommend:
     

    # applications.yaml
    - name: frontend
      type: "nodejs:XX"
      build:
          flavor: none
      hooks:
          build: |
              pnpm i
              pnpm build
          deploy: |
              pnpm deploy --filter "@project/frontend" --prod
       ...
    
    - name: backend 
      type: "php:XX"
      build:
          flavor: none
      hooks:
          build: |
              pnpm i
              pnpm build
          deploy: |
              pnpm deploy --filter "@project/backend" --prod
      ...

    1. Both apps do go through the same build hook steps, which I know is not what you're looking to do. That said, our build system tracks changes to trees, so if (for example) after a longer initial build of both apps you pushed changes just to the frontend app, our platform is smart enough to only rebuild the frontend app (reusing the build image that has not changed for the backend). 

    2. What you can explore is the Build cache. Similar to what you have here there is a cache directory (/.tmp) that is accessible during and between builds. (Here is a gist leveraging it for installing node versions using nvm, and the variables docs for it). That could be a path to explore here. I will say that in my experiments I have found two things that might block you. First, PLATFORM_CACHE_DIR is shared across all environments. It's not an unfixable problem, but you may need an identifier in place to say “this build belongs to this environment/state” if needed. Second, PLATFORM_CACHE_DIR does not appear to be shared between applications. This is where I hit a speedbump in what I was trying to do recently, and the thing to experiment with on your specific problem. 

     

    Hope this at least helps you get started, feel free to let me know how it goes.

    Chad C. 

     

    0

Please sign in to leave a comment.