node項目使用gitlab自動部署

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

相關文章
相關標籤/搜索