Run server in docker container, added log file
This commit is contained in:
parent
5413fba309
commit
e44aa9ddfc
1
.gitignore
vendored
1
.gitignore
vendored
@ -1,6 +1,7 @@
|
||||
/target
|
||||
**/*.rs.bk
|
||||
.env
|
||||
.env.docker
|
||||
Session.vim
|
||||
src/db/refinery.toml
|
||||
tags
|
||||
|
12
Cargo.lock
generated
12
Cargo.lock
generated
@ -146,6 +146,7 @@ dependencies = [
|
||||
"sqlx",
|
||||
"tokio",
|
||||
"tracing",
|
||||
"tracing-appender",
|
||||
"tracing-futures",
|
||||
"tracing-subscriber",
|
||||
"url",
|
||||
@ -1937,6 +1938,17 @@ dependencies = [
|
||||
"tracing-core",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "tracing-appender"
|
||||
version = "0.1.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "7aa52d56cc0d79ab604e8a022a1cebc4de33cf09dc9933c94353bea2e00d6e88"
|
||||
dependencies = [
|
||||
"chrono",
|
||||
"crossbeam-channel",
|
||||
"tracing-subscriber",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "tracing-attributes"
|
||||
version = "0.1.9"
|
||||
|
@ -28,6 +28,7 @@ url = "2.1"
|
||||
async-trait = "0.1"
|
||||
seahash = "4.0"
|
||||
tracing = "0.1"
|
||||
tracing-appender = "0.1"
|
||||
tracing-subscriber = "0.2"
|
||||
tracing-futures = "0.2"
|
||||
lru = "0.5"
|
||||
|
@ -10,6 +10,7 @@ FROM ${BASE_IMAGE} AS builder
|
||||
# Add our source code.
|
||||
ADD --chown=rust:rust . ./
|
||||
|
||||
ENV SQLX_OFFLINE true
|
||||
# Build our application.
|
||||
RUN cargo build --release
|
||||
|
||||
@ -19,4 +20,8 @@ RUN apk --no-cache add ca-certificates
|
||||
COPY --from=builder \
|
||||
/home/rust/src/target/x86_64-unknown-linux-musl/release/bazaar_realm_api \
|
||||
/usr/local/bin/
|
||||
|
||||
# forward request and error logs to docker log collector
|
||||
RUN ln -sf /dev/stdout /var/log/bazaarrealm.log
|
||||
|
||||
CMD /usr/local/bin/bazaar_realm_api
|
@ -6,6 +6,10 @@ services:
|
||||
volumes:
|
||||
- cargo:/home/rust/.cargo
|
||||
- target:/home/rust/src/target
|
||||
env_file:
|
||||
- .env.docker
|
||||
ports:
|
||||
- "3030:3030"
|
||||
|
||||
volumes:
|
||||
cargo: {}
|
||||
|
@ -68,9 +68,15 @@ async fn main() -> Result<()> {
|
||||
dotenv().ok();
|
||||
let env_log_filter =
|
||||
env::var("RUST_LOG").unwrap_or_else(|_| "warp=info,bazaar_realm_api=info".to_owned());
|
||||
let file_appender = tracing_appender::rolling::hourly(
|
||||
env::var("LOG_DIR").unwrap_or_else(|_| ".".to_owned()),
|
||||
"bazaarrealm.log",
|
||||
);
|
||||
let (non_blocking, _guard) = tracing_appender::non_blocking(file_appender);
|
||||
tracing_subscriber::fmt()
|
||||
.with_env_filter(env_log_filter)
|
||||
.with_span_events(FmtSpan::CLOSE)
|
||||
.with_writer(non_blocking)
|
||||
.init();
|
||||
|
||||
let host = env::var("HOST").expect("`HOST` environment variable not defined");
|
||||
|
Loading…
Reference in New Issue
Block a user