diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 00000000..0d39b4d4 --- /dev/null +++ b/.travis.yml @@ -0,0 +1,23 @@ +os: linux +services: docker +language: minimal +install: skip +addons: + apt: + packages: + - docker-ce +script: + - USE_DOCKER="true" ./build/build_all.sh + - "./build/build_img.sh" +deploy: + provider: script + skip_cleanup: true + script: + - echo "$DOCKER_PASS" | docker login -u "$DOCKER_USER" --password-stdin && docker push filebrowser/filebrowser && docker logout + on: + repo: 1138-4EB/filebrowser + branch: master +env: + global: + - secure: YtxLrM3z2A/wDh5yLXrMXgsMRr+c7v5auS/2SpNxra0E6fcFKNPtk2g6JB4JfpFRp6feeuwtT61b16OdHjNVcwtZPLEdM1o7nUaLd+UxxKYlXwMSl+Hqaclx5KbBwlVCU3BKJjPVY/RujjSgOGG7C9b40E8YBssVIxyM51qV+u4C7Odu99ZC42OnFG8n+SsdP2xdI7BFw5qJTmNAgnns4QEAiZi++YMtsYmoo828mNpYX093N1VeW81JHeHo82Xwifpeij2fxuOkGAf2JMOuYrH+Mn+jgAiSUGkNRKhaA5do3ov6tSiCWZtQjrAIFk56knXaeeIO+ysryJ+BO9w2qquI1IYktpIemZjjoz24qKeUY0suxPdEe7cH17/P6n2LHUyXiUyUpjRX2bFqo6kfAoMc6oPqgOWu8Ls5GwuEHqCwsZXTVy4ZqNYiAIgk85lUecm9uy+Ubtu4bCdJpDlkC9jGow4Wn/6lHNxsuGWfBR1P94WtC+qmrZf/xje3A5xKATtZtLrfc0tLdsH5VYDyIZ4WYWOIrCemayjXK3RJxN+qQDxaPWPG0cmHAxPslUyHE1eDxy1hCkCZx82Qjr1dX8Xx5tO4SoBayV9pmJo4+IyEb711NQyYrA/EdDswMmrVJNLBY+yDK6umkMlcIuRkVQanOydgRrusbKuQoAGOQRE= + - secure: d+4aM/IGqszna5Yv7M+6wWmdzafSkPH5qJtvd5Jac6QUxMhDIzIN+br+Sf2PNougZso7EsaFHlZQKatSmCM+DsVy2Ke5DB82icTsMyBzano8GF+eYm9BJUhgOk933ygsDKRFvfaiwAPjGgyFDwLAc4CPc/Lly/mqs4wyyekFgTWvIF+AG9GaigCkQB14Ud70BJ0PBCGh82lqKSY32r7ti/G5uNrD5DFIOpUmoq9NWeX7tAvWi6iWWCdndmAnT7aRpb7oprgMTm4Jc7CguJvz2pKh6a2ncY29nuvr0DNEfXRGiGKAZAck852ad/pwSa04Uwi1j5arFAZuRgtldhksFQPWZM4s7SP9e6LpSWU4+QyuXY5R1Rs5KtdREd3J27z2RmFm0m5vMkUTGMMHvw+qOrITVovWKme+ptOKytpIVgoxmzA/Y2/aS0JxN78nuLfX5v24+yDQ1aIxtjTzQufkGyFPMqwDPV0ZO5/Ez0FP1lPWd5cRrL77ako1sTVje4Up08VwcmJueJH2Xv7YfmvYR0w/VMymEliKpDsTJ6A7/o+Y2gyi6mwTjg7q/6aXTBoxVH/3LFABJeBQWqhIaDTdk5xjutEGUKyUMoHjW6fqTvoErLRfwz8dSh1GBtLNz7AqVd2v7tnVzo0iFPIlyqvhUiHQX7M0+lPOz0hQ581VlHw= diff --git a/Dockerfile b/Dockerfile deleted file mode 100644 index 38f3f35f..00000000 --- a/Dockerfile +++ /dev/null @@ -1,18 +0,0 @@ -FROM golang:alpine - -COPY . /go/src/github.com/filebrowser/filebrowser -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=filebrowser/dev /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/ca-certificates.crt - -VOLUME /tmp -VOLUME /srv -EXPOSE 80 - -COPY Docker.json /config.json - -ENTRYPOINT ["/filebrowser", "--config", "/config.json"] diff --git a/build/build.sh b/build/build.sh new file mode 100755 index 00000000..4ba8ad8f --- /dev/null +++ b/build/build.sh @@ -0,0 +1,12 @@ +#!/bin/sh + +set -e + +cd $(dirname $0)/.. + +dep ensure -vendor-only + +cd cmd/filebrowser +CGO_ENABLED=0 go build -a +cd ../.. +cp cmd/filebrowser/filebrowser ./ diff --git a/build/build_all.sh b/build/build_all.sh new file mode 100755 index 00000000..ac14d211 --- /dev/null +++ b/build/build_all.sh @@ -0,0 +1,38 @@ +#!/bin/sh + +cd $(dirname $0)/.. + +if [ "$USE_DOCKER" != "" ]; then + if [ -d "frontend/dist" ]; then + rm -rf frontend/dist + fi; + WORKDIR="/go/src/github.com/filebrowser/filebrowser" + + $(command -v winpty) docker run -it \ + --name filebrowser-tmp \ + -v /$(pwd):/src:z \ + -w /${WORKDIR} \ + filebrowser/dev \ + sh -c "\ + cp -r //src/* /$WORKDIR && \ + cd build && \ + dos2unix build_assets.sh && \ + dos2unix build.sh && \ + ./build_assets.sh && \ + ./build.sh \ + " + exitcode=$? + + if [ $exitcode -eq 0 ]; then + for d in "dist/" "node_modules/"; do + docker cp filebrowser-tmp:/$WORKDIR/frontend/$d frontend + done + for d in "vendor/" "rice-box.go" "filebrowser"; do + docker cp filebrowser-tmp:/$WORKDIR/$d ./ + done + fi + docker rm -f filebrowser-tmp +else + ./build/build_assets.sh + ./build/build.sh +fi diff --git a/build.sh b/build/build_assets.sh old mode 100644 new mode 100755 similarity index 88% rename from build.sh rename to build/build_assets.sh index ae818c56..bd86ac6f --- a/build.sh +++ b/build/build_assets.sh @@ -2,7 +2,7 @@ set -e -cd $(dirname $0) +cd $(dirname $0)/.. # Clean the dist folder and build the assets cd frontend @@ -13,8 +13,6 @@ yarn install 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/build_img.sh b/build/build_img.sh new file mode 100755 index 00000000..af1bcee5 --- /dev/null +++ b/build/build_img.sh @@ -0,0 +1,9 @@ +#!/bin/sh + +set -e + +cd $(dirname $0)/.. + +cp dockerfiles/filebrowser Dockerfile +docker build -t filebrowser/filebrowser . +rm -f Dockerfile diff --git a/build/build_img_dev.sh b/build/build_img_dev.sh new file mode 100755 index 00000000..d196069e --- /dev/null +++ b/build/build_img_dev.sh @@ -0,0 +1,12 @@ +#!/bin/sh + +set -e + +cd $(dirname $0)/.. + +mkdir -p tmp-dev +cd tmp-dev +cp ../dockerfiles/dev Dockerfile +docker build -t filebrowser/dev . +cd .. +rm -rf tmp-dev diff --git a/build_in_docker.sh b/build_in_docker.sh deleted file mode 100644 index 767660b1..00000000 --- a/build_in_docker.sh +++ /dev/null @@ -1,16 +0,0 @@ -#!/bin/sh - -set -e - -cd $(dirname $0) - -WORKDIR="/go/src/github.com/filebrowser/filebrowser" - -$(command -v winpty) docker run --rm -it \ - -v /$(pwd):/${WORKDIR} \ - -w /${WORKDIR} \ - filebrowser/filebrowser:dev \ - sh -c '\ - dos2unix build.sh && \ - ./build.sh \ - ' diff --git a/Dockerfile.dev b/dockerfiles/dev similarity index 100% rename from Dockerfile.dev rename to dockerfiles/dev diff --git a/dockerfiles/filebrowser b/dockerfiles/filebrowser new file mode 100644 index 00000000..c02c3037 --- /dev/null +++ b/dockerfiles/filebrowser @@ -0,0 +1,12 @@ +FROM scratch + +COPY --from=filebrowser/dev /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/ca-certificates.crt + +VOLUME /tmp +VOLUME /srv +EXPOSE 80 + +COPY filebrowser /filebrowser +COPY Docker.json /config.json + +ENTRYPOINT ["/filebrowser", "--config", "/config.json"] diff --git a/publish.sh b/publish.sh index e119218a..660ce463 100644 --- a/publish.sh +++ b/publish.sh @@ -1,8 +1,10 @@ #!/bin/bash set -e +cd $(dirname $0) + echo "Building assets" -./build.sh +./build/build_assets.sh echo "Updating version number to $1..." sed -i "s|(untracked)|$1|g" filebrowser.go