Browse Source

startup script to create couchdb stuff if it doesn't exist

pull/1/head
Wesley Kerfoot 5 years ago
parent
commit
8fb2064f4d
  1. 1
      app/blogPosts.json
  2. 2
      app/posts.py
  3. 9
      app/run.sh
  4. 14
      docker-compose.yml

1
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"

2
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")

9
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 "$@"

14
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"

Loading…
Cancel
Save