Merge pull request #132 from tikazyq/develop

Develop
This commit is contained in:
Marvin Zhang
2019-08-16 00:27:37 +08:00
committed by GitHub
7 changed files with 70 additions and 20 deletions

42
Jenkinsfile vendored
View File

@@ -11,13 +11,20 @@ pipeline {
echo "Running Setup..."
script {
if (env.GIT_BRANCH == 'develop') {
env.MODE = 'develop'
env.TAG = 'develop'
env.BASE_URL = '/dev'
env.DOCKERFILE = 'Dockerfile.local'
} else if (env.GIT_BRANCH == 'master') {
env.MODE = 'production'
env.TAG = 'master'
env.BASE_URL = '/demo'
env.DOCKERFILE = 'Dockerfile.local'
} else if (env.GIT_BRANCH == 'frontend') {
env.TAG = 'frontend-alpine'
env.DOCKERFILE = 'frontend/Dockerfile.frontend.alpine'
} else if (env.GIT_BRANCH == 'backend-master') {
env.TAG = 'master-alpine'
env.DOCKERFILE = 'frontend/Dockerfile.master.alpine'
} else if (env.GIT_BRANCH == 'backend-worker') {
env.TAG = 'worker-alpine'
env.DOCKERFILE = 'frontend/Dockerfile.worker.alpine'
}
}
}
@@ -26,7 +33,7 @@ pipeline {
steps {
echo "Building..."
sh """
docker build -t tikazyq/crawlab:${ENV:TAG} -f Dockerfile.local .
docker build -t tikazyq/crawlab:${ENV:TAG} -f ${ENV.DOCKERFILE} .
"""
}
}
@@ -38,13 +45,26 @@ pipeline {
stage('Deploy') {
steps {
echo 'Deploying....'
script {
if (env.GIT_BRANCH == 'master' || env.GIT_BRANCH == 'develop') {
sh """
cd ./jenkins/${ENV:GIT_BRANCH}
docker-compose stop | true
docker-compose up -d
"""
} else {
sh """
docker push tikazyq/crawlab:${ENV:TAG}
"""
}
}
}
}
stage('Cleanup') {
steps {
echo 'Cleanup...'
sh """
echo ${ENV:GIT_BRANCH}
"""
sh """
cd ./jenkins/${ENV:GIT_BRANCH}
docker-compose stop | true
docker-compose up -d
docker image prune -f
"""
}
}

View File

@@ -1,10 +1,10 @@
# Crawlab
![](http://114.67.75.98:8082/buildStatus/icon?job=crawlab%2Fmaster)
![](https://img.shields.io/badge/版本-v0.3.0-blue.svg)
<a href="https://github.com/tikazyq/crawlab/blob/master/LICENSE" target="_blank">
<img src="https://img.shields.io/badge/License-BSD-blue.svg">
</a>
![](https://img.shields.io/github/release/tikazyq/crawlab.svg)
![](https://img.shields.io/github/last-commit/tikazyq/crawlab.svg)
![](https://img.shields.io/github/issues/tikazyq/crawlab.svg)
![](https://img.shields.io/github/license/tikazyq/crawlab.svg)
中文 | [English](https://github.com/tikazyq/crawlab)

View File

@@ -1,10 +1,10 @@
# Crawlab
![](http://114.67.75.98:8082/buildStatus/icon?job=crawlab%2Fmaster)
![](https://img.shields.io/badge/version-v0.3.0-blue.svg)
<a href="https://github.com/tikazyq/crawlab/blob/master/LICENSE" target="_blank">
<img src="https://img.shields.io/badge/license-BSD-blue.svg">
</a>
![](https://img.shields.io/github/release/tikazyq/crawlab.svg)
![](https://img.shields.io/github/last-commit/tikazyq/crawlab.svg)
![](https://img.shields.io/github/issues/tikazyq/crawlab.svg)
![](https://img.shields.io/github/license/tikazyq/crawlab.svg)
[中文](https://github.com/tikazyq/crawlab/blob/master/README-zh.md) | English

View File

@@ -0,0 +1,20 @@
FROM alpine:latest
# 安装nginx
RUN mkdir /run/nginx && apk add nginx
# 拷贝编译文件
COPY dist /app/dist
# 拷贝nginx代理文件
COPY crawlab.conf /etc/nginx/conf.d
# 拷贝执行脚本
COPY docker_init.sh /app/docker_init.sh
# 定义后端API脚本
ENV CRAWLAB_API_ADDRESS http://localhost:8000
EXPOSE 8080
CMD ["/bin/sh", "/app/docker_init.sh"]

View File

@@ -1,10 +1,20 @@
FROM node:8.16.0-alpine AS build
ADD ./frontend /app
WORKDIR /app
# install frontend
RUN npm install -g yarn && yarn install
RUN npm run build:prod
FROM alpine:latest
# 安装nginx
RUN mkdir /run/nginx && apk add nginx
# 拷贝编译文件
COPY dist /app/dist
COPY --from=build /app/dist /app/dist
# 拷贝nginx代理文件
COPY crawlab.conf /etc/nginx/conf.d