diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..b8df950 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,8 @@ +services: + web: + image: nginx:alpine + ports: + - "45554:80" + volumes: + - ./entrypoint.sh:/entrypoint.sh:ro + entrypoint: ["/bin/sh", "/entrypoint.sh"] diff --git a/entrypoint.sh b/entrypoint.sh new file mode 100644 index 0000000..eaa4aef --- /dev/null +++ b/entrypoint.sh @@ -0,0 +1,29 @@ +#!/bin/sh +set -e + +WEBROOT="/usr/share/nginx/html" +GITEA_URL="https://gitea.reversed.dev" +GITEA_REPO="space/time-until" + +echo "Fetching latest release" + +RELEASE_JSON=$(wget -qO- \ + "$GITEA_URL/api/v1/repos/$GITEA_REPO/releases/latest") + +ASSET_URL=$(echo "$RELEASE_JSON" | sed -n 's/.*"browser_download_url" *: *"\([^"]*dist\.zip[^"]*\)".*/\1/p' | head -1) + +if [ -z "$ASSET_URL" ]; then + echo "ERROR: No dist.zip found in latest release" + exit 1 +fi + +echo "Downloading $ASSET_URL ..." +wget -qO /tmp/dist.zip --header="$AUTH_HEADER" "$ASSET_URL" + +echo "Extracting to $WEBROOT ..." +rm -rf "${WEBROOT:?}"/* +unzip -o /tmp/dist.zip -d "$WEBROOT" +rm /tmp/dist.zip + +echo "Starting nginx ..." +exec nginx -g "daemon off;"