├── .bin
├── pinger.py
├── setup.sh
└── start.sh
├── Dockerfile
├── LICENSE
├── README.md
├── app.json
├── heroku.yml
└── wrangler.toml
/.bin/pinger.py:
--------------------------------------------------------------------------------
1 | import os
2 | import time
3 |
4 | import requests
5 |
6 | url = os.environ.get("PINGER")
7 | if url:
8 | if url.endswith("/"):
9 | url = url[:-1]
10 | while True:
11 | time.sleep(int(os.environ.get("PINGER_INTERVAL", 900)))
12 | requests.get("%s/api/v1/ping" % (url))
13 |
--------------------------------------------------------------------------------
/.bin/setup.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | cd /usr/src/app/.bin
4 |
5 | mkdir ./dev
6 | cd ./dev
7 | mkdir ./tmp
8 | cd ./tmp
9 | git clone "https://github.com/libDrive/server.git" --depth 1 server
10 | git clone "https://github.com/libDrive/web.git" --depth 1 web
11 | mkdir ./libDrive.Server
12 | mkdir ./libDrive.Server/build
13 | mkdir ./libDrive.Server/src
14 | mkdir ./libDrive.Server/templates
15 | cd ./web
16 | yarn install
17 | yarn run build
18 | mv ./build/* ../libDrive.Server/build
19 | cd ../server
20 | mv main.py requirements.txt ../libDrive.Server
21 | mv ./src/* ../libDrive.Server/src
22 | mv ./templates/* ../libDrive.Server/templates
23 | cd ..
24 | cp ../../../README.md ../../../LICENSE ./libDrive.Server
25 | cd libDrive.Server
26 | mv ./* ../..
27 | cd ../../..
28 |
--------------------------------------------------------------------------------
/.bin/start.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | cd /usr/src/app/.bin
4 |
5 | if [ "${LIBDRIVE_VERSION}" != "dev" ]; then
6 | if [ ! -z "${LIBDRIVE_VERSION}" ]; then
7 | if [ "${LIBDRIVE_VERSION}" = "latest" ]; then
8 | VER="latest"
9 | else
10 | VER="tags/${LIBDRIVE_VERSION}"
11 | fi
12 | else
13 | VER="latest"
14 | fi
15 |
16 | if [ ! -z "${LIBDRIVE_REPOSITRY}" ]; then
17 | REPO=${LIBDRIVE_REPOSITRY}
18 | else
19 | REPO="libDrive/libDrive"
20 | fi
21 |
22 | curl -L -s $(curl -s "https://api.github.com/repos/${REPO}/releases/${VER}" | grep -Po '"browser_download_url": "\K.*?(?=")') | tar xf - -C .
23 |
24 | pip3 install -r requirements.txt -q --no-cache-dir
25 | else
26 | cd ./dev
27 | fi
28 |
29 | pip3 install -r requirements.txt -q --no-cache-dir
30 | if [ "${LOCAL_CLOUDFLARE}" = "True" ] | [ "$LOCAL_CLOUDFLARE" = "true" ]; then
31 | if [ ! -z "${PINGER}" ]; then
32 | gunicorn main:app &
33 | python3 /usr/src/app/.bin/pinger.py &
34 | wrangler dev --port 31146
35 | else
36 | gunicorn main:app &
37 | wrangler dev --port 31146
38 | fi
39 | else
40 | if [ ! -z "${PINGER}" ]; then
41 | gunicorn main:app &
42 | python3 /usr/src/app/.bin/pinger.py
43 | else
44 | gunicorn main:app
45 | fi
46 | fi
47 |
--------------------------------------------------------------------------------
/Dockerfile:
--------------------------------------------------------------------------------
1 | FROM ubuntu:20.04
2 |
3 | WORKDIR /usr/src/app
4 |
5 | ENV TZ UTC
6 |
7 | RUN chmod 777 /usr/src/app
8 |
9 | RUN apt-get update -y && \
10 | apt-get install -y --no-install-recommends python3.9 && \
11 | apt-get install -y --no-install-recommends python3.9-dev && \
12 | apt-get install -y --no-install-recommends python3-pip && \
13 | apt-get install -y curl && \
14 | apt-get install -y git && \
15 | apt-get install -y gnupg
16 | RUN curl -sL https://deb.nodesource.com/setup_16.x | bash -
17 | RUN apt-get -y install nodejs
18 | RUN npm install --global yarn
19 | RUN npm install --global @cloudflare/wrangler
20 |
21 | RUN curl -O https://raw.githubusercontent.com/libDrive/server/main/requirements.txt && \
22 | pip3 install -r requirements.txt --no-cache-dir
23 |
24 | ENV PATH="/usr/src/app/.local/bin:${PATH}"
25 |
26 | COPY . .
27 |
28 | RUN chmod +x ./.bin/setup.sh ./.bin/start.sh
29 | RUN ./.bin/setup.sh
30 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2021 libDrive
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 |
2 |
3 |
5 |
6 |
4 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
15 |
16 |
17 |
18 |
20 |
21 |
22 |
23 |