diff --git a/.gitignore b/.gitignore index 16ce41ad7..d0b2a7473 100644 --- a/.gitignore +++ b/.gitignore @@ -1,10 +1,6 @@ /.vscode/ /vendor/ /node_modules/ -/storage/uploads/ -/storage/cache -/storage/db -/storage/influxdb /tests/resources/storage/ /.idea/ .DS_Store diff --git a/Dockerfile b/Dockerfile index 7ab9ac291..6810b4c4a 100755 --- a/Dockerfile +++ b/Dockerfile @@ -129,11 +129,13 @@ RUN mkdir -p /storage/uploads && \ mkdir -p /storage/cache && \ mkdir -p /storage/config && \ mkdir -p /storage/certificates && \ + mkdir -p /storage/functions && \ mkdir -p /storage/debug && \ chown -Rf www-data.www-data /storage/uploads && chmod -Rf 0755 /storage/uploads && \ chown -Rf www-data.www-data /storage/cache && chmod -Rf 0755 /storage/cache && \ chown -Rf www-data.www-data /storage/config && chmod -Rf 0755 /storage/config && \ chown -Rf www-data.www-data /storage/certificates && chmod -Rf 0755 /storage/certificates && \ + chown -Rf www-data.www-data /storage/functions && chmod -Rf 0755 /storage/functions && \ chown -Rf www-data.www-data /storage/debug && chmod -Rf 0755 /storage/debug # Executables diff --git a/Dockerfile.alpine b/Dockerfile.alpine index 37c5ef33e..d6714c8ec 100755 --- a/Dockerfile.alpine +++ b/Dockerfile.alpine @@ -129,11 +129,13 @@ RUN mkdir -p /storage/uploads && \ mkdir -p /storage/cache && \ mkdir -p /storage/config && \ mkdir -p /storage/certificates && \ + mkdir -p /storage/functions && \ mkdir -p /storage/debug && \ chown -Rf www-data.www-data /storage/uploads && chmod -Rf 0755 /storage/uploads && \ chown -Rf www-data.www-data /storage/cache && chmod -Rf 0755 /storage/cache && \ chown -Rf www-data.www-data /storage/config && chmod -Rf 0755 /storage/config && \ chown -Rf www-data.www-data /storage/certificates && chmod -Rf 0755 /storage/certificates && \ + chown -Rf www-data.www-data /storage/functions && chmod -Rf 0755 /storage/functions && \ chown -Rf www-data.www-data /storage/debug && chmod -Rf 0755 /storage/debug # Executables diff --git a/Dockerfile.nginx b/Dockerfile.nginx index 3c25823cd..31d96d8b0 100644 --- a/Dockerfile.nginx +++ b/Dockerfile.nginx @@ -159,10 +159,12 @@ RUN mkdir -p /storage/uploads && \ mkdir -p /storage/cache && \ mkdir -p /storage/config && \ mkdir -p /storage/certificates && \ + mkdir -p /storage/functions && \ chown -Rf www-data.www-data /storage/uploads && chmod -Rf 0755 /storage/uploads && \ chown -Rf www-data.www-data /storage/cache && chmod -Rf 0755 /storage/cache && \ chown -Rf www-data.www-data /storage/config && chmod -Rf 0755 /storage/config && \ - chown -Rf www-data.www-data /storage/certificates && chmod -Rf 0755 /storage/certificates + chown -Rf www-data.www-data /storage/certificates && chmod -Rf 0755 /storage/certificates && \ + chown -Rf www-data.www-data /storage/functions && chmod -Rf 0755 /storage/functions # Supervisord Conf COPY ./docker/supervisord.conf /etc/supervisord.conf diff --git a/Dockerfile.php8 b/Dockerfile.php8 index 8fbef0d98..aee2a09ae 100755 --- a/Dockerfile.php8 +++ b/Dockerfile.php8 @@ -129,11 +129,13 @@ RUN mkdir -p /storage/uploads && \ mkdir -p /storage/cache && \ mkdir -p /storage/config && \ mkdir -p /storage/certificates && \ + mkdir -p /storage/functions && \ mkdir -p /storage/debug && \ chown -Rf www-data.www-data /storage/uploads && chmod -Rf 0755 /storage/uploads && \ chown -Rf www-data.www-data /storage/cache && chmod -Rf 0755 /storage/cache && \ chown -Rf www-data.www-data /storage/config && chmod -Rf 0755 /storage/config && \ chown -Rf www-data.www-data /storage/certificates && chmod -Rf 0755 /storage/certificates && \ + chown -Rf www-data.www-data /storage/functions && chmod -Rf 0755 /storage/functions && \ chown -Rf www-data.www-data /storage/debug && chmod -Rf 0755 /storage/debug # Executables diff --git a/Dockerfile.swoole b/Dockerfile.swoole index ee3804e13..6810b4c4a 100755 --- a/Dockerfile.swoole +++ b/Dockerfile.swoole @@ -102,7 +102,7 @@ RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone RUN \ apt-get update && \ - apt-get install -y --no-install-recommends --no-install-suggests webp certbot htop procps \ + apt-get install -y --no-install-recommends --no-install-suggests webp certbot htop procps docker.io \ libonig-dev libcurl4-gnutls-dev libmagickwand-dev libyaml-dev libbrotli-dev libz-dev && \ pecl install imagick yaml && \ docker-php-ext-enable imagick yaml @@ -129,11 +129,13 @@ RUN mkdir -p /storage/uploads && \ mkdir -p /storage/cache && \ mkdir -p /storage/config && \ mkdir -p /storage/certificates && \ + mkdir -p /storage/functions && \ mkdir -p /storage/debug && \ chown -Rf www-data.www-data /storage/uploads && chmod -Rf 0755 /storage/uploads && \ chown -Rf www-data.www-data /storage/cache && chmod -Rf 0755 /storage/cache && \ chown -Rf www-data.www-data /storage/config && chmod -Rf 0755 /storage/config && \ chown -Rf www-data.www-data /storage/certificates && chmod -Rf 0755 /storage/certificates && \ + chown -Rf www-data.www-data /storage/functions && chmod -Rf 0755 /storage/functions && \ chown -Rf www-data.www-data /storage/debug && chmod -Rf 0755 /storage/debug # Executables @@ -172,4 +174,4 @@ EXPOSE 80 #, "-dxdebug.profiler_enable=1" #, "-dopcache.preload=opcache.preload=/usr/src/code/app/preload.php" -CMD [ "php", "app/server.php", "-dopcache.preload=opcache.preload=/usr/src/code/app/preload.php" ] \ No newline at end of file +CMD [ "php", "app/server.php", "-dopcache.preload=opcache.preload=/usr/src/code/app/preload.php" ] diff --git a/app/app.php b/app/app.php index 904545f17..8d0e376a1 100644 --- a/app/app.php +++ b/app/app.php @@ -89,7 +89,8 @@ App::init(function ($utopia, $request, $response, $console, $project, $user, $lo : '.'.$request->getHostname() ); - Storage::setDevice('local', new Local(APP_STORAGE_UPLOADS.'/app-'.$project->getId())); + Storage::setDevice('files', new Local(APP_STORAGE_UPLOADS.'/app-'.$project->getId())); + Storage::setDevice('functions', new Local(APP_STORAGE_FUNCTIONS.'/app-'.$project->getId())); /* * Security Headers diff --git a/app/controllers/api/functions.php b/app/controllers/api/functions.php index eda9e0d6b..35027874b 100644 --- a/app/controllers/api/functions.php +++ b/app/controllers/api/functions.php @@ -230,7 +230,7 @@ App::post('/v1/functions/:functionId/tags') } $file = $request->getFiles('code'); - $device = Storage::getDevice('local'); + $device = Storage::getDevice('functions'); $fileType = new FileType([FileType::FILE_TYPE_GZIP]); $fileSize = new FileSize(App::getEnv('_APP_STORAGE_LIMIT', 0)); $upload = new Upload(); diff --git a/app/controllers/api/health.php b/app/controllers/api/health.php index a3477e398..b8955a198 100644 --- a/app/controllers/api/health.php +++ b/app/controllers/api/health.php @@ -261,7 +261,7 @@ App::get('/v1/health/stats') // Currently only used internally /** @var Utopia\Response $response */ /** @var Utopia\Registry\Registry $register */ - $device = Storage::getDevice('local'); + $device = Storage::getDevice('files'); $cache = $register->get('cache'); $cacheStats = $cache->info(); diff --git a/app/controllers/api/storage.php b/app/controllers/api/storage.php index b462ef140..b441fb3eb 100644 --- a/app/controllers/api/storage.php +++ b/app/controllers/api/storage.php @@ -75,7 +75,7 @@ App::post('/v1/storage/files') throw new Exception('File size not allowed', 400); } - $device = Storage::getDevice('local'); + $device = Storage::getDevice('files'); if (!$upload->isValid($file['tmp_name'])) { throw new Exception('Invalid file', 403); @@ -239,7 +239,7 @@ App::get('/v1/storage/files/:fileId/preview') /** @var Appwrite\Database\Document $project */ /** @var Appwrite\Database\Database $projectDB */ - $storage = 'local'; + $storage = 'files'; if (!\extension_loaded('imagick')) { throw new Exception('Imagick extension is missing', 500); @@ -282,7 +282,7 @@ App::get('/v1/storage/files/:fileId/preview') } $compressor = new GZIP(); - $device = Storage::getDevice('local'); + $device = Storage::getDevice('files'); if (!\file_exists($path)) { throw new Exception('File not found', 404); @@ -371,7 +371,7 @@ App::get('/v1/storage/files/:fileId/download') } $compressor = new GZIP(); - $device = Storage::getDevice('local'); + $device = Storage::getDevice('files'); $source = $device->read($path); @@ -428,7 +428,7 @@ App::get('/v1/storage/files/:fileId/view') } $compressor = new GZIP(); - $device = Storage::getDevice('local'); + $device = Storage::getDevice('files'); $contentType = 'text/plain'; @@ -542,7 +542,7 @@ App::delete('/v1/storage/files/:fileId') throw new Exception('File not found', 404); } - $device = Storage::getDevice('local'); + $device = Storage::getDevice('files'); if ($device->delete($file->getAttribute('path', ''))) { if (!$projectDB->deleteDocument($fileId)) { @@ -575,7 +575,7 @@ App::delete('/v1/storage/files/:fileId') // ->label('sdk.method', 'getFileScan') // ->label('sdk.hide', true) // ->param('fileId', '', function () { return new UID(); }, 'File unique ID.') -// ->param('storage', 'local', function () { return new WhiteList(['local']);}) +// ->param('storage', 'files', function () { return new WhiteList(['files']);}) // ->action( // function ($fileId, $storage) use ($response, $request, $projectDB) { // $file = $projectDB->getDocument($fileId); diff --git a/app/init.php b/app/init.php index 408512fbb..850253b33 100644 --- a/app/init.php +++ b/app/init.php @@ -39,6 +39,7 @@ const APP_PAGING_LIMIT = 15; const APP_CACHE_BUSTER = 125; const APP_VERSION_STABLE = '0.6.2'; const APP_STORAGE_UPLOADS = '/storage/uploads'; +const APP_STORAGE_FUNCTIONS = '/storage/functions'; const APP_STORAGE_CACHE = '/storage/cache'; const APP_STORAGE_CERTIFICATES = '/storage/certificates'; const APP_STORAGE_CONFIG = '/storage/config'; diff --git a/docker-compose.nginx.yml b/docker-compose.nginx.yml index c11a29b91..677db5e78 100644 --- a/docker-compose.nginx.yml +++ b/docker-compose.nginx.yml @@ -47,6 +47,7 @@ services: - appwrite-cache:/storage/cache:rw - appwrite-config:/storage/config:rw - appwrite-certificates:/storage/certificates:rw + - appwrite-functions:/storage/functions:rw - ./phpunit.xml:/usr/src/code/phpunit.xml - ./tests:/usr/src/code/tests - ./app:/usr/src/code/app @@ -208,6 +209,7 @@ volumes: appwrite-cache: appwrite-uploads: appwrite-certificates: + appwrite-functions: appwrite-influxdb: appwrite-chronograf: appwrite-config: diff --git a/docker-compose.swoole.yml b/docker-compose.swoole.yml index 4febc1237..718e04c7b 100644 --- a/docker-compose.swoole.yml +++ b/docker-compose.swoole.yml @@ -45,10 +45,12 @@ services: - traefik.http.routers.appwrite-secure.rule=PathPrefix(`/`) - traefik.http.routers.appwrite-secure.tls=true volumes: + - /var/run/docker.sock:/var/run/docker.sock - appwrite-uploads:/storage/uploads:rw - appwrite-cache:/storage/cache:rw - appwrite-config:/storage/config:rw - appwrite-certificates:/storage/certificates:rw + - appwrite-functions:/storage/functions:rw - ./phpunit.xml:/usr/src/code/phpunit.xml - ./tests:/usr/src/code/tests - ./app:/usr/src/code/app @@ -371,6 +373,7 @@ volumes: appwrite-cache: appwrite-uploads: appwrite-certificates: + appwrite-functions: appwrite-influxdb: appwrite-chronograf: appwrite-config: diff --git a/docker-compose.yml b/docker-compose.yml index 89d138e4f..718e04c7b 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -50,6 +50,7 @@ services: - appwrite-cache:/storage/cache:rw - appwrite-config:/storage/config:rw - appwrite-certificates:/storage/certificates:rw + - appwrite-functions:/storage/functions:rw - ./phpunit.xml:/usr/src/code/phpunit.xml - ./tests:/usr/src/code/tests - ./app:/usr/src/code/app @@ -372,6 +373,7 @@ volumes: appwrite-cache: appwrite-uploads: appwrite-certificates: + appwrite-functions: appwrite-influxdb: appwrite-chronograf: appwrite-config: