-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adding one more integration test interacting with a local registry
- Loading branch information
Showing
3 changed files
with
106 additions
and
36 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
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,14 +1,15 @@ | ||
{ | ||
"name": "demoapp", | ||
"version": "1.0.0", | ||
"description": "", | ||
"main": "index.js", | ||
"scripts": { | ||
"test": "echo \"Error: no test specified\" && exit 1" | ||
}, | ||
"author": "", | ||
"license": "ISC", | ||
"dependencies": { | ||
"express": "^4.18.2" | ||
} | ||
"name": "demoapp", | ||
"version": "1.0.0", | ||
"description": "", | ||
"main": "index.js", | ||
"scripts": { | ||
"test": "echo \"Error: no test specified\" && exit 1", | ||
"start": "node index.js" | ||
}, | ||
"author": "", | ||
"license": "ISC", | ||
"dependencies": { | ||
"express": "^4.18.2" | ||
} | ||
} |
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,68 @@ | ||
#!/bin/bash | ||
|
||
set -e | ||
|
||
TESTUSER=testuser | ||
TESTPASSWORD=testpassword | ||
BASICAUTH=$(echo -n "$TESTUSER:$TESTPASSWORD" | base64) | ||
|
||
rm -rf tmp | ||
mkdir -p tmp/certs | ||
mkdir -p tmp/auth | ||
|
||
printf "Generating key for local registry...\n" | ||
openssl req \ | ||
-newkey rsa:4096 -nodes -sha256 -keyout tmp/certs/domain.key \ | ||
-addext "subjectAltName = DNS:myregistry.domain.com" \ | ||
-subj "/C=NO/ST=Doqr/L=Doqr/O=Doqr Integration/OU=Test Department/CN=doqr.test" \ | ||
-x509 -days 365 -out tmp/certs/domain.crt | ||
|
||
|
||
printf "\nGenerating password for local registry...\n" | ||
docker run \ | ||
--entrypoint htpasswd \ | ||
httpd:2 -Bbn $TESTUSER $TESTPASSWORD > tmp/auth/htpasswd | ||
|
||
printf "\nStopping any running local doqr test registry...\n" | ||
docker stop registry-doqr-test || echo "No running container registry, so nothing to stop" | ||
|
||
printf "\nStarting local doqr test registry on port 5443...\n" | ||
docker run -d \ | ||
--rm \ | ||
--name registry-doqr-test \ | ||
-v "$(pwd)"/tmp/certs:/certs \ | ||
-v "$(pwd)"/tmp/auth:/auth \ | ||
-e REGISTRY_HTTP_ADDR=0.0.0.0:5443 \ | ||
-e REGISTRY_HTTP_TLS_CERTIFICATE=/certs/domain.crt \ | ||
-e REGISTRY_HTTP_TLS_KEY=/certs/domain.key \ | ||
-e "REGISTRY_AUTH=htpasswd" \ | ||
-e "REGISTRY_AUTH_HTPASSWD_REALM=Registry Realm" \ | ||
-e REGISTRY_AUTH_HTPASSWD_PATH=/auth/htpasswd \ | ||
-p 5443:5443 \ | ||
registry:2 | ||
|
||
printf "\nPulling node:alpine as base image...\n" | ||
docker pull node:alpine | ||
|
||
printf "\nPushing base image to local doqr test registry...\n" | ||
docker tag node:alpine localhost:5443/node | ||
docker push localhost:5443/node | ||
|
||
printf "\nRunning doqr to pull from and push result to the local doqr test registry...\n" | ||
../../lib/cli.js --fromImage node --registry https://localhost:5443/v2/ --toImage doqr-integration-test:localtest --folder ../integration/app --setTimeStamp "2023-03-07T12:53:10.471Z" --allowInsecureRegistries --token "Basic $BASICAUTH" | ||
|
||
|
||
printf "\nPulling image from registry to local docker daemon...\n" | ||
docker pull localhost:5443/doqr-integration-test:localtest | ||
|
||
printf "\nRunning image on local docker daemon...\n" | ||
docker run --rm -it localhost:5443/doqr-integration-test:localtest | ||
|
||
printf "\nDeleting image from registry to local docker daemon...\n" | ||
docker rmi localhost:5443/doqr-integration-test:localtest | ||
|
||
printf "\nStopping local doqr test registry...\n" | ||
docker stop registry-doqr-test | ||
|
||
|
||
printf "\nSUCCESS!\n" |