Skip to content

Commit

Permalink
Build the frontend with nix and add to container
Browse files Browse the repository at this point in the history
  • Loading branch information
choener committed Jan 8, 2025
1 parent 52c6ed2 commit 151fe3d
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion nix/containers.nix
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,23 @@ staticFiles = pkgs.buildEnv {
extraOutputsToInstall = [ "/html" ];
};

frontendNpm = pkgs.buildNpmPackage rec {
name = "frontend";
src = ../frontend;
npmDepsHash = "sha256-Oz7pdTMJVgGj5rzjIMvDjaOV7JU+hYLHoSSb+OcJARk=";
npmPackFlags = [ "--ignore-scripts" ];
installPhase = ''
mkdir -p $out/_next
cp -r .next/* $out/_next
rm -rf $out/_next/cache
'';
};

frontend = pkgs.buildEnv {
name = "frontend";
paths = [ frontendNpm ];
};

in rec {

# Builds a docker container for the cabal executable given as input. First we
Expand Down Expand Up @@ -52,8 +69,9 @@ in rec {
Entrypoint = lib.singleton (lib.getExe inputs.self.packages.wst-poc-cli);
};
layers = [
# npm-created data for frontend
(inputs.n2c.packages.nix2container.buildLayer {
copyToRoot = [staticFiles];
copyToRoot = [frontend];
})
];
};
Expand Down

0 comments on commit 151fe3d

Please sign in to comment.