From e4f14f953129f23aa97ea3efe115dd65842c0ce3 Mon Sep 17 00:00:00 2001 From: Didier Date: Sun, 7 May 2023 21:08:14 +0200 Subject: [PATCH] feat(docker): add docker functionality. --- .dockerignore | 6 +++++ .gitignore | 5 ++-- Dockerfile | 30 ++++++++++++++++++++++ config.example.toml | 2 +- docker/docker-entrypoint.d/00-preflight.sh | 10 ++++++++ docker/docker-entrypoint.sh | 11 ++++++++ 6 files changed, 61 insertions(+), 3 deletions(-) create mode 100644 .dockerignore create mode 100644 Dockerfile create mode 100644 docker/docker-entrypoint.d/00-preflight.sh create mode 100644 docker/docker-entrypoint.sh diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..26d9c74 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,6 @@ +.idea/ +target/ +files/ +*.iml +*.log +config.toml \ No newline at end of file diff --git a/.gitignore b/.gitignore index d5d1f15..d081bae 100644 --- a/.gitignore +++ b/.gitignore @@ -7,7 +7,8 @@ # runtime files *.log -/files -# config +# dev files config.toml +/files +docker-compose.yml diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..e4f708a --- /dev/null +++ b/Dockerfile @@ -0,0 +1,30 @@ +FROM rust + +COPY Cargo.toml /app/Cargo.toml + +WORKDIR /app + +RUN mkdir src && \ + echo "fn main() {println!(\"if you see this, the build broke\")}" > src/main.rs && \ + cargo build --release && \ + rm -r target/release/deps/bumblebee* + +COPY src /app/src + +RUN cargo build --release + +RUN cp target/release/bumblebee /app/bumblebee + +# -- # + +COPY docker/docker-entrypoint.sh /docker-entrypoint.sh +COPY docker/docker-entrypoint.d/ /docker-entrypoint.d +RUN chmod +x /docker-entrypoint.sh + +ENV CONFIG_PATH=/config/config.toml + +VOLUME /config +VOLUME /data/input +VOLUME /data/output + +ENTRYPOINT ["/docker-entrypoint.sh"] diff --git a/config.example.toml b/config.example.toml index a8ab2f8..64cd838 100644 --- a/config.example.toml +++ b/config.example.toml @@ -5,7 +5,7 @@ include = [ 'mp4', 'avi', 'mkv' ] # file extensions to include keep_file_structure = true # e.g. /data/input/foo/bar.mp4 -> /data/output/foo/bar.webm [files.cleanup] -enabled = true +enabled = true # do cleanup? original_cleanup_behavior = "delete" # delete, archive or keep [files.cleanup.archive] diff --git a/docker/docker-entrypoint.d/00-preflight.sh b/docker/docker-entrypoint.d/00-preflight.sh new file mode 100644 index 0000000..1781787 --- /dev/null +++ b/docker/docker-entrypoint.d/00-preflight.sh @@ -0,0 +1,10 @@ +#!/bin/sh + +set -e + +[ -z "$DEBUG" ] || set -x + +if [ ! -f /app/bumblebee ]; then + echo "$0: /app/bumblebee not found, I can't start!!" + exit 1 +fi \ No newline at end of file diff --git a/docker/docker-entrypoint.sh b/docker/docker-entrypoint.sh new file mode 100644 index 0000000..ddfc990 --- /dev/null +++ b/docker/docker-entrypoint.sh @@ -0,0 +1,11 @@ +#!/bin/sh + +set -e + +for file in /docker-entrypoint.d/*; do + echo "$0: running $file" + sh "$file" +done + +cd /app +exec ./bumblebee