diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..26a62dc --- /dev/null +++ b/.gitignore @@ -0,0 +1,20 @@ +# ---> Actionscript +# Build and Release Folders +bin-debug/ +bin-release/ +[Oo]bj/ +[Bb]in/ + +# Other files and folders +.settings/ + +# Executables +*.swf +*.air +*.ipa +*.apk + +# Project files, i.e. `.project`, `.actionScriptProperties` and `.flexProperties` +# should NOT be excluded as they contain compiler settings and other important +# information for Eclipse / Flash Builder. + diff --git a/.trustie-pipeline.yml b/.trustie-pipeline.yml new file mode 100644 index 0000000..db8d79f --- /dev/null +++ b/.trustie-pipeline.yml @@ -0,0 +1,54 @@ + +kind: pipeline +type: docker +name: 开发流水线 +platform: + os: linux + arch: amd64 +steps: +- name: maven + image: maven:3-jdk-10 + commands: + - mvn install -DskipTests=true +# 本模板示例为上传软件包和部署脚本到home目录 +# host、username、password可在参数管理中配置 +- name: 上传文件 + image: appleboy/drone-scp + settings: + host: + from_secret: ip + username: + from_secret: name + password: + from_secret: pwd + port: 22 + target: /opt/demo + source: + - target/*.war + - Dockerfile +# 需要将软件包与部署脚本提前上传到远程主机(见文件上传模板) +# host、username、password可在参数管理中配置 +- name: 远程主机部署 + image: appleboy/drone-ssh + settings: + host: + from_secret: ip + username: + from_secret: name + password: + from_secret: pwd + port: 22 + script: + - echo ====暂停容器开始11======= + - docker rm -f mo-test + - docker rmi mo-test:1.0 + - cd /opt/demo + - echo ====开始部署======= + - docker build -t mo-test:1.0 . + - docker run -d -p 8080:8080 --name mo-test mo-test:1.0 + - echo ====部署成功====== +trigger: + branch: + - master + event: + - push diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..a7d6fe3 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,9 @@ + +#添加docker镜像 +FROM tomcat + +#添加作者信息 +MAINTAINER moshenglv@163.com + +#复制应用程序 +COPY target/demo-1.war /usr/local/tomcat/webapps/demo.war diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..e9d84ae --- /dev/null +++ b/LICENSE @@ -0,0 +1,12 @@ +Copyright (C) 2006 by Rob Landley + +Permission to use, copy, modify, and/or distribute this software for any purpose +with or without fee is hereby granted. + +THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH +REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY +AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, +INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM +LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE +OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR +PERFORMANCE OF THIS SOFTWARE. diff --git a/deploy.sh b/deploy.sh new file mode 100644 index 0000000..b3aa4d8 --- /dev/null +++ b/deploy.sh @@ -0,0 +1,6 @@ +echo ====暂停容器开始======= +docker rm -f devops-test +echo ====开始部署======= +docker build -t devops-test:1.0 . +docker run -d -p 8080:8080 --name devops-test devops-test:1.0 +echo ====部署成功====== \ No newline at end of file diff --git a/pom.xml b/pom.xml new file mode 100644 index 0000000..abb6bac --- /dev/null +++ b/pom.xml @@ -0,0 +1,37 @@ + + + 4.0.0 + + com.example + demo + 1 + demo + war + + + 1.8 + 1.8 + 5.6.2 + + + + + javax.servlet + javax.servlet-api + 4.0.1 + provided + + + + + + + org.apache.maven.plugins + maven-war-plugin + 3.3.0 + + + + \ No newline at end of file diff --git a/src/main/java/controller/HelloWorld.java b/src/main/java/controller/HelloWorld.java new file mode 100644 index 0000000..8f65637 --- /dev/null +++ b/src/main/java/controller/HelloWorld.java @@ -0,0 +1,35 @@ +package controller; + +import javax.servlet.ServletException; +import javax.servlet.annotation.WebServlet; +import javax.servlet.http.HttpServlet; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import java.io.IOException; +import java.io.PrintWriter; + +public class HelloWorld extends HttpServlet { + + private String message; + + @Override + public void init() throws ServletException { + message = "Hello world, this message is from servlet!"; + } + + @Override + protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { + //设置响应内容类型 + resp.setContentType("text/html"); + + //设置逻辑实现 + PrintWriter out = resp.getWriter(); + out.println("

" + message + "

"); + } + + @Override + public void destroy() { + super.destroy(); + } + +} diff --git a/src/main/webapp/WEB-INF/web.xml b/src/main/webapp/WEB-INF/web.xml new file mode 100644 index 0000000..c67f0d9 --- /dev/null +++ b/src/main/webapp/WEB-INF/web.xml @@ -0,0 +1,15 @@ + + + + + HelloWorld + controller.HelloWorld + + + HelloWorld + /hello + + \ No newline at end of file