Attempt to get Docker build working

pull/1/head
mat ess 2022-09-06 00:36:55 -04:00
parent 708609b6d2
commit 91e24c5672
4 changed files with 44 additions and 17 deletions

View File

@ -20,10 +20,6 @@ http://static-mat-services.fly.dev {
file_server
}
log {
output stdout
}
header {
# disable FLoC tracking
Permissions-Policy interest-cohort=()
@ -40,22 +36,28 @@ http://static-mat-services.fly.dev {
# style-src 'unsafe-inline': syntax highlighting in codefences
# sandbox allow-popups: enable target="_blank" links to open in new tabs
Content-Security-Policy "default-src 'none';
img-src 'self';
img-src 'self' https://stats.mat.services;
style-src 'self' 'unsafe-inline';
font-src 'self';
script-src 'self';
script-src 'self' https://stats.mat.services;
form-action 'none';
frame-ancestors 'none';
base-uri 'none';
upgrade-insecure-requests;
sandbox allow-same-origin allow-popups allow-popups-to-escape-sandbox"
sandbox
allow-same-origin
allow-scripts
allow-popups
allow-popups-to-escape-sandbox"
}
# caching
@static {
path *.bmp *.jpg *.png *.svg *.gif *.pdf *.css *.js *.woff *.woff2
}
route {
header /style/* Cache-Control max-age=31536000, immutable
header /image/* Cache-Control max-age=31536000, immutable
header /font/* Cache-Control max-age=31536000, immutable
header Cache-Control max-age=180
header /sitemap.xml Cache-Control max-age=0
header @static Cache-Control max-age=31536000, immutable
}
}

View File

@ -36,6 +36,26 @@
"type": "github"
}
},
"gitignore": {
"inputs": {
"nixpkgs": [
"nixpkgs"
]
},
"locked": {
"lastModified": 1660459072,
"narHash": "sha256-8DFJjXG8zqoONA1vXtgeKXy68KdJL5UaXR8NtVMUbx8=",
"owner": "hercules-ci",
"repo": "gitignore.nix",
"rev": "a20de23b925fd8264fd7fad6454652e142fd7f73",
"type": "github"
},
"original": {
"owner": "hercules-ci",
"repo": "gitignore.nix",
"type": "github"
}
},
"nixpkgs": {
"locked": {
"lastModified": 1661450036,
@ -56,6 +76,7 @@
"inputs": {
"apollo": "apollo",
"flake-parts": "flake-parts",
"gitignore": "gitignore",
"nixpkgs": "nixpkgs"
}
}

View File

@ -5,18 +5,21 @@
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
flake-parts.url = "github:hercules-ci/flake-parts";
flake-parts.inputs.nixpkgs.follows = "nixpkgs";
gitignore.url = "github:hercules-ci/gitignore.nix";
gitignore.inputs.nixpkgs.follows = "nixpkgs";
# theme - inlined now, not used
apollo.url = "github:not-matthias/apollo";
apollo.flake = false;
};
outputs = { self, flake-parts, ... }@inputs:
outputs = { self, flake-parts, gitignore, ... }@inputs:
flake-parts.lib.mkFlake { inherit self; } {
imports = [ ];
systems = inputs.nixpkgs.lib.systems.flakeExposed;
perSystem = { config, self', inputs', pkgs, system, ... }:
let
inherit (gitignore.lib) gitignoreSource;
# TODO: move these to a flake-module
inherit (pkgs.callPackage ./nix { }) container deploy fonts optimize-images themes;
inherit (fonts) copyFonts linkFonts;
@ -28,8 +31,8 @@
{
packages.default = with pkgs; stdenv.mkDerivation {
pname = "personal-site";
version = "2022-08-27";
src = ./.;
version = "2022-09-06";
src = gitignoreSource ./.;
nativeBuildInputs = [ optimize-images zola ];
configurePhase = copyTheme + copyFonts;
buildPhase = ''
@ -45,11 +48,11 @@
shellHook = linkTheme + linkFonts;
};
packages.container = container {
caddyfile = builtins.readFile ./Caddyfile;
caddyfile = ./Caddyfile;
site = config.packages.default;
};
apps.deploy.program =
let deploy' = deploy { dockerImage = config.packages.container; };
let deploy' = deploy { dockerImage = self.packages.x86_64-linux.container; };
in "${deploy'}/bin/deploy";
};
};

View File

@ -4,6 +4,7 @@ writeShellScriptBin "deploy" ''
set -euxo pipefail
export PATH="${lib.makeBinPath [(docker.override { clientOnly = true; }) flyctl]}:$PATH"
archive=${dockerImage}
image=$(docker load < $archive | awk '{ print $3; }')
flyctl deploy -i $image
# load archive, drop all output except last line (in case of warnings), print image name
image=$(docker load < $archive | tail -n1 | awk '{ print $3; }')
flyctl deploy --image $image --local-only
''