By default, the docker-compose setup now supports both internal and external PostgreSQL:
Perfect for production or when you already have PostgreSQL running.
1. Configure .env file:
# Copy the example
cp .env.docker .env
# Edit .env with your database settings
DB_HOST=localhost # or your PostgreSQL host
DB_PORT=5432
DB_USER=postgres
DB_PASSWORD=your_secure_password
DB_NAME=appvault
DB_SSLMODE=disable # use 'require' for production2. Create the database:
CREATE DATABASE appvault;3. Run migrations:
# Apply database schema
psql -h localhost -U postgres -d appvault -f migrations/001_initial_schema.sql4. Start services (WITHOUT internal PostgreSQL):
docker-compose up -dThis will start only the appvault backend and web frontend, connecting to your external database.
For development or testing environments.
1. Configure .env file:
cp .env.docker .env
# Use these settings in .env
DB_HOST=postgres # Docker service name
DB_PORT=5432
DB_USER=postgres
DB_PASSWORD=postgres
DB_NAME=appvault
DB_SSLMODE=disable2. Start services WITH internal PostgreSQL:
docker-compose --profile with-postgres up -dThis will start all services including the PostgreSQL container.
# Start without internal postgres
docker-compose up -d
# Check logs
docker-compose logs -f appvault
# Stop services
docker-compose down# Start with internal postgres
docker-compose --profile with-postgres up -d
# Check postgres logs
docker-compose --profile with-postgres logs postgres
# Stop all including postgres
docker-compose --profile with-postgres down
# Remove postgres data
docker-compose --profile with-postgres down -vUsing external PostgreSQL:
# Terminal 1 - Backend
export DB_HOST=localhost
export DB_PORT=5432
export DB_USER=postgres
export DB_PASSWORD=your_password
export DB_NAME=appvault
export DB_SSLMODE=disable
go run cmd/server/main.go
# Terminal 2 - Frontend
cd web
npm run devThe application uses this connection string format:
postgres://USER:PASSWORD@HOST:PORT/DATABASE?sslmode=SSLMODE
Example:
postgres://postgres:mypassword@localhost:5432/appvault?sslmode=disable
| Variable | Description | Default | Example |
|---|---|---|---|
DB_HOST |
PostgreSQL host | postgres |
localhost, db.example.com |
DB_PORT |
PostgreSQL port | 5432 |
5432 |
DB_USER |
Database user | postgres |
appvault_user |
DB_PASSWORD |
Database password | postgres |
secure_password_123 |
DB_NAME |
Database name | appvault |
appvault_prod |
DB_SSLMODE |
SSL mode | disable |
require, verify-full |
1. Check if PostgreSQL is running:
# For external DB
pg_isready -h localhost -p 5432
# For docker compose postgres
docker ps | grep postgres2. Check environment variables:
docker exec appvault-server env | grep DB_3. Test connection manually:
psql -h localhost -U postgres -d appvault4. Check backend logs:
docker-compose logs appvaultError: "connection refused"
- Check if PostgreSQL is running
- Verify
DB_HOSTandDB_PORTare correct - For external DB: use
localhostor actual IP - For docker: use service name
postgres
Error: "role does not exist"
- Create the database user:
CREATE USER postgres WITH PASSWORD 'your_password';
GRANT ALL PRIVILEGES ON DATABASE appvault TO postgres;Error: "database does not exist"
- Create the database:
CREATE DATABASE appvault;For production deployments with external PostgreSQL:
- Use SSL/TLS: Set
DB_SSLMODE=requireorverify-full - Strong Password: Use a secure, randomly generated password
- Dedicated User: Create a dedicated database user (not
postgres) - Connection Pooling: Configure max connections in PostgreSQL
- Backups: Set up regular automated backups
- Monitoring: Monitor connection pool usage and query performance
# Production .env example
DB_HOST=postgres.internal.example.com
DB_PORT=5432
DB_USER=appvault_prod
DB_PASSWORD=very_secure_random_password_here
DB_NAME=appvault_production
DB_SSLMODE=requireQuick Start:
- External DB:
docker-compose up -d - Internal DB:
docker-compose --profile with-postgres up -d
The new setup gives you flexibility - use what works best for your environment! 🚀