From 7c74c87d2bbef6714dfd0216208d93687f767c2c Mon Sep 17 00:00:00 2001 From: Robert Date: Sat, 1 Nov 2014 15:10:44 +0100 Subject: [PATCH 1/8] Changed Run skript to allow for content directory persistence Added Additional Volume to allow the mapping of the content DIR to the host System Changed Readme to reflect other changes --- Dockerfile | 5 ++++- README.md | 20 ++++++++++++-------- config.js | 3 +++ run | 3 +++ 4 files changed, 22 insertions(+), 9 deletions(-) diff --git a/Dockerfile b/Dockerfile index b74691e..8e6768b 100644 --- a/Dockerfile +++ b/Dockerfile @@ -5,7 +5,7 @@ RUN apt-get update -qq && apt-get install -qy python-software-properties RUN add-apt-repository ppa:chris-lea/node.js RUN echo "deb http://archive.ubuntu.com/ubuntu precise main universe" > /etc/apt/sources.list RUN apt-get -qq update && apt-get install -qy sudo curl unzip nodejs -RUN curl -L https://en.ghost.org/zip/ghost-0.5.0.zip > /tmp/ghost.zip +RUN curl -L https://en.ghost.org/zip/ghost-0.5.3.zip > /tmp/ghost.zip RUN useradd ghost RUN mkdir -p /opt/ghost WORKDIR /opt/ghost @@ -16,6 +16,9 @@ RUN npm install --production RUN mkdir /data VOLUME ["/data"] +RUN mkdir /ghostcontent +VOLUME ["/ghostcontent"] + ADD run /usr/local/bin/run ADD config.js /opt/ghost/config.js RUN chown -R ghost:ghost /opt/ghost diff --git a/README.md b/README.md index 565605d..17adfad 100644 --- a/README.md +++ b/README.md @@ -1,11 +1,21 @@ docker-ghost ============ +Build from this repository +-------------------------- + $ git clone https://github.com/atroo/docker-ghost.git + $ docker build -t="docker-ghost" . + + Run [Ghost](http://ghost.org) with Docker: - $ docker run -d -p 2368:2368 -e GHOST_URL=http://my-ghost-blog.com orchardup/ghost + $ docker run -d -p 2368:2368 --name ghost \ + -e GHOST_URL=http://www.atroo.de \ + -v /opt/ghost/content:/ghostcontent \ + -v /opt/ghost/data:/data \ + docker-ghost -Your Ghost blog will be running on [http://127.0.0.1:2368](http://127.0.0.1:2368). +Your Ghost blog will be running on [http://127.0.0.1:2368](http://127.0.0.1:2368). And the database will be persisted to /opt/ghost/data while the uploaded content and your themes are going to reside in /opt/ghost/content. Those two directory can be configured at will, just map them to /ghostcontent and /data . Running on Orchard @@ -26,9 +36,3 @@ This image can be configured with environment variables: - `GHOST_URL`: The url to use when providing links to the site, E.g. in RSS and email. -Caveats -------- - -You will lose your uploads if you upgrade Ghost by replacing the image. This is because there is no way of specifying an upload directory for Ghost yet, but [they're working on it](https://github.com/TryGhost/Ghost/issues/635). The database is saved in a volume called `/data` so it will persist just fine. - - diff --git a/config.js b/config.js index 102873a..8e2b4a6 100644 --- a/config.js +++ b/config.js @@ -23,6 +23,9 @@ config = { host: '0.0.0.0', // Port to be passed to node's `net.Server#listen()`, for iisnode set this to `process.env.PORT` port: '2368' + }, + paths: { + contentPath: path.join('/ghostcontent') } } }; diff --git a/run b/run index 4604568..d114ee7 100755 --- a/run +++ b/run @@ -1,5 +1,8 @@ #!/bin/bash +cp /opt/ghost/content/* /ghostcontent -rf +rm -rf /opt/ghost/content set -e chown -R ghost:ghost /data +chown -R ghost:ghost /ghostcontent exec sudo -E -u ghost npm start From 4af6eebb1ee262cc24d8d8964c6f841255b50ed3 Mon Sep 17 00:00:00 2001 From: atroo Date: Fri, 12 Dec 2014 13:57:46 +0100 Subject: [PATCH 2/8] Update README.md --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 17adfad..a6311c4 100644 --- a/README.md +++ b/README.md @@ -4,6 +4,7 @@ docker-ghost Build from this repository -------------------------- $ git clone https://github.com/atroo/docker-ghost.git + $ cd docker-ghost $ docker build -t="docker-ghost" . From 88d9fb569b5b1dd12e04f963505262ddc12943d9 Mon Sep 17 00:00:00 2001 From: phal0r Date: Sat, 17 Jan 2015 19:01:04 +0100 Subject: [PATCH 3/8] changed dockerfile to expose the whole ghost folder and not only data and content --- Dockerfile | 11 +++++++---- config.js | 4 ++-- run | 9 +++++---- 3 files changed, 14 insertions(+), 10 deletions(-) diff --git a/Dockerfile b/Dockerfile index 8e6768b..53600af 100644 --- a/Dockerfile +++ b/Dockerfile @@ -13,11 +13,14 @@ RUN unzip /tmp/ghost.zip RUN npm install --production # Volumes -RUN mkdir /data -VOLUME ["/data"] +# RUN mkdir /data +# VOLUME ["/data"] -RUN mkdir /ghostcontent -VOLUME ["/ghostcontent"] + +# RUN mkdir /ghostcontent +# VOLUME ["/ghostcontent"] + +VOLUME ["/"] ADD run /usr/local/bin/run ADD config.js /opt/ghost/config.js diff --git a/config.js b/config.js index 8e2b4a6..d815b69 100644 --- a/config.js +++ b/config.js @@ -14,7 +14,7 @@ config = { database: { client: 'sqlite3', connection: { - filename: '/data/ghost.db' + filename: '/content/data/ghost.db' }, debug: false }, @@ -25,7 +25,7 @@ config = { port: '2368' }, paths: { - contentPath: path.join('/ghostcontent') + contentPath: path.join('/content') } } }; diff --git a/run b/run index d114ee7..a2cc11a 100755 --- a/run +++ b/run @@ -1,8 +1,9 @@ #!/bin/bash -cp /opt/ghost/content/* /ghostcontent -rf -rm -rf /opt/ghost/content +# cp /opt/ghost/content/* /ghostcontent -rf +# rm -rf /opt/ghost/content set -e -chown -R ghost:ghost /data -chown -R ghost:ghost /ghostcontent +# chown -R ghost:ghost /data +# chown -R ghost:ghost /ghostcontent +chown -R ghost:ghost / exec sudo -E -u ghost npm start From afa8abdaad391605878be0a265094c8a9557cd6f Mon Sep 17 00:00:00 2001 From: phal0r Date: Sat, 17 Jan 2015 19:36:23 +0100 Subject: [PATCH 4/8] changed exposed volume to absolute path --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 53600af..6bba9e9 100644 --- a/Dockerfile +++ b/Dockerfile @@ -20,7 +20,7 @@ RUN npm install --production # RUN mkdir /ghostcontent # VOLUME ["/ghostcontent"] -VOLUME ["/"] +VOLUME ["/opt/ghost"] ADD run /usr/local/bin/run ADD config.js /opt/ghost/config.js From 2bc61aa0b486f2beb795c0d533f1abb05d15cacf Mon Sep 17 00:00:00 2001 From: phal0r Date: Sat, 17 Jan 2015 19:46:53 +0100 Subject: [PATCH 5/8] changed chown to ghost directory --- run | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/run b/run index a2cc11a..3e6b31f 100755 --- a/run +++ b/run @@ -4,6 +4,6 @@ set -e # chown -R ghost:ghost /data # chown -R ghost:ghost /ghostcontent -chown -R ghost:ghost / +chown -R ghost:ghost /opt/ghost exec sudo -E -u ghost npm start From dde12aeb582a04455515f4c01895d4786899cdca Mon Sep 17 00:00:00 2001 From: phal0r Date: Sat, 17 Jan 2015 20:07:04 +0100 Subject: [PATCH 6/8] copy ghost app to target directory after container is started to prevent exposing problems --- Dockerfile | 3 ++- run | 4 +++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index 6bba9e9..e16be80 100644 --- a/Dockerfile +++ b/Dockerfile @@ -8,8 +8,9 @@ RUN apt-get -qq update && apt-get install -qy sudo curl unzip nodejs RUN curl -L https://en.ghost.org/zip/ghost-0.5.3.zip > /tmp/ghost.zip RUN useradd ghost RUN mkdir -p /opt/ghost +RUN kmdir -p /opt/ghost-temp WORKDIR /opt/ghost -RUN unzip /tmp/ghost.zip +RUN unzip /tmp/ghost.zip -d /opt/ghost-temp RUN npm install --production # Volumes diff --git a/run b/run index 3e6b31f..5e6e6af 100755 --- a/run +++ b/run @@ -1,7 +1,9 @@ #!/bin/bash # cp /opt/ghost/content/* /ghostcontent -rf +cp /opt/ghost-temp/* /opt/ghost -rf +rm -rf /opt/ghost-temp # rm -rf /opt/ghost/content -set -e +# set -e # chown -R ghost:ghost /data # chown -R ghost:ghost /ghostcontent chown -R ghost:ghost /opt/ghost From 8636c5fa9893838e17617e179a16d5630f547290 Mon Sep 17 00:00:00 2001 From: root Date: Sat, 17 Jan 2015 20:28:17 +0100 Subject: [PATCH 7/8] exposed whole ghost dir and moved copy command to run script to prevent problems with exposed volumes --- Dockerfile | 10 ++++++---- config.js | 4 ++-- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/Dockerfile b/Dockerfile index e16be80..32a9661 100644 --- a/Dockerfile +++ b/Dockerfile @@ -8,9 +8,9 @@ RUN apt-get -qq update && apt-get install -qy sudo curl unzip nodejs RUN curl -L https://en.ghost.org/zip/ghost-0.5.3.zip > /tmp/ghost.zip RUN useradd ghost RUN mkdir -p /opt/ghost -RUN kmdir -p /opt/ghost-temp -WORKDIR /opt/ghost -RUN unzip /tmp/ghost.zip -d /opt/ghost-temp +RUN mkdir -p /opt/ghost-temp +WORKDIR /opt/ghost-temp +RUN unzip /tmp/ghost.zip RUN npm install --production # Volumes @@ -24,9 +24,11 @@ RUN npm install --production VOLUME ["/opt/ghost"] ADD run /usr/local/bin/run -ADD config.js /opt/ghost/config.js +ADD config.js /opt/ghost-temp/config.js RUN chown -R ghost:ghost /opt/ghost +WORKDIR /opt/ghost + ENV NODE_ENV production ENV GHOST_URL http://my-ghost-blog.com EXPOSE 2368 diff --git a/config.js b/config.js index d815b69..7e05c69 100644 --- a/config.js +++ b/config.js @@ -14,7 +14,7 @@ config = { database: { client: 'sqlite3', connection: { - filename: '/content/data/ghost.db' + filename: 'content/data/ghost.db' }, debug: false }, @@ -25,7 +25,7 @@ config = { port: '2368' }, paths: { - contentPath: path.join('/content') + contentPath: path.join('content') } } }; From 42a55cea20d4544b2796bc0b0292800b7344fabb Mon Sep 17 00:00:00 2001 From: root Date: Sat, 17 Jan 2015 21:22:21 +0100 Subject: [PATCH 8/8] ony delete temp folder on first start --- run | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/run b/run index 5e6e6af..b694802 100755 --- a/run +++ b/run @@ -1,7 +1,10 @@ #!/bin/bash # cp /opt/ghost/content/* /ghostcontent -rf -cp /opt/ghost-temp/* /opt/ghost -rf -rm -rf /opt/ghost-temp + +if [ -d /opt/ghost-temp ]; then + cp /opt/ghost-temp/* /opt/ghost -rf + rm -rf /opt/ghost-temp +fi # rm -rf /opt/ghost/content # set -e # chown -R ghost:ghost /data