From c85f68948ae16568a634ef4e3eea82f4170fb6a7 Mon Sep 17 00:00:00 2001 From: Vincent Giersch Date: Thu, 16 Oct 2014 21:24:52 +0200 Subject: [PATCH] Run image as "ghost" - Faster start: chown ghost sources in docker layer - Create /ghost-override volume directory in layer - Remove unused cd (WORKDIR is already /ghost) Signed-off-by: Vincent Giersch --- Dockerfile | 7 ++++++- start.bash | 6 ------ 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/Dockerfile b/Dockerfile index ebb01c32..81b64387 100644 --- a/Dockerfile +++ b/Dockerfile @@ -16,7 +16,9 @@ RUN \ cd /ghost && \ npm install --production && \ sed 's/127.0.0.1/0.0.0.0/' /ghost/config.example.js > /ghost/config.js && \ - useradd ghost --home /ghost + mkdir /ghost-override && \ + useradd ghost --home /ghost && \ + chown -R ghost:ghost /ghost /ghost-override /data # Add files. ADD start.bash /ghost-start @@ -33,5 +35,8 @@ WORKDIR /ghost # Define default command. CMD ["bash", "/ghost-start"] +# Run as ghost +USER ghost + # Expose ports. EXPOSE 2368 diff --git a/start.bash b/start.bash index a5fad241..523dc424 100644 --- a/start.bash +++ b/start.bash @@ -8,8 +8,6 @@ DATA="content/data" IMAGES="content/images" THEMES="content/themes" -cd "$GHOST" - # Symlink data directory. mkdir -p "$OVERRIDE/$DATA" rm -fr "$DATA" @@ -36,8 +34,4 @@ if [[ -d "$OVERRIDE/$THEMES" ]]; then fi # Start Ghost -chown -R ghost:ghost /data /ghost /ghost-override -su ghost << EOF -cd "$GHOST" NODE_ENV=${NODE_ENV:-production} npm start -EOF