El nombre de la imagen sale de la carpeta del servicio y el Dockerfile depende de si es java o web.
Así se puede desplegar sin pom.xml y ubicar el Dockerfile en la raíz cuando el servicio es web.
This commit is contained in:
+36
-18
@@ -7,6 +7,7 @@
|
||||
#
|
||||
# The list path is required (--services). Relative service paths are resolved
|
||||
# against the directory that contains that file, not the caller's cwd.
|
||||
# An optional second field, java or web, selects the Dockerfile location.
|
||||
|
||||
set -euo pipefail
|
||||
IFS=$'\n\t'
|
||||
@@ -57,10 +58,11 @@ process id is appended.
|
||||
Required:
|
||||
--remote TARGET SSH destination forwarded to build-and-push.sh
|
||||
('user@host[:port]' or a ~/.ssh/config alias)
|
||||
--services FILE Service list for one project. One path per line.
|
||||
Blank lines and lines starting with '#' are
|
||||
ignored. Relative paths resolve against the
|
||||
directory that contains FILE.
|
||||
--services FILE Service list for one project. One path per line,
|
||||
with an optional second field: java or web
|
||||
(default java). Blank lines and lines starting
|
||||
with '#' are ignored. Relative paths resolve
|
||||
against the directory that contains FILE.
|
||||
|
||||
Forwarded to each service (build-and-push.sh):
|
||||
--ssh-key PATH Private key file
|
||||
@@ -69,9 +71,9 @@ Forwarded to each service (build-and-push.sh):
|
||||
--no-verify Skip the remote image check
|
||||
--cleanup Prune the remote without building or pushing
|
||||
|
||||
Not accepted (each service reads its own pom.xml; --project-dir is set
|
||||
from the list):
|
||||
--name, --tag, --project-dir
|
||||
Not accepted (each service has its own directory; --type comes from the
|
||||
list, and --project-dir is set from that path):
|
||||
--name, --tag, --project-dir, --type
|
||||
|
||||
Other:
|
||||
-h, --help Show this help
|
||||
@@ -116,8 +118,8 @@ while [[ $# -gt 0 ]]; do
|
||||
forward_args+=("$1")
|
||||
shift
|
||||
;;
|
||||
--name|--tag|--project-dir)
|
||||
die "$1 is not accepted. Each service uses its own directory and pom.xml."
|
||||
--name|--tag|--project-dir|--type)
|
||||
die "$1 is not accepted. Each service uses its own directory; --type comes from the services file."
|
||||
;;
|
||||
-h|--help)
|
||||
usage
|
||||
@@ -137,22 +139,36 @@ done
|
||||
SERVICES_FILE="$(readlink -f "$SERVICES_FILE")"
|
||||
SERVICES_DIR="$(cd "$(dirname "$SERVICES_FILE")" && pwd)"
|
||||
|
||||
services=()
|
||||
service_paths=()
|
||||
service_types=()
|
||||
while IFS= read -r raw_line || [[ -n "$raw_line" ]]; do
|
||||
line="$(trim "$raw_line")"
|
||||
[[ -z "$line" || "$line" == \#* ]] && continue
|
||||
line="${line/#\~/$HOME}"
|
||||
services+=("$line")
|
||||
svc_path=""
|
||||
svc_type=""
|
||||
svc_extra=""
|
||||
IFS=$' \t' read -r svc_path svc_type svc_extra <<< "$line"
|
||||
[[ -n "$svc_extra" ]] && die "Service line has an extra field: ${line}"
|
||||
[[ -n "$svc_path" ]] || die "Service line is missing a path: ${line}"
|
||||
svc_path="${svc_path/#\~/$HOME}"
|
||||
[[ -z "$svc_type" ]] && svc_type="java"
|
||||
case "$svc_type" in
|
||||
java|web) ;;
|
||||
*) die "Unknown service type '${svc_type}' in ${SERVICES_FILE} (use java or web)." ;;
|
||||
esac
|
||||
service_paths+=("$svc_path")
|
||||
service_types+=("$svc_type")
|
||||
done < "$SERVICES_FILE"
|
||||
|
||||
[[ ${#services[@]} -gt 0 ]] || die "Services file is empty: ${SERVICES_FILE}"
|
||||
[[ ${#service_paths[@]} -gt 0 ]] || die "Services file is empty: ${SERVICES_FILE}"
|
||||
|
||||
run_build() {
|
||||
local project_dir="$1"
|
||||
local app_type="$2"
|
||||
if [[ ${#forward_args[@]} -eq 0 ]]; then
|
||||
"$BUILD_SCRIPT" --project-dir "$project_dir" --remote "$REMOTE"
|
||||
"$BUILD_SCRIPT" --project-dir "$project_dir" --remote "$REMOTE" --type "$app_type"
|
||||
else
|
||||
"$BUILD_SCRIPT" --project-dir "$project_dir" --remote "$REMOTE" "${forward_args[@]}"
|
||||
"$BUILD_SCRIPT" --project-dir "$project_dir" --remote "$REMOTE" --type "$app_type" "${forward_args[@]}"
|
||||
fi
|
||||
}
|
||||
|
||||
@@ -239,7 +255,7 @@ write_summary_log() {
|
||||
log "Log file: ${log_path}"
|
||||
}
|
||||
|
||||
total="${#services[@]}"
|
||||
total="${#service_paths[@]}"
|
||||
index=0
|
||||
ok_count=0
|
||||
fail_count=0
|
||||
@@ -257,7 +273,9 @@ log "Services file: ${SERVICES_FILE}"
|
||||
log "Remote: ${REMOTE}"
|
||||
log "Services: ${total}"
|
||||
|
||||
for entry in "${services[@]}"; do
|
||||
while [[ "$index" -lt "$total" ]]; do
|
||||
entry="${service_paths[$index]}"
|
||||
app_type="${service_types[$index]}"
|
||||
index=$((index + 1))
|
||||
resolved="$(normalize_path "$(resolve_service "$entry")")"
|
||||
|
||||
@@ -277,7 +295,7 @@ for entry in "${services[@]}"; do
|
||||
fi
|
||||
|
||||
exit_code=0
|
||||
if run_build "$resolved"; then
|
||||
if run_build "$resolved" "$app_type"; then
|
||||
ok "Finished ${resolved}"
|
||||
result_paths+=("$resolved")
|
||||
result_notes+=("0")
|
||||
|
||||
Reference in New Issue
Block a user