Skip to content

Commit b57e296

Browse files
committed
fix: parser
1 parent 110fac9 commit b57e296

File tree

2 files changed

+113
-35
lines changed

2 files changed

+113
-35
lines changed

bootstrap/helpers/shared.php

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3286,15 +3286,17 @@ function newParser(Application|Service $resource, int $pull_request_id = 0, ?int
32863286
$value = $fqdn;
32873287
}
32883288
if (! $isDatabase) {
3289-
if ($isApplication && is_null($resource->fqdn)) {
3290-
data_forget($resource, 'environment_variables');
3291-
data_forget($resource, 'environment_variables_preview');
3292-
$resource->fqdn = $value;
3293-
$resource->save();
3294-
} elseif ($isService && is_null($savedService->fqdn)) {
3295-
if ($key->startsWith('SERVICE_FQDN_')) {
3296-
$savedService->fqdn = $value;
3297-
$savedService->save();
3289+
if ($key->startsWith('SERVICE_FQDN_') && ($originalValue->value() === '' || $originalValue->startsWith('/'))) {
3290+
if ($isApplication && is_null($resource->fqdn)) {
3291+
data_forget($resource, 'environment_variables');
3292+
data_forget($resource, 'environment_variables_preview');
3293+
$resource->fqdn = $value;
3294+
$resource->save();
3295+
} elseif ($isService && is_null($savedService->fqdn)) {
3296+
if ($key->startsWith('SERVICE_FQDN_')) {
3297+
$savedService->fqdn = $value;
3298+
$savedService->save();
3299+
}
32983300
}
32993301
}
33003302
}

tests/Feature/DockerComposeParseTest.php

Lines changed: 102 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -87,40 +87,116 @@
8787
'pull_request_html_url' => 'https://github.com/coollabsio/coolify-examples/pull/1',
8888
]);
8989
$this->serviceYaml = '
90-
version: "3.8"
9190
services:
92-
app:
93-
image: nginx
91+
chatwoot:
92+
image: chatwoot/chatwoot:latest
93+
depends_on:
94+
- postgres
95+
- redis
9496
environment:
95-
SERVICE_FQDN_APP: /app
96-
APP_KEY: base64
97-
APP_DEBUG: "${APP_DEBUG:-false}"
98-
APP_URL: $SERVICE_FQDN_APP
99-
DB_URL: postgres://${SERVICE_USER_POSTGRES}:${SERVICE_PASSWORD_POSTGRES}@db:5432/postgres?schema=public
97+
- SERVICE_FQDN_CHATWOOT_3000
98+
- SECRET_KEY_BASE=$SERVICE_PASSWORD_CHATWOOT
99+
- FRONTEND_URL=${SERVICE_FQDN_CHATWOOT}
100+
- DEFAULT_LOCALE=${CHATWOOT_DEFAULT_LOCALE}
101+
- FORCE_SSL=false
102+
- ENABLE_ACCOUNT_SIGNUP=false
103+
- REDIS_URL=redis://default@redis:6379
104+
- REDIS_PASSWORD=$SERVICE_PASSWORD_REDIS
105+
- REDIS_OPENSSL_VERIFY_MODE=none
106+
- POSTGRES_DATABASE=chatwoot
107+
- POSTGRES_HOST=postgres
108+
- POSTGRES_USERNAME=$SERVICE_USER_POSTGRES_USER
109+
- POSTGRES_PASSWORD=$SERVICE_PASSWORD_POSTGRES
110+
- RAILS_MAX_THREADS=5
111+
- NODE_ENV=production
112+
- RAILS_ENV=production
113+
- INSTALLATION_ENV=docker
114+
- MAILER_SENDER_EMAIL=${CHATWOOT_MAILER_SENDER_EMAIL}
115+
- SMTP_ADDRESS=${CHATWOOT_SMTP_ADDRESS}
116+
- SMTP_AUTHENTICATION=${CHATWOOT_SMTP_AUTHENTICATION}
117+
- SMTP_DOMAIN=${CHATWOOT_SMTP_DOMAIN}
118+
- SMTP_ENABLE_STARTTLS_AUTO=${CHATWOOT_SMTP_ENABLE_STARTTLS_AUTO}
119+
- SMTP_PORT=${CHATWOOT_SMTP_PORT}
120+
- SMTP_USERNAME=${CHATWOOT_SMTP_USERNAME}
121+
- SMTP_PASSWORD=${CHATWOOT_SMTP_PASSWORD}
122+
- ACTIVE_STORAGE_SERVICE=local
123+
entrypoint: docker/entrypoints/rails.sh
124+
command: sh -c "bundle exec rails db:chatwoot_prepare && bundle exec rails s -p 3000 -b 0.0.0.0"
100125
volumes:
101-
- "./nginx:/etc/nginx"
102-
- "data:/var/www/html"
126+
- rails-data:/app/storage
127+
healthcheck:
128+
test: ["CMD", "wget", "--spider", "-q", "http://127.0.0.1:3000"]
129+
interval: 5s
130+
timeout: 20s
131+
retries: 10
132+
133+
sidekiq:
134+
image: chatwoot/chatwoot:latest
103135
depends_on:
104-
- db
105-
db:
106-
image: postgres
136+
- postgres
137+
- redis
107138
environment:
108-
POSTGRES_USER: "${SERVICE_USER_POSTGRES}"
109-
POSTGRES_PASSWORD: "${SERVICE_PASSWORD_POSTGRES}"
139+
- SECRET_KEY_BASE=$SERVICE_PASSWORD_CHATWOOT
140+
- FRONTEND_URL=${SERVICE_FQDN_CHATWOOT}
141+
- DEFAULT_LOCALE=${CHATWOOT_DEFAULT_LOCALE}
142+
- FORCE_SSL=false
143+
- ENABLE_ACCOUNT_SIGNUP=false
144+
- REDIS_URL=redis://default@redis:6379
145+
- REDIS_PASSWORD=$SERVICE_PASSWORD_REDIS
146+
- REDIS_OPENSSL_VERIFY_MODE=none
147+
- POSTGRES_DATABASE=chatwoot
148+
- POSTGRES_HOST=postgres
149+
- POSTGRES_USERNAME=$SERVICE_USER_POSTGRES_USER
150+
- POSTGRES_PASSWORD=$SERVICE_PASSWORD_POSTGRES
151+
- RAILS_MAX_THREADS=5
152+
- NODE_ENV=production
153+
- RAILS_ENV=production
154+
- INSTALLATION_ENV=docker
155+
- MAILER_SENDER_EMAIL=${CHATWOOT_MAILER_SENDER_EMAIL}
156+
- SMTP_ADDRESS=${CHATWOOT_SMTP_ADDRESS}
157+
- SMTP_AUTHENTICATION=${CHATWOOT_SMTP_AUTHENTICATION}
158+
- SMTP_DOMAIN=${CHATWOOT_SMTP_DOMAIN}
159+
- SMTP_ENABLE_STARTTLS_AUTO=${CHATWOOT_SMTP_ENABLE_STARTTLS_AUTO}
160+
- SMTP_PORT=${CHATWOOT_SMTP_PORT}
161+
- SMTP_USERNAME=${CHATWOOT_SMTP_USERNAME}
162+
- SMTP_PASSWORD=${CHATWOOT_SMTP_PASSWORD}
163+
- ACTIVE_STORAGE_SERVICE=local
164+
command: ["bundle", "exec", "sidekiq", "-C", "config/sidekiq.yml"]
110165
volumes:
111-
- "dbdata:/var/lib/postgresql/data"
166+
- sidekiq-data:/app/storage
112167
healthcheck:
113-
test:
114-
- CMD
115-
- pg_isready
116-
- "-U"
117-
- "postgres"
118-
interval: 2s
168+
test: ["CMD-SHELL", "bundle exec rails runner \'puts Sidekiq.redis(&:info)\' > /dev/null 2>&1"]
169+
interval: 30s
119170
timeout: 10s
120-
retries: 10
121-
depends_on:
122-
app:
123-
condition: service_healthy
171+
retries: 3
172+
173+
postgres:
174+
image: postgres:12
175+
restart: always
176+
volumes:
177+
- postgres-data:/var/lib/postgresql/data
178+
environment:
179+
- POSTGRES_DB=chatwoot
180+
- POSTGRES_USER=$SERVICE_USER_POSTGRES_USER
181+
- POSTGRES_PASSWORD=$SERVICE_PASSWORD_POSTGRES
182+
healthcheck:
183+
test: ["CMD-SHELL", "pg_isready -U $SERVICE_USER_POSTGRES_USER -d chatwoot -h 127.0.0.1"]
184+
interval: 30s
185+
timeout: 10s
186+
retries: 5
187+
188+
redis:
189+
image: redis:alpine
190+
restart: always
191+
command: ["sh", "-c", "redis-server --requirepass \"$SERVICE_PASSWORD_REDIS\""]
192+
volumes:
193+
- redis-data:/data
194+
healthcheck:
195+
test: ["CMD", "redis-cli", "-a", "$SERVICE_PASSWORD_REDIS", "PING"]
196+
interval: 30s
197+
timeout: 10s
198+
retries: 5
199+
124200
';
125201

126202
$this->serviceComposeFileString = Yaml::parse($this->serviceYaml);

0 commit comments

Comments
 (0)