diff --git a/.env b/.env index 7e9a5858f3..79a216c72f 100644 --- a/.env +++ b/.env @@ -79,7 +79,7 @@ _APP_USAGE_STATS=enabled _APP_LOGGING_PROVIDER= _APP_LOGGING_CONFIG= _APP_EXECUTOR_SECRET=your-secret-key -_APP_EXECUTOR_HOST=http://exc1/v1 +_APP_EXECUTOR_HOST=http://proxy1/v1 _APP_FUNCTIONS_RUNTIMES= OPR_EXECUTOR_CONNECTION_STORAGE=file://localhost @@ -88,8 +88,8 @@ OPR_EXECUTOR_NETWORK=openruntimes-runtimes OPR_EXECUTOR_DOCKER_HUB_USERNAME= OPR_EXECUTOR_DOCKER_HUB_PASSWORD= -# OPR_PROXY_ALGORITHM=round-robin -# OPR_PROXY_EXECUTORS=exc1 -# OPR_PROXY_HEALTHCHECK=enabled -# OPR_PROXY_HEALTHCHECK_INTERVAL=5000 -# OPR_PROXY_EXECUTOR_SECRET=your-secret-key \ No newline at end of file +OPR_PROXY_ALGORITHM=round-robin +OPR_PROXY_EXECUTORS=exc1,exc2 +OPR_PROXY_HEALTHCHECK=enabled +OPR_PROXY_HEALTHCHECK_INTERVAL=5000 +OPR_PROXY_EXECUTOR_SECRET=your-secret-key \ No newline at end of file diff --git a/composer.lock b/composer.lock index de2a363a80..7f0bcd7fdb 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "51f81d435f4b5b7a9a6ea8f81b470353", + "content-hash": "1c15c309c6fcefe30360915fdac8adad", "packages": [ { "name": "adhocore/jwt", @@ -5175,7 +5175,14 @@ "time": "2022-09-28T08:42:51+00:00" } ], - "aliases": [], + "aliases": [ + { + "package": "utopia-php/pools", + "version": "dev-feat-optimize-filling", + "alias": "0.3.0", + "alias_normalized": "0.3.0.0" + } + ], "minimum-stability": "stable", "stability-flags": { "utopia-php/pools": 20 diff --git a/docker-compose.yml b/docker-compose.yml index 14c53b3123..0a41df7237 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -690,13 +690,11 @@ services: hostname: exc1 <<: *x-logging stop_signal: SIGINT - image: openruntimes/executor:0.1.0 + image: openruntimes/executor:0.1.1 networks: - - appwrite # Remove this when using OPR Proxy - # - openruntimes-executors + # - appwrite # If not using OPR proxy, uncomment this + - openruntimes-executors - openruntimes-runtimes - ports: - - 9900:80 volumes: - /var/run/docker.sock:/var/run/docker.sock - openruntimes-builds:/storage/builds:rw @@ -710,28 +708,54 @@ services: - OPR_EXECUTOR_DOCKER_HUB_PASSWORD - OPR_EXECUTOR_ENV=$_APP_ENV - OPR_EXECUTOR_RUNTIMES=$_APP_FUNCTIONS_RUNTIMES - - OPR_EXECUTOR_SECRET=$_APP_EXECUTOR_SECRET # If using OPR proxy, use OPR_PROXY_EXECUTOR_SECRET instead + - OPR_EXECUTOR_SECRET=$OPR_PROXY_EXECUTOR_SECRET # If not using OPR proxy, set to $_APP_EXECUTOR_SECRET - OPR_EXECUTOR_LOGGING_PROVIDER=$_APP_LOGGING_PROVIDER - OPR_EXECUTOR_LOGGING_CONFIG=$_APP_LOGGING_CONFIG - # openruntimes-proxy: - # container_name: openruntimes-proxy - # hostname: proxy1 - # <<: *x-logging - # image: openruntimes/proxy:0.3.0 - # networks: - # - appwrite - # - openruntimes-executors - # environment: - # - OPR_PROXY_ALGORITHM - # - OPR_PROXY_EXECUTORS - # - OPR_PROXY_HEALTHCHECK - # - OPR_PROXY_HEALTHCHECK_INTERVAL - # - OPR_PROXY_EXECUTOR_SECRET - # - OPR_PROXY_ENV=$_APP_ENV - # - OPR_PROXY_SECRET=$_APP_EXECUTOR_SECRET - # - OPR_PROXY_LOGGING_PROVIDER=$_APP_LOGGING_PROVIDER - # - OPR_PROXY_LOGGING_CONFIG=$_APP_LOGGING_CONFIG + openruntimes-proxy: + container_name: openruntimes-proxy + hostname: proxy1 + <<: *x-logging + image: openruntimes/proxy:0.2.2 + networks: + - appwrite + - openruntimes-executors + environment: + - OPR_PROXY_ALGORITHM + - OPR_PROXY_EXECUTORS + - OPR_PROXY_HEALTHCHECK + - OPR_PROXY_HEALTHCHECK_INTERVAL + - OPR_PROXY_EXECUTOR_SECRET + - OPR_PROXY_ENV=$_APP_ENV + - OPR_PROXY_SECRET=$_APP_EXECUTOR_SECRET + - OPR_PROXY_LOGGING_PROVIDER=$_APP_LOGGING_PROVIDER + - OPR_PROXY_LOGGING_CONFIG=$_APP_LOGGING_CONFIG + + openruntimes-executor2: + container_name: openruntimes-executor2 + hostname: exc2 + <<: *x-logging + stop_signal: SIGINT + image: openruntimes/executor:0.1.1 + networks: + - openruntimes-executors + - openruntimes-runtimes + volumes: + - /var/run/docker.sock:/var/run/docker.sock + - openruntimes-builds:/storage/builds:rw + - openruntimes-functions:/storage/functions:rw + - /tmp:/tmp:rw + environment: + - OPR_EXECUTOR_CONNECTION_STORAGE + - OPR_EXECUTOR_INACTIVE_TRESHOLD + - OPR_EXECUTOR_NETWORK + - OPR_EXECUTOR_DOCKER_HUB_USERNAME + - OPR_EXECUTOR_DOCKER_HUB_PASSWORD + - OPR_EXECUTOR_ENV=$_APP_ENV + - OPR_EXECUTOR_RUNTIMES=$_APP_FUNCTIONS_RUNTIMES + - OPR_EXECUTOR_SECRET=$OPR_PROXY_EXECUTOR_SECRET + - OPR_EXECUTOR_LOGGING_PROVIDER=$_APP_LOGGING_PROVIDER + - OPR_EXECUTOR_LOGGING_CONFIG=$_APP_LOGGING_CONFIG mariadb: image: mariadb:10.7 # fix issues when upgrading using: mysql_upgrade -u root -p diff --git a/src/Executor/Executor.php b/src/Executor/Executor.php index ff79350553..8f4113b07d 100644 --- a/src/Executor/Executor.php +++ b/src/Executor/Executor.php @@ -66,13 +66,15 @@ class Executor array $variables = [], array $commands = [] ) { + $runtimeId = "$projectId-$deploymentId"; $route = "/runtimes"; $headers = [ 'content-type' => 'application/json', - 'authorization' => 'Bearer ' . App::getEnv('_APP_EXECUTOR_SECRET', '') + 'authorization' => 'Bearer ' . App::getEnv('_APP_EXECUTOR_SECRET', ''), + 'x-opr-runtime-id' => $runtimeId ]; $params = [ - 'runtimeId' => "$projectId-$deploymentId", + 'runtimeId' => $runtimeId, 'source' => $source, 'destination' => $destination, 'image' => $image, @@ -125,7 +127,8 @@ class Executor $route = '/runtimes/' . $runtimeId . '/execution'; $headers = [ 'content-type' => 'application/json', - 'authorization' => 'Bearer ' . App::getEnv('_APP_EXECUTOR_SECRET', '') + 'authorization' => 'Bearer ' . App::getEnv('_APP_EXECUTOR_SECRET', ''), + 'x-opr-runtime-id' => $runtimeId ]; $params = [ 'runtimeId' => $runtimeId,