diff --git a/configure-instance.sh b/configure-instance.sh index 2b75e5d..c0e1cdc 100755 --- a/configure-instance.sh +++ b/configure-instance.sh @@ -1,14 +1,25 @@ -echo "Enter an url for the Frontend (eg: https://piped.kavin.rocks):" -read frontend_url +# Check if Docker-Compose is not installed +if [ -z "$(which docker-compose)" ]; then + echo "Docker-Compose is not installed. Please install it first from https://docs.docker.com/compose/install/#install-compose." + exit 1 +fi -echo "Enter an url for the Backend (eg: https://pipedapi.kavin.rocks):" -read backend_url +# Docker-Compose version check, to prevent "Unsupported configuration option" +COMPOSE_VERSION=$(docker-compose version --short) +REQUIRED_COMPOSE_VERSION="1.28.0" +if [[ $(printf '%s\n' "$REQUIRED_COMPOSE_VERSION" "$COMPOSE_VERSION" | sort -V | head -n1) != $REQUIRED_COMPOSE_VERSION ]]; then + echo "Your docker-compose version of $COMPOSE_VERSION is too old. Please upgrade to $REQUIRED_COMPOSE_VERSION or higher." + echo "See https://docs.docker.com/compose/install/#install-compose for installation instructions." + exit 1 +fi -echo "Enter an hostname for the Proxy (eg: https://pipedproxy.kavin.rocks):" -read proxy_url +echo "Enter an url for the Frontend (eg: https://piped.kavin.rocks):" && read -r frontend_url -echo "Enter the reverse proxy you would like to use (either caddy or nginx):" -read reverseproxy +echo "Enter an url for the Backend (eg: https://pipedapi.kavin.rocks):"" && read -r backend_url + +echo "Enter an hostname for the Proxy (eg: https://pipedproxy.kavin.rocks):"" && read -r proxy_url + +echo "Enter the reverse proxy you would like to use (either caddy or nginx):"" && read -r reverseproxy rm -rf config/ rm -f docker-compose.yml @@ -27,4 +38,9 @@ sed -i "s@FRONTEND_HOSTNAME@$frontend_hostname@g" config/* sed -i "s@BACKEND_HOSTNAME@$backend_hostname@g" config/* sed -i "s@PROXY_HOSTNAME@$proxy_hostname@g" config/* +# The openj9 image does not support aarch64 +if [[ "$(uname -m)" == "aarch64" ]]; then + sed -i "s/piped:latest/piped:hotspot/g" config/* +fi + mv config/docker-compose.$reverseproxy.yml docker-compose.yml diff --git a/template/docker-compose.caddy.yml b/template/docker-compose.caddy.yml index 254399c..c5a2ff1 100644 --- a/template/docker-compose.caddy.yml +++ b/template/docker-compose.caddy.yml @@ -5,7 +5,9 @@ services: depends_on: - piped container_name: piped-frontend - entrypoint: ash -c 'sed -i s@https://pipedapi.kavin.rocks@BACKEND_URL@g /usr/share/nginx/html/js/* && /docker-entrypoint.sh && nginx -g "daemon off;"' + entrypoint: ash -c 'sed -i s@https://pipedapi.kavin.rocks@BACKEND_URL@g + /usr/share/nginx/html/assets/* && /docker-entrypoint.sh && nginx -g + "daemon off;"' ytproxy: image: 1337kavin/ytproxy:latest restart: unless-stopped @@ -29,7 +31,8 @@ services: depends_on: - piped healthcheck: - test: ash -c "wget --no-verbose --tries=1 --spider 127.0.0.1:80/trending?region=US || (varnishreload && exit 1)" + test: ash -c "wget --no-verbose --tries=1 --spider 127.0.0.1:80/feed || + (varnishreload && exit 1)" interval: 10s timeout: 10s retries: 1 @@ -67,5 +70,5 @@ services: container_name: watchtower command: piped-frontend piped-backend ytproxy varnish caddy postgres watchtower volumes: - caddy_data: - ytproxy: + caddy_data: null + ytproxy: null diff --git a/template/docker-compose.nginx.yml b/template/docker-compose.nginx.yml index d39271e..35645d5 100644 --- a/template/docker-compose.nginx.yml +++ b/template/docker-compose.nginx.yml @@ -5,7 +5,9 @@ services: depends_on: - piped container_name: piped-frontend - entrypoint: ash -c 'sed -i s@https://pipedapi.kavin.rocks@BACKEND_URL@g /usr/share/nginx/html/js/* && /docker-entrypoint.sh && nginx -g "daemon off;"' + entrypoint: ash -c 'sed -i s@https://pipedapi.kavin.rocks@BACKEND_URL@g + /usr/share/nginx/html/assets/* && /docker-entrypoint.sh && nginx -g + "daemon off;"' ytproxy: image: 1337kavin/ytproxy:latest restart: unless-stopped @@ -29,7 +31,8 @@ services: depends_on: - piped healthcheck: - test: ash -c "wget --no-verbose --tries=1 --spider 127.0.0.1:80/trending?region=US || (varnishreload && exit 1)" + test: ash -c "wget --no-verbose --tries=1 --spider 127.0.0.1:80/feed || + (varnishreload && exit 1)" interval: 10s timeout: 10s retries: 1 @@ -73,4 +76,4 @@ services: container_name: watchtower command: piped-frontend piped-backend ytproxy varnish nginx postgres watchtower volumes: - ytproxy: + ytproxy: null