radius-project / dashboard

Frontend experience for Project Radius
15 stars 5 forks source link

Putting the dashboard on a diet #25

Closed rynowak closed 8 months ago

rynowak commented 8 months ago

Summary

This change removes unused features of the Dashboard to reduce its overall size. I'm using the results of this run as the baseline for size comparisons.

Our total size right now is: 958.537 MB

For comparison, our control-plane services are in the range of ~40-80 MB each.

Of that ~450 MB comes from the base image and dependencies. In particular yarn install is adding ~405 MB of JS/static/native dependencies to the application.

The features I'm targeting for trimming are the ones we don't actually use in the Dashboard:

Once we remove Scaffolding we can also remove Python from the base image.

Baseline

 IMAGE          CREATED              CREATED BY                                      SIZE      COMMENT
bc82f115b919   30 seconds ago       CMD ["node" "packages/backend" "--config" "a…   0B        buildkit.dockerfile.v0
<missing>      30 seconds ago       RUN /bin/sh -c tar xzf bundle.tar.gz && rm b…   46.6MB    buildkit.dockerfile.v0
<missing>      31 seconds ago       COPY packages/backend/dist/bundle.tar.gz app…   11.8MB    buildkit.dockerfile.v0
<missing>      31 seconds ago       RUN /bin/sh -c YARN_CACHE_FOLDER=/home/node/…   405MB     buildkit.dockerfile.v0
<missing>      About a minute ago   RUN /bin/sh -c tar xzf skeleton.tar.gz && rm…   4.12kB    buildkit.dockerfile.v0
<missing>      About a minute ago   COPY .yarnrc.yml yarn.lock package.json pack…   1.25MB    buildkit.dockerfile.v0
<missing>      About a minute ago   ENV NODE_ENV=production                         0B        buildkit.dockerfile.v0
<missing>      About a minute ago   WORKDIR /app                                    0B        buildkit.dockerfile.v0
<missing>      About a minute ago   USER node                                       0B        buildkit.dockerfile.v0
<missing>      About a minute ago   RUN /bin/sh -c apt-get update &&     apt-get…   3.45MB    buildkit.dockerfile.v0
<missing>      About a minute ago   RUN /bin/sh -c apt-get update &&     apt-get…   333MB     buildkit.dockerfile.v0
<missing>      About a minute ago   RUN /bin/sh -c corepack enable && yarn -v # …   7.53MB    buildkit.dockerfile.v0
<missing>      5 days ago           /bin/sh -c #(nop)  CMD ["node"]                 0B        
<missing>      5 days ago           /bin/sh -c #(nop)  ENTRYPOINT ["docker-entry…   0B        
<missing>      5 days ago           /bin/sh -c #(nop) COPY file:4d192565a7220e13…   388B      
<missing>      5 days ago           /bin/sh -c set -ex   && savedAptMark="$(apt-…   9.36MB    
<missing>      5 days ago           /bin/sh -c #(nop)  ENV YARN_VERSION=1.22.19     0B        
<missing>      5 days ago           /bin/sh -c ARCH= OPENSSL_ARCH= && dpkgArch="…   112MB     
<missing>      5 days ago           /bin/sh -c #(nop)  ENV NODE_VERSION=18.19.0     0B        
<missing>      5 days ago           /bin/sh -c groupadd --gid 1000 node   && use…   8.9kB     
<missing>      5 days ago           /bin/sh -c #(nop)  CMD ["bash"]                 0B        
<missing>      5 days ago           /bin/sh -c #(nop) ADD file:9deb26e1dbc258df4…   74.8MB    
rynowak commented 8 months ago

First iteration down to 898.699 MB.

Reduced JS/static/native dependencies 405 MB -> 348 MB

rynowak commented 8 months ago

Removing Python from the image gets us down to 559.004 MB.

rynowak commented 8 months ago

To get much further than this, we'll need a multi-stage build and possibly bundling for the backend to slim down node_modules/.

When we list the dependencies in node_modules/ it's clear that most of them are frontend dependencies, not backend dependencies.

I'm going to hold off on the next change until we can get some better E2E tests in place for the container. It would be miserable if we break things without knowing.

Here's a list of the top package dependencies by size:

image