forked from NationTech/harmony
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 non_blank_string_rs::NonBlankString;
|
||||
use serde_json::json;
|
||||
use std::collections::HashMap;
|
||||
use std::fs;
|
||||
use std::path::{Path, PathBuf};
|
||||
use std::str::FromStr;
|
||||
@ -17,8 +18,8 @@ use crate::{
|
||||
data::{Id, Version},
|
||||
interpret::{Interpret, InterpretError, InterpretName, InterpretStatus, Outcome},
|
||||
inventory::Inventory,
|
||||
modules::k8s::deployment::K8sDeploymentScore,
|
||||
score::Score,
|
||||
modules::k8s::deployment::K8sDeploymentScore,
|
||||
score::Score,
|
||||
topology::{K8sclient, Topology, Url},
|
||||
};
|
||||
|
||||
@ -36,6 +37,7 @@ pub struct LAMPScore {
|
||||
pub struct LAMPConfig {
|
||||
pub project_root: PathBuf,
|
||||
pub ssl_enabled: bool,
|
||||
pub database_size: String,
|
||||
}
|
||||
|
||||
impl Default for LAMPConfig {
|
||||
@ -43,6 +45,7 @@ impl Default for LAMPConfig {
|
||||
LAMPConfig {
|
||||
project_root: Path::new("./src").to_path_buf(),
|
||||
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,
|
||||
topology: &T,
|
||||
) -> 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 {
|
||||
namespace: self.get_namespace(),
|
||||
release_name: NonBlankString::from_str(&format!("{}-database", self.score.name))
|
||||
@ -161,7 +173,7 @@ impl LAMPInterpret {
|
||||
)
|
||||
.unwrap(),
|
||||
chart_version: None,
|
||||
values_overrides: None,
|
||||
values_overrides: Some(mariadb_overrides),
|
||||
create_namespace: true,
|
||||
install_only: true,
|
||||
values_yaml: None,
|
||||
@ -257,6 +269,13 @@ opcache.fast_shutdown=1
|
||||
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
|
||||
dockerfile.push(RUN::from(
|
||||
"groupadd -g 1000 appuser && \
|
||||
|
||||
Loading…
Reference in New Issue
Block a user