chore: add docker deployment files and scripts
This commit is contained in:
24
Dockerfile
Normal file
24
Dockerfile
Normal file
@@ -0,0 +1,24 @@
|
||||
# Stage 1: Build
|
||||
FROM node:20-slim AS build
|
||||
WORKDIR /app
|
||||
COPY package*.json ./
|
||||
RUN npm install
|
||||
COPY . .
|
||||
RUN npm run build
|
||||
|
||||
# Stage 2: Serve with Nginx
|
||||
FROM nginx:alpine
|
||||
# Copy build output to nginx folder
|
||||
COPY --from=build /app/dist /usr/share/nginx/html
|
||||
# Custom nginx config to handle SPA routing if needed
|
||||
RUN echo 'server { \
|
||||
listen 80; \
|
||||
location / { \
|
||||
root /usr/share/nginx/html; \
|
||||
index index.html; \
|
||||
try_files $uri $uri/ /index.html; \
|
||||
} \
|
||||
}' > /etc/nginx/conf.d/default.conf
|
||||
|
||||
EXPOSE 80
|
||||
CMD ["nginx", "-g", "daemon off;"]
|
||||
29
build_and_push.sh
Executable file
29
build_and_push.sh
Executable file
@@ -0,0 +1,29 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Configuration
|
||||
REGISTRY="dcr-by1jwyxk44.71826370.xyz"
|
||||
IMAGE_NAME="safe-os-ui"
|
||||
TAG="latest"
|
||||
FULL_IMAGE_NAME="$REGISTRY/$IMAGE_NAME:$TAG"
|
||||
|
||||
echo "Step 1: Building Docker image..."
|
||||
docker build -t $IMAGE_NAME:$TAG .
|
||||
|
||||
if [ $? -ne 0 ]; then
|
||||
echo "Error: Docker build failed."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "Step 2: Tagging image for registry..."
|
||||
docker tag $IMAGE_NAME:$TAG $FULL_IMAGE_NAME
|
||||
|
||||
echo "Step 3: Pushing image to $REGISTRY..."
|
||||
# Note: You might need to run 'docker login $REGISTRY' beforehand
|
||||
docker push $FULL_IMAGE_NAME
|
||||
|
||||
if [ $? -eq 0 ]; then
|
||||
echo "Success: Image has been pushed to $FULL_IMAGE_NAME"
|
||||
else
|
||||
echo "Error: Docker push failed."
|
||||
exit 1
|
||||
fi
|
||||
45
deploy/docker-compose.yml
Normal file
45
deploy/docker-compose.yml
Normal file
@@ -0,0 +1,45 @@
|
||||
version: '3.8'
|
||||
|
||||
services:
|
||||
# Frontend Service
|
||||
safe-os-ui:
|
||||
image: dcr-by1jwyxk44.71826370.xyz/safe-os-ui:latest
|
||||
container_name: safe-os-ui
|
||||
restart: always
|
||||
networks:
|
||||
- npm_network
|
||||
|
||||
# Backend: Planning Agent
|
||||
planning-agent:
|
||||
image: dcr-by1jwyxk44.71826370.xyz/planning-agent:latest
|
||||
container_name: planning-agent
|
||||
restart: always
|
||||
environment:
|
||||
- PORT=8090
|
||||
networks:
|
||||
- npm_network
|
||||
|
||||
# Backend: DevOps Agent
|
||||
devops-agent:
|
||||
image: dcr-by1jwyxk44.71826370.xyz/devops-agent:latest
|
||||
container_name: devops-agent
|
||||
restart: always
|
||||
environment:
|
||||
- PORT=8000
|
||||
networks:
|
||||
- npm_network
|
||||
|
||||
# Backend: Quality Gate
|
||||
quality-gate:
|
||||
image: dcr-by1jwyxk44.71826370.xyz/quality-gate:latest
|
||||
container_name: quality-gate
|
||||
restart: always
|
||||
environment:
|
||||
- PORT=5000
|
||||
networks:
|
||||
- npm_network
|
||||
|
||||
networks:
|
||||
npm_network:
|
||||
external: true
|
||||
name: proxy-net # 已更新为实际的 Docker 网络名称
|
||||
Reference in New Issue
Block a user