Build and Run Command

The build command is the command-line statement that compiles your app resource at build time.

Build commands compile your application’s source code and install the dependencies required to run your app. Run commands execute the built application.

The run command is the command-line statement that launches your app resource after it has been built. For example, if this is a service, this means that when the run command is complete, the proper HTTP routes and HTTP ports are open and ready to receive requests after executing the run command.

A build and run command for a Node.js application looks like this:

npm install

This installs all the dependencies within your package.json file and ensures all node modules are installed for your Node.js application to run successfully.

A build command for a Python application hosted on App Platform looks like this:

pip install -r requirements.txt

This command ensures all dependencies specified in requirements.txt are installed during the build phase.

A run command for a Node.js application hosted on App Platform looks like this:

node index.js

This command tells App Platform to start the application using node and uses index.js as the entry point of the Node.js application.

Both build and run commands can be compound (joined by && or separated by newlines) if you need to perform multiple actions at build or runtime. App Platform attempts to infer these commands at inspection time, however if it is unable to do so, you must set them manually.

If you had a Ruby on Rails application, you could use a compound command for your run command:

rake db:migrate && rails server -b 203.0.113.0/24

This command first runs the database migrations using rake db:migrate then starts the Rails server.

For more information on build and run commands within App Platform, read How to Manage Build and Run Commands.