This is a tutorial on how to setup a new environment. Let's call it beta
.
master
anddevelop
should be at the same point, or at least there is no commits that affects database.- Check out a new branch called
beta
frommaster
.
Add these two files into .gitignore
beta.env
kubernetes/secrets-beta.yml
- All the secrets must be base64 encoded using
echo 'linuxhint.com' | base64
- Clone
kubernetes/secrets-staging.yml
and name the created filekubernetes/secrets-beta.yml
- These secrets are the same for staging, beta and production then keep them as is.
google-nl-api-credentials
tls-secret
cloudsql-postgres-credentials
documentcloud
airtable
(beta uses production secrets)mailgun
papertrail
twitterbot-storage-account
twitter-cpdpbot-app
(beta uses staging bot app)mailchimp
??? (only used on production)
- Django secret: randomly generate a string and put it to
django secret-key
- Azure Storage Account (used for
azure-storage-account
anddatapipeline-storage-account
)-
Go to https://portal.azure.com/ and create a storage account for
beta
-
Copy storage data from production storage account to beta storage account
- Clone
fixture
,csv
,heatmap
blobs - Create the empty
static
container with blob access
- Clone
-
Edit the CORS rule as follow
ALLOWED ORIGINS ALLOWED METHODS ALLOWED HEADERS EXPOSED HEADERS https://beta.cpdp.co GET Accept, Accept-Language, Content-Language, Content-Type Cache-Control, Content-Language, Content-Type, Expires, Last-Modified, Pragma https://betaapi.cpdp.co GET Accept, Accept-Language, Content-Language, Content-Type Cache-Control, Content-Language, Content-Type, Expires, Last-Modified, Pragma -
Put storage account name as
name
and api key askey
intoazure-storage-account
anddatapipeline-storage-account
-
- Clone
staging.env
and rename the created file to beta.env PGCLOUD_INSTANCE=twitterbot-180604:us-central1:cpdp-beta-database
- Ask Jeeves to grand you the access permission
- Go to https://console.cloud.google.com/sql/instances?project=twitterbot-180604
- Clone
cpdp-production
and rename it tocpdp-beta-database
DESKTOP_DOMAIN=beta.cpdp.co
MOBILE_DOMAIN=mb.cpdp.co
API_DOMAIN=betaapi.cpdp.co
- Keep the rest unchanged
- Run
git secret hide
- Create
cpdb/config/settings/beta.py
based oncpdb/config/settings/staging.py
- Enable email service by removing
EMAIL_BACKEND
andBANDIT_EMAIL
beta
uses the same AirTable table withproduction
then removeAIRTABLE_COPA_AGENCY_ID
andAIRTABLE_CPD_AGENCY_ID
- AWS S3
- Create bucket with name S3_BUCKET_CRAWLER_LOG
- AWS Lambda
- Update
lambda/deploy.sh
with new environment (beta) - Follow
docs/aws-lambda.md
to create beta's s3 buckets and lambda functions - Deploy new lambda functions using
docker-compose run web lambda/deploy.sh --beta
- Update
- Add
beta
option to most of files inbin
folder - Edit
.circleci/config.yml
to addbeta
workflows (similar tostaging
workflows). Unlikestaging
we needbeta
branch to trigger rebuilding index and search index.
- Run
./bin/initialize_kubernetes_namespace.sh --beta
- Go to https://mycloud.rackspace.com
- Add A record for
betaapi.cpdp.co
,mb.cpdp.co
andbeta.cpdp.co
, they should point to the same ip ascpdp.co
- Push the new
beta
branch and let CircleCI do the rest
- Run
./bin/manage.sh --beta upload_pdf
to upload pdf files to s3 - Check if
betaapi.cpdp.co/admin/
,beta.cpdp.co
,mb.cpdp.co
are working properly - Delete all existing attachment requests because of these:
- We are using the same AirTable ID for
production
andbeta
. We don't wantbeta
to edit/remove anyproduction
's records. - We enable email notification feature and we don't want to sent duplicated emails to real users.
- We are using the same AirTable ID for
beta
branch must be protected from now on.