Docker bugfix

This commit is contained in:
Roman 2022-02-21 00:32:40 +01:00
parent 5ffeddb57a
commit 8a7e25837f
4 changed files with 41 additions and 31 deletions

@ -104,8 +104,8 @@ namespace Documents\Install {
return NULL; return NULL;
} }
private function composerUpdate(bool $dryRun = false): array { private function composerInstall(bool $dryRun = false): array {
$command = "composer update"; $command = "composer install";
if ($dryRun) { if ($dryRun) {
$command .= " --dry-run"; $command .= " --dry-run";
} }
@ -127,8 +127,12 @@ namespace Documents\Install {
return [$status, $output]; return [$status, $output];
} }
private function getExternalDirectory(): string { private function getExternalDirectory(bool $absolute = true): string {
return implode(DIRECTORY_SEPARATOR, [WEBROOT, "core", "External"]);; if ($absolute) {
return implode(DIRECTORY_SEPARATOR, [WEBROOT, "core", "External"]);;
} else {
return implode(DIRECTORY_SEPARATOR, ["core", "External"]);
}
} }
private function getCurrentStep(): int { private function getCurrentStep(): int {
@ -138,17 +142,16 @@ namespace Documents\Install {
} }
$externalDir = $this->getExternalDirectory(); $externalDir = $this->getExternalDirectory();
$vendorDir = $externalDir . DIRECTORY_SEPARATOR . "vendor"; $autoload = implode(DIRECTORY_SEPARATOR, [$externalDir, "vendor", "autoload.php"]);
if (!is_dir($vendorDir)) { if (!is_file($autoload)) {
return self::INSTALL_DEPENDENCIES; return self::INSTALL_DEPENDENCIES;
} else { } else {
list ($status, $output) = $this->composerUpdate(true); list ($status, $output) = $this->composerInstall(true);
if ($status !== 0) { if ($status !== 0) {
$this->errorString = "Error executing 'composer update --dry-run'. Please verify that the command succeeds locally and then try again. Status Code: $status, Output: $output"; $this->errorString = "Error executing 'composer install --dry-run'. Please verify that the command succeeds locally and then try again. Status Code: $status, Output: $output";
return self::CHECKING_REQUIREMENTS; return self::CHECKING_REQUIREMENTS;
} else { } else {
if (!contains($output, "Nothing to modify in lock file") if (!contains($output, "Nothing to install, update or remove")) {
|| !contains($output, "Nothing to install, update or remove")) {
return self::INSTALL_DEPENDENCIES; return self::INSTALL_DEPENDENCIES;
} }
} }
@ -219,17 +222,19 @@ namespace Documents\Install {
$success = true; $success = true;
$failedRequirements = array(); $failedRequirements = array();
$configDir = "core/Configuration/"; if (!is_writeable(WEBROOT)) {
if (!is_writeable($configDir)) { $failedRequirements[] = sprintf("<b>%s</b> is not writeable. Try running <b>chmod 700 %s</b>", WEBROOT, WEBROOT);
$failedRequirements[] = "<b>$configDir</b> is not writeable. Try running <b>chmod 700 $configDir</b>";
$success = false; $success = false;
} }
if (function_exists("posix_getuid")) { if (function_exists("posix_getuid")) {
$userId = posix_getuid(); $userId = posix_getuid();
if (fileowner($configDir) !== $userId) { if (fileowner(WEBROOT) !== $userId) {
$username = posix_getpwuid($userId)['name']; $username = posix_getpwuid($userId)['name'];
$failedRequirements[] = "<b>$configDir</b> is not owned by current user: $username ($userId). Try running <b>chown -R $username $configDir</b>"; $failedRequirements[] = sprintf("<b>%s</b> is not owned by current user: $username ($userId). " .
"Try running <b>chown -R $userId %s</b> or give the required directories write permissions: " .
"<b>core/Configuration</b>, <b>core/TemplateCache</b>, <b>core/External</b>",
WEBROOT, WEBROOT);
$success = false; $success = false;
} }
} }
@ -259,7 +264,7 @@ namespace Documents\Install {
} }
private function installDependencies(): array { private function installDependencies(): array {
list ($status, $output) = $this->composerUpdate(); list ($status, $output) = $this->composerInstall();
return ["success" => $status === 0, "msg" => $output]; return ["success" => $status === 0, "msg" => $output];
} }

18
core/External/composer.lock generated vendored

@ -527,30 +527,30 @@
}, },
{ {
"name": "psr/log", "name": "psr/log",
"version": "3.0.0", "version": "1.1.4",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/php-fig/log.git", "url": "https://github.com/php-fig/log.git",
"reference": "fe5ea303b0887d5caefd3d431c3e61ad47037001" "reference": "d49695b909c3b7628b6289db5479a1c204601f11"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/php-fig/log/zipball/fe5ea303b0887d5caefd3d431c3e61ad47037001", "url": "https://api.github.com/repos/php-fig/log/zipball/d49695b909c3b7628b6289db5479a1c204601f11",
"reference": "fe5ea303b0887d5caefd3d431c3e61ad47037001", "reference": "d49695b909c3b7628b6289db5479a1c204601f11",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
"php": ">=8.0.0" "php": ">=5.3.0"
}, },
"type": "library", "type": "library",
"extra": { "extra": {
"branch-alias": { "branch-alias": {
"dev-master": "3.x-dev" "dev-master": "1.1.x-dev"
} }
}, },
"autoload": { "autoload": {
"psr-4": { "psr-4": {
"Psr\\Log\\": "src" "Psr\\Log\\": "Psr/Log/"
} }
}, },
"notification-url": "https://packagist.org/downloads/", "notification-url": "https://packagist.org/downloads/",
@ -571,9 +571,9 @@
"psr-3" "psr-3"
], ],
"support": { "support": {
"source": "https://github.com/php-fig/log/tree/3.0.0" "source": "https://github.com/php-fig/log/tree/1.1.4"
}, },
"time": "2021-07-14T16:46:02+00:00" "time": "2021-05-03T11:20:27+00:00"
}, },
{ {
"name": "spomky-labs/cbor-php", "name": "spomky-labs/cbor-php",

@ -1,11 +1,11 @@
<?php <?php
$vendorDir = implode(DIRECTORY_SEPARATOR, [__DIR__, "External", "vendor"]); $autoLoad = implode(DIRECTORY_SEPARATOR, [__DIR__, "External", "vendor", "autoload.php"]);
if (is_dir($vendorDir)) { if (is_file($autoLoad)) {
require_once $vendorDir . DIRECTORY_SEPARATOR . "autoload.php"; require_once $autoLoad;
} }
define("WEBBASE_VERSION", "1.4.2"); define("WEBBASE_VERSION", "1.4.3");
spl_autoload_extensions(".php"); spl_autoload_extensions(".php");
spl_autoload_register(function($class) { spl_autoload_register(function($class) {

@ -1,6 +1,11 @@
FROM php:7-fpm FROM composer:latest AS composer
FROM php:7.4-fpm
WORKDIR "/application" WORKDIR "/application"
RUN mkdir -p /application/core/Configuration RUN mkdir -p /application/core/Configuration
RUN chown -R www-data:www-data /application RUN chown -R www-data:www-data /application
RUN docker-php-ext-install mysqli RUN apt-get update -y && apt-get install libyaml-dev libzip-dev -y && apt-get clean && \
pecl install yaml && echo "extension=yaml.so" > /usr/local/etc/php/conf.d/ext-yaml.ini && \
docker-php-ext-enable yaml
RUN docker-php-ext-install mysqli zip
COPY --from=composer /usr/bin/composer /usr/bin/composer
USER www-data USER www-data