bhj / KaraokeEternal

Open karaoke party system
https://www.karaoke-eternal.com
ISC License
460 stars 70 forks source link

[Feature Request] Docker Container Implementation #29

Closed jschmaltz69 closed 2 years ago

jschmaltz69 commented 3 years ago

Hello,

I made a few attempts to spin up the node.js docker package to try and install karaoke-forever, but all I manged to do was fight with permissions issues with the npm install process, so I'm stuck for now. Are you guys considering building a docker container for the next release? Alternately, I think this package would be a good addition to the linuxserver.io ecosystem, as they seem to have more of a clue as to how the docker backend works, unlike myself.

Thanks.

bhj commented 3 years ago

Hey, I know you were able to get up and running with these instructions but I agree there is demand for official images. I probably won't be able to do this before v1.0 (meanwhile the AMD64+ARM64 situation can shake out a bit) but absolutely want to make the process easier. linuxserver.io looks promising as well; thanks for that!

josejlm2 commented 3 years ago

Hi, I recently stumbled upon this project and I believe I might be able to help with this part. What exactly are you looking for? Docker setup for easy deployment in production and development or are you also looking for CI/CD with GitHub?

bhj commented 3 years ago

Hey @josejlm2, sorry for the delay and thank you! We have a number of users running Synology boxes (amd64) and Raspberry Pis (arm32) so having Docker images for those archs would be a great start. Might as well throw in arm64 while we're at it. I guess this can be achieved with a manifest list, but I'm a n00b when it comes to Docker right now. Not too concerned with GitHub CI at the moment; being able to reliably build that multi-arch image from a development machine (macOS in my case) would be amazing.

No pressure at all and any help is appreciated, even if it's just a nudge in the right direction. Thanks again!

drewschbag commented 3 years ago

I'm not a developer and this is my first time posting on github but here's the dockerfile I used to build and deploy this project inside a container

FROM node:16

#create directory
WORKDIR /app

# Install app dependencies
RUN npm uninstall node-pre-gyp --save
RUN npm install @mapbox/node-pre-gyp --save
RUN npm i -g karaoke-forever

# If you are building your code for production
RUN npm ci --only=production && npm cache clean --force

#expose server port
EXPOSE 3000

#start server at dedicated port
CMD karaoke-forever-server -p 3000
bhj commented 3 years ago

Hey @drewschbag, big thanks and stellar first post! And yes, one of the pre-reqs for v1.0 is an updated sqlite3 which should use an updated node-pre-gyp so you hopefully won't have to mess around with that. Once v1.0 is out the door I definitely plan to focus on the packaging options. Thanks again!

Deastrom commented 2 years ago

I managed to get a docker setup working in my fork, but i'm running into config issues. an expectation of docker images is that i should be able to either mount a config file or set env vars to get a system setup the way i'd like it, but much of the config is either in the database or set in the javascript in ways i don't quite understand (tried editing server/Prefs/Prefs.js , but ran into some clobbering issues in the logic which is just a symptom of me not fully understanding the codebase yet)

but, anyway, the biggest hiccup i ran into is database persistence and having to volume map my whole codebase to get it... so i modified the server/lib/cli.js file to look for an env variable for KF_SERVER_PATH_DATA and set that in my docker-compose.

here's my work on that, https://github.com/Deastrom/karaoke-forever/commit/630b78e055a1f64b879df372c7cff74cc2cc816d

i am forking from gazugafan's fork to get the youtube-dl aspects so you can ignore references to ffmpeg and tmp...

The codeblocks below should be able to get you something working, but the config search paths may need some work in the codebase

dockerfile

FROM node:12-bullseye

USER node

WORKDIR /usr/karaoke

COPY . .

RUN npm install \
 && npm run build 

EXPOSE 3000

ENTRYPOINT [ "node", "server/main.js", "-p 3000" ]

docker-compose.yml

---
version: "3.9"
services:
  karaoke:
    build: .
    ports:
      - "3000:3000"
    environment:
      KF_SERVER_PATH_DATA: /usr/karaoke/data
      NODE_OPTIONS: --max_old_space_size=2048
    volumes:
      - ./data:/usr/karaoke/data:rw
Deastrom commented 2 years ago

I ran into an issue building this on my pi... I found this other issue https://github.com/mapbox/node-sqlite3#source-install which led me to the following dockerfile

FROM node:14-bullseye

RUN apt-get update \
 && apt-get install -y make g++ gcc libsqlite3-dev

WORKDIR /usr/karaoke

COPY . .

RUN npm install sqlite3 --build-from-source --sqlite=/usr \
 && npm install\
 && npm run build

EXPOSE 3000

ENTRYPOINT [ "node", "server/main.js", "-p 3000", "--scan" ]
bhj commented 2 years ago

Hey, I have a pre-release image available and feedback would be most helpful. If you're able to give it a spin, hit me up in #dev on Discord. Thanks all!

bhj commented 2 years ago

There is now an official Docker repo. Thank you to everyone who contributed and tested!