This commit is contained in:
OMGeeky
2024-04-21 23:25:33 +02:00
parent 1a67ce0b30
commit 39566547f0
8 changed files with 106 additions and 3 deletions

3
.gitmodules vendored
View File

@@ -22,3 +22,6 @@
[submodule "twba.backup_config"]
path = twba.backup_config
url = git@github.com:OMGeeky/backup_config.git
[submodule "twba-code-receiver"]
path = twba-code-receiver
url = git@github.com:OMGeeky/twba.code-receiver.git

View File

@@ -0,0 +1 @@
target

View 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="{replaceme}" />
<option name="buildArgs">
<list>
<DockerEnvVarImpl>
<option name="name" value="PROGNAME" />
<option name="value" value="{replaceme}" />
</DockerEnvVarImpl>
</list>
</option>
<option name="buildKitEnabled" value="true" />
<option name="containerName" value="{replaceme}" />
<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>

View File

@@ -0,0 +1,45 @@
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 ./.cargo
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
twba-code-receiver Submodule

Submodule twba-code-receiver added at e979cc13f2