forked from didi/KnowStreaming
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support docker source code construction
- Loading branch information
Showing
9 changed files
with
281 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
ARG MAVEN_VERSION=3.8.4-openjdk-8-slim | ||
ARG JAVA_VERSION=8-jdk-alpine3.9 | ||
FROM maven:${MAVEN_VERSION} AS builder | ||
ARG CONSOLE_ENABLE=true | ||
|
||
WORKDIR /opt | ||
COPY . . | ||
COPY distribution/conf/settings.xml /root/.m2/settings.xml | ||
|
||
# whether to build console | ||
RUN set -eux; \ | ||
if [ $CONSOLE_ENABLE = 'false' ]; then \ | ||
sed -i "/kafka-manager-console/d" pom.xml; \ | ||
fi \ | ||
&& mvn -Dmaven.test.skip=true clean install -U | ||
|
||
FROM openjdk:${JAVA_VERSION} | ||
|
||
RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.aliyun.com/g' /etc/apk/repositories && apk add --no-cache tini | ||
|
||
ENV TZ=Asia/Shanghai | ||
ENV AGENT_HOME=/opt/agent/ | ||
|
||
COPY --from=builder /opt/kafka-manager-web/target/kafka-manager.jar /opt | ||
COPY --from=builder /opt/container/dockerfiles/docker-depends/config.yaml $AGENT_HOME | ||
COPY --from=builder /opt/container/dockerfiles/docker-depends/jmx_prometheus_javaagent-0.15.0.jar $AGENT_HOME | ||
COPY --from=builder /opt/distribution/conf/application-docker.yml /opt | ||
|
||
WORKDIR /opt | ||
|
||
ENV JAVA_AGENT="-javaagent:$AGENT_HOME/jmx_prometheus_javaagent-0.15.0.jar=9999:$AGENT_HOME/config.yaml" | ||
ENV JAVA_HEAP_OPTS="-Xms1024M -Xmx1024M -Xmn100M " | ||
ENV JAVA_OPTS="-verbose:gc \ | ||
-XX:MaxMetaspaceSize=256M -XX:+DisableExplicitGC -XX:+UseStringDeduplication \ | ||
-XX:+UseG1GC -XX:+HeapDumpOnOutOfMemoryError -XX:-UseContainerSupport" | ||
|
||
EXPOSE 8080 9999 | ||
|
||
ENTRYPOINT ["tini", "--"] | ||
|
||
CMD [ "sh", "-c", "java -jar $JAVA_AGENT $JAVA_HEAP_OPTS $JAVA_OPTS kafka-manager.jar --spring.config.location=application-docker.yml"] |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
FROM mysql:5.7.37 | ||
|
||
COPY mysqld.cnf /etc/mysql/mysql.conf.d/ | ||
ENV TZ=Asia/Shanghai | ||
ENV MYSQL_ROOT_PASSWORD=root | ||
|
||
RUN apt-get update \ | ||
&& apt -y install wget \ | ||
&& wget https://ghproxy.com/https://raw.githubusercontent.com/didi/LogiKM/master/distribution/conf/create_mysql_table.sql -O /docker-entrypoint-initdb.d/create_mysql_table.sql | ||
|
||
EXPOSE 3306 | ||
|
||
VOLUME ["/var/lib/mysql"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
[client] | ||
default-character-set = utf8 | ||
|
||
[mysqld] | ||
character_set_server = utf8 | ||
pid-file = /var/run/mysqld/mysqld.pid | ||
socket = /var/run/mysqld/mysqld.sock | ||
datadir = /var/lib/mysql | ||
symbolic-links=0 | ||
|
||
max_allowed_packet = 10M | ||
sort_buffer_size = 1M | ||
read_rnd_buffer_size = 2M | ||
max_connections=2000 | ||
|
||
lower_case_table_names=1 | ||
character-set-server=utf8 | ||
|
||
max_allowed_packet = 1G | ||
sql_mode=STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION | ||
group_concat_max_len = 102400 | ||
default-time-zone = '+08:00' | ||
[mysql] | ||
default-character-set = utf8 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
|
||
## kafka-manager的配置文件,该文件中的配置会覆盖默认配置 | ||
## 下面的配置信息基本就是jar中的 application.yml默认配置了; | ||
## 可以只修改自己变更的配置,其他的删除就行了; 比如只配置一下mysql | ||
|
||
|
||
server: | ||
port: 8080 | ||
tomcat: | ||
accept-count: 1000 | ||
max-connections: 10000 | ||
max-threads: 800 | ||
min-spare-threads: 100 | ||
|
||
spring: | ||
application: | ||
name: kafkamanager | ||
version: 2.6.0 | ||
profiles: | ||
active: dev | ||
datasource: | ||
kafka-manager: | ||
jdbc-url: jdbc:mysql://${LOGI_MYSQL_HOST:mysql}:${LOGI_MYSQL_PORT:3306}/${LOGI_MYSQL_DATABASE:logi_kafka_manager}?characterEncoding=UTF-8&useSSL=false&serverTimezone=GMT%2B8 | ||
username: ${LOGI_MYSQL_USER:root} | ||
password: ${LOGI_MYSQL_PASSWORD:root} | ||
driver-class-name: com.mysql.cj.jdbc.Driver | ||
main: | ||
allow-bean-definition-overriding: true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<settings> | ||
<mirrors> | ||
<mirror> | ||
<id>aliyunmaven</id> | ||
<mirrorOf>*</mirrorOf> | ||
<name>阿里云公共仓库</name> | ||
<url>https://maven.aliyun.com/repository/public</url> | ||
</mirror> | ||
</mirrors> | ||
</settings> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,132 @@ | ||
--- | ||
|
||
 | ||
|
||
**一站式`Apache Kafka`集群指标监控与运维管控平台** | ||
|
||
--- | ||
|
||
|
||
## 基于Docker部署Logikm | ||
|
||
为了方便用户快速的在自己的环境搭建Logikm,可使用docker快速搭建 | ||
|
||
### 部署Mysql | ||
|
||
```shell | ||
docker run --name mysql -p 3306:3306 -d registry.cn-hangzhou.aliyuncs.com/zqqq/logikm-mysql:5.7.37 | ||
``` | ||
|
||
可选变量参考[文档](https://hub.docker.com/_/mysql) | ||
|
||
默认参数 | ||
|
||
* MYSQL_ROOT_PASSWORD:root | ||
|
||
|
||
|
||
### 部署Logikm Allinone | ||
|
||
> 前后端部署在一起 | ||
```shell | ||
docker run --name logikm -p 8080:8080 --link mysql -d registry.cn-hangzhou.aliyuncs.com/zqqq/logikm:2.6.0 | ||
``` | ||
|
||
参数详解: | ||
|
||
* -p 映射容器8080端口至宿主机的8080 | ||
* --link 连接mysql容器 | ||
|
||
|
||
|
||
### 部署前后端分离 | ||
|
||
#### 部署后端 Logikm-backend | ||
|
||
```shell | ||
docker run --name logikm-backend --link mysql -d registry.cn-hangzhou.aliyuncs.com/zqqq/logikm-backend:2.6.0 | ||
``` | ||
|
||
可选参数: | ||
|
||
* -e LOGI_MYSQL_HOST mysql连接地址,默认mysql | ||
* -e LOGI_MYSQL_PORT mysql端口,默认3306 | ||
* -e LOGI_MYSQL_DATABASE 数据库,默认logi_kafka_manager | ||
* -e LOGI_MYSQL_USER mysql用户名,默认root | ||
* -e LOGI_MYSQL_PASSWORD mysql密码,默认root | ||
|
||
#### 部署前端 Logikm-front | ||
|
||
```shell | ||
docker run --name logikm-front -p 8088:80 --link logikm-backend -d registry.cn-hangzhou.aliyuncs.com/zqqq/logikm-front:2.6.0 | ||
``` | ||
|
||
|
||
|
||
### Logi后端可配置参数 | ||
|
||
docker run 运行参数 -e 可指定环境变量如下 | ||
|
||
| 环境变量 | 变量解释 | 默认值 | | ||
| ------------------- | ------------- | ------------------ | | ||
| LOGI_MYSQL_HOST | mysql连接地址 | mysql | | ||
| LOGI_MYSQL_PORT | mysql端口 | 3306 | | ||
| LOGI_MYSQL_DATABASE | 数据库 | logi_kafka_manager | | ||
| LOGI_MYSQL_USER | mysql用户名 | root | | ||
| LOGI_MYSQL_PASSWORD | mysql密码 | root | | ||
|
||
|
||
|
||
|
||
## 基于Docker源码构建 | ||
|
||
根据此文档用户可自行通过Docker 源码构建 Logikm | ||
|
||
### 构建Mysql | ||
|
||
```shell | ||
docker build -t mysql:{TAG} -f container/dockerfiles/mysql/Dockerfile container/dockerfiles/mysql | ||
``` | ||
|
||
### 构建Allinone | ||
|
||
将前后端打包在一起 | ||
|
||
```shell | ||
docker build -t logikm:{TAG} . | ||
``` | ||
|
||
可选参数 --build-arg : | ||
|
||
* MAVEN_VERSION maven镜像tag | ||
* JAVA_VERSION java镜像tag | ||
|
||
|
||
|
||
### 构建前后端分离 | ||
|
||
前后端分离打包 | ||
|
||
#### 构建后端 | ||
|
||
```shell | ||
docker build --build-arg CONSOLE_ENABLE=false -t logikm-backend:{TAG} . | ||
``` | ||
|
||
参数: | ||
|
||
* MAVEN_VERSION maven镜像tag | ||
* JAVA_VERSION java镜像tag | ||
|
||
* CONSOLE_ENABLE=false 不构建console模块 | ||
|
||
#### 构建前端 | ||
|
||
```shell | ||
docker build -t logikm-front:{TAG} -f kafka-manager-console/Dockerfile kafka-manager-console | ||
``` | ||
|
||
可选参数: | ||
|
||
* --build-arg:OUTPUT_PATH 修改默认打包输出路径,默认当前目录下的dist |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
ARG NODE_VERSION=12.20.0 | ||
ARG NGINX_VERSION=1.21.5-alpine | ||
FROM node:${NODE_VERSION} AS builder | ||
ARG OUTPUT_PATH=dist | ||
|
||
ENV TZ Asia/Shanghai | ||
WORKDIR /opt | ||
COPY . . | ||
RUN npm config set registry https://registry.npm.taobao.org \ | ||
&& npm install \ | ||
# Change the output directory to dist | ||
&& sed -i "s#../kafka-manager-web/src/main/resources/templates#$OUTPUT_PATH#g" webpack.config.js \ | ||
&& npm run prod-build | ||
|
||
FROM nginx:${NGINX_VERSION} | ||
|
||
ENV TZ=Asia/Shanghai | ||
|
||
COPY --from=builder /opt/dist /opt/dist | ||
COPY --from=builder /opt/web.conf /etc/nginx/conf.d/default.conf |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
server { | ||
listen 80; | ||
|
||
location / { | ||
root /opt/dist; | ||
try_files $uri $uri/ /index.html; | ||
index index.html index.htm; | ||
} | ||
|
||
location /api { | ||
proxy_pass http://logikm-backend:8080; | ||
} | ||
} |