Skip to content

Instantly share code, notes, and snippets.

@johnciprian
Created December 26, 2024 23:54
Database Integration
# .devcontainer/docker-compose.yml
version: '3.8'
services:
app:
build:
context: ..
dockerfile: .devcontainer/Dockerfile
target: development
volumes:
- ..:/workspace:cached
- node_modules:/workspace/node_modules
environment:
- DATABASE_URL=postgresql://user:password@db:5432/myapp
- NODE_ENV=development
depends_on:
db:
condition: service_healthy
db:
image: postgres:14-alpine
restart: unless-stopped
volumes:
- postgres-data:/var/lib/postgresql/data
- ./init:/docker-entrypoint-initdb.d
environment:
- POSTGRES_USER=user
- POSTGRES_PASSWORD=password
- POSTGRES_DB=myapp
healthcheck:
test: ["CMD-SHELL", "pg_isready -U user -d myapp"]
interval: 5s
timeout: 5s
retries: 5
volumes:
postgres-data:
node_modules:
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment