From 894c85bab9f15b509744a377ed2c93286bba95da Mon Sep 17 00:00:00 2001 From: Armin Friedl Date: Mon, 27 Jul 2020 20:41:26 +0200 Subject: [PATCH 1/2] Use local URL, add Readme Use local url in prod config. The local url works if docker is started on localhost. If the container is deployed to a domain, the base URL must be specified via REACT_APP_API environment variable. --- README.md | 38 +++++++++++++++++++++++ web/fling/.env | 2 +- web/fling/src/components/admin/Navbar.jsx | 6 ---- 3 files changed, 39 insertions(+), 7 deletions(-) create mode 100644 README.md diff --git a/README.md b/README.md new file mode 100644 index 0000000..f328a9b --- /dev/null +++ b/README.md @@ -0,0 +1,38 @@ +# Fling +Have you ever missed the simplicity of an USB Stick when sharing data over the +net? + +Zero-friction sharing is a surprisingly unsolved problem. There's no reasonably +ubiquitous solution installed on everybody's machine. Online providers are often +packed with features, but miss out on things like direct download urls, a space +for others to easily _upload_ to you, or require registration from all +participants. I don't remember any of these things being a problem with USB 🤔. + +Fling is a self-hosted file share. It is simple like USB without missing out on +the good parts of the web: +- Drop files on a fling and share the URL. That's it. The fling way of life. + +Other features include: +- Choose your own, meaningful name for your sharing URL +- Share a direct download link +- Choose to let others upload files just as simple +- Protect your fling by a password - no registration required +- Let a fling expire after a date or a number of clicks (or keep it forever) + +# Fling is a API +It gets even better! + +Fling is a backend service and a web interface. But you can use anything else +that speaks HTTP if you prefer. In fact, we generate and publish a javascript +and python client for the Fling API on every build. If you like it bare-bones +there is also a querysheet in the examples folder with raw HTTP calls. + +Fling also has a code-first OpenAPI compliant spec. O mon Dieu, it just checks +_all_ the boxes! + +# Fling as a container +It gets even even better better! + +Fling is self-hosted. But it is packaged up in a docker container for easy +deployment. Run `docker run --rm -p3000:3000 arminfriedl/fling` and go to +http://localhost:3000. Admin user is `adminName:adminPassword`. diff --git a/web/fling/.env b/web/fling/.env index f01232d..a35e848 100644 --- a/web/fling/.env +++ b/web/fling/.env @@ -1,3 +1,3 @@ -REACT_APP_API=https://fling.friedl.net +REACT_APP_API=http://localhost:3000 REACT_APP_LOGLEVEL=warn REACT_APP_FILESIZE=209715200 diff --git a/web/fling/src/components/admin/Navbar.jsx b/web/fling/src/components/admin/Navbar.jsx index a189f66..47309e2 100644 --- a/web/fling/src/components/admin/Navbar.jsx +++ b/web/fling/src/components/admin/Navbar.jsx @@ -23,12 +23,6 @@ export default function Navbar() { Fling -
-
- - -
-
Logout From 987c8ccba5ff54a43b2a09cb6d7cb2a260ffeac8 Mon Sep 17 00:00:00 2001 From: Armin Friedl Date: Wed, 29 Jul 2020 00:34:28 +0200 Subject: [PATCH 2/2] Read configuration from environment --- container/Dockerfile | 9 +++++++-- container/entrypoint.sh | 2 ++ container/var/www/fling/config.js.template | 5 +++++ web/fling/public/config.js | 5 +++++ web/fling/public/index.html | 1 + web/fling/src/components/admin/FlingArtifacts.jsx | 2 +- web/fling/src/components/admin/Upload.jsx | 4 ++-- web/fling/src/components/user/DirectDownload.jsx | 4 ++-- web/fling/src/components/user/FlingUserList.jsx | 6 +++--- web/fling/src/index.js | 4 ++-- web/fling/src/util/fc.js | 2 +- 11 files changed, 31 insertions(+), 13 deletions(-) create mode 100644 container/var/www/fling/config.js.template create mode 100644 web/fling/public/config.js diff --git a/container/Dockerfile b/container/Dockerfile index 08d47a2..2b5f69a 100644 --- a/container/Dockerfile +++ b/container/Dockerfile @@ -2,7 +2,11 @@ FROM alpine:latest ARG VERSION -RUN apk add --update --no-cache nginx openjdk11-jre && \ +ENV FLING_API_BASE http://localhost:3000 +ENV FLING_LOG_LEVEL warn +ENV FLING_FILESIZE 209715200 + +RUN apk add --update --no-cache nginx openjdk11-jre gettext && \ mkdir -p /var/fling/files && \ mkdir -p /tmp/fling && \ wget -O /tmp/fling/service.jar "https://nexus.friedl.net/service/rest/v1/search/assets/download?sort=version&maven.groupId=net.friedl&maven.artifactId=fling&maven.baseVersion=$(echo -n $VERSION | tr [:lower:] [:upper:])&maven.extension=jar" && \ @@ -14,7 +18,8 @@ RUN apk add --update --no-cache nginx openjdk11-jre && \ mv /tmp/fling/service.jar ./service.jar COPY ./etc/nginx/conf.d /etc/nginx/conf.d -COPY ./entrypoint.sh ./usr/local/bin/entrypoint.sh +COPY ./var/www/fling/config.js.template /var/www/fling/config.js.template +COPY ./entrypoint.sh /usr/local/bin/entrypoint.sh VOLUME /var/fling/ diff --git a/container/entrypoint.sh b/container/entrypoint.sh index 296a77a..bfad7ce 100755 --- a/container/entrypoint.sh +++ b/container/entrypoint.sh @@ -6,4 +6,6 @@ mkdir /var/run/nginx # nginx fails with /var/run/nginx/nginx.pid not found in al nginx +cat /var/www/fling/config.js.template | envsubst > /var/www/fling/config.js + java ${FL_JVM_OPTS} -jar service.jar diff --git a/container/var/www/fling/config.js.template b/container/var/www/fling/config.js.template new file mode 100644 index 0000000..adce724 --- /dev/null +++ b/container/var/www/fling/config.js.template @@ -0,0 +1,5 @@ +window['flingconfig'] = { + API_BASE: "${FLING_API_BASE}", + LOG_LEVEL: "${FLING_LOG_LEVEL}", + FILESIZE: "${FLING_FILESIZE}" +} diff --git a/web/fling/public/config.js b/web/fling/public/config.js new file mode 100644 index 0000000..5ed728b --- /dev/null +++ b/web/fling/public/config.js @@ -0,0 +1,5 @@ +window['flingconfig'] = { + API_BASE: "http://localhost:8080", + LOG_LEVEL: "warn", + FILESIZE: 209715200 +} diff --git a/web/fling/public/index.html b/web/fling/public/index.html index 5d62148..6b7d1da 100644 --- a/web/fling/public/index.html +++ b/web/fling/public/index.html @@ -4,6 +4,7 @@ +