question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Suggestion: multistage Docker builds

See original GitHub issue

Currently 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:closed
  • Created 3 years ago
  • Comments:5 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
travisghansencommented, Apr 4, 2021

Implemented with v0.10.0.

0reactions
travisghansencommented, Feb 19, 2021

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

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found