-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
default.nix
61 lines (55 loc) · 1.32 KB
/
default.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
58
59
60
61
{ pkgs ? import <nixpkgs> { }, ... }:
let
shell = import ./shell.nix {
isDevelopment = false;
};
python-venv = pkgs.buildEnv {
name = "python-venv";
paths = [
(pkgs.runCommand "python-venv" { } ''
mkdir -p $out/lib
cp -r "${./.venv/lib/python3.11/site-packages}"/* $out/lib
'')
];
};
etc-hosts = pkgs.buildEnv {
name = "etc-hosts";
paths = [
(pkgs.writeTextDir "etc/hosts" ''
127.0.0.1 localhost
::1 localhost
'')
];
pathsToLink = [ "/etc" ];
};
in
with pkgs; dockerTools.buildLayeredImage {
name = "docker.monicz.dev/osm-yolo-crossings";
tag = "latest";
maxLayers = 10;
contents = shell.buildInputs ++ [ python-venv etc-hosts ];
extraCommands = ''
set -e
mkdir app && cd app
cp "${./.}"/*.py .
cp -r "${./.}"/model .
export PATH="${lib.makeBinPath shell.buildInputs}:$PATH"
${shell.shellHook}
'';
config = {
WorkingDir = "/app";
Env = [
"SSL_CERT_FILE=${cacert}/etc/ssl/certs/ca-bundle.crt"
"LD_LIBRARY_PATH=${lib.makeLibraryPath shell.buildInputs}"
"PYTHONPATH=${python-venv}/lib"
"PYTHONUNBUFFERED=1"
"PYTHONDONTWRITEBYTECODE=1"
];
Volumes = {
"/app/data" = { };
"/.keras" = { };
};
Entrypoint = [ "python" "main.py" ];
Cmd = [ ];
};
}