about summary refs log tree commit diff stats
path: root/nix/default.nix
diff options
context:
space:
mode:
authorAlan Pearce2024-04-20 18:29:18 +0200
committerAlan Pearce2024-04-20 18:29:18 +0200
commitcc2245f991ca0474e3d4db9fa213be4aa8ccccb7 (patch)
tree81dff8c64a1f1c5c81e6fe8a19e4172d6e77d930 /nix/default.nix
parent3da735c4e72f8de390e5f4f0df63476cac43b6b1 (diff)
downloadwebsite-cc2245f991ca0474e3d4db9fa213be4aa8ccccb7.tar.lz
website-cc2245f991ca0474e3d4db9fa213be4aa8ccccb7.tar.zst
website-cc2245f991ca0474e3d4db9fa213be4aa8ccccb7.zip
Use gitlab CI
commit 3bca937c9ff91852269a828de0c778db7d1423df
Author: Alan Pearce <alan@alanpearce.eu>
Date:   Sat Apr 20 01:14:26 2024 +0200

    create gitlab CI configuration

commit ee9eeab17ac88f4020d857dcceb458c66418e2f6
Author: Alan Pearce <alan@alanpearce.eu>
Date:   Sat Apr 20 16:07:01 2024 +0200

    make helpers for both building and streaming docker images

commit d8340ec8ff3e3f9c51b55e95e27e518330435b7c
Author: Alan Pearce <alan@alanpearce.eu>
Date:   Sat Apr 20 00:20:34 2024 +0200

    use long git hashes for docker tags
Diffstat (limited to 'nix/default.nix')
-rw-r--r--nix/default.nix19
1 files changed, 11 insertions, 8 deletions
diff --git a/nix/default.nix b/nix/default.nix
index d586e2b..cd62ebf 100644
--- a/nix/default.nix
+++ b/nix/default.nix
@@ -3,16 +3,15 @@ let
   revision = "${self.lastModifiedDate}-${self.shortRev or self.dirtyShortRev or "dirty"}";
   version = self.shortRev or self.dirtyShortRev or "unstable-${self.lastModified}";
   dockerTag = self.rev or self.dirtyRev or "unstable-${self.lastModified}";
-  mkDocker = server:
+  mkDocker = type: server:
     let
       PORT = 3000;
     in
-    pkgs.dockerTools.streamLayeredImage {
+    pkgs.dockerTools.${type} {
       name = "registry.fly.io/alanpearce-eu";
       tag = dockerTag;
-      contents = [ server ];
       config = {
-        Cmd = [ "website" ];
+        Cmd = [ "${server}/bin/website" ];
         Env = [
           "PRODUCTION=true"
           "PORT=${builtins.toString PORT}"
@@ -23,6 +22,8 @@ let
         };
       };
     };
+  mkDockerStream = mkDocker "streamLayeredImage";
+  mkDockerImage = mkDocker "buildLayeredImage";
 in
 rec {
   default = server;
@@ -66,8 +67,10 @@ rec {
     modules = ./gomod2nix.toml;
     ldflags = [ "-s" "-w" "-X" "main.Commit=${version}" ];
   };
-  docker = mkDocker server;
-  docker-aarch64-linux = mkDocker (self.packages.aarch64-linux.server);
-  docker-x86_64-linux = mkDocker (self.packages.x86_64-linux.server);
-  fly = docker-x86_64-linux;
+  docker-stream = mkDockerStream server;
+  docker-stream-aarch64-linux = mkDockerStream (self.packages.aarch64-linux.server);
+  docker-stream-x86_64-linux = mkDockerStream (self.packages.x86_64-linux.server);
+  docker-image = mkDockerImage server;
+  docker-image-aarch64-linux = mkDockerImage (self.packages.aarch64-linux.server);
+  docker-image-x86_64-linux = mkDockerImage (self.packages.x86_64-linux.server);
 }