chore: added default mariadb size and pass env variables to php app
This commit is contained in:
		
							parent
							
								
									90b80b24bc
								
							
						
					
					
						commit
						1c3669cb47
					
				| @ -3,6 +3,7 @@ use dockerfile_builder::instruction::{CMD, COPY, ENV, EXPOSE, FROM, RUN, WORKDIR | |||||||
| use dockerfile_builder::{Dockerfile, instruction_builder::EnvBuilder}; | use dockerfile_builder::{Dockerfile, instruction_builder::EnvBuilder}; | ||||||
| use non_blank_string_rs::NonBlankString; | use non_blank_string_rs::NonBlankString; | ||||||
| use serde_json::json; | use serde_json::json; | ||||||
|  | use std::collections::HashMap; | ||||||
| use std::fs; | use std::fs; | ||||||
| use std::path::{Path, PathBuf}; | use std::path::{Path, PathBuf}; | ||||||
| use std::str::FromStr; | use std::str::FromStr; | ||||||
| @ -36,6 +37,7 @@ pub struct LAMPScore { | |||||||
| pub struct LAMPConfig { | pub struct LAMPConfig { | ||||||
|     pub project_root: PathBuf, |     pub project_root: PathBuf, | ||||||
|     pub ssl_enabled: bool, |     pub ssl_enabled: bool, | ||||||
|  |     pub database_size: String, | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| impl Default for LAMPConfig { | impl Default for LAMPConfig { | ||||||
| @ -43,6 +45,7 @@ impl Default for LAMPConfig { | |||||||
|         LAMPConfig { |         LAMPConfig { | ||||||
|             project_root: Path::new("./src").to_path_buf(), |             project_root: Path::new("./src").to_path_buf(), | ||||||
|             ssl_enabled: true, |             ssl_enabled: true, | ||||||
|  |             database_size: "2Gi".to_string(), | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
| } | } | ||||||
| @ -113,6 +116,10 @@ impl<T: Topology + K8sclient + HelmCommand> Interpret<T> for LAMPInterpret { | |||||||
|                     } |                     } | ||||||
|                 } |                 } | ||||||
|             }, |             }, | ||||||
|  |             { | ||||||
|  |                 "name": "MYSQL_HOST", | ||||||
|  |                 "value": secret_name | ||||||
|  |             }, | ||||||
|             ]), |             ]), | ||||||
|         }; |         }; | ||||||
| 
 | 
 | ||||||
| @ -152,6 +159,11 @@ impl LAMPInterpret { | |||||||
|         inventory: &Inventory, |         inventory: &Inventory, | ||||||
|         topology: &T, |         topology: &T, | ||||||
|     ) -> Result<Outcome, InterpretError> { |     ) -> Result<Outcome, InterpretError> { | ||||||
|  |         let mut mariadb_overrides = HashMap::new(); | ||||||
|  |         mariadb_overrides.insert( | ||||||
|  |             NonBlankString::from_str("primary.persistence.size").unwrap(), | ||||||
|  |             self.score.config.database_size.clone(), | ||||||
|  |         ); | ||||||
|         let score = HelmChartScore { |         let score = HelmChartScore { | ||||||
|             namespace: self.get_namespace(), |             namespace: self.get_namespace(), | ||||||
|             release_name: NonBlankString::from_str(&format!("{}-database", self.score.name)) |             release_name: NonBlankString::from_str(&format!("{}-database", self.score.name)) | ||||||
| @ -161,7 +173,7 @@ impl LAMPInterpret { | |||||||
|             ) |             ) | ||||||
|             .unwrap(), |             .unwrap(), | ||||||
|             chart_version: None, |             chart_version: None, | ||||||
|             values_overrides: None, |             values_overrides: Some(mariadb_overrides), | ||||||
|             create_namespace: true, |             create_namespace: true, | ||||||
|             install_only: true, |             install_only: true, | ||||||
|             values_yaml: None, |             values_yaml: None, | ||||||
| @ -257,6 +269,13 @@ opcache.fast_shutdown=1 | |||||||
|              sed -i 's/ServerSignature On/ServerSignature Off/' /etc/apache2/conf-enabled/security.conf" |              sed -i 's/ServerSignature On/ServerSignature Off/' /etc/apache2/conf-enabled/security.conf" | ||||||
|         )); |         )); | ||||||
| 
 | 
 | ||||||
|  |         // Set env vars
 | ||||||
|  |         dockerfile.push(RUN::from( | ||||||
|  |             "echo 'PassEnv MYSQL_PASSWORD' >> /etc/apache2/sites-available/000-default.conf \ | ||||||
|  |              && echo 'PassEnv MYSQL_USER' >> /etc/apache2/sites-available/000-default.conf \ | ||||||
|  |              && echo 'PassEnv MYSQL_HOST' >> /etc/apache2/sites-available/000-default.conf",
 | ||||||
|  |         )); | ||||||
|  | 
 | ||||||
|         // Create a dedicated user for running Apache
 |         // Create a dedicated user for running Apache
 | ||||||
|         dockerfile.push(RUN::from( |         dockerfile.push(RUN::from( | ||||||
|             "groupadd -g 1000 appuser && \ |             "groupadd -g 1000 appuser && \ | ||||||
|  | |||||||
		Loading…
	
		Reference in New Issue
	
	Block a user