|
13 | 13 | mkEnableOption |
14 | 14 | ; |
15 | 15 |
|
16 | | - # attribute Set to KEY=VALUE format |
17 | | - toINI = lib.generators.toKeyValue { }; |
18 | | - |
19 | 16 | # Filter env variable by their prefix |
20 | 17 | 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; |
21 | 21 | in |
22 | 22 | { |
23 | 23 | options.dockerEnv = { |
|
123 | 123 |
|
124 | 124 | }; |
125 | 125 |
|
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 | + ); |
186 | 155 | }; |
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 | + }; |
190 | 196 | }; |
191 | 197 | }; |
192 | | - }; |
193 | 198 |
|
194 | 199 | }; |
195 | 200 | } |
0 commit comments