-
Notifications
You must be signed in to change notification settings - Fork 8
Request ephemeral Hypernode when necessary #45
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
24 commits
Select commit
Hold shift + click to select a range
5b7fb77
Request ephemeral Hypernode when necessary
tdgroot 58262d3
Add CI testsuite for ephemeral nodes
tdgroot c96089e
Allow 404 when querying the ephemeral hypernode logbook
tdgroot 4ee2f38
Cleanup ephemeral hypernodes after running
tdgroot 7f35ed5
Add support for openssh private keys
tdgroot b9c7ff5
Only cancel ephemeral hypernode on failure
tdgroot b913e28
Set working directory for ephemeral testsuite
tdgroot c3b64a5
Resolve waiting for ephemeral app only on relevant flows
tdgroot 026d800
Fix always exiting with code 0
tdgroot 9ed9ad4
Update hypernode/api-client
tdgroot b26a349
ci/ephemeral: remove obsolete env.php copy from source hypernode
tdgroot fa0bbbb
Merge branch 'master' of github.com:ByteInternet/hypernode-deploy int…
tdgroot 82ec23f
Add deployment reporting
tdgroot 1743ad7
Add Cleanup command for cancelling ephemeral Hypernodes
tdgroot 38abf49
ci/ephemeral: test for deployment report
tdgroot 5c4f7c7
Remove usage version DI variable for report version
tdgroot f6bd602
Add missing name and description for Cleanup command
tdgroot 7d82205
ci/ephemeral: fix deployment report tests
tdgroot 6ebb15b
ci/ephemeral: verbose and output deployment-report.json
tdgroot 0883799
ci/ephemeral: fix deployment report tests
tdgroot 2aac900
composer: set hypernode/deploy-configuration to v3.x-dev
tdgroot b1c4a05
DeployRunner: fix imports after configurable interface refactorings
tdgroot 3f7e33b
TaskBuilder: fix imports after configurable interface refactorings
tdgroot 4d61c10
Merge branch 'master' of github.com:ByteInternet/hypernode-deploy int…
tdgroot File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 |
|---|---|---|
|
|
@@ -37,6 +37,7 @@ RUN apt-get update && \ | |
| git \ | ||
| patch \ | ||
| bash \ | ||
| jq \ | ||
| ca-certificates \ | ||
| wget \ | ||
| curl \ | ||
|
|
||
This file contains hidden or 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 @@ | ||
| ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQDqf5tGbhjIbRQJ40bTvw69z0kUHQEeDtGkX5DTzXJ1IPHcFpbq+nxc3f++45V8FA3fq31xTjCR3+TWy/AGCVmuntVwJVCEaC/U3X0YDscmzAA4LEOfmMHIGnrJdeTJS4+N6L5uIlZqyBIeJXyEEgFpcHm4i1HGm13DR/XG7lTaXSkRI9IVb0i3S0VdrRjtqkg4M3ZjgNfAwmoDE3dGNwIBH5EVy8t/YNj/RH0TNdhTDL3AGwne6h2bTWb5SNLHNXvu2Wc5aiJlvn2E2W7mcpnPxEkVs1AeDEaPHcLaGE2+Bt/I4ntyjOy9pFDcf28sPKj76S3Sq0Wwdb8rYmT+lerIPfjwj1VPXTU1dhvDJ1ffTufp3Sn67qi7NfBMYayYxLJWh9q84RHgYhog2SNXM+autsTU40GDZUtDtORRZ+Rg5i1cGxUCRT+Fpcx3aFCM/yTLvU80qZkmfgkQwKnGCCFygDsXPuFbyRXRz9MI1+lYGg17ufW5HSHrAw34Rw2yd8k= hypernode-deploy-ci | ||
This file contains hidden or 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,17 @@ | ||
| <?php | ||
|
|
||
| namespace Hypernode\DeployConfiguration; | ||
|
|
||
| /** | ||
| * Start by setting up the configuration | ||
| * | ||
| * The magento 2 configuration contains some default configuration for shared folders / files and running installers | ||
| * @see ApplicationTemplate\Magento2::initializeDefaultConfiguration | ||
| */ | ||
|
|
||
| $configuration = new ApplicationTemplate\Magento2(['en_US', 'nl_NL']); | ||
|
|
||
| $productionStage = $configuration->addStage('test', 'banaan.store'); | ||
| $productionStage->addEphemeralServer('hndeployintegr8'); | ||
|
|
||
| return $configuration; |
This file contains hidden or 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,47 @@ | ||
| #!/usr/bin/env bash | ||
|
|
||
| set -e | ||
| set -x | ||
|
|
||
| # Handy aliases | ||
| HN="ssh app@hndeployintegr8.hypernode.io -o StrictHostKeyChecking=no" | ||
| DP="docker run --rm -v /tmp/m2build:/web -e HYPERNODE_API_TOKEN -e SSH_PRIVATE_KEY -w /web hndeploy" | ||
|
|
||
| # Build Docker image | ||
| docker build \ | ||
| -f ci/build/Dockerfile \ | ||
| --build-arg NODE_VERSION=16 \ | ||
| --build-arg PHP_VERSION="${PHP_VERSION:-8.1}" \ | ||
| -t hndeploy \ | ||
| . | ||
|
|
||
| # Copy application from remote to local | ||
| $HN /data/web/magento2/bin/magento app:config:dump scopes themes | ||
| mkdir /tmp/m2build | ||
| mkdir -p "$HOME/.ssh" | ||
| cp ci/test/magento/deploy_ephemeral.php /tmp/m2build/deploy.php | ||
| rsync -a -e "ssh -o StrictHostKeyChecking=no" app@hndeployintegr8.hypernode.io:magento2/ /tmp/m2build | ||
| rm /tmp/m2build/app/etc/env.php | ||
|
|
||
| # Build application | ||
| $DP hypernode-deploy build -f /web/deploy.php -vvv | ||
|
|
||
| ########################################## | ||
| # DEPLOY WITHOUT PLATFORM CONFIGURATIONS # | ||
| # This should pass, but not generate any # | ||
| # Nginx/Supervisor/etc configs # | ||
| ########################################## | ||
| # SSH from deploy container to hypernode container | ||
| $DP hypernode-deploy deploy test -f /web/deploy.php -vvv | ||
|
|
||
| # Run some tests | ||
|
|
||
| $DP ls -l | ||
| $DP test -f deployment-report.json | ||
| $DP jq . deployment-report.json | ||
| $DP jq .version deployment-report.json -r | ||
| $DP jq .stage deployment-report.json -r | ||
| $DP jq .hostnames[0] deployment-report.json -r | ||
| $DP jq .ephemeral_hypernodes[0] deployment-report.json -r | ||
|
|
||
| $DP hypernode-deploy cleanup -vvv |
This file contains hidden or 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,163 @@ | ||
| #!/usr/bin/env bash | ||
|
|
||
| set -e | ||
| set -x | ||
|
|
||
| export PHP_VERSION_SHORT=$(echo "${PHP_VERSION:-8.1}" | sed 's/\.//') | ||
|
|
||
| # Handy aliases | ||
| HN="docker-compose exec -T hypernode" | ||
| DP="docker-compose exec -T deploy" | ||
| DP1="docker-compose exec --workdir=/web1 -T deploy" | ||
| DP2="docker-compose exec --workdir=/web2 -T deploy" | ||
|
|
||
| function install_magento() { | ||
| $HN mysql -e "DROP DATABASE IF EXISTS dummytag_preinstalled_magento" | ||
| $HN mysql -e "CREATE DATABASE dummytag_preinstalled_magento" | ||
| local pw=$($HN bash -c "grep password /data/web/.my.cnf | cut -d' ' -f3") | ||
|
|
||
| # Strip carriage return of pw and saves it in a new variable | ||
| pw=$(echo $pw | tr -d '\r') | ||
|
|
||
| $HN bash -c "/data/web/magento2/bin/magento setup:install \ | ||
| --base-url=http://banaan1.store \ | ||
| --db-host=mysqlmaster.dummytag.hypernode.io \ | ||
| --db-name=dummytag_preinstalled_magento --db-user=app \ | ||
| --db-password=$pw \ | ||
| --admin-firstname=admin --admin-lastname=admin \ | ||
| --admin-email=admin@admin.com --admin-user=admin \ | ||
| --admin-password=admin123 --language=en_US --currency=USD \ | ||
| --timezone=America/Chicago --elasticsearch-host=localhost" | ||
| } | ||
|
|
||
| # Install docker-compose if it's not installed | ||
| if ! [ -x "$(command -v docker-compose)" ]; then | ||
| pip install docker-compose | ||
| fi | ||
|
|
||
| # Clear up env | ||
| trap "docker-compose down -v" EXIT | ||
|
|
||
| docker-compose up -d | ||
|
|
||
| # Create working initial Magento install on the Hypernode container | ||
| $HN composer create-project --repository=https://mage-os.hypernode.com/mirror/ magento/project-community-edition /data/web/magento2 | ||
| echo "Waiting for MySQL to be available on the Hypernode container" | ||
| $HN bash -c "until mysql -e 'select 1' ; do sleep 1; done" | ||
| install_magento | ||
|
|
||
| # Copy env to the deploy container | ||
| $HN /data/web/magento2/bin/magento app:config:dump scopes themes | ||
| echo "Waiting for SSH to be available on the Hypernode container" | ||
| chmod 0600 ci/test/.ssh/id_rsa | ||
| chmod 0600 ci/test/.ssh/authorized_keys | ||
| $DP rsync -a app@hypernode:/data/web/magento2/ /web | ||
| $DP rsync -v -a /config/ /web | ||
| $DP rm /web/app/etc/env.php | ||
|
|
||
| # Create second app | ||
| $DP cp -ra /web /web1 | ||
| $DP cp -ra /web /web2 | ||
|
|
||
| # Build both apps | ||
| $DP1 hypernode-deploy build -v -f /web1/deploy1.php | ||
| $DP2 hypernode-deploy build -v -f /web2/deploy2.php | ||
|
|
||
| # Prepare env | ||
| $HN mkdir -p /data/web/apps/banaan1.store/shared/app/etc/ | ||
| $HN cp /data/web/magento2/app/etc/env.php /data/web/apps/banaan1.store/shared/app/etc/env.php | ||
| $HN mkdir -p /data/web/apps/banaan2.store/shared/app/etc/ | ||
| $HN cp /data/web/magento2/app/etc/env.php /data/web/apps/banaan2.store/shared/app/etc/env.php | ||
| $HN chown -R app:app /data/web/apps | ||
|
|
||
| ########################################## | ||
| # DEPLOY WITHOUT PLATFORM CONFIGURATIONS # | ||
| # This should pass, but not generate any # | ||
| # Nginx/Supervisor/etc configs # | ||
| ########################################## | ||
| # SSH from deploy container to hypernode container | ||
| $DP1 hypernode-deploy deploy production -f /web1/deploy1_without_platformconfig.php -v | ||
|
|
||
| # Check if deployment made only one release for store1 | ||
| test $($HN ls /data/web/apps/banaan1.store/releases/ | wc -l) = 1 | ||
|
|
||
| # Platform configs shouldn't be present yet | ||
| $HN test ! -d /data/web/nginx/banaan1.store | ||
| $HN test ! -d /data/web/supervisor/banaan1.store | ||
| $HN crontab -l -u app | grep "### BEGIN banaan1.store ###" && exit 1 | ||
| $HN test ! -d /data/web/varnish/banaan1.store | ||
|
|
||
| ################## | ||
| # DEPLOY STORE 2 # | ||
| ################## | ||
| # Store 2 | ||
| $DP2 hypernode-deploy deploy production -f /web2/deploy2.php -v | ||
|
|
||
| # Check if deployment made only one release for store2 | ||
| test $($HN ls /data/web/apps/banaan2.store/releases/ | wc -l) = 1 | ||
| $HN ls -al /data/web/nginx/banaan2.store/ | ||
| $HN ls -al /data/web/apps/banaan2.store/current/ | ||
| $HN ls -al /data/web/apps/banaan2.store/current/.hypernode/nginx/ | ||
| $HN test -f /data/web/nginx/banaan2.store/server.example.conf || ($HN ls -al /data/web/nginx && $HN ls -al /data/web/nginx/banaan2.store && exit 1) | ||
| $HN test $($HN readlink -f /data/web/nginx/banaan2.store) = /data/web/apps/banaan2.store/releases/1/.hypernode/nginx | ||
|
|
||
| ################################## | ||
| # DEPLOY PLATFORM CONFIGURATIONS # | ||
| # Now we should get revisions of # | ||
| # all platform configs. # | ||
| ################################## | ||
| $DP1 hypernode-deploy deploy production -v -f /web1/deploy1.php | ||
|
|
||
| # Check if example location block was placed | ||
| $HN ls -al /data/web/nginx/banaan1.store/ | ||
| $HN ls -al /data/web/apps/banaan1.store/current/ | ||
| $HN ls -al /data/web/apps/banaan1.store/current/.hypernode/nginx/ | ||
| $HN test -f /data/web/nginx/banaan1.store/server.example.conf || ($HN ls -al /data/web/nginx && $HN ls -al /data/web/nginx/banaan1.store && exit 1) | ||
| $HN test $($HN readlink -f /data/web/nginx/banaan1.store) = /data/web/apps/banaan1.store/releases/2/.hypernode/nginx | ||
|
|
||
| $HN test -f /data/web/supervisor/banaan1.store/example.conf || ($HN ls -al /data/web/supervisor/ && exit 1) | ||
| $HN test $($HN readlink -f /data/web/supervisor/banaan1.store) = /data/web/apps/banaan1.store/releases/2/.hypernode/supervisor | ||
|
|
||
| # Test this once we enable supervisor in the hypernode docker image | ||
| # $HN supervisorctl status | grep example | grep -v FATAL || ($HN supervisorctl status && exit 1) | ||
|
|
||
| # Test if varnish dirs exists and vcl has been placed | ||
| $HN ls -al /data/web/varnish/banaan1.store/ | ||
| $HN ls -al /data/web/apps/banaan1.store/current/.hypernode/varnish/ | ||
|
|
||
| $HN test -f /data/web/varnish/banaan1.store/varnish.vcl || ($HN ls -al /data/web/varnish/ && exit 1) | ||
| $HN test $($HN readlink -f /data/web/varnish/banaan1.store/varnish.vcl) = /data/web/apps/banaan1.store/releases/2/.hypernode/varnish/varnish.vcl | ||
|
|
||
| # Check the content of the crontab block | ||
| $HN crontab -l -u app | grep "### BEGIN banaan1.store ###" | ||
| $HN crontab -l -u app | grep "### END banaan1.store ###" | ||
| $HN crontab -l -u app | sed -n -e '/### BEGIN banaan1.store ###/,/### END banaan1.store ###/ p' | grep "banaan" | ||
|
|
||
| ###################################### | ||
| # REMOVE A NGINX LOCATION # | ||
| # Create a new release but make sure # | ||
| # that the file is removed in the # | ||
| # new release. # | ||
| ###################################### | ||
| # Remove example location | ||
| $DP rm /web1/etc/nginx/server.example.conf | ||
|
|
||
| # Deploy again | ||
| $DP1 hypernode-deploy deploy production -f /web1/deploy1.php | ||
|
|
||
| # Check if another deployment was made | ||
| test $($HN ls /data/web/apps/banaan1.store/releases/ | wc -l) = 3 | ||
| $HN test $($HN readlink -f /data/web/nginx/banaan1.store) = /data/web/apps/banaan1.store/releases/3/.hypernode/nginx | ||
| $HN test $($HN readlink -f /data/web/supervisor/banaan1.store) = /data/web/apps/banaan1.store/releases/3/.hypernode/supervisor | ||
| $HN test $($HN readlink -f /data/web/varnish/banaan1.store/varnish.vcl) = /data/web/apps/banaan1.store/releases/3/.hypernode/varnish/varnish.vcl | ||
|
|
||
| # Verify example location block is removed | ||
| $HN test ! -f /data/web/nginx/banaan1.store/server.example.conf || ($HN ls -al /data/web/nginx/banaan1.store && exit 1) | ||
|
|
||
| # Check if the second application is still working as intended | ||
| test $($HN ls /data/web/apps/banaan2.store/releases/ | wc -l) = 1 | ||
| $HN ls -al /data/web/nginx/banaan2.store/ | ||
| $HN ls -al /data/web/apps/banaan2.store/current/ | ||
| $HN ls -al /data/web/apps/banaan2.store/current/.hypernode/nginx/ | ||
| $HN test -f /data/web/nginx/banaan2.store/server.example.conf || ($HN ls -al /data/web/nginx && $HN ls -al /data/web/nginx/banaan2.store && exit 1) | ||
| $HN test $($HN readlink -f /data/web/nginx/banaan2.store) = /data/web/apps/banaan2.store/releases/1/.hypernode/nginx |
This file contains hidden or 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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Where is this file used?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the pub key of the keypair used to login to
hndeployintegr8. I could leave it out