mirror of
https://gitee.com/kennylee/docker.git
synced 2024-11-29 18:38:34 +08:00
完善ci-webhook
This commit is contained in:
parent
8c7bd9b143
commit
a9f3b9e3ab
@ -1,14 +1,18 @@
|
||||
FROM registry.cn-hangzhou.aliyuncs.com/kennylee/sshd-tomcat:tomcat8-jre7-nodejs7
|
||||
FROM registry.cn-hangzhou.aliyuncs.com/kennylee/sshd-tomcat:tomcat8-jdk7-nodejs7
|
||||
|
||||
ENV REPO_URL=http://sys:11111111@192.168.3.231:10080/zgbj/gkxt.git
|
||||
ENV PROJECT_NAME=gkxt
|
||||
ENV PROJECT_BRANCH=feature_testci
|
||||
|
||||
RUN sed -i "s@\/usr\/lib\/jvm\/java-7-oracle@${JAVA_HOME}@" /etc/init.d/tomcat
|
||||
RUN sed -i "s@-server -Xms128m -Xmx1024m -XX\:PermSize=64M -XX\:MaxPermSize=192M@${JAVA_OPTS}@" /etc/init.d/tomcat
|
||||
|
||||
RUN cd /root && git clone https://git.oschina.net/kennylee/ci-webhook.git ci-webhook
|
||||
RUN cd ci-webhook && cnpm install
|
||||
RUN cd /tmp/ && git clone $REPO_URL $PROJECT_NAME && cd $PROJECT_NAME && git checkout $PROJECT_BRANCH
|
||||
RUN cd /tmp/$PROJECT_NAME && ./gradlew --no-daemon clean dist -x test
|
||||
RUN rm -rf ${CATALINA_HOME}/webapps/* && unzip /tmp/$PROJECT_NAME/build/dist/*.zip -d ${CATALINA_HOME}/webapps/
|
||||
|
||||
RUN cd ci-webhook && cnpm install
|
||||
|
||||
# Install Java.
|
||||
RUN \
|
||||
apt-get update && \
|
||||
apt-get install -y python-pip && \
|
||||
pip install supervisor-stdout && \
|
||||
rm -rf /var/lib/apt/lists/*
|
||||
|
||||
COPY deploy.sh /deploy.sh
|
||||
RUN chmod +x /deploy.sh
|
||||
|
||||
|
25
ci-webhook/tomcat/deploy.sh
Normal file
25
ci-webhook/tomcat/deploy.sh
Normal file
@ -0,0 +1,25 @@
|
||||
#!/bin/bash
|
||||
|
||||
PROJECT_NAME=gkxt
|
||||
REPO_BRANCH=feature_testci
|
||||
CUSTOM_JAVA_OPTS=
|
||||
|
||||
if [ -n "${JAVA_OPTS}" ]; then
|
||||
CUSTOM_JAVA_OPTS="$JAVA_OPTS"
|
||||
fi
|
||||
|
||||
source /root/.bashrc
|
||||
TOMCAT_WEBAPPS_PATH=$CATALINA_HOME'/webapps/'
|
||||
|
||||
if [ -n "${CUSTOM_JAVA_OPTS}" ]; then
|
||||
export JAVA_OPTS=$CUSTOM_JAVA_OPTS
|
||||
fi
|
||||
|
||||
${CATALINA_HOME}/bin/catalina.sh stop
|
||||
sleep 3s
|
||||
cd /tmp/$PROJECT_NAME
|
||||
git fetch origin $REPO_BRANCH
|
||||
git reset --hard origin/$REPO_BRANCH
|
||||
./gradlew --no-daemon clean dist -x test
|
||||
/bin/bash -c "rm -rf ${TOMCAT_WEBAPPS_PATH}* && unzip /tmp/$PROJECT_NAME/build/dist/*.zip -d $TOMCAT_WEBAPPS_PATH && ${CATALINA_HOME}/bin/catalina.sh run"
|
||||
|
@ -1,27 +1,14 @@
|
||||
var http = require("http"),
|
||||
exec = require('child_process').exec;
|
||||
|
||||
const PORT = 7788, projectName = 'gkxt';
|
||||
const repo = {
|
||||
url: 'http://sys:11111111@192.168.3.231:10080/zgbj/gkxt.git', // git repository
|
||||
branch: 'feature_testci',
|
||||
localPath: '/tmp/',
|
||||
buildCommand: './gradlew clean dist -x test',
|
||||
distPath: '/root/tomcat/webapps/'
|
||||
};
|
||||
const PORT = 7788;
|
||||
|
||||
http.createServer(function (request, response) {
|
||||
if (request.url.search(/deploy\/?$/i) > 0) {
|
||||
var commands = [
|
||||
'rm -rf ' + repo.localPath + projectName,
|
||||
'cd ' + repo.localPath,
|
||||
'git clone ' + repo.url + ' ' + projectName,
|
||||
'cd ' + projectName,
|
||||
'git checkout ' + repo.branch,
|
||||
repo.buildCommand,
|
||||
'rm -rf ' + repo.distPath + "*",
|
||||
'unzip ./build/dist/*.zip -d ' + repo.distPath,
|
||||
'service tomcat restart'
|
||||
'supervisorctl stop tomcat',
|
||||
'sleep 3s',
|
||||
'supervisorctl start tomcat'
|
||||
].join(' && ');
|
||||
var buildProcess = exec(commands, function (err, out, code) {
|
||||
if (err instanceof Error) {
|
||||
|
@ -5,9 +5,11 @@ nodaemon=true
|
||||
command=/usr/sbin/sshd -D
|
||||
|
||||
[program:tomcat]
|
||||
command=/supervisord_wrapper.sh
|
||||
command=/bin/bash /deploy.sh
|
||||
stdout_events_enabled = true
|
||||
stderr_events_enabled = true
|
||||
startretries=3
|
||||
environment=JAVA_OPTS='-server -Xms256m -Xmx1536m -XX:PermSize=64M -XX:MaxPermSize=192M'
|
||||
|
||||
[program:ci]
|
||||
command=/usr/bin/node /root/ci-webhook/server.js
|
||||
@ -16,7 +18,7 @@ stderr_events_enabled = true
|
||||
|
||||
[eventlistener:stdout]
|
||||
command = supervisor_stdout
|
||||
buffer_size = 100
|
||||
#buffer_size = 10
|
||||
events = PROCESS_LOG
|
||||
result_handler = supervisor_stdout:event_handler
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user