From ff08635c9412edd426ffa2c248cf4c36f26f4a92 Mon Sep 17 00:00:00 2001 From: Wannes Gennar Date: Fri, 1 Mar 2024 17:41:05 +0100 Subject: [PATCH] update documentation for Docker/Podman --- README.md | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/README.md b/README.md index 778082e..2987ade 100644 --- a/README.md +++ b/README.md @@ -4,6 +4,9 @@ This is a reverse engineered API of the official [Helldivers 2](https://store.st This is **NOT** an official *nor* endorsed API and may stop functioning at any time. +> [!TIP] +> Hitting rate limits? You can run a local docker image, see [Local development](#running-in-docker--podman) + ### Getting started Currently the API does not enforce authentication. You can see all active war seasons at `/api/` @@ -19,6 +22,7 @@ This limit will probably be increased in the future, but given the limited API e To avoid hitting rate limits in your clients check the following headers in your response: - `X-Ratelimit-Limit` contains the total amount of requests you can make in the given timeframe - `X-RateLimit-Remaining` how many requests you can still make in the current window +- `X-RateLimit-Reset` the unix epoch (in milliseconds) when you can start making more requests - `Retry-After` only added to 429 requests, the amount of seconds to wait before making a new request ### Roadmap @@ -49,3 +53,34 @@ You can run an interactive shell and the application with ```shell iex -S mix phx.server ``` + +### Running in Docker / Podman +Want to run a private instance of the API, or simply want a local container without rate limits +so you can develop your app without being hit with rate limits constantly? + +Fortunately, it's very easy to get a local/private copy of the Helldivers 2 API running! +All you need is to have either [Docker](https://www.docker.com/) or [Podman](https://podman.io/) installed. + +You can build a local image like this (takes a few minutes, but you only need to re-run this when something changes): +```shell +# Docker +docker build -t helldivers2:latest . +# Or if you're using Podman +podman build -t helldivers2:latest . +``` + +Now to run this container, you'll need a few variables to configure how the API behaves (TLDR below!): +- `SECRET_KEY_BASE` used by the application for singing private or sensitive information, if you're running a private instance publicly you'll want a secure random string of 64 characters +- `FLY_APP_NAME` used internally for networking code to find other instances (you can just use `helldivers-2` for this) +- `FLY_IMAGE_REF` the container reference, this helps cluster to only the same version of the app (you can set this to `0`) +- `FLY_PRIVATE_IP` - used to uniquely identify this node in the cluster (if you're running a single instance you can use `127.0.0.1`) +- `RATE_LIMIT_MAX_REQUESTS` - (optional) the max amount of requests the rate limit will allow, set to `0` to disable rate limiting +- `RATE_LIMIT_INTERVAL` - (optional) how many seconds before the rate limit will reset itself (must be a valid number greater than `0`) + +or if you're just setting up a local development instance, you can copy paste the command below: +```shell +# Docker +docker run -e SECRET_KEY_BASE=JlU7vU9xt9uWbf82Z9HrUjAuNGtqwqG8h8AaUc3AOyH0a86wa5Q4DITNLorGmILv -e FLY_APP_NAME=helldivers-2 -e FLY_IMAGE_REF=0 -e FLY_PRIVATE_IP=127.0.0.1 -p 4000:4000 helldivers2:latest +# Or if you're using Podman +podman run -e SECRET_KEY_BASE=JlU7vU9xt9uWbf82Z9HrUjAuNGtqwqG8h8AaUc3AOyH0a86wa5Q4DITNLorGmILv -e FLY_APP_NAME=helldivers-2 -e FLY_IMAGE_REF=0 -e FLY_PRIVATE_IP=127.0.0.1 -p 4000:4000 helldivers2:latest +``` \ No newline at end of file