From 38f0908cb4fbbe50559627c1744139cd7771374d Mon Sep 17 00:00:00 2001 From: William Petit Date: Mon, 19 Nov 2018 21:43:09 +0100 Subject: [PATCH] Use caddy as HTTP server --- Caddyfile | 4 ++++ Dockerfile | 3 ++- Makefile | 5 +++-- config.py | 2 +- fdroid-update.sh | 5 ++--- misc/start.sh | 6 ++++-- supervisor.ini | 10 +++++----- 7 files changed, 21 insertions(+), 14 deletions(-) create mode 100644 Caddyfile diff --git a/Caddyfile b/Caddyfile new file mode 100644 index 0000000..1bf104b --- /dev/null +++ b/Caddyfile @@ -0,0 +1,4 @@ +{$FDROID_REPO_HOST} +gzip +log stdout +browse \ No newline at end of file diff --git a/Dockerfile b/Dockerfile index 6450277..08e8408 100644 --- a/Dockerfile +++ b/Dockerfile @@ -10,7 +10,7 @@ RUN apk add --no-cache \ python3 build-base freetype-dev libffi-dev \ libpng-dev py3-setuptools python3-dev libxml2-dev \ libxslt-dev openssl-dev jpeg-dev java-common \ - bash supervisor openssh inotify-tools gettext openjdk8 fastjar darkhttpd + bash supervisor openssh inotify-tools gettext openjdk8 fastjar caddy RUN ln -s /usr/bin/fastjar /usr/bin/jar RUN ln -s /usr/include/libxml2 /usr/include/libxml @@ -29,6 +29,7 @@ RUN mkdir /fdroid WORKDIR /fdroid COPY config.py /fdroid/config.py.tmpl +COPY Caddyfile /fdroid/Caddyfile COPY fdroid-update.sh /fdroid/fdroid-update.sh RUN chmod +x /fdroid/fdroid-update.sh diff --git a/Makefile b/Makefile index 9a13a1f..c52eba4 100644 --- a/Makefile +++ b/Makefile @@ -12,11 +12,12 @@ build: run: docker run -it --rm \ -p 2222:2222 \ - -p 8080:8080 \ + -p 8080:2015 \ -v "$(PWD)/data/repo:/fdroid/repo" \ -v "$(PWD)/data/metadata:/fdroid/metadata" \ -v "$(PWD)/data/keystore:/fdroid/keystore" \ - -e "FDROID_REPO_URL=http://localhost:8080" \ + -v "/etc/localtime:/etc/localtime:ro" \ + -e "FDROID_REPO_HOST=0.0.0.0" \ -e "FDROID_REPO_NAME=My local repo" \ -e "FDROID_REPO_DESCRIPTION=My repo description" \ -e "FDROID_KEYSTORE_PASS=mykeystorepass" \ diff --git a/config.py b/config.py index c7a29e7..75b602e 100644 --- a/config.py +++ b/config.py @@ -54,7 +54,7 @@ java_paths = { # The same policy is applied to the archive repo, if there is one. # repo_maxage = 0 -repo_url = "${FDROID_REPO_URL}" +repo_url = "https://${FDROID_REPO_HOST}" repo_name = "${FDROID_REPO_NAME}" repo_icon = "${FDROID_REPO_ICON}" repo_description = """ diff --git a/fdroid-update.sh b/fdroid-update.sh index c45cb1b..3e14d3e 100644 --- a/fdroid-update.sh +++ b/fdroid-update.sh @@ -6,8 +6,7 @@ EVENT=$1 DIR=$2 FILE=$3 -if [ -z "$FILE" ] || [[ "$FILE" == *.apk ]]; then - fdroid update -c --rename-apks --clean --use-date-from-apk - fdroid update --rename-apks --clean --use-date-from-apk +if [ -z "$FILE" ] || [[ "$FILE" == *.apk ]] || [[ "$FILE" == *.yml ]]; then + fdroid update -c --rename-apks --clean fi diff --git a/misc/start.sh b/misc/start.sh index 431b5ad..e3c340f 100644 --- a/misc/start.sh +++ b/misc/start.sh @@ -8,12 +8,14 @@ set +a docker run -it -d \ --restart always \ - -p 80:8080 \ + -p 80:80 \ + -p 443:443 \ -p 2222:2222 \ -v "${PWD}/data/repo:/fdroid/repo" \ -v "${PWD}/data/metadata:/fdroid/metadata" \ -v "${PWD}/data/keystore:/fdroid/keystore" \ - -e "FDROID_REPO_URL=${REPO_URL}" \ + -v "/etc/localtime:/etc/localtime:ro" \ + -e "FDROID_REPO_HOST=${REPO_HOST}" \ -e "FDROID_REPO_NAME=${REPO_NAME}" \ -e "FDROID_REPO_DESCRIPTION=${REPO_DESCRIPTION}" \ -e "FDROID_KEYSTORE_PASS=${KEYSTORE_PASS}" \ diff --git a/supervisor.ini b/supervisor.ini index da88832..6d85f3a 100644 --- a/supervisor.ini +++ b/supervisor.ini @@ -14,7 +14,7 @@ stderr_logfile_maxbytes=0 [program:fdroid-update] -command = inotifyd /fdroid/fdroid-update.sh /fdroid/repo:w +command = inotifyd /fdroid/fdroid-update.sh /fdroid/repo:w /fdroid/metadata:w directory = /fdroid user = fdroid autostart = true @@ -23,10 +23,10 @@ stdout_logfile_maxbytes=0 stderr_logfile=/dev/stderr stderr_logfile_maxbytes=0 -[program:darkhttpd] -command = darkhttpd /fdroid/repo --port 8080 -directory = /fdroid -user = fdroid +[program:caddy] +command = caddy -conf /fdroid/Caddyfile +directory = /fdroid/repo +user = root autostart = true stdout_logfile=/dev/stdout stdout_logfile_maxbytes=0