From 927329de79257d272947e3f883ad574261ff8060 Mon Sep 17 00:00:00 2001 From: pacien Date: Fri, 30 Jul 2021 01:13:20 +0200 Subject: docs: add container-based cloud deployment to Heroku --- flake.nix | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) (limited to 'flake.nix') diff --git a/flake.nix b/flake.nix index b8616f8..5f63359 100644 --- a/flake.nix +++ b/flake.nix @@ -31,6 +31,9 @@ develPackagesAndScripts = [ postgresql_13 # PostgreSQL server with the standard admin tools. python.pkgs.ipython # Interactive Python REPL for experimenting. + heroku # CLI for the Heroku hosting platform. + skopeo # Docker container upload utility. + pwgen # Simple random token generator. # More pleasant alternative to psql, with colours and auto-completion. # Custom configuration to suppress irrelevant warnings and messages. @@ -92,7 +95,7 @@ in { - packages = { + packages = rec { # Minimal production server. # This includes only application files tracked by git. # Using `gunicorn` on top of `uvicorn` is recommended for bigger loads. @@ -100,6 +103,16 @@ cd ${./.} ${pythonWithDependencies}/bin/uvicorn --app-dir app app:main "$@" ''; + + # Minimal docker image. + # The Heroku hosting service assigns the `$PORT` dynamically. + docker = dockerTools.streamLayeredImage { + maxLayers = 2; + name = "app-docker"; + config.EntryPoint = writeShellScript "run.sh" '' + ${server} --host 0.0.0.0 --port $PORT + ''; + }; }; devShell = mkShell rec { -- cgit v1.2.3