-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1706 from milvus-io/301
update 301
- Loading branch information
Showing
3 changed files
with
29 additions
and
18 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
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 |
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 |
---|---|---|
@@ -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); | ||
} |