mirror of
https://github.com/sakaljurgis/kodi-api-server.git
synced 2026-07-08 20:37:41 +00:00
dockerise server
This commit is contained in:
+21
-13
@@ -1,17 +1,25 @@
|
||||
PORT=3000
|
||||
STATIC_SERVE_FOLDER="data/static"
|
||||
LOG_FILE_REQUESTS="data/static/static_log.txt"
|
||||
DB_PATH="./data/db/db.db"
|
||||
RECENT_SEARCHES_FOLDER="./data/recent_searches"
|
||||
|
||||
STATIC_SERVE_FOLDER='/mnt/hdd/videos'
|
||||
LOG_FILE_REQUESTS_FOLDER='/mnt/hdd/videos'
|
||||
LOG_FILE_REQUESTS_NAME="static_log.txt"
|
||||
|
||||
DB_FOLDER='/mnt/hdd/videos/db'
|
||||
DB_FILENAME="db.db"
|
||||
|
||||
RECENT_SEARCHES_FOLDER="/mnt/hdd/videos/recent-searches"
|
||||
RECENT_SEARCHES_LIMIT=20
|
||||
VIDEO_FILES_FOLDERS='[
|
||||
"/home/user/videos",
|
||||
"/mnt/hdd/videos"
|
||||
]'
|
||||
|
||||
VIDEO_FILES_FOLDER='/mnt/hdd/videos' #also torrent download dir
|
||||
|
||||
VIDEO_FILES_EXT='[".mkv", ".mp4", ".avi"]'
|
||||
|
||||
PATTERNS_TO_IGNORE='["AOE1/"]' #file path patterns to ignore from video files scan
|
||||
LINKOMANIJA_USERNAME=usern
|
||||
LINKOMANIJA_PASSWORD=password
|
||||
LINKOMANIJA_PASSKEY=some123long321passkey
|
||||
TORRENT_DOWNLOAD_DIR='/mnt/hdd/videos'
|
||||
TRANSMISSION_CLIENT_HOST=192.168.1.133
|
||||
|
||||
LINKOMANIJA_USERNAME=user
|
||||
LINKOMANIJA_PASSWORD=passw
|
||||
LINKOMANIJA_PASSKEY=123pass456key789
|
||||
|
||||
TRANSMISSION_CLIENT_HOST=host.docker.internal
|
||||
TRANSMISSION_CLIENT_USER=user
|
||||
TRANSMISSION_CLIENT_PASSWORD=password
|
||||
|
||||
+17
@@ -0,0 +1,17 @@
|
||||
FROM node:18
|
||||
|
||||
RUN apt-get update
|
||||
RUN apt-get install ffmpeg -y
|
||||
|
||||
WORKDIR /srv/app
|
||||
COPY ./ /srv/app
|
||||
RUN npm install
|
||||
RUN npm run typeorm:run-migrations
|
||||
|
||||
EXPOSE $PORT
|
||||
|
||||
# serve dev
|
||||
CMD ["npm", "run", "start:dev"]
|
||||
|
||||
#serve prod
|
||||
#CMD ["npm", "run", "start"]
|
||||
@@ -0,0 +1,19 @@
|
||||
services:
|
||||
server:
|
||||
build:
|
||||
context: .
|
||||
dockerfile: ./Dockerfile
|
||||
# working_dir: /srv/app/
|
||||
volumes:
|
||||
- .:/srv/app/
|
||||
- $VIDEO_FILES_FOLDER:$VIDEO_FILES_FOLDER
|
||||
- $LOG_FILE_REQUESTS_FOLDER:/srv/data/requests-log
|
||||
- $STATIC_SERVE_FOLDER:/srv/data/static
|
||||
- $DB_FOLDER:/srv/data/db
|
||||
- $RECENT_SEARCHES_FOLDER:/srv/data/recent-searches
|
||||
env_file:
|
||||
- .env
|
||||
ports:
|
||||
- $PORT:$PORT
|
||||
extra_hosts:
|
||||
- "host.docker.internal:host-gateway"
|
||||
@@ -0,0 +1,3 @@
|
||||
**/node_modules
|
||||
**/data
|
||||
**/dist
|
||||
@@ -322,7 +322,10 @@ export class TorrentService {
|
||||
const torrId = parseInt(id);
|
||||
const result = await this.torrSeedClient
|
||||
.addTorrentById(torrId)
|
||||
.catch(() => false);
|
||||
.catch((e) => {
|
||||
console.log(e);
|
||||
return false;
|
||||
});
|
||||
|
||||
return new NotificationResponse(
|
||||
result ? 'torrent added to transmission' : 'adding failed',
|
||||
|
||||
@@ -29,7 +29,10 @@ export class TorrentSeedClient {
|
||||
return Promise.reject('torrent not found');
|
||||
}
|
||||
|
||||
const torrInfo = await this.addTorrent(torrentEntity).catch(() => null);
|
||||
const torrInfo = await this.addTorrent(torrentEntity).catch((e) => {
|
||||
console.log(e);
|
||||
return null;
|
||||
});
|
||||
|
||||
if (torrInfo) {
|
||||
await this.torrentRepository.update(
|
||||
|
||||
@@ -13,7 +13,7 @@ export class ConfigService {
|
||||
private videoFilesConfig: VideoFilesConfig = new VideoFilesConfig(this);
|
||||
private recentSearches: RecentSearchesConfig = new RecentSearchesConfig(this);
|
||||
|
||||
public getEnv(key: string): any {
|
||||
public getEnv(key: string): string {
|
||||
return process.env[key];
|
||||
}
|
||||
|
||||
|
||||
@@ -7,11 +7,14 @@ export class PathsConfig {
|
||||
}
|
||||
|
||||
public getStaticRequestsLogPath(): string {
|
||||
return this.getPathByEnvKey('LOG_FILE_REQUESTS');
|
||||
return join(
|
||||
'/srv/data/requests-log',
|
||||
this.configService.getEnv('LOG_FILE_REQUESTS_NAME'),
|
||||
);
|
||||
}
|
||||
|
||||
public getStaticFolder(): string {
|
||||
return this.getPathByEnvKey('STATIC_SERVE_FOLDER');
|
||||
return '/srv/data/static';
|
||||
}
|
||||
|
||||
public getPathByEnvKey(key: string) {
|
||||
|
||||
@@ -6,9 +6,7 @@ export class RecentSearchesConfig {
|
||||
}
|
||||
|
||||
public getRecentSearchesFolder(): string {
|
||||
return this.configService
|
||||
.getPaths()
|
||||
.getPathByEnvKey('RECENT_SEARCHES_FOLDER');
|
||||
return '/srv/data/recent-searches';
|
||||
}
|
||||
|
||||
public getRecentSearchesLimit(): number {
|
||||
|
||||
@@ -4,11 +4,12 @@ import { EntityClassOrSchema } from '@nestjs/typeorm/dist/interfaces/entity-clas
|
||||
import { TitleEntity } from '../Shared/Entity/title.entity';
|
||||
import { FileEntity } from '../Shared/Entity/file.entity';
|
||||
import { TorrentEntity } from '../Shared/Entity/torrent.entity';
|
||||
import { join } from 'path';
|
||||
|
||||
export class TypeOrmConfig {
|
||||
constructor(configService: ConfigService) {
|
||||
this.type = 'sqlite';
|
||||
this.database = configService.getEnv('DB_PATH');
|
||||
this.database = join('/srv/data/db', configService.getEnv('DB_FILENAME'));
|
||||
this.entities = [LrtCategory, TitleEntity, FileEntity, TorrentEntity];
|
||||
}
|
||||
type: 'sqlite';
|
||||
|
||||
@@ -6,7 +6,7 @@ export class VideoFilesConfig {
|
||||
}
|
||||
|
||||
public getVideoFilesFolders(): string[] {
|
||||
return JSON.parse(this.configService.getEnv('VIDEO_FILES_FOLDERS'));
|
||||
return [this.configService.getEnv('VIDEO_FILES_FOLDER')];
|
||||
}
|
||||
|
||||
public getVideoFilesExt(): string[] {
|
||||
@@ -18,17 +18,15 @@ export class VideoFilesConfig {
|
||||
}
|
||||
|
||||
public getTorrentDownloadDir(): string {
|
||||
return this.configService
|
||||
.getPaths()
|
||||
.getPathByEnvKey('TORRENT_DOWNLOAD_DIR');
|
||||
return this.configService.getEnv('VIDEO_FILES_FOLDER');
|
||||
}
|
||||
|
||||
public getTransmissionOptions() {
|
||||
return {
|
||||
host: this.configService.getEnv('TRANSMISSION_CLIENT_HOST'), // # default 'localhost'
|
||||
//port: 9091, // # default 9091
|
||||
//username: "username", // # default blank
|
||||
//password: "password", // # default blank
|
||||
username: this.configService.getEnv('TRANSMISSION_CLIENT_USER'), // # default blank
|
||||
password: this.configService.getEnv('TRANSMISSION_CLIENT_PASSWORD'), // # default blank
|
||||
//ssl: true, //# default false use https
|
||||
//url: "/my/other/url" // # default '/transmission/rpc'
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user