From 3ce9a2c6ad8063d8dd9face27b5281c168ef30f8 Mon Sep 17 00:00:00 2001 From: Carlos Vidal Date: Wed, 23 Apr 2025 07:48:35 +0200 Subject: [PATCH] docker setup --- Dockerfile | 39 +++++++++++++++++++++++++++++++++ README.md | 54 ++++++++++++++++++++++++++++++++++++++++++++++ docker-compose.yml | 16 ++++++++++++++ example.env | 11 ++++++++++ 4 files changed, 120 insertions(+) create mode 100644 Dockerfile create mode 100644 docker-compose.yml create mode 100644 example.env diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..506050a --- /dev/null +++ b/Dockerfile @@ -0,0 +1,39 @@ +FROM ubuntu:25.04 + +# Avoid prompts during package installation +ENV DEBIAN_FRONTEND=noninteractive + +# Install required dependencies +RUN apt-get update && apt-get install -y \ + curl \ + ffmpeg \ + unzip \ + ca-certificates \ + && apt-get clean \ + && rm -rf /var/lib/apt/lists/* + +# Create directory for recordings +RUN mkdir -p /recordings + +# Create directory for db +RUN mkdir -p /var/lib/uhf-server + +# Set working directory +WORKDIR /app + +# Install UHF server (modified to not use sudo) +RUN curl -sL https://link.uhfapp.com/setup.sh > setup.sh && \ + chmod +x setup.sh && \ + sed -i 's/sudo //g' setup.sh && \ + bash setup.sh && \ + rm setup.sh + +# Expose default port +EXPOSE ${PORT} + +# Set healthcheck +HEALTHCHECK --interval=60s --timeout=10s --start-period=5s --retries=3 \ + CMD curl -f http://localhost:${PORT}/server/stats || exit 1 + +# Default command +CMD ["uhf-server"] \ No newline at end of file diff --git a/README.md b/README.md index e69de29..41ef2fd 100644 --- a/README.md +++ b/README.md @@ -0,0 +1,54 @@ +# UHF Server Docker Setup + +This directory contains Docker configuration files to easily run the UHF DVR Server. + +## Requirements + +- Docker and Docker Compose installed on your system +- Sufficient disk space for recordings + +## Quick Start + +1. Clone this repository or download these files +2. Run the server with default settings: + +```bash +docker-compose up -d +``` + +This will: +- Build the Docker image with all dependencies +- Start the UHF Server on port 8000 +- Store recordings in a `./recordings` directory + +## Configuration + +You can customize the server by setting environment variables: + +```bash +# Set custom port and recordings directory +PORT=9000 RECORDINGS_DIR=/path/to/recordings docker-compose up -d + +# Add password protection +PORT=8000 RECORDINGS_DIR=/path/to/recordings PASSWORD=mysecretpassword docker-compose up -d +``` + +### Available Options + +- `PORT`: Server port (default: 8000) +- `RECORDINGS_DIR`: Path to store recordings (default: ./recordings) +- `PASSWORD`: Optional password protection + + +## Logs and Troubleshooting + +View logs: +```bash +docker-compose logs -f +``` + +## Stopping the Server + +```bash +docker-compose down +``` diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..93c49f3 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,16 @@ +services: + uhf-server: + build: + context: . + dockerfile: Dockerfile + container_name: uhf-server + restart: unless-stopped + ports: + - "${PORT:-8000}:${PORT:-8000}" + volumes: + - ${RECORDINGS_DIR:-./recordings}:/recordings + environment: + - PORT=${PORT:-8000} + - PASSWORD=${PASSWORD:-} # Optional password protection + command: uhf-server --port ${PORT:-8000} --recordings-dir /recordings ${PASSWORD:+--password ${PASSWORD}} + stop_grace_period: 30s diff --git a/example.env b/example.env new file mode 100644 index 0000000..c9d168d --- /dev/null +++ b/example.env @@ -0,0 +1,11 @@ +# UHF Server Configuration +# Copy this file to .env and modify as needed + +# Server port +PORT=8000 + +# Path to recordings directory (relative or absolute) +RECORDINGS_DIR=./recordings + +# Optional password protection +# PASSWORD=mysecretpassword \ No newline at end of file