Compare commits

..

17 Commits

Author SHA1 Message Date
Isaac Abadi
ab5cd409bb Attempt to reduce docker image size 2022-05-05 03:04:30 -04:00
Isaac Abadi
e0509e8091 Merge branch 'master' of https://github.com/Tzahi12345/YoutubeDL-Material into docker-ubuntu 2022-05-05 03:03:44 -04:00
Tzahi12345
83a9d93ce5 Merge pull request #602 from Tzahi12345/heroku-fixes-and-repo-cleanup
Various bug fixes and heroku improvements
2022-05-05 02:47:45 -04:00
Isaac Abadi
2707b09627 Merge branch 'db-bug-fixes' of https://github.com/Tzahi12345/YoutubeDL-Material into heroku-fixes-and-repo-cleanup 2022-05-05 02:36:00 -04:00
Isaac Abadi
8118906b0a Binary path is now confirmed for linux, solves #601 2022-05-05 02:31:28 -04:00
Isaac Abadi
2ad42ebf27 Fixed issue where python couldn't be found 2022-05-05 02:29:31 -04:00
Isaac Abadi
2b3490e52c Updated heroku dockerfile 2022-05-05 01:08:43 -04:00
Isaac Abadi
55fd60acd3 Merge branch 'master' of https://github.com/Tzahi12345/YoutubeDL-Material into heroku-fixes-and-repo-cleanup 2022-05-05 01:00:35 -04:00
Isaac Abadi
0c1568b38d Renamed postbuild.mjs to postbuild.js 2022-04-30 23:30:56 -04:00
Isaac Abadi
f8a0d14968 Updated Dockerfile to support ubuntu 2022-04-30 17:17:07 -04:00
Isaac Abadi
f5894e6bc0 apk add -> apt-get 2022-04-30 13:50:41 -04:00
Isaac Abadi
f205f8e58e Switched from alpine to ubuntu 2022-04-30 13:38:26 -04:00
Isaac Abadi
02e683add9 Cleaned up unused files 2021-09-21 22:35:49 -06:00
Isaac Abadi
d90b2d3687 Added back stack field in app.json 2021-09-21 21:01:53 -06:00
Isaac Abadi
32b68033e8 Removed stack field from app.json 2021-09-21 21:01:01 -06:00
Isaac Abadi
08027a5c0b Added run statement to heroku.yml 2021-09-21 20:49:38 -06:00
Isaac Abadi
25aac19cfb Replaced procfile with heroku.yml, added heroku-only Dockerfile and updated app.json 2021-09-21 20:33:42 -06:00
12 changed files with 87 additions and 45 deletions

View File

@@ -2,8 +2,9 @@ FROM ubuntu:22.04 AS ffmpeg
ENV DEBIAN_FRONTEND=noninteractive
COPY docker-build.sh .
RUN sh ./docker-build.sh
RUN apt-get update && apt-get install -y software-properties-common
RUN add-apt-repository ppa:savoury1/ffmpeg4
RUN add-apt-repository ppa:savoury1/ffmpeg5 && apt-get update && apt-get install -y ffmpeg
#--------------# Stage 2
@@ -48,7 +49,8 @@ RUN apt-get update && apt-get -y install \
python2 \
python3 \
gosu \
atomicparsley && \
atomicparsley \
--no-install-recommends && \
apt-get install -f && \
apt-get autoremove --purge && \
apt-get autoremove && \
@@ -64,9 +66,12 @@ RUN npm config set strict-ssl false && \
npm install pm2 -g && \
npm install && chown -R $UID:$GID ./
# needed for ubuntu, see #596
RUN ln -s /usr/bin/python3 /usr/bin/python
COPY --chown=$UID:$GID --from=frontend [ "/build/backend/public/", "/app/public/" ]
COPY --chown=$UID:$GID [ "/backend/", "/app/" ]
EXPOSE 17442
ENTRYPOINT [ "/app/entrypoint.sh" ]
# ENTRYPOINT [ "/app/entrypoint.sh" ]
CMD [ "pm2-runtime", "pm2.config.js" ]

2
Dockerfile.heroku Normal file
View File

@@ -0,0 +1,2 @@
FROM tzahi12345/youtubedl-material:nightly
CMD [ "pm2-runtime", "pm2.config.js" ]

View File

@@ -1 +0,0 @@
web: npm start --prefix backend

View File

@@ -2,6 +2,7 @@
"name": "YoutubeDL-Material",
"description": "An open-source and self-hosted YouTube downloader based on Google's Material Design specifications.",
"repository": "https://github.com/Tzahi12345/YoutubeDL-Material",
"stack": "container",
"logo": "https://i.imgur.com/GPzvPiU.png",
"keywords": ["youtube-dl", "youtubedl-material", "nodejs"]
}

View File

@@ -249,14 +249,6 @@ async function startServer() {
});
}
async function restartServer(is_update = false) {
logger.info(`${is_update ? 'Update complete! ' : ''}Restarting server...`);
// the following line restarts the server through nodemon
fs.writeFileSync(`restart${is_update ? '_update' : '_general'}.json`, 'internal use only');
process.exit(1);
}
async function updateServer(tag) {
// no tag provided means update to the latest version
if (!tag) {
@@ -297,7 +289,7 @@ async function updateServer(tag) {
updating: true,
'details': 'Update complete! Restarting server...'
}
restartServer(true);
utils.restartServer(true);
}, err => {
logger.error(err);
updaterStatus = {
@@ -676,6 +668,7 @@ async function getUrlInfos(url) {
async function startYoutubeDL() {
// auto update youtube-dl
youtubedl_api.verifyBinaryExistsLinux();
const update_available = await youtubedl_api.checkForYoutubeDLUpdate();
if (update_available) await youtubedl_api.updateYoutubeDL(update_available);
}
@@ -764,7 +757,7 @@ app.get('/api/versionInfo', (req, res) => {
app.post('/api/restartServer', optionalJwt, (req, res) => {
// delayed by a little bit so that the client gets a response
setTimeout(() => {restartServer()}, 100);
setTimeout(() => {utils.restartServer()}, 100);
res.send({success: true});
});
@@ -1802,6 +1795,7 @@ app.post('/api/updateTaskData', optionalJwt, async (req, res) => {
app.post('/api/getDBBackups', optionalJwt, async (req, res) => {
const backup_dir = path.join('appdata', 'db_backup');
fs.ensureDirSync(backup_dir);
const db_backups = [];
const candidate_backups = await utils.recFindByExt(backup_dir, 'bak', null, [], false);

View File

@@ -415,6 +415,14 @@ async function fetchFile(url, path, file_label) {
});
}
async function restartServer(is_update = false) {
logger.info(`${is_update ? 'Update complete! ' : ''}Restarting server...`);
// the following line restarts the server through nodemon
fs.writeFileSync(`restart${is_update ? '_update' : '_general'}.json`, 'internal use only');
process.exit(1);
}
// adds or replaces args according to the following rules:
// - if it already exists and has value, then replace both arg and value
// - if already exists and doesn't have value, ignore
@@ -491,6 +499,7 @@ module.exports = {
wait: wait,
checkExistsWithTimeout: checkExistsWithTimeout,
fetchFile: fetchFile,
restartServer: restartServer,
injectArgs: injectArgs,
File: File
}

View File

@@ -6,6 +6,8 @@ const utils = require('./utils');
const CONSTS = require('./consts');
const config_api = require('./config.js');
const OUTDATED_VERSION = "2020.00.00";
const is_windows = process.platform === 'win32';
const download_sources = {
@@ -31,7 +33,7 @@ exports.checkForYoutubeDLUpdate = async () => {
let current_app_details_exists = fs.existsSync(CONSTS.DETAILS_BIN_PATH);
if (!current_app_details_exists) {
logger.warn(`Failed to get youtube-dl binary details at location '${CONSTS.DETAILS_BIN_PATH}'. Generating file...`);
fs.writeJSONSync(CONSTS.DETAILS_BIN_PATH, {"version":"2020.00.00", "downloader": default_downloader});
fs.writeJSONSync(CONSTS.DETAILS_BIN_PATH, {"version": OUTDATED_VERSION, "downloader": default_downloader});
}
let current_app_details = JSON.parse(fs.readFileSync(CONSTS.DETAILS_BIN_PATH));
let current_version = current_app_details['version'];
@@ -86,6 +88,18 @@ exports.updateYoutubeDL = async (latest_update_version) => {
await download_sources[default_downloader]['func'](latest_update_version);
}
exports.verifyBinaryExistsLinux = () => {
const details_json = fs.readJSONSync(CONSTS.DETAILS_BIN_PATH);
if (!is_windows && details_json && details_json['path'].includes('.exe')) {
details_json['path'] = 'node_modules/youtube-dl/bin/youtube-dl';
details_json['exec'] = 'youtube-dl';
details_json['version'] = OUTDATED_VERSION;
fs.writeJSONSync(CONSTS.DETAILS_BIN_PATH, details_json);
utils.restartServer();
}
}
async function downloadLatestYoutubeDLBinary(new_version) {
const file_ext = is_windows ? '.exe' : '';

View File

@@ -1,28 +0,0 @@
-----BEGIN PRIVATE KEY-----
MIIEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwggSjAgEAAoIBAQDMX9Wk5SM5cIfY
6ReKX3ybY1rsbNbOzG8ceN7yyeXB0mor8pVsX1MOna2HewOyBuaaYNJRO4tJBxic
7a8zQErfgHL/i/QrVvVCpfJ7xKvq6zij5NYoqd/FBUwawqjeH5/voIcAp9z5Vmsr
kL0sxJUKy6b4IWNp3noU7Nvq2RwxnXQbKDhz8FrX6oQAnDC6gsG5a2OSPsaE4oqw
6nmonORJypmpP5hqyHY8ffXBT2lAxjHT7OnYbaCBe2TQP8+rH6rDBOhjVNtUJ089
ocTQL6LtQEPkcF4yKJmtcOwHl8OPGZs5l9i8xb4j9RuSPkm2lbzZX8sOsdGGoqJZ
q68nYhsHAgMBAA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ZDZAoGAWa62QJChE86xQGP1MrL2
SbIzw3cfeP5xdQ3MKldJiy5IkbMR7Z13WZ7FwvPTy0g/onLHD1rqlm1kUMsGRHpD
5vH06PNpKXQ6x8BYaRGtE6P39jLycO/X+WK/lYTrWo1bR+mGCebDh4B5XrwT3gI6
x4Gvz134pZCTyQCf5JCwbQs=
-----END PRIVATE KEY-----

3
heroku.yml Normal file
View File

@@ -0,0 +1,3 @@
build:
docker:
web: Dockerfile.heroku

View File

@@ -6,7 +6,7 @@
"ng": "ng",
"start": "ng serve",
"build": "ng build --configuration production",
"prebuild": "node src/postbuild.mjs",
"prebuild": "node src/postbuild.js",
"heroku-postbuild": "npm install --prefix backend",
"test": "ng test",
"lint": "ng lint",

43
src/postbuild.js Normal file
View File

@@ -0,0 +1,43 @@
const fs = require('fs-extra');
const path = require('path');
const xliffToJSON = require('xliff-to-json');
async function recFindByExt(base,ext,files,result)
{
files = files || (await fs.readdir(base))
result = result || []
for (const file of files) {
var newbase = path.join(base,file)
if ( (await fs.stat(newbase)).isDirectory() )
{
result = await recFindByExt(newbase,ext,await fs.readdir(newbase),result)
}
else
{
if ( file.substr(-1*(ext.length+1)) == '.' + ext )
{
result.push(newbase)
}
}
}
return result
}
// outputs array of supported locales
async function createLocalizationJSON() {
xliffToJSON.convert('src/assets/i18n');
const files = await recFindByExt(path.join('src', 'assets', 'i18n'), 'json');
const locales = [];
for (let i = 0; i < files.length; i++) {
const file = path.basename(files[i]);
const file_parts = file.split('.');
locales.push(file_parts[1]);
}
fs.unlinkSync('src/assets/i18n/messages.en.json');
fs.writeJSONSync('src/assets/i18n/supported_locales.json', {supported_locales: locales});
}
createLocalizationJSON();