develop
jasder 4 years ago
parent bf4451a18b
commit 19b3079beb

20
.gitignore vendored

@ -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.

@ -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

@ -0,0 +1,9 @@
#添加docker镜像
FROM tomcat
#添加作者信息
MAINTAINER moshenglv@163.com
#复制应用程序
COPY target/demo-1.war /usr/local/tomcat/webapps/demo.war

@ -0,0 +1,12 @@
Copyright (C) 2006 by Rob Landley <rob@landley.net>
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.

@ -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 ====部署成功======

@ -0,0 +1,37 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.example</groupId>
<artifactId>demo</artifactId>
<version>1</version>
<name>demo</name>
<packaging>war</packaging>
<properties>
<maven.compiler.target>1.8</maven.compiler.target>
<maven.compiler.source>1.8</maven.compiler.source>
<junit.version>5.6.2</junit.version>
</properties>
<dependencies>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<version>4.0.1</version>
<scope>provided</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>3.3.0</version>
</plugin>
</plugins>
</build>
</project>

@ -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("<h1>" + message + "</h1>");
}
@Override
public void destroy() {
super.destroy();
}
}

@ -0,0 +1,15 @@
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_4_0.xsd"
version="4.0">
<servlet>
<servlet-name>HelloWorld</servlet-name>
<servlet-class>controller.HelloWorld</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>HelloWorld</servlet-name>
<url-pattern>/hello</url-pattern>
</servlet-mapping>
</web-app>
Loading…
Cancel
Save