-
-
Notifications
You must be signed in to change notification settings - Fork 3.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
WIP: Docker-ng (alpine) #1919
WIP: Docker-ng (alpine) #1919
Conversation
* Builds from alpine image supporting therubyracer (usualoma/ruby-with-therubyracer:2.4.0-alpine) * Ruby 2.4 * Currently setup to be tested against mysql:8.0 * Seems to have issues with utf8m4 * May not have the full binary dependencies installed for all gems at runtime * Unicorn not currently linked to a reverse-proxy * Currently includes git as a runtime dependency, unsure if needed (it’s heavy.. ~16mb) * Builds to an image ~366 MB (by docker images) * usualoma/ruby-with-therubyracer:2.4.0-alpine is ~115mb of that * See ./compose-huginn-ng-mysql.sh * ./compose-huginn-ng-mysql.sh build huginn * ./compose-huginn-ng-mysql.sh run —user=“root” huginn sh
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Very cool @alias1! I did not expect the image to be that much smaller.
Sadly the build failed for me:
tep 11/16 : RUN set -ex && bundle update rails
---> Running in acea035a250e
+ bundle update rails
The dependency tzinfo-data (>= 0) will be unused by any of the platforms Bundler is installing for. Bundler is installing for ruby but the dependency is only for x86-mingw32, x86-mswin32, x64-mingw32. To add those platforms to the bundle, run `bundle lock --add-platform mingw, mswin, x64_mingw`.
Fetching gem metadata from https://rubygems.org/......
Fetching version metadata from https://rubygems.org/..
Fetching dependency metadata from https://rubygems.org/.
You have requested:
json ~> 1.8.5
The bundle currently has json locked at 1.8.3.
Try running `bundle update json`
If you are updating multiple gems in your Gemfile at once,
try passing them all to `bundle update`
The command '/bin/sh -c set -ex && bundle update rails' returned a non-zero code: 7
Gemfile
Outdated
@@ -117,7 +126,7 @@ gem 'mini_magick' | |||
gem 'multi_xml' | |||
gem 'nokogiri' | |||
gem 'omniauth', '~> 1.3.1' | |||
gem 'rails', '~> 5.0.1' | |||
gem 'rails', '~> 5.0.2' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should update and test the rails upgrade in a separate PR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Absolutely agree. Not sure this will end up being the final PR as is, might refactor the commit history or something in the end. I tend to test things as I go and commit in small chunks. Bumped this one (i think) due to a requirement in one of the other gems I bumped.
Gemfile
Outdated
@@ -192,14 +201,22 @@ ENV['DATABASE_ADAPTER'] ||= | |||
'mysql2' | |||
end | |||
|
|||
if_true(ENV['DATABASE_ADAPTER'].strip == 'postgresql') do | |||
gem 'pg', '~> 0.18.3' | |||
if_true(ENV['DATABASE_ADAPTER'].strip == 'postgresql' || !!ENV['INSTALL_ALL_DBS']) do |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's a good idea! I bet the additional space needed in the image is not much compared to the improved startup time? Maybe rename it to INSTALL_ALL_DATABASE_ADAPTERS
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I haven't checked to any great level of detail, but I think it was pretty minimal, maybe a few mb? The main difference comes from needing all of the dev libraries for each DB to compile them, but initial testing seems to imply that we can remove them again once they're compiled, so long as we have the runtime libs installed (much smaller)
Yeah, can definitely change it to INSTALL_ALL_DATABASE_ADAPTERS
.
docker/Dockerfile.ng
Outdated
@@ -0,0 +1,213 @@ | |||
FROM usualoma/ruby-with-therubyracer:2.4.0-alpine |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you remake this image based on ruby 2.3
? I think it would make this PR a bit lighter and separate it from the ruby upgrade in #1876. I would also like to see how much work is required to switch ruby versions in alpine as we will need to move to ruby 2.4.x
and 2.x
eventually.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Currently, no. The only image that exists is built on 2.4
That said, can definitely investigate whether the same technique would work on a 2.3.x build, and if so, we can definitely try it. Would be awesome to isolate the changes/differences required, and give us a far better platform for compatibility checking.
Have opened an issue (usualoma/ruby-with-therubyracer#2) to investigate this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Awesome, sounds great!
docker/Dockerfile.ng
Outdated
# libmysqlclient-dev libpq-dev libsqlite3-dev \ | ||
# ruby2.3 ruby2.3-dev | ||
|
||
# TODO: Put together a little script that will easily parse out all the .env.example lines to copy into here |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like the idea of dropping the .env
file in the docker image. We need to decide how we handle backwards compatibility, the current solution with .env` sometimes requires double escaped strings which will probably not work without converting the values here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe we can put together a little script to 'update' a double escaped .env file? Or maybe just an 'upgrading' type 'breaking changes' document could explain this process.
docker-compose has built in support for using .env-styled files, and then you can override it further in the environment
key:
env_file:
- ../.env
environment:
# These values override the env_file
DATABASE_HOST: db
#etc
docker/Dockerfile.ng
Outdated
|
||
# TODO: Need to tune the .dockerignore, or prevent some things being copied here | ||
# eg. | ||
# Gemfile.lock has caused issues in testing |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What were those issues? I think the Gemfile.lock
is essential to ensure the image uses our locked gem version.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Absolutely going to keep the Gemfile.lock
for final production version. The issues were more around me bumping gems in the Gemfile
, not updating the file on my bare system, then building the docker image; it wasn't passing through the Gemfile.lock
in the initial stages (commented out), so the initial gem installs work, but then later when it adds the full huginn source, the Gemfile.lock
is added, and so it won't start properly.
So, the main issue is laziness during testing ;p
@dsander Off to a promising start for sure! But we won't count our chickens just yet. There may be additional runtime dependencies that are needed which might bump the image size up more. Will address most of your comments inline, but the build failing is related to the Gemfile.lock thing. |
I'll go back and clean up the history once this is in a working state. @dsander Should be able to build now, and with less 2.4.x weirdness mixed in. Exposing huginn on
Also maybe some DB errors
|
@alias1 Nice, it got a bit bigger for me, but still a lot smaller then the current image.
It's probably missing the I am wondering if we can keep most of the old script structure and the init` file for now. By "only" changing the OS and dependencies we would not need to worry about the initialization process because I assume bash in alpine works the same it does in ubuntu. Putting the docker file in |
I'll have a look over the scripts again when i get chance. The intention was to encode all of the setup steps into the dockerfile itself, and should largely be using the same init script, but i may have missed some bits. Note to self: Nice way of handling the DB linking https://github.com/docker-library/redmine/blob/master/docker-entrypoint.sh#L32 |
I have seen two different patterns of docker image builds, one is putting everything in the Dockerfile and the other is to put everything that does more then adding or executing a binary into a bash script. I kept the latter because I find it easier to read and modify the bash code when it is in a file with syntax highlighting. |
I'm no expert by far, but I don't think there's a huge difference between the two. I suppose adding the script file and running it leaves 'clutter' in the container, unless you're explicitly removing it again. May have to add extra layers (e.g. Copy, then run)
My main motivation was following the pattern of a bunch of the official files, and others I've seen, and far more that I've come across seem to stick to the 'all in dockerfile' approach.
Then personally, it sort of feels a bit cleaner having everything explicitly detailed within the one file. But that's not really a strongly evidenced opinion one way or another.
|
Ok.. had a quick look at the old scripts.. seems I failed to read/copy from them properly. Also.. time gets away so quickly..
|
Thinking some more about this.. I wonder if we want/need to keep the ubuntu base image, as opposed to a debian based one? That way we could use the official ruby docker image |
That's a bummer, but kind of resembles my experiences with complex applications on alpine. The main issue is still
Not sure about this, I think if we add an alpine image it should support everything the ubuntu/debian based image supported and then there should not be a need to keep the old images. Even if the setup is very clean it still adds environments that we need to support.
Neat, I have no experience with using docker in development so I don't know how one typically sets uses it.
I don't see why we need to keep the ubuntu base image. It would probably add some more layers but the same time reduce the amount of data to be downloaded when our layer cache is invalidated or fails (which seems to happen sometimes on travis). |
huginn#1959 Might help with huginn#1919
huginn#1959 Might help with huginn#1919
I believe this is the main issue to watch, as far as therubyracer is concerned: rubyjs/therubyracer#378
It does add extra environments to support.. but then I would think that we would still want to support 'normal' OS's, for people who aren't going to be using the docker images. And I think the overhead of building the extra image or so would be minimal.
I suppose we'll find out! :)
nods that makes sense. Well.. as a proof of concept I think i'll work to convert the current images to the 'new dockerfile layout' anyway (since it's halfway done). If nothing else, it should prove that the new layout is sane. @cantino Do you have any strong feelings one way or another around keeping/ditching the ubuntu image? |
I don't have enough Docker experience to have an opinion on this. |
It's not really a docker question as much as a platforms people can run in docker question. I'm kind of heavily leaning towards the fact that we should have an image for all of our supported platforms though. If for no other reason than making testing trivial. |
Not sure how much we would gain from it. The docker images are differing from the manual installation quite a bit. We could ensure that all gems install properly and the processes start, but I can't remember the last change that broke anything like that. |
Hrmm.. thats probably fair. When you say it's differing from the manual install processes, I wonder by how much/in what ways? Just due to docker quirks (eg. separated DB/huginn install/etc), or due to some process that we could better align between the two install methods? |
The main difference is that the manual installation uses |
@alias1 Seems like the rubyracer isn't maintained any longer. :/ |
@Skarlso Oh? What makes you say that? |
@alias1 Mainly because of the lack of responses and significant commits, or any kind of change around the PRs. But most likely, because of this comment for example four months ago:
And of course there is this, submitted in February: |
Interesting, thanks for pointing it out. @dsander Any thoughts on this? Is there another way we could support the features Huginn needs without therubyracer? A friend said he was able to use node directly these days, but not quite sure what features he was using. |
@alias1 I don't think we need Apart from the various compilation problems I am not aware of any issues that are related to rubyracer in Huginn. |
huginn#1959 Might help with huginn#1919
huginn#1959 Might help with huginn#1919
There seems to be a recipe for |
huginn#1959 Might help with huginn#1919
huginn#1959 Might help with huginn#1919
Super outdated + abandoned |
This is a WIP to track my efforts on docker-ng (#1874).
FYI, I fully expect this build to fail currently, and am making no efforts to fix that side of things till it's all working well locally. May need to cherry pick/refactor the history depending on how #1876 / etc go.
Would love any comments/feedback/testing/etc.
usualoma/ruby-with-therubyracer:2.4.0-alpine
)mysql:8.0
utf8m4
./compose-huginn-ng-mysql.sh
./compose-huginn-ng-mysql.sh build huginn
./compose-huginn-ng-mysql.sh run —user="root" huginn sh
Sizing
usualoma/ruby-with-therubyracer:2.4.0-alpine
is ~115mb of thatcantino/huginn
~884 MBcantino/huginn-single-process
~690 MB