@@ -6,6 +6,10 @@ var log4js = require('log4js');
66var createJobMessage = require ( '../common/jobMessage.js' ) . createJobMessage ;
77var os = require ( 'os' ) ;
88
9+ // Used to run worker containers as local user (should be set in the Hyperflow container)
10+ const uid = process . env . USER_ID ;
11+ const gid = process . env . USER_GID ;
12+
913// limit of parallel jobs
1014const MAX_PARALLELISM = process . env . HF_VAR_REDIS_CMD_MAX_PARALLELISM || 10 ;
1115// how long to sleep in the case max parallelism is achieved
@@ -50,14 +54,20 @@ async function redisCommand(ins, outs, context, cb) {
5054 // if 'container' is present, run through Docker, mounting all directories if necessary
5155 if ( ! work_dir ) { work_dir = process . cwd ; }
5256 if ( context . container ) {
53- cmd = 'docker run --network container:redis --name ' + context . name + "_" + context . taskId . replace ( / : / g, '_' ) ;
57+ cmd = 'docker run --network hyperflow-net --name ' + context . name + "_" + context . taskId . replace ( / : / g, '_' ) ;
5458 if ( input_dir ) cmd += ' -v ' + input_dir + ':/input_dir ' ;
5559 if ( work_dir ) cmd += ' -v ' + work_dir + ':/work_dir ' ;
5660 if ( output_dir ) cmd += ' -v ' + output_dir + ':/output_dir ' ;
57- cmd += ' -e HF_LOG_NODE_NAME="' + os . hostname ( ) + '"' ;
61+ if ( uid && gid ) {
62+ cmd += ` --user ${ uid } :${ gid } ` ;
63+ } else {
64+ console . warn ( "⚠️ HOST_UID/HOST_GID not set — running job container as default user" ) ;
65+ }
66+ cmd += ' -e HF_LOG_NODE_NAME="' + os . hostname ( ) + '" ' ;
5867 cmd += context . container + ' hflow-job-execute' ;
5968 } else cmd = 'hflow-job-execute'
6069
70+
6171 try {
6272 // if hyperflow also runs in container, chdir doesn't make sense
6373 if ( work_dir && ! process . env . HF_VAR_HFLOW_IN_CONTAINER ) { process . chdir ( work_dir ) ; }
0 commit comments