nystudio107 / craft-vite

Allows the use of the Vite.js next generation frontend tooling with Craft CMS
MIT License
52 stars 16 forks source link

Suggestion: Use "expose" instead of "ports" for DDEV #38

Closed mandrasch closed 2 years ago

mandrasch commented 2 years ago

Hey,

I found your example configuration for DDEV in https://nystudio107.com/docs/vite/#using-ddev while research for DDEV + vite.

Just wanted to let you know that I had a quick discussion with Randy Fay about the docker-compose file:

He suggested using expose instead of ports:

You just want expose, not ports if you're going to put it on port 3000, because with your current setup ddev-router is also going to try to use port 3000 Originally posted by rfay in https://github.com/torenware/ddev-viteserve/issues/2#issuecomment-1184472413

(Official docs on this: https://ddev.readthedocs.io/en/stable/users/extend/custom-compose-files/#docker-composeyaml-examples, ports uses host computer, expose uses DDEV router instead)

Disclaimer: I'm not a craft dev myself, just strongly interested in vite + DDEV (https://github.com/mandrasch/ddev-addon-simple-vite).

Much success with your project and best regards, Matthias

khalwat commented 2 years ago

@johndwells thoughts?

johndwells commented 2 years ago

@khalwat @mandrasch Interesting. The premise seems right, I'd just like to test this with real values to verify the approach.

johndwells commented 2 years ago

Based on the comment @mandrasch linked in his original, this indeed seems to work just fine:

# ./ddev/docker-compose.vite.yaml
version: '3.6'
services:
  web:
    expose:
      - '3000'
    environment:
      - HTTP_EXPOSE=${DDEV_ROUTER_HTTP_PORT}:80,${DDEV_MAILHOG_PORT}:8025,3001:3000
      - HTTPS_EXPOSE=${DDEV_ROUTER_HTTPS_PORT}:80,${DDEV_MAILHOG_HTTPS_PORT}:8025,3000:3000
khalwat commented 2 years ago

Did you want to PR that change to the docs @johndwells ?

khalwat commented 2 years ago

I updated the docs to reflect this change