ddev / ddev-platformsh

Add integration with Platform.sh hosting service
Apache License 2.0
9 stars 10 forks source link

Set up redis service automatically #60

Closed aimfeld closed 1 year ago

aimfeld commented 1 year ago

While the DB container worked out of the box, the redis container was missing. I got it running quickly with ddev get drud/ddev-redis. The PLATFORM_RELATIONSHIPS variable was missing the configuration for the redis service defined in services.yaml, so I had to create a fallback. Would be great if this works out of the box.

.platform.app.yaml

relationships:
  database: "mysql:mysql"
  rediscache: "cacheredis:redis"

services.yaml

mysql:
  type: mysql:10.5
  disk: 4096
cacheredis:
  type: redis:6.2

redis config

$platformRelationships = json_decode(base64_decode(getenv('PLATFORM_RELATIONSHIPS')));

return [
    'redis'   => [
        'host' => $platformRelationships['rediscache'][0]['host'] ?? 'redis', // Fallback for DDEV
        'port' => $platformRelationships['rediscache'][0]['port'] ?? 6379, // Fallback for DDEV
    ],
]
rfay commented 1 year ago

Thanks @aimfeld - Would you be willing to put your .platform.app.yaml and .platform/services.yaml here (or in a gist on gist.github.com)? Perhaps edited.

aimfeld commented 1 year ago

Sure, there you go:

.platform.app.yaml

name: "surveylab"
type: php:8.1
build:
  flavor: composer
timezone: Europe/Zurich
runtime:
  extensions:
    - redis
relationships:
  database: "mysql:mysql"
  rediscache: "cacheredis:redis"
disk: 1024
mounts:
  "/data": "shared:files/data"
  "/temp": "shared:files/temp"
  "/filebeat": "shared:files/filebeat"
dependencies:
  php:
    composer/composer: '^2'
  nodejs:
    gulp: "4.0.2"
    yarn: "1.22.19"
variables:
  env:
    # Update these for your desired versions.
    NVM_VERSION: v0.39.1
    NODE_VERSION: v16.15.1
    FILEBEAT_VERSION: 7.15.2
hooks:
  build: |
    bin/build-hook
  deploy: |
    bin/deploy-hook
crons:
  events:
   ...
web:
  locations:
    "/":
      root: "public"
      passthru: "/index.php"
      headers:
        X-Frame-Options: SAMEORIGIN
      rules:
        ...

.platform/services.yaml

mysql:
  type: mysql:10.5
  disk: 4096
cacheredis:
  type: redis:6.2
rfay commented 1 year ago

Thanks so much. I imagine the failure was a result of