Skip to content

Secrets Management

This document explains how secrets and credentials are managed in the Merq platform.

MethodStatusDescription
Environment Variables✅ CurrentMain configuration method
Docker Secrets🔵 PlannedFor Docker Swarm
Kubernetes Secrets🔵 PlannedFor K8s deployments
HashiCorp Vault🔵 FutureEnterprise secret management

VariableDescriptionExample
DB_HOSTPostgreSQL hostlocalhost
DB_PORTPostgreSQL port5432
DB_USERDatabase usernamemerq
DB_PASSWORDDatabase passwordsecure-password
DB_NAMEDatabase namemerq_db
REDIS_HOSTRedis hostlocalhost
REDIS_PORTRedis port6379
REDIS_PASSWORDRedis passwordredis-password
JWT_SECRETJWT signing keyrandom-256-bit-string
JWT_EXPIRY_HOURSToken expiry in hours24
VariableDescription
RESEND_API_KEYResend email service
PLUNK_API_KEYPlunk email fallback
MAILERSEND_API_KEYMailersend fallback
FIREBASE_CREDENTIALS_FILEFirebase service account path
DO_SPACES_KEYDigitalOcean Spaces key
DO_SPACES_SECRETDigitalOcean Spaces secret
TYPESENSE_API_KEYTypesense search API key
VariableDescriptionDefault
SERVER_PORTServer port8080
APP_ENVEnvironmentdevelopment

Create .env file in merq-backend/:

Terminal window
# Database
DB_HOST=localhost
DB_PORT=5432
DB_USER=merq
DB_PASSWORD=your-secure-password
DB_NAME=merq_db
# Redis
REDIS_HOST=localhost
REDIS_PORT=6379
REDIS_PASSWORD=redis-password
# Auth
JWT_SECRET=your-256-bit-secret-key-change-in-production
JWT_EXPIRY_HOURS=24
# Email (at least one required)
RESEND_API_KEY=re_xxxxx
RESEND_SENDER_EMAIL=noreply@yourdomain.com
# Firebase
FIREBASE_CREDENTIALS_FILE=./firebase/service-account.json
# DigitalOcean Spaces
DO_SPACES_KEY=your-spaces-key
DO_SPACES_SECRET=your-spaces-secret
DO_SPACES_BUCKET=your-bucket
DO_SPACES_ENDPOINT=https://sgp1.digitaloceanspaces.com
# Typesense
TYPESENSE_HOST=localhost
TYPESENSE_PORT=8108
TYPESENSE_API_KEY=your-typesense-key

Create .env.local file in merq-web:

VITE_API_BASE_URL=http://localhost:8080/api
VITE_GOOGLE_API_KEY=your-google-maps-key
VITE_SECURE_LOCAL_STORAGE_HASH_KEY=your-32-char-hash-key

Create .env.dev or .env.prod file in merq-mobile:

API_BASE_URL=http://localhost:8080/api
GOOGLE_MAPS_API_KEY=your-google-maps-key
STORAGE_ENC_KEY=your-32-char-encryption-key

Terminal window
# Using environment file
docker run -d \
--name merq-backend \
--env-file .env.production \
merq-backend:latest
version: '3.8'
services:
backend:
image: merq-backend:latest
env_file:
- .env.production
apiVersion: v1
kind: Secret
metadata:
name: merq-secrets
type: Opaque
stringData:
DB_PASSWORD: your-password
JWT_SECRET: your-secret
RESEND_API_KEY: re_xxxxx

  1. Generate new secret
  2. Update environment variable
  3. Deploy application
  4. Note: All existing tokens become invalid
  1. Generate new API key from provider
  2. Update environment variable
  3. Deploy application
  4. Revoke old key
  1. Update password in database:
ALTER USER merq WITH PASSWORD 'new-password';
  1. Update environment variable
  2. Deploy application

  • ✅ Use strong, random secrets (256-bit for JWT)
  • ✅ Rotate secrets regularly
  • ✅ Use different secrets per environment
  • ✅ Store secrets in secure location (Vault, K8s Secrets)
  • ✅ Use environment-specific secrets
  • ❌ Commit secrets to version control
  • ❌ Use default/example secrets in production
  • ❌ Share secrets via email/chat
  • ❌ Use simple passwords
  • ❌ Hardcode secrets in source code