From 8add38bee43de53ef4ebcb7331ba1402872cb7cd Mon Sep 17 00:00:00 2001 From: Ondrej Zara Date: Tue, 29 Oct 2019 08:49:04 +0100 Subject: [PATCH] docker and youtube, docs --- .gitignore | 3 ++- Dockerfile | 3 ++- Makefile | 6 ++++++ README.md | 21 ++++++++++++++++++++- _youtube/.empty | 0 index.js | 2 +- 6 files changed, 31 insertions(+), 4 deletions(-) create mode 100644 _youtube/.empty diff --git a/.gitignore b/.gitignore index 4193d91..1c5100d 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ node_modules -_youtube +_youtube/* +!_youtube/.empty cyp.service diff --git a/Dockerfile b/Dockerfile index a094b15..3a522f3 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,6 +1,7 @@ FROM node:10 +RUN curl -L https://yt-dl.org/downloads/latest/youtube-dl -o /usr/local/bin/youtube-dl +RUN chmod a+rx /usr/local/bin/youtube-dl WORKDIR /cyp -RUN ["mkdir", "_youtube"] COPY package.json . RUN npm i COPY index.js . diff --git a/Makefile b/Makefile index 6897838..cb801f2 100644 --- a/Makefile +++ b/Makefile @@ -27,4 +27,10 @@ watch: all clean: rm -f $(SERVICE) $(CSS) +docker-image: + docker build -t cyp . + +docker-run: + docker run --network=host -v "$$(pwd)"/_youtube:/cyp/_youtube cyp + .PHONY: all watch icons service clean diff --git a/README.md b/README.md index a596287..230d706 100644 --- a/README.md +++ b/README.md @@ -38,6 +38,25 @@ docker build -t cyp . docker run --network=host cyp ``` +## Youtube-dl integration + +You will need a working [youtube-dl](https://ytdl-org.github.io/youtube-dl/index.html) installation. Audio files are downloaded into the `_youtube` directory, so make sure it is available to your MPD library (use a symlink). + +If you use Docker, you need to mount the `_youtube` directory into the image: + +```sh +docker run --network=host -v "$(pwd)"/_youtube:/cyp/_youtube cyp +``` + + +## Changing the port + +...is done via the `PORT` environment variable. If you use Docker, the `-e` switch does the trick: + +```sh +docker run --network=host -e PORT=12345 cyp +``` + ## Technology - Connected to MPD via WebSockets (using the [ws2mpd](https://github.com/ondras/ws2mpd/) bridge) @@ -53,5 +72,5 @@ docker run --network=host cyp ## TODO - [ ] Bundling - - [ ] Range styling + - [X] Range styling - [ ] Browser testing diff --git a/_youtube/.empty b/_youtube/.empty new file mode 100644 index 0000000..e69de29 diff --git a/index.js b/index.js index f3d8b5d..64ed29d 100644 --- a/index.js +++ b/index.js @@ -1,6 +1,6 @@ const static = require("node-static"); const app = new static.Server("./app"); -const port = Number(process.argv[2]) || 8080; +const port = Number(process.argv[2]) || process.env.PORT || 8080; let tickets = [];