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.
|
||||
# https://f-droid.org/en/docs/Setup_an_F-Droid_App_Repo/
|
||||
|
||||
# Base Image #
|
||||
|
||||
@@ -6,12 +7,32 @@ FROM debian:trixie-slim
|
||||
|
||||
# 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#
|
||||
# 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 bash curl fdroidserver
|
||||
RUN apt-get update && apt-get install sudo bash curl git vim nginx
|
||||
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 #
|
||||
|
||||
@@ -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 "$FILE19" ]]; then curl "$FILE19" "$REPO"/; fi'
|
||||
|
||||
RUN bash -c 'cd "$REPO" && fdroid update'
|
||||
|
||||
# Publish Repo to Web Root #
|
||||
|
||||
#TBD/TODO
|
||||
|
||||
# Start Container #
|
||||
|
||||
USER root
|
||||
WORKDIR "$REPO"
|
||||
CMD cd "$REPO" && \
|
||||
fdroid update \
|
||||
&& tail -F /var/mail/mail & \
|
||||
CMD sleep 5 \
|
||||
&& tail -F /var/mail/* & \
|
||||
&& tail -F /var/log/nginx/* & \
|
||||
&& wait -n
|
||||
|
||||
@@ -8,9 +8,13 @@ services:
|
||||
build:
|
||||
context: ./
|
||||
network: host
|
||||
args:
|
||||
WEBROOT: ${WEBROOT}
|
||||
REPO: ${REPO}
|
||||
restart: always
|
||||
environment:
|
||||
- REPO=$REPO
|
||||
- WEBROOT=/var/www/html
|
||||
- REPO=/root/fdroid
|
||||
- FILE0=$FILE0
|
||||
- FILE1=$FILE1
|
||||
- FILE2=$FILE2
|
||||
@@ -32,7 +36,8 @@ services:
|
||||
- FILE18=$FILE18
|
||||
- FILE19=$FILE19
|
||||
volumes:
|
||||
- ../../Volumes/F-DroidRepo:$REPO
|
||||
- ../../Volumes/F-DroidRepo/fdroid:/root/fdroid
|
||||
- ../../Volumes/F-DroidRepo/nginx:/var/www/html
|
||||
deploy:
|
||||
mode: global
|
||||
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:
|
||||
|
||||
wp-db:
|
||||
db:
|
||||
container_name: wp-db
|
||||
image: mariadb:lts
|
||||
restart: always
|
||||
@@ -45,17 +45,17 @@ services:
|
||||
cpus: $WP_CPU_DB
|
||||
memory: $WP_MEM_DB
|
||||
|
||||
wp-app:
|
||||
app:
|
||||
container_name: wp-app
|
||||
image: wordpress:latest
|
||||
restart: always
|
||||
ports:
|
||||
- 8080:80
|
||||
depends_on:
|
||||
wp-db:
|
||||
db:
|
||||
condition: service_healthy
|
||||
links:
|
||||
- wp-db
|
||||
- db
|
||||
volumes:
|
||||
- ../../Volumes/WordPress/wordpress:/var/www/html
|
||||
environment:
|
||||
|
||||
@@ -16,7 +16,7 @@ function usage() {
|
||||
# 1) The exit code used when leaving.
|
||||
exit_code=$1
|
||||
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
|
||||
cat <<- EOF
|
||||
|
||||
@@ -26,7 +26,7 @@ function usage() {
|
||||
Parameters - Standalone:
|
||||
|
||||
(ALL)
|
||||
-A : Equivalent of specifying '-udbpcs' for a full upgrade service.
|
||||
-A : Equivalent of specifying '-udbpcms' for a full upgrade service.
|
||||
|
||||
(UP)
|
||||
-u : Start all containers with 'up -d'.
|
||||
@@ -43,6 +43,9 @@ function usage() {
|
||||
(CLEAN)
|
||||
-c : Remove any abandoned Docker objects using the 'prune' commands.
|
||||
|
||||
(MAINTENANCE)
|
||||
-m : Run any maintenance and/or purge scripts for each subproject.
|
||||
|
||||
(STATS)
|
||||
-s : Tune in to the 'stats' of how each container is running.
|
||||
|
||||
@@ -86,7 +89,7 @@ function check_container() {
|
||||
|
||||
## Parameters ##
|
||||
|
||||
while getopts ':Audbpcsi:l:h' opt; do
|
||||
while getopts ':Audbpcsi:l:mh' opt; do
|
||||
case $opt in
|
||||
A) all="Y" ;;
|
||||
u) up="Y" ;;
|
||||
@@ -97,30 +100,31 @@ while getopts ':Audbpcsi:l:h' opt; do
|
||||
s) stats="Y" ;;
|
||||
i) interact="$OPTARG" ;;
|
||||
l) logs="$OPTARG" ;;
|
||||
m) maintenance="Y" ;;
|
||||
h) usage 0 ;;
|
||||
*) echo "ERROR: Parameter '$OPTARG' not recognized." 1>&2 && usage 1 ;;
|
||||
esac
|
||||
done
|
||||
|
||||
# This is done outside the getopts for readability.
|
||||
if [[ -n $all ]]; then
|
||||
up="Y"; down="Y"; build="Y"; pull="Y"; clean="Y"; stats="Y"
|
||||
if [[ -n "$all" && "$all" == "Y" ]]; then
|
||||
up="Y"; down="Y"; build="Y"; pull="Y"; clean="Y"; stats="Y"; maintenance="Y"
|
||||
fi
|
||||
|
||||
## Validations ##
|
||||
|
||||
# Script will behave poorly if not run with admin privileges.
|
||||
if [[ $LOGNAME != "root" ]]; then
|
||||
if [[ "$LOGNAME" != "root" ]]; then
|
||||
echo "*************************************************************"
|
||||
echo "WARNING: Script is intended for root. Please su or sudo/doas."
|
||||
echo "*************************************************************"
|
||||
fi
|
||||
|
||||
# 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
|
||||
fi
|
||||
if [[ -n $logs ]]; then
|
||||
if [[ -n "$logs" ]]; then
|
||||
check_container $logs logs
|
||||
fi
|
||||
|
||||
@@ -128,14 +132,14 @@ fi
|
||||
|
||||
# If no parameters are passed, list all the containers which are running.
|
||||
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
|
||||
docker ps --size
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# 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
|
||||
for dir in `ls`; do
|
||||
# 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 ""
|
||||
pwd
|
||||
|
||||
# Ensure .env files exist so that all compose variables are populated.
|
||||
if [[ -e ./env.standard && ! -e ./.env ]]; then
|
||||
echo "WARNING: .env file was not found, copying standard as placeholder."
|
||||
cp -v env.standard .env
|
||||
# Ensure env file exists so that all compose variables are populated.
|
||||
if [[ -e ./example.env && ! -e ./.env ]]; then
|
||||
echo "WARNING: .env file was not found, copying example as placeholder."
|
||||
cp -v example.env .env
|
||||
fi
|
||||
|
||||
# Ensure all configuration files have been created.
|
||||
@@ -160,6 +164,21 @@ if [[ -n $up || -n $down || -n $build || -n $pull ]]; then
|
||||
done
|
||||
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.
|
||||
if [[ $down == "Y" ]]; then
|
||||
[ -e docker-compose.yml ] && docker compose down
|
||||
@@ -200,6 +219,9 @@ if [[ -n $clean ]]; then
|
||||
docker network prune
|
||||
docker builder prune -a
|
||||
docker system df
|
||||
echo "Syncing."
|
||||
sync
|
||||
sleep 5
|
||||
fi
|
||||
|
||||
# Follow the logs of a container.
|
||||
|
||||
Reference in New Issue
Block a user