Question

How do I specify which Dockerfile is to be used for each app's components?

I have a monorepo, which has 2 directories for each project. Now, they have their own Dockerfiles (so bot/Dockerfile and api/Dockerfile), and I would like DigitalOcean to build using the relevant dockerfile, so if I have 1 app called tags-api, it will use api/Dockerfile to build, and vice versa for bot.

Now my question is, how do I do so? Since currently it just checks for ./Dockerfile, which, in this case doesn’t exist.

Alternatively, could it possibly use my docker-compose file? I have a ./docker-compose.yaml file but I couldn’t find an option where I could use compose instead of Docker.


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.

Accepted Answer

Hi there,

You should be able to use the dockerfile_path directive in your App Spec definition. The path to the Dockerfile is relative to the root of your repo. If set, it will be used to build this component. Here is an example:

name: sample-dockerfile
services:
- name: web
  git:
    repo_clone_url: https://github.com/digitalocean/sample-dockerfile.git
    branch: main
  dockerfile_path: Dockerfile

There is no need to use docker-compose you would just have to define all of your services in your app spec file as separate components instead.

Here is a reference to the documentation that might be helpful as well:

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

Let me know how it goes!

Best,

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.