Skip to content

Commit

Permalink
Merge pull request #2877 from aledbf/change-starup
Browse files Browse the repository at this point in the history
Refactor entrypoint to avoid issues with volumes
  • Loading branch information
k8s-ci-robot authored Jul 30, 2018
2 parents 71abdf7 + 69a2a27 commit 06db4b0
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 16 deletions.
19 changes: 19 additions & 0 deletions rootfs/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,25 @@ RUN clean-install \

COPY . /

# Fix permission during the build to avoid issues at runtime
# with volumes (custom templates)
RUN bash -eux -c ' \
writeDirs=( \
/etc/nginx/template \
/etc/ingress-controller/ssl \
/etc/ingress-controller/auth \
/var/log \
/var/log/nginx \
/tmp \
); \
for dir in "${writeDirs[@]}"; do \
mkdir -p ${dir}; \
chown -R www-data.www-data ${dir}; \
done' \
&& chown www-data.www-data /etc/nginx/nginx.conf \
&& chown www-data.www-data /etc/nginx/opentracing.json \
&& chown www-data.www-data /etc/nginx

ENTRYPOINT ["/entrypoint.sh"]

CMD ["/nginx-ingress-controller"]
24 changes: 8 additions & 16 deletions rootfs/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,32 +16,24 @@

set -e

mkdir -p /var/log/nginx
echo 0 > /tmp/nginx.pid
# fix directory permissions
writeDirs=( \
/etc/nginx/template \
/etc/ingress-controller/ssl \
/etc/ingress-controller/auth \
/var/log \
/var/log/nginx \
/tmp \
/var/log
/var/log/nginx
/tmp
);

for dir in "${writeDirs[@]}"; do
for dir in "${writeDirs[@]}";do
mkdir -p ${dir};
chown -R www-data.www-data ${dir};
done

ln -sf /dev/stdout /var/log/nginx/access.log
ln -sf /dev/stderr /var/log/nginx/error.log

ln -sf /dev/stdout /var/log/nginx/access.log
ln -sf /dev/stderr /var/log/nginx/error.log
chown www-data.www-data /var/log/nginx/*
chown www-data.www-data /etc/nginx/nginx.conf
chown www-data.www-data /etc/nginx/opentracing.json
chown www-data.www-data /etc/nginx

echo "Testing if setcap is supported..."
if test 'setcap cap_net_bind_service=+ep /usr/sbin/nginx'; then
if setcap cap_net_bind_service=+ep /usr/sbin/nginx; then
echo "setcap is supported. Setting cap_net_bind_service=+ep to allow binding port lower than 1024 as non-root"
setcap cap_net_bind_service=+ep /usr/sbin/nginx
setcap -v cap_net_bind_service=+ep /usr/sbin/nginx
Expand Down

0 comments on commit 06db4b0

Please sign in to comment.