From 1a1bdfd674970c87f6de941dcd51b0aff16156ce Mon Sep 17 00:00:00 2001 From: Max Isom Date: Tue, 17 Mar 2020 12:30:27 -0500 Subject: [PATCH] Add Dockerfile --- .dockerignore | 6 ++++++ Dockerfile | 19 +++++++++++++++++ package.json | 6 +++--- src/index.ts | 2 ++ src/services/player.ts | 2 +- yarn.lock | 48 +++++++++++++++++++++--------------------- 6 files changed, 55 insertions(+), 28 deletions(-) create mode 100644 .dockerignore create mode 100644 Dockerfile diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..bc872cb --- /dev/null +++ b/.dockerignore @@ -0,0 +1,6 @@ +node_modules +data +dist +dts +yarn-error.log +.env diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..d4f64df --- /dev/null +++ b/Dockerfile @@ -0,0 +1,19 @@ +FROM jrottenberg/ffmpeg:4.0-scratch +FROM node:13 + +# Copy ffmpeg bins +COPY --from=0 / / + +WORKDIR /usr/app + +COPY package.json . + +RUN yarn install + +COPY . . + +RUN yarn run build + +ENV DATA_DIR /data + +CMD ["yarn", "start"] diff --git a/package.json b/package.json index 808fa87..d546abf 100644 --- a/package.json +++ b/package.json @@ -31,8 +31,8 @@ "@types/spotify-web-api-node": "^4.0.1", "@types/validator": "^12.0.1", "@types/ws": "^7.2.2", - "@typescript-eslint/eslint-plugin": "^2.23.0", - "@typescript-eslint/parser": "^2.23.0", + "@typescript-eslint/eslint-plugin": "^2.24.0", + "@typescript-eslint/parser": "^2.24.0", "eslint": "^6.8.0", "eslint-config-xo": "^0.29.1", "eslint-config-xo-typescript": "^0.26.0", @@ -82,7 +82,7 @@ "spotify-uri": "^2.0.0", "spotify-web-api-node": "^4.0.0", "sqlite3": "^4.1.1", - "youtube.ts": "^0.1.0", + "youtube.ts": "^0.1.1", "ytdl-core": "^2.0.0", "ytsr": "^0.1.11" } diff --git a/src/index.ts b/src/index.ts index 2d1ea66..b2ee442 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,5 +1,6 @@ import Spotify from 'spotify-web-api-node'; import makeDir from 'make-dir'; +import path from 'path'; import container from './inversify.config'; import {TYPES} from './types'; import Bot from './bot'; @@ -16,6 +17,7 @@ const spotify = container.get(TYPES.Lib.Spotify); // Create data directories if necessary await makeDir(container.get(TYPES.Config.DATA_DIR)); await makeDir(container.get(TYPES.Config.CACHE_DIR)); + await makeDir(path.join(container.get(TYPES.Config.CACHE_DIR), 'tmp')); await sequelize.sync({}); diff --git a/src/services/player.ts b/src/services/player.ts index 2465a8a..d578704 100644 --- a/src/services/player.ts +++ b/src/services/player.ts @@ -140,7 +140,7 @@ export default class { } private getCachedPathTemp(url: string): string { - return path.join('/tmp', hasha(url)); + return path.join(this.cacheDir, 'tmp', hasha(url)); } private async isCached(url: string): Promise { diff --git a/yarn.lock b/yarn.lock index 8086009..78564a1 100644 --- a/yarn.lock +++ b/yarn.lock @@ -152,40 +152,40 @@ dependencies: "@types/node" "*" -"@typescript-eslint/eslint-plugin@^2.23.0": - version "2.23.0" - resolved "https://registry.yarnpkg.com/@typescript-eslint/eslint-plugin/-/eslint-plugin-2.23.0.tgz#aa7133bfb7b685379d9eafe4ae9e08b9037e129d" - integrity sha512-8iA4FvRsz8qTjR0L/nK9RcRUN3QtIHQiOm69FzV7WS3SE+7P7DyGGwh3k4UNR2JBbk+Ej2Io+jLAaqKibNhmtw== +"@typescript-eslint/eslint-plugin@^2.24.0": + version "2.24.0" + resolved "https://registry.yarnpkg.com/@typescript-eslint/eslint-plugin/-/eslint-plugin-2.24.0.tgz#a86cf618c965a462cddf3601f594544b134d6d68" + integrity sha512-wJRBeaMeT7RLQ27UQkDFOu25MqFOBus8PtOa9KaT5ZuxC1kAsd7JEHqWt4YXuY9eancX0GK9C68i5OROnlIzBA== dependencies: - "@typescript-eslint/experimental-utils" "2.23.0" + "@typescript-eslint/experimental-utils" "2.24.0" eslint-utils "^1.4.3" functional-red-black-tree "^1.0.1" regexpp "^3.0.0" tsutils "^3.17.1" -"@typescript-eslint/experimental-utils@2.23.0": - version "2.23.0" - resolved "https://registry.yarnpkg.com/@typescript-eslint/experimental-utils/-/experimental-utils-2.23.0.tgz#5d2261c8038ec1698ca4435a8da479c661dc9242" - integrity sha512-OswxY59RcXH3NNPmq+4Kis2CYZPurRU6mG5xPcn24CjFyfdVli5mySwZz/g/xDbJXgDsYqNGq7enV0IziWGXVQ== +"@typescript-eslint/experimental-utils@2.24.0": + version "2.24.0" + resolved "https://registry.yarnpkg.com/@typescript-eslint/experimental-utils/-/experimental-utils-2.24.0.tgz#a5cb2ed89fedf8b59638dc83484eb0c8c35e1143" + integrity sha512-DXrwuXTdVh3ycNCMYmWhUzn/gfqu9N0VzNnahjiDJvcyhfBy4gb59ncVZVxdp5XzBC77dCncu0daQgOkbvPwBw== dependencies: "@types/json-schema" "^7.0.3" - "@typescript-eslint/typescript-estree" "2.23.0" + "@typescript-eslint/typescript-estree" "2.24.0" eslint-scope "^5.0.0" -"@typescript-eslint/parser@^2.23.0": - version "2.23.0" - resolved "https://registry.yarnpkg.com/@typescript-eslint/parser/-/parser-2.23.0.tgz#f3d4e2928ff647fe77fc2fcef1a3534fee6a3212" - integrity sha512-k61pn/Nepk43qa1oLMiyqApC6x5eP5ddPz6VUYXCAuXxbmRLqkPYzkFRKl42ltxzB2luvejlVncrEpflgQoSUg== +"@typescript-eslint/parser@^2.24.0": + version "2.24.0" + resolved "https://registry.yarnpkg.com/@typescript-eslint/parser/-/parser-2.24.0.tgz#2cf0eae6e6dd44d162486ad949c126b887f11eb8" + integrity sha512-H2Y7uacwSSg8IbVxdYExSI3T7uM1DzmOn2COGtCahCC3g8YtM1xYAPi2MAHyfPs61VKxP/J/UiSctcRgw4G8aw== dependencies: "@types/eslint-visitor-keys" "^1.0.0" - "@typescript-eslint/experimental-utils" "2.23.0" - "@typescript-eslint/typescript-estree" "2.23.0" + "@typescript-eslint/experimental-utils" "2.24.0" + "@typescript-eslint/typescript-estree" "2.24.0" eslint-visitor-keys "^1.1.0" -"@typescript-eslint/typescript-estree@2.23.0": - version "2.23.0" - resolved "https://registry.yarnpkg.com/@typescript-eslint/typescript-estree/-/typescript-estree-2.23.0.tgz#d355960fab96bd550855488dcc34b9a4acac8d36" - integrity sha512-pmf7IlmvXdlEXvE/JWNNJpEvwBV59wtJqA8MLAxMKLXNKVRC3HZBXR/SlZLPWTCcwOSg9IM7GeRSV3SIerGVqw== +"@typescript-eslint/typescript-estree@2.24.0": + version "2.24.0" + resolved "https://registry.yarnpkg.com/@typescript-eslint/typescript-estree/-/typescript-estree-2.24.0.tgz#38bbc8bb479790d2f324797ffbcdb346d897c62a" + integrity sha512-RJ0yMe5owMSix55qX7Mi9V6z2FDuuDpN6eR5fzRJrp+8in9UF41IGNQHbg5aMK4/PjVaEQksLvz0IA8n+Mr/FA== dependencies: debug "^4.1.1" eslint-visitor-keys "^1.1.0" @@ -2962,10 +2962,10 @@ yn@3.1.1: resolved "https://registry.yarnpkg.com/yn/-/yn-3.1.1.tgz#1e87401a09d767c1d5eab26a6e4c185182d2eb50" integrity sha512-Ux4ygGWsu2c7isFWe8Yu1YluJmqVhxqK2cLXNQA5AcC3QfbGNpM7fu0Y8b/z16pXLnFxZYvWhd3fhBY9DLmC6Q== -youtube.ts@^0.1.0: - version "0.1.0" - resolved "https://registry.yarnpkg.com/youtube.ts/-/youtube.ts-0.1.0.tgz#9925c59dadf1b9dcf0916aec247667d6cefff6de" - integrity sha512-1JB3w8oCv2nrTv332cs2VZ5X2tWLJrVlq2m7REMGCQmHLxxr7y0yCFbM+69MzmItCgQ6ThijMYb1w2vDmzq7Uw== +youtube.ts@^0.1.1: + version "0.1.1" + resolved "https://registry.yarnpkg.com/youtube.ts/-/youtube.ts-0.1.1.tgz#be5473f58bbc869141039c2cc09038c1b0279bf0" + integrity sha512-zzOiI1WAENysG/XOx6p9ATD+nvJYkSM6DG7H41NEzEmx2yLvCyfRtBJAvJ+xPGYJE8rx7QMxg8C/ga4WXCHwag== dependencies: axios "^0.19.0" ytdl-core-discord "^1.1.0"