-
Notifications
You must be signed in to change notification settings - Fork 7
Update bundler-audit to 0.6.0 #52
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,19 +1,34 @@ | ||
| FROM codeclimate/alpine-ruby:b38 | ||
| FROM alpine:3.6 | ||
|
|
||
| RUN adduser -u 9000 -D app | ||
|
|
||
| WORKDIR /usr/src/app | ||
| RUN apk --update add ruby ruby-bundler git | ||
|
|
||
| COPY Gemfile* /usr/src/app/ | ||
| RUN bundle install --jobs 4 && \ | ||
| rm -rf /usr/share/ri | ||
| RUN apk add --no-cache ruby ruby-json git && \ | ||
| gem install --no-ri --no-rdoc bundler && \ | ||
| rm -r ~/.gem | ||
|
|
||
| RUN adduser -u 9000 -D app | ||
| USER app | ||
| COPY Gemfile* /usr/src/app/ | ||
| RUN bundle install --without=test --no-cache && \ | ||
| rm -rf ~/.bundle /usr/lib/ruby/gems/2.4.0/cache/* /usr/share/ri | ||
|
|
||
| COPY DATABASE_VERSION /usr/src/app/DATABASE_VERSION | ||
|
|
||
| RUN bundle-audit update | ||
| COPY bin bin/ | ||
| COPY lib lib/ | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is there a reason to avoid a simpler
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Smaller image. That is all. And we can't put all the unwanted files in |
||
| RUN chown -R app:app . | ||
|
|
||
| USER app | ||
|
|
||
| COPY . /usr/src/app | ||
| # The following step has to be ran by app user aas it depends on $HOME | ||
| RUN bundle-audit update && \ | ||
| for f in ~/.local/share/ruby-advisory-db/* ~/.local/share/ruby-advisory-db/.*; do \ | ||
| name="$(basename "$f")"; \ | ||
| test "$name" = "gems" || \ | ||
| test "$name" = "." || \ | ||
| test "$name" = ".." || \ | ||
| test "$name" = ".git" || \ | ||
| rm -r "$f"; \ | ||
| done | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. How much do we save by removing these files? Would just the |
||
|
|
||
| CMD ["/usr/src/app/bin/bundler-audit"] | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| FROM codeclimate/codeclimate-bundler-audit | ||
|
|
||
| USER root | ||
|
|
||
| RUN bundler install --no-cache --with="development test" | ||
|
|
||
| COPY Rakefile ./ | ||
| COPY spec spec/ | ||
| RUN chown -R app:app Rakefile spec | ||
|
|
||
| user app | ||
|
|
||
| CMD ["bundle", "exec", "rake"] |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,15 +1,20 @@ | ||
| .PHONY: image test citest update_version | ||
|
|
||
| IMAGE_NAME ?= codeclimate/codeclimate-bundler-audit | ||
| TEST_IMAGE_NAME ?= $(IMAGE_NAME)-test | ||
|
|
||
| image: | ||
| docker build --rm -t $(IMAGE_NAME) . | ||
|
|
||
| test: image | ||
| docker run -e PAGER=more --tty --interactive --rm $(IMAGE_NAME) bundle exec rake | ||
| test-image: image | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What is the difference in image size by maintaining a separate Docker image? I'm wondering if the extra complexity of two images/Dockerfiles is worth the gain.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The way it's setup in this PR prod image is 19MB/30% smaller than the test image. Prod image is 43.7MB, test image is 62.7MB. With proposed changes (ruby base image, copy all, bundler-audit cleanup removed) the image ends up clocking in at 74MB. Or 69% larger. |
||
| docker build --rm -t $(TEST_IMAGE_NAME) -f Dockerfile.test . | ||
|
|
||
| citest: | ||
| docker run --rm $(IMAGE_NAME) bundle exec rake | ||
| test: | ||
| @$(MAKE) test-image > /dev/null | ||
| docker run \ | ||
| -e PAGER=more \ | ||
| --tty --interactive --rm \ | ||
| $(TEST_IMAGE_NAME) | ||
|
|
||
| update_database: | ||
| date > DATABASE_VERSION | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,5 @@ | ||
| require "tmpdir" | ||
|
|
||
| module CC | ||
| module Engine | ||
| module BundlerAudit | ||
|
|
||
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 do you think of using the
2.4-alpine3.6base image so we can skip the ruby/bundler install?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.
For whatever reason I had issues with that base image. Engine code could not find bundler-audit files.
I spent more time than I should've had on it and didn't find the cause of it. Vanilla Alpine and packaged Ruby worked so I stuck with it.