From 3e331d51d19f4335fa7c2583ce855d7acc1ece21 Mon Sep 17 00:00:00 2001 From: Paul Bonaud Date: Mon, 4 May 2020 18:46:33 +0200 Subject: volume: no need to duplicate the initial nix store MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This is a partial revert of #7 where we added a copy of the initial nix store to make sure it's not lost when we use a volume for the /nix mounting point in the container. However this was an unecessary duplication. The initial nix store is already present in the docker image and can be retrieved by using a “named” volume with `-v nix-store:/nix`, docker will copy the /nix path of the image inside a volume called `nix-store` on the host machine for us we don't need to it manually. Of course if mounting an empty directory from the host machine (with `-v /tmp/nix-store:/nix`) then the image won't boot (because docker will NOT copy the content of the /nix path inside the image into the /tmp/nix-store path of the host machine). This change drastically reduces the image size (basically /2 as we were duplicating the biggest source of disk space…) ``` REPOSITORY TAG IMAGE ID CREATED SIZE docker-nix 2.3.4-vol f74209e25515 About a minute ago 1.58GB docker-nix 2.3.4 61880484ceb1 12 minutes ago 835MB ``` Let's be 🍃 instead of ⛰️ --- alpine/Dockerfile | 3 --- 1 file changed, 3 deletions(-) (limited to 'alpine/Dockerfile') diff --git a/alpine/Dockerfile b/alpine/Dockerfile index 0e42345..1da307a 100644 --- a/alpine/Dockerfile +++ b/alpine/Dockerfile @@ -40,9 +40,6 @@ RUN nix-env -iA nixpkgs.glibcLocales # < Nix context as a volume # We want to be able to define /nix/store as a volume -# We thus need to "save" the current nix context to be able -# to restore it at startup time -RUN cp -R /nix /home/nixuser/initial-nix VOLUME ["/nix"] # Create bash profile COPY --chown=nixuser:nixuser files/.profile ${HOME}/.profile -- cgit v1.2.3