优化Docker本地部署

This commit is contained in:
Certificate System
2026-08-13 15:00:31 +08:00
parent c9667d56fb
commit 9a26fef6f4
7 changed files with 1127 additions and 12 deletions

6
backend/.dockerignore Normal file
View File

@@ -0,0 +1,6 @@
__pycache__/
.pytest_cache/
*.pyc
dev.db
tests/
docs/

View File

@@ -13,18 +13,14 @@ RUN sed -i 's/deb.debian.org/mirrors.aliyun.com/g' /etc/apt/sources.list.d/debia
fonts-noto-cjk \ fonts-noto-cjk \
fonts-unifont \ fonts-unifont \
libfontconfig1 \ libfontconfig1 \
libnss3 \
libxss1 \
libasound2 \
libatk-bridge2.0-0 \
libgtk-3-0 \
&& rm -rf /var/lib/apt/lists/* && rm -rf /var/lib/apt/lists/*
COPY requirements.txt . COPY requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt -i https://mirrors.aliyun.com/pypi/simple/ \ RUN pip install --no-cache-dir -r requirements.txt -i https://mirrors.aliyun.com/pypi/simple/
&& python -m playwright install chromium
COPY app ./app COPY app ./app
COPY alembic ./alembic
COPY alembic.ini ./alembic.ini
EXPOSE 8000 EXPOSE 8000

View File

@@ -6,7 +6,6 @@ pymysql==1.1.1
python-multipart==0.0.20 python-multipart==0.0.20
openpyxl==3.1.5 openpyxl==3.1.5
qrcode[pil]==8.0 qrcode[pil]==8.0
playwright==1.49.1
jinja2==3.1.5 jinja2==3.1.5
pytest==8.3.4 pytest==8.3.4
alibabacloud-dysmsapi20170525==4.5.1 alibabacloud-dysmsapi20170525==4.5.1

View File

@@ -9,7 +9,7 @@ services:
volumes: volumes:
- mysql-data:/var/lib/mysql - mysql-data:/var/lib/mysql
ports: ports:
- "3306:3306" - "${MYSQL_PORT:-3306}:3306"
healthcheck: healthcheck:
test: ["CMD", "mysqladmin", "ping", "-h", "localhost"] test: ["CMD", "mysqladmin", "ping", "-h", "localhost"]
interval: 10s interval: 10s
@@ -27,7 +27,7 @@ services:
mysql: mysql:
condition: service_healthy condition: service_healthy
ports: ports:
- "8000:8000" - "${BACKEND_PORT:-8000}:8000"
frontend: frontend:
build: build:
@@ -35,7 +35,7 @@ services:
depends_on: depends_on:
- backend - backend
ports: ports:
- "8080:80" - "${FRONTEND_PORT:-8080}:80"
volumes: volumes:
mysql-data: mysql-data:

3
frontend/.dockerignore Normal file
View File

@@ -0,0 +1,3 @@
node_modules/
dist/
.DS_Store

View File

@@ -2,7 +2,10 @@ FROM node:22-alpine AS build
WORKDIR /app WORKDIR /app
COPY package.json package-lock.json* ./ COPY package.json package-lock.json* ./
RUN npm install ARG TARGETARCH
RUN npm ci \
&& ROLLUP_VERSION=$(node -p "require('./node_modules/rollup/package.json').version") \
&& npm install --no-save "@rollup/rollup-linux-${TARGETARCH}-musl@${ROLLUP_VERSION}"
COPY . . COPY . .
RUN npm run build RUN npm run build

1108
frontend/package-lock.json generated Normal file

File diff suppressed because it is too large Load Diff