From 8820b5929793b3c2ed97fd14af67ab9e87336617 Mon Sep 17 00:00:00 2001 From: "chenwen@trusfort.com" Date: Tue, 7 Feb 2023 13:55:53 +0800 Subject: [PATCH] =?UTF-8?q?feature:=E6=B7=BB=E5=8A=A0=E5=8D=95=E6=9C=BA?= =?UTF-8?q?=E7=89=88=E6=9C=ACdocker-comspoe.yml?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docker-compose-standalone.yml | 66 +++++++++++++++++++ docker-compose.yml | 62 ----------------- docker/eiam-console/Dockerfile | 50 ++++++++++++++ docker/eiam-openapi/Dockerfile | 50 ++++++++++++++ docker/eiam-portal/Dockerfile | 51 ++++++++++++++ docker/eiam-synchronizer/Dockerfile | 49 ++++++++++++++ docker/entrypoint.sh | 23 +++++++ .../src/main/resources/application.yml | 8 +-- 8 files changed, 293 insertions(+), 66 deletions(-) create mode 100644 docker-compose-standalone.yml delete mode 100644 docker-compose.yml create mode 100644 docker/eiam-console/Dockerfile create mode 100644 docker/eiam-openapi/Dockerfile create mode 100644 docker/eiam-portal/Dockerfile create mode 100644 docker/eiam-synchronizer/Dockerfile create mode 100644 docker/entrypoint.sh diff --git a/docker-compose-standalone.yml b/docker-compose-standalone.yml new file mode 100644 index 00000000..e287ace1 --- /dev/null +++ b/docker-compose-standalone.yml @@ -0,0 +1,66 @@ +version: '3' +x-public-common: &public-config + environment: + MYSQL_HOST: 192.168.56.107 # 配置数据库的信息 + MYSQL_USER: root + MYSQL_PASSWORD: admin + ES_HOST: 192.168.56.107 # 配置ES信息 + REDIS_HOST: 192.168.56.107 # 配置REDIS的信息 + REDIS_PASSWORD: 12345678 + CONSOLE_PUBLIC_BASE_URL: http://192.168.56.104:1898 + PORTAL_PUBLIC_BASE_URL: https://192.168.56.104:1989 + OPENAPI_PUBLIC_BASE_URL: http://192.168.56.104:1988 + SYNCHRONIZER_PUBLIC_BASE_URL: http://192.168.56.104:1986 +services: + eiam-console: + build: + context: . + dockerfile: docker/eiam-console/Dockerfile + <<: *public-config + container_name: eiam-console + ports: + - 1898:1898 + image: eiam-console + restart: always + networks: + - eiam-network + eiam-openapi: + build: + context: . + dockerfile: docker/eiam-openapi/Dockerfile + <<: *public-config + container_name: eiam-openapi + image: eiam-openapi + restart: always + ports: + - 1988:1988 + networks: + - eiam-network + eiam-portal: + build: + context: . + dockerfile: docker/eiam-portal/Dockerfile + <<: *public-config + container_name: eiam-portal + image: eiam-portal + restart: always + ports: + - 1989:1989 + networks: + - eiam-network + eiam-synchronizer: + build: + context: . + dockerfile: docker/eiam-synchronizer/Dockerfile + <<: *public-config + container_name: eiam-synchronizer + image: eiam-synchronizer + restart: always + ports: + - 1986:1986 + networks: + - eiam-network +networks: + eiam-network: + external: false + name: eiam-network diff --git a/docker-compose.yml b/docker-compose.yml deleted file mode 100644 index 4e4a0674..00000000 --- a/docker-compose.yml +++ /dev/null @@ -1,62 +0,0 @@ -version: '3' -services: - eiam-console: - build: - context: ./eiam-console/ - dockerfile: Dockerfile - environment: - MYSQL_HOST: 192.168.56.107 - MYSQL_USER: root - MYSQL_PASSWORD: admin - ES_HOST: 192.168.56.107 - REDIS_HOST: 192.168.56.107 - REDIS_PASSWORD: 12345678 - ports: - - 1898:1898 - image: eiam-console - restart: always - eiam-openapi: - build: - context: ./eiam-openapi/ - dockerfile: Dockerfile - environment: - MYSQL_HOST: 192.168.56.107 - MYSQL_USER: root - MYSQL_PASSWORD: admin - ES_HOST: 192.168.56.107 - REDIS_HOST: 192.168.56.107 - REDIS_PASSWORD: 12345678 - image: eiam-openapi - restart: always - ports: - - 1988:1988 - eiam-portal: - build: - context: ./eiam-portal/ - dockerfile: Dockerfile - environment: - MYSQL_HOST: 192.168.56.107 - MYSQL_USER: root - MYSQL_PASSWORD: admin - ES_HOST: 192.168.56.107 - REDIS_HOST: 192.168.56.107 - REDIS_PASSWORD: 12345678 - image: eiam-portal - restart: always - ports: - - 1989:1989 - eiam-synchronizer: - build: - context: ./eiam-synchronizer/ - dockerfile: Dockerfile - environment: - MYSQL_HOST: 192.168.56.107 - MYSQL_USER: root - MYSQL_PASSWORD: admin - ES_HOST: 192.168.56.107 - REDIS_HOST: 192.168.56.107 - REDIS_PASSWORD: 12345678 - image: eiam-synchronizer - restart: always - ports: - - 1986:1986 diff --git a/docker/eiam-console/Dockerfile b/docker/eiam-console/Dockerfile new file mode 100644 index 00000000..e0991362 --- /dev/null +++ b/docker/eiam-console/Dockerfile @@ -0,0 +1,50 @@ +# +# TopIAM Employee - Employee Identity and Access Management Program +# Copyright © 2020-2023 TopIAM (support@topiam.cn) +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . +# + +FROM azul/zulu-openjdk:17-jre as build +WORKDIR /workspace/app +ARG MODULE_NAME=eiam-console +ARG JAR_FILE=${MODULE_NAME}/target/topiam-employee-console-*.jar +COPY ${JAR_FILE} target/application.jar +RUN java -Djarmode=layertools -jar target/application.jar extract --destination target/extracted + +FROM azul/zulu-openjdk:17-jre + +ARG EXTRACTED=/workspace/app/target/extracted +WORKDIR topiam +ARG ENTRYPOINT_FILE=docker/entrypoint.sh +COPY ${ENTRYPOINT_FILE} / +COPY --from=build ${EXTRACTED}/dependencies/ ./ +COPY --from=build ${EXTRACTED}/spring-boot-loader/ ./ +COPY --from=build ${EXTRACTED}/snapshot-dependencies/ ./ +COPY --from=build ${EXTRACTED}/application/ ./ + + +ENV TZ=Asia/Shanghai +RUN sed -i 's/archive.ubuntu.com/cn.archive.ubuntu.com/g' /etc/apt/sources.list \ + && apt-get update \ + && ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone \ + && apt-get install tzdata \ + && apt-get clean \ + && apt-get autoclean \ + && apt-get autoremove \ + && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* \ + +EXPOSE 1898 + +ENTRYPOINT ["/entrypoint.sh"] \ No newline at end of file diff --git a/docker/eiam-openapi/Dockerfile b/docker/eiam-openapi/Dockerfile new file mode 100644 index 00000000..218b89ab --- /dev/null +++ b/docker/eiam-openapi/Dockerfile @@ -0,0 +1,50 @@ +# +# TopIAM Employee - Employee Identity and Access Management Program +# Copyright © 2020-2023 TopIAM (support@topiam.cn) +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . +# + +FROM azul/zulu-openjdk:17-jre as build +WORKDIR /workspace/app +ARG MODULE_NAME=eiam-openapi +ARG JAR_FILE=${MODULE_NAME}/target/topiam-employee-openapi-*.jar +COPY ${JAR_FILE} target/application.jar +RUN java -Djarmode=layertools -jar target/application.jar extract --destination target/extracted + +FROM azul/zulu-openjdk:17-jre + +ARG EXTRACTED=/workspace/app/target/extracted +WORKDIR topiam +ARG ENTRYPOINT_FILE=docker/entrypoint.sh +COPY ${ENTRYPOINT_FILE} / +COPY --from=build ${EXTRACTED}/dependencies/ ./ +COPY --from=build ${EXTRACTED}/spring-boot-loader/ ./ +COPY --from=build ${EXTRACTED}/snapshot-dependencies/ ./ +COPY --from=build ${EXTRACTED}/application/ ./ + + +ENV TZ=Asia/Shanghai +RUN sed -i 's/archive.ubuntu.com/cn.archive.ubuntu.com/g' /etc/apt/sources.list \ + && apt-get update \ + && ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone \ + && apt-get install tzdata \ + && apt-get clean \ + && apt-get autoclean \ + && apt-get autoremove \ + && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* \ + +EXPOSE 1988 + +ENTRYPOINT ["/entrypoint.sh"] \ No newline at end of file diff --git a/docker/eiam-portal/Dockerfile b/docker/eiam-portal/Dockerfile new file mode 100644 index 00000000..abd1861a --- /dev/null +++ b/docker/eiam-portal/Dockerfile @@ -0,0 +1,51 @@ +# +# TopIAM Employee - Employee Identity and Access Management Program +# Copyright © 2020-2023 TopIAM (support@topiam.cn) +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . +# + +FROM azul/zulu-openjdk:17-jre as build +WORKDIR /workspace/app +ARG MODULE_NAME=eiam-portal +ARG JAR_FILE=${MODULE_NAME}/target/topiam-employee-portal-*.jar +COPY ${JAR_FILE} target/application.jar +RUN java -Djarmode=layertools -jar target/application.jar extract --destination target/extracted + +FROM azul/zulu-openjdk:17-jre + + + +ARG EXTRACTED=/workspace/app/target/extracted +WORKDIR topiam +ARG ENTRYPOINT_FILE=docker/entrypoint.sh +COPY ${ENTRYPOINT_FILE} / +COPY --from=build ${EXTRACTED}/dependencies/ ./ +COPY --from=build ${EXTRACTED}/spring-boot-loader/ ./ +COPY --from=build ${EXTRACTED}/snapshot-dependencies/ ./ +COPY --from=build ${EXTRACTED}/application/ ./ + +ENV TZ=Asia/Shanghai +RUN sed -i 's/archive.ubuntu.com/cn.archive.ubuntu.com/g' /etc/apt/sources.list \ + && apt-get update \ + && ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone \ + && apt-get install tzdata \ + && apt-get clean \ + && apt-get autoclean \ + && apt-get autoremove \ + && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* \ + +EXPOSE 1989 + +ENTRYPOINT ["/entrypoint.sh"] \ No newline at end of file diff --git a/docker/eiam-synchronizer/Dockerfile b/docker/eiam-synchronizer/Dockerfile new file mode 100644 index 00000000..4fcad8f3 --- /dev/null +++ b/docker/eiam-synchronizer/Dockerfile @@ -0,0 +1,49 @@ +# +# TopIAM Employee - Employee Identity and Access Management Program +# Copyright © 2020-2023 TopIAM (support@topiam.cn) +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . +# + +FROM azul/zulu-openjdk:17-jre as build +WORKDIR /workspace/app +ARG MODULE_NAME=eiam-synchronizer +ARG JAR_FILE=${MODULE_NAME}/target/topiam-employee-synchronizer-*.jar +COPY ${JAR_FILE} target/application.jar +RUN java -Djarmode=layertools -jar target/application.jar extract --destination target/extracted + +FROM azul/zulu-openjdk:17-jre +ARG ENTRYPOINT_FILE=docker/entrypoint.sh +COPY ${ENTRYPOINT_FILE} / +ARG EXTRACTED=/workspace/app/target/extracted +WORKDIR topiam +COPY --from=build ${EXTRACTED}/dependencies/ ./ +COPY --from=build ${EXTRACTED}/spring-boot-loader/ ./ +COPY --from=build ${EXTRACTED}/snapshot-dependencies/ ./ +COPY --from=build ${EXTRACTED}/application/ ./ + + +ENV TZ=Asia/Shanghai +RUN sed -i 's/archive.ubuntu.com/cn.archive.ubuntu.com/g' /etc/apt/sources.list \ + && apt-get update \ + && ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone \ + && apt-get install tzdata \ + && apt-get clean \ + && apt-get autoclean \ + && apt-get autoremove \ + && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* \ + +EXPOSE 1986 + +ENTRYPOINT ["/entrypoint.sh"] \ No newline at end of file diff --git a/docker/entrypoint.sh b/docker/entrypoint.sh new file mode 100644 index 00000000..cd5973f1 --- /dev/null +++ b/docker/entrypoint.sh @@ -0,0 +1,23 @@ +#!/usr/bin/env bash +# +# TopIAM Employee - Employee Identity and Access Management Program +# Copyright © 2020-2023 TopIAM (support@topiam.cn) +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . +# + +java -XX:TieredStopAtLevel=1 \ + -Djava.security.egd=file:/dev/./urandom \ + -Dspring.main.lazy-initialization=false \ + org.springframework.boot.loader.JarLauncher \ No newline at end of file diff --git a/eiam-console/src/main/resources/application.yml b/eiam-console/src/main/resources/application.yml index 38b94c96..9cb91992 100644 --- a/eiam-console/src/main/resources/application.yml +++ b/eiam-console/src/main/resources/application.yml @@ -156,7 +156,7 @@ springdoc: #TopIAM topiam: server: - console-public-base-url: https://localhost:1898 - portal-public-base-url: https://localhost:1989 - openapi-public-base-url: https://localhost:1988 - synchronizer-public-base-url: https://localhost:1986 \ No newline at end of file + console-public-base-url: ${CONSOLE_PUBLIC_BASE_URL:https://localhost:1898} + portal-public-base-url: ${PORTAL_PUBLIC_BASE_URL:https://localhost:1989} + openapi-public-base-url: ${OPENAPI_PUBLIC_BASE_URL:https://localhost:1988} + synchronizer-public-base-url: ${SYNCHRONIZER_PUBLIC_BASE_URL:https://localhost:1986} \ No newline at end of file