Skip to content

Instantly share code, notes, and snippets.

@rqsakai
Last active April 11, 2025 01:17
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.docker.yml

name: magento
system:
  mode: 'development'
services:
  php:
    version: '8.4'
    extensions:
      enabled:
        - xsl
        - json
        - redis
        - xdebug
  mysql:
    version: '11.4'
    image: 'mariadb'
  redis:
    version: '8.0-rc1'
    image: 'redis'
  opensearch:
    version: '2.5'
    image: 'magento/magento-cloud-docker-opensearch'
  cron:
    jobs:
      run:
        schedule: "* * * * *"
        command: "php bin/magento cron:run"
hooks:
  build: |
    set -e
    php ./vendor/bin/ece-tools run scenario/build/generate.xml
    php ./vendor/bin/ece-tools run scenario/build/transfer.xml
  deploy: 'php ./vendor/bin/ece-tools run scenario/deploy.xml'
  post_deploy: 'php ./vendor/bin/ece-tools run scenario/post-deploy.xml'
mounts:
  var:
    path: 'var'
  app-etc:
    path: 'app/etc'
  pub-media:
    path: 'pub/media'
  pub-static:
    path: 'pub/static'

Init the Docker Configuration

./vendor/magento/magento-cloud-docker/bin/init-docker.sh --php 8.4 --image 1.4.2

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
@rqsakai
Copy link
Author

rqsakai commented Apr 11, 2025

You may need to change the db health check configuration on the docker-compose.yml

  db:
    hostname: db.magento2.docker
    image: 'mariadb:11.4'
    shm_size: 2gb
    environment:
      - MYSQL_ROOT_PASSWORD=magento2
      - MYSQL_DATABASE=magento2
      - MYSQL_USER=magento2
      - MYSQL_PASSWORD=magento2
    ports:
      - '3306:3306'
    volumes:
      - '.:/app:delegated'
      - 'magento-magento-db:/var/lib/mysql'
    healthcheck:
      test: [ "CMD", "healthcheck.sh", "--connect", "--innodb_initialized" ]
      start_period: 10s
      interval: 10s
      timeout: 5s
      retries: 3
    networks:
      magento:
        aliases:
          - db.magento2.docker

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment