From 9f78786c9a1d8947b97d99373b2076dc9b3142b5 Mon Sep 17 00:00:00 2001 From: shanghaikid Date: Fri, 29 Nov 2024 22:12:48 +0800 Subject: [PATCH] update 301 Signed-off-by: shanghaikid --- Nginx.Dockerfile | 5 +++++ conf/conf.d/client.conf | 3 +++ scripts/pre-commit.js | 39 +++++++++++++++++++++------------------ 3 files changed, 29 insertions(+), 18 deletions(-) create mode 100644 Nginx.Dockerfile diff --git a/Nginx.Dockerfile b/Nginx.Dockerfile new file mode 100644 index 000000000..7791d82c1 --- /dev/null +++ b/Nginx.Dockerfile @@ -0,0 +1,5 @@ +FROM anroe/nginx-geoip2:1.22.1-alpine-geoip2-3.4 + +# Replace the default conf.d folder with your local configuration +RUN rm -rf /etc/nginx/conf.d +COPY conf /etc/nginx diff --git a/conf/conf.d/client.conf b/conf/conf.d/client.conf index 5206cd255..e9364ffa9 100644 --- a/conf/conf.d/client.conf +++ b/conf/conf.d/client.conf @@ -177,6 +177,9 @@ server { rewrite ^/docs/configure_nats.md /docs/configure_natsmq.md permanent; rewrite ^/docs/configure_quota_limits.md /docs/configure_quotaandlimits.md permanent; + # 2024 Nov 29 + rewrite ^/docs/use_ColPALI_with_milvus.md /docs/use_ColPali_with_milvus.md permanent; + # redirect old replicated links rewrite ^/docs/text_search_engine.md /docs/build-rag-with-milvus.md permanent; rewrite ^/docs/question_answering_system.md /docs/build-rag-with-milvus.md permanent; diff --git a/scripts/pre-commit.js b/scripts/pre-commit.js index 086c29336..77cca84c2 100644 --- a/scripts/pre-commit.js +++ b/scripts/pre-commit.js @@ -1,25 +1,28 @@ const { execSync } = require('child_process'); +const path = require('path'); -const execOptions = { - encoding: 'utf8', -}; +const execOptions = { encoding: 'utf8' }; -const fileString = execSync('git diff --cached --name-only', execOptions); +// Paths +const confDir = path.resolve(__dirname, '../conf'); +const dockerfilePath = path.resolve(__dirname, '../Nginx.Dockerfile'); +const imageName = 'nginx-geoip2-test'; +const containerName = 'nginx-test-container'; -const nginxConfChanged = fileString - .trim() - .split('\n') - .some(item => item.includes('client.conf')); +try { + // Build Docker image using Nginx.Dockerfile + console.info('Building Docker image...'); + execSync(`docker build -f ${dockerfilePath} -t ${imageName} .`, execOptions); -if (nginxConfChanged) { - try { - execSync('nginx -v', execOptions); - } catch (error) { - console.info('Installing nginx...'); - execSync('brew install nginx', execOptions); - } + // Run container to test Nginx configuration + console.info('Running container to test Nginx configuration...'); + execSync( + `docker run --rm --name ${containerName} -v ${confDir}:/etc/nginx/conf.d ${imageName} nginx -t`, + execOptions + ); - execSync('nginx -t -c $(pwd)/scripts/test.conf', execOptions); -} else { - console.info('Skipping nginx test as client.conf is not changed.'); + console.info('Nginx configuration test passed!'); +} catch (error) { + console.error('Nginx configuration test failed:', error.stderr || error.message); + process.exit(1); }