1
0
mirror of https://github.com/vimagick/dockerfiles.git synced 2024-11-30 09:16:41 +02:00

upgrade ghost to 1.5.0

This commit is contained in:
kev 2017-08-06 10:34:48 +08:00
parent a918a3a930
commit 1637bd6e7b
5 changed files with 44 additions and 43 deletions

View File

@ -11,7 +11,7 @@ ghost:
ports:
- "127.0.0.1:2368:2368"
volumes:
- ./data:/var/lib/ghost
- ./data:/var/lib/ghost/content
restart: always
```

View File

@ -5,32 +5,34 @@
FROM easypi/alpine-arm
MAINTAINER EasyPi Software Foundation
ENV GHOST_VER 0.11.9
ENV GHOST_URL https://github.com/TryGhost/Ghost/releases/download/$GHOST_VER/Ghost-$GHOST_VER.zip
ENV GHOST_SOURCE /usr/src/ghost
ENV GHOST_CONTENT /var/lib/ghost
ENV GHOST_VERSION 1.5.0
ENV GHOST_INSTALL /var/lib/ghost
ENV GHOST_CONTENT /var/lib/ghost/content
ENV GHOST_CLI_VERSION 1.0.3
ENV NPM_CONFIG_LOGLEVEL warn
ENV NODE_ENV production
WORKDIR $GHOST_SOURCE
RUN set -xe \
&& addgroup -g 1000 node \
&& adduser -u 1000 -G node -s /bin/sh -D node \
&& apk add --no-cache bash build-base nodejs nodejs-npm python su-exec \
&& npm install -g --unsafe-perm ghost-cli@$GHOST_CLI_VERSION knex-migrator@latest \
&& mkdir -p $GHOST_INSTALL \
&& chown node:node $GHOST_INSTALL \
&& su-exec node ghost install $GHOST_VERSION --db sqlite3 --no-prompt --no-stack --no-setup --dir $GHOST_INSTALL \
&& cd $GHOST_INSTALL \
&& su-exec node ghost config --ip 0.0.0.0 --port 2368 --no-prompt --db sqlite3 --url http://localhost:2368 --dbpath $GHOST_CONTENT/data/ghost.db \
&& su-exec node ghost config paths.contentPath $GHOST_CONTENT \
&& mv $GHOST_CONTENT $GHOST_INSTALL/content.orig \
&& mkdir -p $GHOST_CONTENT \
&& chown node:node $GHOST_CONTENT \
&& apk del build-base python
WORKDIR $GHOST_INSTALL
VOLUME $GHOST_CONTENT
RUN set -ex \
&& apk add -U bash \
nodejs \
nodejs-npm \
&& apk add -t TMP build-base \
curl \
python \
&& curl -sSL $GHOST_URL -o ghost.zip \
&& unzip ghost.zip \
&& npm install --production \
&& npm cache clean \
&& apk del TMP \
&& rm -rf ghost.zip \
/tmp/npm* \
/var/cache/apk/*
COPY docker-entrypoint.sh /entrypoint.sh
ENTRYPOINT ["/entrypoint.sh"]
COPY docker-entrypoint.sh /usr/local/bin
ENTRYPOINT ["docker-entrypoint.sh"]
EXPOSE 2368
CMD ["npm", "start"]
CMD ["node", "current/index.js"]

View File

@ -3,5 +3,5 @@ ghost:
ports:
- "127.0.0.1:2368:2368"
volumes:
- ./data:/var/lib/ghost
- ./data:/var/lib/ghost/content
restart: always

View File

@ -1,25 +1,24 @@
#!/bin/bash
set -e
if [[ "$*" == npm*start* ]]; then
for dir in "$GHOST_SOURCE/content"/*/; do
targetDir="$GHOST_CONTENT/$(basename "$dir")"
mkdir -p "$targetDir"
if [ -z "$(ls -A "$targetDir")" ]; then
tar cC "$dir" . | tar xC "$targetDir"
# allow the container to be started with `--user`
if [[ "$*" == node*current/index.js* ]] && [ "$(id -u)" = '0' ]; then
chown -R node "$GHOST_CONTENT"
exec su-exec node "$BASH_SOURCE" "$@"
fi
if [[ "$*" == node*current/index.js* ]]; then
baseDir="$GHOST_INSTALL/content.orig"
for src in "$baseDir"/*/ "$baseDir"/themes/*; do
src="${src%/}"
target="$GHOST_CONTENT/${src#$baseDir/}"
mkdir -p "$(dirname "$target")"
if [ ! -e "$target" ]; then
tar -cC "$(dirname "$src")" "$(basename "$src")" | tar -xC "$(dirname "$target")"
fi
done
if [ ! -e "$GHOST_CONTENT/config.js" ]; then
sed -r '
s/127\.0\.0\.1/0.0.0.0/g;
s!path.join\(__dirname, (.)/content!path.join(process.env.GHOST_CONTENT, \1!g;
' "$GHOST_SOURCE/config.example.js" > "$GHOST_CONTENT/config.js"
fi
ln -sf "$GHOST_CONTENT/config.js" "$GHOST_SOURCE/config.js"
exec "$@"
knex-migrator-migrate --init --mgpath "$GHOST_INSTALL/current"
fi
exec "$@"

View File

@ -3,5 +3,5 @@ ghost:
ports:
- "127.0.0.1:2368:2368"
volumes:
- ./data:/var/lib/ghost
- ./data:/var/lib/ghost/content
restart: always