Browse code

Give the Redirect a HostName - filled in from the s3 bucket name.

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

Sven Dowideit authored on 2014/05/12 09:31:27
Showing 3 changed files
... ...
@@ -4,7 +4,7 @@
4 4
 FROM 		debian:jessie
5 5
 MAINTAINER	Sven Dowideit <SvenDowideit@docker.com> (@SvenDowideit)
6 6
 
7
-RUN 	apt-get update && apt-get install -yq make python-pip python-setuptools vim-tiny git pandoc
7
+RUN 	apt-get update && apt-get install -yq make python-pip python-setuptools vim-tiny git gettext
8 8
 
9 9
 RUN	pip install mkdocs
10 10
 
... ...
@@ -19,7 +19,7 @@ EOF
19 19
 [ "$AWS_S3_BUCKET" ] || usage
20 20
 
21 21
 #VERSION=$(cat VERSION)
22
-BUCKET=$AWS_S3_BUCKET
22
+export BUCKET=$AWS_S3_BUCKET
23 23
 
24 24
 export AWS_CONFIG_FILE=$(pwd)/awsconfig
25 25
 [ -e "$AWS_CONFIG_FILE" ] || usage
... ...
@@ -37,7 +37,10 @@ setup_s3() {
37 37
 	# Make the bucket accessible through website endpoints.
38 38
 	echo "make $BUCKET accessible as a website"
39 39
 	#aws s3 website s3://$BUCKET --index-document index.html --error-document jsearch/index.html
40
-	s3conf=$(cat s3_website.json)
40
+	s3conf=$(cat s3_website.json | envsubst)
41
+	echo
42
+	echo $s3conf
43
+	echo
41 44
 	aws s3api put-bucket-website --bucket $BUCKET --website-configuration "$s3conf"
42 45
 }
43 46
 
... ...
@@ -6,12 +6,12 @@
6 6
     "Suffix": "index.html"
7 7
   },
8 8
   "RoutingRules": [
9
-    { "Condition": { "KeyPrefixEquals": "en/latest/" }, "Redirect": { "ReplaceKeyPrefixWith": "" } },
10
-    { "Condition": { "KeyPrefixEquals": "en/master/" }, "Redirect": { "ReplaceKeyPrefixWith": "" } },
11
-    { "Condition": { "KeyPrefixEquals": "en/v0.6.3/" }, "Redirect": { "ReplaceKeyPrefixWith": "" } },
12
-    { "Condition": { "KeyPrefixEquals": "jsearch/index.html" }, "Redirect": { "ReplaceKeyPrefixWith": "jsearch/" } },
13
-    { "Condition": { "KeyPrefixEquals": "index/" }, "Redirect": { "ReplaceKeyPrefixWith": "docker-io/" } },
14
-    { "Condition": { "KeyPrefixEquals": "reference/api/index_api/" }, "Redirect": { "ReplaceKeyPrefixWith": "reference/api/docker-io_api/" } }
9
+    { "Condition": { "KeyPrefixEquals": "en/latest/" }, "Redirect": { "HostName": "$BUCKET", "ReplaceKeyPrefixWith": "" } },
10
+    { "Condition": { "KeyPrefixEquals": "en/master/" }, "Redirect": { "HostName": "$BUCKET", "ReplaceKeyPrefixWith": "" } },
11
+    { "Condition": { "KeyPrefixEquals": "en/v0.6.3/" }, "Redirect": { "HostName": "$BUCKET", "ReplaceKeyPrefixWith": "" } },
12
+    { "Condition": { "KeyPrefixEquals": "jsearch/index.html" }, "Redirect": { "HostName": "$BUCKET", "ReplaceKeyPrefixWith": "jsearch/" } },
13
+    { "Condition": { "KeyPrefixEquals": "index/" }, "Redirect": { "HostName": "$BUCKET", "ReplaceKeyPrefixWith": "docker-io/" } },
14
+    { "Condition": { "KeyPrefixEquals": "reference/api/index_api/" }, "Redirect": { "HostName": "$BUCKET", "ReplaceKeyPrefixWith": "reference/api/docker-io_api/" } }
15 15
   ]
16 16
 }
17 17