diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index 9a22b10c..4aff29d8 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -47,7 +47,7 @@ jobs: - name: Build policies working-directory: ./policies - run: make build + run: make - name: Collect the artifacts run: | @@ -90,7 +90,13 @@ jobs: run: pip3 install ziglang==0.9.1 cargo-zigbuild==0.16.12 - name: Build the binary - run: cargo zigbuild --release --target=${{ matrix.arch }}-unknown-linux-musl -p mas-cli + run: > + cargo zigbuild + --release + --target=${{ matrix.arch }}-unknown-linux-musl + --no-default-features + --features dist + -p mas-cli - name: Download the artifacts uses: actions/download-artifact@v3.1.2 diff --git a/crates/cli/Cargo.toml b/crates/cli/Cargo.toml index 65bf5d63..81b26909 100644 --- a/crates/cli/Cargo.toml +++ b/crates/cli/Cargo.toml @@ -70,6 +70,9 @@ indoc = "2.0.3" [features] default = ["jaeger", "zipkin", "webpki-roots", "policy-cache"] +# Features used for the prebuilt binaries +dist = ["otlp", "jaeger", "zipkin", "prometheus", "policy-cache", "native-roots", "mas-config/dist"] + # Features used in the Docker image docker = ["otlp", "jaeger", "zipkin", "prometheus", "native-roots", "mas-config/docker"] diff --git a/crates/config/Cargo.toml b/crates/config/Cargo.toml index 673a1df6..ff77d663 100644 --- a/crates/config/Cargo.toml +++ b/crates/config/Cargo.toml @@ -37,6 +37,7 @@ mas-iana = { path = "../iana" } [features] docker = [] +dist = [] [[bin]] name = "schema" diff --git a/crates/config/src/lib.rs b/crates/config/src/lib.rs index 6f560f4e..ff88cbbe 100644 --- a/crates/config/src/lib.rs +++ b/crates/config/src/lib.rs @@ -24,6 +24,9 @@ //! Application configuration logic +#[cfg(all(feature = "docker", feature = "dist"))] +compile_error!("Only one of the `docker` and `dist` features can be enabled at once"); + pub(crate) mod schema; mod sections; pub(crate) mod util; diff --git a/crates/config/src/sections/http.rs b/crates/config/src/sections/http.rs index e4c283e1..ea3c66b6 100644 --- a/crates/config/src/sections/http.rs +++ b/crates/config/src/sections/http.rs @@ -45,7 +45,7 @@ fn http_address_example_4() -> &'static str { "0.0.0.0:8080" } -#[cfg(not(feature = "docker"))] +#[cfg(not(any(feature = "docker", feature = "dist")))] fn http_listener_assets_path_default() -> Utf8PathBuf { "./frontend/dist/".into() } @@ -55,6 +55,11 @@ fn http_listener_assets_path_default() -> Utf8PathBuf { "/usr/local/share/mas-cli/assets/".into() } +#[cfg(feature = "dist")] +fn http_listener_assets_path_default() -> Utf8PathBuf { + "./share/assets/".into() +} + /// Kind of socket #[derive(Debug, Serialize, Deserialize, JsonSchema, Clone, Copy)] #[serde(rename_all = "lowercase")] diff --git a/crates/config/src/sections/policy.rs b/crates/config/src/sections/policy.rs index 3ac10254..9317cfb9 100644 --- a/crates/config/src/sections/policy.rs +++ b/crates/config/src/sections/policy.rs @@ -21,7 +21,7 @@ use serde_with::serde_as; use super::ConfigurationSection; -#[cfg(not(feature = "docker"))] +#[cfg(not(any(feature = "docker", feature = "dist")))] fn default_policy_path() -> Utf8PathBuf { "./policies/policy.wasm".into() } @@ -31,6 +31,11 @@ fn default_policy_path() -> Utf8PathBuf { "/usr/local/share/mas-cli/policy.wasm".into() } +#[cfg(feature = "dist")] +fn default_policy_path() -> Utf8PathBuf { + "./share/policy.wasm".into() +} + fn default_client_registration_endpoint() -> String { "client_registration/violation".to_owned() } diff --git a/crates/config/src/sections/templates.rs b/crates/config/src/sections/templates.rs index 09ab50eb..b2b44ef0 100644 --- a/crates/config/src/sections/templates.rs +++ b/crates/config/src/sections/templates.rs @@ -20,7 +20,7 @@ use serde::{Deserialize, Serialize}; use super::ConfigurationSection; -#[cfg(not(feature = "docker"))] +#[cfg(not(any(feature = "docker", feature = "dist")))] fn default_path() -> Utf8PathBuf { "./templates/".into() } @@ -30,7 +30,12 @@ fn default_path() -> Utf8PathBuf { "/usr/local/share/mas-cli/templates/".into() } -#[cfg(not(feature = "docker"))] +#[cfg(feature = "dist")] +fn default_path() -> Utf8PathBuf { + "./share/templates/".into() +} + +#[cfg(not(any(feature = "docker", feature = "dist")))] fn default_assets_path() -> Utf8PathBuf { "./frontend/dist/manifest.json".into() } @@ -40,6 +45,11 @@ fn default_assets_path() -> Utf8PathBuf { "/usr/local/share/mas-cli/manifest.json".into() } +#[cfg(feature = "dist")] +fn default_assets_path() -> Utf8PathBuf { + "./share/manifest.json".into() +} + /// Configuration related to templates #[derive(Debug, Serialize, Deserialize, JsonSchema, Clone)] pub struct TemplatesConfig {