update
This commit is contained in:
@@ -0,0 +1,32 @@
|
||||
services:
|
||||
frontend:
|
||||
build:
|
||||
context: .
|
||||
dockerfile: packages/frontend/Dockerfile
|
||||
container_name: nexus-terminal-frontend
|
||||
ports:
|
||||
- "18111:80"
|
||||
depends_on:
|
||||
- backend
|
||||
networks:
|
||||
- nexus-terminal-network
|
||||
|
||||
backend:
|
||||
build:
|
||||
context: .
|
||||
dockerfile: packages/backend/Dockerfile
|
||||
container_name: nexus-terminal-backend
|
||||
ports:
|
||||
- "18112:3001"
|
||||
environment:
|
||||
NODE_ENV: production
|
||||
PORT: 3001
|
||||
volumes:
|
||||
- ./data:/app/data
|
||||
networks:
|
||||
- nexus-terminal-network
|
||||
|
||||
|
||||
networks:
|
||||
nexus-terminal-network:
|
||||
driver: bridge
|
||||
+18
-28
@@ -1,38 +1,28 @@
|
||||
version: '3.8' # 使用较新的 Compose 文件格式版本
|
||||
|
||||
services:
|
||||
backend:
|
||||
build:
|
||||
context: . # 构建上下文是项目根目录
|
||||
dockerfile: packages/backend/Dockerfile # 指定后端 Dockerfile 路径
|
||||
container_name: nexus_backend # 给容器一个明确的名字
|
||||
frontend:
|
||||
image: heavrnl/nexus-terminal-frontend
|
||||
container_name: nexus-terminal-frontend
|
||||
ports:
|
||||
- "3001:3001" # 将容器的 3001 端口映射到宿主机的 3001 端口
|
||||
- "18111:80"
|
||||
depends_on:
|
||||
- backend)
|
||||
networks:
|
||||
- nexus-terminal-network
|
||||
|
||||
backend:
|
||||
image: heavrnl/nexus-terminal-backend
|
||||
container_name: nexus-terminal-backend
|
||||
ports:
|
||||
- "18112:3001"
|
||||
environment:
|
||||
NODE_ENV: production
|
||||
PORT: 3001
|
||||
|
||||
volumes:
|
||||
- ./data:/app/data # 确保宿主机上的 ./data 目录存在或 Docker 会创建它
|
||||
- ./data:/app/data
|
||||
networks:
|
||||
- nexus_network # 将服务连接到自定义网络
|
||||
- nexus-terminal-network
|
||||
|
||||
frontend:
|
||||
build:
|
||||
context: . # 构建上下文是项目根目录
|
||||
dockerfile: packages/frontend/Dockerfile # 指定前端 Dockerfile 路径
|
||||
container_name: nexus_frontend # 给容器一个明确的名字
|
||||
ports:
|
||||
- "8080:80" # 将容器的 80 端口 (Nginx) 映射到宿主机的 8080 端口
|
||||
depends_on:
|
||||
- backend # 确保后端服务先启动(但不保证完全就绪)
|
||||
networks:
|
||||
- nexus_network # 将服务连接到自定义网络
|
||||
|
||||
networks:
|
||||
nexus_network: # 定义自定义网络
|
||||
driver: bridge # 使用默认的 bridge 驱动
|
||||
|
||||
volumes:
|
||||
# 如果上面定义了卷,这里可以进一步配置(可选)
|
||||
data: {} # 定义一个名为 data 的卷
|
||||
nexus-terminal-network:
|
||||
driver: bridge
|
||||
|
||||
@@ -0,0 +1,2 @@
|
||||
data/
|
||||
sessions/
|
||||
@@ -1,47 +1,37 @@
|
||||
# Stage 1: Build the frontend application using npm workspaces
|
||||
FROM node:20-alpine AS builder
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
# Copy root package.json and package-lock.json
|
||||
|
||||
COPY package.json package-lock.json* ./
|
||||
|
||||
# Copy frontend package definition and backend (needed for workspace install)
|
||||
# We need backend's package.json for npm ci to resolve the workspace correctly
|
||||
COPY packages/frontend/package.json ./packages/frontend/
|
||||
COPY packages/backend/package.json ./packages/backend/
|
||||
# If there are other packages frontend depends on, copy their package.json too
|
||||
|
||||
# Install ALL workspace dependencies using the root lock file
|
||||
RUN npm ci
|
||||
|
||||
# Copy the rest of the frontend source code needed for the build
|
||||
|
||||
COPY packages/frontend/src ./packages/frontend/src
|
||||
COPY packages/frontend/index.html ./packages/frontend/
|
||||
COPY packages/frontend/tsconfig.json ./packages/frontend/
|
||||
COPY packages/frontend/vite.config.ts ./packages/frontend/
|
||||
# Assuming postcss.config.js exists at the root or frontend level if needed
|
||||
# COPY postcss.config.js ./ # Or ./packages/frontend/ if it's there
|
||||
|
||||
# Build only the frontend package
|
||||
|
||||
RUN npm run build --workspace=@nexus-terminal/frontend
|
||||
|
||||
# Stage 2: Serve the static files with Nginx
|
||||
FROM nginx:stable-alpine
|
||||
|
||||
# Remove default Nginx welcome page
|
||||
|
||||
RUN rm -rf /usr/share/nginx/html/*
|
||||
|
||||
# Copy built assets from builder stage to Nginx html directory
|
||||
|
||||
COPY --from=builder /app/packages/frontend/dist /usr/share/nginx/html
|
||||
|
||||
# Copy custom Nginx configuration
|
||||
# This file needs to be present in the build context (project root)
|
||||
# We created it in packages/frontend/, so adjust the COPY source path
|
||||
|
||||
COPY packages/frontend/nginx.conf /etc/nginx/conf.d/default.conf
|
||||
|
||||
# Expose port 80
|
||||
|
||||
EXPOSE 80
|
||||
|
||||
# Start Nginx
|
||||
|
||||
CMD ["nginx", "-g", "daemon off;"]
|
||||
Reference in New Issue
Block a user