From bb8a125ff13dddd3e9eb13b740da2001f8c74fd6 Mon Sep 17 00:00:00 2001 From: JMARyA Date: Thu, 7 Mar 2024 16:25:32 +0100 Subject: [PATCH] add docker + workflow --- .gitea/workflows/build.yml | 25 +++++++++++++++++++++++++ Dockerfile | 19 +++++++++++++++++++ docker-compose.yml | 11 +++++++++++ src/main.rs | 1 + 4 files changed, 56 insertions(+) create mode 100644 .gitea/workflows/build.yml create mode 100644 Dockerfile create mode 100644 docker-compose.yml diff --git a/.gitea/workflows/build.yml b/.gitea/workflows/build.yml new file mode 100644 index 0000000..dc63e86 --- /dev/null +++ b/.gitea/workflows/build.yml @@ -0,0 +1,25 @@ +name: build + +on: + push: + branches: + - master + +jobs: + deploy: + runs-on: ubuntu-latest + + steps: + - name: Checkout repository + uses: actions/checkout@v2 + + - name: Install Docker + run: curl -fsSL https://get.docker.com | sh + + - name: Log in to Docker registry + run: echo "${{ secrets.registry_password }}" | docker login -u "${{ secrets.registry_user }}" --password-stdin git.hydrar.de + + - name: Build and push Docker image + run: | + docker build -t git.hydrar.de/jmarya/hoard:latest . + docker push git.hydrar.de/jmarya/hoard:latest diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..d12da88 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,19 @@ +FROM rust:buster as builder + +COPY . /app +WORKDIR /app + +RUN cargo build --release + +FROM archlinux + +# Install dependencies for yt-dlp and ffmpeg +RUN pacman -Syu --noconfirm && \ + pacman -S --noconfirm ca-certificates ffmpeg yt-dlp && \ + rm -rf /var/cache/pacman/pkg/* + +COPY --from=builder /app/target/release/hoard /hoard + +WORKDIR / + +CMD ["/hoard"] \ No newline at end of file diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..5e78497 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,11 @@ +version: '3' + +services: + app: + build: "." + environment: + TZ: Europe/Berlin + volumes: + - ./download:/download + - ./download.db:/download.db + - ./config.toml:/config.toml diff --git a/src/main.rs b/src/main.rs index ea9afeb..5228ce2 100644 --- a/src/main.rs +++ b/src/main.rs @@ -7,6 +7,7 @@ mod youtube; use config::GlobalConfig; // todo : migrate to async code? +// todo : better log options pub fn ensure_dir_exists(dir_path: &PathBuf) { let path = std::path::Path::new(dir_path);