Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Selinux support #123

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/macos.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
- name: Toolchain
uses: actions-rs/toolchain@v1
with:
toolchain: stable
toolchain: 1.49.0
target: x86_64-apple-darwin
override: true

Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
toolchain: 1.49.0
override: true

- name: Run cargo check
Expand All @@ -37,7 +37,7 @@ jobs:
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
toolchain: 1.49.0
override: true

- name: Run cargo test
Expand All @@ -56,7 +56,7 @@ jobs:
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
toolchain: 1.49.0
override: true
components: rustfmt, clippy

Expand Down
7 changes: 7 additions & 0 deletions wf2_core/src/dc_service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,9 @@ pub struct DcService {

#[serde(skip_serializing_if = "Option::is_none")]
pub networks: Option<HashMap<String, DcServiceNetwork>>,

#[serde(skip_serializing_if = "Option::is_none")]
pub privileged: Option<bool>,
}

impl DcService {
Expand Down Expand Up @@ -155,6 +158,10 @@ impl DcService {
}
self
}
pub fn set_privileged(&mut self, privileged: bool) -> &mut Self {
self.privileged = Some(privileged);
self
}
pub fn finish(&self) -> DcService {
DcService { ..self.clone() }
}
Expand Down
12 changes: 6 additions & 6 deletions wf2_core/src/recipes/m2/services/db.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,14 +60,14 @@ impl Service<M2Vars> for DbService {
let opts = DbServiceOptions::from_ctx(&ctx);
DcService::new(ctx.name(), Self::NAME, opts.image)
.set_volumes(vec![
format!("{}:{}", M2Volumes::DB, DbService::VOLUME_DATA),
format!("{}:{}:z", M2Volumes::DB, DbService::VOLUME_DATA),
format!(
"{}:{}",
"{}:{}:z",
vars.content[&M2Var::DbConfDir],
DbService::VOLUME_CONF
),
format!(
"{}:{}",
"{}:{}:z",
vars.content[&M2Var::DbInitDir],
DbService::VOLUME_ENTRY
),
Expand Down Expand Up @@ -111,9 +111,9 @@ mod tests {
container_name: wf2__project__db
image: "mysql:8.0"
volumes:
- "db-data:/var/lib/mysql"
- "/users/shane/project/.wf2_m2_project/mysql/mysqlconf:/etc/mysql/conf.d"
- "/users/shane/project/.wf2_m2_project/mysql/init-scripts:/docker-entrypoint-initdb.d"
- "db-data:/var/lib/mysql:z"
- "/users/shane/project/.wf2_m2_project/mysql/mysqlconf:/etc/mysql/conf.d:z"
- "/users/shane/project/.wf2_m2_project/mysql/init-scripts:/docker-entrypoint-initdb.d:z"
env_file:
- "/users/shane/project/.wf2_m2_project/.docker.env"
restart: unless-stopped
Expand Down
16 changes: 8 additions & 8 deletions wf2_core/src/recipes/m2/services/nginx.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,16 @@ impl Service<M2Vars> for M2NginxService {
.dc_service(&ctx, &())
.set_working_dir(M2_ROOT)
.set_volumes(vec![
format!("{}:{}", M2Volumes::APP, M2_ROOT),
format!("{}:/etc/nginx/conf.d", vars.content[&M2Var::NginxDir]),
format!("{}:{}:z", M2Volumes::APP, M2_ROOT),
format!("{}:/etc/nginx/conf.d:z", vars.content[&M2Var::NginxDir]),
])
.set_depends_on(vec![PhpService::NAME])
.set_env_file(vec![vars.content[&M2Var::EnvFile].to_string()])
.finish();

if M2RecipeOptions::has_pwa_options(&ctx) {
service.add_depends_on(vec![PwaService::NAME]);
service.add_volumes(vec![format!("{}:{}{}", M2Volumes::PWA, M2_ROOT, "/pwa")]);
service.add_volumes(vec![format!("{}:{}{}:z", M2Volumes::PWA, M2_ROOT, "/pwa")]);
}

service
Expand All @@ -53,8 +53,8 @@ mod tests {
container_name: wf2__wf2_default__nginx
image: "wearejh/nginx:stable-m2"
volumes:
- "app-src:/var/www"
- "./.wf2_default/nginx/sites:/etc/nginx/conf.d"
- "app-src:/var/www:z"
- "./.wf2_default/nginx/sites:/etc/nginx/conf.d:z"
env_file:
- "./.wf2_default/.docker.env"
depends_on:
Expand All @@ -80,9 +80,9 @@ mod tests {
container_name: wf2__wf2_default__nginx
image: "wearejh/nginx:stable-m2"
volumes:
- "app-src:/var/www"
- "./.wf2_m2_wf2_default/nginx/sites:/etc/nginx/conf.d"
- "pwa-src:/var/www/pwa"
- "app-src:/var/www:z"
- "./.wf2_m2_wf2_default/nginx/sites:/etc/nginx/conf.d:z"
- "pwa-src:/var/www/pwa:z"
env_file:
- "./.wf2_m2_wf2_default/.docker.env"
depends_on:
Expand Down
2 changes: 1 addition & 1 deletion wf2_core/src/recipes/m2/services/node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ impl Service<M2Vars> for M2NodeService {
.dc_service(ctx, &())
.set_working_dir(M2_ROOT)
.set_init(true)
.set_volumes(vec![format!("{}:{}", M2Volumes::APP, M2_ROOT)])
.set_volumes(vec![format!("{}:{}:z", M2Volumes::APP, M2_ROOT)])
.set_env_file(vec![vars.content[&M2Var::EnvFile].to_string()])
.finish()
}
Expand Down
4 changes: 2 additions & 2 deletions wf2_core/src/recipes/m2/services/php.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,9 @@ impl Service<M2Vars> for PhpService {
let image = &vars.content[&M2Var::PhpImage].clone();
DcService::new(ctx.name(), Self::NAME, image)
.set_volumes(vec![
format!("{}:{}", M2Volumes::APP, M2_ROOT),
format!("{}:{}:z", M2Volumes::APP, M2_ROOT),
format!(
"{}:{}",
"{}:{}:z",
M2Volumes::COMPOSER_CACHE,
PhpService::COMPOSER_CACHE_PATH,
),
Expand Down
6 changes: 3 additions & 3 deletions wf2_core/src/recipes/m2/services/unison.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,13 @@ impl Service<M2Vars> for UnisonService {
DcService::new(ctx.name(), Self::NAME, Self::IMAGE)
.set_volumes(vec![
format!(
"{}:{}",
"{}:{}:z",
vars.content[&M2Var::Pwd],
UnisonService::VOLUME_HOST
),
format!("{}:{}", M2Volumes::APP, UnisonService::VOLUME_INTERNAL),
format!("{}:{}:z", M2Volumes::APP, UnisonService::VOLUME_INTERNAL),
format!(
"{}:{}",
"{}:{}:z",
vars.content[&M2Var::UnisonFile],
UnisonService::CONFIG_FILE
),
Expand Down
4 changes: 2 additions & 2 deletions wf2_core/src/services/pwa.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ impl Service<PwaServiceOptions> for PwaService {
.set_init(true)
.set_ports(vec![PwaService::PORT.to_string()])
.set_volumes(vec![format!(
"{}:{}",
"{}:{}:z",
M2Volumes::PWA,
opts.src_dir_in_volume
.clone()
Expand Down Expand Up @@ -110,7 +110,7 @@ mod tests {
args:
BUILD_COMMAND: "npm run build:debug"
volumes:
- "pwa-src:/home/node/app/packages/server/pwa"
- "pwa-src:/home/node/app/packages/server/pwa:z"
labels:
- traefik.enable=false
ports:
Expand Down
3 changes: 2 additions & 1 deletion wf2_core/src/services/traefik.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ impl Service for TraefikService {
"default",
DcServiceNetwork::with_aliases(ctx.domains.clone()),
)
.set_privileged(true)
.finish()
}
}
Expand Down Expand Up @@ -91,7 +92,7 @@ mod test {
default:
aliases:
- local.m2

privileged: true
"#;
let expected_dc: DcService = serde_yaml::from_str(expected).expect("deserialize");
assert_eq!(actual, expected_dc);
Expand Down