首页
  • Java
  • Linux
  • Deploy
  • Application

Xiao ku

板砖师傅
首页
  • Java
  • Linux
  • Deploy
  • Application
  • Nginx

  • Git

  • Docker

    • 常用docker命令
    • 使用docker构建前端项目
      • docker-compose
        • 说明
      • 操作命令
        • 启动容器构建前端项目
        • 查看日志构建进度
        • 关闭容器
        • 构建dist包目录
    • 导出docker镜像脚本
  • Vue

  • Macos

  • Application
  • Docker
xiaoku
2023-06-01
目录

使用docker构建前端项目

# docker-compose

docker-compose.yml

version: "3"
services:
  puredoc:
    image: node:14.18.1
    container_name: puredoc
    volumes:
      - ./app:/app
    working_dir: /app
    command: >
      bash -c '
        if [ -d /app/.git ]; then
          cd /app &&
          git pull &&
          yarn install &&
          yarn build
        else
          git clone -b dev https://帐号:密码@gitlab.xxxx.cn/pure-doc.git /app &&
          cd /app &&
          yarn install &&
          yarn build
        fi &&
        tail -f /dev/null
      '
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23

# 说明

  1. "git clone -b dev"中 -b dev指的是拉取dev分支 可根据实际情况修改
  2. 容器启动后便一直在运行中,启动后可查看日志,等待日志输出构建完成后可手动关闭容器
  3. 首次启动会git clone代码,第二次启动会git pull代码。检测条件为[ -d /app/.git ]

# 操作命令

# 启动容器构建前端项目

docker-compose up -d
1

# 查看日志构建进度

docker logs -f puredoc
1

若日志输出如下,则说明已经构建完成

ℹ Compiling Client
ℹ Compiling Server
Language does not exist: @data
✔ Server: Compiled successfully in 34.50s
✔ Client: Compiled successfully in 40.62s
wait Rendering static HTML...

 SITEMAP  Generating sitemap...

 SITEMAP  found 61 locations

 SITEMAP  61 locations have been written.
success Generated static files in docs/.vuepress/dist.

Done in 48.61s.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16

# 关闭容器

docker-compose down
1

# 构建dist包目录

可根据日志输出得知构建完成的目录地址为

docs/.vuepress/dist.
1

由已经把docker目录地址映射出来,可在当前目录地址app下查看

上次更新: 2023/06/01, 03:48:34
常用docker命令
导出docker镜像脚本

← 常用docker命令 导出docker镜像脚本→

Copyright © 2019-2024 | 闽ICP备20012188号-1
  • 跟随系统
  • 浅色模式
  • 深色模式
  • 阅读模式