This sample project demonstrates how to deploy
Sailsjs with Defang and connect it to a Postgres database. Furthermore, we emonstrate how to run a local Postgres container during development vs a managed postgres service (Neon). For a quick database set up please go to Neon and follow set up instructions. The sample starts with a no tasks in the database and allows us to add tasks on the fly. It sets wide open permissions on the tables as well so you can start querying or mutating the data right away.
- Download Defang CLI
- (Optional) If you are using Defang BYOC authenticated with your AWS account
- (Optional - for local development) Docker CLI
- (Optional) [Neon CLI] (https://neon.tech/docs/reference/neon-cli)
- Open the terminal and type
defang login
- Add your connection string for the third party postgres database in the DATABASE_URL part of the compose.yaml section
- Type
defang compose up
in the CLI. - Your app will be running within a few minutes.
For development, we use a Postgres container. The Postgres container is defined in the compose.dev.yaml
file. The Neon postgres container is defined in the compose.yaml
file, with some overrides in the compose.dev.yaml
file so it correctly connects to the development database container. To start your own, please have the env variables, POSTGRES_USER
, POSTGRES_PASSWORD
, POSTGRES_DB
, and SESSION_SECRET
ready.
To start the development environment, run:
docker compose -f compose.dev.yaml up --build
Title: Sails.js & PostgreSQL
Short Description: A sample project demonstrating how to deploy a project with PostgreSQL and Sails.js.
Tags: PostgreSQL, Sails.js, SQL, JavaScript
Languages: nodejs