Skip to content
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

Merged
merged 2 commits into from
Aug 10, 2016
Merged

Conversation

longsleep
Copy link
Contributor

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

@longsleep longsleep force-pushed the docker-minimal-build branch 3 times, most recently from cb22a31 to e9c2bfc Compare August 5, 2016 09:43
ENV DEBIAN_FRONTEND noninteractive

# Base build dependencies.
RUN apt-get update && apt-get install -qy \
Copy link
Member

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

@fancycode
Copy link
Member

Added various comments.


# Add glibc.
ENV GLIBC_PKG_VERSION=2.23-r3
RUN apk add --update-cache curl ca-certificates openssl && \

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)

@icewind1991
Copy link

You could save a bit of work of work keeping the glibc up to date by basing the image on something like frolvlad/alpine-glibc

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

@longsleep longsleep force-pushed the docker-minimal-build branch from 6f1752d to 8ae1009 Compare August 10, 2016 08:02
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
```
@longsleep longsleep force-pushed the docker-minimal-build branch from 8ae1009 to 39a920e Compare August 10, 2016 08:03
@longsleep
Copy link
Contributor Author

Thanks for the feedback, i incorporated all the suggestions and squashed. Looks good now and the updated Dockerfile.run saves almost 20M - awesome!

@longsleep longsleep merged commit eacc767 into develop Aug 10, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants