lando
lando copied to clipboard
Multiple lamp instances with one Lando file
I have a Git repository that contains multiple sites that share files in the root of the repository.
I need to create a single .lando.yml file in the root of the project and create lamp instances in the various subfolders.
Ex.
/common (this folder must be visible to all sites to read certain shared files) /site1 >> site1.lndo.site /site2 >>> site2.lndo.site
How to achieve that?
Thanks !
Would multiple .lando.yml files work for you? If so, you could mount the /common folder using service overrides. Docs: https://docs.lando.dev/config/services.html#advanced
For example:
services:
appserver:
overrides:
volumes:
- ./common:/common
Otherwhise, if both sites are similar you can just add another php service and setup the proxy. You'll need to add something like:
proxy:
appserver2:
- site2.lndo.site
services:
appserver2:
type: php
via: apache
Choose whatever looks the most like your production environment.
Wonderful, I couldn't find any documentation on this! Thanks for the help!
Now I would like to be able to reduce the repetitiveness of the configurations. There are 7 sites and I need to replicate the same configurations between all of them.
What do you think?
name: acme
recipe: lamp
config:
webroot: ./site1/public
php: '7.2'
database: mariadb:10.5.8
env_file:
- .env
proxy:
site2:
- acme-site2.lndo.site
site3:
- acme-site3.lndo.site
site4:
- acme-site4.lndo.site
site5:
- acme-site5.lndo.site
site6:
- acme-site6.lndo.site
site7:
- acme-site7.lndo.site
services:
appserver:
build_as_root:
- apt update -y
- apt install software-properties-common -y
- cd ~ && git clone --branch 3.4.x https://github.com/phalcon/cphalcon && cd ./cphalcon/build && ./install
- docker-php-ext-enable phalcon
- service apache2 reload
site2:
type: php:7.2
via: apache
ssl: true
sslExpose: true
webroot: ./site2/public
build_as_root:
- apt update -y
- apt install software-properties-common -y
- cd ~ && git clone --branch 3.4.x https://github.com/phalcon/cphalcon && cd ./cphalcon/build && ./install
- docker-php-ext-enable phalcon
- service apache2 reload
site3:
type: php:7.2
via: apache
ssl: true
sslExpose: true
webroot: ./site3/public
build_as_root:
- apt update -y
- apt install software-properties-common -y
- cd ~ && git clone --branch 3.4.x https://github.com/phalcon/cphalcon && cd ./cphalcon/build && ./install
- docker-php-ext-enable phalcon
- service apache2 reload
site4:
type: php:7.2
via: apache
ssl: true
sslExpose: true
webroot: ./site4/public
site5:
type: php:7.2
via: apache
ssl: true
sslExpose: true
webroot: ./gestione-interna/public
build_as_root:
- apt update -y
- apt install software-properties-common -y
- cd ~ && git clone --branch 3.4.x https://github.com/phalcon/cphalcon && cd ./cphalcon/build && ./install
- docker-php-ext-enable phalcon
- service apache2 reload
site6:
type: php:7.2
via: apache
ssl: true
sslExpose: true
webroot: ./pagamenti-esterni/public
build_as_root:
- apt update -y
- apt install software-properties-common -y
- cd ~ && git clone --branch 3.4.x https://github.com/phalcon/cphalcon && cd ./cphalcon/build && ./install
- docker-php-ext-enable phalcon
- service apache2 reload
site7:
type: php:7.2
via: apache
ssl: true
sslExpose: true
webroot: ./site7/public
build_as_root:
- apt update -y
- apt install software-properties-common -y
- cd ~ && git clone --branch 3.4.x https://github.com/phalcon/cphalcon && cd ./cphalcon/build && ./install
- docker-php-ext-enable phalcon
- service apache2 reload
It's only one container.
All this,
build_as_root:
- apt update -y
- apt install software-properties-common -y
- cd ~ && git clone --branch 3.4.x https://github.com/phalcon/cphalcon && cd ./cphalcon/build && ./install
- docker-php-ext-enable phalcon
- service apache2 reload
overrides:
volumes:
- ./_common:/home/_common
- ./_files:/home/_files
- ./_sync:/home/_sync
just needs to be done once since it affects the container. You're just running the same over and over on top of what's already there.
Hi @rubenvarela
The build_as_root if I don't replicate it for each container doesn't install phalcon.
How would you optimize the file by reusing this piece?
Someone can help me?
I have created a docker image based on the original Lando, where I perform the download and build part of the Phalcon 3.4 extension for PHP.
At that point from my .lando.yml file I went to use this new image. By doing so I drastically reduced the startup time of the lando instances.
To who interested the solution I leave the file:
name: acme
recipe: lamp
config:
webroot: ./b2c
php: '7.2'
database: mariadb:10.5.8
env_file:
- .env
proxy:
site2:
- acme-site2.lndo.site
site3:
- acme-site3.lndo.site
site4:
- acme-site4.lndo.site
site5:
- acme-site5.lndo.site
site6:
- acme-site6.lndo.site
site7:
- acme-site7.lndo.site
services:
appserver:
overrides:
acme: esperoweb/php:7.2-phalcon-3.4-apache-2
site2:
type: php:7.2
via: apache
ssl: true
sslExpose: true
webroot: ./site2
overrides:
acme: esperoweb/php:7.2-phalcon-3.4-apache-2
site3:
type: php:7.2
via: apache
ssl: true
sslExpose: true
webroot: ./site3
overrides:
acme: esperoweb/php:7.2-phalcon-3.4-apache-2
site4:
type: php:7.2
via: apache
ssl: true
sslExpose: true
webroot: ./site4
overrides:
acme: esperoweb/php:7.2-phalcon-3.4-apache-2
site5:
type: php:7.2
via: apache
ssl: true
sslExpose: true
webroot: ./site5-interna
overrides:
acme: esperoweb/php:7.2-phalcon-3.4-apache-2
site6:
type: php:7.2
via: apache
ssl: true
sslExpose: true
webroot: ./site6-esterni
overrides:
acme: esperoweb/php:7.2-phalcon-3.4-apache-2
site7:
type: php:7.2
via: apache
ssl: true
sslExpose: true
webroot: ./site7
overrides:
acme: esperoweb/php:7.2-phalcon-3.4-apache-2
So the esperoweb/php:7.2-phalcon-3.4-apache-2
image's Dockerfile it contains this directives:
FROM devwithlando/php:7.2-apache-2
RUN apt update -y
RUN apt install software-properties-common -y
RUN git clone --branch 3.4.x https://github.com/phalcon/cphalcon && cd ./cphalcon/build && ./install
RUN docker-php-ext-enable phalcon
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions and please check out this if you are wondering why we auto close issues.
We haven't heard anything here for about a year so we are automatically closing this issue to keep things tidy. If this is in error then please post in this thread and request the issue be reopened!