From 98b04976c1244f37d4fa67e770f9f493cb6efec5 Mon Sep 17 00:00:00 2001 From: Eldad Fux Date: Sun, 10 May 2020 13:30:07 +0300 Subject: [PATCH] Updated server commands --- .travis.yml | 2 +- Dockerfile | 11 +++++------ app/workers/functions.php | 26 +++++++++++++++++++++----- docker-compose.yml | 2 +- 4 files changed, 28 insertions(+), 13 deletions(-) diff --git a/.travis.yml b/.travis.yml index 3bba002a6c..c97c909947 100644 --- a/.travis.yml +++ b/.travis.yml @@ -30,4 +30,4 @@ install: script: - docker ps -- docker exec appwrite bash bin/test +- docker exec appwrite bash test diff --git a/Dockerfile b/Dockerfile index 769c4a5248..72f9e7299c 100644 --- a/Dockerfile +++ b/Dockerfile @@ -119,7 +119,7 @@ COPY ./docker/www.conf /etc/php/$PHP_VERSION/fpm/pool.d/www.conf # Add PHP Source Code COPY ./app /usr/share/nginx/html/app -COPY ./bin /usr/share/nginx/html/bin +COPY ./bin /usr/local/bin COPY ./docs /usr/share/nginx/html/docs COPY ./public /usr/share/nginx/html/public COPY ./src /usr/share/nginx/html/src @@ -138,10 +138,9 @@ RUN mkdir -p /storage/uploads && \ COPY ./docker/supervisord.conf /etc/supervisord.conf # Executables -RUN chmod +x /usr/share/nginx/html/bin/start -RUN chmod +x /usr/share/nginx/html/bin/upgrade -RUN chmod +x /usr/share/nginx/html/bin/test -RUN export PATH=$PATH:/usr/share/nginx/html/bin +RUN chmod +x /usr/local/bin/start +RUN chmod +x /usr/local/bin/upgrade +RUN chmod +x /usr/local/bin/test # Letsencrypt Permissions RUN mkdir -p /etc/letsencrypt/live/ && chmod -Rf 755 /etc/letsencrypt/live/ @@ -150,4 +149,4 @@ EXPOSE 80 WORKDIR /usr/share/nginx/html -CMD ["/bin/bash", "bin/start"] +CMD ["/bin/bash", "/usr/local/bin/start"] diff --git a/app/workers/functions.php b/app/workers/functions.php index cbdefea10b..a19af347c9 100644 --- a/app/workers/functions.php +++ b/app/workers/functions.php @@ -16,6 +16,9 @@ $environments = Config::getParam('environments'); foreach($environments as $environment) { $stdout = ''; $stderr = ''; + + Console::info('Warming up '.$environment['name'].' environment'); + Console::execute('docker pull '.$environment['image'], null, $stdout, $stderr); if(!empty($stdout)) { @@ -31,20 +34,33 @@ class FunctionsV1 { public $args = []; - public $images = [ - - ]; - public function setUp() { } public function perform() { + global $environments; + + /** + * 1. Get event args + * 2. Unpackage code in an isolated folder + * 3. Execute in container with timeout + * 4. Update execution status + * 5. Update execution stdout & stderr + * 6. Trigger audit log + * 7. Trigger usage log + */ + + // docker run --rm -v $(pwd):/app -w /app php:7.4-cli php tests/languages/php/test.php } public function tearDown() { - // ... Remove environment for this job + $stdout = ''; + $stderr = ''; + $image = ''; + + Console::execute('docker pull '.$image, null, $stdout, $stderr); } } diff --git a/docker-compose.yml b/docker-compose.yml index 9e8235755b..dc98f73904 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -54,8 +54,8 @@ services: - ./docs:/usr/share/nginx/html/docs - ./public:/usr/share/nginx/html/public - ./src:/usr/share/nginx/html/src + - ./bin:/usr/local/bin - ./docker/nginx.conf:/etc/nginx/nginx.conf - - ./docker/bin:/home/bin depends_on: - mariadb - redis