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

巧了我就是萌 提交于 2021-02-10 06:19:12

问题


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


回答1:


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

version: '3.6' 
# recent ddev requires docker-compose file 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


来源:https://stackoverflow.com/questions/51731242/how-to-use-a-separate-node-container-in-your-ddev-setup

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!