From 19aaa4aeb01ccd65eaac6107b2298399f23a0ab1 Mon Sep 17 00:00:00 2001 From: Julian Mutter Date: Thu, 9 Oct 2025 21:02:20 +0200 Subject: [PATCH] add docker setup for hosting the repo --- docker-compose.yml.sample | 12 ------------ hosting/Dockerfile | 15 +++++++++++++++ hosting/nginx.conf | 17 +++++++++++++++++ hosting/update.sh | 25 +++++++++++++++++++++++++ nginx.conf | 10 ---------- 5 files changed, 57 insertions(+), 22 deletions(-) delete mode 100644 docker-compose.yml.sample create mode 100644 hosting/Dockerfile create mode 100644 hosting/nginx.conf create mode 100644 hosting/update.sh delete mode 100644 nginx.conf diff --git a/docker-compose.yml.sample b/docker-compose.yml.sample deleted file mode 100644 index a3036b397..000000000 --- a/docker-compose.yml.sample +++ /dev/null @@ -1,12 +0,0 @@ -version: '3.8' - -services: - fdroid-nginx: - image: nginx:alpine - container_name: fdroid-nginx - volumes: - - ./fdroid-repo:/usr/share/nginx/html:ro - - ./nginx.conf:/etc/nginx/conf.d/default.conf:ro - ports: - - "8080:80" - restart: unless-stopped diff --git a/hosting/Dockerfile b/hosting/Dockerfile new file mode 100644 index 000000000..d9907f488 --- /dev/null +++ b/hosting/Dockerfile @@ -0,0 +1,15 @@ +# Use lightweight Nginx + Git +FROM nginx:alpine + +# Install git and bash +RUN apk add --no-cache git bash + +# Copy nginx config +COPY nginx.conf /etc/nginx/nginx.conf + +# Copy update script +COPY update.sh /update.sh +RUN chmod +x /update.sh + +# Start update loop + nginx +CMD ["/bin/bash", "-c", "/update.sh & nginx -g 'daemon off;'"] diff --git a/hosting/nginx.conf b/hosting/nginx.conf new file mode 100644 index 000000000..0431fdd35 --- /dev/null +++ b/hosting/nginx.conf @@ -0,0 +1,17 @@ +events {} +http { + server { + listen 80; + server_name = fdroid.julian-mutter.de; + + location = / { + return 302 /fdroid/repo; + } + + location /fdroid/repo { + alias /repo/fdroid/repo/; + autoindex on; + } + } +} + diff --git a/hosting/update.sh b/hosting/update.sh new file mode 100644 index 000000000..eb67bb101 --- /dev/null +++ b/hosting/update.sh @@ -0,0 +1,25 @@ +#! /bin/bash + +if [ ! -d "/repo/.git" ]; then + echo "Cloning repository..." + git clone --branch "$BRANCH" "$REPO_URL" "/repo" +fi + +while true; do + echo "Running repo update..." + + cd "/repo" || exit + git fetch origin + LOCAL=$(git rev-parse HEAD) + REMOTE=$(git rev-parse origin/binaries) + + if [ "$LOCAL" != "$REMOTE" ]; then + echo "Updating repo..." + git reset --hard origin/binaries + echo "Update complete." + else + echo "Nothing to do." + fi + + sleep 600 # check every 10 min +done diff --git a/nginx.conf b/nginx.conf deleted file mode 100644 index da7e8fd6d..000000000 --- a/nginx.conf +++ /dev/null @@ -1,10 +0,0 @@ -server { - listen 80; - server_name localhost; - - location / { - root /usr/share/nginx/html; - autoindex on; - } -} -