mirror of
https://iceshrimp.dev/crimekillz/trashposs
synced 2024-11-24 09:49:05 +01:00
build: ⚡ reduce container size by removing dev dependencies from final image
This change moves many of the dependencies into devDependencies, by analyzing what is used in the runtime files. Additionally, NPM and apk cache are eliminated with multi-stage builds
This commit is contained in:
parent
f31db29694
commit
eeee91dcb4
@ -1,16 +1,48 @@
|
||||
.autogen
|
||||
.github
|
||||
.travis
|
||||
.vscode
|
||||
.config
|
||||
# Visual Studio Code
|
||||
/.vscode
|
||||
!/.vscode/extensions.json
|
||||
|
||||
# Intelij-IDEA
|
||||
/.idea
|
||||
packages/backend/.idea/backend.iml
|
||||
packages/backend/.idea/modules.xml
|
||||
packages/backend/.idea/vcs.xml
|
||||
|
||||
# Node.js
|
||||
node_modules
|
||||
report.*.json
|
||||
|
||||
# Cypress
|
||||
cypress/screenshots
|
||||
cypress/videos
|
||||
|
||||
# Coverage
|
||||
coverage
|
||||
|
||||
# config
|
||||
/.config/*
|
||||
!/.config/example.yml
|
||||
!/.config/docker_example.env
|
||||
|
||||
#docker dev config
|
||||
/dev/docker-compose.yml
|
||||
|
||||
# misskey
|
||||
built
|
||||
db
|
||||
elasticsearch
|
||||
redis
|
||||
npm-debug.log
|
||||
*.pem
|
||||
run.bat
|
||||
api-docs.json
|
||||
*.log
|
||||
*.code-workspace
|
||||
.DS_Store
|
||||
files
|
||||
ormconfig.json
|
||||
packages/backend/assets/instance.css
|
||||
|
||||
# dockerignore custom
|
||||
.git
|
||||
Dockerfile
|
||||
build/
|
||||
built/
|
||||
db/
|
||||
docker-compose.yml
|
||||
elasticsearch/
|
||||
node_modules/
|
||||
redis/
|
||||
files/
|
||||
misskey-assets/
|
||||
.pnp.*
|
||||
|
19
.gitignore
vendored
19
.gitignore
vendored
@ -28,28 +28,17 @@ coverage
|
||||
/dev/docker-compose.yml
|
||||
|
||||
# misskey
|
||||
/build
|
||||
built
|
||||
/data
|
||||
/.cache-loader
|
||||
/db
|
||||
/elasticsearch
|
||||
db
|
||||
elasticsearch
|
||||
redis
|
||||
npm-debug.log
|
||||
*.pem
|
||||
run.bat
|
||||
api-docs.json
|
||||
*.log
|
||||
/redis
|
||||
*.code-workspace
|
||||
.DS_Store
|
||||
/files
|
||||
files
|
||||
ormconfig.json
|
||||
/custom
|
||||
packages/backend/assets/instance.css
|
||||
|
||||
# blender backups
|
||||
*.blend1
|
||||
*.blend2
|
||||
*.blend3
|
||||
*.blend4
|
||||
*.blend5
|
||||
|
50
Dockerfile
50
Dockerfile
@ -1,25 +1,51 @@
|
||||
FROM node:19-alpine
|
||||
ARG NODE_ENV=production
|
||||
## Install dev and compilation dependencies, build files
|
||||
FROM node:19-alpine as build
|
||||
WORKDIR /calckey
|
||||
|
||||
# Copy Files
|
||||
COPY . ./
|
||||
# Install compilation dependencies
|
||||
RUN apk add --no-cache --no-progress git alpine-sdk python3
|
||||
|
||||
# Install Dependencies
|
||||
RUN apk update
|
||||
RUN apk add git ffmpeg tini alpine-sdk python3
|
||||
# Copy only the dependency-related files first, to cache efficiently
|
||||
COPY package.json pnpm*.yaml ./
|
||||
COPY packages/backend/package.json packages/backend/package.json
|
||||
COPY packages/client/package.json packages/client/package.json
|
||||
COPY packages/sw/package.json packages/sw/package.json
|
||||
|
||||
# Configure corepack and pnpm
|
||||
RUN corepack enable
|
||||
RUN corepack prepare pnpm@latest --activate
|
||||
RUN pnpm i --frozen-lockfile
|
||||
ARG NODE_ENV=production
|
||||
|
||||
# Build project (pnp dependencies are installed)
|
||||
# Install dev mode dependencies for compilation
|
||||
RUN pnpm i --frozen-lockfile
|
||||
|
||||
# Copy in the rest of the files, to compile from TS to JS
|
||||
COPY . ./
|
||||
RUN pnpm run build
|
||||
|
||||
# Remove git files
|
||||
RUN rm -rf .git
|
||||
# Trim down the dependencies to only the prod deps
|
||||
RUN pnpm i --prod --frozen-lockfile
|
||||
|
||||
|
||||
## Runtime container
|
||||
FROM node:19-alpine
|
||||
WORKDIR /calckey
|
||||
|
||||
# Install runtime dependencies
|
||||
RUN apk add --no-cache --no-progress tini ffmpeg
|
||||
|
||||
COPY . ./
|
||||
|
||||
# Copy node modules
|
||||
COPY --from=build /calckey/node_modules /calckey/node_modules
|
||||
COPY --from=build /calckey/packages/backend/node_modules /calckey/packages/backend/node_modules
|
||||
COPY --from=build /calckey/packages/sw/node_modules /calckey/packages/sw/node_modules
|
||||
COPY --from=build /calckey/packages/client/node_modules /calckey/packages/client/node_modules
|
||||
|
||||
# Copy the finished compiled files
|
||||
COPY --from=build /calckey/built /calckey/built
|
||||
COPY --from=build /calckey/packages/backend/built /calckey/packages/backend/built
|
||||
COPY --from=build /calckey/packages/backend/assets/instance.css /calckey/packages/backend/assets/instance.css
|
||||
|
||||
RUN corepack enable
|
||||
ENTRYPOINT [ "/sbin/tini", "--" ]
|
||||
CMD [ "pnpm", "run", "migrateandstart" ]
|
||||
|
16
package.json
16
package.json
@ -32,22 +32,14 @@
|
||||
"cleanall": "pnpm run clean-all"
|
||||
},
|
||||
"resolutions": {
|
||||
"chokidar": "^3.3.1",
|
||||
"lodash": "^4.17.21"
|
||||
"chokidar": "^3.3.1"
|
||||
},
|
||||
"dependencies": {
|
||||
"@bull-board/api": "^4.10.2",
|
||||
"@bull-board/ui": "^4.10.2",
|
||||
"@tensorflow/tfjs": "^3.21.0",
|
||||
"calckey-js": "^0.0.20",
|
||||
"execa": "5.1.1",
|
||||
"gulp": "4.0.2",
|
||||
"gulp-cssnano": "2.1.3",
|
||||
"gulp-rename": "2.0.0",
|
||||
"gulp-replace": "1.1.4",
|
||||
"gulp-terser": "2.1.0",
|
||||
"js-yaml": "4.1.0",
|
||||
"long": "^5.2.1",
|
||||
"phosphor-icons": "^1.4.2",
|
||||
"seedrandom": "^3.0.5"
|
||||
},
|
||||
@ -56,6 +48,12 @@
|
||||
"@types/gulp-rename": "2.0.1",
|
||||
"cross-env": "7.0.3",
|
||||
"cypress": "10.11.0",
|
||||
"execa": "5.1.1",
|
||||
"gulp": "4.0.2",
|
||||
"gulp-cssnano": "2.1.3",
|
||||
"gulp-rename": "2.0.0",
|
||||
"gulp-replace": "1.1.4",
|
||||
"gulp-terser": "2.1.0",
|
||||
"install-peers": "^1.0.4",
|
||||
"rome": "^11.0.0",
|
||||
"start-server-and-test": "1.15.2",
|
||||
|
@ -15,8 +15,7 @@
|
||||
"test": "pnpm run mocha"
|
||||
},
|
||||
"resolutions": {
|
||||
"chokidar": "^3.3.1",
|
||||
"lodash": "^4.17.21"
|
||||
"chokidar": "^3.3.1"
|
||||
},
|
||||
"optionalDependencies": {
|
||||
"@swc/core-android-arm64": "1.3.11",
|
||||
@ -34,13 +33,10 @@
|
||||
"@peertube/http-signature": "1.7.0",
|
||||
"@redocly/openapi-core": "1.0.0-beta.120",
|
||||
"@sinonjs/fake-timers": "9.1.2",
|
||||
"@swc/cli": "^0.1.59",
|
||||
"@swc/core": "^1.3.26",
|
||||
"@syuilo/aiscript": "0.11.1",
|
||||
"@tensorflow/tfjs": "^4.2.0",
|
||||
"ajv": "8.11.2",
|
||||
"archiver": "5.3.1",
|
||||
"autobind-decorator": "2.4.0",
|
||||
"autwh": "0.1.0",
|
||||
"aws-sdk": "2.1277.0",
|
||||
"bcryptjs": "2.4.3",
|
||||
@ -68,8 +64,6 @@
|
||||
"is-svg": "4.3.2",
|
||||
"js-yaml": "4.1.0",
|
||||
"jsdom": "20.0.3",
|
||||
"json5": "2.2.3",
|
||||
"json5-loader": "4.0.1",
|
||||
"jsonld": "6.0.0",
|
||||
"jsrsasign": "10.6.1",
|
||||
"koa": "2.13.4",
|
||||
@ -83,7 +77,6 @@
|
||||
"koa-views": "7.0.2",
|
||||
"mfm-js": "0.23.2",
|
||||
"mime-types": "2.1.35",
|
||||
"mocha": "10.2.0",
|
||||
"multer": "1.4.4-lts.1",
|
||||
"nested-property": "4.0.0",
|
||||
"node-fetch": "3.3.0",
|
||||
@ -96,7 +89,6 @@
|
||||
"private-ip": "2.3.4",
|
||||
"probe-image-size": "7.2.3",
|
||||
"promise-limit": "2.7.0",
|
||||
"pug": "3.0.2",
|
||||
"punycode": "2.1.1",
|
||||
"pureimage": "0.3.15",
|
||||
"qrcode": "1.5.1",
|
||||
@ -108,13 +100,11 @@
|
||||
"rename": "1.0.4",
|
||||
"rndstr": "1.0.0",
|
||||
"rss-parser": "3.12.0",
|
||||
"s-age": "1.1.2",
|
||||
"sanitize-html": "2.8.1",
|
||||
"seedrandom": "^3.0.5",
|
||||
"semver": "7.3.8",
|
||||
"sharp": "0.31.3",
|
||||
"speakeasy": "2.0.0",
|
||||
"strict-event-emitter-types": "2.0.0",
|
||||
"stringz": "2.1.0",
|
||||
"summaly": "2.7.0",
|
||||
"syslog-pro": "1.0.0",
|
||||
@ -122,9 +112,6 @@
|
||||
"tesseract.js": "^3.0.3",
|
||||
"tinycolor2": "1.5.2",
|
||||
"tmp": "0.2.1",
|
||||
"ts-loader": "9.4.2",
|
||||
"ts-node": "10.9.1",
|
||||
"tsconfig-paths": "4.1.2",
|
||||
"twemoji-parser": "14.0.0",
|
||||
"typeorm": "0.3.11",
|
||||
"ulid": "2.3.0",
|
||||
@ -132,10 +119,11 @@
|
||||
"uuid": "9.0.0",
|
||||
"web-push": "3.5.0",
|
||||
"websocket": "1.0.34",
|
||||
"ws": "8.11.0",
|
||||
"xev": "3.0.2"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@swc/cli": "^0.1.59",
|
||||
"@swc/core": "^1.3.26",
|
||||
"@types/bcryptjs": "2.4.2",
|
||||
"@types/bull": "3.15.9",
|
||||
"@types/cbor": "6.0.0",
|
||||
@ -179,11 +167,21 @@
|
||||
"@types/web-push": "3.3.2",
|
||||
"@types/websocket": "1.0.5",
|
||||
"@types/ws": "8.5.3",
|
||||
"autobind-decorator": "2.4.0",
|
||||
"cross-env": "7.0.3",
|
||||
"eslint": "^8.31.0",
|
||||
"execa": "6.1.0",
|
||||
"json5": "2.2.3",
|
||||
"json5-loader": "4.0.1",
|
||||
"mocha": "10.2.0",
|
||||
"pug": "3.0.2",
|
||||
"strict-event-emitter-types": "2.0.0",
|
||||
"swc-loader": "^0.2.3",
|
||||
"ts-loader": "9.4.2",
|
||||
"ts-node": "10.9.1",
|
||||
"tsconfig-paths": "4.1.2",
|
||||
"typescript": "4.9.4",
|
||||
"webpack": "^5.75.0"
|
||||
"webpack": "^5.75.0",
|
||||
"ws": "8.11.0"
|
||||
}
|
||||
}
|
||||
|
@ -7,13 +7,32 @@
|
||||
"lint": "pnpm rome check \"src/**/*.{ts,vue}\""
|
||||
},
|
||||
"dependencies": {
|
||||
"@discordapp/twemoji": "14.0.2",
|
||||
|
||||
},
|
||||
"devDependencies": {
|
||||
"@rollup/plugin-alias": "3.1.9",
|
||||
"@rollup/plugin-json": "4.1.0",
|
||||
"@rollup/pluginutils": "^4.2.1",
|
||||
"@syuilo/aiscript": "0.11.1",
|
||||
"@types/escape-regexp": "0.0.1",
|
||||
"@types/glob": "8.0.0",
|
||||
"@types/gulp": "4.0.10",
|
||||
"@types/gulp-rename": "2.0.1",
|
||||
"@types/katex": "0.14.0",
|
||||
"@types/matter-js": "0.18.2",
|
||||
"@types/punycode": "2.1.0",
|
||||
"@types/seedrandom": "3.0.4",
|
||||
"@types/throttle-debounce": "5.0.0",
|
||||
"@types/tinycolor2": "1.4.3",
|
||||
"@types/uuid": "8.3.4",
|
||||
"@vitejs/plugin-vue": "4.0.0",
|
||||
"@vue/compiler-sfc": "3.2.45",
|
||||
"cross-env": "7.0.3",
|
||||
"cypress": "10.11.0",
|
||||
"rollup": "3.9.1",
|
||||
"start-server-and-test": "1.15.2",
|
||||
"typescript": "4.9.4",
|
||||
"@discordapp/twemoji": "14.0.2",
|
||||
"@syuilo/aiscript": "0.11.1",
|
||||
"autobind-decorator": "2.4.0",
|
||||
"autosize": "5.0.2",
|
||||
"blurhash": "1.1.5",
|
||||
@ -54,7 +73,6 @@
|
||||
"tsc-alias": "1.8.2",
|
||||
"tsconfig-paths": "4.1.2",
|
||||
"twemoji-parser": "14.0.0",
|
||||
"typescript": "4.9.4",
|
||||
"uuid": "9.0.0",
|
||||
"vanilla-tilt": "1.8.0",
|
||||
"vite": "^4.0.4",
|
||||
@ -63,22 +81,5 @@
|
||||
"vue-plyr": "^7.0.0",
|
||||
"vue-prism-editor": "2.0.0-alpha.2",
|
||||
"vuedraggable": "4.1.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/escape-regexp": "0.0.1",
|
||||
"@types/glob": "8.0.0",
|
||||
"@types/gulp": "4.0.10",
|
||||
"@types/gulp-rename": "2.0.1",
|
||||
"@types/katex": "0.14.0",
|
||||
"@types/matter-js": "0.18.2",
|
||||
"@types/punycode": "2.1.0",
|
||||
"@types/seedrandom": "3.0.4",
|
||||
"@types/throttle-debounce": "5.0.0",
|
||||
"@types/tinycolor2": "1.4.3",
|
||||
"@types/uuid": "8.3.4",
|
||||
"cross-env": "7.0.3",
|
||||
"cypress": "10.11.0",
|
||||
"rollup": "3.9.1",
|
||||
"start-server-and-test": "1.15.2"
|
||||
}
|
||||
}
|
||||
|
@ -7,15 +7,14 @@
|
||||
"lint": "pnpm rome check \"src/**/*.ts\""
|
||||
},
|
||||
"dependencies": {
|
||||
"@swc/cli": "^0.1.59",
|
||||
"@swc/core": "^1.3.26",
|
||||
"calckey-js": "^0.0.20",
|
||||
"idb-keyval": "^6.2.0"
|
||||
},
|
||||
"optionalDependencies": {
|
||||
"@swc/core-android-arm64": "1.3.11"
|
||||
|
||||
},
|
||||
"devDependencies": {
|
||||
"@swc/cli": "^0.1.59",
|
||||
"@swc/core": "^1.3.26",
|
||||
"@swc/core-android-arm64": "1.3.11",
|
||||
"calckey-js": "^0.0.20",
|
||||
"idb-keyval": "^6.2.0",
|
||||
"swc-loader": "^0.2.3",
|
||||
"webpack": "^5.75.0"
|
||||
}
|
||||
|
1477
pnpm-lock.yaml
1477
pnpm-lock.yaml
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue
Block a user