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

[1.x] added elasticsearch as service to sail services #714

Closed
wants to merge 1 commit into from
Closed
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
8 changes: 7 additions & 1 deletion src/Console/Concerns/InteractsWithDockerComposeServices.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ trait InteractsWithDockerComposeServices
'memcached',
'meilisearch',
'typesense',
'elasticsearch',
'minio',
'mailpit',
'selenium',
Expand Down Expand Up @@ -99,7 +100,7 @@ protected function buildDockerCompose(array $services)
// Merge volumes...
collect($services)
->filter(function ($service) {
return in_array($service, ['mysql', 'pgsql', 'mariadb', 'redis', 'meilisearch', 'typesense', 'minio']);
return in_array($service, ['mysql', 'pgsql', 'mariadb', 'redis', 'meilisearch', 'typesense', 'minio', 'elasticsearch']);
})->filter(function ($service) use ($compose) {
return ! array_key_exists($service, $compose['volumes'] ?? []);
})->each(function ($service) use (&$compose) {
Expand Down Expand Up @@ -185,6 +186,11 @@ protected function replaceEnvVariables(array $services)
$environment .= "\nTYPESENSE_API_KEY=xyz\n";
}

if (in_array('elasticsearch', $services)) {
$environment .= "\nSCOUT_DRIVER=elastic";
$environment .= "\nELASTICSEARCH_HOST=http://elasticsearch:9200\n";
}

if (in_array('soketi', $services)) {
$environment = preg_replace("/^BROADCAST_DRIVER=(.*)/m", "BROADCAST_DRIVER=pusher", $environment);
$environment = preg_replace("/^PUSHER_APP_ID=(.*)/m", "PUSHER_APP_ID=app-id", $environment);
Expand Down
30 changes: 30 additions & 0 deletions stubs/elasticsearch.stub
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
elasticsearch:
image: docker.elastic.co/elasticsearch/elasticsearch:8.7.1
ports:
- '${FORWARD_ELASTICSEARCH_PORT:-9200}:9200'
environment:
- discovery.type=single-node
- bootstrap.memory_lock=true
- "ES_JAVA_OPTS=-Xms1g -Xmx1g"
- xpack.security.enabled=false
- xpack.security.enrollment.enabled=false
volumes:
- sail-elasticsearch:/usr/share/elasticsearch/data
networks:
- sail
ulimits:
memlock:
soft: -1
hard: -1
deploy:
resources:
limits:
cpus: '2.0'
reservations:
cpus: '1.0'
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:9200/_cluster/health"]
interval: 30s
timeout: 5s
retries: 3
start_period: 30s