feat(ci): Frontend supports Docker build. (#580)
This commit is contained in:
parent
c9c900adb0
commit
8848ad3ff4
|
|
@ -349,12 +349,12 @@ services:
|
|||
restart: always
|
||||
container_name: coze-server
|
||||
env_file: *env_file
|
||||
environment:
|
||||
LISTEN_ADDR: 0.0.0.0:8888
|
||||
# environment:
|
||||
# LISTEN_ADDR: 0.0.0.0:8888
|
||||
networks:
|
||||
- coze-network
|
||||
ports:
|
||||
- '8888:8888'
|
||||
# - '8888:8888'
|
||||
- '8889:8889'
|
||||
volumes:
|
||||
- .env:/app/.env
|
||||
|
|
@ -371,6 +371,25 @@ services:
|
|||
condition: service_healthy
|
||||
milvus:
|
||||
condition: service_healthy
|
||||
command: ['/app/opencoze']
|
||||
|
||||
coze-frontend:
|
||||
build:
|
||||
context: ..
|
||||
dockerfile: frontend/Dockerfile
|
||||
container_name: coze-frontend
|
||||
restart: always
|
||||
ports:
|
||||
- "8888:80"
|
||||
# - "443:443" # SSL port (uncomment if using SSL)
|
||||
volumes:
|
||||
- ./nginx/nginx.conf:/etc/nginx/nginx.conf:ro # Main nginx config
|
||||
- ./nginx/conf.d/default.conf:/etc/nginx/conf.d/default.conf:ro # Proxy config
|
||||
# - ./nginx/ssl:/etc/nginx/ssl:ro # SSL certificates (uncomment if using SSL)
|
||||
depends_on:
|
||||
- coze-server
|
||||
networks:
|
||||
- coze-network
|
||||
|
||||
networks:
|
||||
coze-network:
|
||||
|
|
|
|||
|
|
@ -0,0 +1,65 @@
|
|||
server {
|
||||
listen 80;
|
||||
server_name _;
|
||||
|
||||
# Static resources
|
||||
location / {
|
||||
root /usr/share/nginx/html;
|
||||
try_files $uri $uri/ /index.html;
|
||||
index index.html index.htm;
|
||||
autoindex on;
|
||||
autoindex_exact_size off;
|
||||
autoindex_localtime on;
|
||||
}
|
||||
|
||||
# API proxy
|
||||
location /api/ {
|
||||
proxy_pass http://coze-server:8888;
|
||||
|
||||
proxy_set_header Host $host;
|
||||
proxy_set_header X-Real-IP $remote_addr;
|
||||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||
proxy_set_header X-Forwarded-Proto $scheme;
|
||||
|
||||
# SSL/TLS settings
|
||||
proxy_ssl_protocols TLSv1.1 TLSv1.2 TLSv1.3;
|
||||
proxy_ssl_verify off;
|
||||
}
|
||||
}
|
||||
|
||||
# if you want to use https, you can uncomment the following code
|
||||
# server {
|
||||
# listen 443 ssl;
|
||||
# server_name _;
|
||||
|
||||
# ssl_certificate /etc/nginx/ssl/pem;
|
||||
# ssl_certificate_key /etc/nginx/ssl/key;
|
||||
# ssl_protocols TLSv1.1 TLSv1.2 TLSv1.3;
|
||||
# ssl_prefer_server_ciphers on;
|
||||
# ssl_session_cache shared:SSL:10m;
|
||||
# ssl_session_timeout 10m;
|
||||
|
||||
# # Static resources
|
||||
# location / {
|
||||
# root /usr/share/nginx/html;
|
||||
# try_files $uri $uri/ /index.html;
|
||||
# index index.html index.htm;
|
||||
# autoindex on;
|
||||
# autoindex_exact_size off;
|
||||
# autoindex_localtime on;
|
||||
# }
|
||||
|
||||
# # API proxy
|
||||
# location /api/ {
|
||||
# proxy_pass https://coze-server:8888;
|
||||
|
||||
# proxy_set_header Host $host;
|
||||
# proxy_set_header X-Real-IP $remote_addr;
|
||||
# proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||
# proxy_set_header X-Forwarded-Proto $scheme;
|
||||
|
||||
# # SSL/TLS settings
|
||||
# proxy_ssl_protocols TLSv1.1 TLSv1.2 TLSv1.3;
|
||||
# proxy_ssl_verify off;
|
||||
# }
|
||||
# }
|
||||
|
|
@ -0,0 +1,14 @@
|
|||
worker_processes 1;
|
||||
events { worker_connections 1024; }
|
||||
|
||||
http {
|
||||
include mime.types;
|
||||
default_type application/octet-stream;
|
||||
sendfile on;
|
||||
keepalive_timeout 65;
|
||||
|
||||
# setting client request body size limit - 0 means no limit
|
||||
client_max_body_size 0;
|
||||
|
||||
include /etc/nginx/conf.d/*.conf;
|
||||
}
|
||||
|
|
@ -0,0 +1,24 @@
|
|||
.env
|
||||
.env.*
|
||||
|
||||
# Logs
|
||||
logs
|
||||
*.log*
|
||||
|
||||
# node
|
||||
node_modules
|
||||
.husky
|
||||
.next
|
||||
|
||||
# vscode
|
||||
.vscode
|
||||
|
||||
# webstorm
|
||||
.idea
|
||||
*.iml
|
||||
*.iws
|
||||
*.ipr
|
||||
|
||||
|
||||
# Jetbrains
|
||||
.idea
|
||||
|
|
@ -0,0 +1,54 @@
|
|||
# Build stage
|
||||
FROM node:22-alpine AS builder
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
# if you located in China, you can use aliyun mirror to speed up
|
||||
RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.aliyun.com/g' /etc/apk/repositories
|
||||
|
||||
# Install bash git dos2unix for TypeScript compiler
|
||||
RUN apk add --no-cache bash git dos2unix
|
||||
|
||||
# if you located in China, you can use aliyun mirror to speed up
|
||||
RUN npm config set registry https://registry.npmmirror.com
|
||||
|
||||
# Copy rush.json from root directory first
|
||||
COPY rush.json ./
|
||||
|
||||
# Install rush with retry logic
|
||||
RUN npm install -g @microsoft/rush
|
||||
|
||||
# Copy the frontend source code (excluding node_modules and build artifacts)
|
||||
COPY frontend/ ./frontend/
|
||||
|
||||
# Copy common directory for Rush
|
||||
COPY common/ ./common/
|
||||
|
||||
# Copy scripts directory for Rush hooks
|
||||
COPY scripts/ ./scripts/
|
||||
|
||||
# Convert line endings for shell scripts in scripts directory to Unix format
|
||||
RUN find . -name "*.sh" -type f -exec dos2unix {} \;
|
||||
|
||||
# Install all dependencies
|
||||
RUN rush install
|
||||
|
||||
# Use rush build to build the specific project
|
||||
RUN rush build --to @coze-studio/app
|
||||
|
||||
# Production image stage
|
||||
FROM nginx:1.25-alpine
|
||||
|
||||
|
||||
# if you located in China, you can use aliyun mirror to speed up
|
||||
RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.aliyun.com/g' /etc/apk/repositories
|
||||
# Install necessary tools for SSL configuration
|
||||
RUN apk add --no-cache bash
|
||||
|
||||
# Copy build artifacts to nginx static directory
|
||||
COPY --from=builder /app/frontend/apps/coze-studio/dist /usr/share/nginx/html
|
||||
|
||||
EXPOSE 8888
|
||||
|
||||
# Start nginx
|
||||
CMD ["nginx", "-g", "daemon off;"]
|
||||
Loading…
Reference in New Issue