about summary refs log tree commit diff stats
path: root/default.nix
diff options
context:
space:
mode:
authorAlan Pearce2024-06-25 17:07:47 +0200
committerAlan Pearce2024-06-25 17:07:47 +0200
commitcd1125a213d742b5a89e8b60f0c7aafef13b8783 (patch)
treeb3271d6883c15eea11252d76b3a7c4c6626e1ded /default.nix
parent83a4eef89b9906d8ad90411e9b256da6dab07b55 (diff)
downloadwebsite-cd1125a213d742b5a89e8b60f0c7aafef13b8783.tar.lz
website-cd1125a213d742b5a89e8b60f0c7aafef13b8783.tar.zst
website-cd1125a213d742b5a89e8b60f0c7aafef13b8783.zip
fetch and build site on server start
Diffstat (limited to 'default.nix')
-rw-r--r--default.nix48
1 files changed, 5 insertions, 43 deletions
diff --git a/default.nix b/default.nix
index d135453..2949836 100644
--- a/default.nix
+++ b/default.nix
@@ -14,7 +14,7 @@ let
     runCommandLocal;
 
   version = "unstable";
-  mkDocker = type: { server, website, architecture ? pkgs.go.GOARCH }:
+  mkDocker = type: { server, architecture ? pkgs.go.GOARCH }:
     pkgs.dockerTools.${type} {
       name = "registry.fly.io/alanpearce-eu";
       contents = with pkgs; [
@@ -26,10 +26,10 @@ let
         Env = [
           "PRODUCTION=true"
           "LISTEN_ADDRESS=::"
-          "ROOT=."
+          "ROOT=/data"
           "PORT=80"
         ];
-        WorkingDir = website;
+        WorkingDir = "/data";
         ExposedPorts = {
           "80/tcp" = { };
           "443/tcp" = { };
@@ -61,42 +61,6 @@ rec {
       };
     };
   };
-  builder = buildGoApplication {
-    pname = "website-builder";
-    inherit version;
-    CGO_ENABLED = 0;
-    src = with lib.fileset; toSource {
-      root = ./.;
-      fileset = unions [
-        ./go.mod
-        ./go.sum
-        ./cmd/build
-        ./internal
-        ./templates
-      ];
-    };
-    modules = ./nix/gomod2nix.toml;
-    patchPhase = ''
-      ${pkgs.templ}/bin/templ generate
-    '';
-    subPackages = [ "cmd/build" ];
-  };
-  website = runCommandLocal "build"
-    {
-      src = with lib.fileset; toSource {
-        root = ./.;
-        fileset = unions [
-          ./config.toml
-          ./content
-          ./static
-          ./templates
-        ];
-      };
-    } ''
-    cd $src
-    ${builder}/bin/build -s $src -d $out
-    cp $src/config.toml $out/
-  '';
   server = buildGoApplication {
     pname = "server";
     inherit version;
@@ -122,8 +86,8 @@ rec {
       "-w"
     ];
   };
-  docker-stream = mkDockerStream { inherit server website; };
-  docker-image = mkDockerImage { inherit server website; };
+  docker-stream = mkDockerStream { inherit server; };
+  docker-image = mkDockerImage { inherit server; };
 
   server-amd64-linux = server.overrideAttrs (old: old // {
     GOOS = "linux";
@@ -137,12 +101,10 @@ rec {
     '';
   });
   docker-image-amd64-linux = mkDockerImage {
-    inherit website;
     server = server-amd64-linux;
     architecture = "amd64";
   };
   docker-stream-amd64-linux = mkDockerStream {
-    inherit website;
     server = server-amd64-linux;
     architecture = "amd64";
   };