diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..f8c7917 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,9 @@ +/target +/.vscode +/.github +Dockerfile +.dockerignore +/.git +.gitignore +/config/secrets.toml +.DS_Store \ No newline at end of file diff --git a/.gitignore b/.gitignore index 6088e9f..01416e0 100644 --- a/.gitignore +++ b/.gitignore @@ -16,4 +16,6 @@ Cargo.lock # Secret configuration config/secrets.toml -.idea/ \ No newline at end of file +.idea/ + +.DS_Store diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..dbd2dc1 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,17 @@ +FROM rust:bookworm as builder +WORKDIR /usr/src/myapp +COPY . . +RUN cargo install --path . + +FROM debian:bookworm-slim +RUN set -xe && \ + apt-get update && \ + apt-get install -y --no-install-recommends openssl ca-certificates && \ + apt-get autoremove -y && \ + apt-get clean && \ + rm -rf /var/lib/apt/lists/* /usr/share/man/* /usr/share/doc/* + +COPY --from=builder /usr/src/myapp/config ./app/config +COPY --from=builder /usr/local/cargo/bin/ha-mitaffald ./app +WORKDIR /app +CMD ["./ha-mitaffald"] \ No newline at end of file diff --git a/src/settings.rs b/src/settings.rs index a0b322c..443f340 100644 --- a/src/settings.rs +++ b/src/settings.rs @@ -1,5 +1,5 @@ use crate::mitaffald::settings::AffaldVarmeConfig; -use config::{Config, ConfigError, File}; +use config::{Config, ConfigError, Environment, File}; use serde::Deserialize; #[derive(Debug, Deserialize)] @@ -13,7 +13,8 @@ impl Settings { pub fn new() -> Result { let settings = Config::builder() .add_source(File::with_name("config/default.toml")) - .add_source(File::with_name("config/secrets.toml")) + .add_source(File::with_name("config/secrets.toml").required(false)) + .add_source(Environment::default()) .build()?; settings.try_deserialize()