Skip to content
Merged
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
19 changes: 0 additions & 19 deletions src/build/containers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,13 @@ use tempdir::TempDir;
use tokio_stream::StreamExt;

use anyhow::Context;
use bedrock::Config;
use colored::Colorize;
use tokio::{io::AsyncWriteExt, process::Command};
use tokio_process_stream::ProcessLineStream;
use tokio_tar::Archive;

use crate::cli::ContainerBackend;

const APP_VERSION: &str = env!("CARGO_PKG_VERSION");

lazy_static! {
static ref ANSI_REGEX: Regex = Regex::new(r"\x1b\[[0-9;]*[A-Za-z]").unwrap();
}
Expand Down Expand Up @@ -100,22 +97,6 @@ pub async fn build_container_image(
}
}

/// Based on the config, determine which tag to use
pub fn get_server_tag(cfg: &Config) -> String {
let needs_scripting = !cfg.integrations.event_handlers.is_empty();
let needs_webhooks = !cfg.integrations.webhooks.is_empty();
let variant = if needs_scripting && needs_webhooks {
"full"
} else if needs_scripting {
"scripting"
} else if needs_webhooks {
"webhooks"
} else {
"minimal"
};
format!("{APP_VERSION}-{variant}")
}

pub async fn ensure_podman_accessible() -> anyhow::Result<()> {
Command::new("podman")
.output()
Expand Down
8 changes: 4 additions & 4 deletions src/build/mod.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use containers::{build_container_image, get_server_tag};
use containers::build_container_image;
use std::path::{Path, PathBuf};
use tar_helpers::{append_event_handlers, make_base_init, make_base_install, make_header};

Expand All @@ -16,7 +16,7 @@ const INSTALL_SRC: &str = include_str!("../../data/install.sh");
const ENTRY_SRC: &str = include_str!("../../data/entrypoint.sh");
const DOCKER_IGNORE: &str = "./Dockerfile\n./.dockerignore";

const APP_VERSION: &str = env!("CARGO_PKG_VERSION");
const DEFAULT_TAG: &str = "main";

lazy_static! {
static ref tmpl: tera::Tera = {
Expand Down Expand Up @@ -55,11 +55,11 @@ pub async fn build_with_output(
let mut ctx = tera::Context::new();
ctx.insert(
"server_tag",
&std::env::var("BASALT_SERVER_TAG").unwrap_or_else(|_| get_server_tag(&cfg)),
&std::env::var("BASALT_SERVER_TAG").unwrap_or(DEFAULT_TAG.to_owned()),
);
ctx.insert(
"web_tag",
&std::env::var("BASALT_WEB_TAG").unwrap_or(APP_VERSION.to_owned()),
&std::env::var("BASALT_WEB_TAG").unwrap_or(DEFAULT_TAG.to_owned()),
);
ctx.insert("base_install", &make_base_install(&cfg));
ctx.insert("base_init", &make_base_init(&cfg));
Expand Down
2 changes: 1 addition & 1 deletion tests/one.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ port = 8517

# install = { import = "./install.sh" }
install = '''
dnf install opam
dnf install -y opam
'''

# init = { import = "./init.sh" }
Expand Down