chore: added default mariadb size and pass env variables to php app #28
| @ -24,6 +24,7 @@ async fn main() { | |||||||
|         // This config can be extended as needed for more complicated configurations
 |         // This config can be extended as needed for more complicated configurations
 | ||||||
|         config: LAMPConfig { |         config: LAMPConfig { | ||||||
|             project_root: "./php".into(), |             project_root: "./php".into(), | ||||||
|  |             database_size: format!("2Gi").into(), | ||||||
|             ..Default::default() |             ..Default::default() | ||||||
|         }, |         }, | ||||||
|     }; |     }; | ||||||
|  | |||||||
| @ -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: Option<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: None, | ||||||
|  | |||||||
|         } |         } | ||||||
|     } |     } | ||||||
| } | } | ||||||
| @ -113,6 +116,10 @@ impl<T: Topology + K8sclient + HelmCommand> Interpret<T> for LAMPInterpret { | |||||||
|                     } |                     } | ||||||
|                 } |                 } | ||||||
|             }, |             }, | ||||||
|  |             { | ||||||
|  |                 "name": "MYSQL_HOST", | ||||||
|  |                 "value": secret_name | ||||||
|  |             }, | ||||||
|             ]), |             ]), | ||||||
|         }; |         }; | ||||||
| 
 | 
 | ||||||
| @ -152,6 +159,13 @@ impl LAMPInterpret { | |||||||
|         inventory: &Inventory, |         inventory: &Inventory, | ||||||
|         topology: &T, |         topology: &T, | ||||||
|     ) -> Result<Outcome, InterpretError> { |     ) -> Result<Outcome, InterpretError> { | ||||||
|  |         let mut values_overrides = HashMap::new(); | ||||||
|  |         if let Some(database_size) = self.score.config.database_size.clone() { | ||||||
|  |             values_overrides.insert( | ||||||
|  |                 NonBlankString::from_str("primary.persistence.size").unwrap(), | ||||||
|  |                 database_size, | ||||||
|  |             ); | ||||||
|  |         } | ||||||
|         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 +175,7 @@ impl LAMPInterpret { | |||||||
|             ) |             ) | ||||||
|             .unwrap(), |             .unwrap(), | ||||||
|             chart_version: None, |             chart_version: None, | ||||||
|             values_overrides: None, |             values_overrides: Some(values_overrides), | ||||||
|             create_namespace: true, |             create_namespace: true, | ||||||
|             install_only: true, |             install_only: true, | ||||||
|             values_yaml: None, |             values_yaml: None, | ||||||
| @ -169,7 +183,6 @@ impl LAMPInterpret { | |||||||
| 
 | 
 | ||||||
|         score.create_interpret().execute(inventory, topology).await |         score.create_interpret().execute(inventory, topology).await | ||||||
|     } |     } | ||||||
| 
 |  | ||||||
|     fn build_dockerfile(&self, score: &LAMPScore) -> Result<PathBuf, Box<dyn std::error::Error>> { |     fn build_dockerfile(&self, score: &LAMPScore) -> Result<PathBuf, Box<dyn std::error::Error>> { | ||||||
|         let mut dockerfile = Dockerfile::new(); |         let mut dockerfile = Dockerfile::new(); | ||||||
| 
 | 
 | ||||||
| @ -257,6 +270,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
	
Maintenant que je vois ca je pense que ca devrait etre un Option qui est None par default pour deleguer la tache de set le default a la helm chart. Comme ca nos utilisateurs n'auront pas de surprise et c'est un detail de moins a gerer par nous-meme.
Par exemple, si dans 10 ans le default est rendu a 100G parce que la structure de la BD a change ou je sais pas quoi, on n'aura pas besoin de s'en occuper nous-memes.