Roots Discourse

Dockerize Local Bedrock & Sage Development with Lando

Now that a stable version of Lando 3.x has been released, I have reopened this topic.

1 Like

To others following along with this tutorial in 2020 (thank you Roots!), if you are getting the error:

“Proxying to an unknown service”

This relates to a change moving to 3.0.0-rc.2+. See: https://docs.lando.dev/guides/updating-to-rc2.html#new-images . Lando has been updated heavily since this tutorial was written…

Or more specifically, see:


Long story short, under the ‘proxy:’ settings in the .lando.yml, it should be changed from:

proxy:
    nginx:
       - bedrock.test

to:

proxy:
    appserver_nginx:
       - bedrock.test

(That is, if you are still following this tutorial. Your specific configuration may differ.)

@coltoneakins have you been able to get the browersync server working for you? Using the Landofile from the tutorial and a bunch of different attempts of my own from reading the Lando docs I haven’t been able to get it to work. There’s always some variation of This site can't be reached at localhost:3000.

@max_tyrrell
Last night, I did not get to fully setting up the local dev enviroment w/ Lando yet (was working on other stuff). But, I have pretty heavy experience with Node.js and Docker Compose so I am sure I will figure it out. I plan to sit down with this more in the coming days.

I will make an extensive post of what I did (if I find out), and I will be sure to update this thread here too.

1 Like

Awesome! That’d be amazing! :slight_smile:

This is what I’m using for webpack-dev-server and a non-standard Sage setup. It can probably be adopted to work with BrowserSync if someone wants to give it a shot. In short, replace 8080 with 3000 and then make sure browser-sync binds to 0.0.0.0 instead of default localhost. Also, this means that browser-sync (or dev-server, for me) will always be running. I’m fine with this, but others might prefer to have more control over when it starts and stops.

name: my-roots-site
recipe: wordpress
config:
  cache: redis
  webroot: web
  via: nginx
  database: mariadb
  xdebug: true
  config:
    # vhosts: ../lando/default.conf
    # php: ../lando/php.ini
proxy:
  theme:
    - dev-server.lndo.site:8080
services:
  appserver:
    build:
      - composer global require hirak/prestissimo
      - composer install --no-interaction --no-progress --no-scripts
      - wp package install aaemnnosttv/wp-cli-login-command
      - composer install --working-dir=/app/web/app/themes/my-roots-site --no-interaction --no-progress --no-scripts
    run:
      - wp core is-installed || wp @production db export - | wp db import -
      - >-
        wp plugin is-installed --skip-packages --skip-plugins --skip-themes wp-cli-login-server ||
        wp login install --activate --yes --skip-plugins --skip-themes
      - wp acorn optimize:clear
  cache:
    type: redis
  theme:
    type: node:12
    port: 8080
    ssl: true
    build:
      - yarn --cwd /app/web/app/themes/my-roots-site install --non-interactive --silent --frozen-lockfile
    command: yarn --cwd /app/web/app/themes/my-roots-site start --public https://dev-server.lndo.site --key /lando/certs/lndo.site.key --cert /lando/certs/lndo.site.crt --cacert /lando/certs/lndo.site.pem --non-interactive
    overrides:
      environment:
        DEV_SERVER_HOST: '0.0.0.0'
        DEV_SERVER_PORT: 8080
tooling:
  redis-cli:
    service: cache
  yarn:
    service: theme
    cmd: timeout --preserve-status -k 360 300 /usr/local/bin/yarn --cwd /app/web/app/themes/my-roots-site
  nuke:
    service: appserver
    cmd:
      - rm -rf /app/vendor
      - rm -rf /app/web/wp
      - rm -rf /app/web/app/themes/my-roots-site/node_modules
      - rm -rf /app/web/app/themes/my-roots-site/vendor
      - rm -rf /app/web/app/themes/my-roots-site/dist
events:
  pre-stop:
    - >-
      test -d /app/web/wp &&
      test -d /app/vendor &&
      wp core is-installed --skip-packages --skip-plugins --skip-themes &&
      wp db export
  post-start:
    - appserver: which php && php --version
    - appserver: which wp && wp cli version
    - appserver: which composer && composer --version
    - theme: which node && node --version
    - theme: which npm && npm --version
    - theme: which yarn && yarn --version
5 Likes

Wow absolute life safer. I ran into this just now!

1 Like

My config return only Bad Gateway, I can’t get work with bedrock :confused:

name: name
recipe: wordpress
proxy:
  theme:
    - localhost:3000
config:
  php: '7.2'
  via: nginx
  webroot: web
  database: mariadb
  xdebug: true
services:
  pma:
    type: phpmyadmin
    hosts:
      - database
  theme:
    type: node:10
    services:
      ports:
        - 3000:3000
tooling:
  yarn:
    service: theme

my config return bad gateway when run yarn start from container ;(

I am found a solution!

replace

services:
      ports:
        - 3000:3000

to

overrides:
      ports:
        - 3000:3000

Hey Max, I did sit down with this more. However, for what it is worth Browsersync practically worked outside of the box for me–my configuration differs only a little from the tutorial. For this reason, I think you might be running into an issue with your configuration–not like a problem with Lando or Bedrock/Sage.

Could you create maybe a minimal repository on GitHub of your project and post it here? I would be happy to troubleshoot with you.

Same problem here :confused: