Skip to content
Merged
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
16 changes: 11 additions & 5 deletions .ddev/commands/host/setup-drupal
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
#!/bin/bash
#!/usr/bin/env bash

## Description: Set up project for headless Drupal
## Usage: setup-drupal
## Example: "ddev setup-drupal"

if [ -d "/${DDEV_APPROOT}/frontend" ]; then
cd "/${DDEV_APPROOT}/frontend" || exit ;
fi

if [ -e ./codegen.ts ] || [ -d ./app/api ]; then
echo "Drupal setup can only be run once."
echo "If you need the starter files, copy them from the /starterkits directory."
Expand All @@ -22,8 +26,10 @@ rm -rf ./types
cp -r ./starterkits/drupal/types ./

# Block until file changes are in the web container...
ddev mutagen sync || true
if [ ${DDEV_MUTAGEN_ENABLED} ]; then
ddev mutagen sync || true
fi

ddev exec npm install --package-lock-only
ddev exec npm ci
ddev exec pm2 restart all
ddev exec -s=frontend "npm install --package-lock-only" || ddev exec "npm install --package-lock-only"
ddev exec -s=frontend "npm ci" || ddev exec "npm ci"
ddev exec -s=frontend "pm2 restart all" || ddev exec "pm2 restart all"
16 changes: 11 additions & 5 deletions .ddev/commands/host/setup-wp
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
#!/bin/bash
#!/usr/bin/env bash

## Description: Set up project for headless WordPress
## Usage: setup-wp
## Example: "ddev setup-wp"

if [ -d "/${DDEV_APPROOT}/frontend" ]; then
cd "/${DDEV_APPROOT}/frontend" || exit ;
fi

if [ -e ./codegen.ts ] || [ -d ./app/api ]; then
echo "WordPress setup can only be run once."
echo "If you need the starter files, copy them from the /starterkits directory."
Expand All @@ -28,8 +32,10 @@ cp -r ./starterkits/wp/next.config.mjs ./
cp -r ./starterkits/wp/possibleTypes.json ./

# Block until file changes are in the web container...
ddev mutagen sync || true
if [ ${DDEV_MUTAGEN_ENABLED} ]; then
ddev mutagen sync || true
fi

ddev exec npm install --package-lock-only
ddev exec npm ci
ddev exec pm2 restart all
ddev exec -s=frontend "npm install --package-lock-only" || ddev exec "npm install --package-lock-only"
ddev exec -s=frontend "npm ci" || ddev exec "npm ci"
ddev exec -s=frontend "pm2 restart all" || ddev exec "pm2 restart all"
11 changes: 11 additions & 0 deletions .ddev/config.hooks.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
hooks:
post-start:
# Detects to see if the node_modules folder exists
- exec: 'sh -c "[ ! -d node_modules ] && npm ci || return"'
service: web
# pm2 does not live in the node path, so have to call binary directly
- exec: pm2 start --name next node_modules/.bin/next -- dev
service: web
# pm2 does not live in the node path, so have to call binary directly
- exec: pm2 start --name storybook node_modules/.bin/storybook -- dev --no-open -p 6006
service: web
13 changes: 1 addition & 12 deletions .ddev/config.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name: nextjs-project
type: php
docroot: public
php_version: "8.0"
php_version: "8.3"
webserver_type: nginx-fpm
router_http_port: "80"
router_https_port: "443"
Expand All @@ -15,17 +15,6 @@ use_dns_when_possible: true
composer_version: "2"
web_environment: []
nodejs_version: "20"
hooks:
post-start:
# Detects to see if the node_modules folder exists
- exec: 'sh -c "[ ! -d node_modules ] && npm ci || echo 0"'
service: web
# pm2 does not live in the node path, so have to call binary directly
- exec: pm2 start --name frontend node_modules/.bin/next -- dev
service: web
# pm2 does not live in the node path, so have to call binary directly
- exec: pm2 start --name storybook node_modules/.bin/storybook -- dev --no-open -p 6006
service: web

# Key features of ddev's config.yaml:

Expand Down
6 changes: 3 additions & 3 deletions README.project.md
Original file line number Diff line number Diff line change
Expand Up @@ -87,14 +87,14 @@ ddev nextjs icons
## Helpful commands

### Monitoring the applications
If you want to monitor the status of `app` or `storybook`. Please use `ddev frontend monit`
If you want to monitor the status of `next` or `storybook`. Please use `ddev frontend monit`

### Restarting a specific service
If you want to restart `storybook` or `app`, please use the following:
If you want to restart `storybook` or `next`, please use the following:

`app`
```bash
ddev frontend restart frontend
ddev frontend restart next
```
`storybook`
```bash
Expand Down
2 changes: 1 addition & 1 deletion starterkits/drupal/.env.drupal
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
NEXT_PUBLIC_DRUPAL_BASE_URL=http://web/drupal
NEXT_PUBLIC_DRUPAL_BASE_URL=http://web
NEXT_IMAGE_DOMAIN=web

# Authentication
Expand Down
22 changes: 22 additions & 0 deletions starterkits/drupal/docker-compose.frontend.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
services:
frontend:
container_name: ddev-${DDEV_SITENAME}-frontend
build:
context: frontend
command: "sleep infinity"
expose:
- 3000
- 6006
volumes:
- ./../frontend:/var/www/html/frontend:cached
- ".:/mnt/ddev_config"
- ddev-global-cache:/mnt/ddev-global-cache
working_dir: /var/www/html/frontend
labels:
com.ddev.site-name: ${DDEV_SITENAME}
com.ddev.approot: $DDEV_APPROOT
environment:
- VIRTUAL_HOST=$DDEV_HOSTNAME
- HTTP_EXPOSE=3001:3000,8025:8025,6007:6006
- HTTPS_EXPOSE=3000:3000,8026:8025,6006:6006
networks: [default, ddev_default]