Question

How to use the Apps build command for static site resources

I have a static site to deploy to Apps as a resource. The source is in the /src folder and I have an NPM launched NodeJS build script that outputs to /dist.

How do I specify my build script in the App Spec build_command property? I tried npm run build which works locally but errors in DO

[2022-09-05 22:32:36] => Initializing build
[2022-09-05 22:32:36] => Retrieving source code to /workspace
[2022-09-05 22:32:36] => Selecting branch "main"
[2022-09-05 22:32:36] => Checking out commit "<redacted>"
[2022-09-05 22:32:36] => Got source_dir: src
[2022-09-05 22:32:36] => Using workspace root /workspace/src
[2022-09-05 22:32:36] 
[2022-09-05 22:32:36] => Building app using buildpacks
[2022-09-05 22:32:36] => Configuring custom build command to be run at the end of the build:
[2022-09-05 22:32:36]      npm run build
[2022-09-05 22:32:36] => Running buildpack detection
[2022-09-05 22:32:36] 
[2022-09-05 22:32:36]    digitalocean/static  v0.0.2  (Static Assets)
[2022-09-05 22:32:36]    digitalocean/custom  v0.1.1  (Custom Build Command)
[2022-09-05 22:32:36] 
[2022-09-05 22:32:36] 
[2022-09-05 22:32:36] => Building app
[2022-09-05 22:32:36] 
[2022-09-05 22:32:36] Running custom build command: npm run build
[2022-09-05 22:32:36] bash: npm: command not found
[2022-09-05 22:32:36] building: exit status 127
[2022-09-05 22:32:36] ERROR: failed to build: exit status 1
[2022-09-05 22:32:36] 
[2022-09-05 22:32:36] 
[2022-09-05 22:32:36]  ! Build failed

Note that some Googling yields this link which leads to a 404 https://docs.digitalocean.com/products/app-platform/concepts/command/


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.

Jon Friesen
DigitalOcean Employee
DigitalOcean Employee badge
September 6, 2022

👋 @troyforster

From your build logs, App Platform is not detecting your NodeJS app. I see your source_dir is set to the /src folder, is that where your package.json file is located? If not, can you try updating the source_dir path to the directory that contains your package.json?

Try DigitalOcean for free

Click below to sign up and get $200 of credit to try our products over 60 days!

Sign up