Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

新增一键构建PowerJob-Console镜像脚本 #52

Open
haroldyong opened this issue Sep 18, 2023 · 0 comments
Open

新增一键构建PowerJob-Console镜像脚本 #52

haroldyong opened this issue Sep 18, 2023 · 0 comments

Comments

@haroldyong
Copy link

1、在源代码根目录新增Dockerfile文件

#第一个阶段:拉取node镜像来打包 Vue 项目,as build是给该阶段起名字
FROM node:10.24.1-buster as build

#RUN apt-get update && apt-get install -y --no-install-recommends python3 python3-pip && rm -rf /var/lib/apt/lists/*

#设置docker命令的运行目录,工作空间
WORKDIR /app


# 复制src等目录文件到工作空间中 必入 COPY src src/ 表示复制当前src文件夹中的内容到 工作空间(无则创建文件夹)
COPY public /app/public
COPY src /app/src
COPY package.json /app/package.json
COPY babel.config.js /app/babel.config.js
COPY vue.config.js /app/vue.config.js
COPY LICENSE /app/LICENSE

RUN npm set registry https://registry.npm.taobao.org
RUN npm install
RUN npm run build

# 第二个阶段:创建并运行Nginx服务器,并且把打包好的文件复制到服务器文件夹中

FROM nginx:1.25.2-bookworm
LABEL org.opencontainers.image.authors="[email protected]"

COPY --from=build /app/dist/ /usr/share/nginx/html/
EXPOSE 80
CMD ["/bin/bash", "-c", "sed -i \"s@<html@<html vue-app-base-url=\"$VUE_APP_BASE_URL\"@\" /usr/share/nginx/html/index.html; nginx -g \"daemon off;\""]


2、修改PowerJob-Console项目的main.js

//let baseURL = process.env.VUE_APP_BASE_URL;

let baseURL = document.querySelector("html").getAttribute("vue-app-base-url");
if (baseURL) {
  Vue.prototype.$baseURL = `${baseURL}`;
}
else
{
  baseURL = process.env.VUE_APP_BASE_URL;
}

3、运行方式

docker run -p 20086:80 -e VUE_APP_BASE_URL="http://localhost:1080/api" -d -t tjqq/oms-console:1.0.1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant