InsideDarkWeb.com

Magento 2 - AWS automatic codeDeploy via GitHub webhook

  • Can u please suggest me how effective is AWS codeDeploy for Magento 2
    ?
  • Is there any problems i need to overcome?

Sharing your experience would be helpful for me. Thankyou.

Magento Asked by Prabhu M. on February 14, 2021

1 Answers

One Answer

This is a very "BIG" topic but I will cover the basics here

ASSUMING YOU ALREADY HAVE an AWS account and CodeDeploy setup

Here are the basic that we take on a deployment for M2

Here is the appspec.yml file

version: 0.0
os: linux
hooks:
    BeforeInstall:
        - location: config_files/scripts/beforeInstall.bash
          runas: root
    AfterInstall:
        - location: config_files/scripts/afterInstall.bash
          runas: mage_user
        - location: config_files/scripts/moveToProduction.bash
          runas: root
        - location: config_files/scripts/cacheclean.bash
          runas: mage_user

Script to compile - You pull and compile code to a deploy server

cd production/build/public_html
git checkout .
git pull origin master
rm -rf var/cache/* var/page_cache/* var/composer_home/* var/tmp/*
php composer.phar update --no-interaction --no-progress --optimize-autoloader
bin/magento setup:upgrade

bin/magento setup:static-content:deploy -t Magento/backend
bin/magento setup:static-content:deploy en_US es_ES -a frontend

bin/magento setup:di:compile

# Make code files and directories read-only
echo "Setting directory base permissions to 0750"
find . -type d -exec chmod 0750 {} ;
echo "Setting file base permissions to 0640"
find . -type f -exec chmod 0640 {} ;
chmod o-rwx app/etc/env.php && chmod u+x bin/magento

# Compress source at shared directory
if [ ! -d /build ]; then
    mkdir -p /build
fi
tar -czvf /build/build.tar.gz . --exclude='./pub/media' --exclude='./.htaccess' --exclude='./.git' --exclude='./var/cache' --exclude='./var/composer_home' --exclude='./var/log' --exclude='./var/page_cache' --exclude='./var/import' --exclude='./var/export' --exclude='./var/report' --exclude='./var/backups' --exclude='./var/tmp' --exclude='./var/resource_config.json' --exclude='./var/.sample-data-state.flag' --exclude='./app/etc/config.php' --exclude='./app/etc/env.php'

Now you can deploy to your pre-configured group

sh ./compile.sh
aws deploy create-deployment 
--application-name AppMagento2 
--deployment-config-name CodeDeployDefault.OneAtATime 
--deployment-group-name MyMagentoApp 
--description "Live Deployment" 
--s3-location bucket=mage-codedeploy,bundleType=zip,eTag=<tagname>,key=live-build2.zip

I created this script to show where you are in the deployment

show-deployment.sh

aws deploy get-deployment --deployment-id $1 --query "deploymentInfo.[status, creator]" --output text

Correct answer by brentwpeterson on February 14, 2021

Add your own answers!

Related Questions

is creating block within template in magento 2 good practice

0  Asked on July 24, 2020 by herve-tribouilloy

       

Ask a Question

Get help from others!

© 2021 InsideDarkWeb.com. All rights reserved.