mirror of
https://github.com/OMGeeky/twba.splitter.git
synced 2025-12-26 17:02:35 +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-splitter" />
|
||||
<option name="buildArgs">
|
||||
<list>
|
||||
<DockerEnvVarImpl>
|
||||
<option name="name" value="PROGNAME" />
|
||||
<option name="value" value="twba-splitter" />
|
||||
</DockerEnvVarImpl>
|
||||
</list>
|
||||
</option>
|
||||
<option name="buildKitEnabled" value="true" />
|
||||
<option name="containerName" value="twba-splitter" />
|
||||
<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>
|
||||
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"]
|
||||
@@ -1,7 +1,7 @@
|
||||
use crate::errors::SplitterError;
|
||||
use prelude::*;
|
||||
use twba_backup_config::prelude::Config;
|
||||
use twba_backup_config::Conf;
|
||||
use prelude::*;
|
||||
|
||||
pub mod client;
|
||||
pub mod errors;
|
||||
@@ -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| SplitterError::LoadConfig(e.into()))?;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user