Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ Where the documentation lives:
| `CONTRIBUTING.md` | Build process: the generated files and `make generate`, the CI and `make check`, building and testing locally, the image tests, PHP extension builds |
| `docs/README.md` | Image overview, platforms and nightly updates, how the images build on each other (Mermaid diagram) |
| `docs/environment-variables.md` | Every environment variable with its default and effect; uploads and long requests |
| `docs/customization.md` | Commands, scripts at start and build time, tools for your Dockerfile, services, cron jobs and their time zone, healthcheck, configuration files and placeholders, supervisord, locales, application user and changing its UID |
| `docs/customization.md` | Commands, scripts at start and build time, tools for your Dockerfile, services and their logs, cron jobs, their output and their time zone, healthcheck, configuration files and placeholders, supervisord, locales, application user and changing its UID |
| `docs/images/*.md` | One page per image family: tags, base image, services, settings, development variant. `php.md` also has Debian or Alpine, production, installing extensions, mail and Xdebug with an IDE |
| `docs/known-issues.md` | Options and tools that do not work, with affected images and workaround; migration from older images |
| `docs/discontinued-images.md` | Replacements for images and tags that are no longer built (`bootstrap`, `base`, `base-app`, `dockerfile-build-env`, `nginx`, `apache`, `storage`, `vsftp`, `ssh`) or deprecated (`php-official`) |
Expand Down
43 changes: 42 additions & 1 deletion ci/image-tests/Checks/ContainerEnvironmentChecks.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@
*/
trait ContainerEnvironmentChecks
{
/** Starts syslog-ng in a container of an image that does not start it */
private const string START_SYSLOG = 'docker-service enable syslog && docker-service start syslog';

/**
* TZ=Europe/Berlin: date shows the time zone, and supervisord writes local time to the container log.
*/
Expand Down Expand Up @@ -89,7 +92,7 @@ public function testSyslogMessagesReachTheFileFromTheEnvironment(): void
{
$container = $this->environmentContainer();
if (!in_array('syslog', self::services(), true)) {
$this->assertCommandSucceeds('docker-service enable syslog && docker-service start syslog', $container);
$this->assertCommandSucceeds(self::START_SYSLOG, $container);
}

$this->eventually(function () use ($container): void {
Expand All @@ -98,6 +101,44 @@ public function testSyslogMessagesReachTheFileFromTheEnvironment(): void
});
}

/**
* What a service writes to its stdout and stderr reaches the files of LOG_STDOUT and LOG_STDERR: supervisord writes
* it there. The hook of syslog-ng from Hooks/ writes a line to each. The environment container starts syslog-ng
* where the image does not. At the log level trace of SERVICE_SUPERVISOR_OPTS, supervisord also repeats the output
* of the services in its own messages in the container log, so the container log is not checked here.
*/
public function testServiceOutputReachesTheFilesFromTheEnvironment(): void
{
$container = $this->environmentContainer();
if (!in_array('syslog', self::services(), true)) {
$this->assertCommandSucceeds(self::START_SYSLOG, $container);
}

$this->eventually(function () use ($container): void {
self::assertStringContainsString('image-test: the hook of syslog-ng on stdout', $this->stdout('cat ' . static::ENVIRONMENT['LOG_STDOUT'], $container));
self::assertStringContainsString('image-test: the hook of syslog-ng on stderr', $this->stdout('cat ' . static::ENVIRONMENT['LOG_STDERR'], $container));
});
}

/**
* Without LOG_STDOUT and LOG_STDERR, what a service writes to its stdout and stderr stays in the container log, as
* before supervisord wrote it to /docker.stdout and /docker.stderr: the hook of syslog-ng from Hooks/ writes a line
* to each. In a container of its own, which starts syslog-ng where the image does not.
*/
public function testServiceOutputReachesTheContainerLogWithoutTheEnvironment(): void
{
$container = $this->startTestContainer('service-output');
if (!in_array('syslog', self::services(), true)) {
$this->assertCommandSucceeds(self::START_SYSLOG, $container);
}

$this->eventually(function () use ($container): void {
[$stdout, $stderr] = $container->logStreams();
self::assertStringContainsString('image-test: the hook of syslog-ng on stdout', $stdout);
self::assertStringContainsString('image-test: the hook of syslog-ng on stderr', $stderr);
});
}

/**
* /docker.stdout and /docker.stderr, where the services of the image write their logs, point to the files of
* LOG_STDOUT and LOG_STDERR.
Expand Down
19 changes: 19 additions & 0 deletions ci/image-tests/Checks/NginxEnvironmentChecks.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,4 +52,23 @@ public function testNginxLogsToTheFilesFromTheEnvironment(): void
self::assertMatchesRegularExpression('#\[error\] .*image-test-forbidden\.html" failed \(13: Permission denied\)#', $this->stdout('cat ' . static::ENVIRONMENT['LOG_STDERR'], $container));
});
}

/**
* Nginx writes the messages that belong to no server, those of its main error log, to LOG_STDERR, not to LOG_STDOUT:
* the master process logs that a worker process ended on SIGKILL.
*/
public function testNginxMainErrorLogToTheFileFromTheEnvironment(): void
{
$container = $this->environmentContainer();
$this->request('http://localhost/', container: $container);
$this->assertCommandSucceeds(
'for process in /proc/[0-9]*; do if tr "\\000" " " < $process/cmdline 2>/dev/null | grep -q "^nginx: worker process"; then kill -9 ${process#/proc/}; break; fi; done',
$container,
);
$exited = '#\[alert\] .*worker process \d+ exited on signal 9#';
$this->eventually(function () use ($container, $exited): void {
self::assertMatchesRegularExpression($exited, $this->stdout('cat ' . static::ENVIRONMENT['LOG_STDERR'], $container));
});
self::assertDoesNotMatchRegularExpression($exited, $this->stdout('cat ' . static::ENVIRONMENT['LOG_STDOUT'], $container));
}
}
21 changes: 20 additions & 1 deletion ci/image-tests/Checks/SshChecks.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,14 @@

namespace Webdevops\Build\ImageTests\Checks;

use Webdevops\Build\ImageTests\Docker\ListeningSockets;
use Webdevops\Build\ImageTests\ImageTestCase;

use function implode;

/**
* The SSH server of the development images runs, listens on port 22 and lets root and the application user log in with
* the password dev.
* the password dev. Its log reaches the file of LOG_STDERR.
*
* @phpstan-require-extends ImageTestCase
*/
Expand All @@ -37,4 +38,22 @@ public function testSshLoginWithThePasswordDev(): void
]));
self::assertSame([0, "application\n"], [$result->exitCode, $result->stdout], $result->describe());
}

/**
* sshd logs to its stderr, which supervisord writes to the file of LOG_STDERR in the environment container, where
* sshd listens on port 2222 (SERVICE_SSH_OPTS). Through syslog, its messages were lost: syslog-ng drops the facility
* auth.
*/
public function testSshLogsToTheFileFromTheEnvironment(): void
{
$container = $this->environmentContainer();
$this->eventually(function () use ($container): void {
self::assertTrue(ListeningSockets::read($container)->isListening(2222), 'sshd should listen on port 2222');
});
$login = $this->execute('ssh -o BatchMode=yes -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -p 2222 image-test-nobody@127.0.0.1 true', $container);
self::assertNotSame(0, $login->exitCode, $login->describe());
$this->eventually(function () use ($container): void {
self::assertMatchesRegularExpression('/Invalid user image-test-nobody from 127\.0\.0\.1 /', $this->stdout('cat ' . static::ENVIRONMENT['LOG_STDERR'], $container));
});
}
}
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# Image tests: marks that a service sourced the hooks in its directory, and as which user, see ServiceChecks
mkdir -p /tmp/image-tests/hooks
id -un > "/tmp/image-tests/hooks/$(basename "$(dirname "${BASH_SOURCE[0]}")")"
# and writes a line to the stdout and one to the stderr of the service, see ContainerEnvironmentChecks
echo "image-test: the hook of syslog-ng on stdout"
echo "image-test: the hook of syslog-ng on stderr" >&2
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ process_name=%(program_name)s
startsecs = 5
autostart = false
autorestart = true
stdout_logfile=/dev/stdout
; the container log, or the files of LOG_STDOUT and LOG_STDERR
stdout_logfile=/docker.stdout
stdout_logfile_maxbytes=0
stderr_logfile=/dev/stderr
stderr_logfile=/docker.stderr
stderr_logfile_maxbytes=0
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ process_name=%(program_name)s
startsecs = 5
autostart = false
autorestart = true
stdout_logfile=/dev/stdout
; the container log, or the files of LOG_STDOUT and LOG_STDERR
stdout_logfile=/docker.stdout
stdout_logfile_maxbytes=0
stderr_logfile=/dev/stderr
stderr_logfile=/docker.stderr
stderr_logfile_maxbytes=0
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ process_name=%(program_name)s
startsecs = 5
autostart = false
autorestart = true
stdout_logfile=/dev/stdout
; the container log, or the files of LOG_STDOUT and LOG_STDERR
stdout_logfile=/docker.stdout
stdout_logfile_maxbytes=0
stderr_logfile=/dev/stderr
stderr_logfile=/docker.stderr
stderr_logfile_maxbytes=0
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ process_name=%(program_name)s
startsecs = 5
autostart = false
autorestart = true
stdout_logfile=/dev/stdout
; the container log, or the files of LOG_STDOUT and LOG_STDERR
stdout_logfile=/docker.stdout
stdout_logfile_maxbytes=0
stderr_logfile=/dev/stderr
stderr_logfile=/docker.stderr
stderr_logfile_maxbytes=0
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ process_name=%(program_name)s
startsecs = 5
autostart = false
autorestart = true
stdout_logfile=/dev/stdout
; the container log, or the files of LOG_STDOUT and LOG_STDERR
stdout_logfile=/docker.stdout
stdout_logfile_maxbytes=0
stderr_logfile=/dev/stderr
stderr_logfile=/docker.stderr
stderr_logfile_maxbytes=0
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ process_name=%(program_name)s
startsecs = 5
autostart = false
autorestart = true
stdout_logfile=/dev/stdout
; the container log, or the files of LOG_STDOUT and LOG_STDERR
stdout_logfile=/docker.stdout
stdout_logfile_maxbytes=0
stderr_logfile=/dev/stderr
stderr_logfile=/docker.stderr
stderr_logfile_maxbytes=0
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ process_name=%(program_name)s
startsecs = 5
autostart = false
autorestart = true
stdout_logfile=/dev/stdout
; the container log, or the files of LOG_STDOUT and LOG_STDERR
stdout_logfile=/docker.stdout
stdout_logfile_maxbytes=0
stderr_logfile=/dev/stderr
stderr_logfile=/docker.stderr
stderr_logfile_maxbytes=0
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ process_name=%(program_name)s
startsecs = 5
autostart = false
autorestart = true
stdout_logfile=/dev/stdout
; the container log, or the files of LOG_STDOUT and LOG_STDERR
stdout_logfile=/docker.stdout
stdout_logfile_maxbytes=0
stderr_logfile=/dev/stderr
stderr_logfile=/docker.stderr
stderr_logfile_maxbytes=0
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ process_name=%(program_name)s
startsecs = 5
autostart = false
autorestart = true
stdout_logfile=/dev/stdout
; the container log, or the files of LOG_STDOUT and LOG_STDERR
stdout_logfile=/docker.stdout
stdout_logfile_maxbytes=0
stderr_logfile=/dev/stderr
stderr_logfile=/docker.stderr
stderr_logfile_maxbytes=0
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ process_name=%(program_name)s
startsecs = 5
autostart = false
autorestart = true
stdout_logfile=/dev/stdout
; the container log, or the files of LOG_STDOUT and LOG_STDERR
stdout_logfile=/docker.stdout
stdout_logfile_maxbytes=0
stderr_logfile=/dev/stderr
stderr_logfile=/docker.stderr
stderr_logfile_maxbytes=0
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ process_name=%(program_name)s
startsecs = 0
autostart = true
autorestart = true
stdout_logfile=/dev/stdout
; the container log, or the files of LOG_STDOUT and LOG_STDERR
stdout_logfile=/docker.stdout
stdout_logfile_maxbytes=0
stderr_logfile=/dev/stderr
stderr_logfile=/docker.stderr
stderr_logfile_maxbytes=0
5 changes: 3 additions & 2 deletions docker/php-apache/8.2/conf/etc/supervisor.d/apache.conf
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ process_name=%(program_name)s
startsecs = 0
autostart = true
autorestart = true
stdout_logfile=/dev/stdout
; the container log, or the files of LOG_STDOUT and LOG_STDERR
stdout_logfile=/docker.stdout
stdout_logfile_maxbytes=0
stderr_logfile=/dev/stderr
stderr_logfile=/docker.stderr
stderr_logfile_maxbytes=0
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ process_name=%(program_name)s
startsecs = 0
autostart = true
autorestart = true
stdout_logfile=/dev/stdout
; the container log, or the files of LOG_STDOUT and LOG_STDERR
stdout_logfile=/docker.stdout
stdout_logfile_maxbytes=0
stderr_logfile=/dev/stderr
stderr_logfile=/docker.stderr
stderr_logfile_maxbytes=0
5 changes: 3 additions & 2 deletions docker/php-apache/8.3/conf/etc/supervisor.d/apache.conf
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ process_name=%(program_name)s
startsecs = 0
autostart = true
autorestart = true
stdout_logfile=/dev/stdout
; the container log, or the files of LOG_STDOUT and LOG_STDERR
stdout_logfile=/docker.stdout
stdout_logfile_maxbytes=0
stderr_logfile=/dev/stderr
stderr_logfile=/docker.stderr
stderr_logfile_maxbytes=0
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ process_name=%(program_name)s
startsecs = 0
autostart = true
autorestart = true
stdout_logfile=/dev/stdout
; the container log, or the files of LOG_STDOUT and LOG_STDERR
stdout_logfile=/docker.stdout
stdout_logfile_maxbytes=0
stderr_logfile=/dev/stderr
stderr_logfile=/docker.stderr
stderr_logfile_maxbytes=0
5 changes: 3 additions & 2 deletions docker/php-apache/8.4/conf/etc/supervisor.d/apache.conf
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ process_name=%(program_name)s
startsecs = 0
autostart = true
autorestart = true
stdout_logfile=/dev/stdout
; the container log, or the files of LOG_STDOUT and LOG_STDERR
stdout_logfile=/docker.stdout
stdout_logfile_maxbytes=0
stderr_logfile=/dev/stderr
stderr_logfile=/docker.stderr
stderr_logfile_maxbytes=0
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ process_name=%(program_name)s
startsecs = 0
autostart = true
autorestart = true
stdout_logfile=/dev/stdout
; the container log, or the files of LOG_STDOUT and LOG_STDERR
stdout_logfile=/docker.stdout
stdout_logfile_maxbytes=0
stderr_logfile=/dev/stderr
stderr_logfile=/docker.stderr
stderr_logfile_maxbytes=0
5 changes: 3 additions & 2 deletions docker/php-apache/8.5/conf/etc/supervisor.d/apache.conf
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ process_name=%(program_name)s
startsecs = 0
autostart = true
autorestart = true
stdout_logfile=/dev/stdout
; the container log, or the files of LOG_STDOUT and LOG_STDERR
stdout_logfile=/docker.stdout
stdout_logfile_maxbytes=0
stderr_logfile=/dev/stderr
stderr_logfile=/docker.stderr
stderr_logfile_maxbytes=0
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ process_name=%(program_name)s
startsecs = 0
autostart = true
autorestart = true
stdout_logfile=/dev/stdout
; the container log, or the files of LOG_STDOUT and LOG_STDERR
stdout_logfile=/docker.stdout
stdout_logfile_maxbytes=0
stderr_logfile=/dev/stderr
stderr_logfile=/docker.stderr
stderr_logfile_maxbytes=0
5 changes: 3 additions & 2 deletions docker/php-apache/8.6/conf/etc/supervisor.d/apache.conf
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ process_name=%(program_name)s
startsecs = 0
autostart = true
autorestart = true
stdout_logfile=/dev/stdout
; the container log, or the files of LOG_STDOUT and LOG_STDERR
stdout_logfile=/docker.stdout
stdout_logfile_maxbytes=0
stderr_logfile=/dev/stderr
stderr_logfile=/docker.stderr
stderr_logfile_maxbytes=0
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ process_name=%(program_name)s
startsecs = 5
autostart = false
autorestart = true
stdout_logfile=/dev/stdout
; the container log, or the files of LOG_STDOUT and LOG_STDERR
stdout_logfile=/docker.stdout
stdout_logfile_maxbytes=0
stderr_logfile=/dev/stderr
stderr_logfile=/docker.stderr
stderr_logfile_maxbytes=0
5 changes: 3 additions & 2 deletions docker/php-dev/8.2/conf/etc/supervisor.d/blackfire-agent.conf
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ process_name=%(program_name)s
startsecs = 5
autostart = false
autorestart = true
stdout_logfile=/dev/stdout
; the container log, or the files of LOG_STDOUT and LOG_STDERR
stdout_logfile=/docker.stdout
stdout_logfile_maxbytes=0
stderr_logfile=/dev/stderr
stderr_logfile=/docker.stderr
stderr_logfile_maxbytes=0
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ process_name=%(program_name)s
startsecs = 5
autostart = false
autorestart = true
stdout_logfile=/dev/stdout
; the container log, or the files of LOG_STDOUT and LOG_STDERR
stdout_logfile=/docker.stdout
stdout_logfile_maxbytes=0
stderr_logfile=/dev/stderr
stderr_logfile=/docker.stderr
stderr_logfile_maxbytes=0
Loading