-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3 from ProcessMaker/feature/2
Make node its own package and make the docker image a base image
- Loading branch information
Showing
7 changed files
with
114 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,3 +5,4 @@ src/data.json | |
src/config.json | ||
src/output.json | ||
test.sh | ||
sdk |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,4 @@ | ||
FROM node:8.15.0 | ||
COPY /src /opt/executor | ||
WORKDIR /opt/executor | ||
RUN if [ ! -d "sdk-node" ]; then git clone --depth 1 https://github.com/ProcessMaker/sdk-node.git; fi | ||
RUN cd /opt/executor/sdk-node; npm install | ||
RUN cd /opt/executor/sdk-node; npm run-script build | ||
RUN npm install |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
{ | ||
"name": "processmaker/docker-executor-node", | ||
"friendly_name": "Javascript Docker Executor", | ||
"description": "Javascript script executor for processmaker 4", | ||
"version": "1.0.0", | ||
"minimum-stability": "dev", | ||
"autoload": { | ||
"psr-4": { | ||
"ProcessMaker\\Package\\DockerExecutorNode\\": "src", | ||
"ProcessMaker\\ScriptRunners\\": "src/ScriptRunners" | ||
} | ||
}, | ||
"extra": { | ||
"laravel": { | ||
"providers": [ | ||
"ProcessMaker\\Package\\DockerExecutorNode\\DockerExecutorNodeServiceProvider" | ||
] | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
<?php | ||
namespace ProcessMaker\Package\DockerExecutorNode; | ||
|
||
use Illuminate\Support\Facades\Route; | ||
use Illuminate\Support\ServiceProvider; | ||
use ProcessMaker\Traits\PluginServiceProviderTrait; | ||
use ProcessMaker\Models\ScriptExecutor; | ||
|
||
class DockerExecutorNodeServiceProvider extends ServiceProvider | ||
{ | ||
use PluginServiceProviderTrait; | ||
|
||
const version = '1.0.0'; // Required for PluginServiceProviderTrait | ||
|
||
public function register() | ||
{ | ||
} | ||
|
||
public function boot() | ||
{ | ||
\Artisan::command('docker-executor-node:install', function () { | ||
$scriptExecutor = ScriptExecutor::install([ | ||
'language' => 'javascript', | ||
'title' => 'Node Executor', | ||
'description' => 'Default Javascript/Node Executor' | ||
]); | ||
|
||
// Build the instance image. This is the same as if you were to build it from the admin UI | ||
\Artisan::call('processmaker:build-script-executor ' . $scriptExecutor->id); | ||
|
||
// Restart the workers so they know about the new supported language | ||
\Artisan::call('horizon:terminate'); | ||
}); | ||
|
||
$config = [ | ||
'name' => 'JavaScript', | ||
'runner' => 'NodeRunner', | ||
'mime_type' => 'text/javascript', | ||
'options' => ['gitRepoId' => 'sdk-node'], | ||
'init_dockerfile' => [ | ||
'ARG SDK_DIR', | ||
'COPY $SDK_DIR /opt/sdk-node', | ||
'WORKDIR /opt/sdk-node', | ||
'RUN npm install', | ||
'RUN npm run build', | ||
'WORKDIR /opt/executor', | ||
'RUN npm install /opt/sdk-node', | ||
], | ||
'package_path' => __DIR__ . '/..', | ||
'package_version' => self::version, | ||
]; | ||
config(['script-runners.javascript' => $config]); | ||
|
||
$this->completePluginBoot(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
<?php | ||
|
||
namespace ProcessMaker\ScriptRunners; | ||
|
||
class NodeRunner extends Base | ||
{ | ||
/** | ||
* Configure docker with node executor | ||
* | ||
* @param string $code | ||
* @param array $dockerConfig | ||
* | ||
* @return array | ||
*/ | ||
public function config($code, array $dockerConfig) | ||
{ | ||
$dockerConfig['image'] = config('script-runners.javascript.image'); | ||
$dockerConfig['command'] = '/bin/sh /opt/executor/run.sh'; | ||
$dockerConfig['inputs']['/opt/executor/script.js'] = $code; | ||
return $dockerConfig; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters