feat: drone.ci

This commit is contained in:
mozzie 2023-03-20 09:49:00 +08:00
parent dd29122199
commit 100dbe4ca7
3 changed files with 30 additions and 80 deletions

View File

@ -1,15 +1,15 @@
--- ---
kind: pipeline kind: pipeline
type: docker type: docker
name: backset.cn deploy name: backset.cn ci
# 宿主机目录
volumes: volumes:
- name: node_modules - name: node_modules
host: host:
path: /home/drone/cache/node_modules path: /home/drone/cache/node_modules
steps: steps:
# web端
- name: build-web - name: build-web
image: node:16.19-alpine image: node:16.19-alpine
# 容器内挂载点 # 容器内挂载点
@ -37,9 +37,9 @@ steps:
target: /www/wwwroot/nginx/html/backset.cn/ target: /www/wwwroot/nginx/html/backset.cn/
source: ./apps/web/dist/* source: ./apps/web/dist/*
# admin管理
- name: build-admin - name: build-admin
image: node:16.19-alpine image: node:16.19-alpine
# 容器内挂载点
volumes: volumes:
- name: node_modules - name: node_modules
path: /drone/src/node_modules path: /drone/src/node_modules
@ -63,3 +63,30 @@ steps:
command_timeout: 2m command_timeout: 2m
target: /www/wwwroot/nginx/html/backset.cn/ target: /www/wwwroot/nginx/html/backset.cn/
source: ./apps/admin/dist/* source: ./apps/admin/dist/*
# server
- name: build-server
image: appleboy/drone-scp:1.6
volumes:
- name: node_modules
path: /drone/src/node_modules
commands:
- pwd
- node -v
- npm -v
- npm install -g pnpm
- pnpm install
- pnpm build:server
- name: deploy-server
image: appleboy/drone-scp:1.6
settings:
host:
- backset.cn
username: root
password: cr654654.
port: 22
overwrite: true
command_timeout: 2m
target: /www/wwwroot/nginx/html/backset.cn/
source: ./apps/server/dist/*

View File

@ -1,36 +0,0 @@
# 拉取的原镜像
FROM node:16.19-alpine AS build
# 创建一个项目文件夹,可自定义
WORKDIR /app
# 将本地文件复制到项目文件夹下
COPY ./apps/server .
# 切换到淘宝镜像,安装依赖比较快
RUN npm set registry https://registry.npm.taobao.org
# 安装依赖
RUN npm install -g pnpm
RUN pnpm i
# 打包项目
RUN pnpm build
# 切换镜像文件, alpine镜像打包后更小
FROM node:16.19-alpine
# 切换工作目录
WORKDIR /app
# 将打包后的的文件复制到docker镜像里
COPY --from=build /app/dist ./dist
COPY --from=build /app/src ./src
COPY --from=build /app/bootstrap.js ./
COPY --from=build /app/package.json ./
# RUN apk add --no-cache tzdata
ENV TZ="Asia/Shanghai"
RUN npm set registry https://registry.npm.taobao.org
# 安装工程依赖
RUN npm install --production
# 设置暴露端口
EXPOSE 7001
# 启动
CMD ["npm", "run", "start"]

View File

@ -1,41 +0,0 @@
version: "3"
services:
redis:
image: redis
container_name: redis-backset # 容器名称
restart: always
ports:
- "26379:26379"
expose:
- "26379"
command: redis-server --requirepass "cr654654." --port 26379
mysql:
image: mysql:5.7.38
container_name: mysql-backset # 容器名称
restart: always
ports:
- "3307:3307"
expose:
- "3307"
environment:
MYSQL_DATABASE: "backset"
MYSQL_USER: "backset"
MYSQL_PASSWORD: "backset"
MYSQL_ROOT_PASSWORD: "root"
MYSQL_ROOT_HOST: "%"
MYSQL_TCP_PORT: 3307
web:
build: .
restart: always
container_name: backset-server # 容器名称
ports:
- "7001:7001"
links:
- mysql:mysql
- redis:redis
depends_on:
- mysql
- redis