Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 23 additions & 10 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,15 @@ LABEL description='Slim Docker container featuring embedded Nut server from blaw
LABEL repo='eskwisit/nut-server'
LABEL email='mru2683@gmail.com'

# Fail the build on any error, including inside pipes
SHELL ["/bin/bash", "-euo", "pipefail", "-c"]

ENV DEBIAN_FRONTEND=noninteractive \
PYTHONUNBUFFERED=1 \
PYTHONFAULTHANDLER=1

# Prepare Nut install
RUN apt-get update && apt-get -y install \
RUN apt-get update && apt-get -y install --no-install-recommends \
wget \
unzip \
gcc \
Expand All @@ -16,31 +23,37 @@ RUN apt-get update && apt-get -y install \
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 wget --no-verbose --tries=3 -O /tmp/nut.zip https://github.com/blawar/nut/archive/refs/tags/v3.3.zip
RUN unzip -q /tmp/nut.zip -d /root
RUN mv /root/nut-3.3 /root/nut
RUN test -f /root/nut/nut.py

# Edit 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
RUN sed -i '/scan/c "scan": ["\/titles"]' /root/nut/conf/nut.conf \
&& grep -qF '"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
RUN sed -i -e '/pyqt5/d' -e '/qt-range-slider/d' /root/nut/requirements.txt \
&& ! grep -qiE 'pyqt5|qt-range-slider' /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
RUN pip3 install -U --no-cache-dir pip
RUN pip3 install --no-cache-dir -r /root/nut/requirements.txt

VOLUME [ "/titles", "/root/nut/conf", "/root/nut/_NSPOUT" ]

EXPOSE 9000

# Surface a dead or wedged server instead of reporting the container as healthy
HEALTHCHECK --interval=30s --timeout=5s --start-period=180s --retries=3 \
CMD python3 -c "import socket; socket.create_connection(('127.0.0.1', 9000), 3).close()"

# clean up
RUN rm v3.3.zip
RUN apt-get autoremove
RUN rm /tmp/nut.zip
RUN apt-get -y autoremove && apt-get clean && rm -rf /var/lib/apt/lists/*

CMD ["python3", "/root/nut/nut.py", "--server"]
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ Slim Docker image featuring embedded Nut server from [blawar/nut](https://github
- Very low memory usage.
- Designed to work on amd64 arch (Linux, Unix).
- Auto refresh of titles directory.
- Built-in healthcheck on port 9000.
- Zero config bundle.
- Seamless integration for [Tinfoil](https://tinfoil.io/).

Expand Down