[Nix-dev] Question about dockerTools layering
Luca Bruno
lethalman88 at gmail.com
Fri Sep 23 22:01:58 CEST 2016
Yes, you can create an image with only node_modules and then layer on top
of it another image with fromImage.
You can make the node_modules symlink in the base image. Then only update
assets in the upper image.
On Fri, Sep 23, 2016 at 8:38 PM, Tobias Pflug <Tobias.Pflug at gmx.net> wrote:
> Hi,
>
> I recently started using dockerTools.buildImage for a nodejs based
> project. It's working
> fine but I am hitting a mental block trying to introduce layers - I don't
> want to always push
> around node_modules.
>
> My current setup is something like the following:
>
> # default.nix
> dockerImage = with pkgs; dockerTools.buildImage {
> name = "foo";
> contents = [ nodejsApp ];
> config = {
> Cmd = [ "${nodejs-6_x}/bin/node" "${nodejsApp}/index.js" ];
> WorkingDir = "${nodejsApp}"
> };
> };
>
> # nodejsApp.nix
> stdenv.mkDerivation {
> name = "nodejsApp";
> src = ...
> buildInputs = [ assets nodeModules ];
> installPhase = ''
> mkdir -p $out
> ln -s ${nodeModules}/node_modules $out/node_modules
> ln -s ${assets} $out/assets
> ...
> '';
> }
>
> So basically I have a derivation for my app and I symlink in the
> node_modules. Now if I want to avoid pushing
> the node_modules to my docker registry if they are unchanged I would have
> to create a docker image that contains
> only the node_modules and specify that docker image as `fromImage`
> argument in my buildImage call I assume?
>
> I'm just not quite sure to make it all fit together. Maybe someone could
> help me out a bit?
> Thanks in advance!
>
> best regards,
> Tobi
>
> _______________________________________________
> nix-dev mailing list
> nix-dev at lists.science.uu.nl
> http://lists.science.uu.nl/mailman/listinfo/nix-dev
>
>
--
NixOS Linux <http://nixos.org>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.science.uu.nl/pipermail/nix-dev/attachments/20160923/1f554f51/attachment.html>
More information about the nix-dev
mailing list