Moved docker
This commit is contained in:
21
splitchat/.dockerignore
Normal file
21
splitchat/.dockerignore
Normal file
@@ -0,0 +1,21 @@
|
||||
venv/
|
||||
__pycache__/
|
||||
*.pyc
|
||||
*.pyo
|
||||
*.pyd
|
||||
.Python
|
||||
*.so
|
||||
*.egg
|
||||
*.egg-info/
|
||||
dist/
|
||||
build/
|
||||
.env
|
||||
.env.local
|
||||
.git/
|
||||
.gitignore
|
||||
README.md
|
||||
tree
|
||||
db.sqlite3
|
||||
*.sqlite3
|
||||
.DS_Store
|
||||
*.log
|
||||
42
splitchat/Dockerfile
Normal file
42
splitchat/Dockerfile
Normal file
@@ -0,0 +1,42 @@
|
||||
FROM python:3.14-slim-bookworm
|
||||
|
||||
# Set environment variables
|
||||
ENV PYTHONDONTWRITEBYTECODE=1 \
|
||||
PYTHONUNBUFFERED=1 \
|
||||
DJANGO_SETTINGS_MODULE=config.settings
|
||||
|
||||
# Set work directory
|
||||
WORKDIR /app
|
||||
|
||||
# Install system dependencies
|
||||
RUN apt-get update && apt-get install -y --no-install-recommends \
|
||||
libpq-dev \
|
||||
gcc \
|
||||
curl \
|
||||
&& rm -rf /var/lib/apt/lists/*
|
||||
|
||||
# Copy requirements first for better caching
|
||||
COPY requirements.txt .
|
||||
|
||||
# Install Python dependencies
|
||||
RUN pip install --no-cache-dir -r requirements.txt
|
||||
|
||||
# Copy project files
|
||||
COPY . .
|
||||
|
||||
# Create necessary directories
|
||||
RUN mkdir -p /app/staticfiles /app/static /app/media
|
||||
|
||||
# Collect static files
|
||||
RUN python manage.py collectstatic --noinput
|
||||
|
||||
# Create a non-root user
|
||||
RUN addgroup --system app && adduser --system --group app
|
||||
RUN chown -R app:app /app
|
||||
|
||||
USER app
|
||||
|
||||
EXPOSE 8000
|
||||
|
||||
# Use Daphne for WebSocket support
|
||||
CMD ["daphne", "-b", "0.0.0.0", "-p", "8000", "config.asgi:application"]
|
||||
31
splitchat/Dockerfile.dev
Normal file
31
splitchat/Dockerfile.dev
Normal file
@@ -0,0 +1,31 @@
|
||||
|
||||
FROM python:3.14-slim-bookworm
|
||||
|
||||
ENV PYTHONDONTWRITEBYTECODE=1 \
|
||||
PYTHONUNBUFFERED=1 \
|
||||
DJANGO_SETTINGS_MODULE=config.settings
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
RUN apt-get update && apt-get install -y --no-install-recommends \
|
||||
libpq-dev \
|
||||
gcc \
|
||||
&& rm -rf /var/lib/apt/lists/*
|
||||
|
||||
COPY requirements.txt .
|
||||
RUN pip install --no-cache-dir -r requirements.txt
|
||||
|
||||
# Install development tools
|
||||
RUN pip install watchdog
|
||||
|
||||
COPY . .
|
||||
|
||||
# Create directory for static files
|
||||
RUN mkdir -p /app/staticfiles
|
||||
|
||||
# Don't collect static in dev mode (runserver handles it)
|
||||
|
||||
EXPOSE 8000
|
||||
|
||||
# Run with hot reload using watchdog
|
||||
CMD ["python", "manage.py", "runserver", "0.0.0.0:8000"]
|
||||
21
splitchat/docker-compose.dev.yml
Normal file
21
splitchat/docker-compose.dev.yml
Normal file
@@ -0,0 +1,21 @@
|
||||
version: '3.8'
|
||||
|
||||
services:
|
||||
web:
|
||||
build:
|
||||
context: .
|
||||
dockerfile: Dockerfile.dev
|
||||
ports:
|
||||
- "8001:8000"
|
||||
volumes:
|
||||
- .:/app
|
||||
- /app/venv # Exclude venv
|
||||
environment:
|
||||
- SECRET_KEY=dev-secret-key-change-in-production
|
||||
- DEBUG=True
|
||||
- ALLOWED_HOSTS=localhost,127.0.0.1,web
|
||||
- DATABASE_URL=sqlite:///db.sqlite3
|
||||
# No REDIS_URL - will use in-memory channel layer
|
||||
command: python manage.py runserver 0.0.0.0:8000
|
||||
# Or use daphne for WebSocket testing:
|
||||
# command: daphne -b 0.0.0.0 -p 8000 config.asgi:application
|
||||
80
splitchat/docker-compose.yml
Normal file
80
splitchat/docker-compose.yml
Normal file
@@ -0,0 +1,80 @@
|
||||
version: '3.8'
|
||||
|
||||
services:
|
||||
redis:
|
||||
image: redis:7-alpine
|
||||
command: redis-server --appendonly yes
|
||||
volumes:
|
||||
- redis_data:/data
|
||||
restart: unless-stopped
|
||||
healthcheck:
|
||||
test: ["CMD", "redis-cli", "ping"]
|
||||
interval: 5s
|
||||
timeout: 3s
|
||||
retries: 5
|
||||
networks:
|
||||
- splitchat_network
|
||||
|
||||
db:
|
||||
image: postgres:16-alpine
|
||||
environment:
|
||||
POSTGRES_DB: splitchat
|
||||
POSTGRES_USER: splitchat
|
||||
POSTGRES_PASSWORD: ${DB_PASSWORD:-splitchat_password_123}
|
||||
volumes:
|
||||
- postgres_data:/var/lib/postgresql/data
|
||||
restart: unless-stopped
|
||||
healthcheck:
|
||||
test: ["CMD-SHELL", "pg_isready -U splitchat"]
|
||||
interval: 10s
|
||||
timeout: 5s
|
||||
retries: 5
|
||||
networks:
|
||||
- splitchat_network
|
||||
|
||||
web:
|
||||
build: .
|
||||
expose:
|
||||
- "8000"
|
||||
volumes:
|
||||
- static_volume:/app/staticfiles
|
||||
- media_volume:/app/media
|
||||
environment:
|
||||
- SECRET_KEY=${SECRET_KEY}
|
||||
- DEBUG=${DEBUG:-False}
|
||||
- ALLOWED_HOSTS=${ALLOWED_HOSTS:-localhost,127.0.0.1}
|
||||
- DATABASE_URL=postgres://splitchat:${DB_PASSWORD:-splitchat_password_123}@db:5432/splitchat
|
||||
- REDIS_URL=redis://redis:6379/0
|
||||
depends_on:
|
||||
db:
|
||||
condition: service_healthy
|
||||
redis:
|
||||
condition: service_healthy
|
||||
restart: unless-stopped
|
||||
networks:
|
||||
- splitchat_network
|
||||
|
||||
# Optional: Nginx for serving static files (if you want to offload from Django)
|
||||
nginx:
|
||||
image: nginx:alpine
|
||||
ports:
|
||||
- "8002:80"
|
||||
volumes:
|
||||
- ./nginx.conf:/etc/nginx/conf.d/default.conf:ro
|
||||
- static_volume:/static:ro
|
||||
- media_volume:/media:ro
|
||||
depends_on:
|
||||
- web
|
||||
restart: unless-stopped
|
||||
networks:
|
||||
- splitchat_network
|
||||
|
||||
volumes:
|
||||
postgres_data:
|
||||
redis_data:
|
||||
static_volume:
|
||||
media_volume:
|
||||
|
||||
networks:
|
||||
splitchat_network:
|
||||
driver: bridge
|
||||
Reference in New Issue
Block a user