Skip to content

Commit

Permalink
🔥 optimize package size
Browse files Browse the repository at this point in the history
  • Loading branch information
moisout committed Sep 16, 2020
1 parent 3ec27cc commit 1b37e64
Show file tree
Hide file tree
Showing 6 changed files with 171 additions and 363 deletions.
5 changes: 3 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
FROM node:14.8-alpine
WORKDIR /home/app
ENV NODE_ENV=production

COPY package.json yarn.lock ./
RUN yarn install --link-duplicates --ignore-optional
RUN yarn install --production --link-duplicates --ignore-optional && \
yarn modclean -n default:safe -r

COPY . .

RUN yarn build

EXPOSE 8066
ENV NODE_ENV=production

CMD ["npm", "start"]
1 change: 1 addition & 0 deletions Starting
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ViewTube in development mode
23 changes: 13 additions & 10 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,10 @@
"license": "AGPLv3",
"private": true,
"scripts": {
"start": "cross-env NODE_ENV=production node -r module-alias/register dist/server/main.js",
"build": "cross-env NODE_ENV=production npm run clean && nuxt build && tsc",
"start:local": "cross-env NODE_ENV=production && npm run start",
"start": "node -r module-alias/register dist/server/main.js",
"build:local": "cross-env NODE_ENV=production npm run build",
"build": "npm run clean && nuxt build && tsc -p tsconfig.build.json",
"serve": "cross-env NODE_ENV=development webpack --config webpack.config.js",
"test": "jest",
"db": "mongod --dbpath data",
Expand Down Expand Up @@ -37,6 +39,7 @@
"**/*": "prettier --write --ignore-unknown"
},
"dependencies": {
"@babel/core": "^7.11.6",
"@chenfengyuan/vue-qrcode": "^1.0.2",
"@nestjs/common": "^7.4.4",
"@nestjs/config": "^0.5.0",
Expand All @@ -47,9 +50,12 @@
"@nestjs/platform-express": "^7.4.4",
"@nestjs/schedule": "^0.4.0",
"@nestjs/swagger": "^4.5.12",
"@nestjs/testing": "^7.4.4",
"@nuxtjs/axios": "^5.12.2",
"@nuxtjs/style-resources": "^1.0.0",
"@nuxtjs/workbox": "^3.0.0-beta.16",
"@types/bcryptjs": "^2.4.2",
"@types/jest": "^26.0.13",
"bcryptjs": "^2.4.3",
"cache-manager": "^3.4.0",
"class-transformer": "^0.3.1",
Expand All @@ -63,10 +69,12 @@
"humanize-duration": "^3.22.0",
"jsdom": "^16.4.0",
"mini-svg-data-uri": "^1.2.3",
"modclean": "^3.0.0-beta.1",
"module-alias": "^2.2.2",
"mongoose": "^5.10.5",
"mysql": "^2.18.1",
"node-fetch": "^2.6.1",
"node-sass": "^4.14.1",
"nuxt": "^2.14.5",
"nuxt-start": "^2.14.5",
"passport": "^0.4.1",
Expand All @@ -76,10 +84,12 @@
"reflect-metadata": "^0.1.13",
"rimraf": "^3.0.2",
"rxjs": "^6.6.3",
"sass-loader": "^10.0.2",
"split-file-stream": "^1.3.0",
"svg-captcha": "^1.4.0",
"swagger-ui-express": "^4.1.4",
"tippy.js": "^6.2.6",
"typescript": "^4.0.2",
"universal-cookie": "^4.0.3",
"vue": "^2.6.12",
"vue-material-design-icons": "^4.9.0",
Expand All @@ -90,17 +100,13 @@
"ytsr": "^1.0.1"
},
"devDependencies": {
"@nestjs/cli": "^7.0.0",
"@nestjs/schematics": "^7.1.2",
"@nestjs/testing": "^7.4.4",
"@nuxtjs/eslint-config": "^3.1.0",
"@nuxtjs/eslint-module": "^2.0.0",
"@nuxtjs/style-resources": "^1.0.0",
"@types/cookie-parser": "^1.4.2",
"@types/express": "4.17.8",
"@types/fluent-ffmpeg": "^2.1.15",
"@types/humanize-duration": "^3.18.0",
"@types/jest": "^26.0.13",
"@types/module-alias": "^2.0.0",
"@types/mongoose": "^5.7.36",
"@types/node": "^14.10.2",
Expand All @@ -120,19 +126,16 @@
"eslint-plugin-nuxt": "^1.0.0",
"friendly-errors-webpack-plugin": "^1.7.0",
"husky": "^4.3.0",
"jest": "^26.2.2",
"jest": "^26.4.2",
"lint-staged": "^10.3.0",
"node-sass": "^4.14.1",
"nodemon": "^2.0.4",
"npm-run-all": "^4.1.5",
"prettier": "^2.1.2",
"sass-loader": "^10.0.2",
"supertest": "^4.0.2",
"ts-jest": "^26.3.0",
"ts-loader": "^8.0.2",
"ts-node": "^9.0.0",
"tsconfig-paths": "^3.9.0",
"typescript": "^4.0.2",
"webpack-cli": "^3.3.12",
"webpack-shell-plugin-next": "^1.2.0"
}
Expand Down
6 changes: 2 additions & 4 deletions server/.eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,11 @@ module.exports = {
],
root: true,
env: {
node: true,
jest: true
node: true
},
rules: {
'@typescript-eslint/interface-name-prefix': 'off',
'@typescript-eslint/explicit-function-return-type':
'off',
'@typescript-eslint/explicit-function-return-type': 'off',
'@typescript-eslint/no-explicit-any': 'off'
}
};
15 changes: 3 additions & 12 deletions server/app.controller.spec.ts → server/app.controller.test.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,7 @@
import { Test } from '@nestjs/testing';
import { AppController } from './app.controller';
import { AppService } from './app.service';
import {
name,
version,
author,
country
} from '../package.json';
import { name, version, author, country } from '../package.json';

describe('AppController', () => {
let appController: AppController;
Expand All @@ -19,17 +14,13 @@ describe('AppController', () => {
}).compile();

appService = moduleRef.get<AppService>(AppService);
appController = moduleRef.get<AppController>(
AppController
);
appController = moduleRef.get<AppController>(AppController);
});

describe('status', () => {
it('should return some stats about the instance', async () => {
const result = { name, version, country, author };
jest
.spyOn(appService, 'getStatus')
.mockImplementation(() => result);
jest.spyOn(appService, 'getStatus').mockImplementation(() => result);

expect(appController.getStatus()).toBe(result);
});
Expand Down
Loading

1 comment on commit 1b37e64

@moisout
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed devDependencies from docker image, had to move around some wrongly configured dependencies.
Used modclean to reduce node_modules size.
#71

Please sign in to comment.