Add busybox as base image

This commit is contained in:
Fahmi Akbar Wildana 2019-09-08 22:31:10 +07:00
parent c9c9112155
commit 21896b200c
4 changed files with 34 additions and 10 deletions

View File

@ -33,11 +33,13 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
base-image: [debian, 'debian:stable-slim', alpine]
base-image: [debian, 'debian:stable-slim', alpine, 'busybox:glibc', 'busybox:musl']
include:
- { tag: alpine, base-image: alpine, arch: x86_64-unknown-linux-musl }
- { tag: slim, base-image: 'debian:stable-slim', arch: x86_64-unknown-linux-gnu }
- { tag: debian, base-image: debian, arch: x86_64-unknown-linux-gnu }
- { tag: alpine, base-image: alpine, arch: x86_64-unknown-linux-musl, plugin: true }
- { tag: slim, base-image: 'debian:stable-slim', arch: x86_64-unknown-linux-gnu, plugin: true }
- { tag: debian, base-image: debian, arch: x86_64-unknown-linux-gnu, plugin: true }
- { tag: glibc-busybox, base-image: 'busybox:glibc', arch: x86_64-unknown-linux-gnu, plugin: false }
- { tag: musl-busybox, base-image: 'busybox:musl', arch: x86_64-unknown-linux-musl, plugin: false }
steps:
- uses: actions/checkout@v1
- uses: actions/download-artifact@master
@ -45,6 +47,7 @@ jobs:
- name: Build and publish exact version
run: |
REGISTRY=${REGISTRY,,}; export TAG=${GITHUB_REF##*/}-${{ matrix.tag }};
export NU_BINS=target/release/$( [ ${{ matrix.plugin }} ] && nu* || nu )
echo ${{ secrets.DOCKER_REGISTRY }} | docker login docker.pkg.github.com -u ${{ github.actor }} --password-stdin
docker-compose --file docker/docker-compose.package.yml build

View File

@ -1,5 +1,6 @@
ARG artifact
ARG base
FROM ${base}
COPY target/release/nu* /bin/
COPY ${artifact} /bin/
ENTRYPOINT ["nu"]

View File

@ -8,3 +8,4 @@ services:
dockerfile: docker/Package.Dockerfile
args:
base: ${BASE_IMAGE}
artifact: ${NU_BINS}

View File

@ -1,10 +1,12 @@
# Docker Guide
| tag | base image | plugins | package manager | libs & bins | size |
| ------------------ | -------------------- | ------- | --------------- | ----------------------------------------------------------------------- | ----------- |
| `latest`,`debian` | `debian:latest` | yes | apt | **a lot**, including _glibc_ | ~(48+62) MB |
| `slim` | `debian:stable-slim` | yes | apt | all `nu:debian` image but exclude [this list][.slimify-excludes] | ~(26+62) MB |
| `alpine` | `alpine:latest` | yes | apk | all `nu:musl-busybox` image but include libcrypto, libssl, libtls, libz | ~(3+61) MB |
| tag | base image | plugins | package manager | libs & bins | size |
| ----------------- | -------------------- | ------- | --------------- | ---------------------------------------------------------------- | ----------- |
| `latest`,`debian` | `debian:latest` | yes | apt | **a lot**, including _glibc_ | ~(48+62) MB |
| `slim` | `debian:stable-slim` | yes | apt | all `nu:debian` image but exclude [this list][.slimify-excludes] | ~(26+62) MB |
| `alpine` | `alpine:latest` | yes | apk | all `nu:musl-busybox` image + libcrypto, libssl, libtls, libz | ~(3+61) MB |
| `musl-busybox` | `busybox:musl` | no | — | GNU utils + _musl_ | ~(1+16) MB |
| `glibc-busybox` | `busybox:glibc` | no | — | GNU utils + _glibc_ | ~(3+17) MB |
[.slimify-excludes]: https://github.com/debuerreotype/debuerreotype/blob/master/scripts/.slimify-excludes
[distroless/base]: https://github.com/GoogleContainerTools/distroless/blob/master/base/README.md
@ -42,5 +44,22 @@ This variant is highly recommended when final image size being as small as possi
To minimize image size, it's uncommon for additional related tools (such as `git` or `bash`) to be included in Alpine-based images. Using this image as a base, add the things you need in your own Dockerfile (see the [alpine image description][alpine] for examples of how to install packages if you are unfamiliar).
### `nu:<version>-<libc-variant>-busybox`
This image is based on [Busybox](http://www.busybox.net/) which is a very good ingredient to craft space-efficient distributions. It combines tiny versions of many common UNIX utilities into a single small executable. It also provides replacements for most of the utilities you usually find in GNU fileutils, shellutils, etc. The utilities in BusyBox generally have fewer options than their full-featured GNU cousins; however, the options that are included provide the expected functionality and behave very much like their GNU counterparts. Basically, this image provides a fairly complete environment for any small or embedded system.
> Use this only if you need common utilities like `tar`, `awk`, and many more but don't want extra blob like nushell plugins and others.
<details><summary>example</summary>
```dockerfile
FROM nu:0.2-glibc-busybox
ADD https://github.com/user/repo/releases/download/latest/nu_plugin_cowsay.tar.gz /tmp/
RUN tar xzfv nu_plugin_cowsay.tar.gz -C /bin
ENTRYPOINT ["nu"]
```
</details>
[musl]: http://www.musl-libc.org/
[alpine]: https://hub.docker.com/_/alpine/