Result

Starting from a baseline image (1740 MB) the resulting image (105 MB) is 93.97% smaller.

# Branch Image (MB) Layer Count node Binary (MB) node_modules (MB) Server (B)

0

Baseline

1740

22

116.0

51.0

2515

1

.dockerignore

1660

24

116.0

24.0

2515

2

npm ci

1630

24

116.0

14.0

2515

3

clean-modules

1630

24

116.0

11.0

2515

4

Smaller Base Image

243

21

118.1

10.9

2515

5

Multi-Stage Build

239

19

118.1

10.9

2515

6

Separate Serving Image

201

15

118.1

10.9

2515

7

Harden the Image

201

17

118.1

10.9

2515

8

Compress Node Binary

117

17

41.3

10.9

2515

9

Bundle With External Packages

117

17

41.3

10.9

2003

10

Bundle Without External Packages

105

16

41.3

0

1325646