Bundle Postgres in default stack
This commit is contained in:
+1
-6
@@ -1,11 +1,6 @@
|
|||||||
# --- Portainer / Compose ---
|
# --- Portainer / Compose ---
|
||||||
APP_PORT="3000"
|
APP_PORT="3000"
|
||||||
DATABASE_URL="postgresql://user:password@postgres-host:5432/formbuilder"
|
POSTGRES_PASSWORD="change-this"
|
||||||
|
|
||||||
# Only needed if using docker-compose.postgres.yml instead of an existing DB.
|
|
||||||
# POSTGRES_DB="formbuilder"
|
|
||||||
# POSTGRES_USER="formbuilder"
|
|
||||||
# POSTGRES_PASSWORD="change-this"
|
|
||||||
|
|
||||||
# --- Auth.js ---
|
# --- Auth.js ---
|
||||||
# Generate with: openssl rand -base64 32
|
# Generate with: openssl rand -base64 32
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ The app container runs `prisma migrate deploy` before starting the Next.js stand
|
|||||||
|
|
||||||
```bash
|
```bash
|
||||||
APP_PORT=3000
|
APP_PORT=3000
|
||||||
DATABASE_URL=postgresql://user:password@postgres-host:5432/formbuilder
|
POSTGRES_PASSWORD=replace-with-a-strong-password
|
||||||
|
|
||||||
AUTH_SECRET=replace-with-openssl-rand-base64-32
|
AUTH_SECRET=replace-with-openssl-rand-base64-32
|
||||||
AUTH_URL=https://forms.example.com
|
AUTH_URL=https://forms.example.com
|
||||||
@@ -32,12 +32,6 @@ [email protected]
|
|||||||
|
|
||||||
Optional values are documented in `.env.example` for Redis rate limiting, email, file storage, hCaptcha, and webhook worker auth.
|
Optional values are documented in `.env.example` for Redis rate limiting, email, file storage, hCaptcha, and webhook worker auth.
|
||||||
|
|
||||||
If you do not already have Postgres, deploy with both Compose files and set `POSTGRES_PASSWORD`:
|
|
||||||
|
|
||||||
```bash
|
|
||||||
docker compose -f docker-compose.yml -f docker-compose.postgres.yml up --build
|
|
||||||
```
|
|
||||||
|
|
||||||
## Authentik Setup
|
## Authentik Setup
|
||||||
|
|
||||||
Create an OAuth2/OpenID provider in Authentik:
|
Create an OAuth2/OpenID provider in Authentik:
|
||||||
@@ -54,12 +48,11 @@ The first successful signer becomes an admin. Any emails listed in `AUTH_BOOTSTR
|
|||||||
|
|
||||||
## Persistent Data
|
## Persistent Data
|
||||||
|
|
||||||
The default compose stack creates one named volume:
|
The compose stack creates two named volumes:
|
||||||
|
|
||||||
|
- `postgres_data`: bundled Postgres database
|
||||||
- `uploads`: local uploaded files mounted at `/app/uploads`
|
- `uploads`: local uploaded files mounted at `/app/uploads`
|
||||||
|
|
||||||
When using `docker-compose.postgres.yml`, it also creates `postgres_data` for the bundled database.
|
|
||||||
|
|
||||||
For multi-instance deployments, set `RATE_LIMIT_DRIVER=redis` and provide `REDIS_URL`. For durable object storage outside the app container, configure the S3 values in `.env.example`.
|
For multi-instance deployments, set `RATE_LIMIT_DRIVER=redis` and provide `REDIS_URL`. For durable object storage outside the app container, configure the S3 values in `.env.example`.
|
||||||
|
|
||||||
## Useful Commands
|
## Useful Commands
|
||||||
|
|||||||
@@ -1,25 +0,0 @@
|
|||||||
services:
|
|
||||||
app:
|
|
||||||
depends_on:
|
|
||||||
postgres:
|
|
||||||
condition: service_healthy
|
|
||||||
environment:
|
|
||||||
DATABASE_URL: postgresql://${POSTGRES_USER:-formbuilder}:${POSTGRES_PASSWORD:?set POSTGRES_PASSWORD}@postgres:5432/${POSTGRES_DB:-formbuilder}
|
|
||||||
|
|
||||||
postgres:
|
|
||||||
image: postgres:16-alpine
|
|
||||||
restart: unless-stopped
|
|
||||||
environment:
|
|
||||||
POSTGRES_DB: ${POSTGRES_DB:-formbuilder}
|
|
||||||
POSTGRES_USER: ${POSTGRES_USER:-formbuilder}
|
|
||||||
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:?set POSTGRES_PASSWORD}
|
|
||||||
volumes:
|
|
||||||
- postgres_data:/var/lib/postgresql/data
|
|
||||||
healthcheck:
|
|
||||||
test: ["CMD-SHELL", "pg_isready -U ${POSTGRES_USER:-formbuilder} -d ${POSTGRES_DB:-formbuilder}"]
|
|
||||||
interval: 10s
|
|
||||||
timeout: 5s
|
|
||||||
retries: 5
|
|
||||||
|
|
||||||
volumes:
|
|
||||||
postgres_data:
|
|
||||||
+20
-1
@@ -4,10 +4,13 @@ services:
|
|||||||
context: .
|
context: .
|
||||||
dockerfile: Dockerfile
|
dockerfile: Dockerfile
|
||||||
restart: unless-stopped
|
restart: unless-stopped
|
||||||
|
depends_on:
|
||||||
|
postgres:
|
||||||
|
condition: service_healthy
|
||||||
environment:
|
environment:
|
||||||
NODE_ENV: production
|
NODE_ENV: production
|
||||||
PORT: 3000
|
PORT: 3000
|
||||||
DATABASE_URL: ${DATABASE_URL:?set DATABASE_URL}
|
DATABASE_URL: postgresql://formbuilder:${POSTGRES_PASSWORD:?set POSTGRES_PASSWORD}@postgres:5432/formbuilder
|
||||||
AUTH_SECRET: ${AUTH_SECRET:?set AUTH_SECRET}
|
AUTH_SECRET: ${AUTH_SECRET:?set AUTH_SECRET}
|
||||||
AUTH_URL: ${AUTH_URL:?set AUTH_URL}
|
AUTH_URL: ${AUTH_URL:?set AUTH_URL}
|
||||||
PUBLIC_BASE_URL: ${AUTH_URL}
|
PUBLIC_BASE_URL: ${AUTH_URL}
|
||||||
@@ -37,5 +40,21 @@ services:
|
|||||||
volumes:
|
volumes:
|
||||||
- uploads:/app/uploads
|
- uploads:/app/uploads
|
||||||
|
|
||||||
|
postgres:
|
||||||
|
image: postgres:16-alpine
|
||||||
|
restart: unless-stopped
|
||||||
|
environment:
|
||||||
|
POSTGRES_DB: formbuilder
|
||||||
|
POSTGRES_USER: formbuilder
|
||||||
|
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:?set POSTGRES_PASSWORD}
|
||||||
volumes:
|
volumes:
|
||||||
|
- postgres_data:/var/lib/postgresql/data
|
||||||
|
healthcheck:
|
||||||
|
test: ["CMD-SHELL", "pg_isready -U formbuilder -d formbuilder"]
|
||||||
|
interval: 10s
|
||||||
|
timeout: 5s
|
||||||
|
retries: 5
|
||||||
|
|
||||||
|
volumes:
|
||||||
|
postgres_data:
|
||||||
uploads:
|
uploads:
|
||||||
|
|||||||
Reference in New Issue
Block a user