From 3dcc58205ab45188e5f18657d9ea4d29a710148b Mon Sep 17 00:00:00 2001 From: Zsolt <2solt@users.noreply.github.com> Date: Wed, 23 May 2018 07:32:05 +0100 Subject: [PATCH] Move to alpine based docker images (#643) --- .../go-cve-dictionary/latest/Dockerfile | 27 +++++++++---- .../docker/goval-dictionary/latest/Dockerfile | 27 +++++++++---- setup/docker/vuls/latest/Dockerfile | 27 +++++++++---- setup/docker/vulsrepo/latest/Dockerfile | 38 +++++++++++++------ 4 files changed, 86 insertions(+), 33 deletions(-) diff --git a/setup/docker/go-cve-dictionary/latest/Dockerfile b/setup/docker/go-cve-dictionary/latest/Dockerfile index c201bec3..8ff8f4d3 100644 --- a/setup/docker/go-cve-dictionary/latest/Dockerfile +++ b/setup/docker/go-cve-dictionary/latest/Dockerfile @@ -1,15 +1,28 @@ -FROM golang:latest +FROM golang:alpine as builder + +RUN apk add --no-cache \ + git \ + make \ + gcc \ + musl-dev + +ENV REPOSITORY github.com/kotakanbe/go-cve-dictionary +RUN git clone https://$REPOSITORY.git $GOPATH/src/$REPOSITORY \ + && cd $GOPATH/src/$REPOSITORY \ + && make install + + +FROM alpine:3.7 MAINTAINER hikachan sadayuki-matsuno -ENV REPOSITORY github.com/kotakanbe/go-cve-dictionary ENV LOGDIR /var/log/vuls ENV WORKDIR /vuls -# go-cve-dictionary install -RUN git clone https://$REPOSITORY.git $GOPATH/src/$REPOSITORY \ - && cd $GOPATH/src/$REPOSITORY \ - && make install \ - && mkdir -p $LOGDIR + +RUN apk add --no-cache ca-certificates \ + && mkdir -p $WORKDIR $LOGDIR + +COPY --from=builder /go/bin/go-cve-dictionary /usr/local/bin/ VOLUME [$WORKDIR, $LOGDIR] WORKDIR $WORKDIR diff --git a/setup/docker/goval-dictionary/latest/Dockerfile b/setup/docker/goval-dictionary/latest/Dockerfile index 6aeeb76b..0898728b 100644 --- a/setup/docker/goval-dictionary/latest/Dockerfile +++ b/setup/docker/goval-dictionary/latest/Dockerfile @@ -1,15 +1,28 @@ -FROM golang:latest +FROM golang:alpine as builder + +RUN apk add --no-cache \ + git \ + make \ + gcc \ + musl-dev + +ENV REPOSITORY github.com/kotakanbe/goval-dictionary +RUN git clone https://$REPOSITORY.git $GOPATH/src/$REPOSITORY \ + && cd $GOPATH/src/$REPOSITORY \ + && make install + + +FROM alpine:3.7 MAINTAINER sadayuki-matsuno -ENV REPOSITORY github.com/kotakanbe/goval-dictionary ENV LOGDIR /var/log/vuls ENV WORKDIR /vuls -# goval-dictionary install -RUN git clone https://$REPOSITORY.git $GOPATH/src/$REPOSITORY \ - && cd $GOPATH/src/$REPOSITORY \ - && make install \ - && mkdir -p $LOGDIR + +RUN apk add --no-cache ca-certificates \ + && mkdir -p $WORKDIR $LOGDIR + +COPY --from=builder /go/bin/goval-dictionary /usr/local/bin/ VOLUME [$WORKDIR, $LOGDIR] WORKDIR $WORKDIR diff --git a/setup/docker/vuls/latest/Dockerfile b/setup/docker/vuls/latest/Dockerfile index 1db73c55..14fb3a3a 100644 --- a/setup/docker/vuls/latest/Dockerfile +++ b/setup/docker/vuls/latest/Dockerfile @@ -1,15 +1,28 @@ -FROM golang:latest +FROM golang:alpine as builder + +RUN apk add --no-cache \ + git \ + make \ + gcc \ + musl-dev + +ENV REPOSITORY github.com/future-architect/vuls +RUN git clone https://$REPOSITORY.git $GOPATH/src/$REPOSITORY \ + && cd $GOPATH/src/$REPOSITORY \ + && make install + + +FROM alpine:3.7 MAINTAINER hikachan sadayuki-matsuno -ENV REPOSITORY github.com/future-architect/vuls ENV LOGDIR /var/log/vuls ENV WORKDIR /vuls -# go-cve-dictionary install -RUN git clone https://$REPOSITORY.git $GOPATH/src/$REPOSITORY \ - && cd $GOPATH/src/$REPOSITORY \ - && make install \ - && mkdir -p $LOGDIR + +RUN apk add --no-cache openssh-client \ + && mkdir -p $WORKDIR $LOGDIR + +COPY --from=builder /go/bin/vuls /usr/local/bin/ VOLUME [$WORKDIR, $LOGDIR] WORKDIR $WORKDIR diff --git a/setup/docker/vulsrepo/latest/Dockerfile b/setup/docker/vulsrepo/latest/Dockerfile index bdd1d6a0..abbc7b52 100644 --- a/setup/docker/vulsrepo/latest/Dockerfile +++ b/setup/docker/vulsrepo/latest/Dockerfile @@ -1,18 +1,32 @@ -FROM alpine:3.6 +FROM golang:alpine as builder + +RUN apk --no-cache add git + +ENV REPOSITORY github.com/usiusi360/vulsrepo + +RUN git clone https://$REPOSITORY.git $GOPATH/src/$REPOSITORY \ + && cd $GOPATH/src/$REPOSITORY/server \ + && go get -u github.com/golang/dep/... \ + && dep ensure \ + && go build -ldflags "-s -w" -o $GOPATH/bin/vulsrepo-server + +RUN mkdir /vulsrepo \ + && mv $GOPATH/src/$REPOSITORY/server/vulsrepo-config.toml.sample /vulsrepo/vulsrepo-config.toml \ + && mv $GOPATH/src/$REPOSITORY /vulsrepo/www \ + && rm -rf /vulsrepo/www/.git* /vulsrepo/www/server \ + && sed -i -e 's/vulsrepo/www/g' /vulsrepo/vulsrepo-config.toml \ + && sed -i -e 's/home\/vuls-user/vulsrepo/g' /vulsrepo/vulsrepo-config.toml \ + && sed -i -e 's/\/opt//g' /vulsrepo/vulsrepo-config.toml + +FROM alpine:3.7 MAINTAINER hikachan sadayuki-matsuno usiusi360 +COPY --from=builder /go/bin/vulsrepo-server /usr/local/bin/ +COPY --from=builder /vulsrepo /vulsrepo + VOLUME /vuls - -RUN apk --no-cache add git \ - && git clone https://github.com/usiusi360/vulsrepo.git - -RUN cd /vulsrepo/server \ - && cp vulsrepo-config.toml.sample vulsrepo-config.toml \ - && sed -i -e 's/\/home\/vuls-user//g' vulsrepo-config.toml \ - && sed -i -e 's/\/opt//g' vulsrepo-config.toml \ - && mkdir /lib64 \ - && ln -s /lib/ld-musl-x86_64.so.1 /lib64/ld-linux-x86-64.so.2 +WORKDIR /vulsrepo EXPOSE 5111 -CMD ["/vulsrepo/server/vulsrepo-server"] +CMD ["vulsrepo-server"]