Improve docker setup and update scripts
This commit is contained in:
+10
-7
@@ -1,15 +1,18 @@
|
||||
# Use lightweight Nginx + Git
|
||||
# environment variables necessary to run:
|
||||
# REPO_URL the url of this repo
|
||||
# BRANCH the branch to work at
|
||||
|
||||
FROM nginx:alpine
|
||||
|
||||
# Install git and bash
|
||||
RUN apk add --no-cache git bash
|
||||
|
||||
# Copy nginx config
|
||||
COPY nginx.conf /etc/nginx/nginx.conf
|
||||
|
||||
# Copy update script
|
||||
COPY update.sh /update.sh
|
||||
RUN chmod +x /update.sh
|
||||
|
||||
# Start update loop + nginx
|
||||
CMD ["/bin/bash", "-c", "/update.sh & nginx -g 'daemon off;'"]
|
||||
# Add the cron job to run every 30 minutes
|
||||
# Redirecting to /proc/1/fd/1 ensures the script's echo statements show up in `docker logs`
|
||||
RUN echo "*/30 * * * * bash /update.sh > /proc/1/fd/1 2>&1" > /etc/crontabs/root
|
||||
|
||||
# Start the cron daemon in the background (-b) and nginx in the foreground
|
||||
CMD crond -b && nginx -g 'daemon off;'
|
||||
|
||||
Executable
+4
@@ -0,0 +1,4 @@
|
||||
#!/usr/bin/env sh
|
||||
|
||||
docker build . -t gitlab.julian-mutter.de/julian/fdroid-frajul:latest
|
||||
docker push gitlab.julian-mutter.de/julian/fdroid-frajul:latest
|
||||
@@ -1,6 +0,0 @@
|
||||
# !/bin/sh
|
||||
|
||||
git pull
|
||||
cd fdroid
|
||||
fdroid update -c
|
||||
fdroid update
|
||||
+46
-17
@@ -1,25 +1,54 @@
|
||||
#! /bin/bash
|
||||
|
||||
if [ ! -d "/repo/.git" ]; then
|
||||
if [ ! -d "/code/.git" ]; then
|
||||
echo "Performing initial setup!"
|
||||
mkdir /code
|
||||
echo "Cloning repository..."
|
||||
git clone --branch "$BRANCH" "$REPO_URL" "/repo"
|
||||
git clone --branch "$BRANCH" "$REPO_URL" "/code"
|
||||
echo "Decrypting secrets..."
|
||||
cd /code
|
||||
./scripts/decrypt.sh
|
||||
echo "Done"
|
||||
fi
|
||||
|
||||
while true; do
|
||||
echo "Running repo update..."
|
||||
echo "Running regular repo update..."
|
||||
echo ""
|
||||
|
||||
cd "/repo" || exit
|
||||
git fetch origin
|
||||
LOCAL=$(git rev-parse HEAD)
|
||||
REMOTE=$(git rev-parse origin/binaries)
|
||||
cd "/code"
|
||||
git fetch origin
|
||||
LOCAL=$(git rev-parse HEAD)
|
||||
REMOTE=$(git rev-parse "origin/$BRANCH")
|
||||
|
||||
if [ "$LOCAL" != "$REMOTE" ]; then
|
||||
echo "Updating repo..."
|
||||
git reset --hard origin/binaries
|
||||
echo "Update complete."
|
||||
else
|
||||
echo "Nothing to do."
|
||||
fi
|
||||
NEED_FDROID_UPDATE=false
|
||||
|
||||
sleep 600 # check every 10 min
|
||||
done
|
||||
# Update repo
|
||||
if [ "$LOCAL" != "$REMOTE" ]; then
|
||||
NEED_FDROID_UPDATE=true
|
||||
echo "Pulling repo..."
|
||||
git pull "origin/$BRANCH"
|
||||
echo "Pull complete"
|
||||
echo "Decrypting secrets..."
|
||||
./scripts/decrypt.sh
|
||||
echo "Done"
|
||||
else
|
||||
echo "No changes in repo."
|
||||
fi
|
||||
|
||||
# Update apks
|
||||
echo "Updating apks..."
|
||||
./scripts/update-apks.sh
|
||||
|
||||
if [ $? -eq 10 ]; then
|
||||
NEED_FDROID_UPDATE=true
|
||||
fi
|
||||
|
||||
# Run fdroid update if needed
|
||||
if [ "$NEED_FDROID_UPDATE" = true ]; then
|
||||
echo "Running fdroid update..."
|
||||
fdroid update -c
|
||||
fdroid update
|
||||
echo "Done"
|
||||
else
|
||||
echo "No changes made so no fdroid update necessary."
|
||||
echo "Done"
|
||||
fi
|
||||
|
||||
Reference in New Issue
Block a user