Skip to content

Commit

Permalink
Merge pull request #1706 from milvus-io/301
Browse files Browse the repository at this point in the history
update 301
  • Loading branch information
shanghaikid authored Nov 29, 2024
2 parents 38a9001 + 9f78786 commit 08c8648
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 18 deletions.
5 changes: 5 additions & 0 deletions Nginx.Dockerfile
Original file line number Diff line number Diff line change
@@ -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
3 changes: 3 additions & 0 deletions conf/conf.d/client.conf
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
39 changes: 21 additions & 18 deletions scripts/pre-commit.js
Original file line number Diff line number Diff line change
@@ -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);
}

0 comments on commit 08c8648

Please sign in to comment.