#Optimize Docker Image for production

4 messages · Page 1 of 1 (latest)

steel sedge
#

Hello everyone, recently I try to make small docker image that can run in production.
I make multi stage build in my Dockerfile and have this result:

REPOSITORY                    TAG            IMAGE ID       CREATED          SIZE
nestjs-mikro-orm-dev          1.0            045c3154eb3b   18 seconds ago   331MB
nestjs-mikro-orm-production   1.0            3d1bc1abbeb8   2 hours ago      222MB
node                          22.12-alpine   10d483552d27   2 weeks ago      157MB
node                          20.15-alpine   3ef52eda8a70   5 months ago     133MB
mysql                         8.0            0b60ddd8609d   5 months ago     572MB
nginx                         latest         fffffc90d343   6 months ago     188MB
mariadb                       10.5           8d27db214bfa   6 months ago     394MB
node                          21-alpine      cad63adc9266   6 months ago     139MB
postgres                      13             483aeb0a0bb9   7 months ago     419MB

nestjs-mikro-orm-dev is just images with devDependencies installed on the image, while nestjs-mikro-orm-production using npm install --only=production to install the package.

question: to have about >= 200mb image size for production is normal thing?
thank you.

quiet ridge
#

Depending on the number of dependencies your application needs, I'd say that's about a normal size for a mod sized Nest app

steel sedge
# quiet ridge Depending on the number of dependencies your application needs, I'd say that's a...

Okay, glad to hear that. for now, this is my Dependencies that I need. maybe multer and all good:

"dependencies": {
    "@mikro-orm/cli": "^6.3.13",
    "@mikro-orm/core": "^6.3.13",
    "@mikro-orm/entity-generator": "^6.3.13",
    "@mikro-orm/migrations": "^6.3.13",
    "@mikro-orm/mysql": "^6.3.13",
    "@mikro-orm/nestjs": "^6.0.2",
    "@mikro-orm/reflection": "^6.3.13",
    "@mikro-orm/seeder": "^6.3.13",
    "@mikro-orm/sql-highlighter": "^1.0.1",
    "@nestjs/common": "^10.0.0",
    "@nestjs/config": "^3.3.0",
    "@nestjs/core": "^10.0.0",
    "@nestjs/jwt": "^10.2.0",
    "@nestjs/mapped-types": "*",
    "@nestjs/passport": "^10.0.3",
    "@nestjs/platform-express": "^10.0.0",
    "@nestjs/swagger": "^8.0.2",
    "@nestjs/throttler": "^6.3.0",
    "argon2": "^0.41.1",
    "bcrypt": "^5.1.1",
    "cookie-parser": "^1.4.7",
    "nest-winston": "^1.9.7",
    "nodemailer": "^6.9.16",
    "passport": "^0.7.0",
    "passport-jwt": "^4.0.1",
    "reflect-metadata": "^0.2.0",
    "rxjs": "^7.8.1",
    "uuid": "^11.0.2",
    "zod": "^3.23.8"
  },
#

!resolve