Skip to content

Commit

Permalink
fix bug clobbering default recipe proxy urls when user specifies thei…
Browse files Browse the repository at this point in the history
…r own
  • Loading branch information
pirog committed Sep 6, 2024
1 parent e05a0a5 commit c02d533
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 5 deletions.
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
## {{ UNRELEASED_VERSION }} - [{{ UNRELEASED_DATE }}]({{ UNRELEASED_LINK }})

## Bug Fixes

* Fixed bug causing default `proxy` settings to be clobbered by user specified ones

## Internal

* Updated DevOps to use new `lando exec`
* Updated `ubuntu` test runners to `24.04`

## v1.6.0 - [May 31, 2024](https://github.com/lando/symfony/releases/tag/v1.6.0)

* Use mysql command for MariaDB 10.3.x and below [#52](https://github.com/lando/symfony/issues/52)
Expand Down
24 changes: 19 additions & 5 deletions builders/symfony.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,18 @@ const getServices = options => ({
},
});

/*
* Helper to get proxy config
*/
const getProxy = (options, proxyService = 'appserver') => {
// get any intial proxy stuff for proxyService
const urls = _.get(options, `_app.config.proxy.${proxyService}`, []);
// add
urls.push(`${options.app}.${options._app._config.domain}`);
// return
return {[proxyService]: _.uniq(_.compact(urls))};
};

/*
* Helper to get service config
*/
Expand Down Expand Up @@ -262,18 +274,20 @@ module.exports = {
service: 'appserver',
cmd: `php /app/${options.webroot}/../bin/console`,
};

if (_.has(options, 'cache')) options.services.cache = getCache(options.cache);

// Rebase on top of any default config we might already have
options.defaultFiles = _.merge({}, getConfigDefaults(_.cloneDeep(options)), options.defaultFiles);
options.services = _.merge({}, getServices(options), options.services);
options.tooling = _.merge({}, getTooling(options), options.tooling);
// Switch the proxy if needed
if (!_.has(options, 'proxyService')) {
if (_.startsWith(options.via, 'nginx')) options.proxyService = 'appserver_nginx';
else if (_.startsWith(options.via, 'apache')) options.proxyService = 'appserver';
}
options.proxy = _.set(options.proxy, options.proxyService, [`${options.app}.${options._app._config.domain}`]);

// Rebase on top of any default config we might already have
options.defaultFiles = _.merge({}, getConfigDefaults(_.cloneDeep(options)), options.defaultFiles);
options.proxy = _.merge({}, getProxy(options, options.proxyService), options.proxy);
options.services = _.merge({}, getServices(options), options.services);
options.tooling = _.merge({}, getTooling(options), options.tooling);

// Send downstream
super(id, options);
Expand Down
3 changes: 3 additions & 0 deletions examples/symfony-custom/.lando.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
name: symfony-custom
proxy:
appserver_nginx:
- another.symfony-custom.lndo.site
recipe: symfony
config:
php: '8.3'
Expand Down
4 changes: 4 additions & 0 deletions examples/symfony-custom/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,10 @@ lando mysql symfony -e quit
# Should have xdebug enabled
lando php -m | grep Xdebug

# Should have proxy urls present in lando info
lando info | grep "http://symfony-custom.lndo.site"
lando info | grep "http://another.symfony-custom.lndo.site"

# Should be using custom config files
lando exec appserver -- curl -L appserver_nginx/info.php | grep memory_limit | grep 513M
lando exec appserver_nginx -- cat /opt/bitnami/nginx/conf/vhosts/lando.conf | grep server_name | grep pirog
Expand Down

0 comments on commit c02d533

Please sign in to comment.