This commit is contained in:
Greyscale 2024-04-04 07:21:38 +02:00
parent 30c040caf8
commit 58b5603639
No known key found for this signature in database
GPG key ID: 74BAFF55434DA4B2
8 changed files with 14 additions and 18 deletions
.github/workflows
php/nginx
swarm-connectivity-tester

View file

@ -82,11 +82,6 @@ jobs:
platforms: ${{ !env.ACT && 'linux/amd64,linux/arm64' || 'linux/amd64' }}
pull: true
push: true
build-args: |
GIT_SHA=${{ github.sha }}
GIT_BUILD_ID=${{ github.ref_name }}
BUILD_DATE=${{ steps.date.outputs.container_build_datetime }}
GIT_COMMIT_MESSAGE=${{ github.event.head_commit.message }}
tags: |
${{ !env.ACT && 'benzine/swarm-connectivity-tester:target' || '' }}
${{ !env.ACT && 'ghcr.io/benzine-framework/swarm-connectivity-tester:target' || 'ghcr.io/benzine-framework/swarm-connectivity-tester:target-devel' }}
@ -104,11 +99,6 @@ jobs:
platforms: ${{ !env.ACT && 'linux/amd64,linux/arm64' || 'linux/amd64' }}
pull: true
push: true
build-args: |
GIT_SHA=${{ github.sha }}
GIT_BUILD_ID=${{ github.ref_name }}
BUILD_DATE=${{ steps.date.outputs.container_build_datetime }}
GIT_COMMIT_MESSAGE=${{ github.event.head_commit.message }}
tags: |
${{ !env.ACT && 'benzine/swarm-connectivity-tester:reporter' || '' }}
${{ !env.ACT && 'ghcr.io/benzine-framework/swarm-connectivity-tester:reporter' || 'ghcr.io/benzine-framework/swarm-connectivity-tester:reporter-devel' }}

View file

@ -1,2 +1,3 @@
#!/usr/bin/env bash
# shellcheck disable=SC1083
tail -f /var/log/php{{PHP}}-fpm.log

View file

@ -1,9 +1,10 @@
#!/usr/bin/env bash
# shellcheck disable=SC1083,SC2312
# Create the log file to be able to run tail without errors
touch /var/log/php{{PHP}}-fpm.log
# Load envs into PHP-fpm's env.conf.
# shellcheck disable=SC1083,SC2312
env | sed "s/\(.*\)=\(.*\)/env[\1]='\2'/" >/etc/php/{{PHP}}/fpm/conf.d/env.conf
if [[ ${DEBUG_MODE,,} == "on" ]]; then

View file

@ -3,9 +3,10 @@ FROM php:nginx as connect-target
LABEL maintainer="Matthew Baggett <matthew@baggett.me>" \
org.label-schema.vcs-url="https://github.com/benzine-framework/docker" \
org.opencontainers.image.source="https://github.com/benzine-framework/docker"
SHELL ["/bin/bash", "-o", "pipefail", "-c"]
RUN echo -e "#!/bin/bash\n\ntail -f /var/log/php8.2-fpm.log" > /etc/service/logs-phpfpm-error/run && \
chmod +x /etc/service/logs-phpfpm-error/run
SHELL ["/bin/bash", "-o", "pipefail", "-c"]
WORKDIR /app
HEALTHCHECK --interval=30s --timeout=3s \
CMD curl -f http://localhost/ping.php || exit 1
@ -16,9 +17,9 @@ FROM php:nginx as connect-reporter
LABEL maintainer="Matthew Baggett <matthew@baggett.me>" \
org.label-schema.vcs-url="https://github.com/benzine-framework/docker" \
org.opencontainers.image.source="https://github.com/benzine-framework/docker"
SHELL ["/bin/bash", "-o", "pipefail", "-c"]
RUN echo -e "#!/bin/bash\n\ntail -f /var/log/php8.2-fpm.log" > /etc/service/logs-phpfpm-error/run && \
chmod +x /etc/service/logs-phpfpm-error/run
SHELL ["/bin/bash", "-o", "pipefail", "-c"]
WORKDIR /app
HEALTHCHECK --interval=30s --timeout=3s \
CMD curl -f http://localhost/ping.php || exit 1

View file

@ -12,7 +12,7 @@ $targets = explode(",", $_ENV['TARGETS']);
$targets = array_map('trim', $targets);
# For each $target, resolve the target to IP addresses
foreach($targets as $target){
foreach($targets as $target) {
$targetIps[$target] = gethostbynamel($target) ?: [];
$targetIps[$target] = array_values($targetIps[$target]);
}
@ -27,21 +27,21 @@ foreach ($targets as $target) {
$responses = Utils::settle($promises)->wait();
$rollup = true;
$json = [];
foreach($responses as $target => $response){
foreach($responses as $target => $response) {
if(!isset($response['value']) || $response['value']->getStatusCode() != 200) {
$rollup = false;
if ($response['reason'] instanceof \Exception) {
$json[$target] = ['Status' => 'ERROR', 'Reason' => $response['reason']->getMessage()];
}else {
} else {
$json[$target] = ['Status' => "ERROR", 'Reason' => 'Unknown'];
}
}else{
} else {
$json[$target] = json_decode($response['value']->getBody()->getContents(), true);
}
$json[$target]['IP'] = $targetIps[$target];
}
if(!$rollup){
if(!$rollup) {
header("HTTP/1.0 500 Internal Server Error");
}
header('Content-Type: application/json; charset=utf-8');

View file

@ -1,2 +1,3 @@
<?php
echo json_encode(['Pong',]);

View file

@ -1,4 +1,5 @@
<?php
header('Content-Type: application/json; charset=utf-8');
echo json_encode([
'Status' => 'OK',

View file

@ -1,2 +1,3 @@
<?php
echo json_encode(['Pong',]);