Rework nix + docker
parent
e8a2567cef
commit
d709014b31
|
@ -8,7 +8,7 @@ http://static-mat-services.fly.dev {
|
|||
}
|
||||
|
||||
:8080 {
|
||||
root * /var/www
|
||||
root * {$SITE_ROOT}
|
||||
encode gzip
|
||||
file_server
|
||||
|
||||
|
|
17
flake.nix
17
flake.nix
|
@ -17,10 +17,9 @@
|
|||
systems = inputs.nixpkgs.lib.systems.flakeExposed;
|
||||
perSystem = { config, self', inputs', pkgs, system, ... }:
|
||||
let
|
||||
inherit (pkgs) callPackage;
|
||||
optimize-images = callPackage ./nix/optimize-images.nix { };
|
||||
inherit (callPackage ./nix/fonts.nix { }) copyFonts linkFonts;
|
||||
inherit (callPackage ./nix/theme.nix {
|
||||
inherit (pkgs.callPackage ./nix { }) deploy docker fonts optimize-images themes;
|
||||
inherit (fonts) copyFonts linkFonts;
|
||||
inherit (themes {
|
||||
theme = inputs.apollo;
|
||||
themeEnabled = false;
|
||||
}) copyTheme linkTheme;
|
||||
|
@ -38,17 +37,19 @@
|
|||
'';
|
||||
installPhase = ''
|
||||
cp -r public $out
|
||||
cp Caddyfile $out
|
||||
'';
|
||||
};
|
||||
devShells.default = with pkgs; mkShell {
|
||||
packages = [ flyctl optimize-images zola ];
|
||||
shellHook = linkTheme + linkFonts;
|
||||
};
|
||||
packages.docker = callPackage ./nix/docker.nix { site = self'.packages.default; };
|
||||
packages.docker = docker {
|
||||
caddyfile = builtins.readFile ./Caddyfile;
|
||||
site = self'.packages.default;
|
||||
};
|
||||
apps.deploy.program =
|
||||
let deploy = callPackage ./nix/deploy.nix { dockerImg = self'.packages.docker; };
|
||||
in "${deploy}/bin/deploy";
|
||||
let deploy' = deploy { dockerImage = self'.packages.docker; };
|
||||
in "${deploy'}/bin/deploy";
|
||||
};
|
||||
};
|
||||
}
|
||||
|
|
|
@ -0,0 +1,7 @@
|
|||
{ callPackage }: {
|
||||
deploy = { dockerImage }: callPackage ./deploy.nix { inherit dockerImage; };
|
||||
docker = { caddyfile, site }: callPackage ./docker.nix { inherit caddyfile site; };
|
||||
fonts = callPackage ./fonts.nix { };
|
||||
optimize-images = callPackage ./optimize-images.nix { };
|
||||
themes = { theme, themeEnabled }: callPackage ./themes.nix { inherit theme themeEnabled; };
|
||||
}
|
|
@ -1,9 +1,9 @@
|
|||
{ lib, docker, flyctl, formats, writeShellScriptBin, dockerImg }:
|
||||
{ lib, docker, flyctl, formats, writeShellScriptBin, dockerImage }:
|
||||
|
||||
writeShellScriptBin "deploy" ''
|
||||
set -euxo pipefail
|
||||
export PATH="${lib.makeBinPath [(docker.override { clientOnly = true; }) flyctl]}:$PATH"
|
||||
archive=${dockerImg}
|
||||
archive=${dockerImage}
|
||||
image=$(docker load < $archive | awk '{ print $3; }')
|
||||
flyctl deploy -i $image
|
||||
''
|
||||
|
|
|
@ -1,11 +1,13 @@
|
|||
{ dockerTools, caddy, site }:
|
||||
{ dockerTools, caddy, caddyfile, site }:
|
||||
|
||||
dockerTools.buildLayeredImage {
|
||||
name = site.pname;
|
||||
tag = site.version;
|
||||
contents = [ site caddy ];
|
||||
|
||||
config = {
|
||||
Cmd = [ "${caddy}/bin/caddy" "run" "-config" "${site}/Caddyfile" ];
|
||||
Cmd = [ "${caddy}/bin/caddy" "run" "-config" "${caddyfile}" ];
|
||||
Env = [
|
||||
"SITE_ROOT=${site}"
|
||||
];
|
||||
};
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue