#Sample node.Create a Docker image for your js app
~ $ git clone https://github.com/docker-slim/examples.git
# node_Move to the directory where ubuntu Dockerfile is located
~ $ cd examples/node_ubuntu/
#Build Dockerfile and create an image
~ $ docker build -t my/sample-node-app .
#For the created image, docker-Apply slim
~ $ docker-slim build my/sample-node-app
~ $ docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
my/sample-node-app.slim latest b2c7843a52fa 3 hours ago 14MB
my/sample-node-app latest 3c6ddc217be2 4 hours ago 414MB
The bottom is the original image, and the top is the optimized image. It seems that ".slim" is added to the image optimized by docker-slim. The size is reduced from 414MB to 14MB. What's happening? ..
--Dockerfile of the image to which docker-slim is applied is in the following directory - [docker-slim directory]/.images/[YOUR_APP_IMAGE_ID]/artifacts/
Dockerfile-before
FROM ubuntu:14.04
RUN apt-get update && \
apt-get install -y curl software-properties-common python-software-properties && \
add-apt-repository ppa:chris-lea/node.js && \
apt-get update && \
apt-get install -y build-essential \
nodejs && \
mkdir -p /opt/my/service
COPY service /opt/my/service
WORKDIR /opt/my/service
RUN npm install
EXPOSE 1300
ENTRYPOINT ["node","/opt/my/service/server.js"]
Dockerfile-after
FROM scratch
LABEL docker-slim.version="darwin|Transformer|1.32.0|10b628fc3cd9f903237b9c31a6aba5ac4e6bc9c8|2020-08-24_06:14:32AM"
ENV PATH "/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
ADD files.tar /
WORKDIR /opt/my/service
EXPOSE 1300/tcp
ENTRYPOINT ["node","/opt/my/service/server.js"]
The FROM clause has changed from ubuntu: 14.04 to scratch. FROM scratch means that there is no base, and it seems to indicate that you are writing from the base OS part. It seems that the OS part is handled by files.tar, which is supposed to be a compressed version of the ADD ubuntu file system.
--I tried using DockerSlim - https://scrapbox.io/kimihiro-n/DockerSlim_%E4%BD%BF%E3%81%A3%E3%81%A6%E3%81%BF%E3%81%9F
Recommended Posts