Merge pull request #1 from hybula/docker

Docker support
This commit is contained in:
Tamer 2022-04-14 12:46:40 +02:00 committed by GitHub
commit 6f5395a092
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
10 changed files with 115 additions and 11 deletions

1
.gitignore vendored
View file

@ -1,4 +1,3 @@
.idea .idea
config.php config.php
www.bat

20
CHANGELOG.md Normal file
View file

@ -0,0 +1,20 @@
# Changelog
All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
## [Unreleased]
## [1.0.0] - 14-04-2022
### Fixed
- Undefined warning when refreshing a page after execution.
- Traceroute error when there is no PID found.
### Added
- Added Docker support.
- This CHANGELOG.md to track changes.
## [0.1.0] - 17-01-2022
### Changed
- First release.

View file

@ -311,16 +311,18 @@ class LookingGlass
foreach ($pipes as $pipe) { foreach ($pipes as $pipe) {
fclose($pipe); fclose($pipe);
} }
if ($status['pid']) {
// retrieve parent pid // retrieve parent pid
$ppid = $status['pid']; //$ppid = $status['pid'];
// use ps to get all the children of this process // use ps to get all the children of this process
$pids = preg_split('/\s+/', `ps -o pid --no-heading --ppid $ppid`); $pids = preg_split('/\s+/', 'ps -o pid --no-heading --ppid '.$status['pid']);
// kill remaining processes // kill remaining processes
foreach ($pids as $pid) { foreach ($pids as $pid) {
if (is_numeric($pid)) { if (is_numeric($pid)) {
posix_kill($pid, 9); posix_kill($pid, 9);
} }
} }
}
proc_close($process); proc_close($process);
} }
return true; return true;

18
docker-compose.yml Normal file
View file

@ -0,0 +1,18 @@
version: "3.8"
services:
nginx:
image: hybula/lookingglass-nginx:1
build:
context: docker/nginx
dockerfile: Dockerfile
ports:
- "80:80"
restart: unless-stopped
php-fpm:
image: hybula/lookingglass-php:1
build:
context: .
dockerfile: docker/php-fpm/Dockerfile
restart: unless-stopped

3
docker/nginx/Dockerfile Normal file
View file

@ -0,0 +1,3 @@
FROM nginx:mainline-alpine
COPY nginx.conf /etc/nginx/nginx.conf

View file

@ -0,0 +1,2 @@
Dockerfile
Dockerfile.dockerignore

49
docker/nginx/nginx.conf Normal file
View file

@ -0,0 +1,49 @@
user nginx;
worker_processes 1;
error_log /dev/stderr warn;
pid /run/nginx.pid;
events {
worker_connections 1024;
multi_accept on;
use epoll;
}
http {
include /etc/nginx/mime.types;
default_type application/octet-stream;
access_log /dev/stdout combined;
sendfile on;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 65;
types_hash_max_size 2048;
client_max_body_size 100m;
server_tokens off;
gzip on;
open_file_cache max=100;
server {
listen 80 default_server;
listen [::]:80 default_server;
server_name _;
location / {
try_files $uri $uri/ /index.php$is_args$args;
}
location ~ \.php$ {
root /var/www/html;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass php-fpm:9000;
fastcgi_index index.php;
include fastcgi.conf;
fastcgi_buffering on;
fastcgi_buffer_size 1k;
fastcgi_buffers 128 1k;
fastcgi_max_temp_file_size 0;
gzip off;
}
}
}

View file

@ -0,0 +1,8 @@
FROM php:8.1-fpm-bullseye
RUN apt update && apt install iputils-ping mtr traceroute -y
WORKDIR /var/www/html
COPY . .
COPY docker/php-fpm/src/config.php config.php

View file

@ -0,0 +1,3 @@
Dockerfile
Dockerfile.dockerignore
.git

View file

@ -24,7 +24,7 @@ $detectIpAddress = LookingGlass::detectIpAddress();
if (!empty($_POST)) { if (!empty($_POST)) {
do { do {
if (!isset($_POST['csrfToken']) || ($_POST['csrfToken'] != $_SESSION['CSRF'])) { if (!isset($_POST['csrfToken']) || !isset($_SESSION['CSRF']) || ($_POST['csrfToken'] != $_SESSION['CSRF'])) {
$errorMessage = 'Missing or incorrect CSRF token.'; $errorMessage = 'Missing or incorrect CSRF token.';
break; break;
} }