Question

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!

Show comments

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.

Want to learn more? Join the DigitalOcean Community!

Join our DigitalOcean community of over a million developers for free! Get help and share knowledge in Q&A, subscribe to topics of interest, and get courses and tools that will help you grow as a developer and scale your project or business.

@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
static_sites:
- name: site
  github:
    repo: digitalocean/sample-dockerfile-static
    branch: master
  envs:
  - key: API_URL
    value: https://api.example.com
    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!