Fix git deploys with S3 storage
This commit is contained in:
parent
ec8c3b6bb8
commit
8b7147965e
3 changed files with 53 additions and 7 deletions
|
@ -383,6 +383,27 @@ services:
|
||||||
- _APP_FUNCTIONS_MEMORY
|
- _APP_FUNCTIONS_MEMORY
|
||||||
- _APP_OPTIONS_FORCE_HTTPS
|
- _APP_OPTIONS_FORCE_HTTPS
|
||||||
- _APP_DOMAIN
|
- _APP_DOMAIN
|
||||||
|
- _APP_STORAGE_DEVICE
|
||||||
|
- _APP_STORAGE_S3_ACCESS_KEY
|
||||||
|
- _APP_STORAGE_S3_SECRET
|
||||||
|
- _APP_STORAGE_S3_REGION
|
||||||
|
- _APP_STORAGE_S3_BUCKET
|
||||||
|
- _APP_STORAGE_DO_SPACES_ACCESS_KEY
|
||||||
|
- _APP_STORAGE_DO_SPACES_SECRET
|
||||||
|
- _APP_STORAGE_DO_SPACES_REGION
|
||||||
|
- _APP_STORAGE_DO_SPACES_BUCKET
|
||||||
|
- _APP_STORAGE_BACKBLAZE_ACCESS_KEY
|
||||||
|
- _APP_STORAGE_BACKBLAZE_SECRET
|
||||||
|
- _APP_STORAGE_BACKBLAZE_REGION
|
||||||
|
- _APP_STORAGE_BACKBLAZE_BUCKET
|
||||||
|
- _APP_STORAGE_LINODE_ACCESS_KEY
|
||||||
|
- _APP_STORAGE_LINODE_SECRET
|
||||||
|
- _APP_STORAGE_LINODE_REGION
|
||||||
|
- _APP_STORAGE_LINODE_BUCKET
|
||||||
|
- _APP_STORAGE_WASABI_ACCESS_KEY
|
||||||
|
- _APP_STORAGE_WASABI_SECRET
|
||||||
|
- _APP_STORAGE_WASABI_REGION
|
||||||
|
- _APP_STORAGE_WASABI_BUCKET
|
||||||
|
|
||||||
appwrite-worker-certificates:
|
appwrite-worker-certificates:
|
||||||
image: <?php echo $organization; ?>/<?php echo $image; ?>:<?php echo $version."\n"; ?>
|
image: <?php echo $organization; ?>/<?php echo $image; ?>:<?php echo $version."\n"; ?>
|
||||||
|
|
|
@ -20,6 +20,7 @@ use Utopia\Database\Database;
|
||||||
use Utopia\Database\Query;
|
use Utopia\Database\Query;
|
||||||
use Utopia\Storage\Storage;
|
use Utopia\Storage\Storage;
|
||||||
use Utopia\Database\Validator\Authorization;
|
use Utopia\Database\Validator\Authorization;
|
||||||
|
use Utopia\Storage\Device\Local;
|
||||||
use Utopia\VCS\Adapter\Git\GitHub;
|
use Utopia\VCS\Adapter\Git\GitHub;
|
||||||
|
|
||||||
require_once __DIR__ . '/../init.php';
|
require_once __DIR__ . '/../init.php';
|
||||||
|
@ -248,22 +249,25 @@ class BuildsV1 extends Worker
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
Console::execute('tar --exclude code.tar.gz -czf /tmp/builds/' . \escapeshellcmd($buildId) . '/code.tar.gz -C /tmp/builds/' . \escapeshellcmd($buildId) . '/code' . (empty($rootDirectory) ? '' : '/' . $rootDirectory) . ' .', '', $stdout, $stderr);
|
$tmpPath = '/tmp/builds/' . \escapeshellcmd($buildId);
|
||||||
|
$tmpPathFile = $tmpPath . '/code.tar.gz';
|
||||||
|
|
||||||
|
Console::execute('tar --exclude code.tar.gz -czf ' . $tmpPathFile . ' -C /tmp/builds/' . \escapeshellcmd($buildId) . '/code' . (empty($rootDirectory) ? '' : '/' . $rootDirectory) . ' .', '', $stdout, $stderr);
|
||||||
|
|
||||||
$deviceFunctions = $this->getFunctionsDevice($project->getId());
|
$deviceFunctions = $this->getFunctionsDevice($project->getId());
|
||||||
|
|
||||||
$fileName = 'code.tar.gz';
|
$localDevice = new Local();
|
||||||
$fileTmpName = '/tmp/builds/' . $buildId . '/code.tar.gz';
|
$buffer = $localDevice->read($tmpPathFile);
|
||||||
|
$mimeType = $localDevice->getFileMimeType($tmpPathFile);
|
||||||
|
|
||||||
$path = $deviceFunctions->getPath($deployment->getId() . '.' . \pathinfo($fileName, PATHINFO_EXTENSION));
|
$path = $deviceFunctions->getPath($deployment->getId() . '.' . \pathinfo('code.tar.gz', PATHINFO_EXTENSION));
|
||||||
|
$result = $deviceFunctions->write($path, $buffer, $mimeType);
|
||||||
$result = $deviceFunctions->move($fileTmpName, $path);
|
|
||||||
|
|
||||||
if (!$result) {
|
if (!$result) {
|
||||||
throw new \Exception("Unable to move file");
|
throw new \Exception("Unable to move file");
|
||||||
}
|
}
|
||||||
|
|
||||||
Console::execute('rm -rf /tmp/builds/' . \escapeshellcmd($buildId), '', $stdout, $stderr);
|
Console::execute('rm -rf ' . $tmpPath, '', $stdout, $stderr);
|
||||||
|
|
||||||
$source = $path;
|
$source = $path;
|
||||||
|
|
||||||
|
|
|
@ -418,6 +418,27 @@ services:
|
||||||
- _APP_FUNCTIONS_MEMORY
|
- _APP_FUNCTIONS_MEMORY
|
||||||
- _APP_OPTIONS_FORCE_HTTPS
|
- _APP_OPTIONS_FORCE_HTTPS
|
||||||
- _APP_DOMAIN
|
- _APP_DOMAIN
|
||||||
|
- _APP_STORAGE_DEVICE
|
||||||
|
- _APP_STORAGE_S3_ACCESS_KEY
|
||||||
|
- _APP_STORAGE_S3_SECRET
|
||||||
|
- _APP_STORAGE_S3_REGION
|
||||||
|
- _APP_STORAGE_S3_BUCKET
|
||||||
|
- _APP_STORAGE_DO_SPACES_ACCESS_KEY
|
||||||
|
- _APP_STORAGE_DO_SPACES_SECRET
|
||||||
|
- _APP_STORAGE_DO_SPACES_REGION
|
||||||
|
- _APP_STORAGE_DO_SPACES_BUCKET
|
||||||
|
- _APP_STORAGE_BACKBLAZE_ACCESS_KEY
|
||||||
|
- _APP_STORAGE_BACKBLAZE_SECRET
|
||||||
|
- _APP_STORAGE_BACKBLAZE_REGION
|
||||||
|
- _APP_STORAGE_BACKBLAZE_BUCKET
|
||||||
|
- _APP_STORAGE_LINODE_ACCESS_KEY
|
||||||
|
- _APP_STORAGE_LINODE_SECRET
|
||||||
|
- _APP_STORAGE_LINODE_REGION
|
||||||
|
- _APP_STORAGE_LINODE_BUCKET
|
||||||
|
- _APP_STORAGE_WASABI_ACCESS_KEY
|
||||||
|
- _APP_STORAGE_WASABI_SECRET
|
||||||
|
- _APP_STORAGE_WASABI_REGION
|
||||||
|
- _APP_STORAGE_WASABI_BUCKET
|
||||||
|
|
||||||
appwrite-worker-certificates:
|
appwrite-worker-certificates:
|
||||||
entrypoint: worker-certificates
|
entrypoint: worker-certificates
|
||||||
|
|
Loading…
Reference in a new issue