From 5b9f229291c55a0ff02b1796e3c14844961563d4 Mon Sep 17 00:00:00 2001 From: Daniele Viti Date: Tue, 12 Sep 2023 16:50:00 +0200 Subject: [PATCH] initial commit --- .gitignore | 1 + Dockerfile | 17 +++++++++++++++++ README.md | 37 +++++++++++++++++++++++++++++++++++-- docker-compose-deploy.yaml | 17 +++++++++++++++++ docker-compose.yaml | 12 ++++++++++++ settings.json | 12 ++++++++++++ users.json | 20 ++++++++++++++++++++ 7 files changed, 114 insertions(+), 2 deletions(-) create mode 100644 .gitignore create mode 100644 Dockerfile create mode 100644 docker-compose-deploy.yaml create mode 100644 docker-compose.yaml create mode 100644 settings.json create mode 100644 users.json diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..4c49bd7 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +.env diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..86c6b68 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,17 @@ +# First stage: build the F-Droid repository +FROM ubuntu AS build +RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone +RUN apt-get update +RUN apt-get install -y software-properties-common +RUN add-apt-repository ppa:fdroid/fdroidserver +RUN apt-get update +RUN apt-get install -y fdroidserver +WORKDIR /fdroid +RUN fdroid init -v +RUN fdroid update + +# Second stage: serve the /repo directory using Filebrowser +FROM filebrowser/filebrowser AS final +COPY --from=build /fdroid/ / +COPY settings.json /config/settings.json +CMD ["--config", "/config/settings.json"] \ No newline at end of file diff --git a/README.md b/README.md index f5f4669..4acd097 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,35 @@ -# fdroid-docker-reposerver -F-Droid Repository Server served with Nginx Docker +# F-Droid Repo Server with Filebrowser + +This Dockerfile creates a Docker image that deploys an F-Droid repository server using Alpine Linux and serves the `/repo` directory using Filebrowser with authentication. + +## Overview + +The Dockerfile consists of two stages: + +1. **Build stage**: In this stage, the F-Droid repository is built using Alpine Linux. The necessary packages and tools for the F-Droid server and Android SDK are installed, and the F-Droid repository is initialized and updated. + +2. **Filebrowser stage**: In this stage, the `/repo` directory from the build stage is served using Filebrowser with authentication. The `settings.json` file is used to configure Filebrowser, and the authentication is handled using a `users.json` file. + +## Usage + +1. Create a .env file specifying the Timezone (E.g. TZ=Europe/Rome) + +2. Create a `settings.json` file with the desired Filebrowser settings, including the authentication method and the path to the `users.json` file. + +3. Create a `users.json` file with the desired user credentials and permissions. + +4. Place your custom apps (APK files) in the `/repo` directory. + +5. Build the Docker image using the provided Dockerfile: `docker build -t fdroid-repo-server .` + +6. Run a container using the built image: `docker run -d -p 80:80 --name fdroid-repo-server fdroid-repo-server` + +7. Access the Filebrowser web interface at `http://localhost` (or the appropriate IP address) and log in with the credentials specified in the `users.json` file. + +8. Share the F-Droid repository URL with your users. The URL should be in the format `http:///repo`. + +9. Default username and password is admin/admin (please change the password at first configuration) + +## Customization + +You can modify the Dockerfile and the `settings.json` and `users.json` files according to your specific requirements. For more information on Filebrowser settings and authentication methods, refer to the [Filebrowser documentation](https://filebrowser.org/configuration/authentication-method). \ No newline at end of file diff --git a/docker-compose-deploy.yaml b/docker-compose-deploy.yaml new file mode 100644 index 0000000..65d82e4 --- /dev/null +++ b/docker-compose-deploy.yaml @@ -0,0 +1,17 @@ +version: "3" +services: + repo: + image: dnviti/fdroid-reposerver + restart: always + environment: + - TZ=Europe/Rome + command: [ "--config", "/config/settings.json" ] + volumes: + - repo:/fdroid/repo + - fbdb:/database + ports: + - 8083:80 + +volumes: + fbdb: + repo: diff --git a/docker-compose.yaml b/docker-compose.yaml new file mode 100644 index 0000000..c44e564 --- /dev/null +++ b/docker-compose.yaml @@ -0,0 +1,12 @@ +version: "3" +services: + repo: + image: dnviti/fdroid-reposerver + restart: always + environment: + - TZ=Europe/Rome + ports: + - 8083:80 + build: + context: . + dockerfile: Dockerfile diff --git a/settings.json b/settings.json new file mode 100644 index 0000000..d5ea265 --- /dev/null +++ b/settings.json @@ -0,0 +1,12 @@ +{ + "port": 80, + "baseURL": "", + "address": "0.0.0.0", + "log": "stdout", + "database": "/database/filebrowser.db", + "root": "/fdroid/repo", + "auth": { + "method": "json", + "file": "/config/users.json" + } +} diff --git a/users.json b/users.json new file mode 100644 index 0000000..9bac888 --- /dev/null +++ b/users.json @@ -0,0 +1,20 @@ +[ + { + "id": 1, + "username": "admin", + "password": "$2a$10$9hR3U9G8cPGg2f6jP0U8UO9hJ1z7E5aZ6d8N7nG9vWUO9hJ1z7E5a", + "scope": "/", + "locale": "en", + "viewMode": "mosaic", + "perm": { + "admin": true, + "execute": true, + "create": true, + "rename": true, + "modify": true, + "delete": true, + "share": true, + "download": true + } + } +]