Skip to content

Commit bbf0614

Browse files
authored
Merge pull request #8541 from readthedocs/humitos/script-tools-cache
2 parents 02ebae2 + 1a86439 commit bbf0614

File tree

1 file changed

+22
-5
lines changed

1 file changed

+22
-5
lines changed

scripts/compile_version_upload_s3.sh

+22-5
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,16 @@
11
#!/bin/bash
22
#
33
#
4-
# Script to compile a languge version and upload it to the cache.
4+
# Script to compile a language version and upload it to the cache.
55
#
66
# This script automates the process to build and upload a Python/Node/Rust/Go
77
# version and upload it to S3 making it available for the builders. When a
88
# pre-compiled version is available in the cache, builds are faster because they
99
# don't have to donwload and compile.
1010
#
11+
#
1112
# LOCAL DEVELOPMENT ENVIRONMENT
13+
#
1214
# https://docs.readthedocs.io/en/latest/development/install.html
1315
#
1416
# You can run this script from you local environment to create cached version
@@ -25,9 +27,16 @@
2527
# it's required to set the following environment variables for an IAM user with
2628
# permissions on ``build-tools`` S3's bucket:
2729
#
30+
# AWS_REGION
2831
# AWS_ACCESS_KEY_ID
2932
# AWS_SECRET_ACCESS_KEY
30-
# AWS_ENDPOINT_URL
33+
# AWS_BUILD_TOOLS_BUCKET_NAME
34+
#
35+
# Note that in production we need to install `aws` Python package. We can do that by:
36+
#
37+
# virtualenv venv
38+
# source venv/bin/activate
39+
# pip install awscli==1.20.34
3140
#
3241
#
3342
# USAGE
@@ -95,9 +104,17 @@ docker container kill $CONTAINER_ID
95104
# Upload the .tar.gz to S3
96105
AWS_ENDPOINT_URL="${AWS_ENDPOINT_URL:-http://localhost:9000}"
97106
AWS_BUILD_TOOLS_BUCKET="${AWS_BUILD_TOOLS_BUCKET:-build-tools}"
98-
AWS_ACCESS_KEY_ID="${AWS_ACCESS_KEY_ID:-admin}" \
99-
AWS_SECRET_ACCESS_KEY="${AWS_SECRET_ACCESS_KEY:-password}" \
100-
aws --endpoint-url $AWS_ENDPOINT_URL s3 cp $OS-$TOOL-$VERSION.tar.gz s3://$AWS_BUILD_TOOLS_BUCKET
107+
AWS_ACCESS_KEY_ID="${AWS_ACCESS_KEY_ID:-admin}"
108+
AWS_SECRET_ACCESS_KEY="${AWS_SECRET_ACCESS_KEY:-password}"
109+
110+
if [[ -z $AWS_REGION ]]
111+
then
112+
# Development environment
113+
aws --endpoint-url $AWS_ENDPOINT_URL s3 cp $OS-$TOOL-$VERSION.tar.gz s3://$AWS_BUILD_TOOLS_BUCKET
114+
else
115+
# Production environment does not requires `--endpoint-url`
116+
aws s3 cp $OS-$TOOL-$VERSION.tar.gz s3://$AWS_BUILD_TOOLS_BUCKET
117+
fi
101118

102119
# Delete the .tar.gz file from the host
103120
rm $OS-$TOOL-$VERSION.tar.gz

0 commit comments

Comments
 (0)