diff --git a/app/Dockerfile b/app/Dockerfile index 40ad3a1..2b90de3 100644 --- a/app/Dockerfile +++ b/app/Dockerfile @@ -5,7 +5,7 @@ RUN apt-get update -y RUN apt-get install -y python3-pip python3-dev build-essential RUN apt-get install -y curl RUN curl -sL https://deb.nodesource.com/setup_11.x | bash -RUN apt-get install -y sassc nodejs +RUN apt-get install -y sassc nodejs jq RUN npm install -g uglifycss uglifyjs COPY . ./src diff --git a/app/link.json b/app/link.json new file mode 100644 index 0000000..1f9e8df --- /dev/null +++ b/app/link.json @@ -0,0 +1,17 @@ +{ + "type" : "links", + "links" :[ + { + "type" : "links", + "title" : "test 1", + "href" : "https://wesk.tech", + "sub" : "wat" + }, + { + "type" : "links", + "title" : "test 2", + "href" : "https://wesk.tech", + "sub" : "lolwat" + } + ] +} diff --git a/app/run.sh b/app/run.sh index 05b4593..55d42e9 100644 --- a/app/run.sh +++ b/app/run.sh @@ -1,5 +1,16 @@ #! /bin/bash +function updateLinks() { + revision_id=$(curl http://$COUCHDB_USER:$COUCHDB_PASSWORD@127.0.0.1:5984/$COUCHDB_NAME/links | jq -r "._rev") + echo "$revision_id" + if [ $? == 0 ]; + then + curl -XDELETE "http://$COUCHDB_USER:$COUCHDB_PASSWORD@127.0.0.1:5984/$COUCHDB_NAME/links?rev=$revision_id" || true + fi + curl -XPUT http://$COUCHDB_USER:$COUCHDB_PASSWORD@127.0.0.1:5984/$COUCHDB_NAME/links -d @link.json || true + +} + curl 127.0.0.1:5984 2> /dev/null while [ $? != 0 ]; do curl 127.0.0.1:5984 2> /dev/null @@ -8,4 +19,7 @@ done curl -XPUT http://$COUCHDB_USER:$COUCHDB_PASSWORD@127.0.0.1:5984/$COUCHDB_NAME || true curl -XPUT http://$COUCHDB_USER:$COUCHDB_PASSWORD@127.0.0.1:5984/$COUCHDB_NAME/_design/blogPosts -d @/blogPosts.json || true + +updateLinks + exec python3 "$@"