【发布时间】:2020-07-15 07:32:41
【问题描述】:
所以这是我的问题,我必须对我的 vue 应用程序进行 dockerize 才能在 kubernetes/rancher 环境中使用它。
我想在我的牧场主中设置一些环境变量,例如 API 基本 url,但我不知道该怎么做。
这是我的 dockerFile:
FROM nginx:stable-alpine
# define 'app'
WORKDIR /app
COPY dist /usr/share/nginx/html
EXPOSE 80
CMD ["nginx", "-g", "daemon off;"]
.gitlab-ci.yml
image: node:lts-alpine
stages:
- install
- tests
- build
- deploy-docker
- rerun-docker
cache:
paths:
- node_modules/
install:
stage: install
script: npm install
tags: [ docker ]
test:
stage: tests
script: npm run test:unit
tags: [ docker ]
build:
stage: build
script: npm run build
artifacts:
paths:
- dist
tags: [ docker ]
build_image:
stage: deploy-docker
image: //myurl//
script:
- docker build -t //myurl// .
- docker push //myurl//
only:
- develop
- feat/CI-front
tags: [ docker ]
rerun:
stage: rerun-docker
image: //adress///kubectl:latest
script:
- kubectl scale deployment //myproject// --replicas=0 -n //name//
- kubectl scale deployment //myproject// --replicas=1 -n //name//
only:
- develop
- feat/CI-front
tags: [ docker ]
如果有必要,还有我的 .env
VUE_APP_API_BASE_URL = hello
非常感谢
【问题讨论】:
标签: docker vue.js nginx environment-variables rancher