From 3de7a131f05c2b148f78d7f8568ea4c2a3172084 Mon Sep 17 00:00:00 2001 From: Nikita Vilunov Date: Fri, 15 Sep 2023 17:03:06 +0200 Subject: [PATCH] add dockerfile --- .dockerignore | 6 ++++++ .gitignore | 1 + Cargo.lock | 2 +- Cargo.toml | 2 +- dist/alpine3.18.Dockerfile | 11 +++++++++++ src/main.rs | 5 ++++- 6 files changed, 24 insertions(+), 3 deletions(-) create mode 100644 .dockerignore create mode 100644 dist/alpine3.18.Dockerfile diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..3feddeb --- /dev/null +++ b/.dockerignore @@ -0,0 +1,6 @@ +* +!/src/ +!/migrations/ +!Cargo.lock +!Cargo.toml +!rust-toolchain diff --git a/.gitignore b/.gitignore index e2c5d98..ce1cc97 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ /target /db.sqlite +.idea/ diff --git a/Cargo.lock b/Cargo.lock index 94d6a3e..78099b5 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -750,7 +750,7 @@ dependencies = [ [[package]] name = "lavina" -version = "0.1.0" +version = "0.0.0" dependencies = [ "anyhow", "assert_matches", diff --git a/Cargo.toml b/Cargo.toml index 6a615fb..04e15f8 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "lavina" -version = "0.1.0" +version = "0.0.0" edition = "2021" publish = false diff --git a/dist/alpine3.18.Dockerfile b/dist/alpine3.18.Dockerfile new file mode 100644 index 0000000..3a4a5d4 --- /dev/null +++ b/dist/alpine3.18.Dockerfile @@ -0,0 +1,11 @@ +FROM rust:1.72.0-alpine3.18@sha256:2f5592c561cef195c9fa4462633a674458dc375fc0ba4b80e7efe4c3c8e68403 as bld + +RUN apk add --no-cache musl-dev +COPY . . +RUN cargo build --release + +FROM alpine:3.18@sha256:7144f7bab3d4c2648d7e59409f15ec52a18006a128c733fcff20d3a4a54ba44a + +COPY --from=bld target/release/lavina /usr/bin/lavina +VOLUME ["/etc/lavina/", "/var/lib/lavina/"] +ENTRYPOINT ["lavina"] diff --git a/src/main.rs b/src/main.rs index a623441..cfc3955 100644 --- a/src/main.rs +++ b/src/main.rs @@ -32,7 +32,10 @@ struct ServerConfig { } fn load_config() -> Result { - let raw_config = Figment::new().merge(Toml::file("config.toml")); + // TODO get config path as a cmd line arg + let raw_config = Figment::new() + .merge(Toml::file("config.toml")) + .merge(Toml::file("/etc/lavina/config.toml")); let config: ServerConfig = raw_config.extract()?; Ok(config) }