By mattfink
I have come to DO App Platform from Heroku, and one teething problem i’ve had, is running processes after release, or during release for a Node.js app. Specifically running migrations .
In the past I’ve used postinstall, which usually works, but more recently I’ve used the release process type in a Procfile, which makes more sense.
DO doesn’t seem to support the release process type, but I wonder if i’m using it wrongly for DO?
web: npm start
release: npm run migrate
Also, I get unexpected behaviour using the postinstall method, as DO doesn’t run npm install when it has a cache of the node_modules I presume from package-lock.json.
I tried using a appspec.yml file, with an added build_command, and building via doctl apps create-deployment, but that doesn’t appear to run the postinstall command either.
build_command: npm install --production
Any ideas?! :)
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!
The build_command is run once when commits are pushed to your repo, or in some cases when changes (ex. environment variables or changing the build command itself) are made to your apps configuration.
A good option for running migrations is the pre-deploy and post-deploy job types. These are run just before or just after launching your application containers. If the job fails, your app will be rolled back to its previous version. These run in a separate, short-lived container from your application so they have their own resource allocation and won’t steal CPU or memory from your application.
We strongly recommend against running migrations directly in the service container via run_command (ex. npm run migrate && npm run start). Running in the service container means the migration could run several times (potentially concurrently) based on the component’s instance count. Also, this (anti-)pattern slows the start of your application, which could potentially cause it to fail health checks at deploy, or if ever restarted.
See: How-to Manage Jobs for details on creating and configuring jobs.
I’ll file an internal feature request for directly supporting the release procfile option.
Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.
Full documentation for every DigitalOcean product.
The Wave has everything you need to know about building a business, from raising funding to marketing your product.
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
Scale up as you grow — whether you're running one virtual machine or ten thousand.
Sign up and get $200 in credit for your first 60 days with DigitalOcean.*
*This promotional offer applies to new accounts only.