-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
80 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
# Deploy Nodejs applications | ||
|
||
|
||
## Overview | ||
|
||
Node.js is a widely recognized runtime, known for its ease of use, low learning curve, and large community. Deploying a Node.js application on Tsuru is an effortless task. You should have a package.json, Procfile, and tsuru.yaml. | ||
|
||
|
||
## Creating the app | ||
|
||
To create an app, you use the command app create: | ||
|
||
``` bash | ||
$ tsuru app create <app-name> <app-platform> | ||
``` | ||
|
||
For NodeJS, the app platform is, guess what, nodejs! Let’s be over creative and develop a never-developed tutorial-app: a myapp | ||
|
||
``` bash | ||
$ tsuru app create myapp nodejs | ||
``` | ||
|
||
## Application code | ||
|
||
Basically we need to write 3 files and put on project directory: Procfile, package.json and tsuru.yaml | ||
|
||
### Procfile | ||
|
||
This file is useful to identify how to execute your application, each line represents a tsuru process, usually process named web is responsabile to receive requests, important NOTE the app may listen requests following PORT envvar OR use the default port 8888 | ||
|
||
``` | ||
web: node app.js | ||
``` | ||
|
||
### package.json | ||
|
||
This file is used to pick your nodejs version and install your dependencies. | ||
|
||
``` | ||
{ | ||
"name": "hello-world", | ||
"description": "hello world test on tsuru", | ||
"version": "0.0.1", | ||
"private": true, | ||
"dependencies": { | ||
"express": "4.21.x" | ||
}, | ||
"engines": { | ||
"node": "20.17.0" | ||
} | ||
} | ||
``` | ||
|
||
### tsuru.yaml | ||
|
||
tsuru.yaml is used to tsuru specific settings, this may be the initial settings: | ||
|
||
``` | ||
healthcheck: | ||
path: / | ||
``` | ||
|
||
### Operating system dependencies: requirements.apt (optional) | ||
|
||
list of ubuntu dependencies that will be installed, useful to install tools required for build process | ||
|
||
example: | ||
``` | ||
gcc | ||
``` | ||
|
||
|
||
## Deploy application | ||
|
||
Let's deploy our application with command | ||
|
||
``` | ||
tsuru app deploy -a blog . | ||
``` |