From 4c83784a7401ce5a38378cc1889938310283fabd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=86=B7=E5=86=B7?= Date: Sun, 26 Aug 2018 20:38:43 +0800 Subject: [PATCH] =?UTF-8?q?:whale:=20=E5=9C=A8=20Docker=20=E4=B8=AD?= =?UTF-8?q?=E8=BF=90=E8=A1=8C=EF=BC=8C=E4=BF=AE=E6=94=B9dockerfile?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docker-compose.yml | 18 +++++- pigx-auth/Dockerfile | 2 +- ... BaseResourceServerConfigurerAdapter.java} | 2 +- pigx-config/Dockerfile | 2 +- pigx-eureka/Dockerfile | 2 +- pigx-gateway/Dockerfile | 2 +- .../gateway/filter/PreviewGatewayFilter.java | 58 +++++++++++++++++++ pigx-upms/pigx-upms-biz/Dockerfile | 2 +- pigx-visual/pigx-codegen/Dockerfile | 2 +- pigx-visual/pigx-daemon/Dockerfile | 2 +- pigx-visual/pigx-monitor/Dockerfile | 2 +- pigx-visual/pigx-tx-manager/Dockerfile | 14 +++++ pigx-visual/pigx-tx-manager/pom.xml | 3 + 13 files changed, 99 insertions(+), 12 deletions(-) rename pigx-common/pigx-common-security/src/main/java/com/pig4cloud/pigx/common/security/component/{PigxResourceServerConfigurerAdapter.java => BaseResourceServerConfigurerAdapter.java} (97%) create mode 100644 pigx-gateway/src/main/java/com/pig4cloud/pigx/gateway/filter/PreviewGatewayFilter.java create mode 100644 pigx-visual/pigx-tx-manager/Dockerfile diff --git a/docker-compose.yml b/docker-compose.yml index a515a2a09..a339addd3 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -25,6 +25,7 @@ services: pigx-gateway: links: - pigx-eureka + - pigx-redis build: context: ./ dockerfile: ./pigx-gateway/Dockerfile @@ -40,8 +41,6 @@ services: context: ./ dockerfile: ./pigx-auth/Dockerfile restart: always - ports: - - 3000:3000 pigx-upms: links: @@ -56,6 +55,7 @@ services: pigx-monitor: links: - pigx-eureka + - pigx-redis build: context: ./ dockerfile: ./pigx-visual/pigx-monitor/Dockerfile @@ -66,6 +66,7 @@ services: pigx-daemon: links: - pigx-eureka + - pigx-redis build: context: ./ dockerfile: ./pigx-visual/pigx-daemon/Dockerfile @@ -76,9 +77,20 @@ services: pigx-codegen: links: - pigx-eureka + - pigx-redis build: context: ./ dockerfile: ./pigx-visual/pigx-codegen/Dockerfile restart: always + + pigx-tx-manager: + links: + - pigx-eureka + - pigx-redis + build: + context: ./ + dockerfile: ./pigx-visual/pigx-tx-manager/Dockerfile + restart: always ports: - - 5003:5003 + - 5004:5004 + - 9998:9998 diff --git a/pigx-auth/Dockerfile b/pigx-auth/Dockerfile index 459b6d3bb..e84cc1964 100644 --- a/pigx-auth/Dockerfile +++ b/pigx-auth/Dockerfile @@ -8,6 +8,6 @@ WORKDIR /pigx/bin/com.pig4cloud/pigx-auth EXPOSE 3000 -ADD ./target/pigx-auth.jar ./ +ADD ./pigx-auth/target/pigx-auth.jar ./ CMD java -Djava.security.egd=file:/dev/./urandom -jar pigx-auth.jar diff --git a/pigx-common/pigx-common-security/src/main/java/com/pig4cloud/pigx/common/security/component/PigxResourceServerConfigurerAdapter.java b/pigx-common/pigx-common-security/src/main/java/com/pig4cloud/pigx/common/security/component/BaseResourceServerConfigurerAdapter.java similarity index 97% rename from pigx-common/pigx-common-security/src/main/java/com/pig4cloud/pigx/common/security/component/PigxResourceServerConfigurerAdapter.java rename to pigx-common/pigx-common-security/src/main/java/com/pig4cloud/pigx/common/security/component/BaseResourceServerConfigurerAdapter.java index 4242db953..f49d86b20 100644 --- a/pigx-common/pigx-common-security/src/main/java/com/pig4cloud/pigx/common/security/component/PigxResourceServerConfigurerAdapter.java +++ b/pigx-common/pigx-common-security/src/main/java/com/pig4cloud/pigx/common/security/component/BaseResourceServerConfigurerAdapter.java @@ -30,7 +30,7 @@ import org.springframework.security.oauth2.provider.token.RemoteTokenServices; * @author lengleng * @date 2018/6/22 */ -public abstract class PigxResourceServerConfigurerAdapter extends ResourceServerConfigurerAdapter { +public abstract class BaseResourceServerConfigurerAdapter extends ResourceServerConfigurerAdapter { @Autowired protected ResourceAuthExceptionEntryPoint resourceAuthExceptionEntryPoint; @Autowired diff --git a/pigx-config/Dockerfile b/pigx-config/Dockerfile index 094ff3bc2..fead92d09 100644 --- a/pigx-config/Dockerfile +++ b/pigx-config/Dockerfile @@ -8,6 +8,6 @@ WORKDIR /pigx/bin/com.pig4cloud/pigx-config EXPOSE 4001 -ADD ./target/pigx-config.jar ./ +ADD ./pigx-config/target/pigx-config.jar ./ CMD java -Djava.security.egd=file:/dev/./urandom -jar pigx-config.jar diff --git a/pigx-eureka/Dockerfile b/pigx-eureka/Dockerfile index 3e0e339d6..e05fb249b 100644 --- a/pigx-eureka/Dockerfile +++ b/pigx-eureka/Dockerfile @@ -8,6 +8,6 @@ WORKDIR /pigx/bin/com.pig4cloud/pigx-eureka EXPOSE 1025 -ADD ./target/pigx-eureka.jar ./ +ADD ./pigx-eureka/target/pigx-eureka.jar ./ CMD java -Djava.security.egd=file:/dev/./urandom -jar pigx-eureka.jar diff --git a/pigx-gateway/Dockerfile b/pigx-gateway/Dockerfile index b61d5b6d0..3d765f3ac 100644 --- a/pigx-gateway/Dockerfile +++ b/pigx-gateway/Dockerfile @@ -8,6 +8,6 @@ WORKDIR /pigx/bin/com.pig4cloud/pigx-gateway EXPOSE 9999 -ADD ./target/pigx-gateway.jar ./ +ADD ./pigx-gateway/target/pigx-gateway.jar ./ CMD java -Djava.security.egd=file:/dev/./urandom -jar pigx-gateway.jar diff --git a/pigx-gateway/src/main/java/com/pig4cloud/pigx/gateway/filter/PreviewGatewayFilter.java b/pigx-gateway/src/main/java/com/pig4cloud/pigx/gateway/filter/PreviewGatewayFilter.java new file mode 100644 index 000000000..6a977287e --- /dev/null +++ b/pigx-gateway/src/main/java/com/pig4cloud/pigx/gateway/filter/PreviewGatewayFilter.java @@ -0,0 +1,58 @@ +/* + * Copyright (c) 2018-2025, lengleng All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * Neither the name of the pig4cloud.com developer nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * Author: lengleng (wangiegie@gmail.com) + */ + +package com.pig4cloud.pigx.gateway.filter; + +import cn.hutool.core.util.StrUtil; +import lombok.extern.slf4j.Slf4j; +import org.springframework.cloud.gateway.filter.GatewayFilter; +import org.springframework.cloud.gateway.filter.factory.AbstractGatewayFilterFactory; +import org.springframework.http.HttpMethod; +import org.springframework.http.HttpStatus; +import org.springframework.http.server.reactive.ServerHttpRequest; +import org.springframework.http.server.reactive.ServerHttpResponse; +import org.springframework.stereotype.Component; + +/** + * @author lengleng + * @date 2018/8/421 + * 演示环境过滤处理 + */ +@Slf4j +@Component +public class PreviewGatewayFilter extends AbstractGatewayFilterFactory { + private static final String TOKEN = "token"; + + + @Override + public GatewayFilter apply(Object config) { + return (exchange, chain) -> { + ServerHttpRequest request = exchange.getRequest(); + + // GET,直接向下执行 + if (StrUtil.equalsIgnoreCase(request.getMethodValue(), HttpMethod.GET.name()) || + StrUtil.containsIgnoreCase(request.getURI().getPath(), TOKEN)) { + return chain.filter(exchange); + } + + log.warn("演示环境不能操作-> {},{}", request.getMethodValue(), request.getURI().getPath()); + ServerHttpResponse response = exchange.getResponse(); + response.setStatusCode(HttpStatus.LOCKED); + return response.setComplete(); + }; + } +} diff --git a/pigx-upms/pigx-upms-biz/Dockerfile b/pigx-upms/pigx-upms-biz/Dockerfile index e1734d555..0d9292b1d 100644 --- a/pigx-upms/pigx-upms-biz/Dockerfile +++ b/pigx-upms/pigx-upms-biz/Dockerfile @@ -8,6 +8,6 @@ WORKDIR /pigx/bin/com.pig4cloud/pigx-upms EXPOSE 4000 -ADD ./target/pigx-upms-biz.jar ./ +ADD ./pigx-upms/pigx-upms-biz/target/pigx-upms-biz.jar ./ CMD java -Djava.security.egd=file:/dev/./urandom -jar pigx-upms-biz.jar diff --git a/pigx-visual/pigx-codegen/Dockerfile b/pigx-visual/pigx-codegen/Dockerfile index cb136f278..8df77aa39 100644 --- a/pigx-visual/pigx-codegen/Dockerfile +++ b/pigx-visual/pigx-codegen/Dockerfile @@ -8,6 +8,6 @@ WORKDIR /pigx/bin/com.pig4cloud/pigx-codegen EXPOSE 5003 -ADD ./target/pigx-codegen.jar ./ +ADD ./pigx-visual/pigx-codegen/target/pigx-codegen.jar ./ CMD java -Djava.security.egd=file:/dev/./urandom -jar pigx-codegen.jar diff --git a/pigx-visual/pigx-daemon/Dockerfile b/pigx-visual/pigx-daemon/Dockerfile index bcfddd240..a442fde69 100644 --- a/pigx-visual/pigx-daemon/Dockerfile +++ b/pigx-visual/pigx-daemon/Dockerfile @@ -8,6 +8,6 @@ WORKDIR /pigx/bin/com.pig4cloud/pigx-daemon EXPOSE 5002 -ADD ./target/pigx-daemon.jar ./ +ADD ./pigx-visual/pigx-daemon/target/pigx-daemon.jar ./ CMD java -Djava.security.egd=file:/dev/./urandom -jar pigx-daemon.jar diff --git a/pigx-visual/pigx-monitor/Dockerfile b/pigx-visual/pigx-monitor/Dockerfile index 534fa4fd9..09feb12a2 100644 --- a/pigx-visual/pigx-monitor/Dockerfile +++ b/pigx-visual/pigx-monitor/Dockerfile @@ -8,6 +8,6 @@ WORKDIR /pigx/bin/com.pig4cloud/pigx-monitor EXPOSE 5001 -ADD ./target/pigx-monitor.jar ./ +ADD ./pigx-visual/pigx-monitor/target/pigx-monitor.jar ./ CMD java -Djava.security.egd=file:/dev/./urandom -jar pigx-monitor.jar diff --git a/pigx-visual/pigx-tx-manager/Dockerfile b/pigx-visual/pigx-tx-manager/Dockerfile new file mode 100644 index 000000000..ca500535c --- /dev/null +++ b/pigx-visual/pigx-tx-manager/Dockerfile @@ -0,0 +1,14 @@ +FROM anapsix/alpine-java:8_server-jre_unlimited + +MAINTAINER wangiegie@gmail.com + +RUN mkdir -p /pigx/bin/com.pig4cloud/pigx-tx-manager + +WORKDIR /pigx/bin/com.pig4cloud/pigx-tx-manager + +EXPOSE 5004 +EXPOSE 9998 + +ADD ./pigx-visual/pigx-tx-manager/target/pigx-tx-manager.jar ./ + +CMD java -Djava.security.egd=file:/dev/./urandom -jar pigx-tx-manager.jar diff --git a/pigx-visual/pigx-tx-manager/pom.xml b/pigx-visual/pigx-tx-manager/pom.xml index 8c96f4009..69e6cc2f6 100644 --- a/pigx-visual/pigx-tx-manager/pom.xml +++ b/pigx-visual/pigx-tx-manager/pom.xml @@ -73,6 +73,9 @@ org.springframework.boot spring-boot-maven-plugin + + ${project.name} +