How to force build in app deployments

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?




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.

Accepted 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" \
    "<app_id>/deployments" \
    -XPOST \
    -d '{"force_build": true}'

With the new DO serverless functions you could receive the Strapi webhook request and then trigger the deployment.