Skip to content

Self-hosting the GlobalTagsAPI

Prerequisites

Installation

1. Clone the Repository

Start by cloning the repository to your local machine:

git clone https://github.com/Global-Tags/API gtapi
cd gtapi

2. Create a Configuration File

Next, create a configuration file by copying the example provided. Adjust the settings in config.json as needed. The only mandatory change is the srv field, which should contain the connection string to your MongoDB instance.

cp config.json.example config.json

3. Running the API

Run with Bun (that rhymes)

  1. Install Required Dependencies

    Use the following command to install the necessary dependencies:

    bun i
    
  2. Start the API

    To run the API, execute:

    bun start
    
Hosting the API

To keep the API online, install a tool called pm2 to daemonize the process:

# Install pm2 and pm2-logrotate globally
bun i -g pm2 pm2-logrotate

# Start the daemon
pm2 start src/index.ts --interpreter ~/.bun/bin/bun --name GlobalTagAPI

Run with Docker

You have two options for running the API with Docker:

  • Option 1: Using Docker Compose

    Run the following command to start the API in detached mode:

    docker compose up -d # (1)
    
    1. If you'd like to test the setup, you can omit the -d option to run it in the foreground.
  • Option 2: Without Docker Compose

    You can also run the API without Docker Compose by executing:

    docker run -p 5000:5000 $(docker build -q .)