Update Dockerfile (#5910)

Container now uses unpriviledged user with UID 1000 by default
Container now uses Alpine as base
Final image size dropped to just 67MB
This commit is contained in:
Yethal 2022-06-30 01:36:24 +02:00 committed by GitHub
parent 1c15a4ed3a
commit 6ee13126f7
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -1,31 +1,31 @@
# Git: git version 2.30.2 # Git: git version 2.30.2
# /etc/os-release: Debian: Debian GNU/Linux 11 (bullseye) # /etc/os-release: Alpine Linux v3.16
# Kernel: Linux ec73d87a5aab 5.10.104-linuxkit #1 SMP Wed Mar 9 19:05:23 UTC 2022 x86_64 GNU/Linux # Kernel: Linux ca3abedc4fb1 5.17.15-76051715-generic #202206141358~1655919116~22.04~1db9e34 SMP PREEMPT Wed Jun 22 19 x86_64 Linux
# Build cmd: docker build --no-cache . -t nushell-latest # Build cmd: docker build --no-cache . -t nushell-latest
# Other tags: nushell/debian-nu:latest, nushell # Other tags: nushell/alpine-nu:latest, nushell
FROM debian:bullseye-slim FROM alpine
LABEL maintainer=nushell LABEL maintainer=nushell
RUN apt update \ RUN echo '/usr/bin/nu' >> /etc/shells \
&& apt upgrade -y \ && adduser -D -s /usr/bin/nu nushell \
# Need ca-certificates to make `curl -s` work && mkdir -p /home/nushell/.config/nushell/ \
&& apt install -y --no-install-recommends --no-install-suggests ca-certificates aria2 curl git unzip \ && wget -q https://raw.githubusercontent.com/nushell/nushell/main/docs/sample_config/default_config.nu -O /home/nushell/.config/nushell/config.nu \
# Make /bin/sh symlink to bash instead of dash: && wget -q https://raw.githubusercontent.com/nushell/nushell/main/docs/sample_config/default_env.nu -O /home/nushell/.config/nushell/env.nu \
&& echo "dash dash/sh boolean false" | debconf-set-selections \ && cd /tmp \
&& DEBIAN_FRONTEND=noninteractive dpkg-reconfigure dash \ && wget -qO - https://api.github.com/repos/nushell/nushell/releases/latest \
&& cd /lib; curl -s https://api.github.com/repos/nushell/nushell/releases/latest | grep browser_download_url | cut -d '"' -f 4 | grep x86_64-unknown-linux-gnu | aria2c -i - \ |grep browser_download_url \
&& mkdir nu-latest && tar xvf nu-*.tar.gz --directory=nu-latest \ |grep musl \
&& cp -aR nu-latest/* /usr/local/bin/ \ |cut -f4 -d '"' \
# Setup default config file for nushell |xargs -I{} wget {} \
&& mkdir -p /root/.config/nushell && cd /root/.config/nushell \ && tar -xzf nu* \
&& aria2c https://raw.githubusercontent.com/nushell/nushell/main/docs/sample_config/default_env.nu -o env.nu \ && chmod +x nu \
&& aria2c https://raw.githubusercontent.com/nushell/nushell/main/docs/sample_config/default_config.nu -o config.nu \ && mv nu /usr/bin/nu \
# Do some cleanup work && chown -R nushell:nushell /home/nushell/.config/nushell \
&& cd /lib; rm -rf nu-* \ && rm -rf /tmp/*
&& rm -rf /var/lib/apt/lists/* && apt autoremove -y \
&& echo '/usr/local/bin/nu' >> /etc/shells \
# Add an nushell user and create home dir
&& useradd -m -s /usr/local/bin/nu nushell
CMD [ "nu" ] USER nushell
WORKDIR /home/nushell
ENTRYPOINT ["nu"]