Skip to content

cycle-sync-ai/db-deployment

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

PostgreSQL Docker Deployment

This project provides a Docker Compose setup for deploying PostgreSQL with external access.

Features

  • PostgreSQL 15 with external port access
  • Persistent data storage
  • Health checks
  • Environment variable configuration
  • Custom initialization scripts support

Quick Start

  1. Copy environment file:

    cp env.example .env
  2. Edit environment variables (optional):

    nano .env
  3. Start the database:

    docker-compose up -d
  4. Check status:

    docker-compose ps

Connection Details

  • Host: localhost (or your server IP)
  • Port: 5432 (or custom port from .env)
  • Database: postgres (or custom from .env)
  • Username: postgres (or custom from .env)
  • Password: postgres (or custom from .env)

External Access

The PostgreSQL container is configured to be accessible from outside Docker:

  • Port 5432 is mapped to the host
  • Network is configured as bridge for external connectivity
  • No firewall restrictions within Docker

Management Commands

# Start services
docker-compose up -d

# Stop services
docker-compose down

# View logs
docker-compose logs postgres

# Access PostgreSQL shell
docker-compose exec postgres psql -U postgres

# Backup database
docker-compose exec postgres pg_dump -U postgres postgres > backup.sql

# Restore database
docker-compose exec -T postgres psql -U postgres postgres < backup.sql

Data Persistence

  • Database data is stored in a named volume postgres_data
  • Data persists between container restarts
  • To completely reset: docker-compose down -v

Security Notes

⚠️ Important: Change default passwords in production!

  • Update .env file with strong passwords
  • Consider using Docker secrets for production
  • Restrict network access as needed

Customization

Add initialization scripts:

Place SQL files in ./init-scripts/ directory - they will run on first startup.

Change PostgreSQL version:

Modify the image: postgres:15 line in docker-compose.yml

Add additional services:

Extend the compose file with other services as needed.

Troubleshooting

Connection refused:

  • Check if container is running: docker-compose ps
  • Verify port mapping: docker-compose port postgres 5432
  • Check logs: docker-compose logs postgres

Permission denied:

  • Ensure proper file permissions on mounted volumes
  • Check PostgreSQL user configuration in environment variables

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages