From fc5eca2560869871a7c0b949e5e0b3a77e182d15 Mon Sep 17 00:00:00 2001 From: Ketan Patel Date: Fri, 1 Aug 2025 16:06:50 -0400 Subject: [PATCH] Adding all files for initial repo --- .github/workflows/build-push.yml | 30 ++++++++++++++++++++++++ .gitignore | 1 + Dockerfile | 23 +++++++++++++++++++ docker-compose.yml | 39 ++++++++++++++++++++++++++++++++ env.sample | 8 +++++++ install/rtorrent.sh | 22 ++++++++++++++++++ 6 files changed, 123 insertions(+) create mode 100644 .github/workflows/build-push.yml create mode 100644 .gitignore create mode 100644 Dockerfile create mode 100644 docker-compose.yml create mode 100644 env.sample create mode 100644 install/rtorrent.sh diff --git a/.github/workflows/build-push.yml b/.github/workflows/build-push.yml new file mode 100644 index 0000000..2779af8 --- /dev/null +++ b/.github/workflows/build-push.yml @@ -0,0 +1,30 @@ +name: Build and Push Docker Image + + +# This workflow is manually triggered from the "Actions" tab in GitHub. +# It requires a single input: the version tag of the flood repository to use. +on: + workflow_dispatch: + +jobs: + build: + runs-on: ubuntu-latest + + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Log in to Docker Hub + uses: docker/login-action@v3 + with: + username: ${{ secrets.DOCKER_USERNAME }} + password: ${{ secrets.DOCKER_TOKEN }} + + - name: Build the Docker image + id: build + run: | + docker build . -t k2patel/postfix:latest + echo "IMAGE_NAME=k2patel/postfix:latest" >> $GITHUB_ENV + + - name: Push the Docker image + run: docker push ${{ env.IMAGE_NAME }} \ No newline at end of file diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..4c49bd7 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +.env diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..3dbd5f0 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,23 @@ +FROM alpine:latest +RUN apk add --no-cache bash +RUN apk add --no-cache rtorrent +RUN apk add --no-cache libcurl +RUN apk add --no-cache curl +# RUN apk add supervisor + +RUN mkdir /myconfig +RUN mkdir /home/nfs_download + +# Removed: COPY config/rtorrent.rc /root/.rtorrent.rc +# This file will now be mounted as a volume during container runtime. +# COPY config/rtorrent.rc /root/.rtorrent.rc + +RUN chown root:root /root/.rtorrent.rc || true # Ensure this doesn't fail if file isn't there yet +COPY install/rtorrent.sh /rtorrent.sh +# COPY config/supervisord.conf /etc/supervisor/supervisord.conf + +VOLUME ["/home/nfs_download"] +EXPOSE 5001/tcp +# ENTRYPOINT ["supervisord", "--nodaemon", "-c", "/etc/supervisor/supervisord.conf"] +# ENTRYPOINT ["rtorrent"] +ENTRYPOINT ["/rtorrent.sh"] \ No newline at end of file diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..2ba420a --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,39 @@ +--- +services: + rtorrent: + image: docker.io/k2patel/rtorrent:latest + container_name: rtorrent + environment: + - TZ=${TZ} + volumes: + - "${TORRENT_LOCATION}:/home/nfs_download:rw" + - "${TORRENTRC}:/root/.rtorrent.rc" + ports: + - 5001 + restart: unless-stopped + healthcheck: + test: ["CMD-SHELL", "nc -z localhost 5001 || exit 1"] + interval: 10s # Check every 10 seconds + timeout: 10s # Allow the command 5 seconds to complete + retries: 5 # Number of consecutive failures before marking as 'unhealthy' + start_period: 90s # Give the service 30 seconds to start up before starting health checks + + floodui: + image: docker.io/k2patel/floodui:latest + container_name: floodui + environment: + - TZ=${TZ} + - FLOOD_SECRET=${FLOOD_SECRET} + - RTORRENT_SOCK=${RTORRENT_SOCK} + - RTORRENT_SCGI_HOST=${RTORRENT_SCGI_HOST} + - RTORRENT_SCGI_PORT=${RTORRENT_SCGI_PORT} + volumes: + - "${TORRENT_LOCATION}:/home/nfs_download:ro" + - "${FLOOD_LOCATION}/v4/config:/config:rw" + - "${FLOOD_LOCATION}/server/db:/server/db:rw" + ports: + - 12080:3000 + restart: unless-stopped + depends_on: + rtorrent: + condition: service_healthy \ No newline at end of file diff --git a/env.sample b/env.sample new file mode 100644 index 0000000..1f98348 --- /dev/null +++ b/env.sample @@ -0,0 +1,8 @@ +TZ=America/New_York +FLOOD_SECRET=a98sufasidfaj +RTORRENT_SOCK=false +RTORRENT_SCGI_HOST=rtorrent +RTORRENT_SCGI_PORT=5001 +TORRENT_LOCATION=/mnt/trnt +TORRENTRC=/tmp/rtorrent.rc +FLOOD_LOCATION=/tmp/flood_data \ No newline at end of file diff --git a/install/rtorrent.sh b/install/rtorrent.sh new file mode 100644 index 0000000..5254073 --- /dev/null +++ b/install/rtorrent.sh @@ -0,0 +1,22 @@ +#!/usr/bin/env bash +set -e + +CLEANUP_FILE="/home/nfs_download/rsession/rtorrent.lock" + +# Remove stale lock at startup +if [ -f "$CLEANUP_FILE" ]; then + echo "️Stale lock file found. Removing..." + rm -f "$CLEANUP_FILE" +fi + +cleanup() { + echo "Caught shutdown signal. Cleaning up..." + rm -f "$CLEANUP_FILE" + echo "Cleanup complete." +} + +trap cleanup INT TERM EXIT + +echo "Starting rtorrent..." + +exec rtorrent \ No newline at end of file