# Build application
FROM node:alpine as build-stage
WORKDIR /app
# Install package as a separate layer for improved docker caching
COPY package*.json ./
RUN npm install
# Build the application
COPY . .
RUN npm run build
# Runnable image
FROM tinou98/vue-12factor
COPY --from=build-stage /app/dist /srv/http
CMD ["js/*.js", "index.html"] # List file that contain run-time variable
1条答案
按热度按时间uklbhaso1#
不幸的是,这不像React那样支持开箱即用,而且由于它不是内置的,你必须寻找第三方解决方案。
其中一个解决方案是:https://github.com/tinou98/vue-12factor
示例:对env变量进行标题更改
index.html
Dockerfile
然后构建并运行映像:
现在,服务器运行在端口8080上,为带有注入环境的页面提供服务。