Skip to content

Commit

Permalink
Merge pull request #1 from andersundsehr/searchforcompose
Browse files Browse the repository at this point in the history
Searchforcompose
  • Loading branch information
N0S0I authored Sep 5, 2024
2 parents 9236aa2 + 24c44b7 commit 1d3eb83
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 5 deletions.
16 changes: 13 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,15 +1,25 @@
# Search for compose

## General informations
This image is used in the local development environment. It provides a service that is used as standard in the Nginx proxy.

If you call a url where no service is stored, this service is used.
This image is used in the local development environment. It provides a service that is used as standard in the Nginx
proxy.

If you call a URL where no service is stored, this service is used.

It searches through all available containers and finds the matching container that contains the domain.
The container can be started at the click of a button.

## How to use it

If your project was only stopped and not fully shut down, you can easily restart it by simply entering the project's URL
into your browser. This service will pop up, and with just one click on the start button, all containers
associated with the project will be launched. This eliminates the need to manually start the containers through the
console, saving you time and effort.

### Where you can find it too
* github.com/andersudnsehr

* github.com/andersundsehr
* hub.docker.com

Made by me, Itay ≽^•⩊•^≼
7 changes: 5 additions & 2 deletions src/generateNginxConfig.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,14 @@
$certFiles = scandir($certsDir);

$newConfig = '';
echo PHP_EOL . "\033[32m" . "Certificates : " . "\033[0m" . PHP_EOL;
foreach ($certFiles as $cert) {
if ($cert == '.' || $cert == '..') continue;
if (pathinfo($cert, PATHINFO_EXTENSION) !== 'crt') continue;
if ($cert === 'default.crt') continue;
$domain = pathinfo($cert, PATHINFO_FILENAME);
echo PHP_EOL . "\033[32m" . "- " . $domain . "\033[0m" . PHP_EOL;
$virtualHost = getenv('VIRTUAL_HOST') ?: throw new \Exception('env VIRTUAL_HOST is required');
$newConfig .= "
server {
server_name *.$domain;
Expand All @@ -20,14 +23,14 @@
ssl_certificate /etc/nginx/certs/$domain.crt;
ssl_certificate_key /etc/nginx/certs/$domain.key;
location / {
proxy_pass http://searchforcompose.vm17.iveins.de;
proxy_pass http://$virtualHost;
}
}
";
}

$nginxConfFile = "/searchforcompose.conf";
//nginx proxy nich restarten wenn nichts geändert wurde
//only restart nginx if the config file has changed
$oldConfig = file_get_contents($nginxConfFile);
if ($oldConfig === $newConfig) {
echo PHP_EOL . "\033[32m" . "Nginx config file did not change" . "\033[0m" . PHP_EOL;
Expand Down

0 comments on commit 1d3eb83

Please sign in to comment.