Build & Start command

The build command and run command are essential for preparing and starting your application.

Overview

The build command and run command are essential for preparing and starting your application. These commands are executed inside the working directory and must be correctly defined to ensure the application runs smoothly.

  • The build command installs dependencies and compiles or prepares the application for execution.

  • The run command starts the application, making it available for requests.

Example usage

Node.js application

Repository structure

/my-repo
│── package.json
│── server.js
│── .gitignore  # Ensure node_modules/ is ignored

Build command

npm install

Run command

node server.js

Fastapi application

Repository structure

Build command

Run command


Django application

Repository structure

Build command

Run command


Go application

Repository structure

Build command

Run command

Advanced usage

Sometimes, additional commands need to be executed before starting the application. For example, running database migrations before launching the server. You can join multiple commands using &&, or simply place them on a new line, which automatically joins them with &&.

Running database migrations before starting the application

Django example

Or written on multiple lines:

Fastapi example (using alembic migrations)

Or written on multiple lines:

Conclusion

Setting the correct build command and run command ensures your application installs dependencies and starts correctly. Always verify these commands based on your application’s framework and dependencies.

Last updated