Skip to content

Commit a1d9105

Browse files
committed
add demo file to base image
1 parent 660bd9e commit a1d9105

File tree

2 files changed

+85
-70
lines changed

2 files changed

+85
-70
lines changed

deploy/cluster.nix

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -210,9 +210,6 @@ in
210210
"/config".name = "config";
211211
};
212212
env = lib.attrsToList {
213-
LOMAS_ADMIN_PATH_PREFIX = "/data";
214-
LOMAS_ADMIN_USER_YAML = "/collections/user_collection.yaml";
215-
LOMAS_ADMIN_DATASET_YAML = "/collections/dataset_collection.yaml";
216213
LOMAS_ADMIN_SERVER_URL = "https://${config.hostname}/dashboard";
217214
LOMAS_ADMIN_SERVER_SERVICE = "https://${config.hostname}/dashboard";
218215
STREAMLIT_SECRETS_FILES = "/config/secrets.toml";
@@ -224,6 +221,19 @@ in
224221
};
225222
};
226223
};
224+
225+
jobs.lomas-demo-setup.spec = {
226+
template = {
227+
spec = {
228+
restartPolicy = "Never";
229+
containers.lomas = {
230+
image = "dsccadminch/lomas:sha-e771310";
231+
imagePullPolicy = "IfNotPresent";
232+
command = [ "lomas-demo-setup" ];
233+
};
234+
};
235+
};
236+
};
227237
};
228238

229239
};

devenv/docker-env.nix

Lines changed: 72 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,11 @@ let
1313
mkEnableOption
1414
;
1515

16-
# attribute Set to KEY=VALUE format
17-
toINI = lib.generators.toKeyValue { };
18-
1916
# Filter env variable by their prefix
2017
filterEnvPrefix = prefix: lib.filterAttrs (name: value: lib.strings.hasPrefix prefix name) config.env;
18+
19+
inherit (lib.strings) hasPrefix substring stringLength;
20+
stripPath = strPath: if (hasPrefix "/" strPath) then (substring 1 (stringLength strPath) strPath) else strPath;
2121
in
2222
{
2323
options.dockerEnv = {
@@ -123,73 +123,78 @@ in
123123

124124
};
125125

126-
outputs.lomas-oci = pkgs.dockerTools.streamLayeredImage {
127-
name = "lomas-oci";
128-
tag = "latest";
129-
130-
contents = builtins.attrValues {
131-
inherit (pkgs.dockerTools) binSh usrBinEnv caCertificates;
132-
inherit (pkgs)
133-
bashInteractive
134-
coreutils-full
135-
dnsutils
136-
wget
137-
curl
138-
which
139-
file
140-
bind
141-
git
142-
;
143-
inherit (config.outputs) lomas-env;
144-
lomas-dashboard = (
145-
pkgs.writeShellScriptBin "lomas-dashboard" ''
146-
cd ${config.outputs.lomas-env}/lib/python*/site-packages/
147-
streamlit run lomas-server/administration/dashboard/about.py
148-
''
149-
);
150-
};
151-
152-
extraCommands = ''
153-
mkdir -p tmp
154-
chmod 777 tmp
155-
'';
156-
157-
config = with config.lomas; {
158-
Cmd = [ "lomas-serve" ];
159-
Env = lib.mapAttrsToList (name: value: "${name}=${toString value}") (
160-
(filterEnvPrefix "LOMAS_SERVICE_")
161-
// (filterEnvPrefix "LOMAS_CLIENT_")
162-
// (filterEnvPrefix "LOMAS_ADMIN_")
163-
// (filterEnvPrefix "STREAMLIT_")
164-
// {
165-
LOMAS_SERVICE_server__host_ip = "0.0.0.0";
166-
LOMAS_SERVICE_amqp__url = "amqp://rabbitmq:${toString rabbitmq.port}";
167-
LOMAS_SERVICE_authenticator__oidc_discovery_url = "http://dex:${toString dex.port}${dex.path}/.well-known/openid-configuration";
168-
LOMAS_SERVICE_telemetry__collector_endpoint = "http://otel-collector:${toString telemetry.services.otlp.ports.grpc}";
169-
LOMAS_SERVICE_data_directory = "/data";
170-
171-
LOMAS_CLIENT_APP_URL = "http://lomas_server:${toString port}";
172-
LOMAS_CLIENT_OIDC_DISCOVERY_URL = "http://dex:${toString dex.port}${dex.path}/.well-known/openid-configuration";
173-
LOMAS_CLIENT_telemetry__collector_endpoint = "http://otel-collector:${toString telemetry.services.otlp.ports.grpc}";
174-
175-
LOMAS_ADMIN_DEX_CONFIG__URL = "http://dex:${toString dex.adminPort}";
176-
LOMAS_ADMIN_USER_YAML = "/data/collections/user_collection.yaml";
177-
LOMAS_ADMIN_DATASET_YAML = "/data/collections/dataset_collection.yaml";
178-
LOMAS_ADMIN_server_service = "http://lomas_server:${toString port}";
179-
LOMAS_ADMIN_server_url = "http://lomas_server:${toString port}";
180-
}
181-
);
182-
ExposedPorts = {
183-
"${toString port}" = { };
184-
"${toString client.jupyter.port}" = { };
185-
"${toString dashboard.port}" = { };
126+
outputs.lomas-oci =
127+
let
128+
LOMAS_ADMIN_USER_YAML = "/data/collections/user_collection.yaml";
129+
LOMAS_ADMIN_DATASET_YAML = "/data/collections/dataset_collection.yaml";
130+
in
131+
pkgs.dockerTools.streamLayeredImage {
132+
name = "lomas-oci";
133+
tag = "latest";
134+
135+
contents = builtins.attrValues {
136+
inherit (pkgs.dockerTools) binSh usrBinEnv caCertificates;
137+
inherit (pkgs)
138+
bashInteractive
139+
coreutils-full
140+
dnsutils
141+
wget
142+
curl
143+
which
144+
file
145+
bind
146+
git
147+
;
148+
inherit (config.outputs) lomas-env;
149+
lomas-dashboard = (
150+
pkgs.writeShellScriptBin "lomas-dashboard" ''
151+
cd ${config.outputs.lomas-env}/lib/python*/site-packages/
152+
streamlit run lomas-server/administration/dashboard/about.py
153+
''
154+
);
186155
};
187-
Volumes = {
188-
"/data/collections" = { };
189-
"/data/datasets" = { };
156+
157+
extraCommands = ''
158+
install -dm 777 tmp
159+
install -Dm 644 ${../server/data/collections/user_collection.yaml} ${stripPath LOMAS_ADMIN_USER_YAML}
160+
install -Dm 644 ${../server/data/collections/dataset_collection.yaml} ${stripPath LOMAS_ADMIN_DATASET_YAML}
161+
'';
162+
163+
config = with config.lomas; {
164+
Cmd = [ "lomas-serve" ];
165+
Env = lib.mapAttrsToList (name: value: "${name}=${toString value}") (
166+
(filterEnvPrefix "LOMAS_SERVICE_")
167+
// (filterEnvPrefix "LOMAS_CLIENT_")
168+
// (filterEnvPrefix "LOMAS_ADMIN_")
169+
// (filterEnvPrefix "STREAMLIT_")
170+
// {
171+
LOMAS_SERVICE_server__host_ip = "0.0.0.0";
172+
LOMAS_SERVICE_amqp__url = "amqp://rabbitmq:${toString rabbitmq.port}";
173+
LOMAS_SERVICE_authenticator__oidc_discovery_url = "http://dex:${toString dex.port}${dex.path}/.well-known/openid-configuration";
174+
LOMAS_SERVICE_telemetry__collector_endpoint = "http://otel-collector:${toString telemetry.services.otlp.ports.grpc}";
175+
LOMAS_SERVICE_data_directory = "/data";
176+
177+
LOMAS_CLIENT_APP_URL = "http://lomas_server:${toString port}";
178+
LOMAS_CLIENT_OIDC_DISCOVERY_URL = "http://dex:${toString dex.port}${dex.path}/.well-known/openid-configuration";
179+
LOMAS_CLIENT_telemetry__collector_endpoint = "http://otel-collector:${toString telemetry.services.otlp.ports.grpc}";
180+
181+
LOMAS_ADMIN_DEX_CONFIG__URL = "http://dex:${toString dex.adminPort}";
182+
inherit LOMAS_ADMIN_USER_YAML LOMAS_ADMIN_DATASET_YAML;
183+
LOMAS_ADMIN_server_service = "http://lomas_server:${toString port}";
184+
LOMAS_ADMIN_server_url = "http://lomas_server:${toString port}";
185+
}
186+
);
187+
ExposedPorts = {
188+
"${toString port}" = { };
189+
"${toString client.jupyter.port}" = { };
190+
"${toString dashboard.port}" = { };
191+
};
192+
Volumes = {
193+
"/data/collections" = { };
194+
"/data/datasets" = { };
195+
};
190196
};
191197
};
192-
};
193198

194199
};
195200
}

0 commit comments

Comments
 (0)