# Build a container which hosts Android apps through an F-Droid repository. # Base Image # FROM debian:trixie-slim # variables # ENV WEBROOT="/var/www/html" ENV FDROID="/root/fdroid" ENV REPO="$FDROID/repo" # Install Packages# # https://f-droid.org/en/docs/Installing_the_Server_and_Repo_Tools/#debianubuntumintetc RUN apt-get update && apt-get install -y sudo bash curl git vim nginx COPY files/debian-backports.sources /etc/apt/sources.list.d/ RUN apt-get update && apt-get install -y -t trixie-backports fdroidserver # Generate F-Droid Repo # USER root RUN mkdir -pv "$FDROID" WORKDIR "$FDROID" RUN fdroid init # Start Command # CMD nginx -g "daemon off;" # This is where the image would get published. # # Configure F-Droid Repo # ARG REPO_DOMAIN ENV REPO_DOMAIN="$REPO_DOMAIN" ARG REPO_NAME ENV REPO_NAME="$REPO_NAME" ARG REPO_ICON ENV REPO_ICON="$REPO_ICON" # TBD/TODO: Add commands to remove repo_url and repo_name if they already exist. RUN sed -i "$ a repo_url: $REPO_DOMAIN/fdroid/repo" "$FDROID/config.yml" RUN sed -i "$ a repo_name: $REPO_NAME" "$FDROID/config.yml" RUN fdroid update # Advanced Variables # ARG FILE00 ENV FILE00="$FILE00" ARG FILE01 ENV FILE01="$FILE01" ARG FILE02 ENV FILE02="$FILE02" ARG FILE03 ENV FILE03="$FILE03" ARG FILE04 ENV FILE04="$FILE04" ARG FILE05 ENV FILE05="$FILE05" ARG FILE06 ENV FILE06="$FILE06" ARG FILE07 ENV FILE07="$FILE07" ARG FILE08 ENV FILE08="$FILE08" ARG FILE09 ENV FILE09="$FILE09" ARG FILE10 ENV FILE10="$FILE10" ARG FILE11 ENV FILE11="$FILE11" ARG FILE12 ENV FILE12="$FILE12" ARG FILE13 ENV FILE13="$FILE13" ARG FILE14 ENV FILE14="$FILE14" ARG FILE15 ENV FILE15="$FILE15" ARG FILE16 ENV FILE16="$FILE16" ARG FILE17 ENV FILE17="$FILE17" ARG FILE18 ENV FILE18="$FILE18" ARG FILE19 ENV FILE19="$FILE19" # Download Remote Files # RUN mkdir -pv /root/fdroid/repo RUN bash -c 'if [[ -n "$FILE00" ]]; then wget -P "$REPO" "$FILE00"; fi' RUN bash -c 'if [[ -n "$FILE01" ]]; then wget -P "$REPO" "$FILE01"; fi' RUN bash -c 'if [[ -n "$FILE02" ]]; then wget -P "$REPO" "$FILE02"; fi' RUN bash -c 'if [[ -n "$FILE03" ]]; then wget -P "$REPO" "$FILE03"; fi' RUN bash -c 'if [[ -n "$FILE04" ]]; then wget -P "$REPO" "$FILE04"; fi' RUN bash -c 'if [[ -n "$FILE05" ]]; then wget -P "$REPO" "$FILE05"; fi' RUN bash -c 'if [[ -n "$FILE06" ]]; then wget -P "$REPO" "$FILE06"; fi' RUN bash -c 'if [[ -n "$FILE07" ]]; then wget -P "$REPO" "$FILE07"; fi' RUN bash -c 'if [[ -n "$FILE08" ]]; then wget -P "$REPO" "$FILE08"; fi' RUN bash -c 'if [[ -n "$FILE09" ]]; then wget -P "$REPO" "$FILE09"; fi' RUN bash -c 'if [[ -n "$FILE10" ]]; then wget -P "$REPO" "$FILE10"; fi' RUN bash -c 'if [[ -n "$FILE11" ]]; then wget -P "$REPO" "$FILE11"; fi' RUN bash -c 'if [[ -n "$FILE12" ]]; then wget -P "$REPO" "$FILE12"; fi' RUN bash -c 'if [[ -n "$FILE13" ]]; then wget -P "$REPO" "$FILE13"; fi' RUN bash -c 'if [[ -n "$FILE14" ]]; then wget -P "$REPO" "$FILE14"; fi' RUN bash -c 'if [[ -n "$FILE15" ]]; then wget -P "$REPO" "$FILE15"; fi' RUN bash -c 'if [[ -n "$FILE16" ]]; then wget -P "$REPO" "$FILE16"; fi' RUN bash -c 'if [[ -n "$FILE17" ]]; then wget -P "$REPO" "$FILE17"; fi' RUN bash -c 'if [[ -n "$FILE18" ]]; then wget -P "$REPO" "$FILE18"; fi' RUN bash -c 'if [[ -n "$FILE19" ]]; then wget -P "$REPO" "$FILE19"; fi' RUN sync # Move any downloaded metadata files to the correct folder. RUN cp -v "$REPO"/*.yml "$REPO"/../metadata || \ echo "WARNING! No YML file(s) to copy." && sleep 10 # Move any downloaded icons to the proper folder. RUN mv -v "$REPO"/*.png "$FDROID"/ || \ echo "WARNING! No PNG file(s) to copy." && sleep 10 # If the icon variable is set, add it to the config file before updating. RUN [ ! -z "$REPO_ICON" ] && \ sed -i "$ a repo_icon: $REPO_ICON" "$FDROID/config.yml" RUN fdroid update -c # Publish Repo Contents to Web Root # RUN cp -rv "$FDROID" "$WEBROOT/" # The index files are in repo. # TODO: Can NGINX be configured to serve this as root while still # having the URL be fdroid/repo/? How do others handle this? RUN cp -rv "$REPO"/* "$WEBROOT/" CMD service nginx start && \ echo "\n*** F-Droid Repository has been started successfully! ***\n" && \ tail -F /var/log/nginx/access.log & \ tail -F /var/log/nginx/error.log