Question

How to target a particular stage in a Docker image using App Platform?

I’m trying to create a new project using DigitalOcean’s App Platform with a monorepo. I’m loosely following this guide on how to structure the project, but I’m not sure how to target a particular build step within DigitalOcean.

This is the Docker command:

docker build . --target app1 --tag app1:latest

This is how I would target it in docker compose:

version: '3.8'
services:
    web:
        container_name: sample-app1
        image: sample-app1
        build:
            context: .
            target: app1
        ports:
            - '3000:3000'

Is there a way I can configure this using the App Platform?


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.

Bobby Iliev
Site Moderator
Site Moderator badge
November 27, 2023
Accepted Answer

Hey @aplato,

I believe that this is not available as an app spec argument yet:

https://docs.digitalocean.com/products/app-platform/reference/app-spec/

The best thing to do to get your voice heard regarding this would be to head over to our Product Ideas board and post a new idea, including as much information as possible for what you’d like to see implemented.

https://ideas.digitalocean.com/

For the time being, since the docker_build_target attribute is not supported yet, you would need to structure your Dockerfile to have the desired target stage as the last stage in the Dockerfile when using the App Platform. That way, the App Platform builds the final image based on the last stage of your Dockerfile by default.

Alternatively, you can build your Docker images externally (using GitHub Actions, GitLab CI/CD, or another CI/CD tool), push the images to a container registry (like Docker Hub or DigitalOcean Container Registry), and then deploy the pre-built images to the App Platform.

Hope that helps!

- Bobby.

Try DigitalOcean for free

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

Sign up

Become a contributor for community

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

DigitalOcean Documentation

Full documentation for every DigitalOcean product.

Resources for startups and SMBs

The Wave has everything you need to know about building a business, from raising funding to marketing your product.

Get our newsletter

Stay up to date by signing up for DigitalOcean’s Infrastructure as a Newsletter.

New accounts only. By submitting your email you agree to our Privacy Policy

The developer cloud

Scale up as you grow — whether you're running one virtual machine or ten thousand.

Get started for free

Sign up and get $200 in credit for your first 60 days with DigitalOcean.*

*This promotional offer applies to new accounts only.