Skip to content

DB API Dev Container

Henri Vainio edited this page Apr 14, 2025 · 1 revision

Dev API containerization

Updated: 14.4.2025

Steps marked with * are required only the first time

Simple Instructions

1) Start Docker desktop

2) Create network for Larpake containers*

On terminal run

docker network create weba-network

3) Configure you dev.env*

Follow instructions down below

4) Configure frontend .env*

Configuration instructions below

5) Run docker compose

Run one of following commands

docker compose --env-file dev.env -f docker-compose-dev.yml up --build
  • --build can be left out after first build
  • API might crash on the first run, but should work correctly after running docker compose again
  • You need to sign in first, then restart the container to get API permissions. For this reason it might seem that you cannot make requests to the API

You should now have something like image below and you should find web page at http://localhost:5502/openapi

image



dev.env config

  • Create dev.env file in repository root folder and fill with for example following values.
  • Entra values and api key are the only external values you cannot choose. Note that connection string passwords must be inside single quotes ''.
# database name is larpake_dev with dev containers

# All passwords are random generated UUIDs 
# and are not used in the production environment
# You can choose your own password values

POSTGRES_NAME=larpake_dev
POSTGRES_ADMIN_PASSWORD=devlpga-6f84d529-9252-437a-8c23-04cb529110eb
POSTGRES_ADMIN_USERNAME=postgres_sudo
PG_API_MIGRATIONS_PASSWORD=devlpgm-9d4daafe-b43b-499e-bb51-a9af817582ee
PG_API_CLIENT_PASSWORD=devlpgs-360bde37-3b63-4b38-bbda-316a59c40feb

JWT_SECRET=devljw-b4c7d11e-8385-4d8a-a236-3e388e150933
JWT_AUDIENCE=larpake.luuppi.fi
JWT_ISSUER=larpake.luuppi.fi

LUUPPI_API_KEY=<your-luuppi-api-key>

ENTRA_TEDANT_ID=e066975d-a520-4d16-bc9e-861a5ed8ded7
ENTRA_CLIENT_ID=6b19d245-0286-43a2-8481-98db51a8e777

POSTGRES_MIGRATIONS_CONNECTION_STRING="Host=larpake_pg_dev; Port=5432; Database=larpake_dev; Username=migrations_user_dev; Password='devlpgm-9d4daafe-b43b-499e-bb51-a9af817582ee';"
POSTGRES_API_CONNECTION_STRING="Host=larpake_pg_dev; Port=5432; Database=larpake_dev; Username=api_user_dev; Password='devlpgs-360bde37-3b63-4b38-bbda-316a59c40feb';"

# Add your sudo user's entra issued user id here (or more UUIDs separated by ';') 
# For example 360bde37-3b63-4b38-bbda-316a59c40feb;6f84d529-9252-437a-8c23-04cb529110eb
ENTRA_SUDO_USERS=

Frontend .env configuration

  • API container lives in port 5502 (Notice it must be http, no https)
VITE_ENTRA_CLIENT_ID = 6b19d245-0286-43a2-8481-98db51a8e777
VITE_ENTRA_TEDANT_ID = e066975d-a520-4d16-bc9e-861a5ed8ded7
VITE_ENTRA_SERVER = luuppiweba
VITE_ENTRA_SCOPE = api://luuppi-larpake/Larpake.Use
VITE_ENTRA_REDIRECT_URL = http://localhost:3000/fi/index.html
VITE_API_BASE_URL = http://localhost:5502/

Command definitions

First compose

docker compose --env-file dev.env -f docker-compose-dev.yml up --build

-f (file) flag is used to define specific compose file
--env-file to use dev.env instead of production .env
-d (detach) you can add -d flag if you want to detach docker process from blocking your terminal when the API container is up and running. Without this flag you can see server logs

Clone this wiki locally