-
Notifications
You must be signed in to change notification settings - Fork 258
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add Dockerfiles to build minimal Docker #327
Conversation
cb22a31
to
e9c2bfc
Compare
ENV DEBIAN_FRONTEND noninteractive | ||
|
||
# Base build dependencies. | ||
RUN apt-get update && apt-get install -qy \ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To make future changes easier to track and get one-line diffs, I would rather write this as
RUN apt-get update && \
apt-get install -qy \
autoconf \
automake \
build-essential \
git \
golang \
nodejs
Added various comments. |
|
||
# Add glibc. | ||
ENV GLIBC_PKG_VERSION=2.23-r3 | ||
RUN apk add --update-cache curl ca-certificates openssl && \ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using apk add --no-cache
instead of apk add --update-cache
will stop apk from saving the cache which results in a smaller image (since the cache is not stored in the intermediate layer)
You could save a bit of work of work keeping the glibc up to date by basing the image on something like Or you can probably get rid of glibc altogether by building the server against musl libc in the first place, although the size gain (~7mb iirc) might not be worth the hassle |
6f1752d
to
8ae1009
Compare
To reduce the Docker image size a seperate build Dockerfile is introduced. This Docker image produces a tarball of the released and compiled software which can when be piped into the Dockerfile.run build process. The result is a minimal image only containing Spreed WebRTC and the gear to run OpenSSL. First create the builder image: ``` docker build -t spreed-webrtc-builder -f Dockerfile.build . ``` Next run the builder container, piping its output into the creation of the runner container: ``` docker run --rm spreed-webrtc-builder | docker build -t spreed-webrtc -f Dockerfile.run - ``` Afterwards run the container like this: ``` docker run --rm --name my-spreed-webrtc -p 8080:8080 -p 8443:8443 \ -v `pwd`:/srv/extra -i -t spreed-webrtc ```
8ae1009
to
39a920e
Compare
Thanks for the feedback, i incorporated all the suggestions and squashed. Looks good now and the updated Dockerfile.run saves almost 20M - awesome! |
To reduce the Docker image size a seperate build Dockerfile is
introduced. This Docker image produces a tarball of the released and
compiled software which can when be piped into the Dockerfile.run build
process. The result is a minimal image only containing Spreed WebRTC and
the gear to run OpenSSL.
First create the builder image:
Next run the builder container, piping its output into the creation of
the runner container:
Afterwards run the container like this: