Created
August 11, 2022 10:38
-
-
Save andreysaksonov/c98c188de95c148a9b2a31a13b4d0fc6 to your computer and use it in GitHub Desktop.
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
#!/bin/bash | |
set -e | |
usage() { echo "Usage: $0 -f {file} -u {nexus_user} -p {nexus_pass} {services}" 1>&2; exit 1; } | |
FILE='docker-compose.yml' | |
NEXUS_URL='https://nexus.examples.com/' | |
NEXUS_USER=$(cat ~/.m2/settings.xml | grep -m1 -oP '(?<=<username>).*(?=</username>)') | |
NEXUS_PASS=$(cat ~/.m2/settings.xml | grep -m1 -oP '(?<=<password>).*(?=</password>)') | |
while getopts ":f:u:ph" opt; do | |
case $opt in | |
f) | |
FILE="$OPTARG" | |
;; | |
u) | |
NEXUS_USER="$OPTARG" | |
;; | |
p) | |
NEXUS_PASS="$OPTARG" | |
;; | |
h) | |
usage | |
;; | |
\?) | |
echo "Invalid option -$OPTARG" >&2 | |
usage | |
;; | |
esac | |
done | |
shift $(($OPTIND - 1)) | |
SERVICES=$@ | |
echo $NEXUS_PASS | docker login $NEXUS_URL -u $NEXUS_USER --password-stdin | |
docker compose -f $FILE up $SERVICES |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment