-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
83 changed files
with
3,678 additions
and
63 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
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
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
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,52 @@ | ||
FROM python:3.10.13-bullseye AS builder | ||
|
||
WORKDIR /workspace | ||
|
||
ENV VIRTUAL_ENV=/opt/venv | ||
RUN python3 -m venv ${VIRTUAL_ENV} | ||
ENV PATH="${VIRTUAL_ENV}/bin:$PATH" | ||
|
||
# Install Python dependencies | ||
COPY docker/python/requirements.txt . | ||
COPY docker/bin/entrypoint.sh . | ||
#COPY version.py . | ||
COPY kdp_catalog_manager kdp_catalog_manager/ | ||
RUN ${VIRTUAL_ENV}/bin/pip3 install --no-cache-dir --upgrade pip setuptools Cython==3.0.8 \ | ||
&& ${VIRTUAL_ENV}/bin/pip3 install --no-cache-dir --upgrade --force-reinstall -r requirements.txt \ | ||
&& rm -f requirements.txt \ | ||
&& cd kdp_catalog_manager && python setup.py build_ext --inplace \ | ||
&& ${VIRTUAL_ENV}/bin/python setup.py build_ext clean -a && rm -f setup.py && rm -rf build | ||
|
||
|
||
FROM python:3.10.13-bullseye | ||
|
||
ENV TZ=${TZ:-Asia/Shanghai} | ||
ARG RUNTIME_HOME | ||
ENV RUNTIME_HOME=${RUNTIME_HOME:-/opt/bdos/kdp/bdos-core} | ||
ENV BDOS_USER=${BDOS_USER:-bdos} | ||
ENV BDOS_USER_HOME=${BDOS_USER_HOME:-/home/${BDOS_USER}} | ||
|
||
|
||
WORKDIR ${RUNTIME_HOME} | ||
|
||
RUN apt-get update \ | ||
&& apt-get -y install sudo \ | ||
&& apt-get clean \ | ||
&& rm -rf /var/lib/apt/lists/* \ | ||
&& cp /usr/share/zoneinfo/${TZ} /etc/localtime \ | ||
&& echo ${TZ} > /etc/timezone \ | ||
&& adduser -q --disabled-password --shell /bin/bash ${BDOS_USER} \ | ||
&& echo "${BDOS_USER} ALL=(root) NOPASSWD:ALL" > /etc/sudoers.d/${BDOS_USER} \ | ||
&& chmod 0440 /etc/sudoers.d/${BDOS_USER} \ | ||
&& chown -R ${BDOS_USER}:${BDOS_USER} ${BDOS_USER_HOME} \ | ||
&& mkdir ${RUNTIME_HOME}/logs \ | ||
&& chown -R ${BDOS_USER}:${BDOS_USER} ${RUNTIME_HOME} | ||
|
||
ENV PYTHONPATH=${RUNTIME_HOME} | ||
ENV VIRTUAL_ENV=/opt/venv | ||
ENV PATH="${VIRTUAL_ENV}/bin:$PATH" | ||
COPY --chown=${BDOS_USER}:${BDOS_USER} --from=builder /workspace . | ||
COPY --chown=${BDOS_USER}:${BDOS_USER} --from=builder /opt/venv /opt/venv | ||
|
||
USER ${BDOS_USER} | ||
CMD ["/bin/sh", "-c", "${RUNTIME_HOME}/entrypoint.sh"] |
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,2 @@ | ||
include makefiles/const.mk | ||
include makefiles/build-image.mk |
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 |
---|---|---|
@@ -1,2 +1,95 @@ | ||
# template-project | ||
This is the template project for initializing other LTC projects. | ||
[![License](https://img.shields.io/badge/License-Apache_2.0-blue.svg)](https://opensource.org/licenses/Apache-2.0) | ||
![Tests](https://github.com/linktimecloud/kdp-catalog-manager/actions/workflows/unit-test.yml/badge.svg) | ||
![Build](https://github.com/linktimecloud/kdp-catalog-manager/actions/workflows/ci-build.yml/badge.svg) | ||
![](https://img.shields.io/badge/python-3.10.13-green) | ||
![](https://img.shields.io/badge/fastapi-0.110.0-green) | ||
![image version](https://img.shields.io/docker/v/linktimecloud/kdp-catalog-manager) | ||
![image size](https://img.shields.io/docker/image-size/linktimecloud/kdp-catalog-manager) | ||
|
||
|
||
# KDP Catalog Manager | ||
|
||
## 项目描述 | ||
|
||
### 项目概述 | ||
KDP Catalog Manager是一套大数据应用管理平台。基于应用功能进行分类查看、管理,降低应用管理的复杂度,从而使大数据管理人员更专注于数据的处理 | ||
|
||
### 核心技术架构 | ||
![kdp-catalog-manager](kdp-catalog-manager.png) | ||
|
||
|
||
|
||
### 功能模块描述 | ||
|
||
#### api | ||
* view | ||
定义 Restful API 并对用户输入参数执行基本验证及结果输出 | ||
|
||
#### Domain | ||
* service | ||
业务逻辑 | ||
* format | ||
数据转换层,用于缓存数据与业务数据转换 | ||
* model | ||
数据模型实体 | ||
|
||
|
||
##### Modules | ||
* cache | ||
数据存储层,静态数据存储于缓存中 | ||
* requests | ||
外部数据调用,调用外部服务获取数据 | ||
|
||
|
||
## 目录结构 | ||
```shell | ||
├── CODEOWNERS | ||
├── README.md | ||
└── kdp_catalog_manager | ||
├── api | ||
├── common | ||
├── config | ||
├── main.py # 服务启动程序 | ||
├── requirements.txt | ||
├── test_main.py | ||
├── domain | ||
├── modules | ||
└── utils | ||
``` | ||
|
||
## 启动方式 | ||
### 开发环境搭建 | ||
* 使用python3.10+ | ||
|
||
1. 克隆代码至本地 | ||
```shell | ||
git clone xxx && cd kdp-catalog-manager | ||
``` | ||
|
||
2. 使用虚拟环境 | ||
```shell | ||
#安装virtualenv | ||
pip install virtualenv | ||
virtualenv -p /usr/local/bin/python3 venv | ||
# 激活虚拟环境 | ||
source ./venv/bin/activate | ||
|
||
# 关闭虚拟环境 | ||
deactivate | ||
``` | ||
|
||
3. 安装依赖 | ||
```shell | ||
pip install -r docker/python/requirements.txt | ||
``` | ||
|
||
4. 服务启动 | ||
```shell | ||
cd ~/kdp-catalog-manager \ | ||
&& export PYTHONPATH=$PYTHONPATH:$(pwd) | ||
python kdp_catalog_manager/main.py | ||
|
||
``` | ||
|
||
### API 手册 | ||
* 启动服务后通过 http://127.0.0.1:8000/docs 查看提供的接口列表 |
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,25 @@ | ||
#!/bin/bash | ||
|
||
declare RUNTIME_HOME=${RUNTIME_HOME:-"/opt/bdos/kdp/bdos-core"} | ||
declare BDOS_USER=${BDOS_USER:-bdos} | ||
declare CHOWN_HOST_PATH=${CHOWN_HOST_PATH:-"False"} | ||
declare LOG_LEVEL=${LOG_LEVEL:-"info"} | ||
declare WORKER_NUM=${WORKER_NUM:-4} | ||
declare PARAMS_LIMIT=${PARAMS_LIMIT:-0} | ||
declare MAX_REQUESTS=${MAX_REQUESTS:-100} | ||
declare MAX_REQUESTS_JITTER=${MAX_REQUESTS:-100} | ||
|
||
|
||
sudo chown ${BDOS_USER}:${BDOS_USER} ${RUNTIME_HOME} >/dev/null 2>&1 | ||
|
||
if [[ "${CHOWN_HOST_PATH}" == "True" ]];then | ||
echo -e "### Change owner of $RUNTIME_HOME ###" | ||
sudo chown -R ${BDOS_USER}:${BDOS_USER} ${RUNTIME_HOME}/kdp_catalog_manager ${RUNTIME_HOME}/logs ${RUNTIME_HOME} >/dev/null 2>&1 | ||
echo -e "### Change owner return code: $? ###" | ||
fi | ||
|
||
|
||
echo -e "### Starting Server... ###" | ||
cd ${RUNTIME_HOME} | ||
|
||
gunicorn -c kdp_catalog_manager/config/gunicorn.py kdp_catalog_manager.main:app --workers ${WORKER_NUM} --log-level ${LOG_LEVEL} --limit-request-line=${PARAMS_LIMIT} --max-requests ${MAX_REQUESTS} --max-requests-jitter ${MAX_REQUESTS_JITTER} --preload |
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,8 @@ | ||
fastapi[all]==0.110.0 | ||
uvicorn[standard]==0.27.1 | ||
cachelib==0.12.0 | ||
concurrent-log-handler==0.9.25 | ||
cachelib==0.12.0 | ||
markdown==3.5.2 | ||
prometheus-fastapi-instrumentator==6.1.0 | ||
gunicorn==21.2.0 |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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,2 @@ | ||
#!/usr/bin/env python | ||
# -*- encoding: utf-8 -*- |
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,2 @@ | ||
#!/usr/bin/env python | ||
# -*- encoding: utf-8 -*- |
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,2 @@ | ||
#!/usr/bin/env python | ||
# -*- encoding: utf-8 -*- |
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,18 @@ | ||
#!/usr/bin/env python | ||
# -*- encoding: utf-8 -*- | ||
from fastapi import APIRouter | ||
|
||
from kdp_catalog_manager.api.api_v1.endpoints import catalog | ||
from kdp_catalog_manager.api.api_v1.endpoints import catalog_app_form | ||
from kdp_catalog_manager.api.api_v1.endpoints import catalog_app_runtime | ||
|
||
api_router = APIRouter() | ||
|
||
# 分组路由 | ||
api_router.include_router(catalog.router, tags=["Catalog"]) | ||
api_router.include_router( | ||
catalog_app_form.router, tags=["CatalogAppForm"] | ||
) | ||
api_router.include_router( | ||
catalog_app_runtime.router, tags=["CatalogRuntime"] | ||
) |
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,2 @@ | ||
#!/usr/bin/env python | ||
# -*- encoding: utf-8 -*- |
Oops, something went wrong.