DEV Community

flisk
flisk

Posted on

Run Microservices Locally: An API, a Website and Postgres in 4 Commands

TL;DR: you can run an API, a website and a Postgres database behind one gateway on your laptop with four commands. Flisk writes the Dockerfiles, the routing and the health checks, and reloads on save.

If you searched run microservices locally, you probably hit a wall of Compose files, ports and environment variables. Here is a smaller path. It needs Docker, Tilt, Node.js 22.12+ and Bun 1.2+. Run flisk doctor and it says what is missing.

Install

npm install -g @flisk-sh/flisk
Enter fullscreen mode Exit fullscreen mode

Four commands

mkdir my-shop && cd my-shop
flisk project --yes
flisk resource orders-api --type backend --stack shop --yes
flisk resource shop-web --type frontend --stack shop --yes
flisk up shop
Enter fullscreen mode Exit fullscreen mode

That starts an orders API and a storefront behind one gateway, with Postgres and live reload, and prints their URLs.

What each service is

flisk resource writes one service.json per part. This is the whole file for the orders API:

{
  "schemaVersion": 1,
  "appName": "orders-api",
  "appType": "backend",
  "stack": "shop",
  "port": 4000,
  "healthCheckPath": "/health"
}
Enter fullscreen mode Exit fullscreen mode

From it Flisk writes the Dockerfile, the Compose entry, the gateway route, the health check and the DATABASE_URL.

No Docker? Start smaller

npx @flisk-sh/flisk create
Enter fullscreen mode Exit fullscreen mode

The default runs on your computer with no Docker, no Tilt and no database. It writes a website and an API that run as local processes.

Want a website, an API and Postgres that already work together?

npx @flisk-sh/flisk create myapp --starter next-postgres
Enter fullscreen mode Exit fullscreen mode

That writes a Next.js page with an add, tick and delete list, an Express API and a migrator that creates and seeds the table.

Already have an app?

npx @flisk-sh/flisk import . && npx @flisk-sh/flisk up
Enter fullscreen mode Exit fullscreen mode

Add --dry-run to import to preview.

Limits

This is local development only, not deployment. On native Windows the full app runs in Ubuntu on WSL2.

Site: flisk.sh. Source: github.com/flisk-sh/flisk.

Top comments (0)