支持 docker-compose

pull/17/head
极客开源 2023-02-08 08:43:14 +00:00 committed by smallbun
parent f42421ca9e
commit 1d13877768
7 changed files with 392 additions and 4 deletions

View File

@ -0,0 +1,165 @@
version: '3'
x-public-common: &public-config
environment:
MYSQL_HOST: eiam-db # 配置数据库的信息
MYSQL_USER: root
MYSQL_PASSWORD: topiam
ES_HOST: eiam-es # 配置ES信息
REDIS_HOST: eiam-redis # 配置REDIS的信息
REDIS_PASSWORD: topiam
CONSOLE_PUBLIC_BASE_URL: http://localhost:1898
PORTAL_PUBLIC_BASE_URL: https://localhost:1989
OPENAPI_PUBLIC_BASE_URL: http://localhost:1988
SYNCHRONIZER_PUBLIC_BASE_URL: http://localhost:1986
services:
eiam-es:
image: docker.elastic.co/elasticsearch/elasticsearch:6.8.16
container_name: "eiam-es"
environment:
- discovery.type=single-node
- "ES_JAVA_OPTS=-Xms512m -Xmx512m"
ulimits:
memlock:
soft: -1
hard: -1
ports:
- "9200:9200"
- "9300:9300"
healthcheck:
test: [ "CMD", "curl" , "-f", "http://localhost:9200/_cat/health?v" ]
timeout: 20s
retries: 10
volumes:
- eiam_es_data:/usr/share/elasticsearch/data
networks:
- eiam-network
eiam-db:
image: mysql:8.0
container_name: "eiam-db"
environment:
- MYSQL_ROOT_PASSWORD=topiam
- MYSQL_DATABASE=eiam_develop
healthcheck:
test: [ "CMD", "mysqladmin" , "-ptopiam", "-hlocalhost","ping"]
timeout: 20s
retries: 10
ports:
- "3306:3306"
volumes:
- eiam_db_data:/var/lib/mysql
networks:
- eiam-network
eiam-db-admin:
container_name: "eiam-db-admin"
image: phpmyadmin:latest
ports:
- "7080:80"
environment:
- PMA_HOST=eiam-db
- UPLOAD_LIMIT=512M
healthcheck:
test: [ "CMD", "curl" , "-f", "http://localhost" ]
timeout: 20s
retries: 10
depends_on:
eiam-db:
condition: service_healthy
networks:
- eiam-network
eiam-redis:
image: redis:7.0
container_name: "eiam-redis"
command: redis-server --requirepass topiam
healthcheck:
test: [ "CMD", "redis-cli" ,"ping" ]
timeout: 20s
retries: 10
ports:
- "6379:6379"
networks:
- eiam-network
eiam-console:
build:
context: .
dockerfile: docker/eiam-console/Dockerfile
<<: *public-config
container_name: eiam-console
ports:
- 1898:1898
image: eiam-console
restart: always
depends_on:
eiam-es:
condition: service_healthy
eiam-db:
condition: service_healthy
eiam-redis:
condition: service_healthy
eiam-db-admin:
condition: service_healthy
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
depends_on:
eiam-es:
condition: service_healthy
eiam-db:
condition: service_healthy
eiam-redis:
condition: service_healthy
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
depends_on:
eiam-es:
condition: service_healthy
eiam-db:
condition: service_healthy
eiam-redis:
condition: service_healthy
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
depends_on:
eiam-es:
condition: service_healthy
eiam-db:
condition: service_healthy
eiam-redis:
condition: service_healthy
networks:
- eiam-network
networks:
eiam-network:
external: false
name: eiam-network
volumes:
eiam_es_data:
eiam_db_data:

View File

@ -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 <http://www.gnu.org/licenses/>.
#
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"]

View File

@ -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 <http://www.gnu.org/licenses/>.
#
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"]

View File

@ -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 <http://www.gnu.org/licenses/>.
#
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"]

View File

@ -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 <http://www.gnu.org/licenses/>.
#
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"]

23
docker/entrypoint.sh Normal file
View File

@ -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 <http://www.gnu.org/licenses/>.
#
java -XX:TieredStopAtLevel=1 \
-Djava.security.egd=file:/dev/./urandom \
-Dspring.main.lazy-initialization=false \
org.springframework.boot.loader.JarLauncher

View File

@ -156,7 +156,7 @@ springdoc:
#TopIAM #TopIAM
topiam: topiam:
server: server:
console-public-base-url: https://localhost:1898 console-public-base-url: ${CONSOLE_PUBLIC_BASE_URL:https://localhost:1898}
portal-public-base-url: https://localhost:1989 portal-public-base-url: ${PORTAL_PUBLIC_BASE_URL:https://localhost:1989}
openapi-public-base-url: https://localhost:1988 openapi-public-base-url: ${OPENAPI_PUBLIC_BASE_URL:https://localhost:1988}
synchronizer-public-base-url: https://localhost:1986 synchronizer-public-base-url: ${SYNCHRONIZER_PUBLIC_BASE_URL:https://localhost:1986}