Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion lancache-litmus/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM lancachenet/ubuntu-nginx:latest
FROM lancachenet/ubuntu-nginx:latest AS final
MAINTAINER LanCache.Net Team <team@lancache.net>

ENV WEBUSER www-data
Expand All @@ -25,3 +25,13 @@ VOLUME ["/var/www/litmus"]
EXPOSE 80

WORKDIR /scripts

FROM final AS build-sites-js

# Generate a sites.js
RUN /bin/bash /hooks/entrypoint-pre.d/10_generate_litmus_statusjs.sh

FROM final

# Ship the generated sites.js
COPY --from=build-sites-js /var/www/litmus/sites.js /var/www/litmus/sites.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,18 @@ cd /data/cachedomains
sed -i "s/LITMUS_HOSTNAME/${LITMUS_HOSTNAME}/" /etc/nginx/sites-available/litmus.conf.d/10_litmus.conf
export GIT_SSH_COMMAND="ssh -o UserKnownHostsFile=/dev/null -o StrictHostCACHE_IDENTIFIERChecking=no"
if [[ ! -d .git ]]; then
git clone ${CACHE_DOMAINS_REPO} .
git clone ${CACHE_DOMAINS_REPO} . || {
echo "Failed to clone ${CACHE_DOMAINS_REPO}; falling back to prebuilt sites.js" >&2;
exit 0;
}
fi

if [[ "${NOFETCH:-false}" != "true" ]]; then
git fetch origin
git reset --hard origin/${CACHE_DOMAINS_BRANCH}
fi

declare -i total_domains
TEMP_PATH=$(mktemp -d)
OUTPUTFILE=${TEMP_PATH}/outfile.js
echo "var cachedomains = {" >> $OUTPUTFILE
Expand Down Expand Up @@ -43,6 +47,7 @@ jq -r '.cache_domains | to_entries[] | .key' cache_domains.json | while read CAC
echo " ]" >> $OUTPUTFILE
echo " }," >> $OUTPUTFILE
done
total_domains+=1
done
echo "};" >> $OUTPUTFILE
if [[ -d .git ]]; then
Expand All @@ -55,5 +60,12 @@ else
echo "var urltext='Running with an external hostlist that is not git controlled (Generated at ${date})';" >> $OUTPUTFILE;
fi
cat $OUTPUTFILE

if [ $total_domains -eq 0 ]
then
echo "Found no cache domains; falling back to prebuilt sites.js" >&2
exit 0
fi

cp $OUTPUTFILE /var/www/litmus/sites.js
rm -rf $TEMP_PATH