How to configure a Build Arg in App Specification for Docker-based service

Dear support, is there a way to configure one or more --build-arg values for a Docker-based service in the App Platform?

At the Docker build time, we pass arguments to fine-tune nginx configuration files. We use different Build Arg values for our development, staging, and production environments.

Also, it is not clear whether build_command happens after docker build, or is it actually the way to customize how docker build runs? Could you give some examples of using build_command with Dockerfiles?

Many thanks!


@snormoredo I am following the exact instruction you provided but still out of luck. The arg is empty.

@ReWild did it work for you ?

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

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.

@ReWild 👋

The way to accomplish this today would be to pass in build-time environment variables. If you’re creating envs through the UI, then they’re by default build-and-run-time variables. If creating via raw app spec and doctl, then you can choose one or both using the scope field. We don’t currently support passing --build-args directly, but this is a good idea that we’ll consider adding to the product — your feedback here helps.

An example of an app spec with build-time environment variables might look like this:

name: sample-dockerfile-static
- name: site
    repo: digitalocean/sample-dockerfile-static
    branch: master
  - key: API_URL
    scope: BUILD_TIME

Hopefully that’s a sufficient workaround in the meantime. Stay tuned to our product release notes for updates on this and other features.

Thanks for using the App Platform, and happy coding!