Skip to content

Commit

Permalink
Merge pull request #51 from kannibalox/dockerfile
Browse files Browse the repository at this point in the history
Add Dockerfile
  • Loading branch information
JohnDoee authored Feb 16, 2024
2 parents 0d96b2b + f833e85 commit 23e3b96
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 0 deletions.
17 changes: 17 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
FROM python:3.11

RUN python3 -m venv /app/autotorrent

ENV PATH=/app/autotorrent/bin/:$PATH
ENV HOME=/app/autotorrent
WORKDIR /app/autotorrent

RUN curl -sSL https://github.com/bcicen/tinycron/releases/download/v0.4/tinycron-0.4-linux-amd64 > /usr/local/bin/tinycron && chmod +x /usr/local/bin/tinycron

COPY ./docker-entrypoint.sh /opt/docker-entrypoint.sh
ENTRYPOINT ["/opt/docker-entrypoint.sh"]
COPY . /tmp/autotorrent/
RUN pip install --no-cache-dir /tmp/autotorrent/ && rm -r /tmp/autotorrent/

## Uncomment to install from pypi
# RUN /app/autotorrent/bin/pip install autotorrent2
24 changes: 24 additions & 0 deletions docker-entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#!/bin/bash
if [[ -n "$PUID" && -n "$PGID" ]]; then
groupadd -g "$PGID" autotorrent
useradd -u "$PUID" -g "$PGID" -M -d /app/autotorrent autotorrent
if [[ "$1" == "cron" ]]; then
SCHEDULE="$2"
shift 2
echo -e '#!/bin/bash\nat2 '"$*" > /var/tmp/cron.sh
chmod +x /var/tmp/cron.sh
echo /usr/local/bin/tinycron "$SCHEDULE" /var/tmp/cron.sh | su autotorrent
else
echo at2 "$@" | su autotorrent
fi
else
if [[ "$1" == "cron" ]]; then
SCHEDULE="$2"
shift 2
echo -e '#!/bin/bash\nat2 '"$*" > /var/tmp/cron.sh
chmod +x /var/tmp/cron.sh
/usr/local/bin/tinycron "$SCHEDULE" /var/tmp/cron.sh
else
at2 "$@"
fi
fi

0 comments on commit 23e3b96

Please sign in to comment.