From 15e04fdfa20c93550009ae7ac54070dcca2e5f71 Mon Sep 17 00:00:00 2001
From: Wonderfall <wonderfall@schrodinger.io>
Date: Thu, 20 Jul 2017 17:41:14 +0200
Subject: [PATCH] ghost: add 1.x

---
 ghost/{ => 0.x}/Dockerfile                    |  2 +-
 ghost/{ => 0.x}/README.md                     |  0
 ghost/{ => 0.x}/disqus.conf                   |  0
 ghost/{ => 0.x}/isso.conf                     |  0
 ghost/{ => 0.x}/prism.css.conf                |  0
 ghost/{ => 0.x}/prism.js.conf                 |  0
 ghost/{ => 0.x}/prism_dark.css                |  0
 ghost/{ => 0.x}/prism_dark.js                 |  0
 ghost/{ => 0.x}/prism_light.css               |  0
 ghost/{ => 0.x}/prism_light.js                |  0
 ghost/{ => 0.x}/run.sh                        |  0
 ghost/{ => 0.x}/smtp.conf                     |  0
 ghost/1.x/Dockerfile                          | 45 ++++++++++++++++
 ghost/1.x/rootfs/etc/s6.d/.s6-svscan/finish   |  2 +
 ghost/1.x/rootfs/etc/s6.d/ghost/run           |  5 ++
 ghost/1.x/rootfs/usr/local/bin/run.sh         | 54 +++++++++++++++++++
 ghost/1.x/rootfs/usr/local/etc/disqus.conf    | 16 ++++++
 .../rootfs/usr/local/etc/ghost.example.conf   | 21 ++++++++
 ghost/1.x/rootfs/usr/local/etc/isso.conf      |  7 +++
 19 files changed, 151 insertions(+), 1 deletion(-)
 rename ghost/{ => 0.x}/Dockerfile (98%)
 rename ghost/{ => 0.x}/README.md (100%)
 rename ghost/{ => 0.x}/disqus.conf (100%)
 rename ghost/{ => 0.x}/isso.conf (100%)
 rename ghost/{ => 0.x}/prism.css.conf (100%)
 rename ghost/{ => 0.x}/prism.js.conf (100%)
 rename ghost/{ => 0.x}/prism_dark.css (100%)
 rename ghost/{ => 0.x}/prism_dark.js (100%)
 rename ghost/{ => 0.x}/prism_light.css (100%)
 rename ghost/{ => 0.x}/prism_light.js (100%)
 rename ghost/{ => 0.x}/run.sh (100%)
 rename ghost/{ => 0.x}/smtp.conf (100%)
 create mode 100644 ghost/1.x/Dockerfile
 create mode 100644 ghost/1.x/rootfs/etc/s6.d/.s6-svscan/finish
 create mode 100644 ghost/1.x/rootfs/etc/s6.d/ghost/run
 create mode 100644 ghost/1.x/rootfs/usr/local/bin/run.sh
 create mode 100644 ghost/1.x/rootfs/usr/local/etc/disqus.conf
 create mode 100644 ghost/1.x/rootfs/usr/local/etc/ghost.example.conf
 create mode 100644 ghost/1.x/rootfs/usr/local/etc/isso.conf

diff --git a/ghost/Dockerfile b/ghost/0.x/Dockerfile
similarity index 98%
rename from ghost/Dockerfile
rename to ghost/0.x/Dockerfile
index 8f45fb7..d67516b 100644
--- a/ghost/Dockerfile
+++ b/ghost/0.x/Dockerfile
@@ -1,6 +1,6 @@
 FROM alpine:3.6
 
-ARG GHOST_VERSION=0.11.10
+ARG GHOST_VERSION=0.11.11
 
 ENV GHOST_NODE_VERSION_CHECK=false \
     GID=991 \
diff --git a/ghost/README.md b/ghost/0.x/README.md
similarity index 100%
rename from ghost/README.md
rename to ghost/0.x/README.md
diff --git a/ghost/disqus.conf b/ghost/0.x/disqus.conf
similarity index 100%
rename from ghost/disqus.conf
rename to ghost/0.x/disqus.conf
diff --git a/ghost/isso.conf b/ghost/0.x/isso.conf
similarity index 100%
rename from ghost/isso.conf
rename to ghost/0.x/isso.conf
diff --git a/ghost/prism.css.conf b/ghost/0.x/prism.css.conf
similarity index 100%
rename from ghost/prism.css.conf
rename to ghost/0.x/prism.css.conf
diff --git a/ghost/prism.js.conf b/ghost/0.x/prism.js.conf
similarity index 100%
rename from ghost/prism.js.conf
rename to ghost/0.x/prism.js.conf
diff --git a/ghost/prism_dark.css b/ghost/0.x/prism_dark.css
similarity index 100%
rename from ghost/prism_dark.css
rename to ghost/0.x/prism_dark.css
diff --git a/ghost/prism_dark.js b/ghost/0.x/prism_dark.js
similarity index 100%
rename from ghost/prism_dark.js
rename to ghost/0.x/prism_dark.js
diff --git a/ghost/prism_light.css b/ghost/0.x/prism_light.css
similarity index 100%
rename from ghost/prism_light.css
rename to ghost/0.x/prism_light.css
diff --git a/ghost/prism_light.js b/ghost/0.x/prism_light.js
similarity index 100%
rename from ghost/prism_light.js
rename to ghost/0.x/prism_light.js
diff --git a/ghost/run.sh b/ghost/0.x/run.sh
similarity index 100%
rename from ghost/run.sh
rename to ghost/0.x/run.sh
diff --git a/ghost/smtp.conf b/ghost/0.x/smtp.conf
similarity index 100%
rename from ghost/smtp.conf
rename to ghost/0.x/smtp.conf
diff --git a/ghost/1.x/Dockerfile b/ghost/1.x/Dockerfile
new file mode 100644
index 0000000..c58ffaa
--- /dev/null
+++ b/ghost/1.x/Dockerfile
@@ -0,0 +1,45 @@
+FROM alpine:3.6
+
+ARG VERSION=1.0.0-rc.1
+
+ENV GHOST_NODE_VERSION_CHECK=false \
+    NODE_ENV=production \
+    GID=991 UID=991 \
+    ADDRESS=https://my-ghost-blog.com \
+    ENABLE_ISSO=False \
+    ISSO_HOST=isso.domain.tld \
+    ISSO_AVATAR=false \
+    ISSO_VOTE=false \
+    ENABLE_DISQUS=False \
+    DISQUS_SHORTNAME=shortname
+
+WORKDIR /ghost
+
+RUN apk -U --no-cache add \
+    bash \
+    ca-certificates \
+    grep \
+    libressl \
+    nodejs-current \
+    nodejs-current-npm \
+    s6 \
+    su-exec \
+    vim \
+ && wget -q https://github.com/TryGhost/Ghost/releases/download/${VERSION}/Ghost-${VERSION}.zip -P /tmp \
+ && unzip -q /tmp/Ghost-${VERSION}.zip -d /ghost \
+ && npm install --production \
+ && mv content/themes/casper casper
+
+COPY rootfs /
+
+RUN chmod +x /usr/local/bin/* /etc/s6.d/*/* /etc/s6.d/.s6-svscan/*
+
+EXPOSE 2368
+
+VOLUME /ghost/content
+
+LABEL description="Ghost CMS ${VERSION}" \
+      maintainer="Wonderfall <wonderfall@targaryen.house>"
+
+ENTRYPOINT ["run.sh"]
+CMD ["/bin/s6-svscan", "/etc/s6.d"]
diff --git a/ghost/1.x/rootfs/etc/s6.d/.s6-svscan/finish b/ghost/1.x/rootfs/etc/s6.d/.s6-svscan/finish
new file mode 100644
index 0000000..039e4d0
--- /dev/null
+++ b/ghost/1.x/rootfs/etc/s6.d/.s6-svscan/finish
@@ -0,0 +1,2 @@
+#!/bin/sh
+exit 0
diff --git a/ghost/1.x/rootfs/etc/s6.d/ghost/run b/ghost/1.x/rootfs/etc/s6.d/ghost/run
new file mode 100644
index 0000000..d24cf26
--- /dev/null
+++ b/ghost/1.x/rootfs/etc/s6.d/ghost/run
@@ -0,0 +1,5 @@
+#!/bin/sh
+cd /ghost
+NODE_ENV=development node_modules/.bin/knex-migrator init
+NODE_ENV=development node_modules/.bin/knex-migrator migrate
+exec npm start
diff --git a/ghost/1.x/rootfs/usr/local/bin/run.sh b/ghost/1.x/rootfs/usr/local/bin/run.sh
new file mode 100644
index 0000000..cc9b2b4
--- /dev/null
+++ b/ghost/1.x/rootfs/usr/local/bin/run.sh
@@ -0,0 +1,54 @@
+#!/bin/bash
+echo
+echo ">>> wonderfall/ghost container <<<"
+echo
+
+echo "> Initializing content folder..."
+cd content
+mkdir apps data images themes logs adapters &>/dev/null
+rm -rf /ghost/content/themes/casper &>/dev/null
+cp -r /ghost/casper themes/casper &>/dev/null
+cd /ghost
+
+if [ ! -f /ghost/config.production.json ]; then
+  echo
+  echo "INFO : No configuration file was provided, an example will be used"
+  echo "       You can access and modify it in the volume you mounted"
+  echo "       Restart in order to apply your changes!"
+  echo
+  mv /usr/local/etc/ghost.example.conf /ghost/content/ghost.conf
+  ln -s content/ghost.conf config.production.json
+fi
+
+echo "> Applying preferences..."
+
+sed -i -e "s|https://my-ghost-blog.com|${ADDRESS}|g" /ghost/content/ghost.conf
+
+if [ "$ENABLE_ISSO" == "True" ] && ! grep -q 'isso' /ghost/content/themes/casper/post.hbs; then
+    cd /usr/local/etc
+    sed -i -e "/\/author/r isso.conf" /ghost/content/themes/casper/post.hbs
+    sed -i -e '/isso-thread/{n;d}' /ghost/content/themes/casper/post.hbs
+    sed -i -e "s/<HOST>/$ISSO_HOST/g" \
+           -e "s/<AVATAR>/$ISSO_AVATAR/g" \
+           -e "s/<VOTE>/$ISSO_VOTE/g" /ghost/content/themes/casper/post.hbs
+fi
+
+if [ "$ENABLE_DISQUS" == "True" ] && grep -q 'Disqus comments' /ghost/content/themes/casper/post.hbs; then
+    ### This is crap, if you have a better idea, tell me!
+vim -e - /ghost/content/themes/casper/post.hbs <<@@@
+g/site-id/.-5,.d
+wq
+@@@
+    sed -i '87d' /ghost/content/themes/casper/post.hbs
+    sed -i -e "s/test-apkdzgmqhj/${DISQUS_SHORTNAME}/g" /ghost/content/themes/casper/post.hbs
+fi
+
+echo "> Updating permissions..."
+chown -R ${UID}:${GID} /ghost /etc/s6.d
+
+echo "> Executing process..."
+if [ '$@' == '' ]; then
+    exec su-exec ${UID}:${GID} /bin/s6-svscan /etc/s6.d
+else
+    exec su-exec ${UID}:${GID} "$@"
+fi
diff --git a/ghost/1.x/rootfs/usr/local/etc/disqus.conf b/ghost/1.x/rootfs/usr/local/etc/disqus.conf
new file mode 100644
index 0000000..9b20532
--- /dev/null
+++ b/ghost/1.x/rootfs/usr/local/etc/disqus.conf
@@ -0,0 +1,16 @@
+
+<div id="disqus_thread"></div>
+<script type="text/javascript">
+    var disqus_shortname = '<SHORTNAME>';
+    var disqus_identifier = '{{post.id}}';
+ 
+    /* * * DON'T EDIT BELOW THIS LINE * * */
+    (function() {
+        var dsq = document.createElement('script'); dsq.type = 'text/javascript'; dsq.async = true;
+        dsq.src = '//' + disqus_shortname + '.disqus.com/embed.js';
+        (document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(dsq);
+    })();
+</script>
+<noscript>Please enable JavaScript to view the <a href="http://disqus.com/?ref_noscript">comments powered by Disqus.</a></noscript>
+<a href="http://disqus.com" class="dsq-brlink">comments powered by <span class="logo-disqus">Disqus</span></a>
+
diff --git a/ghost/1.x/rootfs/usr/local/etc/ghost.example.conf b/ghost/1.x/rootfs/usr/local/etc/ghost.example.conf
new file mode 100644
index 0000000..2b01024
--- /dev/null
+++ b/ghost/1.x/rootfs/usr/local/etc/ghost.example.conf
@@ -0,0 +1,21 @@
+{
+  "url": "https://my-ghost-blog.com",
+
+  "server": {
+    "host": "0.0.0.0",
+    "port": "2368"
+  },
+
+  "database": {
+    "client": "sqlite3",
+    "connection": {
+      "filename": "content/data/ghost-dev.db"
+    },
+    "useNullAsDefault": true,
+    "debug": false
+  },
+
+  "mail": {
+    "transport": "Direct"
+  }
+}
diff --git a/ghost/1.x/rootfs/usr/local/etc/isso.conf b/ghost/1.x/rootfs/usr/local/etc/isso.conf
new file mode 100644
index 0000000..4287ebc
--- /dev/null
+++ b/ghost/1.x/rootfs/usr/local/etc/isso.conf
@@ -0,0 +1,7 @@
+</footer>
+<script data-isso="//<HOST>/"
+        data-isso-avatar="<AVATAR>"
+        data-isso-vote="<VOTE>"
+        src="//<HOST>/js/embed.min.js"></script>
+
+<section id="isso-thread"></section>