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

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