Our example node.js app can be found here. You can clone this locally to run and experiment with.
The following is a step-by-step walkthrough of how the app was configured and why. The sample app is a fresh new node.js app, Dockerised, configured and a
convox.yml added. See the
README.md in the repo for the changes made.
A few steps to get started:
- Make sure you have Docker installed on your local machine.
- Signup for a Convox account It’s free!
- Install the Convox CLI.
- Install the Convox local Rack
Once you are all setup you can switch to your local rack with
convox switch local and start your local application with
convox start (make sure you are in the root directory).
You should now be able to access your application by going to https://web.nodejs.convox. If you renamed anything you may need to modify your local URL. The format is https://[service name].[app name].convox
Custom Application Components
Starting from the node:10.16.3-alpine image, the Dockerfile simply sets up a basic nodejs app by copying the app files into the container, exposing port 3000 and specifying the command to be executed.
The convox.yml file explains how to run the application. This file only has one section for our node app.
- Services: This is where we define our application(s). In this case we have a single application called
webwhich is built from our dockerfile. In a production application you may have additional sections for resources like databases etc.
Deploying to production
In order to deploy to production we have to ensure we have completed the following steps:
- Signup for a Convox account
- Connect an AWS account
- Install an AWS Rack
- Make sure your CLI is logged in to your Convox account using
convox loginand your CLI Key
Once you are all set here you can see the name of your production rack
And switch your CLI to your production rack
convox switch [rack name]
Now you can create an empty application in your production rack
convox apps create --wait
And you can deploy your application to production (the first time you do this it may take up to 15 minutes to create the necessary resources)
convox deploy --wait
Finally you can retrieve the URL from your production application with