add runner
This commit is contained in:
47
.gitea/workflows/actions.yml
Normal file
47
.gitea/workflows/actions.yml
Normal file
@@ -0,0 +1,47 @@
|
||||
name: Xiaoshiliu
|
||||
run-name: xiaoshiliu service
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- 'main'
|
||||
|
||||
jobs:
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
env:
|
||||
BUILD_NAME: "xsl"
|
||||
SERVICE_NAME: "xsl"
|
||||
IMAGE_TAG: "release"
|
||||
EXTERNAL_FLAG: ""
|
||||
steps:
|
||||
- name: Checkout Code
|
||||
uses: https://gitea.com/actions/checkout@v4
|
||||
- name: Stop container
|
||||
run: |
|
||||
if [[ "$(sudo docker ps -q --filter name=$SERVICE_NAME)" != "" ]];then
|
||||
docker stop $SERVICE_NAME
|
||||
fi;
|
||||
- name: Delete container
|
||||
run: |
|
||||
if [[ "$(sudo docker ps -qa --filter name=$SERVICE_NAME)" != "" ]];then
|
||||
docker rm $SERVICE_NAME
|
||||
fi;
|
||||
- name: Delete backup image
|
||||
run: |
|
||||
if [[ "$(docker images -q $BUILD_NAME:bak)" != "" ]];then
|
||||
docker rmi $BUILD_NAME:bak
|
||||
fi
|
||||
- name: Rename image
|
||||
run: |
|
||||
if [[ "$(docker images -q $BUILD_NAME:$IMAGE_TAG)" != "" ]];then
|
||||
docker tag $BUILD_NAME:$IMAGE_TAG $BUILD_NAME:bak
|
||||
fi
|
||||
|
||||
- name: Build front image
|
||||
run: cd vue3-project && cp .env.example .env &&docker build -t $BUILD_NAME:$IMAGE_TAG-fr .
|
||||
- name: Build backend image
|
||||
run: cd express-project && cp .env.example .env &&docker build -t $BUILD_NAME:$IMAGE_TAG-bk .
|
||||
- name: Run container
|
||||
run: docker run -d $EXTERNAL_FLAG --name $SERVICE_NAME $BUILD_NAME:$IMAGE_TAG
|
||||
- name: Run container
|
||||
run: docker run -d $EXTERNAL_FLAG --name $SERVICE_NAME $BUILD_NAME:$IMAGE_TAG
|
1
.gitignore
vendored
1
.gitignore
vendored
@@ -3,7 +3,6 @@
|
||||
# Dependencies
|
||||
node_modules/
|
||||
/.pnpm-store
|
||||
|
||||
# Build outputs
|
||||
/dist
|
||||
/dist-ssr
|
||||
|
@@ -1,9 +1,7 @@
|
||||
name: xiaoshiliu
|
||||
|
||||
services:
|
||||
# MySQL数据库服务
|
||||
mysql:
|
||||
# 使用官方MySQL镜像
|
||||
image: mysql:8.0
|
||||
container_name: xiaoshiliu-mysql
|
||||
restart: unless-stopped
|
||||
@@ -16,22 +14,22 @@ services:
|
||||
ports:
|
||||
- "3307:3306"
|
||||
volumes:
|
||||
- mysql_data:/var/lib/mysql
|
||||
- /mnt/persist/xsl_mysql:/var/lib/mysql
|
||||
- ./express-project/scripts/init-database.sql:/docker-entrypoint-initdb.d/init.sql
|
||||
- /etc/localtime:/etc/localtime:ro
|
||||
networks:
|
||||
- xiaoshiliu-network
|
||||
command: --default-authentication-plugin=mysql_native_password --character-set-server=utf8mb4 --collation-server=utf8mb4_unicode_ci
|
||||
command:
|
||||
- --default-authentication-plugin=mysql_native_password
|
||||
- --character-set-server=utf8mb4
|
||||
- --collation-server=utf8mb4_unicode_ci
|
||||
healthcheck:
|
||||
test: ["CMD", "mysqladmin", "ping", "-h", "localhost"]
|
||||
timeout: 20s
|
||||
retries: 10
|
||||
|
||||
# 后端API服务
|
||||
backend:
|
||||
build:
|
||||
context: ./express-project
|
||||
dockerfile: Dockerfile
|
||||
image: xsl:release-bk
|
||||
container_name: xiaoshiliu-backend
|
||||
restart: unless-stopped
|
||||
environment:
|
||||
@@ -46,8 +44,8 @@ services:
|
||||
JWT_EXPIRES_IN: ${JWT_EXPIRES_IN:-7d}
|
||||
REFRESH_TOKEN_EXPIRES_IN: ${REFRESH_TOKEN_EXPIRES_IN:-30d}
|
||||
API_BASE_URL: http://localhost:3001
|
||||
UPLOAD_MAX_SIZE: ${UPLOAD_MAX_SIZE:-50mb}
|
||||
UPLOAD_STRATEGY: ${UPLOAD_STRATEGY:-imagehost}
|
||||
UPLOAD_MAX_SIZE: ${UPLOAD_MAX_SIZE:-300mb}
|
||||
UPLOAD_STRATEGY: ${UPLOAD_STRATEGY:-localhost}
|
||||
LOCAL_UPLOAD_DIR: ${LOCAL_UPLOAD_DIR:-uploads}
|
||||
LOCAL_BASE_URL: ${LOCAL_BASE_URL:-http://localhost:3001}
|
||||
IMAGEHOST_API_URL: ${IMAGEHOST_API_URL:-https://api.xinyew.cn/api/jdtc}
|
||||
@@ -56,7 +54,7 @@ services:
|
||||
ports:
|
||||
- "3001:3001"
|
||||
volumes:
|
||||
- backend_uploads:/app/uploads
|
||||
- /mnt/file/xiaoshiliu/backend_uploads:/app/uploads
|
||||
- /etc/localtime:/etc/localtime:ro
|
||||
networks:
|
||||
- xiaoshiliu-network
|
||||
@@ -70,17 +68,13 @@ services:
|
||||
retries: 3
|
||||
start_period: 40s
|
||||
|
||||
# 前端Web服务
|
||||
frontend:
|
||||
build:
|
||||
context: ./vue3-project
|
||||
dockerfile: Dockerfile
|
||||
args:
|
||||
VITE_API_BASE_URL: http://localhost:3001/api
|
||||
image: xsl:release-fr
|
||||
container_name: xiaoshiliu-frontend
|
||||
restart: unless-stopped
|
||||
environment:
|
||||
TZ: Asia/Shanghai
|
||||
VITE_API_BASE_URL: "http://localhost:3001/api"
|
||||
ports:
|
||||
- "8080:80"
|
||||
volumes:
|
||||
@@ -91,17 +85,11 @@ services:
|
||||
backend:
|
||||
condition: service_healthy
|
||||
healthcheck:
|
||||
test: ["CMD", "wget", "-q", "--spider", "http://localhost/" ]
|
||||
test: ["CMD", "wget", "-q", "--spider", "http://localhost/"]
|
||||
interval: 30s
|
||||
timeout: 10s
|
||||
retries: 3
|
||||
|
||||
volumes:
|
||||
mysql_data:
|
||||
driver: local
|
||||
backend_uploads:
|
||||
driver: local
|
||||
|
||||
networks:
|
||||
xiaoshiliu-network:
|
||||
driver: bridge
|
95
docker-compose.yml.bak
Normal file
95
docker-compose.yml.bak
Normal file
@@ -0,0 +1,95 @@
|
||||
name: xiaoshiliu
|
||||
|
||||
services:
|
||||
mysql:
|
||||
image: mysql:8.0
|
||||
container_name: xiaoshiliu-mysql
|
||||
restart: unless-stopped
|
||||
environment:
|
||||
MYSQL_ROOT_PASSWORD: ${DB_PASSWORD:-123456}
|
||||
MYSQL_DATABASE: ${DB_NAME:-xiaoshiliu}
|
||||
MYSQL_USER: ${DB_USER:-xiaoshiliu_user}
|
||||
MYSQL_PASSWORD: ${DB_PASSWORD:-123456}
|
||||
TZ: Asia/Shanghai
|
||||
ports:
|
||||
- "3307:3306"
|
||||
volumes:
|
||||
- /mnt/persist/xsl_mysql:/var/lib/mysql
|
||||
- /mnt/persist/xiaoshiliu/express-project/scripts/init-database.sql:/docker-entrypoint-initdb.d/init.sql
|
||||
- /etc/localtime:/etc/localtime:ro
|
||||
networks:
|
||||
- xiaoshiliu-network
|
||||
command:
|
||||
- --default-authentication-plugin=mysql_native_password
|
||||
- --character-set-server=utf8mb4
|
||||
- --collation-server=utf8mb4_unicode_ci
|
||||
healthcheck:
|
||||
test: ["CMD", "mysqladmin", "ping", "-h", "localhost"]
|
||||
timeout: 20s
|
||||
retries: 10
|
||||
|
||||
backend:
|
||||
build: ./express-project
|
||||
container_name: xiaoshiliu-backend
|
||||
restart: unless-stopped
|
||||
environment:
|
||||
NODE_ENV: production
|
||||
PORT: 3001
|
||||
DB_HOST: mysql
|
||||
DB_USER: ${DB_USER:-xiaoshiliu_user}
|
||||
DB_PASSWORD: ${DB_PASSWORD:-123456}
|
||||
DB_NAME: ${DB_NAME:-xiaoshiliu}
|
||||
DB_PORT: 3306
|
||||
JWT_SECRET: ${JWT_SECRET:-xiaoshiliu_secret_key_2025}
|
||||
JWT_EXPIRES_IN: ${JWT_EXPIRES_IN:-7d}
|
||||
REFRESH_TOKEN_EXPIRES_IN: ${REFRESH_TOKEN_EXPIRES_IN:-30d}
|
||||
API_BASE_URL: http://localhost:3001
|
||||
UPLOAD_MAX_SIZE: ${UPLOAD_MAX_SIZE:-300mb}
|
||||
UPLOAD_STRATEGY: ${UPLOAD_STRATEGY:-localhost}
|
||||
LOCAL_UPLOAD_DIR: ${LOCAL_UPLOAD_DIR:-uploads}
|
||||
LOCAL_BASE_URL: ${LOCAL_BASE_URL:-http://localhost:3001}
|
||||
IMAGEHOST_API_URL: ${IMAGEHOST_API_URL:-https://api.xinyew.cn/api/jdtc}
|
||||
IMAGEHOST_TIMEOUT: ${IMAGEHOST_TIMEOUT:-60000}
|
||||
TZ: Asia/Shanghai
|
||||
ports:
|
||||
- "3001:3001"
|
||||
volumes:
|
||||
- /mnt/file/xiaoshiliu/backend_uploads:/app/uploads
|
||||
- /etc/localtime:/etc/localtime:ro
|
||||
networks:
|
||||
- xiaoshiliu-network
|
||||
depends_on:
|
||||
mysql:
|
||||
condition: service_healthy
|
||||
healthcheck:
|
||||
test: ["CMD", "node", "-e", "require('http').get('http://localhost:3001/api/health', (res) => { process.exit(res.statusCode === 200 ? 0 : 1) }).on('error', () => process.exit(1))"]
|
||||
interval: 30s
|
||||
timeout: 10s
|
||||
retries: 3
|
||||
start_period: 40s
|
||||
|
||||
frontend:
|
||||
build: ./vue3-project
|
||||
container_name: xiaoshiliu-frontend
|
||||
restart: unless-stopped
|
||||
environment:
|
||||
TZ: Asia/Shanghai
|
||||
VITE_API_BASE_URL: "http://localhost:3001/api"
|
||||
ports:
|
||||
- "8080:80"
|
||||
volumes:
|
||||
- /etc/localtime:/etc/localtime:ro
|
||||
networks:
|
||||
- xiaoshiliu-network
|
||||
depends_on:
|
||||
backend:
|
||||
condition: service_healthy
|
||||
healthcheck:
|
||||
test: ["CMD", "wget", "-q", "--spider", "http://localhost/"]
|
||||
interval: 30s
|
||||
timeout: 10s
|
||||
retries: 3
|
||||
|
||||
networks:
|
||||
xiaoshiliu-network:
|
||||
driver: bridge
|
Reference in New Issue
Block a user