Skip to content

Commit

Permalink
Allow passing in CLI args directly via Docker (#1252)
Browse files Browse the repository at this point in the history
Add new Dockerfile to run Brakeman via Docker
  • Loading branch information
ryankemper authored and presidentbeef committed Aug 29, 2018
1 parent f8bbd43 commit ac689aa
Show file tree
Hide file tree
Showing 4 changed files with 62 additions and 4 deletions.
3 changes: 3 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# ignore .git and .cache folders
.git
.cache
18 changes: 14 additions & 4 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,15 +1,25 @@
FROM ruby:2.4-alpine
MAINTAINER Justin Collins
LABEL maintainer="Justin Collins"

WORKDIR /usr/src/app
COPY . /usr/src/app

# Create user named app with uid=9000, give it ownership of /usr/src/app
RUN adduser -u 9000 -D app && \
chown -R app:app /usr/src/app
USER app

# Copy our Gemfile (and related files) *without* copying our actual source code yet
COPY Gemfile* *.gemspec gem_common.rb ./
# Copy lib/brakeman/version.rb so that bundle install works
COPY lib/brakeman/version.rb ./lib/brakeman/

# Install the necessary gems
RUN bundle install --jobs 4 --without "development test"

VOLUME /code
# Copy in the latest Brakeman source code as the final stage
COPY . /usr/src/app

# Default to looking for source in /code
WORKDIR /code

CMD ["/usr/src/app/bin/codeclimate-brakeman"]
ENTRYPOINT ["/usr/src/app/bin/brakeman"]
25 changes: 25 additions & 0 deletions Dockerfile.codeclimate
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
FROM ruby:2.4-alpine
LABEL maintainer="Justin Collins"

WORKDIR /usr/src/app

# Create user named app with uid=9000, give it ownership of /usr/src/app
RUN adduser -u 9000 -D app && \
chown -R app:app /usr/src/app
USER app

# Copy our Gemfile (and related files) *without* copying our actual source code yet
COPY Gemfile* *.gemspec gem_common.rb ./
# Copy lib/brakeman/version.rb so that bundle install works
COPY lib/brakeman/version.rb ./lib/brakeman/

# Install the necessary gems
RUN bundle install --jobs 4 --without "development test"

# Copy in the latest Brakeman source code as the final stage
COPY . /usr/src/app

# Default to looking for source in /code
WORKDIR /code

CMD ["/usr/src/app/bin/codeclimate-brakeman"]
20 changes: 20 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,16 @@ Using Bundler:
gem 'brakeman'
end

Using Docker:

docker build . -t brakeman

If you wish to use the codeclimate-brakeman docker image directly:

docker build . -f "${PWD}/Dockerfile.codeclimate" -t codeclimate-brakeman

# Usage
#### Running locally

From a Rails application's root directory:

Expand All @@ -32,6 +41,17 @@ Outside of Rails root:

brakeman /path/to/rails/application

#### Running with Docker

From a Rails application's root directory:

docker run -v "$(pwd)":/code brakeman -o brakeman_results.html

Outside of Rails root: (Note that the output file is relative to path/to/rails/application)

docker run -v 'path/to/rails/application':/code brakeman -o brakeman_results.html


# Compatibility

Brakeman should work with any version of Rails from 2.3.x to 5.x.
Expand Down

0 comments on commit ac689aa

Please sign in to comment.