Skip to content

Environment Variables

Root .env (Docker Compose)

Used by docker-compose.yml and docker-compose.override.yml.

VariableDefaultRequiredDescription
DB_ROOT_PASSWORDMySQL root password
DB_PASSWORDPassword for the medregia application user
DB_CONNECTION_STRING✅ (prod)Full connection string for the API in production
API_PORT5000Host port for the API container
FRONTEND_PORT80Host port for the frontend container
ASPNETCORE_ENVIRONMENTProductionASP.NET environment name

Backend: appsettings.json / appsettings.Development.json

KeyDefaultDescription
ConnectionStrings:DefaultConnectionSee fileMySQL connection string
Jwt:SecretKeyCHANGE_ME_...🔴 Must be changed — HS256 signing secret (min 32 chars)
Jwt:IssuerMedRegiaJWT issuer claim
Jwt:AudienceMedRegiaUsersJWT audience claim
Jwt:ExpirationHours24Token lifetime in hours

Connection String Format

Server=<host>;Port=3306;Database=medregia_ca_db;Uid=<user>;Pwd=<password>;SslMode=None;AllowPublicKeyRetrieval=True;

Override for Development (appsettings.Development.json)

Values here override appsettings.json in the Development environment:

json
{
  "ConnectionStrings": {
    "DefaultConnection": "Server=localhost;Port=3306;Database=medregia_ca_db;Uid=medregia;Pwd=dev_password;SslMode=None;AllowPublicKeyRetrieval=True;"
  },
  "Jwt": {
    "SecretKey": "dev_only_secret_key_32_chars_minimum"
  }
}

Frontend: Vite .env Files

VariableDefault (dev)Description
VITE_API_BASE_URLhttp://localhost:5000/apiBackend API base URL

Files

FileWhen loaded
.envAlways
.env.developmentnpm run dev
.env.productionnpm run build

Production Build

When building for production via Docker, the VITE_API_BASE_URL is set to /api (same-origin Nginx proxy):

dockerfile
# In frontend/Dockerfile
ARG VITE_API_BASE_URL=/api

This means the frontend makes API calls to /api/* which Nginx proxies to the API container.

Security Notes

Never Commit Secrets

  • Never commit real Jwt:SecretKey values to source control
  • Never commit .env files with real passwords
  • Use a .gitignore entry for .env and appsettings.Development.json
  • In production, inject secrets via container environment variables or a secrets manager

MedRegia — Pharmaceutical Vendor Management Platform