Skip to content

Commit 46432ab

Browse files
authored
Merge pull request #54 from infosiftr/any-user
Allow arbitrary --user values
2 parents 4afb4db + 3aae08a commit 46432ab

File tree

2 files changed

+12
-7
lines changed

2 files changed

+12
-7
lines changed

Dockerfile

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,12 @@ RUN buildDeps=' \
3838
&& rm -rf /tmp/npm*
3939

4040
ENV GHOST_CONTENT /var/lib/ghost
41-
RUN mkdir -p "$GHOST_CONTENT" && chown -R user:user "$GHOST_CONTENT"
41+
RUN mkdir -p "$GHOST_CONTENT" \
42+
&& chown -R user:user "$GHOST_CONTENT" \
43+
# Ghost expects "config.js" to be in $GHOST_SOURCE, but it's more useful for
44+
# image users to manage that as part of their $GHOST_CONTENT volume, so we
45+
# symlink.
46+
&& ln -s "$GHOST_CONTENT/config.js" "$GHOST_SOURCE/config.js"
4247
VOLUME $GHOST_CONTENT
4348

4449
COPY docker-entrypoint.sh /entrypoint.sh

docker-entrypoint.sh

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
11
#!/bin/bash
22
set -e
33

4+
# allow the container to be started with `--user`
5+
if [[ "$*" == npm*start* ]] && [ "$(id -u)" = '0' ]; then
6+
chown -R user "$GHOST_CONTENT"
7+
exec gosu user "$BASH_SOURCE" "$@"
8+
fi
9+
410
if [[ "$*" == npm*start* ]]; then
511
baseDir="$GHOST_SOURCE/content"
612
for dir in "$baseDir"/*/ "$baseDir"/themes/*/; do
@@ -17,12 +23,6 @@ if [[ "$*" == npm*start* ]]; then
1723
s!path.join\(__dirname, (.)/content!path.join(process.env.GHOST_CONTENT, \1!g;
1824
' "$GHOST_SOURCE/config.example.js" > "$GHOST_CONTENT/config.js"
1925
fi
20-
21-
ln -sf "$GHOST_CONTENT/config.js" "$GHOST_SOURCE/config.js"
22-
23-
chown -R user "$GHOST_CONTENT"
24-
25-
set -- gosu user "$@"
2626
fi
2727

2828
exec "$@"

0 commit comments

Comments
 (0)