Self-hosted Thin Backend

Run it your way: Deploy Thin on your own infrastructure in less than 5 minutes.

Running Thin locally requires docker to be installed. If you haven't installed docker yet, follow the install instructions on the docker website before you continue.

  1. Create a new file docker-compose.yml:

    services:
      db:
        image: postgres:alpine3.16
        restart: always
        environment:
          POSTGRES_PASSWORD: examplepassword
        ports:
          - '5432:5432'
      thin:
        image: downloads.digitallyinduced.com/digitallyinduced/thin-backend:latest
        restart: always
        ports:
          - 8000:8000
        depends_on:
          - db
        environment:
          DATABASE_URL: "postgres://postgres:examplepassword@db/postgres"
          TYPE_DEFINITONS_BASE_PATH: "$PWD"
        volumes:
          - ".:/home/app/Application:rw"
    
  2. Now you can start the database and Thin Backend with docker-compose:

    docker compose up
    
  3. Thin Backend is now running at http://localhost:8000.

First Start

On first start Thin will automatically generate a few files in the working directory:

FileDescription
Schema.sqlDatabase tables are defined here. You can edit this file with your text editor if you want.
Migration/Database migrations are stored here.
Types/npm package that contains the generated TypeScript definitions.
jwt.pubPublic key generated for the JWT-based
jwt.secretSecret key generated for the JWT-based. Keep this secret.

It's recommended to keep all these files (except the Types/ directory) in git.

Connecting a Frontend

The self hosted Thin works very similiar to the Cloud version at thin.dev, so you can follow all the other Guides and it should just work as expected. Make sure to use http://localhost:8000 as your Backend url.

Next: Your First Project

Community

If you need any help or input, feel free to ask in the Thin Community Forum.