update to latest version
Build and Push Docker Images / build-and-push (push) Successful in 2m4s

This commit is contained in:
2025-04-19 21:28:41 +02:00
parent 1b3676371c
commit 0234bce8ce
2 changed files with 89 additions and 24 deletions
+5 -5
View File
@@ -6,14 +6,14 @@ RUN apk add --no-cache git curl unzip coreutils
# Set working directory
WORKDIR /app
# Download and extract the EPG repository
RUN curl -L https://github.com/iptv-org/epg/archive/refs/tags/2023.12.1.zip -o epg.zip && \
unzip epg.zip && \
mv epg-2023.12.1/* ./ && \
rm -rf epg.zip epg-2023.12.1 && \
# Clone the latest EPG repository code
RUN git clone --depth 1 -b master https://github.com/iptv-org/epg.git . && \
npm install && \
npm install pm2 serve -g
# Create output directory
RUN mkdir -p /app/output
# Copy entrypoint script
COPY entrypoint.sh /app/entrypoint.sh
RUN chmod +x /app/entrypoint.sh
+82 -17
View File
@@ -30,22 +30,64 @@ grab_epg() {
eval $cmd
}
# Function to grab EPG data for all sites
# Function to grab EPG data for all sites concurrently
grab_all_sites() {
# Split the SITES environment variable by comma - POSIX sh compatible
echo "$SITES" | tr ',' '\n' >/tmp/sites.txt
# Process each site
# Create a temporary script to run all grab commands
cat >/tmp/grab_all.sh <<EOL
#!/bin/sh
# Process each site concurrently
while read site; do
grab_epg "$site"
if [ -n "\$site" ]; then
(
echo "Starting grab for site: \$site"
# Build command with optional parameters
cmd="npm run grab -- --site=\$site --output=output/\${site}.xml --maxConnections=${MAX_CONNECTIONS}"
# Add optional parameters if they are set
if [ -n "${DAYS}" ]; then
cmd="\$cmd --days=${DAYS}"
fi
if [ -n "${DELAY}" ]; then
cmd="\$cmd --delay=${DELAY}"
fi
if [ -n "${LANG}" ]; then
cmd="\$cmd --lang=${LANG}"
fi
if [ "${GZIP}" = "true" ]; then
cmd="\$cmd --gzip"
fi
# Execute the command
eval \$cmd
echo "Completed grab for site: \$site"
) &
fi
done </tmp/sites.txt
# Wait for all background processes to complete
wait
echo "All EPG data grabs completed"
EOL
chmod +x /tmp/grab_all.sh
/tmp/grab_all.sh
# Clean up
rm /tmp/sites.txt
rm /tmp/sites.txt /tmp/grab_all.sh
}
# Create output directory if it doesn't exist
mkdir -p /app/output
# Initial grab
if [ -n "$SITES" ]; then
echo "Starting initial EPG data grab for all sites concurrently"
grab_all_sites
fi
@@ -53,27 +95,50 @@ fi
if [ -n "$CRON_SCHEDULE" ] && [ -n "$SITES" ]; then
echo "Setting up cron job with schedule: $CRON_SCHEDULE"
# Create a script to grab all sites
# Create a script to grab all sites concurrently
cat >/app/grab-sites.js <<EOL
#!/usr/bin/env node
const { execSync } = require('child_process');
const sites = process.env.SITES.split(',');
const { spawn } = require('child_process');
const sites = process.env.SITES.split(',').filter(site => site.trim() !== '');
console.log(\`Starting scheduled EPG grab at \${new Date().toISOString()}\`);
// Track running processes
const processes = [];
let completedCount = 0;
sites.forEach(site => {
try {
console.log(\`Grabbing EPG data for site: \${site}\`);
let cmd = \`npm run grab -- --site=\${site} --output=output/\${site}.xml --maxConnections=\${process.env.MAX_CONNECTIONS || 1}\`;
console.log(\`Starting grab for site: \${site}\`);
let cmd = 'npm';
let args = ['run', 'grab', '--', \`--site=\${site}\`, \`--output=output/\${site}.xml\`, \`--maxConnections=\${process.env.MAX_CONNECTIONS || 1}\`];
// Add optional parameters
if (process.env.DAYS) cmd += \` --days=\${process.env.DAYS}\`;
if (process.env.DELAY) cmd += \` --delay=\${process.env.DELAY}\`;
if (process.env.LANG) cmd += \` --lang=\${process.env.LANG}\`;
if (process.env.GZIP === 'true') cmd += \` --gzip\`;
if (process.env.DAYS) args.push(\`--days=\${process.env.DAYS}\`);
if (process.env.DELAY) args.push(\`--delay=\${process.env.DELAY}\`);
if (process.env.LANG) args.push(\`--lang=\${process.env.LANG}\`);
if (process.env.GZIP === 'true') args.push('--gzip');
execSync(cmd, { stdio: 'inherit' });
const process = spawn(cmd, args, { stdio: 'inherit' });
process.on('close', (code) => {
completedCount++;
if (code === 0) {
console.log(\`Successfully grabbed EPG data for site: \${site}\`);
} else {
console.error(\`Error grabbing EPG data for site: \${site}, exit code: \${code}\`);
}
if (completedCount === sites.length) {
console.log(\`Completed scheduled EPG grab at \${new Date().toISOString()}\`);
}
});
processes.push(process);
} catch (error) {
console.error(\`Error grabbing EPG data for site: \${site}\`, error);
console.error(\`Error starting EPG grab for site: \${site}\`, error);
completedCount++;
}
});
EOL
@@ -81,12 +146,12 @@ EOL
# Start the cron job
pm2 start --name epg-grabber /app/grab-sites.js --no-autorestart --cron-restart="$CRON_SCHEDULE"
pm2 logs epg-grabber &
fi
# Start the server to serve the guide files
cd /app
echo "Starting server on port 3000"
npx serve -p 3000
echo "Starting server on port 3000 to serve EPG files from /app/output"
npx serve -p 3000 /app/output &
# Keep the container running
tail -f /dev/null