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:
Do I need to prepare and create a container image or is there anyother way.
Thanks.
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!
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.
Hey there!
In addition to what Mark mentioned already here, 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 yournpmAuthToken
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 anAptfile
in your project’s root directory and list each package you need. Here’s an example for Puppeteer:Aptfile:
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 yourpackage.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:
Hope that this helps!
- Bobby