Selaa lähdekoodia

新增docker 部署配置

周浩 9 vuotta sitten
vanhempi
commit
6353b3fdfd

+ 3 - 4
hsweb-web-run/Dockerfile

@@ -1,6 +1,5 @@
-FROM zh.sqy/java7:v1.0
-RUN mkdir -p /apps/hsweb
+FROM hsweb/java8
 
-COPY target/hsweb-web-run-1.0-SNAPSHOT.jar /apps/hsweb/hsweb-run.jar
+COPY target/hsweb-web-run-1.0-SNAPSHOT.jar /app.jar
 EXPOSE 8088
-ENTRYPOINT java -jar /apps/hsweb/hsweb-run.jar
+ENTRYPOINT ["java","-Xdebug","-Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=5005","-jar","/app.jar"]

+ 36 - 2
hsweb-web-run/pom.xml

@@ -8,9 +8,7 @@
         <version>1.0-SNAPSHOT</version>
     </parent>
     <modelVersion>4.0.0</modelVersion>
-
     <artifactId>hsweb-web-run</artifactId>
-    <version>${parent.version}</version>
 
     <!--配置信息-->
     <properties>
@@ -77,15 +75,45 @@
                         </goals>
                     </execution>
                 </executions>
+                <dependencies>
+                    <dependency>
+                        <groupId>org.springframework</groupId>
+                        <artifactId>springloaded</artifactId>
+                        <version>1.2.5.RELEASE</version>
+                    </dependency>
+                </dependencies>
+            </plugin>
+
+            <plugin>
+                <groupId>com.spotify</groupId>
+                <artifactId>docker-maven-plugin</artifactId>
+                <version>0.4.5</version>
+                <configuration>
+                    <imageName>${project.artifactId}</imageName>
+                    <baseImage>hsweb/java8</baseImage>
+                    <entryPoint>["java", "-jar", "/${project.build.finalName}.jar"]</entryPoint>
+                    <resources>
+                        <resource>
+                            <targetPath>/</targetPath>
+                            <directory>${project.build.directory}</directory>
+                            <include>${project.build.finalName}.jar</include>
+                        </resource>
+                    </resources>
+                </configuration>
             </plugin>
         </plugins>
     </build>
 
     <dependencies>
+
         <dependency>
             <groupId>org.hsweb</groupId>
             <artifactId>hsweb-web-controller</artifactId>
         </dependency>
+        <!--<dependency>-->
+        <!--<groupId>org.springframework.boot</groupId>-->
+        <!--<artifactId>spring-boot-devtools</artifactId>-->
+        <!--</dependency>-->
         <dependency>
             <groupId>org.hsweb</groupId>
             <artifactId>hsweb-web-service-impl-common</artifactId>
@@ -94,6 +122,12 @@
             <groupId>org.hsweb</groupId>
             <artifactId>hsweb-web-dao-impl-mybatis</artifactId>
         </dependency>
+
+        <!--<dependency>-->
+        <!--<groupId>org.springframework</groupId>-->
+        <!--<artifactId>springloaded</artifactId>-->
+        <!--</dependency>-->
+
         <dependency>
             <groupId>org.springframework.boot</groupId>
             <artifactId>spring-boot-starter-freemarker</artifactId>

+ 13 - 2
hsweb-web-run/run-in-docker.sh

@@ -1,4 +1,15 @@
 #!/usr/bin/env bash
 mvn clean package -Pprod
-docker build -t hsweb:test .
-docker run -it --rm --link oracle11gxe:oracle -p 80:8088 hsweb:test
+if [ -f "target/hsweb-web-run-1.0-SNAPSHOT.jar" ]; then
+        container_id=$(docker ps | grep "hsweb-web-run" | awk '{print $1}')
+        if [ "container_id" != "" ];then
+            docker stop hsweb/web-run
+            docker rmi  hsweb/web-run
+        fi
+            docker build -t hsweb/web-run .
+            docker run -d --link oracle11gxe:oracle -p 80:8088 -p 5005:5005 --name hsweb hsweb/web-run
+           # docker run -it --rm --link oracle11gxe:oracle -p 80:8088 -p 5005:5005 --name hsweb hsweb/web-run
+    else
+        echo "build error!"
+        exit -1
+fi

+ 2 - 2
hsweb-web-run/src/main/environment/develop/config/logback.xml

@@ -7,9 +7,9 @@
         </encoder>
     </appender>
     <logger name="org.springframework" level="ERROR" />
-    <logger name="org.springframework.web" level="DEBUG" />
+    <logger name="org.springframework.web" level="ERROR" />
     <logger name="org.apache.tomcat" level="ERROR" />
-    <logger name="org.hsweb" level="DEBUG" />
+    <logger name="org.hsweb" level="ERROR" />
     <root level="ERROR">
         <appender-ref ref="Console"/>
     </root>

+ 0 - 2
hsweb-web-run/src/main/java/org/hsweb/web/boot/Run.java

@@ -5,9 +5,7 @@ import org.springframework.boot.SpringApplication;
 import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
 import org.springframework.context.annotation.ComponentScan;
 import org.springframework.context.annotation.Configuration;
-import org.springframework.context.annotation.EnableAspectJAutoProxy;
 import org.springframework.transaction.annotation.EnableTransactionManagement;
-import org.springframework.web.servlet.support.RequestContext;
 
 /**
  * Created by 浩 on 2016-01-16 0016.

+ 8 - 4
hsweb-web-run/src/main/resources/application.yml

@@ -1,10 +1,14 @@
 #LOGGING
 logging:
     config: classpath:config/logback.xml
-
 server:
     port: 8088
+
+#spring config
 spring:
+    devtools:
+        remote:
+            secret: hsweb
     application:
         name: ${app.name}
         index: index.html
@@ -30,9 +34,9 @@ spring:
         poolPreparedStatements: true
         maxOpenPreparedStatements: 20
     freemarker :
-                suffix : .ftl
-                request-context-attribute : request
-                expose-request-attributes : true
+        suffix : .ftl
+        request-context-attribute : request
+        expose-request-attributes : true
 # MyBatis
 mybatis:
     type-aliases-package: org.hsweb.web.bean.po

+ 1 - 1
hsweb-web-run/src/main/resources/static/1.txt

@@ -1 +1 @@
-test2
+test2 sdd

+ 0 - 1
hsweb-web-run/src/main/resources/templates/1.ftl

@@ -1 +0,0 @@
-hello

+ 1 - 0
hsweb-web-run/src/main/resources/templates/index.ftl

@@ -0,0 +1 @@
+2222