2020# --auto-approve Skip terraform apply confirmation
2121# --skip-build Skip container build+push (use existing images in OCIR)
2222# --push-info Print OCIR push instructions for external containers and exit
23+ # --push-env Output OCIR registry info as shell env vars (eval-able)
2324# --help Show this help message
2425#
2526# Examples:
@@ -60,6 +61,7 @@ DRY_RUN=false
6061AUTO_APPROVE=false
6162SKIP_BUILD=false
6263PUSH_INFO=false
64+ PUSH_ENV=false
6365
6466# Parse arguments
6567while [[ $# -gt 0 ]]; do
@@ -96,8 +98,12 @@ while [[ $# -gt 0 ]]; do
9698 PUSH_INFO=true
9799 shift
98100 ;;
101+ --push-env)
102+ PUSH_ENV=true
103+ shift
104+ ;;
99105 --help)
100- head -34 " $0 " | tail -32
106+ head -35 " $0 " | tail -33
101107 exit 0
102108 ;;
103109 * )
@@ -330,9 +336,38 @@ print_external_container_info() {
330336 log_info " OCIR login (if not already authenticated):"
331337 echo -e " docker login ${registry} -u ${namespace} /<your-oci-username>"
332338 echo -e " (Use an OCI Auth Token as password — create at OCI Console > User Settings > Auth Tokens)"
339+ echo " "
340+ log_info " Or use eval to set env vars for external build scripts:"
341+ echo -e " eval \$ (scripts/deploy-oci.sh --push-env)"
333342 fi
334343}
335344
345+ # ---------------------------------------------------------------------------
346+ # Output OCIR registry info as shell env vars (machine-readable)
347+ # Usage from external projects: eval $(path/to/deploy-oci.sh --push-env)
348+ # ---------------------------------------------------------------------------
349+ print_push_env () {
350+ local namespace
351+ namespace=$( oci os ns get --query data --raw-output --profile " $OCI_PROFILE " 2> /dev/null || echo " " )
352+ local registry=" ${OCI_REGION} .ocir.io"
353+ local name_prefix
354+ name_prefix=$( grep ' ^name_prefix' " $TF_DIR /terraform.tfvars" 2> /dev/null \
355+ | sed ' s/.*= *"//;s/".*//' || echo " tmi" )
356+
357+ # Common registry info
358+ echo " export OCIR_REGISTRY=${registry} "
359+ echo " export OCIR_NAMESPACE=${namespace} "
360+ echo " export OCIR_REGION=${OCI_REGION} "
361+ echo " export OCIR_BASE_URL=${registry} /${namespace} /${name_prefix} "
362+ echo " export OCIR_PLATFORM=linux/arm64"
363+
364+ # Per-component image URLs
365+ echo " export TMI_IMAGE_URL=${registry} /${namespace} /${name_prefix} /tmi:latest"
366+ echo " export TMI_REDIS_IMAGE_URL=${registry} /${namespace} /${name_prefix} /tmi-redis:latest"
367+ echo " export TMI_UX_IMAGE_URL=${registry} /${namespace} /${name_prefix} /tmi-ux:latest"
368+ echo " export TMI_TF_WH_IMAGE_URL=${registry} /${namespace} /${name_prefix} /tmi-tf-wh:latest"
369+ }
370+
336371# ---------------------------------------------------------------------------
337372# Delete orphaned OCI load balancers
338373# ---------------------------------------------------------------------------
@@ -564,8 +599,8 @@ do_deploy() {
564599# Main
565600# ---------------------------------------------------------------------------
566601
567- # Handle --push-info without full preflight
568- if $PUSH_INFO ; then
602+ # Handle --push-info and --push-env without full preflight
603+ if $PUSH_INFO || $PUSH_ENV ; then
569604 # Minimal setup: read profile/region from tfvars
570605 if [[ -z " $OCI_PROFILE " ]]; then
571606 OCI_PROFILE=$( grep ' ^oci_config_profile' " $TF_DIR /terraform.tfvars" 2> /dev/null \
@@ -575,7 +610,11 @@ if $PUSH_INFO; then
575610 OCI_REGION=$( grep ' ^region' " $TF_DIR /terraform.tfvars" 2> /dev/null \
576611 | sed ' s/.*= *"//;s/".*//' || echo " us-ashburn-1" )
577612 fi
578- print_external_container_info
613+ if $PUSH_ENV ; then
614+ print_push_env
615+ else
616+ print_external_container_info
617+ fi
579618 exit 0
580619fi
581620
0 commit comments