diff --git a/app/blogPosts.json b/app/blogPosts.json index 41da47c..0b9d515 100644 --- a/app/blogPosts.json +++ b/app/blogPosts.json @@ -1,6 +1,5 @@ { "_id": "_design/blogPosts", - "_rev": "128-d6bf6a41f78d140bdbb71a8bed3c2554", "views": { "blog-posts": { "map": "function (doc) {\n if (doc.type == \"post\" && !doc.draft) {\n emit(doc._id.slice(-8), 1);\n }\n}\n\n\n\n\n" diff --git a/app/posts.py b/app/posts.py index f7f6c08..1a8c077 100644 --- a/app/posts.py +++ b/app/posts.py @@ -34,7 +34,7 @@ class Posts: self.client.credentials = (user, password) - self.db = self.client["blog"] + self.db = self.client[name] self.iterpost = self.postIterator("blogPosts/blog-posts") diff --git a/app/run.sh b/app/run.sh index 46eca1f..714f05d 100644 --- a/app/run.sh +++ b/app/run.sh @@ -1,4 +1,11 @@ #! /bin/bash -touch /wtfisthis +curl localhost:5984 2> /dev/null +while [ $? != 0 ]; do + curl localhost:5984 2> /dev/null + sleep 5; +done + +curl -XPUT http://$COUCHDB_USER:$COUCHDB_PASSWORD@localhost:5984/blog || true +curl -XPUT http://$COUCHDB_USER:$COUCHDB_PASSWORD@localhost:5984/blog/_design/blogPosts -d @/blogPosts.json || true exec python3 "$@" diff --git a/docker-compose.yml b/docker-compose.yml index 19464a9..f09e376 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,5 +1,11 @@ version: '3' services: + couch: + build: couchdb + ports: + - "127.0.0.1:5984:5984" + env_file: + - "./.envrc" web: build: app ports: @@ -7,9 +13,5 @@ services: network_mode: host env_file: - "./.envrc" - couch: - build: couchdb - ports: - - "127.0.0.1:5984:5984" - env_file: - - "./.envrc" + depends_on: + - "couch"