Suggestion: multistage Docker builds
See original GitHub issueCurrently the docker image for external-auth-server sits at just over 1.04GB. This can be reduced using multi-staged builds. Here’s an initial pass at a Dockerfile for eas:
FROM node:10 AS builder
WORKDIR /root
COPY package*.json ./
RUN npm install
FROM node:10-alpine AS release
# Run as a non-root user
RUN adduser --disabled-password eas \
&& mkdir /home/eas/app \
&& chown -R eas: /home/eas
WORKDIR /home/eas/app
USER eas
COPY --from=builder --chown=eas:eas /root/node_modules ./node_modules
COPY --chown=eas:eas . .
EXPOSE 8080
CMD [ "npm", "start" ]
Using node:10-alpine the resultant image ends up being just under 200MB:
docker images external-auth-server:slim
REPOSITORY TAG IMAGE ID CREATED SIZE
external-auth-server slim bfc66bf5f94c 38 seconds ago 194MB
I haven’t tested to see if eas will work with this change, but I thought I’d at least suggest a way to reduce the current eas image by 4/5ths.
Issue Analytics
- State:
- Created 3 years ago
- Comments:5 (4 by maintainers)
Top Results From Across the Web
Multi-stage builds - Docker Documentation
With multi-stage builds, you use multiple FROM statements in your Dockerfile. Each FROM instruction can use a different base, and each of them...
Read more >Using multi-stage builds to make your docker image 10x smaller
In this short article we build an image in multiple stages to significantly reduce the size of our docker image.
Read more >Combining Docker Multi-Stage builds and Health Checks
After some googling, there seemed to be not on recommendation for how to best combine these two things. However, three solutions came to...
Read more >Docker: How to use multistage images after build finishes
I would like to be able to use the base image built. As suggested for Testing stages, a secondary Dockerfile.test could be used....
Read more >(Multi-stage docker) in docker as CI Sledgehammer
With an objective of building some docker images on cloud CI infrastructure I introduce one build-template sledgehammer I've been using ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

Implemented with
v0.10.0.For binary compatibility with some pre-built npm stuff I think we’ll stick with glibc over musl based system.