Coder Social home page Coder Social logo

magento2-docker-environment's Introduction

Magento 2 docker environment

This repo provide a light Docker environment for Magento 2 using Nginx, Php7.2 and Mysql 5.7.26

First of all

  • it is a best practise to not run Docker like sudo user: for this reason we need to build out php container using the user of our machine running docker-compose build --build-arg UID=$(id -u) --build-arg GID=$(id -g) php-fpm
  • Set the UID and GID in .env file, related to our user id and group id of our machine.
    Get the user id typing id -u. Get the group id typing id -g`` This will ensure that our php-fpm container will run with our host machine user.

Set up an existing Magento2 project

  • copy your magento2 project into php/src folder
  • run docker-compose up -d
  • remove file .gitignore from php/src folder
  • add in your /etc/hosts file 127.0.0.1 magento2.local
  • open your browser and go to magento2.local

set up a new Magento2 project

  • docker-compose up --build -d
  • remove file .gitignore from php/src folder
  • docker run --rm --interactive --tty --volume ${PWD}/php/src:/app --user $(id -u):$(id -g) composer create-project --ignore-platform-reqs --repository-url=https://repo.magento.com/ magento/project-community-edition ./
  • Provide public key and private key for repo.magento.com and wait for composer to create the project
  • add in your /etc/hosts file 127.0.0.1 magento2.local
  • open your browser and go to magento2.local
  • Follow the step to install magento2

load sample data

  • docker-compose exec php-fpm php -dmemory_limit=6G bin/magento sampledata:deploy
  • docker run --rm --interactive --tty --volume ${PWD}/php/src:/app --user $(id -u):$(id -g) composer update --ignore-platform-reqs
  • docker-compose exec php-fpm php bin/magento setup:upgrade

Cache with redis

Enable cache with redis running on redis database 0

docker-compose exec php-fpm php bin/magento setup:config:set --cache-backend=redis --cache-backend-redis-server=redis --cache-backend-redis-db=0

Page cache over redis can be enabled, using db 1 with: docker-compose exec php-fpm php bin/magento setup:config:set --page-cache=redis --page-cache-redis-server=redis --page-cache-redis-db=1

Useful commands

Set environment in Magento 2 like developer docker-compose exec php-fpm php bin/magento deploy:mode:set developer

magento2-docker-environment's People

Contributors

mbrioski avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.