From 6e8bcae48202b5246adfbf0792ecce54687fee1b Mon Sep 17 00:00:00 2001 From: "Grzegorz Wierzowiecki (gww-fuel)" Date: Thu, 21 Dec 2023 12:12:39 +0100 Subject: [PATCH] Dockerfile - improved caching! To learn more: https://docs.docker.com/build/cache/ . --- docker/Dockerfile | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/docker/Dockerfile b/docker/Dockerfile index 09504341..4202ec02 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -4,8 +4,9 @@ FROM nixos/nix # Set the working directory in the container WORKDIR /usr/src/app -# Copy the current directory contents into the container at /usr/src/app -COPY . . +# For better cashing, first copy only files that maybe required +# for building nix environment. +COPY *.nix manifests patch script . # Install the Fuel tools using Nix RUN nix-channel --add https://nixos.org/channels/nixos-unstable nixos \ @@ -13,9 +14,13 @@ RUN nix-channel --add https://nixos.org/channels/nixos-unstable nixos \ && nix --extra-experimental-features "nix-command flakes" build github:FuelLabs/fuel.nix#fuel # Correct URL to repository is : https://github.com/FuelLabs/fuel.nix/ +# Now, once we finished long, expensive nix building, we can +# copy over all contents of the current directory into the container at /usr/src/app +COPY . . + # Define environment variable for Nix ENV ENV="/root/.nix-profile/etc/profile.d/nix.sh" # Run a shell when the container launches -# CMD ["/bin/sh"] CMD ["/bin/bash"] +