Get Started with Node.js on Scalingo
Requirements
Before doing this tutorial you should have setup your environment:
-
Setup the SSH authentication, it has to be done to let you
push
your application on the platform. - Install ‘scalingo’ Command Line Interface
Initialize Your Application
$ mkdir my-app
$ cd my-app
$ npm init
#
# You need to fill the different info field for your project
#
$ npm install express --save
$ echo "node_modules" > .gitignore
Write a Base Server File
The main file for this sample project is server.js
:
// Node.js - Express sample application
var express = require('express')
var app = express()
app.get('/', function (req, res) {
res.send('Hello World!')
})
var server = app.listen(process.env.PORT || 3000, function () {
var host = server.address().address
var port = server.address().port
console.log('App listening at https://%s:%s', host, port)
})
Define How to Start Your Application
The Procfile
(with a capital ‘P’) is the file defining how your application
is supposed to start (more info about Procfile). This file must be at the root of your project.
Here is the content you have to write in the Procfile
file for this project:
web: node server.js
Commit Your Application
$ git init
$ git add .
$ git commit -m "Base Node.js application"
Create Your Application on Scalingo and Deploy
$ scalingo create my-app
Git repository detected: remote scalingo added
→ 'git push scalingo master' to deploy your app
$ git push scalingo master
Access Your Application
…
Waiting for your application to boot...
<-- https://my-app.osc-fr1.scalingo.io -->
Now develop your project and build something amazing!
Last update: 22 Dec 2023
Suggest edits