Skip to content

Commit 0066792

Browse files
authored
Merge pull request #288 from wunderio/NEX-194
NEX-194: DDEV setup improvements: own domain for frontend, elasticsearch improvements
2 parents 00a7433 + 4e9297a commit 0066792

File tree

8 files changed

+122
-44
lines changed

8 files changed

+122
-44
lines changed

.ddev/config.yaml

Lines changed: 23 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,10 @@ nodejs_version: "20"
66
php_version: "8.3"
77
webserver_type: nginx-fpm
88
xdebug_enabled: false
9-
additional_hostnames: []
9+
# This allows us to access the frontend app via https://frontend.ddev.site
10+
# also check the traefik config in .ddev/traefik/config/frontend.yaml.
11+
additional_hostnames:
12+
- frontend
1013
additional_fqdns: []
1114
database:
1215
type: mariadb
@@ -29,30 +32,39 @@ web_environment:
2932
# URL OF THE FRONTEND SITE:
3033
# This needs to match the proxy value for the node service
3134
# so if you change it, remember to change it here as well.
32-
- WUNDER_NEXT_FRONTEND_URL=https://next-drupal-starterkit.ddev.site:3000
35+
- WUNDER_NEXT_FRONTEND_URL=https://frontend.ddev.site
3336
- ENVIRONMENT_NAME=ddev
3437
- HASH_SALT=notsosecurehashnotsosecurehashnotsosecurehash
3538
- NEXT_PUBLIC_DRUPAL_BASE_URL=https://next-drupal-starterkit.ddev.site
36-
- NEXT_PUBLIC_FRONTEND_URL=https://next-drupal-starterkit.ddev.site:3000
39+
- NEXT_PUBLIC_FRONTEND_URL=https://frontend.ddev.site
3740
# Environment variables for next_auth:
3841
- AUTH_SECRET=nextauth_secret_not_secure_used_only_locally
3942
- AUTH_TRUST_HOST=true
40-
- AUTH_URL=https://next-drupal-starterkit.ddev.site:3000
43+
- AUTH_URL=https://frontend.ddev.site
4144
# Environment variables for redis
4245
- REDIS_HOST=redis
4346
- REDIS_PASS=redis
4447
# Environment variables for elasticsearch
4548
- ES_HOST=elasticsearch
49+
- SMTP_ADDRESS=localhost:1025
4650

4751
corepack_enable: false
48-
web_extra_exposed_ports:
49-
- name: "Next.js"
50-
container_port: 3000
51-
http_port: 2999
52-
https_port: 3000
5352

5453
hooks:
5554
post-start:
56-
- exec: "elasticsearch-plugin install analysis-icu"
57-
service: elasticsearch
5855
- exec: "cd next && npm i"
56+
- exec-host: |
57+
# Run the Elasticsearch plugin setup script
58+
ddev exec -s elasticsearch /mnt/ddev_config/elasticsearch/elasticsearch-setup.sh
59+
# Check for the restart marker file
60+
if [ -f .ddev/elasticsearch/restart_needed ]; then
61+
echo "Elasticsearch plugins installed. Restarting elasticsearch container..."
62+
docker restart ddev-${DDEV_SITENAME}-elasticsearch
63+
rm .ddev/elasticsearch/restart_needed
64+
fi
65+
66+
web_extra_exposed_ports:
67+
- name: node-app
68+
container_port: 3000
69+
http_port: 3000
70+
https_port: 3001

.ddev/docker-compose.elasticsearch.yaml

Lines changed: 0 additions & 28 deletions
This file was deleted.
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,29 @@
11
#ddev-generated
22
services:
33
elasticsearch:
4+
container_name: ddev-${DDEV_SITENAME}-elasticsearch
5+
hostname: ${DDEV_SITENAME}-elasticsearch
46
image: elasticsearch:8.10.2
7+
expose:
8+
- "9200"
9+
- "9300"
10+
environment:
11+
- ES_JAVA_OPTS=-Xms512m -Xmx512m
12+
- discovery.type=single-node
13+
- bootstrap.memory_lock=true
14+
- VIRTUAL_HOST=$DDEV_HOSTNAME
15+
- HTTP_EXPOSE=9200:9200
16+
- HTTPS_EXPOSE=9201:9200
17+
- ELASTICSEARCH_PLUGINS=analysis-icu
18+
labels:
19+
com.ddev.site-name: ${DDEV_SITENAME}
20+
com.ddev.approot: $DDEV_APPROOT
521
volumes:
22+
- elasticsearch:/usr/share/elasticsearch/data
23+
- ".:/mnt/ddev_config"
624
- ./elasticsearch/config/elasticsearch8.yml:/usr/share/elasticsearch/config/elasticsearch.yml
25+
healthcheck:
26+
test: ["CMD-SHELL", "curl --fail -s elasticsearch:9200"]
27+
28+
volumes:
29+
elasticsearch:

.ddev/elasticsearch/docker-compose.elasticsearch8.yaml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
#ddev-generated
21
services:
32
elasticsearch:
43
image: elasticsearch:8.10.2ss
@@ -11,5 +10,10 @@ services:
1110
# Disable authentication in local development
1211
xpack.security.enabled: "false"
1312
xpack.security.enrollment.enabled: "false"
13+
# Disable default watermark, which can cause issues in local development:
14+
cluster.routing.allocation.disk.watermark.low: "2gb"
15+
cluster.routing.allocation.disk.watermark.high: "1gb"
16+
cluster.routing.allocation.disk.watermark.flood_stage: "500mb"
17+
cluster.info.update.interval: "1m"
1418
volumes:
1519
- ./elasticsearch/config/elasticsearch8.yml:/usr/share/elasticsearch/config/elasticsearch.yml
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
#!/bin/bash
2+
3+
# Exit if no plugins specified
4+
[ -z "$ELASTICSEARCH_PLUGINS" ] && echo "No plugins specified in ELASTICSEARCH_PLUGINS" && exit 0
5+
6+
echo "Installing Elasticsearch plugins: $ELASTICSEARCH_PLUGINS"
7+
needs_restart=false
8+
9+
# Process each plugin
10+
for plugin in $ELASTICSEARCH_PLUGINS; do
11+
# Skip if already installed
12+
if bin/elasticsearch-plugin list | grep -q "$plugin"; then
13+
echo "✓ Plugin $plugin already installed"
14+
continue
15+
fi
16+
17+
# Install plugin
18+
echo "Installing $plugin plugin..."
19+
if bin/elasticsearch-plugin install "$plugin"; then
20+
chown -R elasticsearch:root "/usr/share/elasticsearch/plugins/$plugin" && \
21+
chmod -R 755 "/usr/share/elasticsearch/plugins/$plugin" && \
22+
echo "✓ Plugin $plugin installed successfully" && \
23+
needs_restart=true
24+
else
25+
echo "✗ Failed to install plugin $plugin"
26+
exit 1
27+
fi
28+
done
29+
30+
# Signal for restart if needed
31+
if [ "$needs_restart" = true ]; then
32+
echo "New plugins were installed. Elasticsearch needs to be restarted."
33+
34+
# Create a marker file in the mounted config directory (visible to host)
35+
touch /mnt/ddev_config/elasticsearch/restart_needed
36+
fi
37+
38+
exit 0

.ddev/traefik/config/frontend.yaml

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
http:
2+
routers:
3+
# Router for HTTP (port 80)
4+
next-drupal-starterkit-web-80-http-frontend:
5+
entrypoints:
6+
- http-80
7+
rule: Host(`frontend.ddev.site`)
8+
service: "next-drupal-starterkit-web-node-3000"
9+
ruleSyntax: v3
10+
tls: false
11+
priority: 100
12+
13+
# Router for HTTPS (port 443)
14+
next-drupal-starterkit-web-80-https-frontend:
15+
entrypoints:
16+
- http-443
17+
rule: Host(`frontend.ddev.site`)
18+
service: "next-drupal-starterkit-web-node-3000"
19+
ruleSyntax: v3
20+
tls: true
21+
priority: 100
22+
23+
services:
24+
# Here we define the service for the Next.js app, which
25+
# is running on port 3000 on the web container.
26+
next-drupal-starterkit-web-node-3000:
27+
loadbalancer:
28+
servers:
29+
- url: http://next-drupal-starterkit.ddev.site:3000

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -95,9 +95,9 @@ lando info
9595

9696
DDEV has a single container for both the backend and frontend, so the URLs differ only by the port:
9797

98-
| Backend | Frontend |
99-
| ---------------------------------------- | --------------------------------------------- |
100-
| https://next-drupal-starterkit.ddev.site | https://next-drupal-starterkit.ddev.site:3000 |
98+
| Backend | Frontend |
99+
| ---------------------------------------- |----------------------------|
100+
| https://next-drupal-starterkit.ddev.site | https://frontend.ddev.site |
101101

102102
> NOTE: localhost:3000 does not work in DDEV, you need to use the URL provided by DDEV above.
103103

setup-ddev.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ run_commands() {
7272
echo '↪️ Use this link to log into the backend as user 1:'
7373
ddev drush uli
7474
echo '🏎️ Starting the frontend site in production mode...'
75-
echo '⚠️️️️⚠️️️️⚠️️️️ Note: the site will be available at https://next-drupal-starterkit.ddev.site:3000, not localhost:3000 as the output of next start suggests.'
75+
echo '⚠️️️️⚠️️️️⚠️️️️ Note: the site will be available at https://frontend.ddev.site, not localhost:3000 as the output of next start suggests.'
7676
ddev npm run start
7777
}
7878

0 commit comments

Comments
 (0)