Skip to content

Commit

Permalink
Add nodejs guide
Browse files Browse the repository at this point in the history
  • Loading branch information
wpjunior committed Sep 17, 2024
1 parent b1a0a06 commit 6211c03
Show file tree
Hide file tree
Showing 2 changed files with 80 additions and 0 deletions.
1 change: 1 addition & 0 deletions mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ nav:
- Using Dockerfile: ./user_guides/deploy_using_dockerfile.md
- GO apps: ./user_guides/deploy_go_apps.md
- Python apps: ./user_guides/deploy_python_apps.md
- Node.js apps: ./user_guides/deploy_nodejs_apps.md

- Admin guides:
- Managing clusters: ./admin_guides/managing_clusters.md
Expand Down
79 changes: 79 additions & 0 deletions src/user_guides/deploy_nodejs_apps.md
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 .
```

0 comments on commit 6211c03

Please sign in to comment.