Skip to content

Commit

Permalink
🐳 chore: 自动化部署Docker配置
Browse files Browse the repository at this point in the history
  • Loading branch information
yuanjunjie committed Jul 3, 2024
1 parent 3266dc5 commit 2f602f0
Show file tree
Hide file tree
Showing 9 changed files with 92 additions and 501 deletions.
34 changes: 34 additions & 0 deletions docker-compose.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
version: "3"

networks:
web_net:
external: true

services:
vueui:
container_name: vue-vben-admin
image: swr.cn-north-4.myhuaweicloud.com/yuanjunjie/vue-vben-admin:dev
build:
context: ./vue-vben-admin
dockerfile: ./vue-vben-admin/Dockerfile
restart: always
ports:
- 5173:80
depends_on:
- servers

servers:
container_name: nest-admin
image: swr.cn-north-4.myhuaweicloud.com/yuanjunjie/nest-admin:dev
build:
context: ./nest-admin/servers
dockerfile: ./nest-admin/servers/Dockerfile
command: npm run start:docker
restart: always
ports:
- 8080:8080
volumes:
- upload:/nest-admin/upload

volumes:
upload:
21 changes: 0 additions & 21 deletions nest-admin/LICENSE

This file was deleted.

60 changes: 0 additions & 60 deletions nest-admin/docker-compose.yaml

This file was deleted.

2 changes: 1 addition & 1 deletion nest-admin/servers/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM node:16
FROM node:22.3.0 as builder

CMD [ "mkdir", "/upload" ]

Expand Down
34 changes: 23 additions & 11 deletions vue-vben-admin/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
# node 构建
FROM node:16-alpine as build-stage
# 署名
MAINTAINER Adoin '[email protected]'
# ================== STEP 1: Build ==================
FROM node:22.3.0 as builder

# 将源码复制到 /app 目录中
WORKDIR /app
COPY . ./
COPY . .

# 设置 node 阿里镜像
RUN npm config set registry https://registry.npmmirror.com
# 设置--max-old-space-size
Expand All @@ -14,12 +15,23 @@ RUN npm install pnpm -g && \
pnpm build:docker
# node部分结束
RUN echo "🎉 编 🎉 译 🎉 成 🎉 功 🎉"
# nginx 部署
FROM nginx:1.23.3-alpine as production-stage
COPY --from=build-stage /app/dist /usr/share/nginx/html/dist
COPY --from=build-stage /app/nginx.conf /etc/nginx/nginx.conf

# ================== STEP 2: Publish ==================
FROM nginx:1.19.6

# 复制 nginx.conf 配置文件到镜像中
COPY ["./_nginx/default.conf", "/etc/nginx/nginx.conf"]

# 删除 nginx html 原有内容
RUN rm -rf /usr/share/nginx/html/*

EXPOSE 80

# 从编译镜像复制编译结果到此镜像
COPY --from=builder /app/dist /usr/share/nginx/html

## 将/usr/share/nginx/html/dist/assets/index.js 和/usr/share/nginx/html/dist/_app.config.js中的"$vg_base_url"替换为环境变量中的VG_BASE_URL,$vg_sub_domain 替换成VG_SUB_DOMAIN,$vg_default_user替换成VG_DEFAULT_USER,$vg_default_password替换成VG_DEFAULT_PASSWORD 而后启动nginx
CMD sed -i "s|__vg_base_url|$VG_BASE_URL|g" /usr/share/nginx/html/dist/assets/entry/index-*.js /usr/share/nginx/html/dist/_app.config.js && \
nginx -g 'daemon off;'
# CMD sed -i "s|__vg_base_url|$VG_BASE_URL|g" /usr/share/nginx/html/dist/assets/entry/index-*.js /usr/share/nginx/html/dist/_app.config.js && \
# nginx -g 'daemon off;'

RUN echo "🎉 架 🎉 设 🎉 成 🎉 功 🎉"
179 changes: 0 additions & 179 deletions vue-vben-admin/README.md

This file was deleted.

Loading

0 comments on commit 2f602f0

Please sign in to comment.