|
|
Command Line Tools Requirements:
|
|
|
|
|
* MYSQL CLI
|
|
|
|
|
* WP CLI
|
|
|
|
|
* AWS CLI
|
|
|
|
|
* EB CLI
|
|
|
|
|
|
|
|
|
|
# Deployment to Staging
|
|
# Deployment to Staging
|
|
|
|
|
|
|
|
1. Dump SQL from Production RDS instance and backup to S3
|
|
From the our Jenkins deployment site there is a job ([http://deployment.blocpower.us/job/marketplace-staging/](http://deployment.blocpower.us/job/marketplace-staging/)). Starting the job builds and deploy to staging.
|
|
|
|
|
|
|
|
```
|
|
|
|
|
mysqldump --host=$PROD_RDS_HOSTNAME --port=$PROD_RDS_PORT --user=$PROD_RDS_USER --password=$PROD_RDS_PASSWORD --add-drop-table marketplace > proddump-{git-commit-hash}.sql
|
|
|
|
|
aws s3 cp proddump-{git-commit-hash}.sql s3://blocpower.us.builds/marketplace/sql/proddump-{git-commit-hash}.sql
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
2. Backup uploads from production in S3
|
|
|
|
|
|
|
|
|
|
```
|
|
|
|
|
ssh ec2-user@$EC2_IP -i ~/.ssh/EastCoastBPKey
|
|
|
|
|
cp /var/app/current/wp-content/uploads/ uploads/
|
|
|
|
|
cd uploads
|
|
|
|
|
zip -r uploads-{git-commit-hash}.zip .
|
|
|
|
|
aws s3 cp uploads_current/uploads.zip s3://blocpower.us.builds/marketplace/wordpress/uploads.zip
|
|
|
|
|
cd ..
|
|
|
|
|
rm -r uploads
|
|
|
|
|
exit
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
3. Restore data from SQL dump and add images from zip with current uploads.
|
|
|
|
|
|
|
|
|
|
```
|
|
|
|
|
mysql --host=$RDS_HOST --user=$RDS_USER --port=$RDS_PORT --password=$RDS_PASSWORD marketplace < proddump-{git-commit-hash}.sql
|
|
|
|
|
rm proddump-{git-commit-hash}.sql
|
|
|
|
|
cd $APPROOT
|
|
|
|
|
wp search-replace "http://blocpower.us" "http://staging.marketplace.blocpower.us"
|
|
|
|
|
wp search-replace "http://www.blocpower.us" "http://staging.marketplace.blocpower.us"
|
|
|
|
|
mysqldump --host=$RDS_HOSTNAME --port=$RDS_PORT --user=$RDS_USER --password=$RDS_PASSWORD --add-drop-table marketplace > stagingdump-{git-commit-hash}.sql
|
|
|
|
|
mysql --host=$STAGING_RDS_HOST --user=$STAGING_RDS_USER --port=$STAGING_RDS_PORT --password=$STAGING_RDS_PASSWORD marketplace < stagingdump-{git-commit-hash}.sql
|
|
|
|
|
aws s3 mv stagingdump-{git-commit-hash}.sql s3://blocpower.us.builds/marketplace/sql/stagingdump-{git-commit-hash}.sql`
|
|
|
|
|
cd $APP_ROOT
|
|
|
|
|
aws s3 cp s3://blocpower.us.builds/marketplace/wordpress/uploads-{git-commit-hash}.zip wp-content/uploads/uploads-{git-commit-hash}.zip
|
|
|
|
|
cd wp-content/uploads/
|
|
|
|
|
unzip uploads-{git-commit-hash}.zip
|
|
|
|
|
rm uploads-{git-commit-hash}.zip
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
4. Deploy Elastic Beanstalk Application
|
|
|
|
|
|
|
|
|
|
```
|
|
|
|
|
cd $APP_ROOT
|
|
|
|
|
zip -r marketplaceBuild.zip .
|
|
|
|
|
eb deploy
|
|
|
|
|
````
|
|
|
|
|
|
|
|
|
|
# Deployment to Production
|
|
# Deployment to Production
|
|
|
|
|
|
| ... | | ... | |