|
| 1 | +apiVersion: v1 |
| 2 | +kind: ConfigMap |
| 3 | +metadata: |
| 4 | + name: static-site-{{ .Release.Name }}-config |
| 5 | + labels: |
| 6 | + app: static-site |
| 7 | + site: {{ .Release.Name }} |
| 8 | +data: |
| 9 | + nginx.conf: | |
| 10 | + user nginx; |
| 11 | + worker_processes auto; |
| 12 | +
|
| 13 | + error_log /tmp/log/nginx/error.log warn; |
| 14 | + pid /tmp/nginx.pid; |
| 15 | +
|
| 16 | +
|
| 17 | + events { |
| 18 | + worker_connections 1024; |
| 19 | + } |
| 20 | +
|
| 21 | + http { |
| 22 | + include /etc/nginx/mime.types; |
| 23 | + default_type application/octet-stream; |
| 24 | +
|
| 25 | + log_format main '$remote_addr - $remote_user [$time_local] "$request" ' |
| 26 | + '$status $body_bytes_sent "$http_referer" ' |
| 27 | + '"$http_user_agent" "$http_x_forwarded_for"'; |
| 28 | +
|
| 29 | + access_log /tmp/log/nginx/access.log main; |
| 30 | +
|
| 31 | + client_body_temp_path /tmp/client_temp; |
| 32 | + proxy_temp_path /tmp/proxy_temp_path; |
| 33 | + fastcgi_temp_path /tmp/fastcgi_temp; |
| 34 | + uwsgi_temp_path /tmp/uwsgi_temp; |
| 35 | + scgi_temp_path /tmp/scgi_temp; |
| 36 | +
|
| 37 | +
|
| 38 | + sendfile on; |
| 39 | + #tcp_nopush on; |
| 40 | +
|
| 41 | + keepalive_timeout 65; |
| 42 | +
|
| 43 | + gzip on; |
| 44 | + include /etc/nginx/conf.d/*.conf; |
| 45 | + } |
| 46 | +
|
| 47 | + default.conf: | |
| 48 | + server { |
| 49 | + listen 8080; |
| 50 | + server_name localhost; |
| 51 | +
|
| 52 | + #charset koi8-r; |
| 53 | + #access_log /var/log/nginx/host.access.log main; |
| 54 | +
|
| 55 | + location / { |
| 56 | + absolute_redirect off; |
| 57 | + {{- if .Values.site.enableDirectoryListing }} |
| 58 | + autoindex on; |
| 59 | + {{- end }} |
| 60 | +
|
| 61 | + root /usr/share/nginx/html; |
| 62 | + index index.html index.htm; |
| 63 | + } |
| 64 | +
|
| 65 | + #error_page 404 /404.html; |
| 66 | +
|
| 67 | + # redirect server error pages to the static page /50x.html |
| 68 | + # |
| 69 | + error_page 500 502 503 504 /50x.html; |
| 70 | + location = /50x.html { |
| 71 | + root /usr/share/nginx/html; |
| 72 | + } |
| 73 | +
|
| 74 | + # proxy the PHP scripts to Apache listening on 127.0.0.1:80 |
| 75 | + # |
| 76 | + #location ~ \.php$ { |
| 77 | + # proxy_pass http://127.0.0.1; |
| 78 | + #} |
| 79 | +
|
| 80 | + # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000 |
| 81 | + # |
| 82 | + #location ~ \.php$ { |
| 83 | + # root html; |
| 84 | + # fastcgi_pass 127.0.0.1:9000; |
| 85 | + # fastcgi_index index.php; |
| 86 | + # fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name; |
| 87 | + # include fastcgi_params; |
| 88 | + #} |
| 89 | +
|
| 90 | + # deny access to .htaccess files, if Apache's document root |
| 91 | + # concurs with nginx's one |
| 92 | + # |
| 93 | + #location ~ /\.ht { |
| 94 | + # deny all; |
| 95 | + #} |
| 96 | + } |
| 97 | +
|
| 98 | + clone.sh: | |
| 99 | + #!/bin/sh |
| 100 | +
|
| 101 | + set -e |
| 102 | +
|
| 103 | + REPO_URL='{{ .Values.repo.location }}' |
| 104 | +
|
| 105 | + {{- if and .Values.repo.credential.username .Values.repo.credential.password }} |
| 106 | + echo 'exec echo $GIT_PASSWORD' > /tmp/git-askpass.sh |
| 107 | + chmod +x /tmp/git-askpass.sh |
| 108 | + export GIT_ASKPASS=/tmp/git-askpass.sh |
| 109 | + |
| 110 | + if [ ! -z "${REPO_URL##*@*}" ] ; then |
| 111 | + REPO_URL=$(echo $REPO_URL | sed 's;//;//{{ .Values.repo.credential.username }}@;') |
| 112 | + fi |
| 113 | + {{- end }} |
| 114 | +
|
| 115 | + INSIDE_TREE=$(git rev-parse --is-inside-work-tree 2>/dev/null || true) |
| 116 | + if [ -z "$INSIDE_TREE" ]; then |
| 117 | + git init . |
| 118 | + fi |
| 119 | +
|
| 120 | + git config remote.origin.url $REPO_URL |
| 121 | +
|
| 122 | + BRANCH={{ .Values.repo.branch }} |
| 123 | + CURRENT=$(git rev-parse --verify HEAD 2>/dev/null || true) |
| 124 | + if [ "$CURRENT" != "$GIT_REVISION" ]; then |
| 125 | + git fetch --no-tags --progress -- $REPO_URL +refs/heads/$BRANCH:refs/remotes/origin/$BRANCH |
| 126 | + |
| 127 | + git config advice.detachedHead false |
| 128 | + git checkout -f $GIT_REVISION |
| 129 | + git branch -D $BRANCH 2>/dev/null || true |
| 130 | + git checkout -b $BRANCH $GIT_REVISION |
| 131 | + fi |
| 132 | +
|
| 133 | + git reset --hard |
| 134 | + git clean -fdx |
| 135 | +
|
| 136 | + # Running at /source |
| 137 | + cp -R ./ /website |
| 138 | + rm -rf /website/.git |
0 commit comments