Merge pull request #2877 from aledbf/change-starup

Refactor entrypoint to avoid issues with volumes
This commit is contained in:
k8s-ci-robot 2018-07-30 13:54:56 -07:00 committed by GitHub
commit 06db4b01a2
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 27 additions and 16 deletions

View file

@ -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"]

View file

@ -16,17 +16,13 @@
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
mkdir -p ${dir};
chown -R www-data.www-data ${dir};
@ -34,14 +30,10 @@ done
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