summaryrefslogtreecommitdiffstats
path: root/build
diff options
context:
space:
mode:
authorBartek Grzybowski <b.grzybowski@partner.samsung.com>2020-10-22 12:46:17 +0200
committerBartek Grzybowski <b.grzybowski@partner.samsung.com>2020-10-26 10:27:50 +0000
commit65b9384075832ba18642fb51fed1349f2f654234 (patch)
tree9081ab8c754f714287b696774e81e406926218b2 /build
parent4b86e113ae7e2d7f2d42afd76edab9126030fb23 (diff)
Drop registry hosts simulation
Instead of simulating all images original registry hostnames locally running Nexus instance IP address is used to simplify the whole procedre. Change-Id: I42de7e2bc177a9b784090aece0b4ebe7d57912e7 Issue-ID: OOM-2605 Signed-off-by: Bartek Grzybowski <b.grzybowski@partner.samsung.com>
Diffstat (limited to 'build')
-rwxr-xr-xbuild/build_nexus_blob.sh34
1 files changed, 7 insertions, 27 deletions
diff --git a/build/build_nexus_blob.sh b/build/build_nexus_blob.sh
index ae3f8870..47190d0b 100755
--- a/build/build_nexus_blob.sh
+++ b/build/build_nexus_blob.sh
@@ -37,6 +37,7 @@ exec &> >(tee -a "${SCRIPT_LOG}")
# Nexus repository properties
NEXUS_DOMAIN="nexus"
+NEXUS_HOST="127.0.0.1"
NEXUS_PORT="8081"
NEXUS_DOCKER_PORT="8082"
DEFAULT_REGISTRY="docker.io"
@@ -99,15 +100,6 @@ usage () {
exit 1
}
-simulated_hosts () {
- SIMUL_HOSTS=($(sed -n '/\.[^/].*\//p' ${1} | sed -e 's/\/.*$// ; s/:.*$//' | sort -u | grep -v ${DEFAULT_REGISTRY} || true ) ${NEXUS_DOMAIN})
- for HOST in "${SIMUL_HOSTS[@]}"; do
- if ! grep -wq ${HOST} /etc/hosts; then
- echo "127.0.0.1 ${HOST}" >> /etc/hosts
- fi
- done
-}
-
load_docker_images () {
for ARCHIVE in $(sed $'s/\r// ; /^#/d ; s/\:/\_/g ; s/\//\_/g ; s/$/\.tar/g' ${1} | awk '{ print $1 }'); do
docker load -i ${NXS_SRC_DOCKER_IMG_DIR}/${ARCHIVE}
@@ -253,9 +245,9 @@ if [ ${#FAILED_COMMANDS[*]} -gt 0 ]; then
fi
# Nexus repository locations
-NPM_REGISTRY="http://${NEXUS_DOMAIN}:${NEXUS_PORT}/repository/npm-private/"
-PYPI_REGISTRY="http://${NEXUS_DOMAIN}:${NEXUS_PORT}/repository/pypi-private/"
-DOCKER_REGISTRY="${NEXUS_DOMAIN}:${NEXUS_DOCKER_PORT}"
+NPM_REGISTRY="http://${NEXUS_HOST}:${NEXUS_PORT}/repository/npm-private/"
+PYPI_REGISTRY="http://${NEXUS_HOST}:${NEXUS_PORT}/repository/pypi-private/"
+DOCKER_REGISTRY="${NEXUS_HOST}:${NEXUS_DOCKER_PORT}"
# Setup directories with resources for docker, npm and pypi
NXS_SRC_DOCKER_IMG_DIR="${DATA_DIR}/offline_data/docker_images_for_nexus"
@@ -277,10 +269,6 @@ if [ ${#NXS_DOCKER_IMG_LISTS[@]} -eq 0 ]; then
NXS_DOCKER_IMG_LISTS=("${NXS_DOCKER_IMG_LIST}" "${NXS_RKE_DOCKER_IMG_LIST}" "${NXS_K8S_DOCKER_IMG_LIST}")
fi
-# Backup /etc/hosts
-HOSTS_BACKUP="$(eval ${TIMESTAMP}_hosts.bk)"
-cp /etc/hosts /etc/${HOSTS_BACKUP}
-
# Backup the current docker registry settings
if [ -f ~/.docker/config.json ]; then
DOCKER_CONF_BACKUP="$(eval ${TIMESTAMP}_config.json.bk)"
@@ -290,11 +278,6 @@ fi
# Setup default ports published to host as docker registry
PUBLISHED_PORTS="-p ${NEXUS_PORT}:${NEXUS_PORT} -p ${NEXUS_DOCKER_PORT}:${NEXUS_DOCKER_PORT}"
-# Setup simulated domain names to be able to push all to private Nexus repository
-for DOCKER_IMG_LIST in "${NXS_DOCKER_IMG_LISTS[@]}"; do
- simulated_hosts "${DOCKER_IMG_LIST}"
-done
-
# Nexus repository configuration setup
NEXUS_CONFIG_GROOVY='import org.sonatype.nexus.security.realm.RealmManager
import org.sonatype.nexus.repository.attributes.AttributesFacet
@@ -378,15 +361,15 @@ INFO
# Start the Nexus
NEXUS_CONT_ID=$(docker run -d --rm -v ${NEXUS_DATA_DIR}:/nexus-data:rw --name ${NEXUS_DOMAIN} ${PUBLISHED_PORTS} ${NEXUS_IMAGE})
echo "Waiting for Nexus to fully start"
-until curl -su ${NEXUS_USERNAME}:${NEXUS_PASSWORD} http://${NEXUS_DOMAIN}:${NEXUS_PORT}/service/metrics/healthcheck | grep '"healthy":true' > /dev/null ; do
+until curl -su ${NEXUS_USERNAME}:${NEXUS_PASSWORD} http://${NEXUS_HOST}:${NEXUS_PORT}/service/metrics/healthcheck | grep '"healthy":true' > /dev/null ; do
printf "."
sleep 3
done
echo -e "\nNexus started"
# Configure the nexus repository
-curl -sX POST --header 'Content-Type: application/json' --data-binary "${NEXUS_CONFIG}" http://${NEXUS_USERNAME}:${NEXUS_PASSWORD}@${NEXUS_DOMAIN}:${NEXUS_PORT}/service/rest/v1/script
-curl -sX POST --header "Content-Type: text/plain" http://${NEXUS_USERNAME}:${NEXUS_PASSWORD}@${NEXUS_DOMAIN}:${NEXUS_PORT}/service/rest/v1/script/configure/run > /dev/null
+curl -sX POST --header 'Content-Type: application/json' --data-binary "${NEXUS_CONFIG}" http://${NEXUS_USERNAME}:${NEXUS_PASSWORD}@${NEXUS_HOST}:${NEXUS_PORT}/service/rest/v1/script
+curl -sX POST --header "Content-Type: text/plain" http://${NEXUS_USERNAME}:${NEXUS_PASSWORD}@${NEXUS_HOST}:${NEXUS_PORT}/service/rest/v1/script/configure/run > /dev/null
###########################
# Populate NPM repository #
@@ -437,9 +420,6 @@ echo "Stopping Nexus and returning backups"
# Stop the Nexus
docker stop ${NEXUS_CONT_ID} > /dev/null
-# Return backed up configuration files
-mv -f "/etc/${HOSTS_BACKUP}" /etc/hosts
-
if [ -f ~/.docker/${DOCKER_CONF_BACKUP} ]; then
mv -f ~/.docker/${DOCKER_CONF_BACKUP} ~/.docker/config.json
fi