Enable cors in laconicd http services (#875)
	
		
			
	
		
	
	
		
	
		
			Some checks failed
		
		
	
	
		
			
				
	
				Lint Checks / Run linter (push) Successful in 37s
				
			
		
			
				
	
				Publish / Build and publish (push) Successful in 1m17s
				
			
		
			
				
	
				Deploy Test / Run deploy test suite (push) Successful in 4m58s
				
			
		
			
				
	
				Webapp Test / Run webapp test suite (push) Successful in 4m33s
				
			
		
			
				
	
				Smoke Test / Run basic test suite (push) Successful in 4m2s
				
			
		
			
				
	
				Database Test / Run database hosting test on kind/k8s (push) Successful in 9m6s
				
			
		
			
				
	
				Container Registry Test / Run contaier registry hosting test on kind/k8s (push) Successful in 3m53s
				
			
		
			
				
	
				External Stack Test / Run external stack test suite (push) Successful in 4m42s
				
			
		
			
				
	
				Fixturenet-Laconicd-Test / Run Laconicd fixturenet and Laconic CLI tests (push) Successful in 13m19s
				
			
		
			
				
	
				K8s Deploy Test / Run deploy test suite on kind/k8s (push) Successful in 8m16s
				
			
		
			
				
	
				Fixturenet-Eth-Plugeth-Arm-Test / Run an Ethereum plugeth fixturenet test (push) Failing after 3h13m59s
				
			
		
			
				
	
				Fixturenet-Eth-Plugeth-Test / Run an Ethereum plugeth fixturenet test (push) Failing after 3h14m0s
				
			
		
		
	
	
				
					
				
			
		
			Some checks failed
		
		
	
	Lint Checks / Run linter (push) Successful in 37s
				
			Publish / Build and publish (push) Successful in 1m17s
				
			Deploy Test / Run deploy test suite (push) Successful in 4m58s
				
			Webapp Test / Run webapp test suite (push) Successful in 4m33s
				
			Smoke Test / Run basic test suite (push) Successful in 4m2s
				
			Database Test / Run database hosting test on kind/k8s (push) Successful in 9m6s
				
			Container Registry Test / Run contaier registry hosting test on kind/k8s (push) Successful in 3m53s
				
			External Stack Test / Run external stack test suite (push) Successful in 4m42s
				
			Fixturenet-Laconicd-Test / Run Laconicd fixturenet and Laconic CLI tests (push) Successful in 13m19s
				
			K8s Deploy Test / Run deploy test suite on kind/k8s (push) Successful in 8m16s
				
			Fixturenet-Eth-Plugeth-Arm-Test / Run an Ethereum plugeth fixturenet test (push) Failing after 3h13m59s
				
			Fixturenet-Eth-Plugeth-Test / Run an Ethereum plugeth fixturenet test (push) Failing after 3h14m0s
				
			Reviewed-on: #875 Co-authored-by: David Boreham <david@bozemanpass.com> Co-committed-by: David Boreham <david@bozemanpass.com>
This commit is contained in:
		
							parent
							
								
									17c21464ab
								
							
						
					
					
						commit
						83397bbae4
					
				| @ -9,4 +9,5 @@ SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd ) | |||||||
| ${SCRIPT_DIR}/update-explorer-config.sh | ${SCRIPT_DIR}/update-explorer-config.sh | ||||||
| 
 | 
 | ||||||
| echo "Starting serving explorer" | echo "Starting serving explorer" | ||||||
| yarn serve --host | # Force cache re-build because vite is dumb and can't be restarted otherwise | ||||||
|  | yarn serve --host --force | ||||||
|  | |||||||
| @ -115,13 +115,38 @@ def _insert_persistent_peers(config_dir: Path, new_persistent_peers: str): | |||||||
|         sys.exit(1) |         sys.exit(1) | ||||||
|     with open(config_file_path, "r") as input_file: |     with open(config_file_path, "r") as input_file: | ||||||
|         config_file_content = input_file.read() |         config_file_content = input_file.read() | ||||||
|         persistent_peers_pattern = '^persistent_peers = ""' |         persistent_peers_pattern = r'^persistent_peers = ""' | ||||||
|         replace_with = f"persistent_peers = \"{new_persistent_peers}\"" |         replace_with = f"persistent_peers = \"{new_persistent_peers}\"" | ||||||
|         config_file_content = re.sub(persistent_peers_pattern, replace_with, config_file_content, flags=re.MULTILINE) |         config_file_content = re.sub(persistent_peers_pattern, replace_with, config_file_content, flags=re.MULTILINE) | ||||||
|     with open(config_file_path, "w") as output_file: |     with open(config_file_path, "w") as output_file: | ||||||
|         output_file.write(config_file_content) |         output_file.write(config_file_content) | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
|  | def _enable_cors(config_dir: Path): | ||||||
|  |     config_file_path = config_dir.joinpath("config.toml") | ||||||
|  |     if not config_file_path.exists(): | ||||||
|  |         print("Error: config.toml not found") | ||||||
|  |         sys.exit(1) | ||||||
|  |     with open(config_file_path, "r") as input_file: | ||||||
|  |         config_file_content = input_file.read() | ||||||
|  |         cors_pattern = r'^cors_allowed_origins = \[]' | ||||||
|  |         replace_with = 'cors_allowed_origins = ["*"]' | ||||||
|  |         config_file_content = re.sub(cors_pattern, replace_with, config_file_content, flags=re.MULTILINE) | ||||||
|  |     with open(config_file_path, "w") as output_file: | ||||||
|  |         output_file.write(config_file_content) | ||||||
|  |     app_file_path = config_dir.joinpath("app.toml") | ||||||
|  |     if not app_file_path.exists(): | ||||||
|  |         print("Error: app.toml not found") | ||||||
|  |         sys.exit(1) | ||||||
|  |     with open(app_file_path, "r") as input_file: | ||||||
|  |         app_file_content = input_file.read() | ||||||
|  |         cors_pattern = r'^enabled-unsafe-cors = false' | ||||||
|  |         replace_with = "enabled-unsafe-cors = true" | ||||||
|  |         app_file_content = re.sub(cors_pattern, replace_with, app_file_content, flags=re.MULTILINE) | ||||||
|  |     with open(app_file_path, "w") as output_file: | ||||||
|  |         output_file.write(app_file_content) | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
| def _phase_from_params(parameters): | def _phase_from_params(parameters): | ||||||
|     phase = SetupPhase.ILLEGAL |     phase = SetupPhase.ILLEGAL | ||||||
|     if parameters.initialize_network: |     if parameters.initialize_network: | ||||||
| @ -292,6 +317,8 @@ def create(deployment_context: DeploymentContext, extra_args): | |||||||
|     if extra_args[1]: |     if extra_args[1]: | ||||||
|         initial_persistent_peers = extra_args[1] |         initial_persistent_peers = extra_args[1] | ||||||
|         _insert_persistent_peers(deployment_config_dir, initial_persistent_peers) |         _insert_persistent_peers(deployment_config_dir, initial_persistent_peers) | ||||||
|  |     # Enable CORS headers so explorers and so on can talk to the node | ||||||
|  |     _enable_cors(deployment_config_dir) | ||||||
|     # Copy the data directory contents into our deployment |     # Copy the data directory contents into our deployment | ||||||
|     # TODO: change this to work with non local paths |     # TODO: change this to work with non local paths | ||||||
|     deployment_data_dir = deployment_context.deployment_dir.joinpath("data", "laconicd-data") |     deployment_data_dir = deployment_context.deployment_dir.joinpath("data", "laconicd-data") | ||||||
|  | |||||||
| @ -18,6 +18,20 @@ do | |||||||
|         rm -rf ${node_network_dir} |         rm -rf ${node_network_dir} | ||||||
|     fi |     fi | ||||||
| done | done | ||||||
|  | echo "Deleting any existing deployments..." | ||||||
|  | for (( i=1 ; i<=$node_count ; i++ )); | ||||||
|  | do | ||||||
|  |     node_deployment_dir=${node_dir_prefix}${i}-deployment | ||||||
|  |     node_spec_file=${node_dir_prefix}${i}-spec.yml | ||||||
|  |     if [[ -d $node_deployment_dir ]]; then | ||||||
|  |         echo "Deleting ${node_deployment_dir}" | ||||||
|  |         rm -rf ${node_deployment_dir} | ||||||
|  |     fi | ||||||
|  |     if [[ -f $node_spec_file ]]; then | ||||||
|  |         echo "Deleting ${node_spec_file}" | ||||||
|  |         rm ${node_spec_file} | ||||||
|  |     fi | ||||||
|  | done | ||||||
| 
 | 
 | ||||||
| echo "Initalizing ${node_count} nodes networks..." | echo "Initalizing ${node_count} nodes networks..." | ||||||
| for (( i=1 ; i<=$node_count ; i++ ));  | for (( i=1 ; i<=$node_count ; i++ ));  | ||||||
| @ -56,3 +70,12 @@ do | |||||||
|     node_network_dir=${node_dir_prefix}${i} |     node_network_dir=${node_dir_prefix}${i} | ||||||
|     laconic-so --stack mainnet-laconic deploy setup --network-dir ${node_network_dir} --create-network --genesis-file ${genesis_file} |     laconic-so --stack mainnet-laconic deploy setup --network-dir ${node_network_dir} --create-network --genesis-file ${genesis_file} | ||||||
| done | done | ||||||
|  | 
 | ||||||
|  | # Create deployments | ||||||
|  | echo "Creating ${node_count} deployments..." | ||||||
|  | for (( i=1 ; i<=$node_count ; i++ )); | ||||||
|  | do | ||||||
|  |     node_network_dir=${node_dir_prefix}${i} | ||||||
|  |     laconic-so --stack mainnet-laconic deploy init --output ${node_network_dir}-spec.yml | ||||||
|  |     laconic-so --stack mainnet-laconic deploy create --deployment-dir ${node_network_dir}-deployment --spec-file ${node_dir_prefix}${i}-spec.yml --network-dir ${node_network_dir} | ||||||
|  | done | ||||||
|  | |||||||
		Loading…
	
		Reference in New Issue
	
	Block a user