I have a Next.js app deployed as a web service on App Platform, because I want to take advantage of both its SSR and SSG capabilities. I’ve connected it to my CMS, which sends a webhook to Digital Ocean to trigger a redeploy when changes require a rebuild of the app.

However, DO will skip the build for any deploy in which the code doesn’t change. My question is, how can I force DO to rebuild on every deploy?

Thanks!

Justin

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.

×
1 answer

👋🏼 @ilonews

It’s possible to force build the app from source even if a previous build can be reused, however right now it is only available via doctl and the API. The web control panel should support it soon.

With doctl, as of the v1.52.0 release, you can pass the --force-rebuild option to the doctl apps create-deployment command.

If you are using the API, the POST /v2/apps/<app_id>/deployments route accepts a JSON document for the body. You can set the force_build option in it like so:

curl \
    -H "Content-Type: application/json" \
    -H "Authorization: Bearer TOKEN" \
    "https://api.digitalocean.com/v2/apps/<app_id>/deployments" \
    -XPOST \
    -d '{"force_build": true}'
  • Thanks @kamaln7! That solved my problem! I don’t think this is documented anywhere though. I would have expected to find it in the API Docs. Can you tell me what other options that endpoint expects?

    • I’m glad to hear! You’re right, it’s not in the documentation—it was only recently added and the documentation updates are in review and should be published soon. This is the only option that this endpoint accepts currently.

Submit an Answer