From 2a2259f049859ff09070ed0c052208fb227331c6 Mon Sep 17 00:00:00 2001 From: Adithya Nair Date: Thu, 4 Jan 2024 18:27:38 +0530 Subject: [PATCH] dockerize --- .dockerignore | 7 +++++++ Dockerfile | 10 ++++++++++ flake.nix | 15 ++++++++++----- 3 files changed, 27 insertions(+), 5 deletions(-) create mode 100644 .dockerignore create mode 100644 Dockerfile diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..971fbd3 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,7 @@ +.direnv/ +.git/ +.github/ +.pub/ +result +update-version.sh +Dockerfile diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..4ac8b9c --- /dev/null +++ b/Dockerfile @@ -0,0 +1,10 @@ +FROM nixos/nix:latest +WORKDIR /app +COPY . . + +RUN nix \ + --extra-experimental-features "nix-command flakes" \ + build .#app + +CMD [ "/app/result/bin/app" ] + diff --git a/flake.nix b/flake.nix index c68c703..24b5308 100644 --- a/flake.nix +++ b/flake.nix @@ -18,16 +18,21 @@ pkgs = import nixpkgs { inherit system; }; + package = pkgs.callPackage ./default.nix { }; + app = pkgs.writeShellScriptBin "app" "${pkgs.merecat}/bin/merecat -n -p 8080 ${package}/share/web"; in - with pkgs; { - formatter = nixpkgs-fmt; - devShells.default = mkShell { - packages = [ + { + formatter = pkgs.nixpkgs-fmt; + devShells.default = pkgs.mkShell { + packages = with pkgs; [ mdbook tailwindcss-language-server ]; }; - packages.default = callPackage ./default.nix { }; + packages = { + inherit app; + default = package; + }; } ); }