添加cicd
This commit is contained in:
parent
a28374c854
commit
75c15b92e9
105
.gitlab-ci.yml
Normal file
105
.gitlab-ci.yml
Normal file
@ -0,0 +1,105 @@
|
||||
variables:
|
||||
DOCKER_REGION: "registry.cn-qingdao.aliyuncs.com"
|
||||
DOCKER_NAMESPACE: "lacus"
|
||||
DOCKER_USERNAME: "rainsun20170129"
|
||||
DOCKER_PASSWORD: "100200300Wdy*"
|
||||
APP_NAME: "canary_fe"
|
||||
IMAGE_NAME: "$DOCKER_REGION/$DOCKER_NAMESPACE/$APP_NAME:$CI_COMMIT_REF_NAME-$CI_COMMIT_SHORT_SHA"
|
||||
DOCKER_FILE_PATH: "./Dockerfile"
|
||||
|
||||
stages:
|
||||
- build
|
||||
- test
|
||||
- clear
|
||||
- deploy
|
||||
- clear_test
|
||||
|
||||
build:
|
||||
stage: build
|
||||
image: docker:latest
|
||||
services:
|
||||
- name: docker:dind
|
||||
tags:
|
||||
- dockerbase
|
||||
script:
|
||||
- ls -a
|
||||
- docker login --username=${DOCKER_USERNAME} --password=${DOCKER_PASSWORD} ${DOCKER_REGION}
|
||||
- docker build -t ${IMAGE_NAME} -f ${DOCKER_FILE_PATH} .
|
||||
- docker push ${IMAGE_NAME}
|
||||
- docker rmi ${IMAGE_NAME}
|
||||
|
||||
test:
|
||||
stage: test
|
||||
tags:
|
||||
- dockerbase
|
||||
script:
|
||||
- ls -a
|
||||
- docker login --username=${DOCKER_USERNAME} --password=${DOCKER_PASSWORD} ${DOCKER_REGION}
|
||||
- docker pull ${IMAGE_NAME}
|
||||
- docker run -d --name ${APP_NAME} -p 8080:80 ${IMAGE_NAME}
|
||||
cache:
|
||||
policy: pull
|
||||
|
||||
clear_master:
|
||||
stage: clear
|
||||
tags:
|
||||
- ali2
|
||||
only:
|
||||
- master
|
||||
script:
|
||||
- docker stop pan_${APP_NAME}
|
||||
- docker rm pan_${APP_NAME}
|
||||
allow_failure: true
|
||||
when: manual
|
||||
|
||||
deploy_master:
|
||||
stage: deploy
|
||||
tags:
|
||||
- ali2
|
||||
only:
|
||||
- master
|
||||
script:
|
||||
- ls -a
|
||||
- docker login --username=${DOCKER_USERNAME} --password=${DOCKER_PASSWORD} ${DOCKER_REGION}
|
||||
- docker pull ${IMAGE_NAME}
|
||||
- docker run -d --name pan_${APP_NAME} -p 127.0.0.1:5005:80 ${IMAGE_NAME}
|
||||
cache:
|
||||
policy: pull
|
||||
when: manual
|
||||
|
||||
clear_outside:
|
||||
stage: clear
|
||||
tags:
|
||||
- ali2
|
||||
only:
|
||||
- outside
|
||||
script:
|
||||
- docker stop ${APP_NAME}
|
||||
- docker rm ${APP_NAME}
|
||||
allow_failure: true
|
||||
when: manual
|
||||
|
||||
deploy_outside:
|
||||
stage: deploy
|
||||
tags:
|
||||
- ali2
|
||||
only:
|
||||
- outside
|
||||
script:
|
||||
- ls -a
|
||||
- docker login --username=${DOCKER_USERNAME} --password=${DOCKER_PASSWORD} ${DOCKER_REGION}
|
||||
- docker pull ${IMAGE_NAME}
|
||||
- docker run -d --name ${APP_NAME} -p 127.0.0.1:5004:80 ${IMAGE_NAME}
|
||||
cache:
|
||||
policy: pull
|
||||
when: manual
|
||||
|
||||
clear_test:
|
||||
stage: clear_test
|
||||
tags:
|
||||
- dockerbase
|
||||
script:
|
||||
- docker stop ${APP_NAME}
|
||||
- docker rm ${APP_NAME}
|
||||
allow_failure: true
|
||||
when: manual
|
@ -1,3 +1,4 @@
|
||||
FROM nginx
|
||||
COPY dist/ /usr/share/nginx/html/
|
||||
FROM nginx:1.18.0
|
||||
|
||||
COPY dist/ /usr/share/nginx/html
|
||||
COPY nginx/default.conf /etc/nginx/conf.d/default.conf
|
@ -1,17 +1,24 @@
|
||||
server {
|
||||
listen 80;
|
||||
server_name localhost;
|
||||
listen 80;
|
||||
listen [::]:80;
|
||||
server_name localhost;
|
||||
|
||||
access_log /var/log/nginx/host.access.log main;
|
||||
error_log /var/log/nginx/error.log error;
|
||||
access_log /var/log/nginx/host.access.log main;
|
||||
error_log /var/log/nginx/error.log error;
|
||||
|
||||
location / {
|
||||
root /usr/share/nginx/html;
|
||||
index index.html index.htm;
|
||||
try_files $uri $uri/ /index.html;
|
||||
}
|
||||
error_page 500 502 503 504 /50x.html;
|
||||
location = /50x.html {
|
||||
root /usr/share/nginx/html;
|
||||
}
|
||||
}
|
||||
location / {
|
||||
root /usr/share/nginx/html;
|
||||
index index.html index.htm;
|
||||
try_files $uri $uri/ /index.html;
|
||||
}
|
||||
|
||||
error_page 404 /404.html;
|
||||
location = /404.html {
|
||||
root /usr/share/nginx/html;
|
||||
}
|
||||
|
||||
error_page 500 502 503 504 /50x.html;
|
||||
location = /50x.html {
|
||||
root /usr/share/nginx/html;
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user