lando / mailhog

The Official MailHog Lando Plugin
https://docs.lando.dev/mailhog/
GNU General Public License v3.0
1 stars 1 forks source link

cURL not universally available #35

Open pirog opened 2 months ago

pirog commented 2 months ago

Currently, the build step we use to download the mhsendmail binary into each hogfrom service assumes that curl exists within said service.

This worked great until recently when bitnami removed curl from newer versions of nginx. You can see this failure demonstrated in https://github.com/lando/mailhog/pull/36. To provide a more robust service and to prep for Lando 4 we should make getting mhsendmail a bit more sophisticated.

So, the fix should be something like this:

1. Convert needed build steps into a shell script that lives in the scripts folder.

The script should test for the existence of curl and install it if needed, i think its probably OK to assume apt/debian flavored images but adding apk support for alpine images wouldnt be horrible.

Then the script should download the arch specific binary, move it into PATH and make it executable.

2. Invoke the script as a build step

Everything put into the scripts folder in a plugin ends up in the /helpers folder in each container so we should switch the build step to just run that script. It's possible we need to pass in an option/arg to handle the different architectures. I'm a bit confused on how that works tbh.

3. The tests should pass

We should also add the code from https://github.com/lando/mailhog/pull/36 and make sure those tests pass.

matthewgarrettks commented 2 months ago

I can take this one unless someone else wants it.

matthewgarrettks commented 2 months ago

@pirog @reynoldsalec - Do you know of any docs on how to do #2 above? I get that I can create a scripts folder and do a bash script in there, and that it maps to the helpers folder in the build process (weird), but looking through the other plugins that do this, they all rely on a services object being defined earlier in the builder, which this builder.js doesn't have. I can't seem to make it call the shell script. EG, right now I'm trying to do:

      options.services.mailhog.push('/helpers/mailhog.sh');

but it throws "ERROR ==> Cannot read properties of undefined (reading 'services')". How do I make it call the helpers /mailhog.sh script?

reynoldsalec commented 2 months ago

@matthewgarrettks here's an example in the Pantheon builder of adding the scripts as build steps: https://github.com/lando/pantheon/blob/main/builders/pantheon.js#L42

After options is declared in mailhog.js, I think you should be able to use the same logic.

LMK if you have more questions!

matthewgarrettks commented 1 month ago

Sorry gang, I'm buried in other work, unassigning myself from this in hopes someone else will pick it up.