From d11aa8de6b2a248cb44a4624b2761c01ddde836d Mon Sep 17 00:00:00 2001 From: 1138-4EB <1138-4EB@users.noreply.github.com> Date: Thu, 19 Apr 2018 08:16:01 +0200 Subject: [PATCH] add filebrowser/filebrowser:dev, move dep execution to build.sh --- Dockerfile | 9 +-------- Dockerfile.dev | 13 +++++++++++++ build.sh | 3 +++ build_in_docker.sh | 15 +++++++-------- 4 files changed, 24 insertions(+), 16 deletions(-) create mode 100644 Dockerfile.dev diff --git a/Dockerfile b/Dockerfile index 024f6be1..38f3f35f 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,20 +1,13 @@ FROM golang:alpine COPY . /go/src/github.com/filebrowser/filebrowser - -WORKDIR /go/src/github.com/filebrowser/filebrowser -RUN apk --no-cache --update upgrade && apk --no-cache add ca-certificates git curl && \ - curl -fsSL -o /usr/local/bin/dep https://github.com/golang/dep/releases/download/v0.4.1/dep-linux-amd64 && \ - chmod +x /usr/local/bin/dep -RUN dep ensure -vendor-only - WORKDIR /go/src/github.com/filebrowser/filebrowser/cmd/filebrowser RUN CGO_ENABLED=0 go build -a RUN mv filebrowser /go/bin/filebrowser FROM scratch COPY --from=0 /go/bin/filebrowser /filebrowser -COPY --from=0 /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/ca-certificates.crt +COPY --from=filebrowser/dev /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/ca-certificates.crt VOLUME /tmp VOLUME /srv diff --git a/Dockerfile.dev b/Dockerfile.dev new file mode 100644 index 00000000..fbbaaecd --- /dev/null +++ b/Dockerfile.dev @@ -0,0 +1,13 @@ +FROM golang:alpine + +RUN echo "http://dl-cdn.alpinelinux.org/alpine/edge/testing" >> /etc/apk/repositories && \ + sed -i -e "s/v[0-9]\.[0-9]/edge/g" /etc/apk/repositories && \ + apk --no-cache -U upgrade && apk --no-cache add ca-certificates yarn git curl dos2unix && \ + go get github.com/GeertJohan/go.rice/rice && \ + curl -fsSL -o /usr/local/bin/dep $( \ + curl -s https://api.github.com/repos/golang/dep/releases/latest \ + | grep "browser_download_url.*linux-amd64\"" \ + | cut -d : -f 2,3 \ + | tr -d \" \ + ) && \ + chmod +x /usr/local/bin/dep diff --git a/build.sh b/build.sh index 6c060753..89ee9981 100644 --- a/build.sh +++ b/build.sh @@ -1,4 +1,5 @@ #!/bin/sh + set -e cd $(dirname $0) @@ -16,6 +17,8 @@ yarn build cd .. +dep ensure -vendor-only + # Install rice tool if not present if ! [ -x "$(command -v rice)" ]; then go get github.com/GeertJohan/go.rice/rice diff --git a/build_in_docker.sh b/build_in_docker.sh index 21312ef2..767660b1 100644 --- a/build_in_docker.sh +++ b/build_in_docker.sh @@ -1,17 +1,16 @@ #!/bin/sh +set -e + cd $(dirname $0) -docker pull golang:alpine +WORKDIR="/go/src/github.com/filebrowser/filebrowser" $(command -v winpty) docker run --rm -it \ - -v /$(pwd)://src \ - -w //src \ - golang:alpine \ + -v /$(pwd):/${WORKDIR} \ + -w /${WORKDIR} \ + filebrowser/filebrowser:dev \ sh -c '\ - echo "http://dl-cdn.alpinelinux.org/alpine/edge/testing" >> /etc/apk/repositories && \ - sed -i -e "s/v[0-9]\.[0-9]/edge/g" /etc/apk/repositories && \ - apk add -U --no-cache yarn git && \ - go get github.com/GeertJohan/go.rice/rice && \ + dos2unix build.sh && \ ./build.sh \ '