refactor: 统一构建产物输出目录
This commit is contained in:
@@ -0,0 +1,44 @@
|
||||
# CapacityReport Dockerfile
|
||||
# The frontend is built in a Node stage and served by the FastAPI runtime.
|
||||
|
||||
FROM node:22-slim AS frontend-build
|
||||
|
||||
WORKDIR /frontend
|
||||
|
||||
COPY frontend/package*.json ./
|
||||
RUN npm ci
|
||||
|
||||
COPY frontend/ ./
|
||||
RUN npm run build
|
||||
|
||||
|
||||
FROM python:3.13.11-slim
|
||||
|
||||
LABEL maintainer="CapacityReport"
|
||||
LABEL description="CapacityReport processing service"
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
RUN apt-get update && apt-get install -y --no-install-recommends \
|
||||
gcc \
|
||||
libmariadb-dev \
|
||||
curl \
|
||||
&& rm -rf /var/lib/apt/lists/*
|
||||
|
||||
COPY requirements.txt ./
|
||||
RUN pip install --no-cache-dir -r requirements.txt
|
||||
|
||||
RUN mkdir -p /var/log/supervisor /var/run /app/cache
|
||||
|
||||
COPY app ./app
|
||||
COPY Configure.json ReportScript.sql start.sh supervisord.conf ./
|
||||
COPY --from=frontend-build /frontend/dist /app/frontend/dist
|
||||
|
||||
RUN chmod +x /app/start.sh 2>/dev/null || true
|
||||
|
||||
EXPOSE 9081
|
||||
|
||||
HEALTHCHECK --interval=30s --timeout=10s --start-period=10s --retries=3 \
|
||||
CMD curl -f http://localhost:9081/health || exit 1
|
||||
|
||||
CMD ["supervisord", "-c", "/app/supervisord.conf"]
|
||||
@@ -0,0 +1,99 @@
|
||||
# -*- mode: python ; coding: utf-8 -*-
|
||||
|
||||
import os
|
||||
from pathlib import Path
|
||||
|
||||
|
||||
project_root = Path.cwd()
|
||||
onefile = os.environ.get("CAPAREPORT_ONEFILE") == "1"
|
||||
|
||||
hiddenimports = [
|
||||
"uvicorn.logging",
|
||||
"uvicorn.loops.auto",
|
||||
"uvicorn.loops.asyncio",
|
||||
"uvicorn.protocols.http.auto",
|
||||
"uvicorn.protocols.http.h11_impl",
|
||||
"uvicorn.protocols.websockets.auto",
|
||||
"uvicorn.protocols.websockets.websockets_impl",
|
||||
"uvicorn.lifespan.on",
|
||||
"pymysql",
|
||||
"paramiko",
|
||||
"openpyxl",
|
||||
"chardet",
|
||||
]
|
||||
|
||||
excludes = [
|
||||
"pytest",
|
||||
"pandas.tests",
|
||||
"numpy.tests",
|
||||
"openpyxl.tests",
|
||||
"matplotlib",
|
||||
"IPython",
|
||||
"notebook",
|
||||
"tkinter",
|
||||
]
|
||||
|
||||
a = Analysis(
|
||||
[str(project_root / "app" / "main.py")],
|
||||
pathex=[str(project_root)],
|
||||
binaries=[],
|
||||
datas=[],
|
||||
hiddenimports=hiddenimports,
|
||||
hookspath=[],
|
||||
hooksconfig={},
|
||||
runtime_hooks=[],
|
||||
excludes=excludes,
|
||||
noarchive=False,
|
||||
optimize=0,
|
||||
)
|
||||
|
||||
pyz = PYZ(a.pure)
|
||||
|
||||
if onefile:
|
||||
exe = EXE(
|
||||
pyz,
|
||||
a.scripts,
|
||||
a.binaries,
|
||||
a.datas,
|
||||
[],
|
||||
exclude_binaries=False,
|
||||
name="capareport-server",
|
||||
debug=False,
|
||||
bootloader_ignore_signals=False,
|
||||
strip=False,
|
||||
upx=True,
|
||||
console=False,
|
||||
disable_windowed_traceback=False,
|
||||
argv_emulation=False,
|
||||
target_arch=None,
|
||||
codesign_identity=None,
|
||||
entitlements_file=None,
|
||||
)
|
||||
else:
|
||||
exe = EXE(
|
||||
pyz,
|
||||
a.scripts,
|
||||
[],
|
||||
exclude_binaries=True,
|
||||
name="capareport-server",
|
||||
debug=False,
|
||||
bootloader_ignore_signals=False,
|
||||
strip=False,
|
||||
upx=True,
|
||||
console=True,
|
||||
disable_windowed_traceback=False,
|
||||
argv_emulation=False,
|
||||
target_arch=None,
|
||||
codesign_identity=None,
|
||||
entitlements_file=None,
|
||||
)
|
||||
|
||||
coll = COLLECT(
|
||||
exe,
|
||||
a.binaries,
|
||||
a.datas,
|
||||
strip=False,
|
||||
upx=True,
|
||||
upx_exclude=[],
|
||||
name="capareport-server",
|
||||
)
|
||||
@@ -0,0 +1,62 @@
|
||||
services:
|
||||
capacity-app:
|
||||
image: capacity-report-app:latest
|
||||
container_name: capacity-report-app
|
||||
restart: unless-stopped
|
||||
ports:
|
||||
- "19081:9081"
|
||||
volumes:
|
||||
- ./cache:/app/cache
|
||||
- ./Configure.json:/app/Configure.json
|
||||
- ./ReportScript.sql:/app/ReportScript.sql
|
||||
- ./logs:/var/log/supervisor
|
||||
environment:
|
||||
- TZ=Asia/Shanghai
|
||||
- PYTHONUNBUFFERED=1
|
||||
- SUPERVISOR_ENABLED=1
|
||||
depends_on:
|
||||
capacity-mysql:
|
||||
condition: service_healthy
|
||||
networks:
|
||||
- capacity-network
|
||||
|
||||
capacity-mysql:
|
||||
image: mysql:8.0.44
|
||||
container_name: capacity-mysql
|
||||
restart: unless-stopped
|
||||
ports:
|
||||
- "13306:3306"
|
||||
volumes:
|
||||
- capacity-mysql-data:/var/lib/mysql
|
||||
- ./mysql/conf.d:/etc/mysql/conf.d:ro
|
||||
- ./mysql/init:/docker-entrypoint-initdb.d:ro
|
||||
environment:
|
||||
- TZ=Asia/Shanghai
|
||||
- MYSQL_ROOT_PASSWORD=gmcc123
|
||||
- MYSQL_DATABASE=CapacityReport
|
||||
command:
|
||||
- --character-set-server=utf8mb4
|
||||
- --collation-server=utf8mb4_unicode_ci
|
||||
- --local-infile=ON
|
||||
- --secure-file-priv=
|
||||
- --max_allowed_packet=256M
|
||||
- --innodb_buffer_pool_size=512M
|
||||
- --innodb_log_file_size=128M
|
||||
- --innodb_flush_log_at_trx_commit=2
|
||||
- --sync_binlog=0
|
||||
networks:
|
||||
- capacity-network
|
||||
healthcheck:
|
||||
test: ["CMD", "mysqladmin", "ping", "-h", "localhost", "-u", "root", "-pgmcc123"]
|
||||
interval: 10s
|
||||
timeout: 5s
|
||||
retries: 5
|
||||
start_period: 30s
|
||||
|
||||
networks:
|
||||
capacity-network:
|
||||
driver: bridge
|
||||
|
||||
volumes:
|
||||
capacity-mysql-data:
|
||||
driver: local
|
||||
@@ -0,0 +1,29 @@
|
||||
# MySQL settings for CapacityReport
|
||||
|
||||
[mysqld]
|
||||
# Charset
|
||||
character-set-server = utf8mb4
|
||||
collation-server = utf8mb4_unicode_ci
|
||||
|
||||
# LOAD DATA LOCAL INFILE
|
||||
local_infile = ON
|
||||
secure_file_priv = ""
|
||||
|
||||
# Performance
|
||||
max_allowed_packet = 256M
|
||||
innodb_buffer_pool_size = 512M
|
||||
innodb_log_file_size = 128M
|
||||
innodb_flush_log_at_trx_commit = 2
|
||||
sync_binlog = 0
|
||||
|
||||
# Connections
|
||||
max_connections = 200
|
||||
wait_timeout = 28800
|
||||
interactive_timeout = 28800
|
||||
|
||||
[mysql]
|
||||
local_infile = ON
|
||||
default-character-set = utf8mb4
|
||||
|
||||
[client]
|
||||
default-character-set = utf8mb4
|
||||
@@ -0,0 +1,10 @@
|
||||
-- MySQL initialization for CapacityReport.
|
||||
-- This file runs only when the MySQL data directory is empty.
|
||||
|
||||
CREATE DATABASE IF NOT EXISTS CapacityReport
|
||||
CHARACTER SET utf8mb4
|
||||
COLLATE utf8mb4_unicode_ci;
|
||||
|
||||
USE CapacityReport;
|
||||
|
||||
SELECT 'CapacityReport database initialized with utf8mb4 charset' AS status;
|
||||
Reference in New Issue
Block a user