Skip to content

Commit 7a67c6a

Browse files
authored
Merge pull request #6 from ProcessMaker/feature/5
Build this docker image as a base image
2 parents 399d6ad + 0b07155 commit 7a67c6a

File tree

6 files changed

+30
-31
lines changed

6 files changed

+30
-31
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
src/vendor
2+
sdk

Dockerfile

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
# Bring in from PHP docker image
21
FROM php:7.2.8-cli-stretch
32

43
# Copy over our PHP libraries/runtime
@@ -13,19 +12,4 @@ RUN php composer-setup.php --install-dir=/usr/local/bin --filename=composer
1312

1413
RUN apt-get update && apt-get install -y git zip unzip
1514

16-
RUN composer install
17-
18-
##
19-
## Below is temporary until this is converted to a base image
20-
##
21-
22-
# Get the sdk repo if it doesn't exist
23-
RUN apt-get update && apt-get install -y git
24-
RUN if [ ! -d "sdk-php" ]; then git clone --depth 1 https://github.com/ProcessMaker/sdk-php.git; fi
25-
RUN mv sdk-php /opt/
26-
RUN composer config repositories.sdk-php path /opt/sdk-php
27-
RUN composer require ProcessMaker/sdk-php:@dev
28-
29-
# Get the last AWS-SDK version
30-
RUN apt-get install zip unzip -y
31-
RUN composer require aws/aws-sdk-php
15+
RUN composer install

README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
# Build
2+
```
3+
docker build -t processmaker4/executor-php:latest .
4+
```
5+
16
# executor-php
27
Script Task Executor Engine with PHP Runtime
38

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "processmaker/docker-executor-php",
33
"friendly_name": "PHP Docker Executor",
44
"description": "PHP script executor for processmaker 4",
5-
"version": "0.0.1",
5+
"version": "1.0.0",
66
"minimum-stability": "dev",
77
"autoload": {
88
"psr-4": {

src/DockerExecutorPhpServiceProvider.php

Lines changed: 21 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,39 +4,48 @@
44
use Illuminate\Support\Facades\Route;
55
use Illuminate\Support\ServiceProvider;
66
use ProcessMaker\Traits\PluginServiceProviderTrait;
7+
use ProcessMaker\Models\ScriptExecutor;
78

89
class DockerExecutorPhpServiceProvider extends ServiceProvider
910
{
1011
use PluginServiceProviderTrait;
1112

12-
const version = '0.0.1'; // Required for PluginServiceProviderTrait
13+
const version = '1.0.0'; // Required for PluginServiceProviderTrait
1314

1415
public function register()
1516
{
1617
}
1718

1819
public function boot()
1920
{
20-
$image = env('SCRIPTS_PHP_IMAGE', 'processmaker4/executor-php');
21-
$dockerDir = sys_get_temp_dir() . "/pm4-docker-builds/php";
22-
$sdkDir = $dockerDir . "/sdk";
23-
2421
\Artisan::command('docker-executor-php:install', function () {
22+
$scriptExecutor = ScriptExecutor::install([
23+
'language' => 'php',
24+
'title' => 'PHP Executor',
25+
'description' => 'Default PHP Executor',
26+
'config' => 'RUN composer require aws/aws-sdk-php'
27+
]);
28+
29+
// Build the instance image. This is the same as if you were to build it from the admin UI
30+
\Artisan::call('processmaker:build-script-executor ' . $scriptExecutor->id);
31+
2532
// Restart the workers so they know about the new supported language
26-
\Artisan::call('horizon:terminate');
33+
// \Artisan::call('horizon:terminate');
2734
});
2835

29-
\Artisan::command('docker-executor-php:build-base', function () {
30-
system("docker build -t processmaker4/base-php:latest " . __DIR__ . '/..');
31-
});
32-
3336
$config = [
3437
'name' => 'PHP',
3538
'runner' => 'PhpRunner',
3639
'mime_type' => 'application/x-php',
37-
'image' => $image,
3840
'options' => ['invokerPackage' => "ProcessMaker\\Client"],
39-
'init_dockerfile' => "FROM processmaker4/base-php:latest\nCOPY ./sdk /opt/pm4-sdk\nRUN composer config repositories.pm4-sdk path /opt/pm4-sdk\nRUN composer require ProcessMaker/sdk-php:@dev",
41+
'init_dockerfile' => [
42+
'ARG SDK_DIR',
43+
'COPY $SDK_DIR /opt/sdk-php',
44+
'RUN composer config repositories.sdk-php path /opt/sdk-php',
45+
'RUN composer require processmaker/sdk-php:@dev',
46+
],
47+
'package_path' => __DIR__ . '/..',
48+
'package_version' => self::version,
4049
];
4150
config(['script-runners.php' => $config]);
4251

src/bootstrap.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
exit(SCRIPT_PATH_INVALID);
3636
}
3737

38-
if (getenv('API_TOKEN') && getenv('API_HOST')) {
38+
if (getenv('API_TOKEN') && getenv('API_HOST') && class_exists('ProcessMaker\Client\Configuration')) {
3939
$api_config = new ProcessMaker\Client\Configuration();
4040
$api_config->setAccessToken(getenv('API_TOKEN'));
4141
$api_config->setHost(getenv('API_HOST'));

0 commit comments

Comments
 (0)