From 6d7629705ad6ef1e6c5fe88a5499fa4b17d5cd91 Mon Sep 17 00:00:00 2001 From: Tobias Nauen Date: Fri, 6 Mar 2026 09:06:56 +0100 Subject: [PATCH] add files for hosting with docker --- Dockerfile.updater | 21 +++++++++++++++++++++ docker-compose.yml | 26 ++++++++++++++++++++++++++ rebuild_docker.sh | 40 ++++++++++++++++++++++++++++++++++++++++ 3 files changed, 87 insertions(+) create mode 100644 Dockerfile.updater create mode 100644 docker-compose.yml create mode 100755 rebuild_docker.sh diff --git a/Dockerfile.updater b/Dockerfile.updater new file mode 100644 index 0000000..c8731db --- /dev/null +++ b/Dockerfile.updater @@ -0,0 +1,21 @@ +FROM alpine:latest + +RUN apk add --no-cache git docker-cli curl + +WORKDIR /app + +# Clone the repo +RUN git clone https://git.nauen-it.de/tobias/Pokemon-Type-Quiz.git . + +# Install node and npm +RUN apk add --no-cache nodejs npm + +# Install dependencies and build +RUN npm install && npm run build + +# Script to rebuild on changes +COPY rebuild_docker.sh /rebuild_docker.sh +RUN chmod +x /rebuild_docker.sh + +# Initial build +CMD ["/rebuild_docker.sh"] diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..415df2f --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,26 @@ +version: '1.0' + +networks: + frontend: + external: true + +services: + web: + image: nginx:latest + restart: unless-stopped + volumes: + - '/hdd/poketypes:/usr/share/nginx/html:ro' + networks: + - frontend + + updater: + build: + context: . + dockerfile: Dockerfile.updater + volumes: + - /hdd/poketypes:/dist + environment: + - REPO_URL=https://git.nauen-it.de/tobias/Pokemon-Type-Quiz.git + - BRANCH=main + restart: unless-stopped + diff --git a/rebuild_docker.sh b/rebuild_docker.sh new file mode 100755 index 0000000..e41c25b --- /dev/null +++ b/rebuild_docker.sh @@ -0,0 +1,40 @@ +#!/bin/sh + +REPO_URL="${REPO_URL:-https://github.com/YOUR_USERNAME/YOUR_REPO.git}" +BRANCH="${BRANCH:-main}" +POLL_INTERVAL="${POLL_INTERVAL:-3600}" + +echo "Starting updater for $REPO_URL (branch: $BRANCH)" + +# Build initially +cd /app +npm install +npm run build + +# Copy to shared volume +cp -r /app/dist/* /dist/ + +echo "Initial build complete" + +# Poll for updates +while true; do + sleep "$POLL_INTERVAL" + + echo "Checking for updates..." + git fetch origin "$BRANCH" + + LOCAL=$(git rev-parse HEAD) + REMOTE=$(git rev-parse origin/"$BRANCH") + + if [ "$LOCAL" != "$REMOTE" ]; then + echo "New changes detected! Rebuilding..." + + git pull origin "$BRANCH" + npm run build + cp -r /app/dist/* /dist/ + + echo "Done!" + else + echo "No changes" + fi +done