Skip to content

Commit 4b2ca98

Browse files
build(docker): do not run with root user (#330)
1 parent 85f05b9 commit 4b2ca98

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

Dockerfile

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,12 +37,12 @@ targets=(
3737
for base_dir in "${base_dirs[@]}"; do
3838
for target in "${targets[@]}"; do
3939
if [ -e "$base_dir/$target" ]; then
40-
cp -rf "$base_dir/$target" ${TMPDIR}/
40+
cp -rf "$base_dir/$target" "${TMPDIR}/"
4141
fi
4242
done
4343
done
4444

45-
cp -RTf ./ ${TMPDIR}/
45+
cp -RTf ./ "${TMPDIR}/"
4646

4747
_SITE
4848

@@ -68,8 +68,14 @@ RUN <<_SETUP
6868
set -e
6969

7070
bundle install
71+
72+
# Create a non-root user and transfer ownership
73+
useradd --no-create-home --shell /bin/bash jekyll
74+
chown -R jekyll:jekyll /app
7175
_SETUP
7276

77+
USER jekyll
78+
7379
# Expose the port that Jekyll will run on
7480
EXPOSE 4000
7581

0 commit comments

Comments
 (0)