Skip to content

Latest commit

 

History

History
101 lines (65 loc) · 2.97 KB

File metadata and controls

101 lines (65 loc) · 2.97 KB

API

This is the API for the project.

Content

Prerequisites

Getting Started

To run the API, you will primarily need Docker installed. If you prefer to run the API without Docker, ensure you have Go installed on your system.

You will also need a Firebase project. Refer to the Firebase documentation to create a new project.

Using Docker

We recommend using Docker and Docker Compose and following the instructions in the installation guide to launch the API.

Without Docker

  1. Environment Variables:

    Specify the required environment variables in the .env file. You can override the default values using a .env.local file.

    Note:
    The API does not utilize any configuration manager like Viper, relying instead on environment variables injected by Docker.

    To run the API without Docker, manually specify the environment variables from the .env file. For example:

    API_ENV=development go run main.go
  2. PostgreSQL Database:

    The API uses a PostgreSQL database, so you need to have a running PostgreSQL server to use it.

Migrations

To create the database schema, run the following command:

docker run --rm -v $(PWD)/api/migrations:/migrations --network <database-network> arigaio/atlas migrate apply --dir "file://migrations" --url ${DB_URL} --allow-dirty

You need to replace ${DB_URL} by your actual database url.

If your database is running in a Docker container, you can use the same network as the database container. Replace <database-network> with the network name of the database container.

Collector

To load the data from the Helldivers API, run the following command:

go run main.go collector

Running unit tests

To run the unit tests, execute the following command:

go test ./...

Building the API

Production Environment

  1. Build the API Image:

    docker build -t helldivers-prod-api -f docker/prod/golang/Dockerfile .
  2. Run the API Container:

    docker run -d -p 5000:5000 --env-file .env helldivers-prod-api

    Specify the environment variables in the .env file for the production environment:

    API_ENV=production