Skip to content

Commit d875e25

Browse files
committed
security: use environment variables for secrets in docker-compose
- All secrets now sourced from .env file (gitignored) - Added .env.example template for developers - Public repo safe - no hardcoded secrets
1 parent a2fd4c0 commit d875e25

2 files changed

Lines changed: 30 additions & 12 deletions

File tree

.env.example

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# Separ Local Development Environment
2+
# Copy this file to .env and fill in the values
3+
# DO NOT commit .env to version control!
4+
5+
# PostgreSQL Configuration
6+
POSTGRES_USER=separ
7+
POSTGRES_PASSWORD=your-secure-postgres-password
8+
POSTGRES_DB=separ
9+
10+
# SpiceDB Configuration
11+
SPICEDB_PRESHARED_KEY=your-secure-spicedb-key
12+
13+
# JWT Configuration
14+
JWT_SECRET=your-secure-jwt-secret-min-32-chars
15+
JWT_ISSUER=separ
16+
17+
# Logging (optional)
18+
RUST_LOG=info,separ=debug

docker-compose.yml

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,15 @@ services:
44
image: postgres:16-alpine
55
container_name: separ-postgres
66
environment:
7-
POSTGRES_USER: separ
8-
POSTGRES_PASSWORD: separ
9-
POSTGRES_DB: separ
7+
POSTGRES_USER: ${POSTGRES_USER:-separ}
8+
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD}
9+
POSTGRES_DB: ${POSTGRES_DB:-separ}
1010
ports:
1111
- "5433:5432"
1212
volumes:
1313
- postgres_data:/var/lib/postgresql/data
1414
healthcheck:
15-
test: ["CMD-SHELL", "pg_isready -U separ"]
15+
test: ["CMD-SHELL", "pg_isready -U ${POSTGRES_USER:-separ}"]
1616
interval: 5s
1717
timeout: 5s
1818
retries: 5
@@ -21,7 +21,7 @@ services:
2121
spicedb:
2222
image: authzed/spicedb:latest
2323
container_name: separ-spicedb
24-
command: serve --grpc-preshared-key "supersecretkey"
24+
command: serve --grpc-preshared-key "${SPICEDB_PRESHARED_KEY}"
2525
ports:
2626
- "50051:50051" # gRPC
2727
- "8443:8443" # HTTP/REST
@@ -30,7 +30,7 @@ services:
3030
condition: service_healthy
3131
environment:
3232
SPICEDB_DATASTORE_ENGINE: postgres
33-
SPICEDB_DATASTORE_CONN_URI: "postgres://separ:separ@postgres:5432/separ?sslmode=disable"
33+
SPICEDB_DATASTORE_CONN_URI: "postgres://${POSTGRES_USER:-separ}:${POSTGRES_PASSWORD}@postgres:5432/${POSTGRES_DB:-separ}?sslmode=disable"
3434
healthcheck:
3535
test: ["CMD", "grpc_health_probe", "-addr=localhost:50051"]
3636
interval: 10s
@@ -42,7 +42,7 @@ services:
4242
spicedb-migrate:
4343
image: authzed/spicedb:latest
4444
container_name: separ-spicedb-migrate
45-
command: migrate head --datastore-engine postgres --datastore-conn-uri "postgres://separ:separ@postgres:5432/separ?sslmode=disable"
45+
command: migrate head --datastore-engine postgres --datastore-conn-uri "postgres://${POSTGRES_USER:-separ}:${POSTGRES_PASSWORD}@postgres:5432/${POSTGRES_DB:-separ}?sslmode=disable"
4646
depends_on:
4747
postgres:
4848
condition: service_healthy
@@ -58,12 +58,12 @@ services:
5858
environment:
5959
SEPAR__SERVER__HOST: "0.0.0.0"
6060
SEPAR__SERVER__PORT: "8080"
61-
SEPAR__DATABASE__URL: "postgres://separ:separ@postgres:5432/separ"
61+
SEPAR__DATABASE__URL: "postgres://${POSTGRES_USER:-separ}:${POSTGRES_PASSWORD}@postgres:5432/${POSTGRES_DB:-separ}"
6262
SEPAR__SPICEDB__ENDPOINT: "http://spicedb:50051"
63-
SEPAR__SPICEDB__TOKEN: "supersecretkey"
64-
SEPAR__JWT__SECRET: "local-dev-only-not-for-production-generate-strong-secret"
65-
SEPAR__JWT__ISSUER: "separ"
66-
RUST_LOG: "info,separ=debug"
63+
SEPAR__SPICEDB__TOKEN: "${SPICEDB_PRESHARED_KEY}"
64+
SEPAR__JWT__SECRET: "${JWT_SECRET}"
65+
SEPAR__JWT__ISSUER: "${JWT_ISSUER:-separ}"
66+
RUST_LOG: "${RUST_LOG:-info,separ=debug}"
6767
depends_on:
6868
postgres:
6969
condition: service_healthy

0 commit comments

Comments
 (0)