This is the API for the project.
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.
We recommend using Docker and Docker Compose and following the instructions in the installation guide to launch the API.
-
Environment Variables:
Specify the required environment variables in the
.envfile. You can override the default values using a.env.localfile.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
.envfile. For example:API_ENV=development go run main.go
-
PostgreSQL Database:
The API uses a PostgreSQL database, so you need to have a running PostgreSQL server to use it.
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-dirtyYou 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.
To load the data from the Helldivers API, run the following command:
go run main.go collectorTo run the unit tests, execute the following command:
go test ./...-
Build the API Image:
docker build -t helldivers-prod-api -f docker/prod/golang/Dockerfile . -
Run the API Container:
docker run -d -p 5000:5000 --env-file .env helldivers-prod-api
Specify the environment variables in the
.envfile for the production environment:API_ENV=production