From b6a7d408630d0711a264b980840c16b3416822ba Mon Sep 17 00:00:00 2001 From: Alex Tran Date: Sat, 5 Feb 2022 01:33:08 -0600 Subject: [PATCH] Added fluent ffmpeg --- Makefile | 6 +++--- server/Dockerfile | 6 ++++-- server/Dockerfile-minimal | 27 +++++++++++++++++++++++++-- server/package.json | 3 ++- server/src/main.ts | 1 + server/yarn.lock | 27 +++++++++++++++++++++++++++ 6 files changed, 62 insertions(+), 8 deletions(-) diff --git a/Makefile b/Makefile index e3f4b19943..7a63337100 100644 --- a/Makefile +++ b/Makefile @@ -1,5 +1,5 @@ -run_server_dev: +dev: docker-compose -f ./server/docker-compose.yml up -run_server_update: - docker-compose -f ./server/docker-compose.yml up --build -V \ No newline at end of file +dev-update: + docker-compose -f ./server/docker-compose.yml up --build -V diff --git a/server/Dockerfile b/server/Dockerfile index 4375f94978..5dc33baf0c 100644 --- a/server/Dockerfile +++ b/server/Dockerfile @@ -15,7 +15,8 @@ RUN apt-get update && apt-get install -y --fix-missing --no-install-recommends \ rsync \ software-properties-common \ unzip \ - wget + wget \ + ffmpeg # Install NodeJS RUN curl --silent --location https://deb.nodesource.com/setup_14.x | bash - @@ -54,7 +55,8 @@ RUN apt-get update && apt-get install -y --fix-missing --no-install-recommends \ rsync \ software-properties-common \ unzip \ - wget + wget \ + ffmpeg # Install NodeJS RUN curl --silent --location https://deb.nodesource.com/setup_14.x | bash - diff --git a/server/Dockerfile-minimal b/server/Dockerfile-minimal index cbe50de964..5df93e35ab 100644 --- a/server/Dockerfile-minimal +++ b/server/Dockerfile-minimal @@ -1,3 +1,6 @@ +################################## +# DEVELOPMENT +################################## FROM node:16-bullseye-slim AS development ARG DEBIAN_FRONTEND=noninteractive @@ -7,7 +10,7 @@ WORKDIR /usr/src/app COPY package.json yarn.lock ./ RUN apt-get update -RUN apt-get install gcc g++ make cmake python3 python3-pip -y +RUN apt-get install gcc g++ make cmake python3 python3-pip ffmpeg -y RUN npm i -g yarn --force @@ -17,6 +20,18 @@ COPY . . RUN yarn build +# Clean up commands +RUN apt-get autoremove -y && apt-get clean && \ + rm -rf /usr/local/src/* + +RUN apt-get clean && \ + rm -rf /var/lib/apt/lists/* + + + +################################## +# PRODUCTION +################################## FROM node:16-bullseye-slim as production ARG DEBIAN_FRONTEND=noninteractive ARG NODE_ENV=production @@ -27,7 +42,7 @@ WORKDIR /usr/src/app COPY package.json yarn.lock ./ RUN apt-get update -RUN apt-get install gcc g++ make cmake python3 python3-pip -y +RUN apt-get install gcc g++ make cmake python3 python3-pip ffmpeg -y RUN npm i -g yarn --force @@ -37,4 +52,12 @@ COPY . . COPY --from=development /usr/src/app/dist ./dist +# Clean up commands +RUN apt-get autoremove -y && apt-get clean && \ + rm -rf /usr/local/src/* + +RUN apt-get clean && \ + rm -rf /var/lib/apt/lists/* + + CMD ["node", "dist/main"] \ No newline at end of file diff --git a/server/package.json b/server/package.json index 3e65681c2f..80214501fd 100644 --- a/server/package.json +++ b/server/package.json @@ -36,12 +36,12 @@ "@tensorflow/tfjs-converter": "^3.13.0", "@tensorflow/tfjs-core": "^3.13.0", "@tensorflow/tfjs-node": "^3.13.0", - "@types/sharp": "^0.29.5", "bcrypt": "^5.0.1", "bull": "^4.4.0", "class-transformer": "^0.5.1", "class-validator": "^0.13.2", "dotenv": "^14.2.0", + "fluent-ffmpeg": "^2.1.2", "joi": "^17.5.0", "lodash": "^4.17.21", "passport": "^0.5.2", @@ -70,6 +70,7 @@ "@types/supertest": "^2.0.11", "@typescript-eslint/eslint-plugin": "^5.0.0", "@typescript-eslint/parser": "^5.0.0", + "@types/sharp": "^0.29.5", "eslint": "^8.0.1", "eslint-config-prettier": "^8.3.0", "eslint-plugin-prettier": "^4.0.0", diff --git a/server/src/main.ts b/server/src/main.ts index e82e03ac1d..84e53e342d 100644 --- a/server/src/main.ts +++ b/server/src/main.ts @@ -1,6 +1,7 @@ import { NestFactory } from '@nestjs/core'; import { NestExpressApplication } from '@nestjs/platform-express'; import { AppModule } from './app.module'; +import ffmpeg from 'fluent-ffmpeg'; async function bootstrap() { const app = await NestFactory.create(AppModule); diff --git a/server/yarn.lock b/server/yarn.lock index 834a2322dd..37be4c6066 100644 --- a/server/yarn.lock +++ b/server/yarn.lock @@ -1039,6 +1039,13 @@ "@types/qs" "*" "@types/serve-static" "*" +"@types/fluent-ffmpeg@^2.1.20": + version "2.1.20" + resolved "https://registry.yarnpkg.com/@types/fluent-ffmpeg/-/fluent-ffmpeg-2.1.20.tgz#3b5f42fc8263761d58284fa46ee6759a64ce54ac" + integrity sha512-B+OvhCdJ3LgEq2PhvWNOiB/EfwnXLElfMCgc4Z1K5zXgSfo9I6uGKwR/lqmNPFQuebNnes7re3gqkV77SyypLg== + dependencies: + "@types/node" "*" + "@types/graceful-fs@^4.1.2": version "4.1.5" resolved "https://registry.npmjs.org/@types/graceful-fs/-/graceful-fs-4.1.5.tgz" @@ -1739,6 +1746,11 @@ asap@^2.0.0: resolved "https://registry.npmjs.org/asap/-/asap-2.0.6.tgz" integrity sha1-5QNHYR1+aQlDIIu9r+vLwvuGbUY= +async@>=0.2.9: + version "3.2.3" + resolved "https://registry.yarnpkg.com/async/-/async-3.2.3.tgz#ac53dafd3f4720ee9e8a160628f18ea91df196c9" + integrity sha512-spZRyzKL5l5BZQrr/6m/SqFdBN0q3OCI0f9rjfBzCMBIP4p75P620rR3gTmaksNOhmzgdxcaxdNfMy6anrbM0g== + asynckit@^0.4.0: version "0.4.0" resolved "https://registry.npmjs.org/asynckit/-/asynckit-0.4.0.tgz" @@ -3094,6 +3106,14 @@ flatted@^3.1.0: resolved "https://registry.npmjs.org/flatted/-/flatted-3.2.4.tgz" integrity sha512-8/sOawo8tJ4QOBX8YlQBMxL8+RLZfxMQOif9o0KUKTNTjMYElWPE0r/m5VNFxTRd0NSw8qSy8dajrwX4RYI1Hw== +fluent-ffmpeg@^2.1.2: + version "2.1.2" + resolved "https://registry.yarnpkg.com/fluent-ffmpeg/-/fluent-ffmpeg-2.1.2.tgz#c952de2240f812ebda0aa8006d7776ee2acf7d74" + integrity sha1-yVLeIkD4EuvaCqgAbXd27irPfXQ= + dependencies: + async ">=0.2.9" + which "^1.1.1" + follow-redirects@^1.14.4: version "1.14.7" resolved "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.14.7.tgz" @@ -6467,6 +6487,13 @@ whatwg-url@^8.0.0, whatwg-url@^8.5.0: tr46 "^2.1.0" webidl-conversions "^6.1.0" +which@^1.1.1: + version "1.3.1" + resolved "https://registry.yarnpkg.com/which/-/which-1.3.1.tgz#a45043d54f5805316da8d62f9f50918d3da70b0a" + integrity sha512-HxJdYWq1MTIQbJ3nw0cqssHoTNU267KlrDuGZ1WYlxDStUtKUhOaJmh112/TZmHxxUfuJqPXSOm7tDyas0OSIQ== + dependencies: + isexe "^2.0.0" + which@^2.0.1: version "2.0.2" resolved "https://registry.npmjs.org/which/-/which-2.0.2.tgz"