Compare commits
3 Commits
1bcf5f3e7b
...
9bc7988b81
| Author | SHA1 | Date | |
|---|---|---|---|
| 9bc7988b81 | |||
| 0ed000cd20 | |||
| 4264e47577 |
@@ -1,4 +1,5 @@
|
|||||||
# Build a container which hosts Android apps through an F-Droid repository.
|
# Build a container which hosts Android apps through an F-Droid repository.
|
||||||
|
# https://f-droid.org/en/docs/Setup_an_F-Droid_App_Repo/
|
||||||
|
|
||||||
# Base Image #
|
# Base Image #
|
||||||
|
|
||||||
@@ -6,12 +7,32 @@ FROM debian:trixie-slim
|
|||||||
|
|
||||||
# Setup #
|
# Setup #
|
||||||
|
|
||||||
RUN mkdir -pv "$REPO/"
|
ARG REPO
|
||||||
|
ENV REPO="$REPO"
|
||||||
|
ARG WEBROOT
|
||||||
|
ENV WEBROOT="$WEBROOT"
|
||||||
|
|
||||||
|
USER root
|
||||||
|
RUN mkdir -pv "$REPO"
|
||||||
|
WORKDIR "$REPO"
|
||||||
|
|
||||||
# Install Packages#
|
# Install Packages#
|
||||||
|
# https://f-droid.org/en/docs/Installing_the_Server_and_Repo_Tools/#debianubuntumintetc
|
||||||
|
|
||||||
# TBD/TODO: get list of packages
|
RUN apt-get update && apt-get install sudo bash curl git vim nginx
|
||||||
RUN apt-get update && apt-get install bash curl fdroidserver
|
COPY files/debian-backports.sources /etc/apt/sources.list.d/
|
||||||
|
RUN apt-get update && apt-get install -t trixie-backports fdroidserver
|
||||||
|
|
||||||
|
# Generate F-Droid Repo #
|
||||||
|
|
||||||
|
|
||||||
|
# Publish? #
|
||||||
|
|
||||||
|
#TBD/TODO
|
||||||
|
|
||||||
|
# Configure F-Droid Repo #
|
||||||
|
|
||||||
|
RUN sed -i 's/TBD/TODO/g' TBD.cfg
|
||||||
|
|
||||||
# Download Files #
|
# Download Files #
|
||||||
|
|
||||||
@@ -39,11 +60,15 @@ RUN bash -c 'if [[ -n "$FILE17" ]]; then curl "$FILE17" "$REPO"/; fi'
|
|||||||
RUN bash -c 'if [[ -n "$FILE18" ]]; then curl "$FILE18" "$REPO"/; fi'
|
RUN bash -c 'if [[ -n "$FILE18" ]]; then curl "$FILE18" "$REPO"/; fi'
|
||||||
RUN bash -c 'if [[ -n "$FILE19" ]]; then curl "$FILE19" "$REPO"/; fi'
|
RUN bash -c 'if [[ -n "$FILE19" ]]; then curl "$FILE19" "$REPO"/; fi'
|
||||||
|
|
||||||
|
RUN bash -c 'cd "$REPO" && fdroid update'
|
||||||
|
|
||||||
|
# Publish Repo to Web Root #
|
||||||
|
|
||||||
|
#TBD/TODO
|
||||||
|
|
||||||
# Start Container #
|
# Start Container #
|
||||||
|
|
||||||
USER root
|
CMD sleep 5 \
|
||||||
WORKDIR "$REPO"
|
&& tail -F /var/mail/* & \
|
||||||
CMD cd "$REPO" && \
|
&& tail -F /var/log/nginx/* & \
|
||||||
fdroid update \
|
&& wait -n
|
||||||
&& tail -F /var/mail/mail & \
|
|
||||||
&& wait -n
|
|
||||||
|
|||||||
@@ -8,9 +8,13 @@ services:
|
|||||||
build:
|
build:
|
||||||
context: ./
|
context: ./
|
||||||
network: host
|
network: host
|
||||||
|
args:
|
||||||
|
WEBROOT: ${WEBROOT}
|
||||||
|
REPO: ${REPO}
|
||||||
restart: always
|
restart: always
|
||||||
environment:
|
environment:
|
||||||
- REPO=$REPO
|
- WEBROOT=/var/www/html
|
||||||
|
- REPO=/root/fdroid
|
||||||
- FILE0=$FILE0
|
- FILE0=$FILE0
|
||||||
- FILE1=$FILE1
|
- FILE1=$FILE1
|
||||||
- FILE2=$FILE2
|
- FILE2=$FILE2
|
||||||
@@ -32,7 +36,8 @@ services:
|
|||||||
- FILE18=$FILE18
|
- FILE18=$FILE18
|
||||||
- FILE19=$FILE19
|
- FILE19=$FILE19
|
||||||
volumes:
|
volumes:
|
||||||
- ../../Volumes/F-DroidRepo:$REPO
|
- ../../Volumes/F-DroidRepo/fdroid:/root/fdroid
|
||||||
|
- ../../Volumes/F-DroidRepo/nginx:/var/www/html
|
||||||
deploy:
|
deploy:
|
||||||
mode: global
|
mode: global
|
||||||
resources:
|
resources:
|
||||||
|
|||||||
6
Config/F-DroidRepo/files/debian-backports.sources
Normal file
6
Config/F-DroidRepo/files/debian-backports.sources
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
Types: deb deb-src
|
||||||
|
URIs: http://deb.debian.org/debian
|
||||||
|
Suites: trixie-backports
|
||||||
|
Components: main contrib non-free non-free-firmware
|
||||||
|
Signed-By: /usr/share/keyrings/debian-archive-keyring.gpg
|
||||||
|
Enabled: yes
|
||||||
@@ -17,7 +17,7 @@
|
|||||||
|
|
||||||
services:
|
services:
|
||||||
|
|
||||||
wp-db:
|
db:
|
||||||
container_name: wp-db
|
container_name: wp-db
|
||||||
image: mariadb:lts
|
image: mariadb:lts
|
||||||
restart: always
|
restart: always
|
||||||
@@ -45,17 +45,17 @@ services:
|
|||||||
cpus: $WP_CPU_DB
|
cpus: $WP_CPU_DB
|
||||||
memory: $WP_MEM_DB
|
memory: $WP_MEM_DB
|
||||||
|
|
||||||
wp-app:
|
app:
|
||||||
container_name: wp-app
|
container_name: wp-app
|
||||||
image: wordpress:latest
|
image: wordpress:latest
|
||||||
restart: always
|
restart: always
|
||||||
ports:
|
ports:
|
||||||
- 8080:80
|
- 8080:80
|
||||||
depends_on:
|
depends_on:
|
||||||
wp-db:
|
db:
|
||||||
condition: service_healthy
|
condition: service_healthy
|
||||||
links:
|
links:
|
||||||
- wp-db
|
- db
|
||||||
volumes:
|
volumes:
|
||||||
- ../../Volumes/WordPress/wordpress:/var/www/html
|
- ../../Volumes/WordPress/wordpress:/var/www/html
|
||||||
environment:
|
environment:
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ function usage() {
|
|||||||
# 1) The exit code used when leaving.
|
# 1) The exit code used when leaving.
|
||||||
exit_code=$1
|
exit_code=$1
|
||||||
echo ""
|
echo ""
|
||||||
echo -n "Usage: $PROG [-A ( -u | -d | -b | -p | -c | -s )] " 1>&2
|
echo -n "Usage: $PROG [-A ( -u | -d | -b | -p | -c | -m | -s )] " 1>&2
|
||||||
echo "[-i CONTAINER] [-l CONTAINER] [-h]" 1>&2
|
echo "[-i CONTAINER] [-l CONTAINER] [-h]" 1>&2
|
||||||
cat <<- EOF
|
cat <<- EOF
|
||||||
|
|
||||||
@@ -26,7 +26,7 @@ function usage() {
|
|||||||
Parameters - Standalone:
|
Parameters - Standalone:
|
||||||
|
|
||||||
(ALL)
|
(ALL)
|
||||||
-A : Equivalent of specifying '-udbpcs' for a full upgrade service.
|
-A : Equivalent of specifying '-udbpcms' for a full upgrade service.
|
||||||
|
|
||||||
(UP)
|
(UP)
|
||||||
-u : Start all containers with 'up -d'.
|
-u : Start all containers with 'up -d'.
|
||||||
@@ -43,6 +43,9 @@ function usage() {
|
|||||||
(CLEAN)
|
(CLEAN)
|
||||||
-c : Remove any abandoned Docker objects using the 'prune' commands.
|
-c : Remove any abandoned Docker objects using the 'prune' commands.
|
||||||
|
|
||||||
|
(MAINTENANCE)
|
||||||
|
-m : Run any maintenance and/or purge scripts for each subproject.
|
||||||
|
|
||||||
(STATS)
|
(STATS)
|
||||||
-s : Tune in to the 'stats' of how each container is running.
|
-s : Tune in to the 'stats' of how each container is running.
|
||||||
|
|
||||||
@@ -86,7 +89,7 @@ function check_container() {
|
|||||||
|
|
||||||
## Parameters ##
|
## Parameters ##
|
||||||
|
|
||||||
while getopts ':Audbpcsi:l:h' opt; do
|
while getopts ':Audbpcsi:l:mh' opt; do
|
||||||
case $opt in
|
case $opt in
|
||||||
A) all="Y" ;;
|
A) all="Y" ;;
|
||||||
u) up="Y" ;;
|
u) up="Y" ;;
|
||||||
@@ -97,30 +100,31 @@ while getopts ':Audbpcsi:l:h' opt; do
|
|||||||
s) stats="Y" ;;
|
s) stats="Y" ;;
|
||||||
i) interact="$OPTARG" ;;
|
i) interact="$OPTARG" ;;
|
||||||
l) logs="$OPTARG" ;;
|
l) logs="$OPTARG" ;;
|
||||||
|
m) maintenance="Y" ;;
|
||||||
h) usage 0 ;;
|
h) usage 0 ;;
|
||||||
*) echo "ERROR: Parameter '$OPTARG' not recognized." 1>&2 && usage 1 ;;
|
*) echo "ERROR: Parameter '$OPTARG' not recognized." 1>&2 && usage 1 ;;
|
||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
|
|
||||||
# This is done outside the getopts for readability.
|
# This is done outside the getopts for readability.
|
||||||
if [[ -n $all ]]; then
|
if [[ -n "$all" && "$all" == "Y" ]]; then
|
||||||
up="Y"; down="Y"; build="Y"; pull="Y"; clean="Y"; stats="Y"
|
up="Y"; down="Y"; build="Y"; pull="Y"; clean="Y"; stats="Y"; maintenance="Y"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
## Validations ##
|
## Validations ##
|
||||||
|
|
||||||
# Script will behave poorly if not run with admin privileges.
|
# Script will behave poorly if not run with admin privileges.
|
||||||
if [[ $LOGNAME != "root" ]]; then
|
if [[ "$LOGNAME" != "root" ]]; then
|
||||||
echo "*************************************************************"
|
echo "*************************************************************"
|
||||||
echo "WARNING: Script is intended for root. Please su or sudo/doas."
|
echo "WARNING: Script is intended for root. Please su or sudo/doas."
|
||||||
echo "*************************************************************"
|
echo "*************************************************************"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Options which only work if the container exists or is going to be started.
|
# Options which only work if the container exists or is going to be started.
|
||||||
if [[ -n $interact ]]; then
|
if [[ -n "$interact" ]]; then
|
||||||
check_container $interact interaction
|
check_container $interact interaction
|
||||||
fi
|
fi
|
||||||
if [[ -n $logs ]]; then
|
if [[ -n "$logs" ]]; then
|
||||||
check_container $logs logs
|
check_container $logs logs
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@@ -128,14 +132,14 @@ fi
|
|||||||
|
|
||||||
# If no parameters are passed, list all the containers which are running.
|
# If no parameters are passed, list all the containers which are running.
|
||||||
if [[ -z $up && -z $down && -z $build && -z $pull && -z $clean
|
if [[ -z $up && -z $down && -z $build && -z $pull && -z $clean
|
||||||
&& -z $interact && -z $logs && -z $stats
|
&& -z $interact && -z $logs && -z $stats && -z $maintenance
|
||||||
]]; then
|
]]; then
|
||||||
docker ps --size
|
docker ps --size
|
||||||
exit 0
|
exit 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Otherwise, loop through all the subproject configurations.
|
# Otherwise, loop through all the subproject configurations.
|
||||||
if [[ -n $up || -n $down || -n $build || -n $pull ]]; then
|
if [[ -n $up || -n $down || -n $build || -n $pull || -n $maintenance ]]; then
|
||||||
cd $DOCKER_HOME/Config
|
cd $DOCKER_HOME/Config
|
||||||
for dir in `ls`; do
|
for dir in `ls`; do
|
||||||
# If this is a directory, enter it, otherwise skip to the next listing.
|
# If this is a directory, enter it, otherwise skip to the next listing.
|
||||||
@@ -143,10 +147,10 @@ if [[ -n $up || -n $down || -n $build || -n $pull ]]; then
|
|||||||
echo ""
|
echo ""
|
||||||
pwd
|
pwd
|
||||||
|
|
||||||
# Ensure .env files exist so that all compose variables are populated.
|
# Ensure env file exists so that all compose variables are populated.
|
||||||
if [[ -e ./env.standard && ! -e ./.env ]]; then
|
if [[ -e ./example.env && ! -e ./.env ]]; then
|
||||||
echo "WARNING: .env file was not found, copying standard as placeholder."
|
echo "WARNING: .env file was not found, copying example as placeholder."
|
||||||
cp -v env.standard .env
|
cp -v example.env .env
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Ensure all configuration files have been created.
|
# Ensure all configuration files have been created.
|
||||||
@@ -160,6 +164,21 @@ if [[ -n $up || -n $down || -n $build || -n $pull ]]; then
|
|||||||
done
|
done
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# Run the prep script to create any necessary volumes.
|
||||||
|
if [[ -f prep.sh ]]; then
|
||||||
|
./prep.sh
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Run any maintenance scripts associate with the container.
|
||||||
|
if [[ "$maintenance" == "Y" ]]; then
|
||||||
|
if [[ -f "maintenance.sh" ]]; then
|
||||||
|
./maintenance.sh
|
||||||
|
fi
|
||||||
|
if [[ -f "purge.sh" ]]; then
|
||||||
|
./purge.sh
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
# Shut off container.
|
# Shut off container.
|
||||||
if [[ $down == "Y" ]]; then
|
if [[ $down == "Y" ]]; then
|
||||||
[ -e docker-compose.yml ] && docker compose down
|
[ -e docker-compose.yml ] && docker compose down
|
||||||
@@ -200,6 +219,9 @@ if [[ -n $clean ]]; then
|
|||||||
docker network prune
|
docker network prune
|
||||||
docker builder prune -a
|
docker builder prune -a
|
||||||
docker system df
|
docker system df
|
||||||
|
echo "Syncing."
|
||||||
|
sync
|
||||||
|
sleep 5
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Follow the logs of a container.
|
# Follow the logs of a container.
|
||||||
|
|||||||
Reference in New Issue
Block a user