Saltar al contenido principal

Configuration reference

Memship is configured through environment variables, typically set in a .env file next to docker-compose.yml. Copy .env.example to .env and adjust. This page documents every setting the backend reads.

Minimum for production: change SECRET_KEY and DB_PASSWORD, set IMAGE_TAG to a released version, and configure email.

Deployment layout

VariableDefaultDescription
MEMSHIP_DATA_ROOT./dataAbsolute path holding every persistent path — database, uploads, scheduler state, TLS certificates, backups. Back this up. See Installation.
SITE_ADDRESS(empty)The address Caddy serves. A bare hostname (memship.example.com) makes Caddy provision a Let’s Encrypt certificate automatically; empty serves plain HTTP on port 80.
HOST_UID1001Uid the backend containers run as. Set to your id -u so bind-mounted uploads belong to you and are readable without sudo.
HOST_GID1001Gid, likewise — your id -g.

scripts/install.sh sets all four for you.

Security

VariableDefaultDescription
SECRET_KEY(generated into storage/session.key)Signs session cookies and member-card QR codes, and derives the key encrypting stored payment-provider credentials. Leave blank and a per-install key is generated on first boot; set it explicitly if you want it to survive a lost data root. Generate with openssl rand -hex 32. The placeholder values shipped in the example files are recognised and ignored — anything signed with a published key is forgeable.
SESSION_KEY_FILE<STORAGE_LOCAL_PATH>/session.keyWhere the auto-generated signing key is persisted when SECRET_KEY is blank. Must sit on persistent storage, or every restart logs all users out and stored payment credentials stop decrypting.
COOKIE_SECURE(derived from FRONTEND_URL)Forces the Secure attribute on the session cookie on/off. The default reads the FRONTEND_URL scheme, which is correct unless TLS is terminated by an upstream proxy that talks plain HTTP to Caddy — set true there.
MEMSHIP_SECRET_KEY(generated into storage/secret.key)Encrypts SSO and payment-provider credentials stored in the database. Set it explicitly — an auto-generated key lives only in the data root, so a rebuilt host cannot decrypt a restored backup without it. Rotating it makes existing stored credentials unreadable.
SECRETS_KEY_FILE<STORAGE_LOCAL_PATH>/secret.keyWhere the auto-generated key is persisted when MEMSHIP_SECRET_KEY is unset. Must sit on persistent storage, or stored credentials become unreadable after a restart.
ACCESS_TOKEN_EXPIRE_MINUTES30Access token lifetime in minutes.

Database

VariableDefaultDescription
DB_PASSWORDmemshipChange this. PostgreSQL password used by Compose.
DATABASE_URLpostgresql://memship:memship@localhost:5433/memship_dbFull connection string. In Compose it points at the db service.

Application

VariableDefaultDescription
APP_ENVdevelopmentSet to production for deployments. Affects debug behaviour and API docs exposure.
APP_VERSION(from image / git tag)Baked into the image at build time; leave unset when running published images.
DEFAULT_LOCALEesDefault interface language: es, ca, or en.
CORS_ORIGINShttp://localhost:3000Comma-separated list of allowed browser origins. Set to your site URL(s).
FRONTEND_URLhttp://localhost:3000Public URL of the frontend; used in email links.
BACKEND_PUBLIC_URLhttp://localhost:8003Publicly reachable backend URL for payment-provider callbacks (e.g. Redsys Ds_Merchant_MerchantURL). In production this must be the external hostname the gateway can POST to.

Ports

Set in .env for the Compose stack (defaults shown in .env.example):

VariableDefaultDescription
HTTP_PORT80Caddy HTTP port.
HTTPS_PORT443Caddy HTTPS port.
API_PORT8003Direct backend API port.
DB_PORT5433PostgreSQL host port.

Email

Email is disabled unless either a Resend API key or an SMTP host is set. See Email delivery for a full walkthrough.

Resend (preferred, managed delivery):

VariableDefaultDescription
RESEND_API_KEY(empty)Enables Resend delivery.
RESEND_FROM_EMAIL(empty)Verified sender address.

SMTP (self-hosted alternative):

VariableDefaultDescription
SMTP_HOST(empty)Enables SMTP delivery when set.
SMTP_PORT587SMTP port.
SMTP_USER(empty)SMTP username.
SMTP_PASSWORD(empty)SMTP password.
SMTP_FROMnoreply@memship.localFrom address.
SMTP_TLStrueUse STARTTLS.

If both are configured, Resend takes precedence.

Background jobs (Celery / Redis)

VariableDefaultDescription
CELERY_BROKER_URLredis://localhost:6379/0Redis broker for async email, recurring billing, reminders. Redis is included in the Compose stack.

The worker and scheduler (Celery beat) run as part of the stack and power async emails, scheduled fee generation, and payment reminders.

File storage

VariableDefaultDescription
STORAGE_LOCAL_PATHstorageIn-container path for uploads (logos, activity images, PDFs). Bind-mounted from $MEMSHIP_DATA_ROOT/storage, which also holds secret.key — include it in backups.
MAX_UPLOAD_SIZE_MB10Maximum upload size in megabytes.

Server

VariableDefaultDescription
HOST0.0.0.0Bind address of the backend.
PORT8000In-container backend port.

Migrations

VariableDefaultDescription
RUN_MIGRATIONS(set to 1 in Compose)When 1, the backend runs database migrations on startup. See Upgrading.