-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile_root
42 lines (40 loc) · 1.26 KB
/
Dockerfile_root
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
FROM nginx:alpine
ARG giturl
ARG filename
ARG webrootpath="/usr/share/nginx/$filename"
ARG fqdn
RUN apk add --no-cache git
RUN git clone $giturl $webrootpath
RUN tee /etc/nginx/conf.d/default.conf > /dev/null <<EOF
server {
listen 80 default_server;
root $webrootpath;
index index.html index.htm;
server_name _;
location ~ ^/$ {
return 301 https://$fqdn/index.html;
try_files \$uri \$uri/ =404;
}
}
EOF
RUN tee /home/gitPull.sh > /dev/null <<EOF
cronLog='/home/cron.log'
echo \`date +'%Y-%m-%d %H:%M:%S'\`" ::: Git Pull START" >> \$cronLog
git -C $webrootpath fetch --quiet
git -C $webrootpath remote prune origin
git -C $webrootpath checkout -f --quiet
git -C $webrootpath pull -f --quiet
success=\$?
if [ \$success -eq 0 ]; then
echo \`date +'%Y-%m-%d %H:%M:%S'\`" ::: Git Pull END" >> \$cronLog
nginx -s reload
echo \`date +'%Y-%m-%d %H:%M:%S'\`" ::: Nginx Reloaded" >> \$cronLog
else
echo \`date +'%Y-%m-%d %H:%M:%S'\`" ::: Git Pull FAILED" >> \$cronLog
fi
EOF
# Bug with tee command above adding carriage-return ^M character at end of each line
RUN sed -i 's/\r$//' /home/gitPull.sh
RUN chmod +x /home/gitPull.sh
RUN echo '0 */6 * * * /home/gitPull.sh >/dev/null 2>&1' >> /etc/crontabs/root
CMD crond && nginx -g "daemon off;"