Question

Need App Platform deployment advice.

Hi,

I would like to deploy my NodeJs app using the App Platform. What is the recommended way of deploying when the app has the following:

  1. Uses custom/private NPM repo and its packages that are not public
  2. Requires libs like Puppeteer for printing PDFs and such
  3. Has a custom prepare script that needs to prepare stuff before the build

Do I need to prepare and create a container image or is there anyother way.

Thanks.


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.

Bobby Iliev
Site Moderator
Site Moderator badge
November 14, 2024

Hey there!

In addition to what Mark mentioned already, I could add a couple of things!

To access a private NPM repo, you can set up an environment variable called NPM_TOKEN in the App Platform, which stores your private repository’s authentication token. This token allows your build process to authenticate and fetch packages from your private repo as usual.

If you need more detailed instructions, take a look at this discussion here, where a community user got this working with a private NPM repos on App Platform:

Alternatively, if you’re using Yarn, you can configure .yarnrc.yaml with your npmAuthToken to manage your authentication settings securely.

For additional dependencies like those required by Puppeteer, App Platform supports an Aptfile to install packages during the build. Just create an Aptfile in your project’s root directory and list each package you need. Here’s an example for Puppeteer:

Aptfile:

chromium
libnss3
freetype
harfbuzz
ttf-freefont

App Platform will automatically detect the Aptfile and install the packages during the build process. For more info, check out the Aptfile reference documentation.

There is a chance that some obscure packages might not be available in the default repositories though.

For custom steps that need to be run before the app is built, you could add a prepare script in your package.json, or configure it through other environment variables if needed.


And finally as Mark mentioned, it might be best to use a Dockerfile as you will have more control.

If these native options don’t fully meet your needs, you can always deploy using a custom Docker image. This gives you complete control over the environment but does require some setup. Just push your Docker image to DigitalOcean’s Container Registry and specify it in your App Platform service:

https://docs.digitalocean.com/products/app-platform/reference/dockerfile/

Hope that this helps!

- Bobby

There are a few options.

As you mentioned, you can prepare and create a container image, and host it on a repository such as DockerHub, or DO’s own image repository service.

If you are starting a brand new repo, a great option is to fork off DO’s sample App repo, and build up from there. With just a little more effort, you could fork off the sample repo and incorporate your existing work into it. Details are available in this tutorial: https://docs.digitalocean.com/products/app-platform/getting-started/sample-apps/node/

You can create a repo with a Dockerfile and deploy this repo to App Platform. This will result in slower build-times, but DO will handle actually building the image and deploying it. This option seems best for the most complicated orchestration, using a monorepo for multiple resources. Details about this option can be seen at https://docs.digitalocean.com/products/app-platform/reference/dockerfile/

Finally, you can use a buildpack. This is the option I know the least about, so you’ll have to research yourself at https://docs.digitalocean.com/products/app-platform/reference/buildpacks/nodejs/

Try DigitalOcean for free

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

Sign up

Become a contributor for community

Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.

DigitalOcean Documentation

Full documentation for every DigitalOcean product.

Resources for startups and SMBs

The Wave has everything you need to know about building a business, from raising funding to marketing your product.

Get our newsletter

Stay up to date by signing up for DigitalOcean’s Infrastructure as a Newsletter.

New accounts only. By submitting your email you agree to our Privacy Policy

The developer cloud

Scale up as you grow — whether you're running one virtual machine or ten thousand.

Get started for free

Sign up and get $200 in credit for your first 60 days with DigitalOcean.*

*This promotional offer applies to new accounts only.