From 24d7021c47a275bd4e68e698272af446814be1a8 Mon Sep 17 00:00:00 2001 From: Teppei Fukuda Date: Thu, 12 Jul 2018 20:28:18 +0900 Subject: [PATCH] Refactor Dockerfile (#683) --- .dockerignore | 7 ++++ .../latest/Dockerfile => Dockerfile | 15 +++++---- .../docker/goval-dictionary/latest/Dockerfile | 32 ------------------- setup/docker/vulsrepo/latest/Dockerfile | 32 ------------------- 4 files changed, 15 insertions(+), 71 deletions(-) create mode 100644 .dockerignore rename setup/docker/go-cve-dictionary/latest/Dockerfile => Dockerfile (51%) delete mode 100644 setup/docker/goval-dictionary/latest/Dockerfile delete mode 100644 setup/docker/vulsrepo/latest/Dockerfile diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 00000000..2278005b --- /dev/null +++ b/.dockerignore @@ -0,0 +1,7 @@ +.dockerignore +Dockerfile +vendor/ +cve.sqlite3* +oval.sqlite3* +setup/ +img/ diff --git a/setup/docker/go-cve-dictionary/latest/Dockerfile b/Dockerfile similarity index 51% rename from setup/docker/go-cve-dictionary/latest/Dockerfile rename to Dockerfile index 8ff8f4d3..d1cf4b78 100644 --- a/setup/docker/go-cve-dictionary/latest/Dockerfile +++ b/Dockerfile @@ -6,10 +6,9 @@ RUN apk add --no-cache \ 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 +ENV REPOSITORY github.com/future-architect/vuls +COPY . $GOPATH/src/$REPOSITORY +RUN cd $GOPATH/src/$REPOSITORY && make install FROM alpine:3.7 @@ -19,14 +18,16 @@ MAINTAINER hikachan sadayuki-matsuno ENV LOGDIR /var/log/vuls ENV WORKDIR /vuls -RUN apk add --no-cache ca-certificates \ +RUN apk add --no-cache \ + openssh-client \ + ca-certificates \ && mkdir -p $WORKDIR $LOGDIR -COPY --from=builder /go/bin/go-cve-dictionary /usr/local/bin/ +COPY --from=builder /go/bin/vuls /usr/local/bin/ VOLUME [$WORKDIR, $LOGDIR] WORKDIR $WORKDIR ENV PWD $WORKDIR -ENTRYPOINT ["go-cve-dictionary"] +ENTRYPOINT ["vuls"] CMD ["--help"] diff --git a/setup/docker/goval-dictionary/latest/Dockerfile b/setup/docker/goval-dictionary/latest/Dockerfile deleted file mode 100644 index 0898728b..00000000 --- a/setup/docker/goval-dictionary/latest/Dockerfile +++ /dev/null @@ -1,32 +0,0 @@ -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 LOGDIR /var/log/vuls -ENV WORKDIR /vuls - -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 -ENV PWD $WORKDIR - -ENTRYPOINT ["goval-dictionary"] -CMD ["--help"] diff --git a/setup/docker/vulsrepo/latest/Dockerfile b/setup/docker/vulsrepo/latest/Dockerfile deleted file mode 100644 index abbc7b52..00000000 --- a/setup/docker/vulsrepo/latest/Dockerfile +++ /dev/null @@ -1,32 +0,0 @@ -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 -WORKDIR /vulsrepo - -EXPOSE 5111 -CMD ["vulsrepo-server"]