feat: Update Docker Compose file with DB_URL environment variable

This commit is contained in:
Andras Bacsai
2024-09-06 10:02:44 +02:00
parent b44f4e49e8
commit a32e53c5a3

View File

@@ -1,5 +1,6 @@
<?php <?php
use App\Actions\Service\DeleteService;
use App\Models\Application; use App\Models\Application;
use App\Models\ApplicationPreview; use App\Models\ApplicationPreview;
use App\Models\GithubApp; use App\Models\GithubApp;
@@ -8,7 +9,6 @@ use App\Models\Service;
use App\Models\StandaloneDocker; use App\Models\StandaloneDocker;
use Illuminate\Support\Collection; use Illuminate\Support\Collection;
use Symfony\Component\Yaml\Yaml; use Symfony\Component\Yaml\Yaml;
use Visus\Cuid2\Cuid2;
beforeEach(function () { beforeEach(function () {
$this->applicationYaml = ' $this->applicationYaml = '
@@ -21,6 +21,7 @@ services:
APP_KEY: base64 APP_KEY: base64
APP_DEBUG: "${APP_DEBUG:-false}" APP_DEBUG: "${APP_DEBUG:-false}"
APP_URL: $SERVICE_FQDN_APP APP_URL: $SERVICE_FQDN_APP
DB_URL: postgres://${SERVICE_USER_POSTGRES}:${SERVICE_PASSWORD_POSTGRES}@db:5432/postgres?schema=public
volumes: volumes:
- "./nginx:/etc/nginx" - "./nginx:/etc/nginx"
- "data:/var/www/html" - "data:/var/www/html"
@@ -29,8 +30,8 @@ services:
db: db:
image: postgres image: postgres
environment: environment:
POSTGRES_USER: "${POSTGRES_USER:-postgres}" POSTGRES_USER: "${SERVICE_USER_POSTGRES}"
POSTGRES_PASSWORD: "${POSTGRES_PASSWORD:-postgres}" POSTGRES_PASSWORD: "${SERVICE_PASSWORD_POSTGRES}"
volumes: volumes:
- "dbdata:/var/lib/postgresql/data" - "dbdata:/var/lib/postgresql/data"
healthcheck: healthcheck:
@@ -88,34 +89,24 @@ networks:
$this->serviceYaml = ' $this->serviceYaml = '
version: "3.8" version: "3.8"
services: services:
activepieces: app:
image: ghcr.io/activepieces/activepieces:latest image: nginx
environment: environment:
- SERVICE_FQDN_ACTIVEPIECES SERVICE_FQDN_APP: /app
- AP_ENCRYPTION_KEY=$SERVICE_PASSWORD_ENCRYPTIONKEY APP_KEY: base64
- AP_EXECUTION_MODE=UNSANDBOXED APP_DEBUG: "${APP_DEBUG:-false}"
- AP_FRONTEND_URL=$SERVICE_FQDN_ACTIVEPIECES APP_URL: $SERVICE_FQDN_APP
- AP_TEST=${AP_TEST:-test} DB_URL: postgres://${SERVICE_USER_POSTGRES}:${SERVICE_PASSWORD_POSTGRES}@db:5432/postgres?schema=public
volumes: volumes:
- "dbdata:/var/lib/postgresql/data" - "./nginx:/etc/nginx"
- "data:/var/www/html"
depends_on: depends_on:
- postgres - db
- redis db:
activepieces2: image: postgres
image: ghcr.io/activepieces/activepieces:latest
environment: environment:
TEST: $SERVICE_FQDN_ACTIVEPIECES POSTGRES_USER: "${SERVICE_USER_POSTGRES}"
volumes: POSTGRES_PASSWORD: "${SERVICE_PASSWORD_POSTGRES}"
- "dbdata:/var/lib/postgresql/data"
depends_on:
- postgres
- redis
postgres:
image: postgres:latest
environment:
POSTGRES_DB: activepieces
POSTGRES_USER: $SERVICE_USER_POSTGRES
POSTGRES_PASSWORD: $SERVICE_PASSWORD_POSTGRES
volumes: volumes:
- "dbdata:/var/lib/postgresql/data" - "dbdata:/var/lib/postgresql/data"
healthcheck: healthcheck:
@@ -127,34 +118,16 @@ services:
interval: 2s interval: 2s
timeout: 10s timeout: 10s
retries: 10 retries: 10
redis: depends_on:
image: redis:latest app:
volumes: condition: service_healthy
- "redis_data:/data" ';
healthcheck:
test:
- CMD
- redis-cli
- ping
interval: 2s
timeout: 10s
retries: 10
volumes:
dbdata:
redis_data:
networks:
default:
name: something
external: true
noinet:
driver: bridge
internal: true';
$this->serviceComposeFileString = Yaml::parse($this->serviceYaml); $this->serviceComposeFileString = Yaml::parse($this->serviceYaml);
$this->service = Service::create([ $this->service = Service::create([
'name' => 'Service for tests', 'name' => 'Service for tests',
'uuid' => (string) new Cuid2(), 'uuid' => 'tgwcg8w4s844wkog8kskw44g',
'docker_compose_raw' => $this->serviceYaml, 'docker_compose_raw' => $this->serviceYaml,
'environment_id' => 1, 'environment_id' => 1,
'server_id' => 0, 'server_id' => 0,
@@ -166,9 +139,18 @@ networks:
afterEach(function () { afterEach(function () {
// $this->applicationPreview->forceDelete(); // $this->applicationPreview->forceDelete();
$this->application->forceDelete(); $this->application->forceDelete();
DeleteService::run($this->service);
$this->service->forceDelete(); $this->service->forceDelete();
}); });
test('ServiceComposeParseNew', function () {
$output = newParser($this->service);
// ray('New parser');
// ray($output->toArray());
ray($this->service->environment_variables->pluck('value', 'key')->toArray());
expect($output)->toBeInstanceOf(Collection::class);
});
// test('ApplicationComposeParse', function () { // test('ApplicationComposeParse', function () {
// expect($this->jsonapplicationComposeFile)->toBeJson()->ray(); // expect($this->jsonapplicationComposeFile)->toBeJson()->ray();
@@ -332,14 +314,6 @@ afterEach(function () {
// }); // });
// test('ServiceComposeParseNew', function () {
// $output = newParser($this->application, pull_request_id: 1, preview_id: $this->applicationPreview->id);
// // ray('New parser');
// // ray($output->toArray());
// ray($this->service->environment_variables_preview->pluck('value', 'key')->toArray());
// expect($output)->toBeInstanceOf(Collection::class);
// });
// test('ServiceComposeParseOld', function () { // test('ServiceComposeParseOld', function () {
// $output = parseDockerComposeFile($this->service); // $output = parseDockerComposeFile($this->service);
// ray('Old parser'); // ray('Old parser');