1
0
Fork 0
mirror of https://github.com/moby/moby.git synced 2022-11-09 12:21:53 -05:00

Merge pull request #9721 from SvenDowideit/add-cloudfront-invalidation-to-docs

Add docs Cloudfront cache invalidation
This commit is contained in:
Michael Crosby 2015-01-05 16:25:20 -08:00
commit 4235e2796b
4 changed files with 58 additions and 6 deletions

View file

@ -53,7 +53,7 @@ docs-shell: docs-build
$(DOCKER_RUN_DOCS) -p $(if $(DOCSPORT),$(DOCSPORT):)8000 "$(DOCKER_DOCS_IMAGE)" bash
docs-release: docs-build
$(DOCKER_RUN_DOCS) -e OPTIONS -e BUILD_ROOT "$(DOCKER_DOCS_IMAGE)" ./release.sh
$(DOCKER_RUN_DOCS) -e OPTIONS -e BUILD_ROOT -e DISTRIBUTION_ID "$(DOCKER_DOCS_IMAGE)" ./release.sh
docs-test: docs-build
$(DOCKER_RUN_DOCS) "$(DOCKER_DOCS_IMAGE)" ./test.sh
@ -83,6 +83,7 @@ build: bundles
docker build -t "$(DOCKER_IMAGE)" .
docs-build:
git diff --name-status upstream/release..upstream/docs docs/ > docs/changed-files
cp ./VERSION docs/VERSION
echo "$(GIT_BRANCH)" > docs/GIT_BRANCH
echo "$(AWS_S3_BUCKET)" > docs/AWS_S3_BUCKET

View file

@ -145,11 +145,13 @@ to view your results and make sure what you published is what you wanted.
When you're happy with it, publish the docs to our live site:
make AWS_S3_BUCKET=docs.docker.com BUILD_ROOT=yes docs-release
make AWS_S3_BUCKET=docs.docker.com BUILD_ROOT=yes DISTRIBUTION_ID=C2K6......FL2F docs-release
Test the uncached version of the live docs at http://docs.docker.com.s3-website-us-east-1.amazonaws.com/
Note that the new docs will not appear live on the site until the cache (a complex,
distributed CDN system) is flushed. This requires someone with S3 keys. Contact Docker
(Sven Dowideit or John Costa) for assistance.
distributed CDN system) is flushed. The `make docs-release` command will do this
_if_ the `DISTRIBUTION_ID` is set to the Cloudfront distribution ID (ask the meta
team) - this will take at least 15 minutes to run and you can check its progress
with the CDN Cloudfront Chrome addin.

View file

@ -97,6 +97,50 @@ upload_current_documentation() {
$run
}
invalidate_cache() {
if [ "" == "$DISTRIBUTION_ID" ]; then
echo "Skipping Cloudfront cache invalidation"
return
fi
dst=$1
#aws cloudfront create-invalidation --profile docs.docker.com --distribution-id $DISTRIBUTION_ID --invalidation-batch '{"Paths":{"Quantity":1, "Items":["'+$file+'"]},"CallerReference":"19dec2014sventest1"}'
aws configure set preview.cloudfront true
files=($(cat changed-files | grep 'sources/.*$' | sed -E 's#.*docs/sources##' | sed -E 's#index\.md#index.html#' | sed -E 's#\.md#/index.html#'))
files[${#files[@]}]="/index.html"
files[${#files[@]}]="/versions.html_fragment"
len=${#files[@]}
echo "aws cloudfront create-invalidation --profile docs.docker.com --distribution-id $DISTRIBUTION_ID --invalidation-batch '" > batchfile
echo "{\"Paths\":{\"Quantity\":$len," >> batchfile
echo "\"Items\": [" >> batchfile
#for file in $(cat changed-files | grep 'sources/.*$' | sed -E 's#.*docs/sources##' | sed -E 's#index\.md#index.html#' | sed -E 's#\.md#/index.html#')
for file in "${files[@]}"
do
if [ "$file" == "${files[${#files[@]}-1]}" ]; then
comma=""
else
comma=","
fi
echo "\"$dst$file\"$comma" >> batchfile
done
echo "]}, \"CallerReference\":" >> batchfile
echo "\"$(date)\"}'" >> batchfile
echo "-----"
cat batchfile
echo "-----"
sh batchfile
echo "-----"
}
if [ "$OPTIONS" != "--dryrun" ]; then
setup_s3
fi
@ -106,6 +150,7 @@ if [ "$BUILD_ROOT" == "yes" ]; then
echo "Building root documentation"
build_current_documentation
upload_current_documentation
invalidate_cache
fi
#build again with /v1.0/ prefix
@ -113,3 +158,4 @@ sed -i "s/^site_url:.*/site_url: \/$MAJOR_MINOR\//" mkdocs.yml
echo "Building the /$MAJOR_MINOR/ documentation"
build_current_documentation
upload_current_documentation "/$MAJOR_MINOR/"
invalidate_cache "/$MAJOR_MINOR"

View file

@ -267,14 +267,17 @@ git checkout -b docs release || git checkout docs
git fetch
git reset --hard origin/release
git push -f origin docs
make AWS_S3_BUCKET=docs.docker.com BUILD_ROOT=yes docs-release
make AWS_S3_BUCKET=docs.docker.com BUILD_ROOT=yes DISTRIBUTION_ID=C2K6......FL2F docs-release
```
The docs will appear on http://docs.docker.com/ (though there may be cached
versions, so its worth checking http://docs.docker.com.s3-website-us-east-1.amazonaws.com/).
For more information about documentation releases, see `docs/README.md`.
Ask Sven, or JohnC to invalidate the cloudfront cache using the CND Planet chrome applet.
Note that the new docs will not appear live on the site until the cache (a complex,
distributed CDN system) is flushed. The `make docs-release` command will do this
_if_ the `DISTRIBUTION_ID` is set correctly - this will take at least 15 minutes to run
and you can check its progress with the CDN Cloudfront Chrome addin.
### 12. Create a new pull request to merge release back into master