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

View file

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