Skip to content

Instantly share code, notes, and snippets.

@rqsakai
Last active February 15, 2024 18:37
Show Gist options
  • Save rqsakai/940ad2017f351f080525ab56579dee06 to your computer and use it in GitHub Desktop.
Save rqsakai/940ad2017f351f080525ab56579dee06 to your computer and use it in GitHub Desktop.
The IT Nerd - Gist

Install magento with composer

composer create-project --repository-url=https://repo.magento.com/ magento/project-community-edition <install-directory-name>
 composer create-project --repository-url=https://repo.magento.com/ magento/project-enterprise-edition <install-directory-name>

Require the Cloud docker and ECE tools

composer require --no-update --dev magento/ece-tools magento/magento-cloud-docker

Update composer

composer update

Create Config files: .magento/services.yaml

mysql:
  type: mariadb:10.6
  disk: 2048

redis:
  type: redis:7.0

opensearch:
  type: opensearch:2.4
  disk: 1024
  configuration:
    plugins:
      - analysis-icu
      - analysis-phonetic

rabbitmq:
  type: rabbitmq:3.9
  disk: 512

.magento/routes.yaml

"http://{default}/":
  type: upstream
  upstream: "origenes:http"

"http://{all}/":
  type: upstream
  upstream: "origenes:http"

.magento.app.yaml

name: origenes
type: php:8.2
build:
    flavor: none

dependencies:
    php:
        composer/composer: '2.2.4'

# Enable PHP extensions
runtime:
    extensions:
        - xsl
        - newrelic
        - sodium
        - xdebug
# DNS names
relationships:
    database: "mysql:mysql"
    redis: "redis:redis"
    opensearch: "opensearch:opensearch"
    rabbitmq: "rabbitmq:rabbitmq"

# The configuration of app when it is exposed to the web.
web:
    locations:
        "/":
            # The public directory of the app, relative to its root.
            root: "pub"
            # The front-controller script to send non-static requests to.
            passthru: "/index.php"
            index:
                - index.php
            expires: -1
            scripts: true
            allow: false
            rules:
                \.(css|js|map|hbs|gif|jpe?g|png|tiff|wbmp|ico|jng|bmp|svgz|midi?|mp?ga|mp2|mp3|m4a|ra|weba|3gpp?|mp4|mpe?g|mpe|ogv|mov|webm|flv|mng|asx|asf|wmv|avi|ogx|swf|jar|ttf|eot|woff|otf|html?)$:
                    allow: true
                ^/sitemap(.*)\.xml$:
                    passthru: "/media/sitemap$1.xml"
        "/media":
            root: "pub/media"
            allow: true
            scripts: false
            expires: 1y
            passthru: "/get.php"
        "/static":
            root: "pub/static"
            allow: true
            scripts: false
            expires: 1y
            passthru: "/front-static.php"
            rules:
                ^/static/version\d+/(?<resource>.*)$:
                    passthru: "/static/$resource"

# The size of the persistent disk of the application (in MB).
disk: 5120

# The mounts that will be performed when the package is deployed.
mounts:
    "var": "shared:files/var"
    "app/etc": "shared:files/etc"
    "pub/media": "shared:files/media"
    "pub/static": "shared:files/static"

hooks:
    # We run build hooks before your application has been packaged.
    build: |
        set -e
        composer install
        php ./vendor/bin/ece-tools run scenario/build/generate.xml
        php ./vendor/bin/ece-tools run scenario/build/transfer.xml
    # We run deploy hook after your application has been deployed and started.
    deploy: |
        php ./vendor/bin/ece-tools run scenario/deploy.xml
    # We run post deploy hook to clean and warm the cache. Available with ECE-Tools 2002.0.10.
    post_deploy: |
        php ./vendor/bin/ece-tools run scenario/post-deploy.xml

# Default Magento 2 cron jobs
crons:
    cronrun:
        spec: "*/5 * * * *"
        cmd: "php bin/magento cron:run"

# Environment variables
variables:
    env:
        CONFIG__DEFAULT__PAYPAL_ONBOARDING__MIDDLEMAN_DOMAIN: 'payment-broker.magento.com'
        CONFIG__STORES__DEFAULT__PAYPAL__NOTATION_CODE: 'Magento_Enterprise_Cloud'
        CONFIG__DEFAULT__SMILE_ELASTICSUITE_CORE_BASE_SETTINGS__ES_CLIENT__SERVERS: 'opensearch:9200'
        CONFIG__DEFAULT__SMILE_ELASTICSUITE_CORE_BASE_SETTINGS__ES_CLIENT__ENABLE_HTTPS_MODE: 0
        CONFIG__DEFAULT__SMILE_ELASTICSUITE_CORE_BASE_SETTINGS__ES_CLIENT__ENABLE_HTTP_AUTH: 0
        CONFIG__DEFAULT__SMILE_ELASTICSUITE_CORE_BASE_SETTINGS__ES_CLIENT__HTTP_AUTH_USER: ""
        CONFIG__DEFAULT__SMILE_ELASTICSUITE_CORE_BASE_SETTINGS__ES_CLIENT__HTTP_AUTH_PWD: ""

.magento.env.yaml

stage:
  global:
    SKIP_HTML_MINIFICATION: true
    X_FRAME_CONFIGURATION: SAMEORIGIN
  build:
    SCD_THREADS: 4
    SCD_COMPRESSION_LEVEL: 8
    SCD_MATRIX:
      "magento/backend":
        language:
          - en_US
          - pt_BR
      "magento/Luma":
        language:
          - en_US
          - pt_BR
  deploy:
    SCD_STRATEGY: "standard"
    MYSQL_USE_SLAVE_CONNECTION: true
    REDIS_USE_SLAVE_CONNECTION: true
    REDIS_BACKEND: '\Magento\Framework\Cache\Backend\RemoteSynchronizedCache'
    SEARCH_CONFIGURATION:
      _merge: true
      engine: ElasticSuite
    ELASTICSUITE_CONFIGURATION:
      _merge: true
      es_client:
        servers: 'opensearch:9200'
      indices_settings:
        number_of_shards: 1
        number_of_replicas: 1
    CRON_CONSUMERS_RUNNER:
      cron_run: true
      max_messages: 1000
      consumers:
        - product_action_attribute.update
        - product_action_attribute.website.update
        - media.storage.catalog.image.resize
        - matchCustomerSegmentProcessor
        - codegeneratorProcessor
        - negotiableQuotePriceUpdate
        - exportProcessor
        - sharedCatalogUpdatePrice
        - sharedCatalogUpdateCategoryPermissions
        - inventory.source.items.cleanup
        - inventory.mass.update
        - inventory.reservations.cleanup
        - inventory.reservations.update
        - purchaseorder.toorder
        - purchaseorder.transactional.email
        - purchaseorder.validation
        - quoteItemCleaner
        - inventoryQtyCounter
        - inventory.reservations.updateSalabilityStatus
        - inventory.indexer.sourceItem
        - inventory.indexer.stock
        - media.content.synchronization
        - media.gallery.renditions.update
        - media.gallery.synchronization
        - async.operations.all

Install magento running the following

echo "127.0.0.1	magento2.docker" | sudo tee -a /etc/hosts
./vendor/bin/ece-docker build:compose --mode="developer" --sync-engine="native" --expose-db-port=3306 --with-cron --set-docker-host --with-xdebug
docker-compose up -d
docker-compose run deploy cloud-deploy
docker-compose run deploy magento-command deploy:mode:set developer
docker-compose run deploy magento-command config:set system/full_page_cache/caching_application 2 --lock-env
docker-compose run deploy magento-command setup:config:set --http-cache-hosts=varnish
docker-compose run deploy magento-command setup:upgrade
docker-compose run deploy cloud-deploy
sudo chown -Rh $(whoami): .

Now copy the followgin files

  • package.json.sample to package.json
  • Gruntfile.js.sample to Gruntfile.js
  • grunt-config.json.sample to grunt-config.json
  • dev/tools/grunt/configs/themes.js to dev/tools/grunt/configs/local-themes.js

Install npm dependencies

docker-compose run deploy 
npm i
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment