add dockerfile

This commit is contained in:
Nikita Vilunov 2023-09-15 17:03:06 +02:00
parent c662b64f11
commit 3de7a131f0
6 changed files with 24 additions and 3 deletions

6
.dockerignore Normal file
View File

@ -0,0 +1,6 @@
*
!/src/
!/migrations/
!Cargo.lock
!Cargo.toml
!rust-toolchain

1
.gitignore vendored
View File

@ -1,2 +1,3 @@
/target /target
/db.sqlite /db.sqlite
.idea/

2
Cargo.lock generated
View File

@ -750,7 +750,7 @@ dependencies = [
[[package]] [[package]]
name = "lavina" name = "lavina"
version = "0.1.0" version = "0.0.0"
dependencies = [ dependencies = [
"anyhow", "anyhow",
"assert_matches", "assert_matches",

View File

@ -1,6 +1,6 @@
[package] [package]
name = "lavina" name = "lavina"
version = "0.1.0" version = "0.0.0"
edition = "2021" edition = "2021"
publish = false publish = false

11
dist/alpine3.18.Dockerfile vendored Normal file
View File

@ -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"]

View File

@ -32,7 +32,10 @@ struct ServerConfig {
} }
fn load_config() -> Result<ServerConfig> { fn load_config() -> Result<ServerConfig> {
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()?; let config: ServerConfig = raw_config.extract()?;
Ok(config) Ok(config)
} }