-
Notifications
You must be signed in to change notification settings - Fork 0
/
docker.nix
57 lines (49 loc) · 1.24 KB
/
docker.nix
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
let
pkgs = import ./nix;
trytond = import ./release.nix;
pgstring = (pkgs.lib.importJSON ./secrets.json).pgstring;
start = pkgs.writeShellScript "start.sh" ''
set -euo pipefail
echo "Creating the database if necessary..."
psql $TRYTOND_DATABASE__URI/postgres -tc "SELECT 1 FROM pg_database WHERE datname = 'health'" |
grep -q 1 ||
psql $TRYTOND_DATABASE__URI/postgres -c "CREATE DATABASE health"
echo "Setting up admin..."
trytond-admin --all --database=health --email=juanrapha@gmail.com --password
echo "Starting..."
trytond
'';
in
pkgs.dockerTools.buildImage {
name = "gnuhealth-nix";
tag = "latest";
contents = [
pkgs.coreutils
pkgs.bashInteractive
pkgs.postgresql
pkgs.gnugrep
trytond
];
runAsRoot = ''
# Password file
mkdir -p /data
echo "admin" > /data/passfile
# Bash
chmod 777 /bin/bash
rm /bin/sh
ln -s /bin/bash /bin/sh
'';
config = {
Env = [
"FONTCONFIG_FILE=${pkgs.fontconfig.out}/etc/fonts/fonts.conf"
"PATH=/bin:$PATH"
"TRYTOND_DATABASE__URI=${pgstring}"
"TRYTONPASSFILE=/data/passfile"
"TRYTOND_WEB__LISTEN=0.0.0.0:8000"
];
Cmd = [ start ];
ExposedPorts = {
"8000" = {};
};
};
}