e2e: local nexus
Signed-off-by: CrazyMax <crazy-max@users.noreply.github.com>
This commit is contained in:
		
							parent
							
								
									2d8166c4b9
								
							
						
					
					
						commit
						af7537dc3e
					
				
							
								
								
									
										8
									
								
								.github/e2e/nexus/docker-compose.yml
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										8
									
								
								.github/e2e/nexus/docker-compose.yml
									
									
									
									
										vendored
									
									
										Normal file
									
								
							@ -0,0 +1,8 @@
 | 
			
		||||
services:
 | 
			
		||||
  nexus:
 | 
			
		||||
    image: sonatype/nexus3:${NEXUS_VERSION:-latest}
 | 
			
		||||
    volumes:
 | 
			
		||||
      - "./data:/nexus-data"
 | 
			
		||||
    ports:
 | 
			
		||||
      - "8081:8081"
 | 
			
		||||
      - "8082:8082"
 | 
			
		||||
							
								
								
									
										9
									
								
								.github/e2e/nexus/env
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										9
									
								
								.github/e2e/nexus/env
									
									
									
									
										vendored
									
									
										Normal file
									
								
							@ -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
 | 
			
		||||
							
								
								
									
										93
									
								
								.github/e2e/nexus/install.sh
									
									
									
									
										vendored
									
									
										Executable file
									
								
							
							
						
						
									
										93
									
								
								.github/e2e/nexus/install.sh
									
									
									
									
										vendored
									
									
										Executable file
									
								
							@ -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::"
 | 
			
		||||
							
								
								
									
										5
									
								
								.github/workflows/e2e.yml
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										5
									
								
								.github/workflows/e2e.yml
									
									
									
									
										vendored
									
									
								
							@ -26,6 +26,7 @@ env:
 | 
			
		||||
  BUILDX_VERSION: latest
 | 
			
		||||
  BUILDKIT_IMAGE: moby/buildkit:buildx-stable-1
 | 
			
		||||
  HARBOR_VERSION: v2.7.0
 | 
			
		||||
  NEXUS_VERSION: 3.47.1
 | 
			
		||||
 | 
			
		||||
jobs:
 | 
			
		||||
  build:
 | 
			
		||||
@ -101,6 +102,10 @@ jobs:
 | 
			
		||||
            name: Harbor
 | 
			
		||||
            id: harbor
 | 
			
		||||
            type: local
 | 
			
		||||
          -
 | 
			
		||||
            name: Nexus
 | 
			
		||||
            id: nexus
 | 
			
		||||
            type: local
 | 
			
		||||
    steps:
 | 
			
		||||
      -
 | 
			
		||||
        name: Checkout
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user