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

Patch 2025.01.2 #2573

Draft
wants to merge 30 commits into
base: master
Choose a base branch
from
Draft

Patch 2025.01.2 #2573

wants to merge 30 commits into from

Conversation

freearhey
Copy link
Collaborator

@freearhey freearhey commented Jan 10, 2025

Changes:

Script tests:

npm test --- commands

> test
> run-script-os commands


> test:default
> TZ=Pacific/Nauru npx jest --runInBand commands

 PASS  tests/commands/epg/grab.test.ts (18.031 s)
 PASS  tests/commands/channels/lint.test.ts (6.041 s)
 PASS  tests/commands/channels/validate.test.ts
 PASS  tests/commands/channels/editor.test.ts
 PASS  tests/commands/sites/update.test.ts
 PASS  tests/commands/api/generate.test.ts
 PASS  tests/commands/channels/parse.test.ts

Test Suites: 7 passed, 7 total
Tests:       16 passed, 16 total
Snapshots:   0 total
Time:        39.308 s
Ran all test suites matching /commands/i

Test build:

docker build -t iptv-org/epg --no-cache --build-arg GIT_BRANCH=patch-2025.01.2 .
[+] Building 78.7s (8/8) FINISHED                                                        
 => [internal] load build definition from Dockerfile                                0.0s
 => => transferring dockerfile: 37B                                                 0.0s
 => [internal] load .dockerignore                                                   0.0s
 => => transferring context: 2B                                                     0.0s
 => [internal] load metadata for docker.io/library/node:22-alpine                   1.7s
 => [auth] library/node:pull token for registry-1.docker.io                         0.0s
 => [1/3] FROM docker.io/library/node:22-alpine@sha256:f2dc6eea95f787e25f173ba9904  0.0s
 => CACHED [2/3] WORKDIR /epg                                                       0.0s
 => [3/3] RUN apk update     && apk upgrade --no-cache     && apk add --no-cache   61.3s
 => exporting to image                                                             15.6s
 => => exporting layers                                                            15.5s
 => => writing image sha256:8b8b9f1a61ac15d857e6faee9232e5acddc70576927992be875c3d  0.0s 
 => => naming to docker.io/iptv-org/epg                                             0.0s 

Test run (using SITE and CLANG variables):

docker run -p 3000:3000 -e SITE=allente.dk -e CLANG=sv iptv-org/epg
2025-01-18T22:02:55: PM2 log: Launching in no daemon mode
2025-01-18T22:02:55: PM2 log: App [serve:0] starting in -fork mode-
2025-01-18T22:02:55: PM2 log: App [grab:1] starting in -fork mode-
2025-01-18T22:02:55: PM2 log: App [serve:0] online
2025-01-18T22:02:55: PM2 log: App [grab:1] online
> grab
> npx tsx scripts/commands/epg/grab.ts --site=allente.dk --lang=sv --output=public/guide.xml
 INFO  Accepting connections at http://localhost:3000
starting...
config:
  output: public/guide.xml
  maxConnections: 1
  gzip: false
  site: allente.dk
  lang: sv
loading channels...
  found 1 channel(s)
run:
  [1/2] allente.dk (sv) - TV4.se - Jan 18, 2025 (19 programs)
  [2/2] allente.dk (sv) - TV4.se - Jan 19, 2025 (24 programs)
  saving to "public/guide.xml"...
  done in 00h 00m 01s
2025-01-18T22:03:00: PM2 log: App [grab:1] exited with code [0] via signal [SIGINT]
 HTTP  1/18/2025 10:03:06 PM 172.17.0.1 GET /
 HTTP  1/18/2025 10:03:06 PM 172.17.0.1 Returned 200 in 56 ms
 HTTP  1/18/2025 10:03:11 PM 172.17.0.1 GET /guide.xml

Test run (using custom channel list):

docker run -p 3000:3000 -v /Users/Arhey/Code/iptv-org/epg/channels.xml:/epg/channels.xml iptv-org/epg
2025-01-18T22:00:56: PM2 log: Launching in no daemon mode
2025-01-18T22:00:56: PM2 log: App [serve:0] starting in -fork mode-
2025-01-18T22:00:56: PM2 log: App [grab:1] starting in -fork mode-
2025-01-18T22:00:56: PM2 log: App [serve:0] online
2025-01-18T22:00:56: PM2 log: App [grab:1] online
> grab
> npx tsx scripts/commands/epg/grab.ts --channels=channels.xml --output=public/guide.xml
 INFO  Accepting connections at http://localhost:3000
starting...
config:
  output: public/guide.xml
  maxConnections: 1
  gzip: false
  channels: channels.xml
loading channels...
  found 1 channel(s)
run:
  [1/1] chada.ma (fr) - ChadaTV.ma - Jan 18, 2025 (11 programs)
  saving to "public/guide.xml"...
  done in 00h 00m 03s
2025-01-18T22:01:03: PM2 log: App [grab:1] exited with code [0] via signal [SIGINT]
 HTTP  1/18/2025 10:01:13 PM 172.17.0.1 GET /guide.xml
 HTTP  1/18/2025 10:01:13 PM 172.17.0.1 Returned 304 in 43 ms

@BellezaEmporium
Copy link
Contributor

@michaelfeinbier, @tohenk please test the Dockerfile and say if everything's good on your side.

@michaelfeinbier
Copy link
Contributor

While the Dockerfile in this PR seems valid, I would not recommend using it this way. The image here has too many unnecessary dependencies like git. I also don't understand what's the benefit of cloning the repo into the image here. To build the Dockerfile locally you already need to have checked out the repo - so I don't see value in checking it out again inside the image.
Also there is no way to configure the script without rebuilding the whole docker image since it's always expecting a specific channel.xml at a fixed path. Ideally the image is a static one and can be used with pure configuration
I would not use this image in my stack to be honest.

@tohenk
Copy link
Collaborator

tohenk commented Jan 11, 2025

For me, I even don't need to build the Docker image. My use case is described as:

This docker compose created with concept of plug and forget, once the configuration is satisfied, start docker compose then forget it. The guide will always be built based on latest fix available on EPG site.

So, everything related to EPG is unattended, whether one day, one month, or one year, I don't need to restart the Docker except if there's something broken.

@freearhey
Copy link
Collaborator Author

The image here has too many unnecessary dependencies like git.

The image has 3 dependencies: tzdata (to set timzones), git (to clone the repository), bash (to run commands inside the container). And the git is deleted at the end of the build: https://github.com/iptv-org/epg/blob/patch-2025.01.2/Dockerfile#L17

I also don't understand what's the benefit of cloning the repo into the image here.

This way we can be sure that the user is using the latest version of the scripts when building the image.

To build the Dockerfile locally you already need to have checked out the repo

You don't need to download the entire repository to build the image, you just need a copy of the Dockerfile.

there is no way to configure the script without rebuilding the whole docker image

All configuration happens at docker run:

docker run \
-p 5000:3000 \
-v /path/to/channels.xml:/epg/channels.xml \
-e CRON="0 0,12 * * *" \
-e MAX_CONNECTIONS=10 \
-e GZIP=true \
-e DAYS=14 \
-e TIMEOUT=5 \
-e DELAY=2 \
iptv-org/epg

so you can run as many containers as you want with different channels.xml and configs from a single image.

@michaelfeinbier
Copy link
Contributor

Hey @freearhey
thanks for the explanations - I think I get the idea. However I think that's not how most people would use this Dockerfile. I would think they either clone the repo and build from there or - that's what I would prefer - use an already pre-built docker image that is pushed from this repo to either hub.docker.com or ghcr.io and just pull the image from there (thats' btw how i do it in my fork here: https://github.com/michaelfeinbier/epg/blob/docker-action/.github/workflows/docker.yml and here: https://github.com/michaelfeinbier/epg/pkgs/container/epg)

However, your approach here will work - only change request I'd had then would be to also use SITE as ENV var so that instead providing a separate channel.xml I could directly use site configs.
Beside that - let's merge it. It will work :)

@freearhey
Copy link
Collaborator Author

Added the ability to use SITE and CLANG (LANG is already used by Node.js) variables.

@freearhey freearhey marked this pull request as ready for review January 19, 2025 23:36
@freearhey freearhey marked this pull request as draft January 24, 2025 18:06
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.

4 participants