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;
}
private function composerUpdate(bool $dryRun = false): array {
$command = "composer update";
private function composerInstall(bool $dryRun = false): array {
$command = "composer install";
if ($dryRun) {
$command .= " --dry-run";
}
@ -127,8 +127,12 @@ namespace Documents\Install {
return [$status, $output];
}
private function getExternalDirectory(): string {
return implode(DIRECTORY_SEPARATOR, [WEBROOT, "core", "External"]);;
private function getExternalDirectory(bool $absolute = true): string {
if ($absolute) {
return implode(DIRECTORY_SEPARATOR, [WEBROOT, "core", "External"]);;
} else {
return implode(DIRECTORY_SEPARATOR, ["core", "External"]);
}
}
private function getCurrentStep(): int {
@ -138,17 +142,16 @@ namespace Documents\Install {
}
$externalDir = $this->getExternalDirectory();
$vendorDir = $externalDir . DIRECTORY_SEPARATOR . "vendor";
if (!is_dir($vendorDir)) {
$autoload = implode(DIRECTORY_SEPARATOR, [$externalDir, "vendor", "autoload.php"]);
if (!is_file($autoload)) {
return self::INSTALL_DEPENDENCIES;
} else {
list ($status, $output) = $this->composerUpdate(true);
list ($status, $output) = $this->composerInstall(true);
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;
} else {
if (!contains($output, "Nothing to modify in lock file")
|| !contains($output, "Nothing to install, update or remove")) {
if (!contains($output, "Nothing to install, update or remove")) {
return self::INSTALL_DEPENDENCIES;
}
}
@ -219,17 +222,19 @@ namespace Documents\Install {
$success = true;
$failedRequirements = array();
$configDir = "core/Configuration/";
if (!is_writeable($configDir)) {
$failedRequirements[] = "<b>$configDir</b> is not writeable. Try running <b>chmod 700 $configDir</b>";
if (!is_writeable(WEBROOT)) {
$failedRequirements[] = sprintf("<b>%s</b> is not writeable. Try running <b>chmod 700 %s</b>", WEBROOT, WEBROOT);
$success = false;
}
if (function_exists("posix_getuid")) {
$userId = posix_getuid();
if (fileowner($configDir) !== $userId) {
if (fileowner(WEBROOT) !== $userId) {
$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;
}
}
@ -259,7 +264,7 @@ namespace Documents\Install {
}
private function installDependencies(): array {
list ($status, $output) = $this->composerUpdate();
list ($status, $output) = $this->composerInstall();
return ["success" => $status === 0, "msg" => $output];
}

18
core/External/composer.lock generated vendored

@ -527,30 +527,30 @@
},
{
"name": "psr/log",
"version": "3.0.0",
"version": "1.1.4",
"source": {
"type": "git",
"url": "https://github.com/php-fig/log.git",
"reference": "fe5ea303b0887d5caefd3d431c3e61ad47037001"
"reference": "d49695b909c3b7628b6289db5479a1c204601f11"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/php-fig/log/zipball/fe5ea303b0887d5caefd3d431c3e61ad47037001",
"reference": "fe5ea303b0887d5caefd3d431c3e61ad47037001",
"url": "https://api.github.com/repos/php-fig/log/zipball/d49695b909c3b7628b6289db5479a1c204601f11",
"reference": "d49695b909c3b7628b6289db5479a1c204601f11",
"shasum": ""
},
"require": {
"php": ">=8.0.0"
"php": ">=5.3.0"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "3.x-dev"
"dev-master": "1.1.x-dev"
}
},
"autoload": {
"psr-4": {
"Psr\\Log\\": "src"
"Psr\\Log\\": "Psr/Log/"
}
},
"notification-url": "https://packagist.org/downloads/",
@ -571,9 +571,9 @@
"psr-3"
],
"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",

@ -1,11 +1,11 @@
<?php
$vendorDir = implode(DIRECTORY_SEPARATOR, [__DIR__, "External", "vendor"]);
if (is_dir($vendorDir)) {
require_once $vendorDir . DIRECTORY_SEPARATOR . "autoload.php";
$autoLoad = implode(DIRECTORY_SEPARATOR, [__DIR__, "External", "vendor", "autoload.php"]);
if (is_file($autoLoad)) {
require_once $autoLoad;
}
define("WEBBASE_VERSION", "1.4.2");
define("WEBBASE_VERSION", "1.4.3");
spl_autoload_extensions(".php");
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"
RUN mkdir -p /application/core/Configuration
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