Skip to content

Latest commit

 

History

History
99 lines (72 loc) · 2.94 KB

README.md

File metadata and controls

99 lines (72 loc) · 2.94 KB

Quizlord API

Graphql api for sharing newspaper quizzes between friends, including results and statistics

Follows the GraphQL Cursor Connections Specification.

codecov

Deployment

The api is packaged in docker and deployed with github actions to the github registry. A helm template is also deployed with a github action to https://helm.demery.net.

See quizlord-stack for further details about deployment and for the terraform module.

Local Development

Doppler is used to provide access to secrets, in order to run the app you first need to run

  • doppler login
  • doppler setup

Using Nix

If using nixos a flake file is provided to load a shell with all the required dependencies.

nix develop

Upgrade Flake

The following can be run to upgrade the flake.lock file

nix flake update

Afterwards rerun nix develop and check the new versions installed by the flake match.

node --version
prisma --version

The node and prisma versions may need to be updated to match.

  • Prisma: Just the package.json version
  • Node: The package.json engine entry, the Dockerfile FROM and the .nvmrc file

Bootstrap project

docker compose up -d
npm ci
npm run db:dev:migrate

Run project

npm start

Test Docker Image Locally

# Perform a local production build
npm run build
# Build a local image tagged with local
docker build -t quizlord-api:local .
# Run local build using the env file
docker run -p 4000:80 --env-file <(doppler secrets download --no-file --format docker) --name=quizlord-api quizlord-api:local
# Cleanup
docker rm quizlord-api && docker image rm quizlord-api:local

Test Helm Locally

  1. You first to have a local k8s cluster running.
  2. Ensure doppler is setup with doppler setup
  3. Install the doppler operator as described https://docs.doppler.com/docs/kubernetes-operator
  4. Create the doppler token secret
    kubectl create secret generic doppler-token-quizlord-api-secret \
    --namespace doppler-operator-system \
    --from-literal=serviceToken=$(doppler configs tokens create doppler-kubernetes-operator --plain)
  5. Create the destination namespace with kubectl create namespace quizlord
  6. Create the doppler secret with kubectl apply -f .k8s/doppler-secret.yaml
  7. Create the registry pull secret kubectl create secret docker-registry registry-github-quizlord --docker-server=ghcr.io --docker-username=danielemery --docker-password=REPLACE_ME --docker-email="[email protected]" -n quizlord
  8. Install using local chart
    helm install -n quizlord quizlord-api ./helm
  9. Cleanup
    helm uninstall -n quizlord quizlord-api