Cleanup docker builds (#829)

* Making docker builds smaller. Fixes #828

* Running sortpack
This commit is contained in:
Dessalines 2022-10-21 15:28:18 -04:00 committed by GitHub
parent 309c93e918
commit 4983cb82b5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 36 additions and 26 deletions

View file

@ -1,11 +1,12 @@
FROM node:alpine as builder FROM node:alpine as builder
RUN apk update && apk add yarn python3 build-base gcc wget git --no-cache RUN apk update && apk add curl yarn python3 build-base gcc wget git --no-cache
RUN curl -sf https://gobinaries.com/tj/node-prune | sh
WORKDIR /usr/src/app WORKDIR /usr/src/app
# Cache deps # Cache deps
COPY package.json yarn.lock ./ COPY package.json yarn.lock ./
RUN yarn install --pure-lockfile RUN yarn install --production --ignore-scripts --prefer-offline --pure-lockfile
# Build # Build
COPY generate_translations.js \ COPY generate_translations.js \
@ -21,9 +22,18 @@ COPY .git .git
# Set UI version # Set UI version
RUN echo "export const VERSION = '$(git describe --tag)';" > "src/shared/version.ts" RUN echo "export const VERSION = '$(git describe --tag)';" > "src/shared/version.ts"
RUN yarn RUN yarn install --production --ignore-scripts --prefer-offline
RUN yarn build:prod RUN yarn build:prod
# Prune the image
RUN node-prune /usr/src/app/node_modules
RUN rm -rf ./node_modules/import-sort-parser-typescript
RUN rm -rf ./node_modules/typescript
RUN rm -rf ./node_modules/npm
RUN du -sh ./node_modules/* | sort -nr | grep '\dM.*'
FROM node:alpine as runner FROM node:alpine as runner
COPY --from=builder /usr/src/app/dist /app/dist COPY --from=builder /usr/src/app/dist /app/dist
COPY --from=builder /usr/src/app/node_modules /app/node_modules COPY --from=builder /usr/src/app/node_modules /app/node_modules

View file

@ -17,11 +17,24 @@
}, },
"repository": "https://github.com/LemmyNet/lemmy-ui", "repository": "https://github.com/LemmyNet/lemmy-ui",
"dependencies": { "dependencies": {
"@babel/plugin-proposal-decorators": "^7.18.9",
"@babel/plugin-transform-runtime": "^7.18.9",
"@babel/plugin-transform-typescript": "^7.18.8",
"@babel/preset-env": "7.19.3",
"@babel/preset-typescript": "^7.18.6",
"@babel/runtime": "^7.18.9",
"@sniptt/monads": "^0.5.10",
"@typescript-eslint/parser": "^5.31.0", "@typescript-eslint/parser": "^5.31.0",
"autosize": "^5.0.1", "autosize": "^5.0.1",
"babel-loader": "^8.2.5",
"babel-plugin-inferno": "^6.5.0",
"check-password-strength": "^2.0.7", "check-password-strength": "^2.0.7",
"choices.js": "^10.1.0", "choices.js": "^10.1.0",
"class-transformer": "^0.5.1",
"classnames": "^2.3.1", "classnames": "^2.3.1",
"clean-webpack-plugin": "^4.0.0",
"copy-webpack-plugin": "^11.0.0",
"css-loader": "^6.7.1",
"emoji-short-name": "^2.0.0", "emoji-short-name": "^2.0.0",
"express": "~4.18.1", "express": "~4.18.1",
"i18next": "^21.8.14", "i18next": "^21.8.14",
@ -34,70 +47,57 @@
"inferno-server": "^8.0.3", "inferno-server": "^8.0.3",
"isomorphic-cookie": "^1.2.4", "isomorphic-cookie": "^1.2.4",
"jwt-decode": "^3.1.2", "jwt-decode": "^3.1.2",
"lemmy-js-client": "0.17.0-rc.46",
"markdown-it": "^13.0.1", "markdown-it": "^13.0.1",
"markdown-it-container": "^3.0.0", "markdown-it-container": "^3.0.0",
"markdown-it-footnote": "^3.0.3", "markdown-it-footnote": "^3.0.3",
"markdown-it-html5-embed": "^1.0.0", "markdown-it-html5-embed": "^1.0.0",
"markdown-it-sub": "^1.0.0", "markdown-it-sub": "^1.0.0",
"markdown-it-sup": "^1.0.0", "markdown-it-sup": "^1.0.0",
"mini-css-extract-plugin": "^2.6.1",
"moment": "^2.29.4", "moment": "^2.29.4",
"node-fetch": "^2.6.1",
"reflect-metadata": "^0.1.13",
"register-service-worker": "^1.7.2", "register-service-worker": "^1.7.2",
"run-node-webpack-plugin": "^1.3.0",
"rxjs": "^7.5.6", "rxjs": "^7.5.6",
"sass": "^1.54.0", "sass": "^1.54.0",
"sass-loader": "^13.0.2",
"serialize-javascript": "^6.0.0", "serialize-javascript": "^6.0.0",
"tippy.js": "^6.3.7", "tippy.js": "^6.3.7",
"toastify-js": "^1.12.0", "toastify-js": "^1.12.0",
"tributejs": "^5.1.3", "tributejs": "^5.1.3",
"webpack": "5.74.0",
"webpack-cli": "^4.10.0",
"webpack-node-externals": "^3.0.0",
"websocket-ts": "^1.1.1" "websocket-ts": "^1.1.1"
}, },
"devDependencies": { "devDependencies": {
"@babel/core": "^7.18.9", "@babel/core": "^7.18.9",
"@babel/plugin-proposal-decorators": "^7.18.9",
"@babel/plugin-transform-runtime": "^7.18.9",
"@babel/plugin-transform-typescript": "^7.18.8",
"@babel/preset-env": "7.19.3",
"@babel/preset-typescript": "^7.18.6",
"@babel/runtime": "^7.18.9",
"@sniptt/monads": "^0.5.10",
"@types/autosize": "^4.0.0", "@types/autosize": "^4.0.0",
"@types/express": "^4.17.13", "@types/express": "^4.17.13",
"@types/node": "^18.6.2", "@types/node": "^18.6.2",
"@types/node-fetch": "^2.6.2", "@types/node-fetch": "^2.6.2",
"@types/serialize-javascript": "^5.0.1", "@types/serialize-javascript": "^5.0.1",
"@typescript-eslint/eslint-plugin": "^5.31.0", "@typescript-eslint/eslint-plugin": "^5.31.0",
"babel-loader": "^8.2.5",
"babel-plugin-inferno": "^6.5.0",
"bootstrap": "^5.2.0", "bootstrap": "^5.2.0",
"bootswatch": "^5.2.0", "bootswatch": "^5.2.0",
"class-transformer": "^0.5.1",
"clean-webpack-plugin": "^4.0.0",
"copy-webpack-plugin": "^11.0.0",
"css-loader": "^6.7.1",
"eslint": "^8.20.0", "eslint": "^8.20.0",
"eslint-plugin-inferno": "^7.31.8", "eslint-plugin-inferno": "^7.31.8",
"eslint-plugin-prettier": "^4.2.1", "eslint-plugin-prettier": "^4.2.1",
"husky": "^8.0.1", "husky": "^8.0.1",
"import-sort-style-module": "^6.0.0", "import-sort-style-module": "^6.0.0",
"lemmy-js-client": "0.17.0-rc.46",
"lint-staged": "^13.0.3", "lint-staged": "^13.0.3",
"mini-css-extract-plugin": "^2.6.1",
"node-fetch": "^2.6.1",
"prettier": "^2.7.1", "prettier": "^2.7.1",
"prettier-plugin-import-sort": "^0.0.7", "prettier-plugin-import-sort": "^0.0.7",
"prettier-plugin-organize-imports": "^3.0.0", "prettier-plugin-organize-imports": "^3.0.0",
"prettier-plugin-packagejson": "^2.2.18", "prettier-plugin-packagejson": "^2.2.18",
"reflect-metadata": "^0.1.13",
"rimraf": "^3.0.2", "rimraf": "^3.0.2",
"run-node-webpack-plugin": "^1.3.0",
"sass-loader": "^13.0.2",
"sortpack": "^2.3.0", "sortpack": "^2.3.0",
"style-loader": "^3.3.1", "style-loader": "^3.3.1",
"terser": "^5.14.2", "terser": "^5.14.2",
"typescript": "^4.8.4", "typescript": "^4.8.4",
"webpack": "5.74.0", "webpack-dev-server": "4.11.1"
"webpack-cli": "^4.10.0",
"webpack-dev-server": "4.11.1",
"webpack-node-externals": "^3.0.0"
}, },
"engines": { "engines": {
"node": ">=8.9.0" "node": ">=8.9.0"