Add Dockerfile

This commit is contained in:
Max Isom 2020-03-17 12:30:27 -05:00
parent 426d0b0335
commit 1a1bdfd674
6 changed files with 55 additions and 28 deletions

6
.dockerignore Normal file
View file

@ -0,0 +1,6 @@
node_modules
data
dist
dts
yarn-error.log
.env

19
Dockerfile Normal file
View file

@ -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"]

View file

@ -31,8 +31,8 @@
"@types/spotify-web-api-node": "^4.0.1", "@types/spotify-web-api-node": "^4.0.1",
"@types/validator": "^12.0.1", "@types/validator": "^12.0.1",
"@types/ws": "^7.2.2", "@types/ws": "^7.2.2",
"@typescript-eslint/eslint-plugin": "^2.23.0", "@typescript-eslint/eslint-plugin": "^2.24.0",
"@typescript-eslint/parser": "^2.23.0", "@typescript-eslint/parser": "^2.24.0",
"eslint": "^6.8.0", "eslint": "^6.8.0",
"eslint-config-xo": "^0.29.1", "eslint-config-xo": "^0.29.1",
"eslint-config-xo-typescript": "^0.26.0", "eslint-config-xo-typescript": "^0.26.0",
@ -82,7 +82,7 @@
"spotify-uri": "^2.0.0", "spotify-uri": "^2.0.0",
"spotify-web-api-node": "^4.0.0", "spotify-web-api-node": "^4.0.0",
"sqlite3": "^4.1.1", "sqlite3": "^4.1.1",
"youtube.ts": "^0.1.0", "youtube.ts": "^0.1.1",
"ytdl-core": "^2.0.0", "ytdl-core": "^2.0.0",
"ytsr": "^0.1.11" "ytsr": "^0.1.11"
} }

View file

@ -1,5 +1,6 @@
import Spotify from 'spotify-web-api-node'; import Spotify from 'spotify-web-api-node';
import makeDir from 'make-dir'; import makeDir from 'make-dir';
import path from 'path';
import container from './inversify.config'; import container from './inversify.config';
import {TYPES} from './types'; import {TYPES} from './types';
import Bot from './bot'; import Bot from './bot';
@ -16,6 +17,7 @@ const spotify = container.get<Spotify>(TYPES.Lib.Spotify);
// Create data directories if necessary // Create data directories if necessary
await makeDir(container.get(TYPES.Config.DATA_DIR)); await makeDir(container.get(TYPES.Config.DATA_DIR));
await makeDir(container.get(TYPES.Config.CACHE_DIR)); await makeDir(container.get(TYPES.Config.CACHE_DIR));
await makeDir(path.join(container.get(TYPES.Config.CACHE_DIR), 'tmp'));
await sequelize.sync({}); await sequelize.sync({});

View file

@ -140,7 +140,7 @@ export default class {
} }
private getCachedPathTemp(url: string): string { 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<boolean> { private async isCached(url: string): Promise<boolean> {

View file

@ -152,40 +152,40 @@
dependencies: dependencies:
"@types/node" "*" "@types/node" "*"
"@typescript-eslint/eslint-plugin@^2.23.0": "@typescript-eslint/eslint-plugin@^2.24.0":
version "2.23.0" version "2.24.0"
resolved "https://registry.yarnpkg.com/@typescript-eslint/eslint-plugin/-/eslint-plugin-2.23.0.tgz#aa7133bfb7b685379d9eafe4ae9e08b9037e129d" resolved "https://registry.yarnpkg.com/@typescript-eslint/eslint-plugin/-/eslint-plugin-2.24.0.tgz#a86cf618c965a462cddf3601f594544b134d6d68"
integrity sha512-8iA4FvRsz8qTjR0L/nK9RcRUN3QtIHQiOm69FzV7WS3SE+7P7DyGGwh3k4UNR2JBbk+Ej2Io+jLAaqKibNhmtw== integrity sha512-wJRBeaMeT7RLQ27UQkDFOu25MqFOBus8PtOa9KaT5ZuxC1kAsd7JEHqWt4YXuY9eancX0GK9C68i5OROnlIzBA==
dependencies: dependencies:
"@typescript-eslint/experimental-utils" "2.23.0" "@typescript-eslint/experimental-utils" "2.24.0"
eslint-utils "^1.4.3" eslint-utils "^1.4.3"
functional-red-black-tree "^1.0.1" functional-red-black-tree "^1.0.1"
regexpp "^3.0.0" regexpp "^3.0.0"
tsutils "^3.17.1" tsutils "^3.17.1"
"@typescript-eslint/experimental-utils@2.23.0": "@typescript-eslint/experimental-utils@2.24.0":
version "2.23.0" version "2.24.0"
resolved "https://registry.yarnpkg.com/@typescript-eslint/experimental-utils/-/experimental-utils-2.23.0.tgz#5d2261c8038ec1698ca4435a8da479c661dc9242" resolved "https://registry.yarnpkg.com/@typescript-eslint/experimental-utils/-/experimental-utils-2.24.0.tgz#a5cb2ed89fedf8b59638dc83484eb0c8c35e1143"
integrity sha512-OswxY59RcXH3NNPmq+4Kis2CYZPurRU6mG5xPcn24CjFyfdVli5mySwZz/g/xDbJXgDsYqNGq7enV0IziWGXVQ== integrity sha512-DXrwuXTdVh3ycNCMYmWhUzn/gfqu9N0VzNnahjiDJvcyhfBy4gb59ncVZVxdp5XzBC77dCncu0daQgOkbvPwBw==
dependencies: dependencies:
"@types/json-schema" "^7.0.3" "@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" eslint-scope "^5.0.0"
"@typescript-eslint/parser@^2.23.0": "@typescript-eslint/parser@^2.24.0":
version "2.23.0" version "2.24.0"
resolved "https://registry.yarnpkg.com/@typescript-eslint/parser/-/parser-2.23.0.tgz#f3d4e2928ff647fe77fc2fcef1a3534fee6a3212" resolved "https://registry.yarnpkg.com/@typescript-eslint/parser/-/parser-2.24.0.tgz#2cf0eae6e6dd44d162486ad949c126b887f11eb8"
integrity sha512-k61pn/Nepk43qa1oLMiyqApC6x5eP5ddPz6VUYXCAuXxbmRLqkPYzkFRKl42ltxzB2luvejlVncrEpflgQoSUg== integrity sha512-H2Y7uacwSSg8IbVxdYExSI3T7uM1DzmOn2COGtCahCC3g8YtM1xYAPi2MAHyfPs61VKxP/J/UiSctcRgw4G8aw==
dependencies: dependencies:
"@types/eslint-visitor-keys" "^1.0.0" "@types/eslint-visitor-keys" "^1.0.0"
"@typescript-eslint/experimental-utils" "2.23.0" "@typescript-eslint/experimental-utils" "2.24.0"
"@typescript-eslint/typescript-estree" "2.23.0" "@typescript-eslint/typescript-estree" "2.24.0"
eslint-visitor-keys "^1.1.0" eslint-visitor-keys "^1.1.0"
"@typescript-eslint/typescript-estree@2.23.0": "@typescript-eslint/typescript-estree@2.24.0":
version "2.23.0" version "2.24.0"
resolved "https://registry.yarnpkg.com/@typescript-eslint/typescript-estree/-/typescript-estree-2.23.0.tgz#d355960fab96bd550855488dcc34b9a4acac8d36" resolved "https://registry.yarnpkg.com/@typescript-eslint/typescript-estree/-/typescript-estree-2.24.0.tgz#38bbc8bb479790d2f324797ffbcdb346d897c62a"
integrity sha512-pmf7IlmvXdlEXvE/JWNNJpEvwBV59wtJqA8MLAxMKLXNKVRC3HZBXR/SlZLPWTCcwOSg9IM7GeRSV3SIerGVqw== integrity sha512-RJ0yMe5owMSix55qX7Mi9V6z2FDuuDpN6eR5fzRJrp+8in9UF41IGNQHbg5aMK4/PjVaEQksLvz0IA8n+Mr/FA==
dependencies: dependencies:
debug "^4.1.1" debug "^4.1.1"
eslint-visitor-keys "^1.1.0" 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" resolved "https://registry.yarnpkg.com/yn/-/yn-3.1.1.tgz#1e87401a09d767c1d5eab26a6e4c185182d2eb50"
integrity sha512-Ux4ygGWsu2c7isFWe8Yu1YluJmqVhxqK2cLXNQA5AcC3QfbGNpM7fu0Y8b/z16pXLnFxZYvWhd3fhBY9DLmC6Q== integrity sha512-Ux4ygGWsu2c7isFWe8Yu1YluJmqVhxqK2cLXNQA5AcC3QfbGNpM7fu0Y8b/z16pXLnFxZYvWhd3fhBY9DLmC6Q==
youtube.ts@^0.1.0: youtube.ts@^0.1.1:
version "0.1.0" version "0.1.1"
resolved "https://registry.yarnpkg.com/youtube.ts/-/youtube.ts-0.1.0.tgz#9925c59dadf1b9dcf0916aec247667d6cefff6de" resolved "https://registry.yarnpkg.com/youtube.ts/-/youtube.ts-0.1.1.tgz#be5473f58bbc869141039c2cc09038c1b0279bf0"
integrity sha512-1JB3w8oCv2nrTv332cs2VZ5X2tWLJrVlq2m7REMGCQmHLxxr7y0yCFbM+69MzmItCgQ6ThijMYb1w2vDmzq7Uw== integrity sha512-zzOiI1WAENysG/XOx6p9ATD+nvJYkSM6DG7H41NEzEmx2yLvCyfRtBJAvJ+xPGYJE8rx7QMxg8C/ga4WXCHwag==
dependencies: dependencies:
axios "^0.19.0" axios "^0.19.0"
ytdl-core-discord "^1.1.0" ytdl-core-discord "^1.1.0"