Commit 0520345d authored by rg's avatar rg

Peaufinage.

parent d34701fe
......@@ -15,6 +15,7 @@ services:
- MAPS_TOKEN=${MAPS_TOKEN:--}
- USE_CACHE=${USE_CACHE:-false}
- URL_DOWNLOADMAP=${URL_DOWNLOADMAP:--}
- USE_MAP=${USE_MAP:--}
ports:
- "${HTTP_PORT:-80}:80"
- "${HTTPS_PORT:-443}:443"
......
......@@ -11,7 +11,8 @@ RUN apt-get update && \
#apt-get update; \
apt-get -y install nginx python-certbot-nginx munin logrotate;
RUN mkdir -p /home/www/letsencrypt /home/maps;
RUN mkdir -p /home/www/letsencrypt /home/maps; \
rm -f /etc/nginx/sites-enabled/*;
ARG URL_DOWNLOADMAP={$URL_DOWNLOADMAP:--}
......@@ -36,6 +37,9 @@ ARG MAPS_TOKEN=${MAPS_TOKEN:--}
ENV MAPS_TOKEN=$MAPS_TOKEN
ARG USE_MAP=${USE_MAP:--}
ENV USE_MAP=$USE_MAP
ARG INIT_NGINX=/tmp/init_nginx.sh
ENV INIT_NGINX=$INIT_NGINX
RUN echo 'DOMAIN=$1; shift; USE_CACHE=$1; shift; SSL=$1; shift; SSL_LETSENCRYPTMAIL=$1; shift; MAPS_TOKEN=$1; shift;' >>$INIT_NGINX; \
......@@ -71,7 +75,7 @@ RUN echo 'DOMAIN=$1; shift; USE_CACHE=$1; shift; SSL=$1; shift; SSL_LETSENCRYPTM
echo 'fi' >>$INIT_NGINX; \
echo '[ "$MAPS_TOKEN" = "-" ] && MAPS_TOKEN=`echo $RANDOM$RANDOM£RANDOM$RANDOM | sha256sum | cut -d " " -f 1`' >>$INIT_NGINX; \
echo '[[ "$USE_CACHE" =~ false|^$ ]] && PROXY_NO_CACHE=1 || PROXY_NO_CACHE=0' >>$INIT_NGINX; \
echo '[[ ! "$USE_CACHE" =~ true|false|^$ ]] && CACHE=$USE_CACHE || CACHE="300m"' >>$INIT_NGINX; \
echo '[[ ! "$USE_CACHE" =~ true|false|^$ ]] && CACHE=$USE_CACHE || CACHE="500m"' >>$INIT_NGINX; \
echo 'echo "Cache: $CACHE => $PROXY_NO_CACHE"' >>$INIT_NGINX; \
echo 'CONF=${CONF//\\{LISTEN\\}/$LISTEN}' >>$INIT_NGINX; \
echo 'CONF=${CONF//\\{NGINX_BALANCERLIST\\}/$TEMP}' >>$INIT_NGINX; \
......@@ -89,7 +93,8 @@ ENV INIT_DOWNLOAD=$INIT_DOWNLOAD
RUN echo 'for url in $@; do' >>$INIT_DOWNLOAD; \
echo ' echo "*** downloading: $url ***"' >>$INIT_DOWNLOAD; \
echo ' if [[ "$url" =~ ^.*/(.*\.mbtiles)$ ]]; then' >>$INIT_DOWNLOAD; \
echo ' FILE="/data/${BASH_REMATCH[1]}";' >>$INIT_DOWNLOAD; \
echo ' LAST_USEMAP="${BASH_REMATCH[1]}";' >>$INIT_DOWNLOAD; \
echo ' FILE="/data/$LAST_USEMAP";' >>$INIT_DOWNLOAD; \
echo ' [[ `wget --spider --server-response "$url" 2>&1 | grep "Content-Length"` =~ ^.*:[[:space:]]([[:digit:]]+)$ ]] && REMOTE_MAP_SIZE=${BASH_REMATCH[1]} || REMOTE_MAP_SIZE=0;' >>$INIT_DOWNLOAD; \
echo ' [ ! -f $FILE ] || [ `stat -c%s $FILE` -ne $REMOTE_MAP_SIZE ] && [ $REMOTE_MAP_SIZE -ne 0 ] && wget "$url" -O $FILE' >>$INIT_DOWNLOAD; \
echo ' fi' >>$INIT_DOWNLOAD; \
......@@ -112,10 +117,12 @@ RUN echo 'chown -R root: /var/cache/nginx /etc/nginx/ssl' >>$INIT; \
echo ' PORT=8080' >>$INIT; \
echo ' [ "BALANCER_IPLIST" = "" ] && BALANCER_IPLIST="127.0.0.1"' >>$INIT; \
echo ' [[ " $BALANCER_IPLIST " =~ " 127.0.0.1 " ]] && LOCAL_NODE="true" || LOCAL_NODE="false"' >>$INIT; \
echo ' [ "$URL_DOWNLOADMAP" != "-" ] && /bin/bash $INIT_DOWNLOAD $URL_DOWNLOADMAP' >>$INIT; \
echo ' [[ "$URL_DOWNLOADMAP" =~ ^.*/(.*\.mbtiles)$ ]] && LAST_USEMAP="--mbtiles ${BASH_REMATCH[1]}" && /bin/bash $INIT_DOWNLOAD $URL_DOWNLOADMAP' >>$INIT; \
echo ' /bin/bash $INIT_NGINX "$DOMAIN" "$USE_CACHE" "$SSL" "$SSL_LETSENCRYPTMAIL" "$MAPS_TOKEN" $BALANCER_IPLIST' >>$INIT; \
echo 'fi' >>$INIT; \
echo '[ "$LOCAL_NODE" = "true" ] && /bin/bash /usr/src/app/run.sh -p $PORT' >>$INIT; \
echo '[[ "$USE_MAP" =~ ^-$|^$ ]] && USE_MAP=$LAST_USEMAP || USE_MAP="--mbtiles $USE_MAP"' >>$INIT; \
echo 'echo "last map: #$LAST_USEMAP#; use map: #$USE_MAP#"' >>$INIT; \
echo '[ "$LOCAL_NODE" = "true" ] && /bin/bash /usr/src/app/run.sh -p $PORT $USE_MAP' >>$INIT; \
echo 'sleep infinity' >>$INIT;
#Pour logrotate
......@@ -123,9 +130,10 @@ RUN echo -e '#!/bin/sh\nexit 0' > /usr/sbin/policy-rc.d;
ENV TZ Europe/Paris
ENTRYPOINT
WORKDIR /etc/nginx/conf.d
CMD /bin/bash $INIT
#bash /tmp/init.sh "$DOMAIN" "$SSL" "$SSL_LETSENCRYPTMAIL" "$MAPS_TOKEN" $BALANCER_IPLIST; \
ENTRYPOINT /bin/bash $INIT
#CMD /bin/bash $INIT
......@@ -47,7 +47,7 @@ server {
}
server {
listen 90;
listen 80;
return 301 https://{DOMAIN}$request_uri;
}
\ No newline at end of file
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment