mirror of
https://github.com/OMGeeky/twba.twitch_fetcher.git
synced 2026-02-23 15:49:57 +01:00
docker deploy
This commit is contained in:
1
.dockerignore
Normal file
1
.dockerignore
Normal file
@@ -0,0 +1 @@
|
||||
target
|
||||
53
.run/Dockerfile.run.xml
Normal file
53
.run/Dockerfile.run.xml
Normal file
@@ -0,0 +1,53 @@
|
||||
<component name="ProjectRunConfigurationManager">
|
||||
<configuration default="false" name="Dockerfile" type="docker-deploy" factoryName="dockerfile" server-name="Docker">
|
||||
<deployment type="dockerfile">
|
||||
<settings>
|
||||
<option name="imageTag" value="twba-twitch-fetcher"/>
|
||||
<option name="buildArgs">
|
||||
<list>
|
||||
<DockerEnvVarImpl>
|
||||
<option name="name" value="PROGNAME"/>
|
||||
<option name="value" value="twba-twitch-fetcher"/>
|
||||
</DockerEnvVarImpl>
|
||||
</list>
|
||||
</option>
|
||||
<option name="buildKitEnabled" value="true"/>
|
||||
<option name="containerName" value="twba-twitch-fetcher"/>
|
||||
<option name="envVars">
|
||||
<list>
|
||||
<DockerEnvVarImpl>
|
||||
<option name="name" value="TWBA_CONFIG"/>
|
||||
<option name="value" value="/twba/configs/config.toml"/>
|
||||
</DockerEnvVarImpl>
|
||||
</list>
|
||||
</option>
|
||||
<option name="commandLineOptions" value="--restart=unless-stopped"/>
|
||||
<option name="showCommandPreview" value="true"/>
|
||||
<option name="sourceFilePath" value="Dockerfile"/>
|
||||
<option name="volumeBindings">
|
||||
<list>
|
||||
<DockerVolumeBindingImpl>
|
||||
<option name="containerPath" value="/twba/configs/"/>
|
||||
<option name="hostPath" value="/twba/"/>
|
||||
<option name="readOnly" value="true"/>
|
||||
</DockerVolumeBindingImpl>
|
||||
<DockerVolumeBindingImpl>
|
||||
<option name="containerPath" value="/twba/tmp/"/>
|
||||
<option name="hostPath" value="/var/tmp/twba/"/>
|
||||
</DockerVolumeBindingImpl>
|
||||
<DockerVolumeBindingImpl>
|
||||
<option name="containerPath" value="/twba/data/"/>
|
||||
<option name="hostPath" value="/twba/data/"/>
|
||||
</DockerVolumeBindingImpl>
|
||||
<DockerVolumeBindingImpl>
|
||||
<option name="containerPath" value="/etc/ssl/certs"/>
|
||||
<option name="hostPath" value="/etc/ssl/certs"/>
|
||||
<option name="readOnly" value="true"/>
|
||||
</DockerVolumeBindingImpl>
|
||||
</list>
|
||||
</option>
|
||||
</settings>
|
||||
</deployment>
|
||||
<method v="2"/>
|
||||
</configuration>
|
||||
</component>
|
||||
19
Cargo.lock
generated
19
Cargo.lock
generated
@@ -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",
|
||||
|
||||
44
Dockerfile
Normal file
44
Dockerfile
Normal file
@@ -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"]
|
||||
@@ -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,
|
||||
};
|
||||
|
||||
@@ -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()))?;
|
||||
|
||||
|
||||
@@ -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<T> = StdResult<T, FetcherError>;
|
||||
|
||||
Reference in New Issue
Block a user