Skip to content

Commit

Permalink
Merge pull request #1 from ricardbejarano/musl-static
Browse files Browse the repository at this point in the history
statically link musl-based image
  • Loading branch information
ricardbejarano committed Apr 27, 2019
2 parents f56685c + b4efc51 commit 3f86d1c
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 15 deletions.
10 changes: 3 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ Available at [`ricardbejarano/haproxy`](https://hub.docker.com/r/ricardbejarano/

## Features

* Super tiny (`glibc`-based is `~11.6MB` and `musl`-based is `~19.2MB`)
* Super tiny (`glibc`-based is `~11.6MB` and `musl`-based is `~18.6MB`)
* Built from source, including libraries
* Built `FROM scratch`, see the [Filesystem](#Filesystem) section below for an exhaustive list of the image's contents
* Reduced attack surface (no `bash`, no UNIX tools, no package manager...)
Expand Down Expand Up @@ -135,7 +135,7 @@ Based on the [glibc](https://www.gnu.org/software/libc/) implementation of `libc

### `musl`

Based on the [musl](https://www.musl-libc.org/) implementation of `libc`. Dynamically linked.
Based on the [musl](https://www.musl-libc.org/) implementation of `libc`. Statically linked (with the exception of `ld-musl-x86_64.so.1`).

```
/
Expand All @@ -146,11 +146,7 @@ Based on the [musl](https://www.musl-libc.org/) implementation of `libc`. Dynami
β”‚ └── passwd
β”œβ”€β”€ haproxy
└── lib/
β”œβ”€β”€ ld-musl-x86_64.so.1
β”œβ”€β”€ libcrypto.so.1.1
β”œβ”€β”€ libpcre.so.1
β”œβ”€β”€ libssl.so.1.1
└── libz.so.1
└── ld-musl-x86_64.so.1
```


Expand Down
12 changes: 4 additions & 8 deletions musl/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ ARG HAPROXY_CHECKSUM="5e59466728cc3ec0bcdd0271d8a8c5bd07d99a3a9cfa0989583da0ddde
ARG HAPROXY_CONFIG="\
-j 4 \
TARGET=linux2628 \
USE_PCRE=1 \
USE_STATIC_PCRE=1 \
USE_ZLIB=1 \
USE_OPENSSL=1 \
USE_LUA=1 \
Expand Down Expand Up @@ -47,15 +47,15 @@ RUN cd /tmp && \

RUN apk add gcc g++ perl make readline-dev linux-headers && \
cd /tmp/pcre-$PCRE_VERSION && \
./configure && \
./configure --disable-shared && \
make && \
make install && \
cd /tmp/zlib-$ZLIB_VERSION && \
./configure && \
./configure --static && \
make && \
make install && \
cd /tmp/openssl-$OPENSSL_VERSION && \
./config && \
./config no-shared && \
make && \
make install && \
cd /tmp/lua-$LUA_VERSION && \
Expand All @@ -67,10 +67,6 @@ RUN apk add gcc g++ perl make readline-dev linux-headers && \
FROM scratch

COPY --from=build /lib/ld-musl-x86_64.so.1 \
/usr/local/lib/libpcre.so.1 \
/usr/local/lib/libz.so.1 \
/usr/local/lib/libssl.so.1.1 \
/usr/local/lib/libcrypto.so.1.1 \
/lib/
COPY --from=build /tmp/haproxy/haproxy /haproxy

Expand Down

0 comments on commit 3f86d1c

Please sign in to comment.