wunderio / ddev-drupal Goto Github PK
View Code? Open in Web Editor NEWWork in progress of template for DDEV Drupal projects
Work in progress of template for DDEV Drupal projects
We have this in all of our projects:
grumphp:
git_hook_variables:
EXEC_GRUMPHP_COMMAND: lando php
If we start using DDEV, it would always run Lando on git commit.
For now I've created this. More info here wunderio/drupal-project#393
grumphp:
git_hook_variables:
EXEC_GRUMPHP_COMMAND: "[ -d .ddev/traefik/ ] && GRUMPHP_COMMAND='ddev php' || GRUMPHP_COMMAND='lando php' && $GRUMPHP_COMMAND"
I think the ideal solution would be that this package replaces the line in grumph.yml
In Lando we set xdebug.start_with_request = yes
in php.ini. Do we need this in DDEV?
@ragnarkurmwunder said the https://github.com/wunderio/ddev-drupal/blob/main/dist/.ddev/wunderio/core/_run-scripts.sh script could be simplified to this (checking based on PATH var):
export PATH=./c:./b:./a
if command -v cmd 1>/dev/null; then
cmd
else
echo "no cmd"
fi
You probably have some differences in the db that you're importing. Why do the import and then manually run the config import?
This should be changed from:
cd $DDEV_COMPOSER_ROOT && drush cache:rebuild -y && drush @local user:login
to
cd $DDEV_COMPOSER_ROOT && drush deploy && drush @local user:login
Or I guess there should be some drush version check before doing that. If it's 11 or older, let's add cim somewhere near the cr
The original code for this was taken from https://github.com/wunderio/drupal-project/blob/main/.lando.yml#L154
There's currently these toolings:
ddev pmu
ddev syncdb
ddev grumphp
ddev phpunit
ddev regenerate-phpunit-config
ddev yq
Optionally when migrating from Lando you might have something like .lando/php.ini.
You might need to copy this to .ddev/php/php.ini as the default limits might be too low for your local env. For example upload size is 100MB in DDEV.
Add this info to readme.
In lando we had this:
varnishadm:
description: "Runs varnishadm commands"
service: varnish
user: root
There's also env variable
VARNISH_ADMIN_HOST: varnish
Example:
.ddev/docker-compose.sonarqube.yaml
# Host requirements:
# sysctl -w vm.max_map_count=524288
# sysctl -w fs.file-max=131072
# ulimit -n 131072
# ulimit -u 8192
services:
# Based on:
# https://www.docker.com/blog/how-to-use-the-postgres-docker-official-image/
# https://github.com/ICTU/sonar
postgres:
container_name: ddev-${DDEV_SITENAME}-postgres
image: postgres:15
restart: "always"
cpus: 0.5
mem_limit: 4096M
mem_reservation: 1024M
labels:
com.ddev.site-name: ${DDEV_SITENAME}
com.ddev.approot: $DDEV_APPROOT
# @todo How to create password for "postgres" user?
user: postgres
environment:
POSTGRES_DB: database
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
POSTGRES_HOST_AUTH_METHOD: scram-sha-256
POSTGRES_INITDB_ARGS: --auth-host=scram-sha-256
ports:
- 5432:5432
expose:
- "5432"
volumes:
- pgdata:/var/lib/postgresql/data
healthcheck:
test: ["CMD-SHELL", "pg_isready"]
interval : 1s
timeout: 5s
retries: 10
sonarqube:
container_name: ddev-${DDEV_SITENAME}-sonarqube
image: sonarqube:10.4-community
entrypoint: [ /opt/sonarqube/docker/entrypoint.sh ]
init: true
# working_dir: "/root"
# volumes:
# - sonarqube_data:/opt/sonarqube/data
# - sonarqube_extensions:/opt/sonarqube/extensions
# - sonarqube_logs:/opt/sonarqube/logs
# Not sure if best: https://community.sonarsource.com/t/sonarqube-sometimes-cant-connect-to-postgres-docker-setup/41628
restart: "unless-stopped"
cpus: 0.5
mem_limit: 4096M
mem_reservation: 1024M
labels:
com.ddev.site-name: ${DDEV_SITENAME}
com.ddev.approot: $DDEV_APPROOT
ports:
- 9000:9000
#- "0.0.0.0:9000:9000"
# expose:
# - "9000"
environment:
- SONAR_JDBC_URL=jdbc:postgresql://postgres:5432/database
- SONAR_JDBC_USERNAME=postgres
- SONAR_JDBC_PASSWORD=postgres
- HTTP_EXPOSE=80:9000
- VIRTUAL_HOST=sonar.${DDEV_HOSTNAME}
# @todo Binding to all ip's but doesn't seem to work.
#- SONAR_WEB_HOST=0.0.0.0
#- DOMAIN=${DDEV_HOSTNAME}
#- SONAR_HOST_URL=http://${DDEV_HOSTNAME}
depends_on:
- postgres
volumes:
pgdata:
name: pgdata
Tooling/command run run scan:
.ddev/commands/web/sonar-scanner.sh
#!/usr/bin/env bash
## Description: Run SonarQube scanner locally.
## Usage: sonar-scanner
## Example: "ddev sonar-scanner"
export SONAR_SCANNER_VERSION=5.0.1.3006
export SONAR_SCANNER_HOME=$HOME/.sonar/sonar-scanner-$SONAR_SCANNER_VERSION-linux
curl --create-dirs -sSLo $HOME/.sonar/sonar-scanner.zip https://binaries.sonarsource.com/Distribution/sonar-scanner-cli/sonar-scanner-cli-$SONAR_SCANNER_VERSION-linux.zip
unzip -o $HOME/.sonar/sonar-scanner.zip -d $HOME/.sonar/
export PATH=$SONAR_SCANNER_HOME/bin:$PATH
export SONAR_SCANNER_OPTS="-server"
export SONAR_TOKEN=sqp_5156f0dc5c5197b1f2e501d6ea573827b9b59856
sonar-scanner \
-Dsonar.projectKey=tua \
-Dsonar.sources=. \
-Dsonar.host.url=http://sonarqube:9000
Ragnar suggested to always quote variables. So here's one I should https://github.com/wunderio/ddev-drupal/pull/12/files#diff-858ae242bb89b1f7b21f07c96a99602c883ecb253d0a24a27af902e1d52ab807
cd $DDEV_COMPOSER_ROOT
=>
cd "$DDEV_COMPOSER_ROOT"
I was creating local setup for one my projects and reliser later that .ddev/.gitignore is not in code. This is needed as ddev adds lots of files that we don't need to commit.
Q:Also why isn't it added? Is it GIT feature? I didn't see .gitignore in my root .gitignore.
A: I think it might be just missing from setup instructions and I added other files?
git add .ddev/.gitignore -f
Always writing the titles from scratch for PR's eg (Description, Screenshots etc) is a bit tedious. Sometimes I might also make a typo or write it differently. Let's create PR template to always have the same base.
From the docs the best one seems creating it in .github folder - out of the way and we could probably add more GitHub related features there.
Based on one previous PR #18 this is the plan:
## Overview
## Screenshots
## Testing
This is my current new code:
#!/bin/bash
#
# Synchronise local database with the production environment.
#
# Based on https://github.com/wunderio/unisport/blob/master/.lando/syncdb.sh
#
set -eu
if [[ -n "${WUNDERIO_DEBUG:-}" ]]; then
set -x
fi
export PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin
source .ddev/wunderio/core/_helpers.sh
# Pass drush alias as argument and sync the database
# from the remote environment to the local environment.
sync_database_from() {
alias=$1
sql_file="$alias-syncdb-$(date +'%Y-%m-%d').sql"
alias_entry=$(ddev drush sa @$alias)
ssh_user=$(echo "$alias_entry" | ddev yq '.\"@self.'$alias'\".user' )
ssh_options=$(echo "$alias_entry" | ddev yq '.\"@self.'$alias'\".ssh.options' )
ssh_host=$(echo "$alias_entry" | ddev yq '.\"@self.'$alias'\".host' )
set -x
# For some reason "ddev drush sql-sync @your-alias @local -y" does not work and times out
# so we have to do this with sql-dump.
ssh "$ssh_user@$ssh_host" "$ssh_options" "drush sql-dump --structure-tables-list=cache,cache_*,history,search_*,sessions" > "$sql_file"
ddev import-db --file="$sql_file"
#rm "$sql_file"
{ set +x; } 2>/dev/null
display_status_message "Sync complete!"
}
sync_database_from $1
Sometimes when module install or uninstall breaks then Drupal can be in state that you can't uninstall module because table doesn't exist while it's trying to delete it. It doesn't happen that often but then it does, then you have to shell into db, create dummy table, then proceed with module uninstallation. Let's add command in ddev to create dummy table?
I've seen at least one error after snapshot restor and clear cache helped.
Also snapshots are probably a little-bit behind the codebase so let's run the same post db import script as we do after db import.
it would be nice if this package would ask for automatic update if there's one.
What kind of folder/file structure to have?
Let's create config.wunderio.yaml. This will come later than config.yaml - should we overwrite everything there or not? I guess not otherwise configuration that ddev adds to config.yaml would not work. In other words if developer has created project with drupal10 recipe, then let's allow ddev to configure these in config.yaml.
What's needed to get project started with this package?
Todo:
Add automatic composer install with something like this:
hooks:
post-start:
- exec: "[ ! -d \"/var/www/html/vendor\" ] && /var/www/html/.ddev/custom/appserver-build.sh || true"
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.