mirror of
				https://github.com/samply/bridgehead.git
				synced 2025-10-31 11:10:17 +01:00 
			
		
		
		
	feat: unify version handeling (#265)
This commit is contained in:
		
							
								
								
									
										49
									
								
								bridgehead
									
									
									
									
									
								
							
							
						
						
									
										49
									
								
								bridgehead
									
									
									
									
									
								
							| @@ -53,17 +53,44 @@ case "$PROJECT" in | ||||
| 		;; | ||||
| esac | ||||
|  | ||||
| # Loads config variables and runs the projects setup script | ||||
| loadVars() { | ||||
| 	# Load variables from /etc/bridgehead and /srv/docker/bridgehead | ||||
| 	set -a | ||||
| 	# Source the project specific config file | ||||
| 	source /etc/bridgehead/$PROJECT.conf || fail_and_report 1 "/etc/bridgehead/$PROJECT.conf not found" | ||||
| 	# Source the project specific local config file if present | ||||
| 	# This file is ignored by git as oposed to the regular config file as it contains private site information like etl auth data | ||||
| 	if [ -e /etc/bridgehead/$PROJECT.local.conf ]; then | ||||
| 		log INFO "Applying /etc/bridgehead/$PROJECT.local.conf" | ||||
| 		source /etc/bridgehead/$PROJECT.local.conf || fail_and_report 1 "Found /etc/bridgehead/$PROJECT.local.conf but failed to import" | ||||
| 	fi | ||||
| 	# Set execution environment on main default to prod else test | ||||
| 	if [[ -z "${ENVIRONMENT+x}" ]]; then | ||||
| 		if [ "$(git rev-parse --abbrev-ref HEAD)" == "main" ]; then | ||||
| 			ENVIRONMENT="production" | ||||
| 		else | ||||
| 			ENVIRONMENT="test" | ||||
| 		fi | ||||
| 	fi | ||||
| 	# Source the versions of the images components  | ||||
| 	case "$ENVIRONMENT" in | ||||
| 		"production") | ||||
| 			source ./versions/prod | ||||
| 			;; | ||||
| 		"test") | ||||
| 			source ./versions/test | ||||
| 			;; | ||||
| 		*) | ||||
| 			report_error 7 "Environment \"$ENVIRONMENT\" is unknown. Assuming production. FIX THIS!" | ||||
| 			source ./versions/prod | ||||
| 			;; | ||||
| 	esac | ||||
| 	fetchVarsFromVaultByFile /etc/bridgehead/$PROJECT.conf || fail_and_report 1 "Unable to fetchVarsFromVaultByFile" | ||||
| 	setHostname | ||||
| 	optimizeBlazeMemoryUsage | ||||
| 	# Run project specific setup if it exists | ||||
| 	# This will ususally modiy the `OVERRIDE` to include all the compose files that the project depends on | ||||
| 	# This is also where projects specify which modules to load | ||||
| 	[ -e ./$PROJECT/vars ] && source ./$PROJECT/vars | ||||
| 	set +a | ||||
|  | ||||
| @@ -79,26 +106,6 @@ loadVars() { | ||||
| 	fi | ||||
| 	detectCompose | ||||
| 	setupProxy | ||||
|  | ||||
| 	# Set some project-independent default values | ||||
| 	: ${ENVIRONMENT:=production} | ||||
| 	export ENVIRONMENT | ||||
|  | ||||
| 	case "$ENVIRONMENT" in | ||||
| 		"production") | ||||
| 			export FOCUS_TAG=main | ||||
| 			export BEAM_TAG=main | ||||
| 			;; | ||||
| 		"test") | ||||
| 			export FOCUS_TAG=develop | ||||
| 			export BEAM_TAG=develop | ||||
| 			;; | ||||
| 		*) | ||||
| 			report_error 7 "Environment \"$ENVIRONMENT\" is unknown. Assuming production. FIX THIS!" | ||||
| 			export FOCUS_TAG=main | ||||
| 			export BEAM_TAG=main | ||||
| 			;; | ||||
| 	esac | ||||
| } | ||||
|  | ||||
| case "$ACTION" in | ||||
|   | ||||
							
								
								
									
										2
									
								
								versions/prod
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										2
									
								
								versions/prod
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,2 @@ | ||||
| FOCUS_TAG=main | ||||
| BEAM_TAG=main | ||||
							
								
								
									
										2
									
								
								versions/test
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										2
									
								
								versions/test
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,2 @@ | ||||
| FOCUS_TAG=develop | ||||
| BEAM_TAG=develop | ||||
		Reference in New Issue
	
	Block a user