216 lines
7.5 KiB
Docker
216 lines
7.5 KiB
Docker
# Build a container which hosts Android apps through an F-Droid repository.
|
|
|
|
# Base Image #
|
|
|
|
FROM debian:trixie-slim
|
|
|
|
# Static Variables #
|
|
|
|
ENV DOWNLOAD="/root/Downloads"
|
|
|
|
ENV WEBROOT="/var/www/html"
|
|
|
|
ENV FDROID="/root/fdroid"
|
|
ENV METADATA="$FDROID/metadata"
|
|
ENV REPO="$FDROID/repo"
|
|
ENV CONFIG="$FDROID/config.yml"
|
|
|
|
# Create Directory Hierarchies #
|
|
|
|
RUN mkdir -pv "$DOWNLOAD" "$WEBROOT" \
|
|
"$FDROID" "$METADATA" "$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
|
|
WORKDIR "$FDROID"
|
|
RUN fdroid init
|
|
|
|
# This is where the image would get published on Docker Hub. #
|
|
|
|
# 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"
|
|
ARG FILE20
|
|
ENV FILE20="$FILE20"
|
|
ARG FILE21
|
|
ENV FILE21="$FILE21"
|
|
ARG FILE22
|
|
ENV FILE22="$FILE22"
|
|
ARG FILE23
|
|
ENV FILE23="$FILE23"
|
|
ARG FILE24
|
|
ENV FILE24="$FILE24"
|
|
ARG FILE25
|
|
ENV FILE25="$FILE25"
|
|
ARG FILE26
|
|
ENV FILE26="$FILE26"
|
|
ARG FILE27
|
|
ENV FILE27="$FILE27"
|
|
ARG FILE28
|
|
ENV FILE28="$FILE28"
|
|
ARG FILE29
|
|
ENV FILE29="$FILE29"
|
|
ARG FILE30
|
|
ENV FILE30="$FILE30"
|
|
ARG FILE31
|
|
ENV FILE31="$FILE31"
|
|
ARG FILE32
|
|
ENV FILE32="$FILE32"
|
|
ARG FILE33
|
|
ENV FILE33="$FILE33"
|
|
ARG FILE34
|
|
ENV FILE34="$FILE34"
|
|
ARG FILE35
|
|
ENV FILE35="$FILE35"
|
|
ARG FILE36
|
|
ENV FILE36="$FILE36"
|
|
ARG FILE37
|
|
ENV FILE37="$FILE37"
|
|
ARG FILE38
|
|
ENV FILE38="$FILE38"
|
|
ARG FILE39
|
|
ENV FILE39="$FILE39"
|
|
|
|
ARG CACHE_BUST
|
|
ENV CACHE_BUST="$CACHE_BUST"
|
|
|
|
# Download Remote Files #
|
|
|
|
RUN bash -c 'echo "$CACHE_BUST" && if [[ -n "$FILE00" ]]; then wget -P "$DOWNLOAD" "$FILE00"; fi'
|
|
RUN bash -c 'echo "$CACHE_BUST" && if [[ -n "$FILE01" ]]; then wget -P "$DOWNLOAD" "$FILE01"; fi'
|
|
RUN bash -c 'echo "$CACHE_BUST" && if [[ -n "$FILE02" ]]; then wget -P "$DOWNLOAD" "$FILE02"; fi'
|
|
RUN bash -c 'echo "$CACHE_BUST" && if [[ -n "$FILE03" ]]; then wget -P "$DOWNLOAD" "$FILE03"; fi'
|
|
RUN bash -c 'echo "$CACHE_BUST" && if [[ -n "$FILE04" ]]; then wget -P "$DOWNLOAD" "$FILE04"; fi'
|
|
RUN bash -c 'echo "$CACHE_BUST" && if [[ -n "$FILE05" ]]; then wget -P "$DOWNLOAD" "$FILE05"; fi'
|
|
RUN bash -c 'echo "$CACHE_BUST" && if [[ -n "$FILE06" ]]; then wget -P "$DOWNLOAD" "$FILE06"; fi'
|
|
RUN bash -c 'echo "$CACHE_BUST" && if [[ -n "$FILE07" ]]; then wget -P "$DOWNLOAD" "$FILE07"; fi'
|
|
RUN bash -c 'echo "$CACHE_BUST" && if [[ -n "$FILE08" ]]; then wget -P "$DOWNLOAD" "$FILE08"; fi'
|
|
RUN bash -c 'echo "$CACHE_BUST" && if [[ -n "$FILE09" ]]; then wget -P "$DOWNLOAD" "$FILE09"; fi'
|
|
RUN bash -c 'echo "$CACHE_BUST" && if [[ -n "$FILE10" ]]; then wget -P "$DOWNLOAD" "$FILE10"; fi'
|
|
RUN bash -c 'echo "$CACHE_BUST" && if [[ -n "$FILE11" ]]; then wget -P "$DOWNLOAD" "$FILE11"; fi'
|
|
RUN bash -c 'echo "$CACHE_BUST" && if [[ -n "$FILE12" ]]; then wget -P "$DOWNLOAD" "$FILE12"; fi'
|
|
RUN bash -c 'echo "$CACHE_BUST" && if [[ -n "$FILE13" ]]; then wget -P "$DOWNLOAD" "$FILE13"; fi'
|
|
RUN bash -c 'echo "$CACHE_BUST" && if [[ -n "$FILE14" ]]; then wget -P "$DOWNLOAD" "$FILE14"; fi'
|
|
RUN bash -c 'echo "$CACHE_BUST" && if [[ -n "$FILE15" ]]; then wget -P "$DOWNLOAD" "$FILE15"; fi'
|
|
RUN bash -c 'echo "$CACHE_BUST" && if [[ -n "$FILE16" ]]; then wget -P "$DOWNLOAD" "$FILE16"; fi'
|
|
RUN bash -c 'echo "$CACHE_BUST" && if [[ -n "$FILE17" ]]; then wget -P "$DOWNLOAD" "$FILE17"; fi'
|
|
RUN bash -c 'echo "$CACHE_BUST" && if [[ -n "$FILE18" ]]; then wget -P "$DOWNLOAD" "$FILE18"; fi'
|
|
RUN bash -c 'echo "$CACHE_BUST" && if [[ -n "$FILE19" ]]; then wget -P "$DOWNLOAD" "$FILE19"; fi'
|
|
RUN bash -c 'echo "$CACHE_BUST" && if [[ -n "$FILE20" ]]; then wget -P "$DOWNLOAD" "$FILE20"; fi'
|
|
RUN bash -c 'echo "$CACHE_BUST" && if [[ -n "$FILE21" ]]; then wget -P "$DOWNLOAD" "$FILE21"; fi'
|
|
RUN bash -c 'echo "$CACHE_BUST" && if [[ -n "$FILE22" ]]; then wget -P "$DOWNLOAD" "$FILE22"; fi'
|
|
RUN bash -c 'echo "$CACHE_BUST" && if [[ -n "$FILE23" ]]; then wget -P "$DOWNLOAD" "$FILE23"; fi'
|
|
RUN bash -c 'echo "$CACHE_BUST" && if [[ -n "$FILE24" ]]; then wget -P "$DOWNLOAD" "$FILE24"; fi'
|
|
RUN bash -c 'echo "$CACHE_BUST" && if [[ -n "$FILE25" ]]; then wget -P "$DOWNLOAD" "$FILE25"; fi'
|
|
RUN bash -c 'echo "$CACHE_BUST" && if [[ -n "$FILE26" ]]; then wget -P "$DOWNLOAD" "$FILE26"; fi'
|
|
RUN bash -c 'echo "$CACHE_BUST" && if [[ -n "$FILE27" ]]; then wget -P "$DOWNLOAD" "$FILE27"; fi'
|
|
RUN bash -c 'echo "$CACHE_BUST" && if [[ -n "$FILE28" ]]; then wget -P "$DOWNLOAD" "$FILE28"; fi'
|
|
RUN bash -c 'echo "$CACHE_BUST" && if [[ -n "$FILE29" ]]; then wget -P "$DOWNLOAD" "$FILE29"; fi'
|
|
RUN bash -c 'echo "$CACHE_BUST" && if [[ -n "$FILE30" ]]; then wget -P "$DOWNLOAD" "$FILE30"; fi'
|
|
RUN bash -c 'echo "$CACHE_BUST" && if [[ -n "$FILE31" ]]; then wget -P "$DOWNLOAD" "$FILE31"; fi'
|
|
RUN bash -c 'echo "$CACHE_BUST" && if [[ -n "$FILE32" ]]; then wget -P "$DOWNLOAD" "$FILE32"; fi'
|
|
RUN bash -c 'echo "$CACHE_BUST" && if [[ -n "$FILE33" ]]; then wget -P "$DOWNLOAD" "$FILE33"; fi'
|
|
RUN bash -c 'echo "$CACHE_BUST" && if [[ -n "$FILE34" ]]; then wget -P "$DOWNLOAD" "$FILE34"; fi'
|
|
RUN bash -c 'echo "$CACHE_BUST" && if [[ -n "$FILE35" ]]; then wget -P "$DOWNLOAD" "$FILE35"; fi'
|
|
RUN bash -c 'echo "$CACHE_BUST" && if [[ -n "$FILE36" ]]; then wget -P "$DOWNLOAD" "$FILE36"; fi'
|
|
RUN bash -c 'echo "$CACHE_BUST" && if [[ -n "$FILE37" ]]; then wget -P "$DOWNLOAD" "$FILE37"; fi'
|
|
RUN bash -c 'echo "$CACHE_BUST" && if [[ -n "$FILE38" ]]; then wget -P "$DOWNLOAD" "$FILE38"; fi'
|
|
RUN bash -c 'echo "$CACHE_BUST" && if [[ -n "$FILE39" ]]; then wget -P "$DOWNLOAD" "$FILE39"; fi'
|
|
|
|
# Move Downloaded Files #
|
|
|
|
# Move any downloaded APK files to the repo folder.
|
|
RUN mv -v "$DOWNLOAD"/*.apk "$REPO"/ || \
|
|
(echo "WARNING! No APK file(s) to copy." && sleep 10)
|
|
|
|
# Move any downloaded metadata files to the metadata folder.
|
|
RUN mv -v "$DOWNLOAD"/*.yml "$METADATA"/ || \
|
|
(echo "WARNING! No YML file(s) to copy." && sleep 10)
|
|
|
|
# Move any downloaded icons to the main folder.
|
|
RUN mv -v "$DOWNLOAD"/*.png "$FDROID"/ || \
|
|
(echo "WARNING! No PNG file(s) to copy." && sleep 10)
|
|
|
|
# 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"
|
|
|
|
RUN sed -i '/repo_url/d' "$CONFIG"
|
|
RUN sed -i '/repo_name/d' "$CONFIG"
|
|
RUN sed -i '/repo_icon/d' "$CONFIG"
|
|
|
|
RUN sed -i "$ a repo_url: $REPO_DOMAIN/fdroid/repo" "$CONFIG"
|
|
RUN sed -i "$ a repo_name: $REPO_NAME" "$CONFIG"
|
|
# 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 REPO as the webroot while still
|
|
# having the user's URL be fdroid/repo/? How do others handle this?
|
|
RUN cp -rv "$REPO"/* "$WEBROOT/"
|
|
|
|
# Start Command #
|
|
|
|
CMD tail -F /var/log/nginx/access.log & \
|
|
tail -F /var/log/nginx/error.log & \
|
|
nginx -g "daemon off;"
|