From c1c5ba815727bd24d78203d3d16e7b8cb6fc447b Mon Sep 17 00:00:00 2001 From: kunw Date: Mon, 14 Nov 2016 18:27:56 +0800 Subject: [PATCH] Update for adding timestamp to JS file name to avoid browser cache. --- make/dev/ui/Dockerfile | 4 +++- make/photon/ui/Dockerfile | 5 ++++- make/ubuntu/ui/Dockerfile | 4 +++- src/ui/controllers/base.go | 3 ++- 4 files changed, 12 insertions(+), 4 deletions(-) diff --git a/make/dev/ui/Dockerfile b/make/dev/ui/Dockerfile index f8d56fdd7..dfa7ec5fa 100644 --- a/make/dev/ui/Dockerfile +++ b/make/dev/ui/Dockerfile @@ -23,7 +23,9 @@ COPY make/jsminify.sh /tmp/jsminify.sh RUN chmod u+x /go/bin/harbor_ui \ && sed -i 's/TLS_CACERT/#TLS_CAERT/g' /etc/ldap/ldap.conf \ && sed -i '$a\TLS_REQCERT allow' /etc/ldap/ldap.conf \ - && /tmp/jsminify.sh /go/bin/views/sections/script-include.htm /go/bin/static/resources/js/harbor.app.min.js /go/bin/ + && timestamp=`date '+%s'` \ + && /tmp/jsminify.sh /go/bin/views/sections/script-include.htm /go/bin/static/resources/js/harbor.app.min.$timestamp.js /go/bin/ \ + && sed -i "s/harbor\.app\.min\.js/harbor\.app\.min\.$timestamp\.js/g" /go/bin/views/sections/script-min-include.htm WORKDIR /go/bin/ ENTRYPOINT ["/go/bin/harbor_ui"] diff --git a/make/photon/ui/Dockerfile b/make/photon/ui/Dockerfile index c858905ac..34b3d5335 100644 --- a/make/photon/ui/Dockerfile +++ b/make/photon/ui/Dockerfile @@ -11,7 +11,10 @@ COPY ./src/favicon.ico /harbor/favicon.ico COPY ./make/jsminify.sh /tmp/jsminify.sh RUN chmod u+x /harbor/harbor_ui \ - && tmp/jsminify.sh /harbor/views/sections/script-include.htm /harbor/static/resources/js/harbor.app.min.js /harbor/ \ + && timestamp=`date '+%s'` \ + && /tmp/jsminify.sh /harbor/views/sections/script-include.htm /harbor/static/resources/js/harbor.app.min.$timestamp.js /harbor/ \ + && sed -i "s/harbor\.app\.min\.js/harbor\.app\.min\.$timestamp\.js/g" /harbor/views/sections/script-min-include.htm \ && echo "TLS_REQCERT allow" >> /etc/openldap/ldap.conf + WORKDIR /harbor/ ENTRYPOINT ["/harbor/harbor_ui"] diff --git a/make/ubuntu/ui/Dockerfile b/make/ubuntu/ui/Dockerfile index ac41c6bb4..6a39037b5 100644 --- a/make/ubuntu/ui/Dockerfile +++ b/make/ubuntu/ui/Dockerfile @@ -20,7 +20,9 @@ COPY ./make/jsminify.sh /tmp/jsminify.sh RUN chmod u+x /harbor/harbor_ui \ && sed -i 's/TLS_CACERT/#TLS_CAERT/g' /etc/ldap/ldap.conf \ && sed -i '$a\TLS_REQCERT allow' /etc/ldap/ldap.conf \ - && /tmp/jsminify.sh /harbor/views/sections/script-include.htm /harbor/static/resources/js/harbor.app.min.js /harbor/ + && timestamp=`date '+%s'` \ + && /tmp/jsminify.sh /harbor/views/sections/script-include.htm /harbor/static/resources/js/harbor.app.min.$timestamp.js /harbor/ \ + && sed -i "s/harbor\.app\.min\.js/harbor\.app\.min\.$timestamp\.js/g" /harbor/views/sections/script-min-include.htm WORKDIR /harbor/ ENTRYPOINT ["/harbor/harbor_ui"] diff --git a/src/ui/controllers/base.go b/src/ui/controllers/base.go index 5f9b8a8cc..fdfaa6b6b 100644 --- a/src/ui/controllers/base.go +++ b/src/ui/controllers/base.go @@ -111,7 +111,8 @@ func (b *BaseController) Prepare() { b.UseCompressedJS = true } - if _, err := os.Stat(filepath.Join("static", "resources", "js", "harbor.app.min.js")); os.IsNotExist(err) { + m, err := filepath.Glob(filepath.Join("static", "resources", "js", "harbor.app.min.*.js")) + if err != nil || len(m) == 0 { b.UseCompressedJS = false }