Add container build

This commit is contained in:
Yannik Rödel 2022-02-24 22:08:34 +01:00
parent b1365bde04
commit dc6db55181
2 changed files with 26 additions and 17 deletions

12
flake.lock generated
View file

@ -2,11 +2,11 @@
"nodes": {
"flake-utils": {
"locked": {
"lastModified": 1631561581,
"narHash": "sha256-3VQMV5zvxaVLvqqUrNz3iJelLw30mIVSfZmAaauM3dA=",
"lastModified": 1644229661,
"narHash": "sha256-1YdnJAsNy69bpcjuoKdOYQX0YxZBiCYZo4Twxerqv7k=",
"owner": "numtide",
"repo": "flake-utils",
"rev": "7e5bf3925f6fbdfaf50a2a7ca0be2879c4261d19",
"rev": "3cecb5b042f7f209c56ffd8371b2711a290ec797",
"type": "github"
},
"original": {
@ -17,11 +17,11 @@
},
"nixpkgs": {
"locked": {
"lastModified": 1633528625,
"narHash": "sha256-AGj5q58eHACAe0RQGxObrGwMUsjMozTsiznhsLCYisQ=",
"lastModified": 1645433236,
"narHash": "sha256-4va4MvJ076XyPp5h8sm5eMQvCrJ6yZAbBmyw95dGyw4=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "5e2018f7b383aeca6824a30c0cd1978c9532a46a",
"rev": "7f9b6e2babf232412682c09e57ed666d8f84ac2d",
"type": "github"
},
"original": {

View file

@ -18,8 +18,8 @@
dontNpmInstall = true;
};
angestoepseltSite = pkgs.stdenv.mkDerivation {
name = "angestoepseltSite";
site = pkgs.stdenv.mkDerivation {
name = "angestoepselt-site";
src = self;
buildInputs = [ nodejs nodeDependencies ];
@ -29,17 +29,26 @@
'';
installPhase = ''
mkdir -p "$out"
cp -r _site "$out/www"
mv dist $out
'';
};
container = pkgs.dockerTools.buildImage {
name = "angestoepselt-site";
tag = "latest";
config = {
Cmd = [
"${pkgs.caddy}/bin/caddy"
"file-server"
"-root" "${site}"
];
};
};
in
rec {
apps = { inherit angestoepseltSite; };
defaultApp = apps.angestoepseltSite;
packages = {
inherit angestoepseltSite;
inherit site container;
# This package isn't actually the fully-built site, but rather a
# derivation that contains the relevant programs (with correctly set up
@ -47,8 +56,8 @@
# `nix develop` see the repository's readme for details or compiled
# with `nix build`. The latter will output a folder which contains node
# and npm binaries that can be used in an IDE.
angestoepseltSiteEnv = pkgs.symlinkJoin {
name = "angestoepseltSiteEnv";
devEnv = pkgs.symlinkJoin {
name = "devEnv";
buildInputs = [ pkgs.makeWrapper ];
paths = [ nodejs nodeDependencies ];
@ -78,7 +87,7 @@
};
defaultPackage = packages.angestoepseltSite;
devShell = packages.angestoepseltSiteEnv;
devShell = packages.devEnv;
}
);
}