Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add simple Docker integration #2569

Open
wants to merge 7 commits into
base: master
Choose a base branch
from

Conversation

michaelfeinbier
Copy link
Contributor

Similar to https://github.com/iptv-org/epg/pull/2488/files this is a working, slim Dockerfile configuration to run the script inside docker.
I made a small change on the script itself to accept also environment vars for the grab script instead of providing options. (e.g. you can use now SITE=example.com npm run grab instead of npm run grab --- --site=example.com) This is not only a convenient feature but it helps also dramatically to configure the docker container accordingly.

I did not yet include some sort of GitHub Action to build and publish a ready-to-use image but if that's something that you guys want I can also add that (I will do it anyways in my fork of the repo)

@jansohn
Copy link

jansohn commented Jan 5, 2025

I've just tested this (first time epg user) and I have two remarks:

  • the container (and the process) should not run as the root user in my opinion
  • when using the one-off run and specifying the CHANNELS environment variable with an absolute path it seems to swallow the leading slash (might be unrelated to this PR)

Command:

docker run --rm -e CHANNELS=/build/channels.xml -v "${PWD}/channels.xml:/build/channels.xml" -v "${PWD}:/build/public" epg

Output:

2025-01-05T22:26:40: PM2 log: Launching in no daemon mode
2025-01-05T22:26:40: PM2 log: App [grab:0] starting in -fork mode-
2025-01-05T22:26:40: PM2 log: App [grab:0] online
> grab
> npx tsx scripts/commands/epg/grab.ts
starting...
config:
  output: /build/public/guide.xml
  maxConnections: 5
  gzip: true
  channels: /build/channels.xml
loading channels...
node:internal/process/promises:394
    triggerUncaughtException(err, true /* fromPromise */);
    ^
[Error: ENOENT: no such file or directory, open 'build/channels.xml'] {
  errno: -2,
  code: 'ENOENT',
  syscall: 'open',
  path: 'build/channels.xml'
}
Node.js v22.12.0
2025-01-05T22:26:41: PM2 log: App [grab:0] exited with code [1] via signal [SIGINT]
2025-01-05T22:26:46: PM2 log: 0 application online, retry = 3
2025-01-05T22:26:48: PM2 log: 0 application online, retry = 2
2025-01-05T22:26:50: PM2 log: 0 application online, retry = 1
2025-01-05T22:26:52: PM2 log: 0 application online, retry = 0
2025-01-05T22:26:52: PM2 log: PM2 successfully stopped

@michaelfeinbier
Copy link
Contributor Author

Hey @jansohn
thanks for your feedback! Regarding the non-root user you are right - it should indeed not run as root. I pushed a fix. If you want to try out a pre-build image of this branch, you can find it at docker pull ghcr.io/michaelfeinbier/epg:docker-action
@BellezaEmporium @freearhey if you wanna have a look at how a GitHub Action for building this automatically would look like have a look here: https://github.com/michaelfeinbier/epg/actions/runs/12640244696/workflow

Regarding your problem with the absolute channel path: This seems to be an issue with the script itself, because also giving an absolute channel path directly leads to the same issue:

npm run grab --- --channels=/Users/michael/Projects/epg/channels.
xml

> grab
> npx tsx scripts/commands/epg/grab.ts --channels=/Users/michael/Projects/epg/channels.xml

starting...
config:
  output: guide.xml
  maxConnections: 5
  gzip: false
  channels: /Users/michael/Projects/epg/channels.xml
loading channels...
node:internal/process/promises:289
            triggerUncaughtException(err, true /* fromPromise */);
            ^

[Error: ENOENT: no such file or directory, open 'Users/michael/Projects/epg/channels.xml'] {
  errno: -2,
  code: 'ENOENT',
  syscall: 'open',
  path: 'Users/michael/Projects/epg/channels.xml'
}

Node.js v20.14.0

You should maybe create a dedicated bug ticket for that :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants