Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Searchforcompose #1

Merged
merged 7 commits into from
Sep 5, 2024
Merged
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
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
Loading