waschinski / photo-stream

Self-hosted, super simple photo stream
https://github.com/waschinski/photo-stream
MIT License
449 stars 70 forks source link

Added VAGRANT_DISABLE_RESOLV_REPLACE=1 to allow building on macOS #12

Closed PatrickTCB closed 1 year ago

PatrickTCB commented 2 years ago

When building on macOS you can't use the normal libc DNS resolver, and this means that building this container on macOS fails at the point where gems need to be installed.

I therefore added the VAGRANT_DISABLE_RESOLV_REPLACE=1 flag so that Ruby Resolv is used during build instead.

PatrickTCB commented 2 years ago

Here's the documentation I read that lead me to this root cause/fix: https://www.vagrantup.com/docs/other/environmental-variables

waschinski commented 2 years ago

First off, thanks for your PR.

Just to get this right, this is an issue you encountered specifically on macOS when using Vagrant, right? Because I was successfully building images using Docker on macOS before.

As far as I got it, VAGRANT_DISABLE_RESOLV_REPLACE=1 would just tell Vagrant to not optionally use the Ruby Resolv library in place of the libc resolver. So it is the other way round and doesn't seem to be the root cause of your issue.

Also, what are the implications of this change when building the container using Vagrant on another OS?

PatrickTCB commented 2 years ago

The issue that I get is during [7/7] RUN ruby -v && gem install bundler jekyll && bundle config --local build.sassc --disable-march-tune-native && bundle install. The error is SocketError: Failed to open TCP connection to rubygems.org:443.

I found this bug report where the suggested the ENV VAGRANT_DISABLE_RESOLV_REPLACE=1 fix, then I went to check out the documentation I mentioned and it all seemed to make sense.

So I made the change, and then I could build the container just fine. I was going to open an issue for it, but since I already found the fix I decided to just open a PR instead.

In terms of the impact on building for other systems, I don't have the ability to verify the build process on anything other than macOS, but there's no indication in the documentation that this should cause any issues.

waschinski commented 2 years ago

I am actually reluctant forcing this setting on every user when it only affects Vagrant users on macOS. As you pointed out, the change is probably not causing problems for anyone, still it changes the default behaviour and neither you nor me can tell if it will be problematic for anyone else.

So how about adding a Vagrantfile to the project as an alternative solution? I think there is an option to check for the OS being used (like def OS.macos?) which could be used to set the ENV for macOS only.

PatrickTCB commented 2 years ago

That's probably a good option, but I'm afraid I don't know how to build such a file. Another option could be I just add the Dockerfile as Dockerfile.macos or put something in the README.md.

Because it was an issue for me, and I solved it, I'd like somehow to make the information available in the project for the next person who runs into it but I'm not picky about how it's included.

waschinski commented 2 years ago

I think adding a Dockerfile.vagrant.macos file sounds like a good solution until someone is able to provide a proper Vagrantfile. If you could adjust your PR accordingly I am going to merge it.