diff --git a/docker/server/Dockerfile b/docker/server/Dockerfile index d767bc1..7b1fa45 100644 --- a/docker/server/Dockerfile +++ b/docker/server/Dockerfile @@ -15,9 +15,13 @@ EOF RUN cp "$(nix build nixpkgs#cacert --print-out-paths)/etc/ssl/certs/ca-bundle.crt" /tmp/ca-bundle.crt -COPY . /tmp/build +COPY flake.nix flake.lock /tmp/build WORKDIR /tmp/build +RUN --mount=type=ssh GIT_SSH_COMMAND="ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null" nix build --no-link '.#dependencies' + +COPY . /tmp/build + RUN --mount=type=ssh GIT_SSH_COMMAND="ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null" nix build '.#docker_env' # Export the built closure to a folder diff --git a/flake.nix b/flake.nix index 97e4696..1165a71 100644 --- a/flake.nix +++ b/flake.nix @@ -74,6 +74,11 @@ inherit (appliedOverlay.homepage) release ; + dependencies = pkgs.symlinkJoin { + # This is to enable the docker image to install all the dependencies, cache that layer, and then build the final site after the org source files have been loaded. Without this, every update to the blog posts would result in recompiling everything. + name = "homepage-dependencies"; + paths = appliedOverlay.homepage.dependencies; + }; docker_env = pkgs.stdenv.mkDerivation { pname = "homepage-docker-env"; version = "0.0.0"; @@ -100,14 +105,16 @@ natter' = (natter.overlays.default final final).natter.release; organic_ast_explorer' = (organic_ast_explorer.overlays.default final final).organic_ast_explorer.release; - release = homepageScope.callPackage ./nix/package.nix { + dependencies = { natter = natter'; organic_ast_explorer = organic_ast_explorer'; inherit homepage_private; }; + release = homepageScope.callPackage ./nix/package.nix dependencies; in { inherit release; + dependencies = (builtins.attrValues dependencies); } ); };