1.建立Dockerfile文件vue
# This file is a template, and might need editing before it works on your project. FROM node:8.9.3 WORKDIR /usr/src/app ARG NODE_ENV ENV NODE_ENV $NODE_ENV COPY package.json /usr/src/app/ RUN npm install --registry=https://registry.npm.taobao.org COPY . /usr/src/app CMD [ "npm", "start" ] # replace this with your application's default port EXPOSE 80
2.建立.gitlab-ci.yml文件node
before_script: #中止正在运行的容器 - "docker rm gpcmarket-ops-vue -f" job_test: script: #build镜像 - "docker build -t liyc/gpcmarket-ops-vue ." #运行对外端口80 - "docker run --name gpcmarket-ops-vue -d -p 80:80 liyc/gpcmarket-ops-vue" only: - test tags: - shared1
这样每次test分支有commit时会自动构建镜像并运行一个新的docker容器,对外端口80。git