diff --git a/.drone.yml b/.drone.yml index 6d5d0b6..8af1647 100644 --- a/.drone.yml +++ b/.drone.yml @@ -29,6 +29,8 @@ steps: - push-container result --repository network/healthchecks-maintenance - nix build -L .#migrate - push-container result --repository network/healthchecks-migrate + - nix build -L .#static + - push-container result --repository network/healthchecks-static settings: registry: r.ocj.io username: diff --git a/flake.lock b/flake.lock index a3be552..430df0b 100644 --- a/flake.lock +++ b/flake.lock @@ -2,11 +2,11 @@ "nodes": { "nixpkgs": { "locked": { - "lastModified": 1681648924, - "narHash": "sha256-pzi3HISK8+7mpEtv08Yr80wswyHKsz+RP1CROG1Qf6s=", + "lastModified": 1682879489, + "narHash": "sha256-sASwo8gBt7JDnOOstnps90K1wxmVfyhsTPPNTGBPjjg=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "f294325aed382b66c7a188482101b0f336d1d7db", + "rev": "da45bf6ec7bbcc5d1e14d3795c025199f28e0de0", "type": "github" }, "original": { diff --git a/flake.nix b/flake.nix index 035fa0e..0ce8ca3 100644 --- a/flake.nix +++ b/flake.nix @@ -36,7 +36,7 @@ "PYTHONPATH=${self.packages.${system}.healthchecks.pythonPath}" "PYTHONUNBUFFERED=1" "SSL_CERT_FILE=${pkgs.cacert}/etc/ssl/certs/ca-bundle.crt" - "STATIC_ROOT=${self.packages.${system}.healthchecks}/static" + "STATIC_ROOT=${self.packages.${system}.healthchecks.static}" ]; }; }; @@ -76,6 +76,8 @@ inherit pname version propagatedBuildInputs; format = "other"; + outputs = [ "out" "static" "doc" ]; + src = pkgs.fetchFromGitHub { owner = "healthchecks"; repo = pname; @@ -83,13 +85,25 @@ inherit hash; }; + dontPatch = true; + dontConfigure = true; + dontBuild = true; + doCheck = false; + dontFixup = true; + installPhase = '' mkdir -p $out/app - cp -r . $out/app + cp -r hc manage.py templates $out/app chmod +x $out/app/manage.py cp ${localSettings} $out/app/hc/local_settings.py - DEBUG=False SECRET_KEY=build-key STATIC_ROOT=$out/static ${py}/bin/python $out/app/manage.py collectstatic --noinput - DEBUG=False SECRET_KEY=build-key STATIC_ROOT=$out/static ${py}/bin/python $out/app/manage.py compress + + mkdir -p $doc + cp -r *.md LICENSE $doc + + mkdir -p $static + DEBUG=False SECRET_KEY=build-key STATIC_ROOT=$static ${py}/bin/python ./manage.py collectstatic --noinput + DEBUG=False SECRET_KEY=build-key STATIC_ROOT=$static ${py}/bin/python ./manage.py compress + cp -r static-collected/* $static ''; passthru = { @@ -198,7 +212,6 @@ plugins = python3 post-buffering = 4096 processes = 4 - static-map = /static=${self.packages.${system}.healthchecks}/static threads = 1 thunder-lock ''; @@ -222,6 +235,24 @@ }; } ); + + static = pkgs.dockerTools.buildLayeredImage { + name = "healthchecks-static"; + tag = "latest"; + maxLayers = 2; + config = { + User = "5000:5000"; + Cmd = [ + "${pkgs.static-web-server}/bin/static-web-server" + "--port=8000" + "--root=${self.packages.${system}.healthchecks.static}" + ]; + ExposedPorts = { + "8000/tcp" = { }; + }; + }; + }; + }; }; }