Merge pull request #6 from creativenoz/feature/postgres-config
chore(postgres_db): Relocated database files to outside backend, init DockerFile, expand docker-compose
This commit is contained in:
commit
a0dba4261f
|
|
@ -0,0 +1,33 @@
|
|||
# backend/Dockerfile.dev
|
||||
# Development Dockerfile with hot reload support
|
||||
|
||||
# Stage 1: Base image with Go tools
|
||||
FROM golang:1.21-alpine AS base
|
||||
|
||||
# Install developement tools
|
||||
# - git: Required for go get
|
||||
# - gcc, musl-dev: Required for CGO (some packages need C compiler)
|
||||
# - air: Hot reload tool for GO
|
||||
RUN apk add --no-cache \
|
||||
git \
|
||||
gcc \
|
||||
musl-dev && \
|
||||
go install github.com/air-verse/air@latest
|
||||
|
||||
|
||||
# Set working directory
|
||||
WORKDIR /app
|
||||
|
||||
# Stage 2: Development environment
|
||||
FROM base as development
|
||||
|
||||
# Copy dependency files first (for layer caching)
|
||||
COPY go.mod go.sum./
|
||||
|
||||
# Download dependencies
|
||||
# This layer is cached unless go.mod or go.sum changes
|
||||
RUN go mod download
|
||||
|
||||
# Copy Air configuration
|
||||
|
||||
COPY .air.t
|
||||
|
|
@ -1,6 +1,10 @@
|
|||
# docker-compose.yml
|
||||
version: '3.8'
|
||||
|
||||
# Define all services that make up Aurganize
|
||||
services:
|
||||
|
||||
# PostgreSQL 14 - Primary database
|
||||
postgres:
|
||||
image: postgres:14-alpine
|
||||
container_name: aurganize-postgres
|
||||
|
|
@ -21,5 +25,147 @@ services:
|
|||
timeout: 5s
|
||||
retries: 5
|
||||
|
||||
networks:
|
||||
- aurganize-network
|
||||
|
||||
# Redis 7 - Caching and session storage
|
||||
redis:
|
||||
image: redis:7-alpine
|
||||
container_name: aurganize-redis
|
||||
restart: unless-stopped
|
||||
command: redis-server --appendonly yes
|
||||
ports:
|
||||
- "6379:6379"
|
||||
volumes:
|
||||
- redis_data:/data
|
||||
healthcheck:
|
||||
test: ["CMD", "redis-cli", "ping"]
|
||||
interval: 10s
|
||||
timeout: 5s
|
||||
retries: 5
|
||||
networks:
|
||||
- aurganize-network
|
||||
|
||||
# NATS with JetStream - Event bus
|
||||
nats:
|
||||
image: nats:latest
|
||||
container_name: aurganize-nats
|
||||
restart: unless-stopped
|
||||
command: ["-js", "-m", "8222"]
|
||||
ports:
|
||||
- "4222:4222" # Client connections
|
||||
- "8222:8222" # HTTP monitoring
|
||||
volumes:
|
||||
- nats_data:/data
|
||||
healthcheck:
|
||||
test: ["CMD", "wget", "--spider", "-q", "http://localhost:8222/healthz"]
|
||||
interval: 10s
|
||||
timeout: 5s
|
||||
retries: 5
|
||||
networks:
|
||||
- aurganize-network
|
||||
|
||||
# MinIO - S3-compatible object storage
|
||||
minio:
|
||||
image: minio/minio:latest
|
||||
container_name: aurganize-minio
|
||||
restart: unless-stopped
|
||||
command: server /data --console-address ":9001"
|
||||
environment:
|
||||
MINIO_ROOT_USER: minioadmin
|
||||
MINIO_ROOT_PASSWORD: minioadmin
|
||||
ports:
|
||||
- "9000:9000" # API
|
||||
- "9001:9001" # Web Console
|
||||
volumes:
|
||||
- minio_data:/data
|
||||
healthcheck:
|
||||
test: ["CMD", "curl", "-f", "http://localhost:9000/minio/health/live"]
|
||||
interval: 10s
|
||||
timeout: 5s
|
||||
retries: 5
|
||||
networks:
|
||||
- aurganize-network
|
||||
|
||||
# Backend - Go API server
|
||||
backend:
|
||||
build:
|
||||
context: ./../../backend
|
||||
dockerfile: Dockerfile.dev
|
||||
container_name: aurganize-backend
|
||||
restart: unless-stopped
|
||||
environment:
|
||||
# Application config
|
||||
ENV: development
|
||||
PORT: 8080
|
||||
|
||||
# Database connection
|
||||
DB_HOST: postgres
|
||||
DB_PORT: 5432
|
||||
DB_USER: aurganize
|
||||
DB_PASSWORD: dev_password_change_in_prod
|
||||
DB_NAME: aurganize
|
||||
DB_SSL_MODE: disable
|
||||
|
||||
# Redis connection
|
||||
REDIS_HOST: redis
|
||||
REDIS_PORT: 6379
|
||||
REDIS_PASSWORD: ""
|
||||
|
||||
# NATS connection
|
||||
NATS_URL: nats://nats:4222
|
||||
|
||||
# MinIO connection
|
||||
MINIO_ENDPOINT: minio:9000
|
||||
MINIO_ACCESS_KEY: minioadmin
|
||||
MINIO_SECRET_KEY: minioadmin
|
||||
MINIO_USE_SSL: false
|
||||
|
||||
# JWT secrets (development only)
|
||||
JWT_SECRET: dev-secret-change-in-production
|
||||
|
||||
# CORS settings
|
||||
CORS_ORIGINS: http://localhost:3000
|
||||
ports:
|
||||
- "8080:8080"
|
||||
volumes:
|
||||
# Mount source code for hot reload
|
||||
- ./backend:/app
|
||||
# Exclude node_modules and vendor
|
||||
- /app/vendor
|
||||
- /app/bin
|
||||
depends_on:
|
||||
postgres:
|
||||
condition: service_healthy
|
||||
redis:
|
||||
condition: service_healthy
|
||||
nats:
|
||||
condition: service_healthy
|
||||
minio:
|
||||
condition: service_healthy
|
||||
healthcheck:
|
||||
test: ["CMD", "wget", "--spider", "-q", "http://localhost:8080/health"]
|
||||
interval: 10s
|
||||
timeout: 5s
|
||||
retries: 5
|
||||
networks:
|
||||
- aurganize-network
|
||||
|
||||
# Frontend - React application
|
||||
# TODO
|
||||
|
||||
# Named volumes for data persistence
|
||||
volumes:
|
||||
postgres_data:
|
||||
driver: local
|
||||
redis_data:
|
||||
driver: local
|
||||
nats_data:
|
||||
driver: local
|
||||
minio_data:
|
||||
driver: local
|
||||
|
||||
# Custom network for service isolation
|
||||
networks:
|
||||
aurganize-network:
|
||||
driver: bridge
|
||||
Loading…
Reference in New Issue