diff --git a/mkdocs.yml b/mkdocs.yml index 04429ea..fd6bf0c 100644 --- a/mkdocs.yml +++ b/mkdocs.yml @@ -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 diff --git a/src/user_guides/deploy_nodejs_apps.md b/src/user_guides/deploy_nodejs_apps.md new file mode 100644 index 0000000..68ee72e --- /dev/null +++ b/src/user_guides/deploy_nodejs_apps.md @@ -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 +``` + +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 . +``` \ No newline at end of file