容器
This commit is contained in:
parent
188270586a
commit
5771d34359
@ -1,4 +1,4 @@
|
|||||||
FROM python:3.9-slim
|
FROM python:3.11.4-slim
|
||||||
|
|
||||||
# 设置工作目录
|
# 设置工作目录
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
@ -7,7 +7,7 @@ WORKDIR /app
|
|||||||
ENV PYTHONDONTWRITEBYTECODE=1
|
ENV PYTHONDONTWRITEBYTECODE=1
|
||||||
ENV PYTHONUNBUFFERED=1
|
ENV PYTHONUNBUFFERED=1
|
||||||
ENV FLASK_APP=app.py
|
ENV FLASK_APP=app.py
|
||||||
ENV FLASK_ENV=production
|
# FLASK_ENV 和其他环境变量将在 docker-compose.yml 中设置
|
||||||
|
|
||||||
# 安装系统依赖
|
# 安装系统依赖
|
||||||
RUN apt-get update && apt-get install -y \
|
RUN apt-get update && apt-get install -y \
|
||||||
@ -17,6 +17,9 @@ RUN apt-get update && apt-get install -y \
|
|||||||
# 复制依赖文件
|
# 复制依赖文件
|
||||||
COPY requirements.txt .
|
COPY requirements.txt .
|
||||||
|
|
||||||
|
# 配置pip国内镜像源 (以阿里云为例)
|
||||||
|
RUN pip config set global.index-url https://pypi.tuna.tsinghua.edu.cn/simple
|
||||||
|
|
||||||
# 安装Python依赖
|
# 安装Python依赖
|
||||||
RUN pip install --no-cache-dir -r requirements.txt
|
RUN pip install --no-cache-dir -r requirements.txt
|
||||||
|
|
||||||
|
|||||||
@ -1,17 +1,42 @@
|
|||||||
version: '3.8'
|
version: '3.8'
|
||||||
|
|
||||||
services:
|
services:
|
||||||
video-api:
|
# 开发环境
|
||||||
|
# hs-video-api-dev:
|
||||||
|
# build: .
|
||||||
|
# container_name: hs-video-api-dev
|
||||||
|
# ports:
|
||||||
|
# - "8443:5000"
|
||||||
|
# env_file:
|
||||||
|
# - .env.dev
|
||||||
|
# environment:
|
||||||
|
# - FLASK_ENV=development
|
||||||
|
# - APP_ENV=dev
|
||||||
|
# - SECRET_KEY=${DEV_SECRET_KEY:-dev-secret-key}
|
||||||
|
# volumes:
|
||||||
|
# - ./logs:/app/logs
|
||||||
|
# restart: unless-stopped
|
||||||
|
# healthcheck:
|
||||||
|
# test: ["CMD", "curl", "-f", "http://localhost:5000/health"]
|
||||||
|
# interval: 30s
|
||||||
|
# timeout: 10s
|
||||||
|
# retries: 3
|
||||||
|
# start_period: 40s
|
||||||
|
|
||||||
|
# 测试环境
|
||||||
|
hs-video-api-test:
|
||||||
build: .
|
build: .
|
||||||
container_name: hs-video-api
|
container_name: hs-video-api-test
|
||||||
ports:
|
ports:
|
||||||
- "5000:5000"
|
- "8443:5000"
|
||||||
|
env_file:
|
||||||
|
- .env.dev-server
|
||||||
environment:
|
environment:
|
||||||
- FLASK_ENV=production
|
- FLASK_ENV=development
|
||||||
- SECRET_KEY=your-secret-key-here
|
- APP_ENV=dev-server
|
||||||
|
- SECRET_KEY=${TEST_SECRET_KEY:-test-secret-key}
|
||||||
volumes:
|
volumes:
|
||||||
- ./logs:/app/logs
|
- ./logs:/app/logs
|
||||||
- ./uploads:/app/uploads
|
|
||||||
restart: unless-stopped
|
restart: unless-stopped
|
||||||
healthcheck:
|
healthcheck:
|
||||||
test: ["CMD", "curl", "-f", "http://localhost:5000/health"]
|
test: ["CMD", "curl", "-f", "http://localhost:5000/health"]
|
||||||
@ -19,42 +44,25 @@ services:
|
|||||||
timeout: 10s
|
timeout: 10s
|
||||||
retries: 3
|
retries: 3
|
||||||
start_period: 40s
|
start_period: 40s
|
||||||
networks:
|
|
||||||
- video-api-network
|
|
||||||
|
|
||||||
# 可选:添加Redis用于任务状态持久化
|
|
||||||
# redis:
|
|
||||||
# image: redis:7-alpine
|
|
||||||
# container_name: hs-video-redis
|
|
||||||
# ports:
|
|
||||||
# - "6379:6379"
|
|
||||||
# volumes:
|
|
||||||
# - redis_data:/data
|
|
||||||
# restart: unless-stopped
|
|
||||||
# networks:
|
|
||||||
# - video-api-network
|
|
||||||
|
|
||||||
# 可选:添加Nginx反向代理
|
|
||||||
# nginx:
|
|
||||||
# image: nginx:alpine
|
|
||||||
# container_name: hs-video-nginx
|
|
||||||
# ports:
|
|
||||||
# - "80:80"
|
|
||||||
# - "443:443"
|
|
||||||
# volumes:
|
|
||||||
# - ./nginx.conf:/etc/nginx/nginx.conf:ro
|
|
||||||
# - ./ssl:/etc/nginx/ssl:ro
|
|
||||||
# depends_on:
|
|
||||||
# - video-api
|
|
||||||
# restart: unless-stopped
|
|
||||||
# networks:
|
|
||||||
# - video-api-network
|
|
||||||
|
|
||||||
networks:
|
|
||||||
video-api-network:
|
|
||||||
driver: bridge
|
|
||||||
|
|
||||||
|
# 生产环境
|
||||||
|
hs-video-api-pro:
|
||||||
|
build: .
|
||||||
|
container_name: hs-video-api-pro
|
||||||
|
ports:
|
||||||
|
- "3300:5000"
|
||||||
|
env_file:
|
||||||
|
- .env.pro
|
||||||
|
environment:
|
||||||
|
- FLASK_ENV=production
|
||||||
|
- APP_ENV=pro
|
||||||
|
- SECRET_KEY=${PROD_SECRET_KEY}
|
||||||
volumes:
|
volumes:
|
||||||
# redis_data:
|
- ./logs:/app/logs
|
||||||
logs:
|
restart: unless-stopped
|
||||||
uploads:
|
healthcheck:
|
||||||
|
test: ["CMD", "curl", "-f", "http://localhost:5000/health"]
|
||||||
|
interval: 30s
|
||||||
|
timeout: 10s
|
||||||
|
retries: 3
|
||||||
|
start_period: 40s
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user