I am building a Laravel App, which runs great on the App Platform.
It has a service, two workers (schedule:work and queue:work) and a pre-deploy job (migrate).
They use the same code, env variables, etc., but it looks like they are building one after another, wasting tons of time.
How can I build one image (maybe as a pre-deploy job) and use it in the service, workers and pre-deploy job containers?

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

×
Submit an Answer
2 answers

We do support build reuse between components as long as we can determine there are no differences in the spec that would affect the build phase.

For example, you can modify the run_command between two different components and it will share the build, but if the build_command or commit_hash was different, then we would have to issue a new build for each component.

Procfile is also supported and you can create a file similar to the following in order to specify a default run_command for your component:

web: bin/sample-golang

In your case, it sounds like something is causing us to detect a difference in the build key for reusing builds between your components. Is it possible for you to provide a sanitized version of your app spec for us to view? Alternatively, you can reach out to support with more detailed information and we can take a look at your specific application.

In general though, you should be able to achieve your approach by just changing the run_command for each of your components and leaving the rest of the configuration between the components the same.

Btw, it takes almost 20 minutes for a deployment, because it builds tons of images.
With heroku I could simply use a Procfile with a few lines in there.
Is there no way to achieve the same?