add travis

pull/492/head
1138-4EB 2018-06-06 21:02:00 +01:00
parent a2e293292e
commit 703318c214
11 changed files with 110 additions and 38 deletions

23
.travis.yml Normal file
View File

@ -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=

View File

@ -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"]

12
build/build.sh Executable file
View File

@ -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 ./

38
build/build_all.sh Executable file
View File

@ -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

4
build.sh → build/build_assets.sh Normal file → Executable file
View File

@ -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

9
build/build_img.sh Executable file
View File

@ -0,0 +1,9 @@
#!/bin/sh
set -e
cd $(dirname $0)/..
cp dockerfiles/filebrowser Dockerfile
docker build -t filebrowser/filebrowser .
rm -f Dockerfile

12
build/build_img_dev.sh Executable file
View File

@ -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

View File

@ -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 \
'

12
dockerfiles/filebrowser Normal file
View File

@ -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"]

View File

@ -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