Add dockerfile (#32)
This commit is contained in:
parent
5751463942
commit
9c8d426184
3 changed files with 25 additions and 6 deletions
1
.dockerignore
Normal file
1
.dockerignore
Normal file
|
@ -0,0 +1 @@
|
||||||
|
./target
|
12
Dockerfile
Normal file
12
Dockerfile
Normal file
|
@ -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"]
|
|
@ -4,7 +4,7 @@ use std::path::{Path, PathBuf};
|
||||||
|
|
||||||
use chrono::prelude::*;
|
use chrono::prelude::*;
|
||||||
use chrono::Utc;
|
use chrono::Utc;
|
||||||
use config::{Config, File as ConfigFile};
|
use config::{Config, Environment, File as ConfigFile};
|
||||||
use directories::ProjectDirs;
|
use directories::ProjectDirs;
|
||||||
use eyre::{eyre, Result};
|
use eyre::{eyre, Result};
|
||||||
use parse_duration::parse;
|
use parse_duration::parse;
|
||||||
|
@ -94,10 +94,14 @@ impl Settings {
|
||||||
|
|
||||||
create_dir_all(config_dir)?;
|
create_dir_all(config_dir)?;
|
||||||
|
|
||||||
let mut config_file = PathBuf::new();
|
let config_file = if let Ok(p) = std::env::var("ATUIN_CONFIG") {
|
||||||
config_file.push(config_dir);
|
PathBuf::from(p)
|
||||||
config_file.push("config.toml");
|
} else {
|
||||||
let config_file = config_file.as_path();
|
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
|
// 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.host", "127.0.0.1")?;
|
||||||
s.set_default("server.port", 8888)?;
|
s.set_default("server.port", 8888)?;
|
||||||
s.set_default("server.open_registration", false)?;
|
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() {
|
if config_file.exists() {
|
||||||
s.merge(ConfigFile::with_name(config_file.to_str().unwrap()))?;
|
s.merge(ConfigFile::with_name(config_file.to_str().unwrap()))?;
|
||||||
|
@ -139,6 +143,8 @@ impl Settings {
|
||||||
file.write_all(example_config)?;
|
file.write_all(example_config)?;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
s.merge(Environment::with_prefix("atuin").separator("_"))?;
|
||||||
|
|
||||||
// all paths should be expanded
|
// all paths should be expanded
|
||||||
let db_path = s.get_str("local.db_path")?;
|
let db_path = s.get_str("local.db_path")?;
|
||||||
let db_path = shellexpand::full(db_path.as_str())?;
|
let db_path = shellexpand::full(db_path.as_str())?;
|
||||||
|
|
Loading…
Reference in a new issue