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

Featured on Community

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