Tim Schreiner
Tim Schreiner

Reputation: 563

How to use a separate node container in your ddev setup?

Sometimes you want to use a custom node version in your ddev setup. I will give an example configuration how this can be archived.

Upvotes: 3

Views: 1673

Answers (1)

Tim Schreiner
Tim Schreiner

Reputation: 563

Create a file in .ddev folder named docker-compose.node.yaml with the following content:

version: '3.6' 
services:
  node:
    container_name: ddev-${DDEV_SITENAME}-node
    image: node:10.6
    user: "node"
    restart: "no"
    labels:
      com.ddev.site-name: ${DDEV_SITENAME}
      com.ddev.platform: ddev
      com.ddev.app-type: php
      com.ddev.approot: $DDEV_APPROOT
    volumes:
      - "../:/var/www/html:cached"
    working_dir: /var/www/html
    command: ["tail", "-f", "/dev/null"]

Ddev will start a separate node container that is not terminated after startup. You can ssh into that container using the command ddev ssh -s node

You can also configure post-start hook like this:

hooks:
  post-start:
    - exec-host: ddev exec -s node npm ci --quiet
    - exec-host: ddev exec -s node npm start

Upvotes: 3

Related Questions