small refactoring and logging improvements
This commit is contained in:
parent
6894fda5df
commit
09637b4120
36
Dockerfile
36
Dockerfile
@ -9,12 +9,10 @@ RUN yum -y install epel-release && \
|
||||
inotify-tools \
|
||||
glibc-static perl
|
||||
|
||||
# Compile runit and socklog
|
||||
# Compile runit
|
||||
# Deps: glibc-static
|
||||
ENV RUNIT_NAME "runit-2.1.2"
|
||||
ENV RUNIT_HASH "6fd0160cb0cf1207de4e66754b6d39750cff14bb0aa66ab49490992c0c47ba18"
|
||||
ENV SOCKLOG_NAME "socklog-2.1.0"
|
||||
ENV SOCKLOG_HASH "aa869a787ee004da4e5509b5a0031bcc17a4ab4ac650c2ce8d4e488123acb455"
|
||||
|
||||
RUN pushd /opt && \
|
||||
curl -#L -o $RUNIT_NAME.tar.gz http://smarden.org/runit/$RUNIT_NAME.tar.gz && \
|
||||
@ -22,18 +20,22 @@ RUN pushd /opt && \
|
||||
tar xf $RUNIT_NAME.tar.gz && \
|
||||
rm -f $RUNIT_NAME.tar.gz && \
|
||||
pushd admin/$RUNIT_NAME && \
|
||||
find . -xdev -type f -name "fmt_ptime.c" -exec sed -i.orig 's;gmtime;localtime;g' '{}' \; && \
|
||||
package/install && \
|
||||
package/install-man && \
|
||||
popd && \
|
||||
curl -#L -o $SOCKLOG_NAME.tar.gz http://smarden.org/socklog/$SOCKLOG_NAME.tar.gz && \
|
||||
sha256sum $SOCKLOG_NAME.tar.gz |grep -qw $SOCKLOG_HASH && \
|
||||
tar xf $SOCKLOG_NAME.tar.gz && \
|
||||
rm -f $SOCKLOG_NAME.tar.gz && \
|
||||
pushd admin/$SOCKLOG_NAME && \
|
||||
package/install && \
|
||||
package/install-man && \
|
||||
popd && \
|
||||
popd
|
||||
package/install-man
|
||||
|
||||
# Compile socklog
|
||||
#ENV SOCKLOG_NAME "socklog-2.1.0"
|
||||
#ENV SOCKLOG_HASH "aa869a787ee004da4e5509b5a0031bcc17a4ab4ac650c2ce8d4e488123acb455"
|
||||
|
||||
#RUN pushd /opt && \
|
||||
# curl -#L -o $SOCKLOG_NAME.tar.gz http://smarden.org/socklog/$SOCKLOG_NAME.tar.gz && \
|
||||
# sha256sum $SOCKLOG_NAME.tar.gz |grep -qw $SOCKLOG_HASH && \
|
||||
# tar xf $SOCKLOG_NAME.tar.gz && \
|
||||
# rm -f $SOCKLOG_NAME.tar.gz && \
|
||||
# pushd admin/$SOCKLOG_NAME && \
|
||||
# package/install && \
|
||||
# package/install-man
|
||||
|
||||
|
||||
# runit-docker - painlessly use Runit in Docker containers
|
||||
@ -63,7 +65,7 @@ RUN curl -#L -o $OPENSSL_NAME.tar.gz https://www.openssl.org/source/$OPENSSL_NAM
|
||||
|
||||
|
||||
# Compile nginx
|
||||
# Deps: make gcc openssl-devel(* custom now!) pcre-devel zlib-devel
|
||||
# Deps: make gcc pcre-devel zlib-devel
|
||||
ENV NGINX_NAME "nginx-1.10.1"
|
||||
ENV NGINX_GPGKEY_FP "B0F4253373F8F6F510D42178520A9993A1C052F8"
|
||||
|
||||
@ -119,6 +121,8 @@ RUN useradd -u 1000 -d /var/lib/nginx -s /sbin/nologin nginx && \
|
||||
|
||||
COPY nginx.conf /etc/nginx/nginx.conf
|
||||
COPY service /etc/service/
|
||||
RUN chmod +x -- /etc/service/*/run
|
||||
RUN chmod +x -- /etc/service/*/run /etc/service/*/log/run
|
||||
|
||||
ENTRYPOINT ["/sbin/runit-docker"]
|
||||
VOLUME ["/var/log/nginx"]
|
||||
EXPOSE 80 443
|
||||
|
@ -1,5 +1,5 @@
|
||||
daemon off;
|
||||
error_log stderr info;
|
||||
error_log /dev/stdout info;
|
||||
user nginx;
|
||||
worker_processes 1;
|
||||
pid /var/run/nginx.pid;
|
||||
@ -15,7 +15,7 @@ http {
|
||||
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
|
||||
'$status $body_bytes_sent "$http_referer" '
|
||||
'"$http_user_agent" "$http_x_forwarded_for"';
|
||||
access_log /var/log/nginx/access.log main;
|
||||
access_log /dev/stdout main;
|
||||
|
||||
sendfile on;
|
||||
keepalive_timeout 65;
|
||||
|
@ -1,11 +0,0 @@
|
||||
#!/bin/sh
|
||||
# Collect all logs which come to /dev/log
|
||||
exec 2>&1
|
||||
echo $(realpath $0) started
|
||||
|
||||
set -x
|
||||
touch /var/log/nginx/access.log /var/log/nginx/error.log
|
||||
exec tail -f /var/log/nginx/access.log /var/log/nginx/error.log
|
||||
# exec chpst -Unobody socklog unix /dev/log
|
||||
# exec socklog unix /dev/log
|
||||
# exec socat UNIX-LISTEN:/dev/log,reuseaddr,fork -
|
10
service/nginx/log/run
Normal file
10
service/nginx/log/run
Normal file
@ -0,0 +1,10 @@
|
||||
#!/bin/sh
|
||||
# file: nginx/log/run
|
||||
|
||||
# Collect all logs which come to stdout from the app
|
||||
exec 2>&1
|
||||
echo $(realpath $0) started
|
||||
|
||||
mkdir /var/log/nginx 2>/dev/null
|
||||
|
||||
exec svlogd -tt /var/log/nginx
|
@ -1,4 +1,6 @@
|
||||
#!/bin/sh
|
||||
# file: nginx/run
|
||||
|
||||
exec 2>&1
|
||||
echo $(realpath $0) started
|
||||
|
||||
|
12
service/showlog/run
Executable file
12
service/showlog/run
Executable file
@ -0,0 +1,12 @@
|
||||
#!/bin/sh
|
||||
# file: showlog/run
|
||||
|
||||
# Make the logs visible on `docker logs` command
|
||||
exec 2>&1
|
||||
echo $(realpath $0) started
|
||||
|
||||
# A little timeout is required, since svlogd moves current log to an archive,
|
||||
# and only after that it starts logging to the "new" current log.
|
||||
sleep 2
|
||||
|
||||
exec tail -f /var/log/nginx/current 2>/dev/null
|
Loading…
Reference in New Issue
Block a user