Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
eskwisit committed Feb 26, 2024
0 parents commit 2ff9ca2
Show file tree
Hide file tree
Showing 4 changed files with 118 additions and 0 deletions.
23 changes: 23 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# compiled output
/tmp

# IDEs and editors
/.idea
.project
.classpath
.c9/
*.launch
.settings/
*.sublime-workspace

# IDE - VSCode
.vscode/*
!.vscode/settings.json
!.vscode/tasks.json
!.vscode/launch.json
!.vscode/extensions.json
.history/*

# System Files
.DS_Store
Thumbs.db
51 changes: 51 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
FROM python:3.10-slim

LABEL author='eskwisit'
LABEL description='Slim Docker container featuring embedded Nut server from blawar/nut latest release that works for most.'
LABEL repo='eskwisit/nut-server'
LABEL email='[email protected]'

# Prepare Nut install
RUN apt-get update && apt-get -y install \
gcc \
cron \
wget \
unzip \
libssl-dev \
libcurl4-openssl-dev \
zlib1g-dev \
libjpeg-dev

# Fetch Nut codebase
RUN wget https://github.com/blawar/nut/archive/refs/tags/v3.3.zip
RUN unzip v3.3.zip -d /root
RUN mv /root/nut-3.3 /root/nut

# Tune config
RUN mv /root/nut/conf/nut.default.conf /root/nut/conf/nut.conf
RUN sed -i '/scan/c "scan": ["\/titles"]' /root/nut/conf/nut.conf

# Remove GUI packages
RUN sed -i '/pyqt5/d' /root/nut/requirements.txt
RUN sed -i '/qt-range-slider/d' /root/nut/requirements.txt

# Add missing requirements
RUN echo markupsafe==2.0.1 >>/root/nut/requirements.txt

# Install project dependencies
RUN pip3 install -U pip
RUN pip3 install -r /root/nut/requirements.txt

COPY /entrypoint.sh /

RUN chmod +x /entrypoint.sh

VOLUME [ "/titles" ]

EXPOSE 9000

# clean up
RUN rm v3.3.zip
RUN apt-get autoremove

ENTRYPOINT ["/entrypoint.sh"]
22 changes: 22 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Nut-server

Slim Docker image featuring embedded Nut server from [blawar/nut](https://github.com/blawar/nut) latest release that works for most.

## Features

- Thin Docker image.
- Very low memory usage.
- Designed to work on amd64 arch (Linux, Unix).
- Cron task to poll new titles.
- Zero config bundle.
- Seamless integration for [Tinfoil](https://tinfoil.io/).

## Usage

```bash
# Pull image from Docker hub
docker pull eskwisit/nut-server

# Run image
docker run -d --name=nut-server -v /path/to/titles:/titles:rw eskwisit/nut-server
```
22 changes: 22 additions & 0 deletions entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#!/bin/bash
set -e

CRON_CMD='wget --spider --user guest --password guest'
HOSTED_API=http://127.0.0.1:9000/api
CRON_FOLDER=/etc/cron.d

echo 'Registering cron task'

rm -f $CRON_FOLDER/polling-titles && touch $CRON_FOLDER/polling-titles

echo "0 1 * * * $CRON_CMD $HOSTED_API/scan" >>$CRON_FOLDER/polling-titles

chmod 0644 $CRON_FOLDER/polling-titles

crontab $CRON_FOLDER/polling-titles

service cron start

echo 'Starting nut server on port 9000'

python3 /root/nut/nut.py --server

0 comments on commit 2ff9ca2

Please sign in to comment.