-
Notifications
You must be signed in to change notification settings - Fork 558
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
e2e: local harbor and nexus #800
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
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 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,8 @@ | ||
REGISTRY_FQDN=localhost:8081 | ||
REGISTRY_USER=admin | ||
REGISTRY_PASSWORD=Harbor12345 | ||
REGISTRY_SLUG=localhost:8081/test-docker-action/test-docker-action | ||
|
||
HARBOR_HOST=localhost | ||
HARBOR_PORT=8081 | ||
HARBOR_PROJECT=test-docker-action |
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,79 @@ | ||
#!/usr/bin/env bash | ||
set -eu | ||
|
||
: "${HARBOR_VERSION:=v2.7.0}" | ||
: "${HARBOR_HOST:=localhost}" | ||
: "${HARBOR_PORT:=49154}" | ||
: "${REGISTRY_USER:=admin}" | ||
: "${REGISTRY_PASSWORD:=Harbor12345}" | ||
|
||
: "${HARBOR_PROJECT:=test-docker-action}" | ||
|
||
project_post_data() { | ||
cat <<EOF | ||
{ | ||
"project_name": "$HARBOR_PROJECT", | ||
"public": true | ||
} | ||
EOF | ||
} | ||
|
||
export TERM=xterm | ||
|
||
# download | ||
echo "::group::Downloading Harbor $HARBOR_VERSION" | ||
( | ||
cd /tmp | ||
set -x | ||
wget -q "https://github.com/goharbor/harbor/releases/download/${HARBOR_VERSION}/harbor-offline-installer-${HARBOR_VERSION}.tgz" -O harbor-online-installer.tgz | ||
tar xvf harbor-online-installer.tgz | ||
) | ||
echo "::endgroup::" | ||
|
||
# config | ||
echo "::group::Configuring Harbor" | ||
( | ||
cd /tmp/harbor | ||
set -x | ||
cp harbor.yml.tmpl harbor.yml | ||
harborConfig="$(harborHost="$HARBOR_HOST" harborPort="$HARBOR_PORT" harborPwd="$REGISTRY_PASSWORD" yq --no-colors '.hostname = env(harborHost) | .http.port = env(harborPort) | .harbor_admin_password = env(harborPwd) | del(.https)' harbor.yml)" | ||
tee harbor.yml <<<"$harborConfig" >/dev/null | ||
yq --no-colors harbor.yml | ||
) | ||
echo "::endgroup::" | ||
|
||
# install and start | ||
echo "::group::Installing Harbor" | ||
( | ||
cd /tmp/harbor | ||
set -x | ||
./install.sh | ||
sleep 10 | ||
netstat -aptn | ||
) | ||
echo "::endgroup::" | ||
|
||
# compose config | ||
echo "::group::Compose config" | ||
( | ||
cd /tmp/harbor | ||
set -x | ||
docker compose config | ||
) | ||
echo "::endgroup::" | ||
|
||
# create project | ||
echo "::group::Creating project" | ||
( | ||
set -x | ||
curl --fail -v -k --max-time 10 -u "$REGISTRY_USER:$REGISTRY_PASSWORD" -X POST -H "Content-Type: application/json" -d "$(project_post_data)" "http://$HARBOR_HOST:$HARBOR_PORT/api/v2.0/projects" | ||
) | ||
echo "::endgroup::" | ||
|
||
# list projects | ||
echo "::group::List projects" | ||
( | ||
set -x | ||
curl --fail -s -k --max-time 10 -u "$REGISTRY_USER:$REGISTRY_PASSWORD" -H "Content-Type: application/json" "http://$HARBOR_HOST:$HARBOR_PORT/api/v2.0/projects" | jq | ||
) | ||
echo "::endgroup::" |
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,8 @@ | ||
services: | ||
nexus: | ||
image: sonatype/nexus3:${NEXUS_VERSION:-latest} | ||
volumes: | ||
- "./data:/nexus-data" | ||
ports: | ||
- "8081:8081" | ||
- "8082:8082" |
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,9 @@ | ||
REGISTRY_FQDN=localhost:8082 | ||
REGISTRY_USER=admin | ||
REGISTRY_PASSWORD=Nexus12345 | ||
REGISTRY_SLUG=localhost:8082/test-docker-action | ||
|
||
NEXUS_HOST=localhost | ||
NEXUS_PORT=8081 | ||
NEXUS_REGISTRY_PORT=8082 | ||
NEXUS_REPO=test-docker-action |
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,93 @@ | ||
#!/usr/bin/env bash | ||
set -eu | ||
|
||
SCRIPT_DIR=$(cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd) | ||
|
||
: "${NEXUS_VERSION:=3.47.1}" | ||
: "${NEXUS_HOST:=localhost}" | ||
: "${NEXUS_PORT:=8081}" | ||
: "${NEXUS_REGISTRY_PORT:=8082}" | ||
: "${REGISTRY_USER:=admin}" | ||
: "${REGISTRY_PASSWORD:=Nexus12345}" | ||
|
||
: "${NEXUS_REPO:=test-docker-action}" | ||
|
||
createrepo_post_data() { | ||
cat <<EOF | ||
{ | ||
"name": "${NEXUS_REPO}", | ||
"online": true, | ||
"storage": { | ||
"blobStoreName": "default", | ||
"strictContentTypeValidation": true, | ||
"writePolicy": "ALLOW" | ||
}, | ||
"docker": { | ||
"v1Enabled": false, | ||
"forceBasicAuth": true, | ||
"httpPort": ${NEXUS_REGISTRY_PORT}, | ||
"httpsPort": null, | ||
"subdomain": null | ||
} | ||
} | ||
EOF | ||
} | ||
|
||
export NEXUS_VERSION | ||
|
||
mkdir -p /tmp/nexus/data | ||
chown 200:200 /tmp/nexus/data | ||
cp "${SCRIPT_DIR}/docker-compose.yml" /tmp/nexus/docker-compose.yml | ||
|
||
echo "::group::Pulling Nexus $NEXUS_VERSION" | ||
( | ||
cd /tmp/nexus | ||
set -x | ||
docker compose pull | ||
) | ||
echo "::endgroup::" | ||
|
||
echo "::group::Compose config" | ||
( | ||
cd /tmp/nexus | ||
set -x | ||
docker compose config | ||
) | ||
echo "::endgroup::" | ||
|
||
echo "::group::Running Nexus" | ||
( | ||
cd /tmp/nexus | ||
set -x | ||
docker compose up -d | ||
) | ||
echo "::endgroup::" | ||
|
||
echo "::group::Running Nexus" | ||
( | ||
cd /tmp/nexus | ||
set -x | ||
docker compose up -d | ||
) | ||
echo "::endgroup::" | ||
|
||
echo "::group::Waiting for Nexus to be ready" | ||
until $(curl --output /dev/null --silent --head --fail "http://$NEXUS_HOST:$NEXUS_PORT"); do | ||
printf '.' | ||
sleep 5 | ||
done | ||
echo "::endgroup::" | ||
|
||
echo "::group::Change user's password" | ||
( | ||
set -x | ||
curl --fail -v -k --max-time 10 -u "$REGISTRY_USER:$(cat /tmp/nexus/data/admin.password)" -X PUT -H 'Content-Type: text/plain' -d "$REGISTRY_PASSWORD" "http://$NEXUS_HOST:$NEXUS_PORT/service/rest/v1/security/users/$REGISTRY_USER/change-password" | ||
) | ||
echo "::endgroup::" | ||
|
||
echo "::group::Create Docker repository" | ||
( | ||
set -x | ||
curl --fail -v -k --max-time 10 -u "$REGISTRY_USER:$REGISTRY_PASSWORD" -X POST -H 'Content-Type: application/json' -d "$(createrepo_post_data)" "http://$NEXUS_HOST:$NEXUS_PORT/service/rest/v1/repositories/docker/hosted" | ||
) | ||
echo "::endgroup::" |
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
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.
Would be nice if we could use the same version format for all the versions specified if possible.
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.
Yeah that's because one is an image on registry, the other a GitHub Release 🙃