Upsun User Documentation

Local development

Upsun Beta access

Test and provide feedback for our newest offering - Upsun!

You can register for the Beta by clicking here and completing the form.

Sign up for Beta access

Once Your Express application has been deployed on Upsun, you might want to start develop your application locally.

If you’re new to Upsun, you might want to check out the philosophy of Upsun to get started on the best possible footing.

Before you begin Anchor to this heading

You need:

  • Git. Git is the primary tool to manage everything your app needs to run. Push commits to deploy changes and control configuration through YAML files. These files describe your infrastructure, making it transparent and version-controlled.
  • A Upsun account. If you don’t already have one, register for a trial account. You can sign up with an email address or an existing GitHub, Bitbucket, or Google account. If you choose one of these accounts, you can set a password for your Upsun account later.
  • Required: the Upsun CLI. This lets you interact with your project from the command line. You can also do most things through the Web Console, but this guide focuses on using the CLI.

Create a MariaDb Docker container Anchor to this heading

At the root of your project, create a docker-composer.yaml file with the following:

docker-compose.yaml
version: '3'
volumes:
  data:
services:
  db:
    image: mariadb
    environment:
      MYSQL_ROOT_PASSWORD: password
      MYSQL_DATABASE: express
      MYSQL_USER: user
      MYSQL_PASSWORD: password
    volumes:
      - data:/var/lib/mysql
    ports:
      - "3306:3306"

And launch corresponding Docker container:

Terminal
docker-compose up -d

Adapt your Express application to use local Docker container Anchor to this heading

For your Express application to use the local Docker container, adapt your index.js file, function openConnection() with the following :

...
function openConnection() {
  return mysql.createConnection({
    host: (process.env.DB_HOST || '127.0.0.1'),
    port: (process.env.DB_PORT || '3306'),
    user: (process.env.DB_USERNAME || 'user'),
    password: (process.env.DB_PASSWORD || 'password'),
    database: (process.env.DB_DATABASE || 'express')
  });
}
...

Launch local Express application Anchor to this heading

To run your Express application locally, use the following:

Terminal
node index.js

And then open your favorite browser with http://localhost:3000.

Is this page helpful?