diff options
author | William Carroll <wpcarro@gmail.com> | 2023-01-03T01·42-0800 |
---|---|---|
committer | wpcarro <wpcarro@gmail.com> | 2023-01-18T03·11+0000 |
commit | 98b155c8c1c13afb2e3d542f9c8c4c65352f8d5f (patch) | |
tree | 050554dc3261cb82bfe7171eb6e2be91e049c0fc | |
parent | 6078d6eade84c7504bdeda3f8fcd7ca001e401a7 (diff) |
feat(wpcarro/website): Prefer docker image r/5686
Google Cloud Run uses images to define services, so: ```shell $ mg build :image $ docker load <./result $ docker tag website:latest gcr.io/wpcarros-infrastructure/website:latest $ docker push gcr.io/wpcarros-infrastructure/website:latest ``` And then restart the service with `:latest`. TODO: Figure-out some ~sane CI solution (maybe personal Buildkite). Change-Id: I5734e3344779552aba7e0478321ba99610204e29 Reviewed-on: https://cl.tvl.fyi/c/depot/+/7735 Reviewed-by: wpcarro <wpcarro@gmail.com> Tested-by: BuildkiteCI
-rw-r--r-- | users/wpcarro/website/default.nix | 38 |
1 files changed, 36 insertions, 2 deletions
diff --git a/users/wpcarro/website/default.nix b/users/wpcarro/website/default.nix index 047b783e3049..56f5b02cc89d 100644 --- a/users/wpcarro/website/default.nix +++ b/users/wpcarro/website/default.nix @@ -23,11 +23,28 @@ let withBrand = contentHtml: renderTemplate ./fragments/template.html { inherit contentHtml; }; + + # Create a simple static file server using nginx to serve `content`. + nginxCfgFor = content: pkgs.writeText "nginx.conf" '' + user nobody nobody; + daemon off; + error_log /dev/stdout info; + pid /dev/null; + events {} + http { + server { + listen 8080; + location / { + root ${content}; + } + } + } + ''; in -{ +rec { inherit domain renderTemplate withBrand; - root = pkgs.runCommand "wpcarro.dev" { } '' + content = pkgs.runCommand "wpcarro.dev" { } '' mkdir -p $out # / @@ -40,4 +57,21 @@ in # /blog cp -r ${wpcarro.website.blog} $out/blog ''; + + # Create a docker image suitable for Google Cloud Run (to save costs). + image = pkgs.dockerTools.buildLayeredImage { + name = "website"; + tag = "latest"; + contents = [ pkgs.fakeNss ]; + extraCommands = '' + mkdir -p tmp/nginx_client_body + mkdir -p var/log/nginx + ''; + config = { + Cmd = [ "${pkgs.nginx}/bin/nginx" "-c" (nginxCfgFor content) ]; + ExposedPorts = { "8080/tcp" = { }; }; + }; + }; + + meta.ci.targets = [ "root" "image" ]; } |