diff options
author | Quentin Dufour <quentin@deuxfleurs.fr> | 2022-04-15 12:36:49 +0200 |
---|---|---|
committer | Quentin Dufour <quentin@deuxfleurs.fr> | 2022-04-15 12:36:49 +0200 |
commit | 8cf1b0c3e44f481abd7e07d0e793bd444a81fe52 (patch) | |
tree | ff82b26f40a9f47219fcd9f3105fb2b775111fa5 /app/backup/build/backup-psql | |
parent | 9701b863fd2703450abe19eda0940ee2faf1ec15 (diff) | |
download | infrastructure-8cf1b0c3e44f481abd7e07d0e793bd444a81fe52.tar.gz infrastructure-8cf1b0c3e44f481abd7e07d0e793bd444a81fe52.zip |
Build image via Nix
Diffstat (limited to 'app/backup/build/backup-psql')
-rw-r--r-- | app/backup/build/backup-psql/.gitignore | 1 | ||||
-rw-r--r-- | app/backup/build/backup-psql/README.md | 8 | ||||
-rwxr-xr-x | app/backup/build/backup-psql/backup-psql.py (renamed from app/backup/build/backup-psql/do_backup.py) | 0 | ||||
-rw-r--r-- | app/backup/build/backup-psql/common.nix | 8 | ||||
-rw-r--r-- | app/backup/build/backup-psql/default.nix | 39 | ||||
-rw-r--r-- | app/backup/build/backup-psql/docker.nix | 11 |
6 files changed, 56 insertions, 11 deletions
diff --git a/app/backup/build/backup-psql/.gitignore b/app/backup/build/backup-psql/.gitignore new file mode 100644 index 0000000..b2be92b --- /dev/null +++ b/app/backup/build/backup-psql/.gitignore @@ -0,0 +1 @@ +result diff --git a/app/backup/build/backup-psql/README.md b/app/backup/build/backup-psql/README.md new file mode 100644 index 0000000..97929db --- /dev/null +++ b/app/backup/build/backup-psql/README.md @@ -0,0 +1,8 @@ +## Build + +```bash +docker load < $(nix-build docker.nix) +docker push superboum/backup-psql:??? +``` + + diff --git a/app/backup/build/backup-psql/do_backup.py b/app/backup/build/backup-psql/backup-psql.py index fa0b94e..fa0b94e 100755 --- a/app/backup/build/backup-psql/do_backup.py +++ b/app/backup/build/backup-psql/backup-psql.py diff --git a/app/backup/build/backup-psql/common.nix b/app/backup/build/backup-psql/common.nix new file mode 100644 index 0000000..639d9a1 --- /dev/null +++ b/app/backup/build/backup-psql/common.nix @@ -0,0 +1,8 @@ +{ + pkgsSrc = fetchTarball { + # Latest commit on https://github.com/NixOS/nixpkgs/tree/nixos-21.11 + # As of 2022-04-15 + url ="https://github.com/NixOS/nixpkgs/archive/2f06b87f64bc06229e05045853e0876666e1b023.tar.gz"; + sha256 = "sha256:1d7zg96xw4qsqh7c89pgha9wkq3rbi9as3k3d88jlxy2z0ns0cy2"; + }; +} diff --git a/app/backup/build/backup-psql/default.nix b/app/backup/build/backup-psql/default.nix index 94dd4e1..1ded395 100644 --- a/app/backup/build/backup-psql/default.nix +++ b/app/backup/build/backup-psql/default.nix @@ -1,16 +1,33 @@ -{ pkgs ? import <nixpkgs> {} }: let + common = import ./common.nix; + pkgs = import common.pkgsSrc {}; python-with-my-packages = pkgs.python3.withPackages (p: with p; [ minio ]); in -pkgs.mkShell { - buildInputs = [ - python-with-my-packages - pkgs.age - pkgs.postgresql_14 - ]; - shellHook = '' - PYTHONPATH=${python-with-my-packages}/${python-with-my-packages.sitePackages} - ''; -} + pkgs.stdenv.mkDerivation { + name = "backup-psql"; + src = pkgs.lib.sourceFilesBySuffices ./. [ ".py" ]; + + buildInputs = [ + python-with-my-packages + pkgs.age + pkgs.postgresql_14 + ]; + + buildPhase = '' + cat > backup-psql <<EOF + #!${pkgs.bash}/bin/bash + export PYTHONPATH=${python-with-my-packages}/${python-with-my-packages.sitePackages} + python3 $out/lib/backup-psql.py + EOF + chmod +x backup-psql + ''; + + installPhase = '' + mkdir -p $out/{bin,lib} + cp *.py $out/lib/backup-psql.py + cp backup-psql $out/bin/backup-sql + ''; + } + diff --git a/app/backup/build/backup-psql/docker.nix b/app/backup/build/backup-psql/docker.nix new file mode 100644 index 0000000..001cada --- /dev/null +++ b/app/backup/build/backup-psql/docker.nix @@ -0,0 +1,11 @@ +let + common = import ./common.nix; + app = import ./default.nix; + pkgs = import common.pkgsSrc {}; +in + pkgs.dockerTools.buildLayeredImage { + name = "superboum/backup-psql-docker"; + config = { + Cmd = [ "${app}/bin/backup-psql" ]; + }; + } |