diff --git a/.dockerignore b/.dockerignore
new file mode 100644
index 0000000..eb5a316
--- /dev/null
+++ b/.dockerignore
@@ -0,0 +1 @@
+target
diff --git a/.run/Dockerfile.run.xml b/.run/Dockerfile.run.xml
new file mode 100644
index 0000000..6d3cc9f
--- /dev/null
+++ b/.run/Dockerfile.run.xml
@@ -0,0 +1,53 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/Cargo.lock b/Cargo.lock
index 56a63af..a615bc5 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -2048,6 +2048,7 @@ dependencies = [
"http",
"http-body",
"hyper",
+ "hyper-rustls 0.24.2",
"hyper-tls",
"ipnet",
"js-sys",
@@ -2057,6 +2058,7 @@ dependencies = [
"once_cell",
"percent-encoding 2.3.1",
"pin-project-lite",
+ "rustls 0.21.11",
"rustls-pemfile 1.0.4",
"serde",
"serde_json",
@@ -2065,6 +2067,7 @@ dependencies = [
"system-configuration",
"tokio",
"tokio-native-tls",
+ "tokio-rustls 0.24.1",
"tokio-util",
"tower-service",
"url 2.5.0",
@@ -2072,6 +2075,7 @@ dependencies = [
"wasm-bindgen-futures",
"wasm-streams",
"web-sys",
+ "webpki-roots",
"winreg",
]
@@ -2626,9 +2630,9 @@ dependencies = [
[[package]]
name = "signal-hook-registry"
-version = "1.4.1"
+version = "1.4.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "d8229b473baa5980ac72ef434c4415e70c4b5e71b423043adb4ba059f89c99a1"
+checksum = "a9e9e0b4211b72e7b8b6e85c807d36c212bdb33ea8587f7569562a84df5465b1"
dependencies = [
"libc",
]
@@ -3068,18 +3072,18 @@ dependencies = [
[[package]]
name = "thiserror"
-version = "1.0.58"
+version = "1.0.59"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "03468839009160513471e86a034bb2c5c0e4baae3b43f79ffc55c4a5427b3297"
+checksum = "f0126ad08bff79f29fc3ae6a55cc72352056dfff61e3ff8bb7129476d44b23aa"
dependencies = [
"thiserror-impl",
]
[[package]]
name = "thiserror-impl"
-version = "1.0.58"
+version = "1.0.59"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "c61f3ba182994efc43764a46c018c347bc492c79f024e705f46567b418f6d4f7"
+checksum = "d1cd413b5d558b4c5bf3680e324a6fa5014e7b7c067a51e69dbdf47eb7148b66"
dependencies = [
"proc-macro2",
"quote",
@@ -3371,7 +3375,8 @@ dependencies = [
[[package]]
name = "twba-twitch-data"
-version = "0.3.0"
+version = "0.3.2"
+source = "git+https://github.com/OMGeeky/twitch_data.git#64635bef670e4feb6ca423d0da286db52e687965"
dependencies = [
"anyhow",
"async-recursion",
diff --git a/Dockerfile b/Dockerfile
new file mode 100644
index 0000000..2601768
--- /dev/null
+++ b/Dockerfile
@@ -0,0 +1,44 @@
+FROM lukemathwalker/cargo-chef:latest-rust-1 AS chef
+WORKDIR /app
+
+FROM chef AS planner
+COPY /src ./src
+COPY /Cargo.toml .
+COPY /Cargo.lock .
+RUN cargo chef prepare --recipe-path recipe.json
+
+FROM chef AS builder
+COPY --from=planner /app/recipe.json recipe.json
+# Build dependencies - this is the caching Docker layer!
+RUN --mount=type=cache,target=/usr/local/cargo/registry \
+ --mount=type=cache,target=/home/root/app/target \
+ cargo chef cook --release --locked --recipe-path recipe.json
+# Build application
+COPY /src ./src
+COPY /Cargo.toml .
+COPY /Cargo.lock .
+RUN --mount=type=cache,target=/usr/local/cargo/registry \
+ --mount=type=cache,target=/home/root/app/target \
+ cargo build --release --locked
+
+# We do not need the Rust toolchain to run the binary!
+FROM debian:bookworm AS runtime
+WORKDIR /app
+ARG PROGNAME
+RUN apt-get update && apt-get install -y libssl-dev coreutils
+# Create a script to run the command and sleep for one hour after the command is done
+RUN echo "#!/bin/bash \n \
+ echo \"Running command: '$PROGNAME'\" \n \
+ # Run your command \n \
+ $PROGNAME \n \
+ echo \"Done with normal command. Sleeping for one hour\" \n \
+ # Sleep for one hour \n \
+ sleep 3600 \n \
+ echo \"Done with sleep. Exiting\" \
+ " > /app/entrypoint.sh
+
+# Make the script executable
+RUN chmod +x /app/entrypoint.sh
+COPY --from=builder /app/target/release/$PROGNAME /usr/local/bin/$PROGNAME
+
+CMD ["/app/entrypoint.sh"]
diff --git a/src/client.rs b/src/client.rs
index 2e8f353..83a33d1 100644
--- a/src/client.rs
+++ b/src/client.rs
@@ -2,7 +2,7 @@ use crate::prelude::*;
use twba_backup_config::Conf;
use twba_local_db::entities::users::Model;
use twba_local_db::entities::videos::ActiveModel;
-use twba_local_db::prelude::{Status, Users, UsersColumn, Videos, VideosColumn, VideosModel};
+use twba_local_db::prelude::{Status, Users, UsersColumn, Videos, VideosColumn};
use twba_local_db::re_exports::sea_orm::{
ActiveModelTrait, ActiveValue, ColumnTrait, DatabaseConnection, EntityTrait, QueryFilter,
};
diff --git a/src/main.rs b/src/main.rs
index 55667d1..f5f7f07 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -26,6 +26,7 @@ async fn run() -> Result<()> {
.env()
.file("./settings.toml")
.file(shellexpand::tilde("~/twba/config.toml").into_owned())
+ .file(std::env::var("TWBA_CONFIG").unwrap_or_else(|_| "~/twba/config.toml".to_string()))
.load()
.map_err(|e| FetcherError::LoadConfig(e.into()))?;
diff --git a/src/prelude.rs b/src/prelude.rs
index fcc5a9a..4d9742b 100644
--- a/src/prelude.rs
+++ b/src/prelude.rs
@@ -1,5 +1,6 @@
pub use crate::errors::FetcherError;
pub(crate) use std::result::Result as StdResult;
+#[allow(unused_imports)]
pub(crate) use tracing::{debug, error, info, trace, warn};
pub type Result = StdResult;