Question

How do I use the same image for multiple containers in App Platform

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?


Submit an answer


This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Sign In or Sign Up to Answer

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.

Nick Tate
DigitalOcean Employee
DigitalOcean Employee badge
January 18, 2021
Accepted Answer

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?

Try DigitalOcean for free

Click below to sign up and get $200 of credit to try our products over 60 days!

Sign up

Get our biweekly newsletter

Sign up for Infrastructure as a Newsletter.

Hollie's Hub for Good

Working on improving health and education, reducing inequality, and spurring economic growth? We'd like to help.

Become a contributor

Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.

Welcome to the developer cloud

DigitalOcean makes it simple to launch in the cloud and scale up as you grow — whether you're running one virtual machine or ten thousand.

Learn more
DigitalOcean Cloud Control Panel