From 0366f366617a0a5c36d365c56a2c1178fd19ed94 Mon Sep 17 00:00:00 2001 From: Paul B Date: Wed, 31 Oct 2018 11:43:02 +0100 Subject: Add debian based images --- .travis.yml | 7 ++++++- Dockerfile | 40 ---------------------------------------- alpine/Dockerfile | 40 ++++++++++++++++++++++++++++++++++++++++ debian/Dockerfile | 40 ++++++++++++++++++++++++++++++++++++++++ 4 files changed, 86 insertions(+), 41 deletions(-) delete mode 100644 Dockerfile create mode 100644 alpine/Dockerfile create mode 100644 debian/Dockerfile diff --git a/.travis.yml b/.travis.yml index 8b3769d..32a66bb 100644 --- a/.travis.yml +++ b/.travis.yml @@ -8,7 +8,12 @@ addons: packages: - docker-ce +matrix: + include: + - env: BASE_OS=alpine + - env: BASE_OS=debian + script: - - docker build --pull -t fretlink/nix . + - docker build --pull -t fretlink/nix ${BASE_OS}/ - docker run -it --rm fretlink/nix 'nix-channel --list' - docker run -it --rm fretlink/nix 'nix-env -iA nixpkgs.hello && test "$(hello)" = "Hello, world!"' diff --git a/Dockerfile b/Dockerfile deleted file mode 100644 index 5aa7fcc..0000000 --- a/Dockerfile +++ /dev/null @@ -1,40 +0,0 @@ -# Dockerfile to create an environment that contains the Nix package manager. -FROM alpine - -ARG NIX_VERSION -ENV NIX_VERSION ${NIX_VERSION:-2.1.3} -ARG LANG -ENV LANG ${LANG:-"en_US.UTF-8"} - -RUN addgroup -g 30000 -S nixbld \ - && for i in $(seq 1 30); do adduser -S -D -h /var/empty -g "Nix build user $i" -u $((30000 + i)) -G nixbld nixbld$i ; done \ - && adduser -D nixuser \ - && mkdir -m 0755 /nix && chown nixuser /nix \ - && apk add --no-cache bash \ - && rm -rf /var/cache/apk/* - -USER nixuser -ENV USER=nixuser -ENV HOME="/home/nixuser" - -RUN cd && wget https://nixos.org/releases/nix/nix-$NIX_VERSION/nix-$NIX_VERSION-x86_64-linux.tar.bz2 \ - && tar xjf nix-*-x86_64-linux.tar.bz2 \ - && ~/nix-*-x86_64-linux/install \ - && rm -rf ~/nix-*-* - -ENV ENV="/home/nixuser/.nix-profile/etc/profile.d/nix.sh" -RUN echo ". ${ENV}" >> ${HOME}/.profile -# All subsequent "RUN" will use a login shell -SHELL ["/usr/bin/env", "bash", "-l", "-c"] - -RUN nix-channel --add https://nixos.org/channels/nixpkgs-unstable \ - && nix-channel --update - -# Propagate UTF8 -# https://github.com/NixOS/nix/issues/599#issuecomment-153885553 -# The same is hapenning with stack2nix -RUN nix-env -iA nixpkgs.glibcLocales \ - && echo "export LOCALE_ARCHIVE=$(nix-env --installed --no-name --out-path --query glibc-locales)/lib/locale/locale-archive" >> ${HOME}/.profile - -# Make sure to use "login" shell when running container -ENTRYPOINT ["/usr/bin/env", "bash", "-l", "-c"] diff --git a/alpine/Dockerfile b/alpine/Dockerfile new file mode 100644 index 0000000..5aa7fcc --- /dev/null +++ b/alpine/Dockerfile @@ -0,0 +1,40 @@ +# Dockerfile to create an environment that contains the Nix package manager. +FROM alpine + +ARG NIX_VERSION +ENV NIX_VERSION ${NIX_VERSION:-2.1.3} +ARG LANG +ENV LANG ${LANG:-"en_US.UTF-8"} + +RUN addgroup -g 30000 -S nixbld \ + && for i in $(seq 1 30); do adduser -S -D -h /var/empty -g "Nix build user $i" -u $((30000 + i)) -G nixbld nixbld$i ; done \ + && adduser -D nixuser \ + && mkdir -m 0755 /nix && chown nixuser /nix \ + && apk add --no-cache bash \ + && rm -rf /var/cache/apk/* + +USER nixuser +ENV USER=nixuser +ENV HOME="/home/nixuser" + +RUN cd && wget https://nixos.org/releases/nix/nix-$NIX_VERSION/nix-$NIX_VERSION-x86_64-linux.tar.bz2 \ + && tar xjf nix-*-x86_64-linux.tar.bz2 \ + && ~/nix-*-x86_64-linux/install \ + && rm -rf ~/nix-*-* + +ENV ENV="/home/nixuser/.nix-profile/etc/profile.d/nix.sh" +RUN echo ". ${ENV}" >> ${HOME}/.profile +# All subsequent "RUN" will use a login shell +SHELL ["/usr/bin/env", "bash", "-l", "-c"] + +RUN nix-channel --add https://nixos.org/channels/nixpkgs-unstable \ + && nix-channel --update + +# Propagate UTF8 +# https://github.com/NixOS/nix/issues/599#issuecomment-153885553 +# The same is hapenning with stack2nix +RUN nix-env -iA nixpkgs.glibcLocales \ + && echo "export LOCALE_ARCHIVE=$(nix-env --installed --no-name --out-path --query glibc-locales)/lib/locale/locale-archive" >> ${HOME}/.profile + +# Make sure to use "login" shell when running container +ENTRYPOINT ["/usr/bin/env", "bash", "-l", "-c"] diff --git a/debian/Dockerfile b/debian/Dockerfile new file mode 100644 index 0000000..6c09f82 --- /dev/null +++ b/debian/Dockerfile @@ -0,0 +1,40 @@ +# Dockerfile to create an environment that contains the Nix package manager. +FROM debian:stable-slim + +ARG NIX_VERSION +ENV NIX_VERSION ${NIX_VERSION:-2.1.3} +ARG LANG +ENV LANG ${LANG:-"en_US.UTF-8"} + +RUN addgroup --gid 30000 --system nixbld \ + && for i in $(seq 1 30); do adduser --system --disabled-password --home /var/empty --gecos "Nix build user $i" --uid $((30000 + i)) --ingroup nixbld nixbld$i ; done \ + && adduser --disabled-password nixuser \ + && mkdir -m 0755 /nix && chown nixuser /nix \ + && apt update && apt install -y wget bzip2 \ + && apt clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* + +USER nixuser +ENV USER=nixuser +ENV HOME="/home/nixuser" + +RUN cd && wget https://nixos.org/releases/nix/nix-$NIX_VERSION/nix-$NIX_VERSION-x86_64-linux.tar.bz2 \ + && tar xjf nix-*-x86_64-linux.tar.bz2 \ + && ~/nix-*-x86_64-linux/install \ + && rm -rf ~/nix-*-* + +ENV ENV="/home/nixuser/.nix-profile/etc/profile.d/nix.sh" +RUN echo ". ${ENV}" >> ${HOME}/.profile +# All subsequent "RUN" will use a login shell +SHELL ["/usr/bin/env", "bash", "-l", "-c"] + +RUN nix-channel --add https://nixos.org/channels/nixpkgs-unstable \ + && nix-channel --update + +# Propagate UTF8 +# https://github.com/NixOS/nix/issues/599#issuecomment-153885553 +# The same is hapenning with stack2nix +RUN nix-env -iA nixpkgs.glibcLocales \ + && echo "export LOCALE_ARCHIVE=$(nix-env --installed --no-name --out-path --query glibc-locales)/lib/locale/locale-archive" >> ${HOME}/.profile + +# Make sure to use "login" shell when running container +ENTRYPOINT ["/usr/bin/env", "bash", "-l", "-c"] -- cgit v1.2.3