-
-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathimage.nix
More file actions
41 lines (37 loc) · 790 Bytes
/
image.nix
File metadata and controls
41 lines (37 loc) · 790 Bytes
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
{ pkgs ? import <nixpkgs> { }
, app
, name ? "example"
, tag ? "latest"
}:
pkgs.dockerTools.buildImage {
inherit name tag;
copyToRoot = pkgs.buildEnv {
name = "image-root";
paths = [
app
pkgs.cacert
pkgs.tzdata
];
pathsToLink = [ "/bin" ];
};
runAsRoot = ''
#!${pkgs.runtimeShell}
${pkgs.dockerTools.shadowSetup}
mkdir /tmp
chmod 777 -R /tmp
groupadd -r nonroot
useradd -r -g nonroot nonroot
mkdir -p /workspace
chown nonroot:nonroot /workspace
'';
config = {
Env = [
"SSL_CERT_FILE=${pkgs.cacert}/etc/ssl/certs/ca-bundle.crt"
"PYTHONDONTWRITEBYTECODE=1"
"PYTHONUNBUFFERED=1"
];
User = "nonroot";
WorkingDir = "/workspace";
Entrypoint = [ "${app}/bin/example" ];
};
}