jenkbushu
This commit is contained in:
1 parent
fcb70b85f4
commit
9b7f26f0df
4 files changed
+91
-5
No files matched your search
@@ -20,6 +20,9 @@ ROOT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
|
||||
COMPOSE_FILE="${ROOT_DIR}/docker-compose.yml"
|
||||
ENV_FILE="${ROOT_DIR}/.env.${ENV_NAME}"
|
||||
ORACLE_CLIENT_DIR="${ROOT_DIR}/oracle_client"
|
||||
BACKEND_DOCKERFILE="${ROOT_DIR}/backend/Dockerfile"
|
||||
SCHEMA_DOC_PATH="${ROOT_DIR}/docs/(表+字段).md"
|
||||
ROOT_DOCKERIGNORE="${ROOT_DIR}/.dockerignore"
|
||||
|
||||
check_oracle_client() {
|
||||
if [[ ! -d "${ORACLE_CLIENT_DIR}" ]]; then
|
||||
@@ -35,6 +38,49 @@ check_oracle_client() {
|
||||
fi
|
||||
}
|
||||
|
||||
check_backend_build_inputs() {
|
||||
echo "Validating backend Docker build inputs..."
|
||||
echo "- compose file: ${COMPOSE_FILE}"
|
||||
echo "- backend Dockerfile: ${BACKEND_DOCKERFILE}"
|
||||
echo "- schema doc: ${SCHEMA_DOC_PATH}"
|
||||
echo "- dockerignore: ${ROOT_DOCKERIGNORE}"
|
||||
|
||||
if [[ ! -f "${BACKEND_DOCKERFILE}" ]]; then
|
||||
echo "Missing backend Dockerfile: ${BACKEND_DOCKERFILE}"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [[ ! -f "${SCHEMA_DOC_PATH}" ]]; then
|
||||
echo "Missing Text2SQL schema doc: ${SCHEMA_DOC_PATH}"
|
||||
echo "Please ensure docs/(表+字段).md exists in the repository root before building hxops-backend."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if ! grep -Fq 'context: .' "${COMPOSE_FILE}" || ! grep -Fq 'dockerfile: backend/Dockerfile' "${COMPOSE_FILE}"; then
|
||||
echo "Invalid backend build settings in ${COMPOSE_FILE}"
|
||||
echo "hxops-backend must be built from repository root with:"
|
||||
echo " context: ."
|
||||
echo " dockerfile: backend/Dockerfile"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if ! grep -Fq 'COPY docs/(表+字段).md /app/docs/(表+字段).md' "${BACKEND_DOCKERFILE}"; then
|
||||
echo "Invalid backend Dockerfile: schema doc is not copied into the image."
|
||||
echo "Expected line:"
|
||||
echo " COPY docs/(表+字段).md /app/docs/(表+字段).md"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [[ -f "${ROOT_DOCKERIGNORE}" ]] && grep -Eq '^(docs|docs/\*)$' "${ROOT_DOCKERIGNORE}"; then
|
||||
if ! grep -Fxq '!docs/(表+字段).md' "${ROOT_DOCKERIGNORE}"; then
|
||||
echo "Invalid .dockerignore: docs is excluded but docs/(表+字段).md is not re-included."
|
||||
echo "Please add the following line to ${ROOT_DOCKERIGNORE}:"
|
||||
echo " !docs/(表+字段).md"
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
# 基础文件检查:compose 文件必须存在
|
||||
if [[ ! -f "${COMPOSE_FILE}" ]]; then
|
||||
echo "Missing compose file: ${COMPOSE_FILE}"
|
||||
@@ -109,6 +155,11 @@ echo "Prebuilt image mode: ${PREBUILT_MODE}"
|
||||
if printf '%s\n' "${services[@]}" | grep -qx "hxops-backend"; then
|
||||
echo "Checking Oracle Instant Client directory..."
|
||||
check_oracle_client
|
||||
if [[ "${PREBUILT_MODE}" != "true" ]]; then
|
||||
check_backend_build_inputs
|
||||
else
|
||||
echo "Skipping backend Docker input validation because prebuilt image mode is enabled."
|
||||
fi
|
||||
fi
|
||||
|
||||
# 预构建镜像模式:只启动,不构建
|
||||
|
||||
Reference in new issue
Block a user