Add dockerfile

This commit is contained in:
Shu Guang 2025-04-01 20:51:48 +08:00
parent 7c22df84cf
commit 420f8317af
5 changed files with 52 additions and 9 deletions

14
Dockerfile Normal file
View File

@ -0,0 +1,14 @@
# 构建阶段
FROM node:16-alpine as build-stage
WORKDIR /app
COPY package*.json ./
RUN npm install --registry=https://registry.npmmirror.com
COPY . .
RUN npm run build
# 生产阶段
FROM nginx:alpine as production-stage
COPY --from=build-stage /app/dist /usr/share/nginx/html
COPY nginx.conf /etc/nginx/conf.d/default.conf
EXPOSE 80
CMD ["nginx", "-g", "daemon off;"]

15
docker-compose.yml Normal file
View File

@ -0,0 +1,15 @@
# 删除 version 字段
services:
web:
build:
context: .
dockerfile: Dockerfile
image: shuguangnet/ollama-book-web:1.0.0
container_name: competition-management-frontend
ports:
- "8080:80"
volumes:
- ./:/app
- /app/node_modules
environment:
- NODE_ENV=production

15
nginx.conf Normal file
View File

@ -0,0 +1,15 @@
server {
listen 80;
server_name localhost;
location / {
root /usr/share/nginx/html;
index index.html;
try_files $uri $uri/ /index.html;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
}

15
package-lock.json generated
View File

@ -12,7 +12,7 @@
"core-js": "^3.8.3",
"default-passive-events": "^2.0.0",
"echarts": "^5.4.1",
"element-ui": "^2.4.5",
"element-ui": "^2.15.14",
"html2canvas": "^1.4.1",
"jspdf": "^2.5.1",
"lodash": "^4.17.21",
@ -5403,10 +5403,9 @@
"license": "ISC"
},
"node_modules/element-ui": {
"version": "2.15.12",
"resolved": "https://registry.npmmirror.com/element-ui/-/element-ui-2.15.12.tgz",
"integrity": "sha512-Y5FMT2BPOindU2GkDEQ5ZKUVxDawKONRNMh2eL3uBx1FOtvUJ+L6IxXLVsNxq4WnaX/UnVNgWXebl7DobygZMg==",
"license": "MIT",
"version": "2.15.14",
"resolved": "https://registry.npmmirror.com/element-ui/-/element-ui-2.15.14.tgz",
"integrity": "sha512-2v9fHL0ZGINotOlRIAJD5YuVB8V7WKxrE9Qy7dXhRipa035+kF7WuU/z+tEmLVPBcJ0zt8mOu1DKpWcVzBK8IA==",
"dependencies": {
"async-validator": "~1.8.1",
"babel-helper-vue-jsx-merge-props": "^2.0.0",
@ -15644,9 +15643,9 @@
"integrity": "sha512-M8WEXFuKXMYMVr45fo8mq0wUrrJHheiKZf6BArTKk9ZBYCKJEOU5H8cdWgDT+qCVZf7Na4lVUaZsA+h6uA9+PA=="
},
"element-ui": {
"version": "2.15.12",
"resolved": "https://registry.npmmirror.com/element-ui/-/element-ui-2.15.12.tgz",
"integrity": "sha512-Y5FMT2BPOindU2GkDEQ5ZKUVxDawKONRNMh2eL3uBx1FOtvUJ+L6IxXLVsNxq4WnaX/UnVNgWXebl7DobygZMg==",
"version": "2.15.14",
"resolved": "https://registry.npmmirror.com/element-ui/-/element-ui-2.15.14.tgz",
"integrity": "sha512-2v9fHL0ZGINotOlRIAJD5YuVB8V7WKxrE9Qy7dXhRipa035+kF7WuU/z+tEmLVPBcJ0zt8mOu1DKpWcVzBK8IA==",
"requires": {
"async-validator": "~1.8.1",
"babel-helper-vue-jsx-merge-props": "^2.0.0",

View File

@ -13,7 +13,7 @@
"core-js": "^3.8.3",
"default-passive-events": "^2.0.0",
"echarts": "^5.4.1",
"element-ui": "^2.4.5",
"element-ui": "^2.15.14",
"html2canvas": "^1.4.1",
"jspdf": "^2.5.1",
"lodash": "^4.17.21",