Update.
This commit is contained in:
parent
fb6125bf38
commit
085006e500
@ -51,6 +51,7 @@ WORKDIR /app
|
||||
COPY --from=builder /install /usr/local
|
||||
|
||||
# Copy application files
|
||||
COPY prod.py .
|
||||
COPY main3.py .
|
||||
COPY gunicorn_config.py .
|
||||
COPY .env.example .env
|
||||
@ -73,6 +74,6 @@ HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 \
|
||||
ENV PYTHONUNBUFFERED=1
|
||||
ENV HOST=0.0.0.0
|
||||
ENV PORT=8080
|
||||
|
||||
ENV DB_PATH=/app/webdav.db
|
||||
# Run application
|
||||
CMD ["python", "main3.py"]
|
||||
CMD ["python", "prod.py"]
|
||||
|
||||
@ -37,7 +37,7 @@ services:
|
||||
environment:
|
||||
# Server Configuration
|
||||
- HOST=0.0.0.0
|
||||
- PORT=8080
|
||||
- PORT=8597
|
||||
|
||||
# Database
|
||||
- DB_PATH=/app/webdav.db
|
||||
@ -57,19 +57,13 @@ services:
|
||||
- LOG_LEVEL=INFO
|
||||
- LOG_FILE=/app/logs/webdav.log
|
||||
|
||||
# Cache (if Redis enabled)
|
||||
- CACHE_ENABLED=false
|
||||
- REDIS_HOST=redis
|
||||
- REDIS_PORT=6379
|
||||
|
||||
networks:
|
||||
- webdav-network
|
||||
|
||||
depends_on:
|
||||
- redis
|
||||
|
||||
healthcheck:
|
||||
test: ["CMD", "curl", "-f", "http://localhost:8080/"]
|
||||
test: ["CMD", "curl", "-f", "http://localhost:8597/"]
|
||||
interval: 30s
|
||||
timeout: 10s
|
||||
retries: 3
|
||||
@ -78,58 +72,6 @@ services:
|
||||
# --------------------------------------------------------------------------
|
||||
# Redis Cache (Optional but recommended for production)
|
||||
# --------------------------------------------------------------------------
|
||||
redis:
|
||||
image: redis:7-alpine
|
||||
container_name: webdav-redis
|
||||
restart: unless-stopped
|
||||
|
||||
ports:
|
||||
- "6379:6379"
|
||||
|
||||
volumes:
|
||||
- redis-data:/data
|
||||
|
||||
command: redis-server --appendonly yes --maxmemory 256mb --maxmemory-policy allkeys-lru
|
||||
|
||||
networks:
|
||||
- webdav-network
|
||||
|
||||
healthcheck:
|
||||
test: ["CMD", "redis-cli", "ping"]
|
||||
interval: 10s
|
||||
timeout: 5s
|
||||
retries: 3
|
||||
|
||||
# --------------------------------------------------------------------------
|
||||
# Nginx Reverse Proxy with SSL (Production)
|
||||
# --------------------------------------------------------------------------
|
||||
nginx:
|
||||
image: nginx:alpine
|
||||
container_name: webdav-nginx
|
||||
restart: unless-stopped
|
||||
|
||||
ports:
|
||||
- "80:80"
|
||||
- "443:443"
|
||||
|
||||
volumes:
|
||||
- ./nginx.conf:/etc/nginx/conf.d/webdav.conf:ro
|
||||
- ./nginx/conf.d:/etc/nginx/conf.d:ro
|
||||
- ./nginx/ssl:/etc/nginx/ssl:ro
|
||||
- ./logs/nginx:/var/log/nginx
|
||||
|
||||
networks:
|
||||
- webdav-network
|
||||
|
||||
depends_on:
|
||||
- webdav
|
||||
|
||||
healthcheck:
|
||||
test: ["CMD", "wget", "--quiet", "--tries=1", "--spider", "http://localhost/"]
|
||||
interval: 30s
|
||||
timeout: 10s
|
||||
retries: 3
|
||||
|
||||
# ============================================================================
|
||||
# Networks
|
||||
# ============================================================================
|
||||
@ -137,9 +79,3 @@ networks:
|
||||
webdav-network:
|
||||
driver: bridge
|
||||
|
||||
# ============================================================================
|
||||
# Volumes
|
||||
# ============================================================================
|
||||
volumes:
|
||||
redis-data:
|
||||
driver: local
|
||||
|
||||
8
main3.py
8
main3.py
@ -120,9 +120,13 @@ class Database:
|
||||
CREATE TABLE IF NOT EXISTS users (
|
||||
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||
username TEXT UNIQUE NOT NULL,
|
||||
email TEXT UNIQUE,
|
||||
password_hash TEXT NOT NULL,
|
||||
salt TEXT NOT NULL,
|
||||
is_active BOOLEAN DEFAULT 1
|
||||
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
|
||||
last_login TIMESTAMP,
|
||||
is_active BOOLEAN DEFAULT 1,
|
||||
role TEXT DEFAULT 'user'
|
||||
)
|
||||
''')
|
||||
|
||||
@ -742,8 +746,6 @@ async def webdav_handler_func(request: web.Request):
|
||||
app = request.app
|
||||
auth_handler: AuthHandler = app['auth']
|
||||
webdav_handler: WebDAVHandler = app['webdav']
|
||||
app.shared['counter'] = os.getpid()
|
||||
print(app.shared['counter'],os.getpid())
|
||||
# OPTIONS is often unauthenticated (pre-flight)
|
||||
if request.method == 'OPTIONS':
|
||||
return await webdav_handler.handle_options(request, {})
|
||||
|
||||
4
prod.py
4
prod.py
@ -2,7 +2,7 @@ from multiprocessing import Process, Manager
|
||||
from socket import SOL_SOCKET, SO_REUSEADDR, socket
|
||||
from aiohttp import web
|
||||
import logging
|
||||
|
||||
import os
|
||||
logging.basicConfig(level=logging.DEBUG)
|
||||
|
||||
from main3 import init_app
|
||||
@ -11,7 +11,7 @@ import asyncio
|
||||
def serve_multiple(app,workers):
|
||||
sock = socket()
|
||||
sock.setsockopt(SOL_SOCKET, SO_REUSEADDR, 1)
|
||||
sock.bind(('0.0.0.0', 8080))
|
||||
sock.bind(('0.0.0.0',int(os.getenv('PORT', '8080'))))
|
||||
sock.set_inheritable(True)
|
||||
setattr(app,"shared",Manager().dict())
|
||||
app.shared['counter'] = 0
|
||||
|
||||
Loading…
Reference in New Issue
Block a user