From 151fe3d651d86ea2e24b426c78dd187f4e5415e7 Mon Sep 17 00:00:00 2001 From: Christian Hoener zu Siederdissen Date: Tue, 7 Jan 2025 14:32:40 +0100 Subject: [PATCH] Build the frontend with nix and add to container --- nix/containers.nix | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/nix/containers.nix b/nix/containers.nix index 0e8ff68..e642fd7 100644 --- a/nix/containers.nix +++ b/nix/containers.nix @@ -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 @@ -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]; }) ]; };