Skip to content

Self hosting guide

Jay Malhotra edited this page Oct 24, 2024 · 12 revisions

Here is a quick guide for getting started with a self hosting setup. This guide focuses on Windows, but most of the steps should be generally applicable to other operating systems.

Starting up the server.

  1. Install dependencies. On Windows, Docker Desktop is required to set up Docker and run Linux containers.
  2. Create a folder for the server files.
  3. Create a file called docker-compose.yml, with the following content:
volumes:
  pgdata:

services:
  dragaliaapi:
    image: ghcr.io/sapiensanatis/dragalia-api:4.0.59
    environment:
      - ASPNETCORE_URLS=http://+:80
      - ConnectionStrings__Postgres=Host=postgres;User ID=${POSTGRES_USER};Password=${POSTGRES_PASSWORD};Database=${POSTGRES_DB}
      - ConnectionStrings__Redis=redis
    ports:
      - "80:80"
    env_file:
      - .env

  postgres:
    hostname: postgres
    image: postgres:16
    env_file:
      - .env
    volumes:
      - pgdata:/var/lib/postgresql/data

  redis:
    hostname: redis
    image: redis:7
  1. Make a file next to the docker-compose.yaml called .env. Populate it with credentials from the server, like in the below example, but choose your own values. Do not copy and paste these ones, especially if your instance will be accessible via the Internet.
# Password for PostgreSQL connection (required)
POSTGRES_PASSWORD=midgardsormr
# Username for PostgreSQL connection
POSTGRES_USER=alberius
# Database for PostgreSQL connection
POSTGRES_DB=DragaliaAPI

# Bearer token for admin endpoints e.g. manual save import
DEVELOPER_TOKEN=token
# Hostname to add to logging context
HOSTNAME=
  1. Open a command-line inside the folder.
  2. Run the command docker compose -f docker-compose.yml up -d.
  3. Using Docker Desktop, check all containers have started correctly, and that there are no errors in the logs.
  4. Check that the server is healthy by using a browser to navigate to http://localhost/health. You should see all of the health checks passing:
{
  "status": "Healthy",
  "results": {
    "self": {
      "status": "Healthy",
      "description": null,
      "data": {}
    },
    "ApiContext": {
      "status": "Healthy",
      "description": null,
      "data": {}
    },
    "Redis": {
      "status": "Healthy",
      "description": null,
      "data": {}
    }
  }
}

Setting up a client

The docker-compose file will start the server on port 80, so you can use Dragalipatch with your PC's local IP address to play on your local server. You must input this as http://192.168.xxx.xxx because without a http prefix, Dragalipatch assumes HTTPS which is not enabled on the development setup.

Updating the server

The above docker-compose.yml represents a version of the server that was available at the time of writing. However, the server is always being updated. Each time there is an update to the main server component the dragalia-api:4.0.42 version will be incremented. You can check the package page to see the latest versions. If you want to update your local server, change this tag in the file and run

docker-compose -f docker-compose.yml down

and then run the docker-compose up command above again.

Running the website frontend

Running the website locally is more of an advanced topic which is out of the scope of this guide. This is because the Docker Compose setup can only run one service on the default HTTP port of 80. You can run the website on a different port, using the image dawnshard-website image, but the website loads data from DragaliaAPI and browsers will refuse to make requests to it because it does not support CORS.

At this time, the easiest way to run the website is behind a reverse proxy, so that it and the API can serve from the same origin.

CORS support could be implemented via configuration, depending on if there is interest. Contact the maintainer if you would like to include the website in your self-hosted deployment.

Co-op support

Co-op support can be enabled for a self-hosted instance by setting up an instance of Photon Server. A guide for that can be found on this page. Unfortunately, this is unlikely to be feasible for most players as the licensing costs are incredibly expensive.

Clone this wiki locally