Merge pull request 'docker-upload-directories' (#185) from 3np/teddit:docker-upload-directories into main

Reviewed-on: https://codeberg.org/teddit/teddit/pulls/185
This commit is contained in:
teddit 2021-04-08 16:46:18 +02:00
commit aa8d3f3452
4 changed files with 12 additions and 6 deletions

View File

@ -6,8 +6,10 @@ RUN apk add ffmpeg
# Install NPM dependencies and copy the project # Install NPM dependencies and copy the project
WORKDIR /teddit WORKDIR /teddit
COPY . /teddit/ COPY . ./
RUN npm install --no-optional RUN npm install --no-optional
COPY config.js.template /teddit/config.js COPY config.js.template ./config.js
RUN find ./static/ -type d -exec chmod -R 777 {} \;
CMD npm start CMD npm start

8
app.js
View File

@ -7,7 +7,6 @@ global.ratelimit_counts = {}
global.ratelimit_timestamps = {} global.ratelimit_timestamps = {}
const pug = require('pug') const pug = require('pug')
const path = require('path')
const compression = require('compression') const compression = require('compression')
const express = require('express') const express = require('express')
const cookieParser = require('cookie-parser') const cookieParser = require('cookie-parser')
@ -53,7 +52,12 @@ const fs = require('fs')
const app = express() const app = express()
const request = require('postman-request') const request = require('postman-request')
const commons = require('./inc/commons.js')(request, fs) const commons = require('./inc/commons.js')(request, fs)
const dlAndSave = require('./inc/downloadAndSave.js')(commons) const dlAndSave = require('./inc/downloadAndSave.js')(commons);
['pics/thumbs', 'pics/flairs', 'pics/icons', 'vids']
.map(d => `./static/${d}`)
.filter(d => !fs.existsSync(d))
.forEach(d => fs.mkdirSync(d, { recursive: true }))
if(!config.https_enabled && config.redirect_http_to_https) { if(!config.https_enabled && config.redirect_http_to_https) {
console.error(`Cannot redirect HTTP=>HTTPS while "https_enabled" is false.`) console.error(`Cannot redirect HTTP=>HTTPS while "https_enabled" is false.`)

View File

@ -20,7 +20,7 @@ module.exports = function(request, fs) {
if(!error) { if(!error) {
resolve({ success: true }) resolve({ success: true })
} else { } else {
resolve({ success: false }) resolve({ success: false, error })
} }
}) })
}).catch((err) => { }).catch((err) => {

View File

@ -89,7 +89,7 @@ module.exports = function(tools) {
let temp_files = [temp_path, audio_path] let temp_files = [temp_path, audio_path]
deleteFiles(temp_files, (error) => { deleteFiles(temp_files, (error) => {
if(error) { if(error) {
console.log(`Error while deleting temporay files:`, error) console.log(`Error while deleting temporary files:`, error)
} }
}) })
resolve(final_url) resolve(final_url)