Commit 9f65c474 authored by Profpatsch's avatar Profpatsch

containers/postgres: add an option to enable mock data

parent 3787010c
{ lib, pkgs, config, testing, ... }:
let
cfg = config.org.techcultivation.deploy.database;
# set database connection values
connectionData = {
......@@ -123,9 +124,14 @@ in {
let
userName = "postgres";
isDev = cfg.dockerImage.insertMockData;
image = pkgs.helpers.createStandaloneDockerImage {
name = "sangha-postgres";
tag = "unstable";
tag =
if isDev
then "dev"
else "deployment";
description = ''
Docker image containing a minimal postgres closure
and an initialized sangha database template in a volume.
......@@ -144,15 +150,21 @@ in {
config = {
User = userName;
Cmd = [ dockerCmd ];
Env = [
"PGDATA=${dbDir}"
];
ExposedPorts."${toString connectionData.Port}/tcp" = {};
}
# only if mock data should be inserted
// (if cfg.dockerImage.insertMockData then {
Env =
lib.optional
cfg.dockerImage.insertMockData
"PGDATA=${dbDir}";
# we create a volume so the db is persistent over restarts
Volumes."${dbDir}" = {};
};
} else {});
rootSetupScript = ''
rootSetupScript =
# setup for mock data
lib.optionalString cfg.dockerImage.insertMockData ''
cp -r "${sanghaInitDatabase}" "./${dbDir}"
chmod --recursive u=rwX,go= "./${dbDir}"
chown --recursive ${userName}:${userName} "./${dbDir}"
......@@ -200,9 +212,6 @@ in {
tests.dockerImages.sanghaPostgres = dockerTest;
};
in
let
cfg = config.org.techcultivation.deploy.database;
in
lib.mkMerge [
(lib.mkIf cfg.enable nixosConfig)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment