Browse code

add Docker version and branch to html header

Docker-DCO-1.1-Signed-off-by: Sven Dowideit <SvenDowideit@docker.com> (github: SvenDowideit)

Sven Dowideit authored on 2014/06/23 12:10:00
Showing 4 changed files
... ...
@@ -6,6 +6,7 @@ BINDDIR := bundles
6 6
 DOCSPORT := 8000
7 7
 
8 8
 GIT_BRANCH := $(shell git rev-parse --abbrev-ref HEAD 2>/dev/null)
9
+GITCOMMIT := $(shell git rev-parse --short HEAD 2>/dev/null)
9 10
 DOCKER_IMAGE := docker$(if $(GIT_BRANCH),:$(GIT_BRANCH))
10 11
 DOCKER_DOCS_IMAGE := docker-docs$(if $(GIT_BRANCH),:$(GIT_BRANCH))
11 12
 DOCKER_MOUNT := $(if $(BINDDIR),-v "$(CURDIR)/$(BINDDIR):/go/src/github.com/dotcloud/docker/$(BINDDIR)")
... ...
@@ -59,6 +60,7 @@ docs-build:
59 59
 	cp ./VERSION docs/VERSION
60 60
 	echo "$(GIT_BRANCH)" > docs/GIT_BRANCH
61 61
 	echo "$(AWS_S3_BUCKET)" > docs/AWS_S3_BUCKET
62
+	echo "$(GITCOMMIT)" > docs/GITCOMMIT
62 63
 	docker build -t "$(DOCKER_DOCS_IMAGE)" docs
63 64
 
64 65
 bundles:
... ...
@@ -28,8 +28,12 @@ WORKDIR	/docs
28 28
 
29 29
 RUN	VERSION=$(cat /docs/VERSION)								&&\
30 30
 	GIT_BRANCH=$(cat /docs/GIT_BRANCH)							&&\
31
+	GITCOMMIT=$(cat /docs/GITCOMMIT)							&&\
31 32
 	AWS_S3_BUCKET=$(cat /docs/AWS_S3_BUCKET)						&&\
32
-	echo "{% set docker_version = \"${VERSION}\" %}{% set docker_branch = \"${GIT_BRANCH}\" %}{% set aws_bucket = \"${AWS_S3_BUCKET}\" %}{% include \"beta_warning.html\" %}" > /docs/theme/mkdocs/version.html
33
+	sed -i "s/\$VERSION/$VERSION/g" /docs/theme/mkdocs/base.html				&&\
34
+	sed -i "s/\$GITCOMMIT/$GITCOMMIT/g" /docs/theme/mkdocs/base.html			&&\
35
+	sed -i "s/\$GIT_BRANCH/$GIT_BRANCH/g" /docs/theme/mkdocs/base.html			&&\
36
+	sed -i "s/\$AWS_S3_BUCKET/$AWS_S3_BUCKET/g" /docs/theme/mkdocs/base.html
33 37
 
34 38
 # note, EXPOSE is only last because of https://github.com/dotcloud/docker/issues/3525
35 39
 EXPOSE	8000
... ...
@@ -18,7 +18,15 @@ EOF
18 18
 
19 19
 [ "$AWS_S3_BUCKET" ] || usage
20 20
 
21
-#VERSION=$(cat VERSION)
21
+VERSION=$(cat VERSION)
22
+
23
+if [ "$$AWS_S3_BUCKET" == "docs.docker.com" ]; then
24
+	if [ "${VERSION%-dev}" != "$VERSION" ]; then
25
+		echo "Please do not push '-dev' documentation to docs.docker.com ($VERSION)"
26
+		exit 1
27
+	fi
28
+fi
29
+
22 30
 export BUCKET=$AWS_S3_BUCKET
23 31
 
24 32
 export AWS_CONFIG_FILE=$(pwd)/awsconfig
... ...
@@ -50,7 +58,7 @@ build_current_documentation() {
50 50
 
51 51
 upload_current_documentation() {
52 52
 	src=site/
53
-	dst=s3://$BUCKET
53
+	dst=s3://$BUCKET$1
54 54
 
55 55
 	echo
56 56
 	echo "Uploading $src"
... ...
@@ -61,7 +69,7 @@ upload_current_documentation() {
61 61
 
62 62
 	# a really complicated way to send only the files we want
63 63
 	# if there are too many in any one set, aws s3 sync seems to fall over with 2 files to go
64
-	endings=( json html xml css js gif png JPG )
64
+	endings=( json html xml css js gif png JPG ttf svg woff)
65 65
 	for i in ${endings[@]}; do
66 66
 		include=""
67 67
 		for j in ${endings[@]}; do
... ...
@@ -78,11 +86,8 @@ upload_current_documentation() {
78 78
 			--exclude *.DS_Store \
79 79
 			--exclude *.psd \
80 80
 			--exclude *.ai \
81
-			--exclude *.svg \
82 81
 			--exclude *.eot \
83 82
 			--exclude *.otf \
84
-			--exclude *.ttf \
85
-			--exclude *.woff \
86 83
 			--exclude *.rej \
87 84
 			--exclude *.rst \
88 85
 			--exclude *.orig \
... ...
@@ -99,3 +104,10 @@ setup_s3
99 99
 build_current_documentation
100 100
 upload_current_documentation
101 101
 
102
+# Remove the last version - 1.0.2-dev -> 1.0
103
+MAJOR_MINOR="v${VERSION%.*}"
104
+
105
+#build again with /v1.0/ prefix
106
+sed -i "s/^site_url:.*/site_url: \/$MAJOR_MINOR\//" mkdocs.yml
107
+build_current_documentation
108
+upload_current_documentation "/$MAJOR_MINOR/"
... ...
@@ -3,6 +3,12 @@
3 3
 <head>
4 4
   <meta charset="utf-8">
5 5
   <meta http-equiv="X-UA-Compatible" content="IE=edge">
6
+  <meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no">
7
+{% set docker_version = "$VERSION" %}{% set docker_commit = "$GITCOMMIT" %}{% set docker_branch = "$GIT_BRANCH" %}{% set aws_bucket = "$AWS_S3_BUCKET" %}
8
+  <meta name="docker_version" content="{{ docker_version }}">
9
+  <meta name="docker_git_branch" content="{{ docker_branch }}">
10
+  <meta name="docker_git_commit" content="{{ docker_commit }}">
11
+
6 12
   {% if meta.page_description %}<meta name="description" content="{{ meta.page_description[0] }}">{% endif %}
7 13
   {% if meta.page_keywords %}<meta name="keywords" content="{{ meta.page_keywords[0] }}">{% endif %}
8 14
   {% if site_author %}<meta name="author" content="{{ site_author }}">{% endif %}
... ...
@@ -59,7 +65,7 @@
59 59
         </div>
60 60
       </div>
61 61
       <div class="span9 content-body">
62
-        {% include "version.html" %}
62
+        {% include "beta_warning.html" %}
63 63
         {{ content }}
64 64
       </div>
65 65
     </div>