Skip to content

Commit

Permalink
Merge pull request #30 from likesistemas/feature/disable-config
Browse files Browse the repository at this point in the history
✨ Adding option to disable configuration
  • Loading branch information
ricardoapaes committed Jun 3, 2022
2 parents 72db4f7 + 29c3397 commit 03b5777
Show file tree
Hide file tree
Showing 4 changed files with 63 additions and 1 deletion.
31 changes: 31 additions & 0 deletions .github/workflows/docker-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,37 @@ jobs:
exit 1;
fi
- name: Run tests config disabled
if: matrix.PHP == '80'
env:
PHP_VERSION: ${{ matrix.PHP }}
run: |
docker-compose -f docker-compose.yml \
-f docker-compose-${PHP_VERSION}.yml \
-f docker-compose-config-disabled.yml \
up --build -d
echo $(docker run -t --network lemp jwilder/dockerize \
-wait http://core_nginx/ \
-timeout 60s)
docker ps -a
docker logs app
CONTENT=$(curl -s "http://127.0.0.1/");
echo "CHAMADA HTTP: ${CONTENT}";
if [ "${CONTENT}" != "core|${PHP_VERSION}|empty" ]; then
echo "Chamada HTTP retornou errado: ${CONTENT}"
exit 1;
fi
docker-compose -f docker-compose.yml \
-f docker-compose-${PHP_VERSION}.yml \
-f docker-compose-config-disabled.yml \
down -v
- name: Run tests prod
env:
PHP_VERSION: ${{ matrix.PHP }}
Expand Down
7 changes: 7 additions & 0 deletions docker-compose-config-disabled.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
version: '3.5'

services:

app:
environment:
- CONFIG_DISABLED=true
8 changes: 7 additions & 1 deletion events/src-copied
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
#!/bin/bash
configure-volumes;
configure-db;

if [ -z $CONFIG_DISABLED ]; then
configure-db;
else
echo "config-db: está desabilitado!";
fi

configure-app ${APP_NAME};
18 changes: 18 additions & 0 deletions www80/public/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,19 @@
$versaoPhpFormatadaComPonto = $versaoPhp[0] . '.' . $versaoPhp[1];

$config = parse_ini_file(__DIR__ . "/../config.ini", true);

$emptyConfig = [
'bd' => [
'host' => '',
'user' => '',
'password' => '',
'bd' => ''
],
'php' => [
'version' => $versaoPhpFormatadaComPonto
]
];

$expectedConfig = [
'bd' => [
'host' => 'mysql',
Expand Down Expand Up @@ -65,6 +78,11 @@
}

if( count($validation) > 0 ) {
if($config === $emptyConfig) {
echo "core" . "|" . $versaoPhpFormatada . "|empty";
return;
}

echo "<pre>";
echo join("\n", $validation);
var_dump($config);
Expand Down

0 comments on commit 03b5777

Please sign in to comment.