第一次

This commit is contained in:
ZhuJW
2026-04-16 15:44:32 +08:00
commit 5a98242f2f
171 changed files with 42954 additions and 0 deletions

View File

@@ -0,0 +1,6 @@
FROM python:3.12-alpine
ARG RUFF_VERSION="0.9.10"
RUN apk add sudo bash git parallel
RUN pip install ruff==$RUFF_VERSION

View File

@@ -0,0 +1,25 @@
FROM swr.cn-north-4.myhuaweicloud.com/ddn-k8s/docker.io/python:3.12-slim-bookworm AS builder
#FROM artifacts.swf.i.mercedes-benz.com/panguprod-docker/fst_data_pipeline/python:3.12-slim-bookworm AS builder
#COPY --from=artifacts.swf.i.mercedes-benz.com/panguprod-docker/fst_data_pipeline/astral-sh/uv:0.7.21 /uv /uvx /bin/
COPY --from=swr.cn-north-4.myhuaweicloud.com/ddn-k8s/ghcr.io/astral-sh/uv:latest /uv /uvx /bin/
WORKDIR /app
COPY fst_data_pipeline/apps/root_db_api/pyproject.toml fst_data_pipeline/apps/root_db_api/uv.lock ./
RUN uv venv .venv && \
uv pip install -r pyproject.toml
COPY . .
RUN uv pip install --no-deps .
# ---------- 运行时 ----------
#FROM artifacts.swf.i.mercedes-benz.com/panguprod-docker/fst_data_pipeline/python:3.12-slim-bookworm
FROM swr.cn-north-4.myhuaweicloud.com/ddn-k8s/docker.io/python:3.12-slim-bookworm
RUN groupadd -r app && useradd -r -g app app
COPY --from=builder --chown=app:app /app/.venv /app/.venv
COPY --from=builder --chown=app:app /app /app
ENV VIRTUAL_ENV=/app/.venv PATH="/app/.venv/bin:$PATH"
WORKDIR /app
USER app
EXPOSE 5232
CMD ["gunicorn", "fst_data_pipeline.apps.root_db_api.src.app:app", "-b", "0.0.0.0:5232", "-w", "32"]

View File

@@ -0,0 +1,11 @@
version: '3'
services:
python-format:
image: fst_data_pipeline:python-format-v1
build:
dockerfile: Dockerfile.python-format
context: .
volumes:
- ../../..:/fst_data_pipeline
working_dir: /fst_data_pipeline

View File

@@ -0,0 +1,66 @@
#!/usr/bin/env sh
set -euo pipefail
current_dir=$(dirname "$0")
cd "${current_dir}/../../.." || exit
fetch=0
check=0
no_lint=0
fix=0
unsafe_fixes=0
format_all=0
while [ $# -gt 0 ]; do
case "$1" in
--fetch) fetch=1 ;;
--check) check=1 ;;
--no-lint) no_lint=1 ;;
--fix) fix=1 ;;
--unsafe-fixes) unsafe_fixes=1 ;;
--format-all) format_all=1 ;;
*)
echo "ignored unexpected arguments $1"
;;
esac
shift
done
if [ "$fetch" -eq 1 ]; then
git fetch origin
fi
echo -e "\033[33mchecking python code style, wait a moment...\033[0m"
if [ "$format_all" -eq 1 ]; then
py_source_code_files=$(find . -type f -name "*.py" ! -path "*/.venv/*" ! -path "*/venv/*")
else
py_source_code_files=$(git diff --name-only --diff-filter=ACMRTUXB origin/main | grep -E '\.py$' || true)
fi
if [ -n "${py_source_code_files}" ]; then
if [ "$check" -eq 1 ]; then
echo -e "checking python files: \n${py_source_code_files}"
echo -e "-----------------------------------\033[32m ruff checking \033[0m-----------------------------------"
ruff format --respect-gitignore --check --diff --preview ${py_source_code_files}
if [ "$no_lint" -eq 0 ]; then
ruff check --respect-gitignore ${py_source_code_files}
else
echo "no lint!!!"
fi
else
echo -e "fixing python files: \n${py_source_code_files}"
if [ "$fix" -eq 1 ]; then
echo -e "-----------------------------------\033[32m ruff fixing \033[0m-----------------------------------"
ruff check --respect-gitignore --fix ${py_source_code_files}
elif [ "${unsafe_fixes}" -eq 1 ]; then
echo -e "-----------------------------------\033[32m ruff unsafe-fixing \033[0m-----------------------------------"
ruff check --respect-gitignore --fix --unsafe-fixes ${py_source_code_files}
fi
echo -e "-----------------------------------\033[32m ruff formatting \033[0m-----------------------------------"
ruff format --respect-gitignore ${py_source_code_files}
echo -e "\033[32mall python code matches the coding style\033[0m"
fi
else
echo "no python files to process"
fi