diff options
author | Alan Pearce | 2023-06-30 18:42:51 +0200 |
---|---|---|
committer | Alan Pearce | 2023-06-30 18:42:51 +0200 |
commit | 90c15edbc8c4b664704f4e205cffcfeff578f98c (patch) | |
tree | ef71c59e931729d46e221dcecf44ee5d89ac8b87 | |
parent | 416aed825565074c19ab4550766da1623b8bb326 (diff) | |
download | website-90c15edbc8c4b664704f4e205cffcfeff578f98c.tar.lz website-90c15edbc8c4b664704f4e205cffcfeff578f98c.tar.zst website-90c15edbc8c4b664704f4e205cffcfeff578f98c.zip |
Build docker image
-rw-r--r-- | Caddyfile | 25 | ||||
-rw-r--r-- | flake.lock | 16 | ||||
-rw-r--r-- | flake.nix | 89 |
3 files changed, 106 insertions, 24 deletions
diff --git a/Caddyfile b/Caddyfile new file mode 100644 index 0000000..6e62a6d --- /dev/null +++ b/Caddyfile @@ -0,0 +1,25 @@ +http:// { + root * public/ + file_server { + precompressed br zstd gzip + } + header { + Cache-Control max-age=14400 + X-Content-Type-Options nosniff + Strict-Transport-Security "max-age=31536000; includeSubDomains; preload" + } + handle_errors { + @404 expression `{err.status_code} == 404` + handle @404 { + rewrite * /404.html + } + file_server { + precompressed br zstd gzip + } + } + header /feed-styles/ Content-Type text/xsl + error /feed-styles/index.html* 404 + respond /favicon.ico 204 + redir /index.xml /atom.xml + redir /post/index.xml /atom.xml +} diff --git a/flake.lock b/flake.lock index 9b67443..dc17e6c 100644 --- a/flake.lock +++ b/flake.lock @@ -34,6 +34,21 @@ "type": "github" } }, + "flockenzeit": { + "locked": { + "lastModified": 1671185345, + "narHash": "sha256-+5IWi+iJAYcRxvLN15hKO2hVwNokfN3U+lvWf/zFtCg=", + "owner": "balsoft", + "repo": "Flockenzeit", + "rev": "90abba65671690d95b5d28ce6dd8de7959aa1339", + "type": "github" + }, + "original": { + "owner": "balsoft", + "repo": "Flockenzeit", + "type": "github" + } + }, "nixpkgs": { "locked": { "lastModified": 1681124868, @@ -54,6 +69,7 @@ "inputs": { "flake-compat": "flake-compat", "flake-utils": "flake-utils", + "flockenzeit": "flockenzeit", "nixpkgs": "nixpkgs" } }, diff --git a/flake.nix b/flake.nix index 9cf8588..e4067e5 100644 --- a/flake.nix +++ b/flake.nix @@ -1,38 +1,79 @@ { description = "My website, alanpearce.eu"; inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable"; + inputs.flockenzeit.url = "github:balsoft/Flockenzeit"; inputs.flake-utils.url = "github:numtide/flake-utils"; inputs.flake-compat = { url = "github:edolstra/flake-compat"; flake = false; }; - outputs = { self, nixpkgs, flake-utils, flake-compat }: - flake-utils.lib.eachDefaultSystem (system: - let - pkgs = nixpkgs.legacyPackages.${system}; - in - { - packages = { - default = pkgs.stdenv.mkDerivation { - name = "alanpearce.eu"; - src = self; + outputs = { self, nixpkgs, flockenzeit, flake-utils, ... }: + flake-utils.lib.eachDefaultSystem + (system: + let + pkgs = nixpkgs.legacyPackages.${system}; + nativeBuildInputs = with pkgs; [ + zola + nodePackages_latest.prettier + fd + brotli + gzip + zstd + git + ]; + in + rec { + packages = { + default = pkgs.stdenv.mkDerivation { + name = "alanpearce.eu"; + src = self; - enableParallelBuilding = true; - makeFlags = [ "PREFIX=$(out)" ]; + enableParallelBuilding = true; + makeFlags = [ "PREFIX=$(out)/public" ]; - nativeBuildInputs = with pkgs; [ - zola - nodePackages_latest.prettier - fd - brotli - gzip - zstd - git - ]; + inherit nativeBuildInputs; + + dontFixup = true; - dontFixup = true; + postInstall = '' + cp Caddyfile $out/ + ''; + }; + docker = pkgs.dockerTools.buildImage { + name = "alanpearce/website"; + fromImage = pkgs.dockerTools.pullImage { + imageName = "caddy"; + finalImageName = "caddy"; + finalImageTag = "2-alpine"; + imageDigest = "sha256:d4ca216d8dc515a49bc20fa22a449283ade6c8fc132eb6fa412ff351664d4917"; + sha256 = "auFzOG+6PSOVNXXXsRsEEThtIHJYM3JUkMQGcUt4cNQ="; + }; + created = flockenzeit.lib.ISO-8601 self.lastModified; + copyToRoot = pkgs.buildEnv { + name = "website"; + paths = with pkgs; [ + packages.default + nss.tools + ]; + pathsToLink = [ "/bin" "/public" ]; + }; + config = { + WorkingDir = "${packages.default}"; + ExposedPorts = { + "80/tcp" = { }; + }; + Volumes = { + "/data" = { }; + }; + }; + }; + }; + devShell = pkgs.mkShell { + buildInputs = [ + nativeBuildInputs + pkgs.flyctl + ]; }; - }; - }); + }); } |