 10bc8fe7cb
			
		
	
	10bc8fe7cb
	
	
		
			
	
		
	
	
		
			All checks were successful
		
		
	
	Build and Push Docker Image / build (push) Successful in 1m42s
				
			- Introduced Dockerfile for multi-stage build process using Node.js and Nginx. - Added .dockerignore to exclude unnecessary files from Docker context. - Created nginx.conf for server configuration, including gzip compression and SPA routing. - Implemented Gitea CI/CD workflow for building and pushing Docker images on version tags.
		
			
				
	
	
		
			37 lines
		
	
	
		
			593 B
		
	
	
	
		
			Docker
		
	
	
	
	
	
			
		
		
	
	
			37 lines
		
	
	
		
			593 B
		
	
	
	
		
			Docker
		
	
	
	
	
	
| # 第一阶段: 构建应用
 | |
| FROM node:22-alpine AS builder
 | |
| 
 | |
| # 安装 pnpm
 | |
| RUN npm install -g pnpm
 | |
| 
 | |
| # 设置工作目录
 | |
| WORKDIR /app
 | |
| 
 | |
| # 复制依赖配置文件
 | |
| COPY package.json pnpm-lock.yaml ./
 | |
| 
 | |
| # 安装依赖
 | |
| RUN pnpm install --frozen-lockfile
 | |
| 
 | |
| # 复制源代码
 | |
| COPY . .
 | |
| 
 | |
| # 构建应用
 | |
| RUN pnpm build
 | |
| 
 | |
| # 第二阶段: 运行应用
 | |
| FROM nginx:alpine
 | |
| 
 | |
| # 复制自定义 nginx 配置
 | |
| COPY nginx.conf /etc/nginx/nginx.conf
 | |
| 
 | |
| # 从构建阶段复制构建产物
 | |
| COPY --from=builder /app/dist /usr/share/nginx/html
 | |
| 
 | |
| # 暴露端口
 | |
| EXPOSE 80
 | |
| 
 | |
| # 启动 nginx
 | |
| CMD ["nginx", "-g", "daemon off;"]
 | |
| 
 |