You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I propose we create a node-slim for alpine. I was optimized my Dockerfile for Ghost and I found a way to not include yarn, npm, npx. I also compressed node using upx.
Here is the result.
size
devmtl/10.16-alpine-slim latest e5efb0afa59d 6 seconds ago 23.3MB
node 10.16-alpine 9dfa73010b19 5 days ago 75.3MB
The beauty here is that it's all based on the official node:10.16-alpine image.
dockerfile
ARG ALPINE_VERSION="3.9"
ARG NODE_VERSION="10.16-alpine"
# Node official layer
### ### ### ### ### ### ### ### ### ### ###
FROM node:${NODE_VERSION} AS node-official
WORKDIR /usr/local/bin
RUN set -eux && \
apk --update --no-cache add \
upx && \
upx node ;
# node size / before=39.8MO, after=14.2MO
# Thanks for the idea https://github.com/mhart/alpine-node/blob/master/slim/Dockerfile :)
# Node slim layer (about 50MO lighter)
### ### ### ### ### ### ### ### ### ### ###
FROM alpine:${ALPINE_VERSION} AS node-slim
LABEL org.label-schema.ghost.node-version="${NODE_VERSION}" \
org.label-schema.ghost.alpine-version="${ALPINE_VERSION}" \
org.label-schema.ghost.maintainer="${MAINTAINER}" \
org.label-schema.schema-version="1.0"
RUN set -eux && \
# setup node user and group
addgroup -g 1000 node \
&& adduser -u 1000 -G node -s /bin/sh -D node ;
# install node without yarn, npm, npx, etc.
COPY --from=node-official /usr/local/bin/node /usr/bin/
COPY --from=node-official /usr/lib/libgcc* /usr/lib/libstdc* /usr/lib/
in production
You can see how I use this in production to build Ghost.
conclusion
I know Dockerhub doesn't support multi-stage builds at the moment, but it's not the point. The point is to include only the library needed to run our node apps in PROD.
If slim is not the right term, I don't mind. This image does not include npm, yarn. It also compress the node binary with UPX.
Thanks for considering :)
The text was updated successfully, but these errors were encountered:
Think "slim" currently has a different meaning (ex: the other "slim" still have npm/yarn). There is an separate issue discussing variants without NPM/Yarn #404
pascalandy
changed the title
FEAT: Introducing node:10.16-alpine-slim (23.3MB instead of 75.3MB)
FEAT: Introducing a much slimmer image (23.3MB instead of 75.3MB) for node:10-alpine-slim
Sep 29, 2019
Hi folks,
I propose we create a node-slim for alpine. I was optimized my Dockerfile for Ghost and I found a way to not include yarn, npm, npx. I also compressed node using upx.
Here is the result.
size
The beauty here is that it's all based on the official node:10.16-alpine image.
dockerfile
in production
You can see how I use this in production to build Ghost.
conclusion
I know Dockerhub doesn't support multi-stage builds at the moment, but it's not the point. The point is to include only the library needed to run our node apps in PROD.
If
slim
is not the right term, I don't mind. This image does not include npm, yarn. It also compress the node binary with UPX.Thanks for considering :)
The text was updated successfully, but these errors were encountered: