From a6103ac865ad60793f84e4f9271c117c9d0ecc61 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?F=E5=98=89=E9=98=B3?= Date: Wed, 27 Nov 2019 11:00:08 +0800 Subject: [PATCH] =?UTF-8?q?=E7=BC=96=E5=86=99=E9=95=9C=E5=83=8F=E6=96=87?= =?UTF-8?q?=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitlab-ci.yml | 69 ++++++++++++++++ Dockerfile | 11 +++ pom.xml | 52 +++--------- src/main/resources/application-k8s.yml | 39 +++++++++ src/main/resources/logback-spring.xml | 96 +++++++++++------------ src/main/resources/logback-spring.xml.bak | 60 ++++++++++++++ 6 files changed, 233 insertions(+), 94 deletions(-) create mode 100644 .gitlab-ci.yml create mode 100644 Dockerfile create mode 100644 src/main/resources/application-k8s.yml create mode 100644 src/main/resources/logback-spring.xml.bak diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml new file mode 100644 index 0000000..fae2517 --- /dev/null +++ b/.gitlab-ci.yml @@ -0,0 +1,69 @@ +image: harbor.fjy8018.top:8883/library/docker:19.03 + +variables: + MAVEN_CLI_OPTS: "-s .m2/settings.xml --batch-mode -Dmaven.test.skip=true" + MAVEN_OPTS: "-Dmaven.repo.local=.m2/repository" + DOCKER_DRIVER: overlay + DOCKER_HOST: tcp://localhost:2375 + DOCKER_TLS_CERTDIR: "" + SPRING_PROFILES_ACTIVE: docker + IMAGE_VERSION: "V2.9.13" + DOCKER_REGISTRY_MIRROR: "https://clayphwh.mirror.aliyuncs.com" + +stages: + - test + - package + - review + - deploy + +maven-build: + image: harbor.fjy8018.top:8883/library/maven:3-jdk-8 + stage: test + retry: 2 + script: + - mvn $MAVEN_CLI_OPTS clean package -U -B -T 2C + artifacts: + expire_in: 1 week + paths: + - target/*.jar + +maven-scan: + stage: test + retry: 2 + image: harbor.fjy8018.top:8883/library/maven:3-jdk-8 + script: + - mvn $MAVEN_CLI_OPTS verify sonar:sonar + +maven-deploy: + stage: deploy + retry: 2 + image: harbor.fjy8018.top:8883/library/maven:3-jdk-8 + script: + - mvn $MAVEN_CLI_OPTS deploy + + +docker-harbor-build: + stage: package + retry: 2 + image: + name: harbor.fjy8018.top:8883/google_container/kaniko-executor:debug + entrypoint: [""] + script: + - echo "{\"auths\":{\"$CI_REGISTRY\":{\"username\":\"$CI_REGISTRY_USER\",\"password\":\"$CI_REGISTRY_PASSWORD\"}}}" > /kaniko/.docker/config.json + - /kaniko/executor --context $CI_PROJECT_DIR --dockerfile $CI_PROJECT_DIR/Dockerfile --destination $CI_REGISTRY_IMAGE:$IMAGE_VERSION + +deploy_live: + image: harbor.fjy8018.top:8883/offical/kubectl:v1.14.0 + stage: deploy + retry: 2 + environment: + name: prod + url: https://cms.fjy8018.xin + script: + - kubectl version + - kubectl get pods -n hmdt + - cd manifests/ + - sed -i "s/__IMAGE_VERSION_SLUG__/${IMAGE_VERSION}/" deployment.yaml + - kubectl apply -f deployment.yaml + # - kubectl rollout status -f deployment.yaml + - kubectl get pods -n hmdt diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..ad4a612 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,11 @@ +FROM harbor.fjy8018.top:8883/library/openjdk:8-jre +MAINTAINER fjy8018 fjy8018@gmail.com + +COPY target/spring-V2.9.13.jar.jar /cms-springboot.jar +# 设置时区,默认为UTC +RUN ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime +RUN echo 'Asia/Shanghai' > /etc/timezone + +ENTRYPOINT ["java","-jar","/cms-springboot.jar","--spring.profiles.active=k8s"] + +EXPOSE 8080 diff --git a/pom.xml b/pom.xml index b2a6818..5ddea9f 100644 --- a/pom.xml +++ b/pom.xml @@ -5,7 +5,7 @@ com.fjy spring - V2.9.12 + V2.9.13 jar spring @@ -14,7 +14,7 @@ org.springframework.boot spring-boot-starter-parent - 2.0.0.RC2 + 2.0.0.RELEASE @@ -22,6 +22,7 @@ UTF-8 UTF-8 1.8 + true @@ -44,7 +45,6 @@ org.springframework.boot spring-boot-starter-data-jpa - mysql mysql-connector-java @@ -73,6 +73,12 @@ commons-io 2.6 + + + de.siegmar + logback-gelf + 2.1.0 + @@ -84,44 +90,4 @@ - - - - spring-snapshots - Spring Snapshots - https://repo.spring.io/snapshot - - true - - - - spring-milestones - Spring Milestones - https://repo.spring.io/milestone - - false - - - - - - - spring-snapshots - Spring Snapshots - https://repo.spring.io/snapshot - - true - - - - spring-milestones - Spring Milestones - https://repo.spring.io/milestone - - false - - - - - diff --git a/src/main/resources/application-k8s.yml b/src/main/resources/application-k8s.yml new file mode 100644 index 0000000..8f4b76e --- /dev/null +++ b/src/main/resources/application-k8s.yml @@ -0,0 +1,39 @@ +#运行环境配置文件 +server: + servlet: + context-path: /cms + session: + timeout: 1440s + port: 8080 + tomcat: + remote-ip-header: x-forwarded-for + protocol-header: x-forwarded-proto + port-header: X-Forwarded-Port + use-forward-headers: true +serverproperties: + port_num: 8080 + filePath: /www/cmsfile/ +spring: + thymeleaf: + prefix: classpath:/templates/ + cache: true + check-template: true + + datasource: + driver-class-name: com.mysql.jdbc.Driver + url: jdbc:mysql://192.168.1.25/db_imis2?useSSL=false&useUnicode=true&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai + username: imis2 + password: 2015imis2 + + servlet: + multipart: + max-file-size: 100Mb + max-request-size: 100Mb + + jpa: + hibernate: + ddl-auto: update + show-sql: false + #resources: + # static-locations: classpath:/templates/ +debug: false \ No newline at end of file diff --git a/src/main/resources/logback-spring.xml b/src/main/resources/logback-spring.xml index 0e82c6d..7d1eb87 100644 --- a/src/main/resources/logback-spring.xml +++ b/src/main/resources/logback-spring.xml @@ -1,60 +1,54 @@ - - - - - %d - %msg%n - - + + 192.168.1.27 + 12201 + 508 + true + + false + true + true + false + false + + true + + %m%nopex + + + %m%n + + + app_name:cms + os_arch:${os.arch} + os_name:${os.name} + os_version:${os.version} + - - - - - ERROR - DENY - ACCEPT - + + + + + + + + + + - - %d - %msg%n - + ${CONSOLE_LOG_PATTERN} utf8 - - - - F:\JAVA Workspace\Temp\log\%d\info.%d.log - - - - - - - - ERROR - - - - %d - %msg%n - - utf8 - - - - - F:\JAVA Workspace\Temp\log\error.%d.log - - - - - - - - - - + + + + + + \ No newline at end of file diff --git a/src/main/resources/logback-spring.xml.bak b/src/main/resources/logback-spring.xml.bak new file mode 100644 index 0000000..0e82c6d --- /dev/null +++ b/src/main/resources/logback-spring.xml.bak @@ -0,0 +1,60 @@ + + + + + + + %d - %msg%n + + + + + + + + ERROR + DENY + ACCEPT + + + + %d - %msg%n + + utf8 + + + + + F:\JAVA Workspace\Temp\log\%d\info.%d.log + + + + + + + + ERROR + + + + %d - %msg%n + + utf8 + + + + + F:\JAVA Workspace\Temp\log\error.%d.log + + + + + + + + + + + + + \ No newline at end of file