1
0
mirror of https://github.com/immich-app/immich.git synced 2024-12-24 10:37:28 +02:00

chore: reduce docker image size (#1523)

* chore: remove @tensorflow/tfjs-node-gpu as it is unused

* chore: remove ffmpeg from machine-learning docker image

* chore: remove unneeded dependencies + move dev dependencies in server

* chore: reduce server image size

* chore: machine-learning remove extraneous dependencies

* chore: web remove extraneous dependencies

* chore: web Dockerfile reduce production image size

* chore: add exiftool-vendored.pl as a dependency
This commit is contained in:
Zack Pollard 2023-02-03 03:28:34 +00:00 committed by GitHub
parent 0b65cea6fd
commit 43da8c2a72
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 1096 additions and 794 deletions

View File

@ -1,4 +1,3 @@
FROM node:16-bullseye-slim as builder
ARG DEBIAN_FRONTEND=noninteractive
@ -6,7 +5,7 @@ ARG DEBIAN_FRONTEND=noninteractive
WORKDIR /usr/src/app
RUN apt-get update
RUN apt-get install gcc g++ make cmake python3 python3-pip ffmpeg -y
RUN apt-get install gcc g++ make cmake python3 python3-pip -y
COPY package.json package-lock.json ./
@ -15,24 +14,17 @@ RUN npm rebuild @tensorflow/tfjs-node --build-from-source
COPY . .
FROM builder as prod
RUN npm run build
RUN npm prune --omit=dev
FROM node:16-bullseye-slim
ARG DEBIAN_FRONTEND=noninteractive
WORKDIR /usr/src/app
RUN apt-get update \
&& apt-get install -y ffmpeg \
&& rm -rf /var/cache/apt/lists
COPY --from=prod /usr/src/app/node_modules ./node_modules
COPY --from=prod /usr/src/app/dist ./dist

File diff suppressed because it is too large Load Diff

View File

@ -23,19 +23,9 @@
"dependencies": {
"@nestjs/common": "^8.0.0",
"@nestjs/core": "^8.0.0",
"@nestjs/mapped-types": "^1.0.1",
"@nestjs/platform-express": "^8.0.0",
"@tensorflow-models/coco-ssd": "^2.2.2",
"@tensorflow-models/mobilenet": "^2.1.0",
"@tensorflow/tfjs": "^3.19.0",
"@tensorflow/tfjs-converter": "^3.19.0",
"@tensorflow/tfjs-core": "^3.19.0",
"@tensorflow/tfjs-node": "^3.19.0",
"@tensorflow/tfjs-node-gpu": "^3.19.0",
"@trpc/server": "^9.20.3",
"reflect-metadata": "^0.1.13",
"rimraf": "^3.0.2",
"rxjs": "^7.2.0"
"@tensorflow/tfjs-node": "^3.19.0"
},
"devDependencies": {
"@nestjs/cli": "^8.2.4",
@ -52,6 +42,7 @@
"eslint-plugin-prettier": "^4.0.0",
"jest": "^27.2.5",
"prettier": "^2.3.2",
"rimraf": "^3.0.2",
"source-map-support": "^0.5.20",
"supertest": "^6.1.3",
"ts-jest": "^27.0.3",

View File

@ -2,7 +2,7 @@ FROM node:16-alpine3.14 as builder
WORKDIR /usr/src/app
RUN apk add --update-cache build-base python3 libheif vips-dev ffmpeg exiftool perl
RUN apk add --update-cache build-base python3 libheif vips-dev ffmpeg perl
COPY package.json package-lock.json ./
@ -14,14 +14,14 @@ COPY . .
FROM builder as prod
RUN npm run build
RUN npm prune --omit=dev
RUN npm prune --omit=dev --omit=optional
FROM node:16-alpine3.14
WORKDIR /usr/src/app
RUN apk add --no-cache libheif vips ffmpeg exiftool perl
RUN apk add --no-cache libheif vips ffmpeg perl
COPY --from=prod /usr/src/app/node_modules ./node_modules
COPY --from=prod /usr/src/app/dist ./dist
@ -32,7 +32,7 @@ COPY LICENSE /LICENSE
COPY package.json package-lock.json ./
COPY start-server.sh start-microservices.sh ./
RUN npm link
RUN npm link && npm cache clean --force
VOLUME /usr/src/app/upload

1245
server/package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -42,7 +42,6 @@
"@nestjs/common": "^9.2.1",
"@nestjs/config": "^2.2.0",
"@nestjs/core": "^9.2.1",
"@nestjs/mapped-types": "1.2.0",
"@nestjs/platform-express": "^9.2.1",
"@nestjs/platform-socket.io": "^9.2.1",
"@nestjs/schedule": "^2.1.0",
@ -58,15 +57,11 @@
"class-validator": "^0.13.2",
"cookie-parser": "^1.4.6",
"diskusage": "^1.1.3",
"dotenv": "^14.2.0",
"exiftool-vendored": "^19.0.0",
"fdir": "^5.3.0",
"exiftool-vendored.pl": "^12.54.0",
"fluent-ffmpeg": "^2.1.2",
"geo-tz": "^7.0.2",
"handlebars": "^4.7.7",
"i18n-iso-countries": "^7.5.0",
"ioredis": "^5.2.4",
"jest-when": "^3.5.2",
"joi": "^17.5.0",
"local-reverse-geocoder": "0.12.5",
"lodash": "^4.17.21",
@ -77,11 +72,9 @@
"pg": "^8.8.0",
"redis": "^4.5.1",
"reflect-metadata": "^0.1.13",
"rimraf": "^3.0.2",
"rxjs": "^7.2.0",
"sanitize-filename": "^1.6.3",
"sharp": "^0.28.0",
"systeminformation": "^5.11.0",
"typeorm": "^0.3.11"
},
"devDependencies": {
@ -107,11 +100,14 @@
"@types/supertest": "^2.0.11",
"@typescript-eslint/eslint-plugin": "^5.48.1",
"@typescript-eslint/parser": "^5.48.1",
"dotenv": "^14.2.0",
"eslint": "^8.31.0",
"eslint-config-prettier": "^8.3.0",
"eslint-plugin-prettier": "^4.0.0",
"jest": "^27.2.5",
"jest-when": "^3.5.2",
"prettier": "^2.3.2",
"rimraf": "^3.0.2",
"source-map-support": "^0.5.20",
"supertest": "^6.1.3",
"ts-jest": "^27.0.3",

View File

@ -1,29 +1,40 @@
# Our Node base image
FROM node:16-alpine3.14 as base
COPY LICENSE /licenses/LICENSE.txt
COPY LICENSE /LICENSE
WORKDIR /usr/src/app
EXPOSE 3000
RUN apk add --no-cache setpriv
FROM base as builder
RUN chown node:node /usr/src/app
RUN apk add --no-cache setpriv
COPY --chown=node:node package*.json ./
RUN npm ci
COPY --chown=node:node . .
RUN npm run build
EXPOSE 3000
FROM base AS dev
FROM builder AS dev
ENV CHOKIDAR_USEPOLLING=true
EXPOSE 24678
CMD ["npm", "run", "dev"]
FROM base as prod
FROM builder AS prod
RUN npm run build
RUN npm prune --omit=dev
FROM base
ENV NODE_ENV=production
WORKDIR /usr/src/app
COPY --from=prod /usr/src/app/node_modules ./node_modules
COPY --from=prod /usr/src/app/build ./build
COPY package.json package-lock.json ./
COPY entrypoint.sh ./

7
web/package-lock.json generated
View File

@ -14,7 +14,6 @@
"exifr": "^7.1.3",
"handlebars": "^4.7.7",
"leaflet": "^1.8.0",
"lodash": "^4.17.21",
"lodash-es": "^4.17.21",
"luxon": "^3.1.1",
"socket.io-client": "^4.5.1",
@ -8999,7 +8998,8 @@
"node_modules/lodash": {
"version": "4.17.21",
"resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.21.tgz",
"integrity": "sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg=="
"integrity": "sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg==",
"dev": true
},
"node_modules/lodash-es": {
"version": "4.17.21",
@ -17880,7 +17880,8 @@
"lodash": {
"version": "4.17.21",
"resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.21.tgz",
"integrity": "sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg=="
"integrity": "sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg==",
"dev": true
},
"lodash-es": {
"version": "4.17.21",

View File

@ -66,7 +66,6 @@
"exifr": "^7.1.3",
"handlebars": "^4.7.7",
"leaflet": "^1.8.0",
"lodash": "^4.17.21",
"lodash-es": "^4.17.21",
"luxon": "^3.1.1",
"socket.io-client": "^4.5.1",