From db1309af835b205d5a708fe4e87020c1d8174dfe Mon Sep 17 00:00:00 2001 From: Mostafa Hussein Date: Tue, 2 Oct 2018 08:45:35 +0200 Subject: [PATCH 1/4] Use LABEL and Make use of multistage build Maintainer keyword should be replaced with LABEL, and Also using multistage build decreases the image from 139MB to 117MB Signed-off-by: Mostafa Hussein --- Dockerfile | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/Dockerfile b/Dockerfile index eb56a0db..046be1ac 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,5 +1,5 @@ -FROM ruby:2.5-alpine -MAINTAINER WPScan Team +FROM ruby:2.5-alpine AS builder +LABEL maintainer="WPScan Team " ARG BUNDLER_ARGS="--jobs=8 --without test development" @@ -19,9 +19,20 @@ RUN apk add --no-cache libcurl procps sqlite-libs && \ WORKDIR /wpscan RUN rake install --trace +FROM ruby:2.5-alpine +LABEL maintainer="WPScan Team , Mostafa Hussein " + +RUN adduser -h /wpscan -g WPScan -D wpscan + +COPY --from=builder /usr/local/bundle /usr/local/bundle +COPY --from=builder /wpscan /wpscan +RUN chown -R wpscan:wpscan /wpscan + +# runtime dependencies +RUN apk add --no-cache libcurl procps sqlite-libs + USER wpscan RUN /usr/local/bundle/bin/wpscan --update --verbose ENTRYPOINT ["/usr/local/bundle/bin/wpscan"] CMD ["--help"] - From 3a1a976e353e9d48de738c8aa5e1a43fba0ae34c Mon Sep 17 00:00:00 2001 From: Mostafa Hussein Date: Tue, 2 Oct 2018 13:29:10 +0200 Subject: [PATCH 2/4] Update Maintainers --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 046be1ac..a3e2061f 100644 --- a/Dockerfile +++ b/Dockerfile @@ -20,7 +20,7 @@ WORKDIR /wpscan RUN rake install --trace FROM ruby:2.5-alpine -LABEL maintainer="WPScan Team , Mostafa Hussein " +LABEL maintainer="WPScan Team " RUN adduser -h /wpscan -g WPScan -D wpscan From bd90da7ed2165ab80777fec5890adf4809343ced Mon Sep 17 00:00:00 2001 From: Mostafa Hussein Date: Tue, 2 Oct 2018 14:43:38 +0200 Subject: [PATCH 3/4] Remove runtime dependencies from build stage --- Dockerfile | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/Dockerfile b/Dockerfile index a3e2061f..6c0486b7 100644 --- a/Dockerfile +++ b/Dockerfile @@ -9,10 +9,8 @@ RUN echo "gem: --no-ri --no-rdoc" > /etc/gemrc COPY . /wpscan RUN chown -R wpscan:wpscan /wpscan -# runtime dependencies -RUN apk add --no-cache libcurl procps sqlite-libs && \ - # build dependencies - apk add --no-cache --virtual build-deps git libcurl ruby-dev libffi-dev make gcc musl-dev zlib-dev procps sqlite-dev && \ +# build dependencies +RUN apk add --no-cache --virtual build-deps git libcurl ruby-dev libffi-dev make gcc musl-dev zlib-dev procps sqlite-dev && \ bundle install --system --gemfile=/wpscan/Gemfile $BUNDLER_ARGS && \ apk del --no-cache build-deps From d6f44b2f4230769eabccf8281b0843361320fe72 Mon Sep 17 00:00:00 2001 From: Mostafa Hussein Date: Tue, 2 Oct 2018 15:55:35 +0200 Subject: [PATCH 4/4] Remove unnecessary commands --- Dockerfile | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/Dockerfile b/Dockerfile index 6c0486b7..94511f15 100644 --- a/Dockerfile +++ b/Dockerfile @@ -10,9 +10,8 @@ COPY . /wpscan RUN chown -R wpscan:wpscan /wpscan # build dependencies -RUN apk add --no-cache --virtual build-deps git libcurl ruby-dev libffi-dev make gcc musl-dev zlib-dev procps sqlite-dev && \ - bundle install --system --gemfile=/wpscan/Gemfile $BUNDLER_ARGS && \ - apk del --no-cache build-deps +RUN apk add --no-cache git libcurl ruby-dev libffi-dev make gcc musl-dev zlib-dev procps sqlite-dev && \ + bundle install --system --gemfile=/wpscan/Gemfile $BUNDLER_ARGS WORKDIR /wpscan RUN rake install --trace