diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..9fe342c --- /dev/null +++ b/.dockerignore @@ -0,0 +1 @@ +./target diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..4ef5f15 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,12 @@ +# no point in tagging the rust version, currently using nightly +FROM rust:slim-buster + +RUN apt update && apt -y install libssl-dev libpq-dev pkg-config make +RUN rustup default nightly + +WORKDIR /atuin +COPY . /atuin + +RUN cargo build --release + +ENTRYPOINT ["/atuin/target/release/atuin"] diff --git a/src/settings.rs b/src/settings.rs index dcf69a7..5d19699 100644 --- a/src/settings.rs +++ b/src/settings.rs @@ -4,7 +4,7 @@ use std::path::{Path, PathBuf}; use chrono::prelude::*; use chrono::Utc; -use config::{Config, File as ConfigFile}; +use config::{Config, Environment, File as ConfigFile}; use directories::ProjectDirs; use eyre::{eyre, Result}; use parse_duration::parse; @@ -94,10 +94,14 @@ impl Settings { create_dir_all(config_dir)?; - let mut config_file = PathBuf::new(); - config_file.push(config_dir); - config_file.push("config.toml"); - let config_file = config_file.as_path(); + let config_file = if let Ok(p) = std::env::var("ATUIN_CONFIG") { + PathBuf::from(p) + } else { + let mut config_file = PathBuf::new(); + config_file.push(config_dir); + config_file.push("config.toml"); + config_file + }; // create the config file if it does not exist @@ -129,7 +133,7 @@ impl Settings { s.set_default("server.host", "127.0.0.1")?; s.set_default("server.port", 8888)?; s.set_default("server.open_registration", false)?; - s.set_default("server.db_uri", "please set a postgres url")?; + s.set_default("server.db_uri", "DEFAULT POSTGRES URI, PLEASE CHANGE")?; if config_file.exists() { s.merge(ConfigFile::with_name(config_file.to_str().unwrap()))?; @@ -139,6 +143,8 @@ impl Settings { file.write_all(example_config)?; } + s.merge(Environment::with_prefix("atuin").separator("_"))?; + // all paths should be expanded let db_path = s.get_str("local.db_path")?; let db_path = shellexpand::full(db_path.as_str())?;