From 56e500548491c0a294870b11711b6063cbc0f7ed Mon Sep 17 00:00:00 2001 From: 1138-4EB <1138-4EB@users.noreply.github.com> Date: Wed, 18 Apr 2018 17:27:28 +0200 Subject: [PATCH] drop package.json, use yarn instad of npm, add build_in_docker.sh Former-commit-id: 1f1ce1a5350eb1d4d12dc3b90bae20d6df6048f9 [formerly fae0cae6f369574aab49ab952e1aa681c97f7067] [formerly 6f8245ec50d0d2485a263e5877a6a353837b1197 [formerly f91ee24858116d7a313bdf8d57a994abbbc3f2a8]] Former-commit-id: b9bb3ad6a460de55851943bbbc62aee74e32028c [formerly 049f6c239d7a936d70493e68f23838c0ec11af88] Former-commit-id: 81f69427472bbeb3f82e6bd2c3a114e2c5fb47d7 --- .gitignore | 2 +- build.sh | 21 ++++++++++++++++----- build_in_docker.sh | 17 +++++++++++++++++ filebrowser.go | 2 +- package.json | 8 -------- 5 files changed, 35 insertions(+), 15 deletions(-) create mode 100644 build_in_docker.sh delete mode 100644 package.json diff --git a/.gitignore b/.gitignore index 98b81469..aecda952 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,5 @@ .DS_Store -node_modules/ +frontend/ */dist/* *.db *.db.lock diff --git a/build.sh b/build.sh index fc2fca57..6c060753 100644 --- a/build.sh +++ b/build.sh @@ -1,14 +1,25 @@ -#!/bin/bash +#!/bin/sh set -e +cd $(dirname $0) + +# Clean the dist folder and build the assets +if [ ! -d "frontend" ]; then + git clone -b master https://github.com/filebrowser/frontend +fi; +cd frontend +if [ -d "dist" ]; then + rm -rf dist/* +fi; +yarn install +yarn build + +cd .. + # Install rice tool if not present if ! [ -x "$(command -v rice)" ]; then go get github.com/GeertJohan/go.rice/rice fi -# Clean the dist folder and build the assets -rm -rf node_modules -npm install - # Embed the assets using rice rice embed-go diff --git a/build_in_docker.sh b/build_in_docker.sh new file mode 100644 index 00000000..21312ef2 --- /dev/null +++ b/build_in_docker.sh @@ -0,0 +1,17 @@ +#!/bin/sh + +cd $(dirname $0) + +docker pull golang:alpine + +$(command -v winpty) docker run --rm -it \ + -v /$(pwd)://src \ + -w //src \ + golang:alpine \ + 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 && \ + ./build.sh \ + ' diff --git a/filebrowser.go b/filebrowser.go index 1b23e24a..3879bbb1 100644 --- a/filebrowser.go +++ b/filebrowser.go @@ -119,7 +119,7 @@ type FSBuilder func(scope string) FileSystem func (m *FileBrowser) Setup() error { // Creates a new File Browser instance with the Users // map and Assets box. - m.Assets = rice.MustFindBox("./node_modules/filebrowser-frontend/dist") + m.Assets = rice.MustFindBox("./frontend/dist") m.Cron = cron.New() // Tries to get the encryption key from the database. diff --git a/package.json b/package.json deleted file mode 100644 index 76d69197..00000000 --- a/package.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "name": "filebrowser", - "author": "File Browser contributors", - "private": true, - "dependencies": { - "filebrowser-frontend": "1.6.0" - } -}