Local Development

This guide will help you set up your local development environment for saasbrella, including the necessary services like PostgreSQL and MinIO S3 storage.

Prerequisites

To run the application locally, you need to have the following:

Setting Up Local Services

Create a docker-compose.yml file in your project root with the following configuration:

docker-compose.yml
version: '3.8'
services:
postgres:
image: postgres:15-alpine
container_name: saasbrella-postgres
environment:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
POSTGRES_DB: saasbrella
ports:
- "5432:5432"
volumes:
- postgres_data:/var/lib/postgresql/data
healthcheck:
test: ["CMD-SHELL", "pg_isready -U postgres"]
interval: 5s
timeout: 5s
retries: 5
minio:
image: minio/minio
container_name: saasbrella-minio
environment:
MINIO_ROOT_USER: minioadmin
MINIO_ROOT_PASSWORD: minioadmin
ports:
- "9000:9000"
- "9001:9001"
volumes:
- minio_data:/data
command: server /data --console-address ":9001"
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:9000/minio/health/live"]
interval: 30s
timeout: 20s
retries: 3
volumes:
postgres_data:
minio_data:

Starting the Services

  1. Start the services using Docker Compose:
Terminal window
docker-compose up -d
  1. Verify that the services are running:
Terminal window
docker-compose ps

Environment Configuration

Create or update your .env file with the following configuration:

# Database
DATABASE_URL="postgresql://postgres:postgres@localhost:5432/saasbrella"
# MinIO S3
S3_ACCESS_KEY_ID="minioadmin"
S3_SECRET_ACCESS_KEY="minioadmin"
S3_BUCKET="saasbrella"
S3_REGION="us-east-1"
S3_ENDPOINT="http://localhost:9000"

Accessing the Services

  • PostgreSQL:

    • Host: localhost
    • Port: 5432
    • Username: postgres
    • Password: postgres
    • Database: saasbrella
  • MinIO Console:

Creating the S3 Bucket

  1. Access the MinIO Console at http://localhost:9001
  2. Log in with the credentials above
  3. Click “Create Bucket”
  4. Name it “avatars”
  5. Click “Create Bucket”

Start saasbrella development server

Start the development server:

Terminal window
pnpm dev

Your saasbrella application should now be running with the local PostgreSQL database and MinIO S3 storage.

Troubleshooting

Database Connection Issues

If you’re having trouble connecting to PostgreSQL:

  1. Verify the database is running:
Terminal window
docker-compose ps postgres
  1. Check the logs:
Terminal window
docker-compose logs postgres

S3 Storage Issues

If you’re having trouble with S3 storage:

  1. Verify MinIO is running:
Terminal window
docker-compose ps minio
  1. Check the logs:
Terminal window
docker-compose logs minio
  1. Ensure the bucket exists in the MinIO Console

Stopping the Services

To stop all services:

Terminal window
docker-compose down

To stop and remove all data (including volumes):

Terminal window
docker-compose down -v

Additional Resources