From 21896b200cd4ec544f40cd416c977af4e4816d19 Mon Sep 17 00:00:00 2001 From: Fahmi Akbar Wildana Date: Sun, 8 Sep 2019 22:31:10 +0700 Subject: [PATCH] Add busybox as base image --- .github/workflows/docker-publish.yml | 11 +++++++---- docker/Package.Dockerfile | 3 ++- docker/docker-compose.package.yml | 1 + docs/docker.md | 29 +++++++++++++++++++++++----- 4 files changed, 34 insertions(+), 10 deletions(-) diff --git a/.github/workflows/docker-publish.yml b/.github/workflows/docker-publish.yml index a3c3e0f2af..353401e91b 100644 --- a/.github/workflows/docker-publish.yml +++ b/.github/workflows/docker-publish.yml @@ -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 diff --git a/docker/Package.Dockerfile b/docker/Package.Dockerfile index 8d61b03342..7bc2bfe291 100644 --- a/docker/Package.Dockerfile +++ b/docker/Package.Dockerfile @@ -1,5 +1,6 @@ +ARG artifact ARG base FROM ${base} -COPY target/release/nu* /bin/ +COPY ${artifact} /bin/ ENTRYPOINT ["nu"] \ No newline at end of file diff --git a/docker/docker-compose.package.yml b/docker/docker-compose.package.yml index 2192da8879..3622fa0cf6 100644 --- a/docker/docker-compose.package.yml +++ b/docker/docker-compose.package.yml @@ -8,3 +8,4 @@ services: dockerfile: docker/Package.Dockerfile args: base: ${BASE_IMAGE} + artifact: ${NU_BINS} diff --git a/docs/docker.md b/docs/docker.md index dc8d37988c..78db9a44c7 100644 --- a/docs/docker.md +++ b/docs/docker.md @@ -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:--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. + +
example + +```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"] +``` +
+ [musl]: http://www.musl-libc.org/ [alpine]: https://hub.docker.com/_/alpine/ \ No newline at end of file