Skip to content
This repository has been archived by the owner on Jun 15, 2021. It is now read-only.

williamengbjerg/docker-magento2

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

🟧 Magento 2

Fresh magento2 project setup. Head into application folder in your host/root through term.

1. Install fresh Magento2 version

composer create-project --repository=https://repo.magento.com/ magento/project-community-edition ./

2. Run command below

php bin/magento setup:install \
--base-url=http://magento2.test \
--db-host=db:3306 \
--db-name=database \
--db-user=user \
--db-password=password \
--admin-firstname=admin \
--admin-lastname=admin \
[email protected] \
--admin-user=admin \
--admin-password=admin123 \
--language=en_US \
--currency=USD \
--timezone=Europe/Copenhagen \
--use-rewrites=1 \
--elasticsearch-host=elastic-search \
--elasticsearch-port=9200

Admin url is being generated once installation is done.

3. Disable two factor and compile files

php bin/magento mo:di Magento_TwoFactorAuth
php bin/magento setup:di:compile

4. Enable developer mode (For debug)

php bin/magento deploy:mode:set developer
php bin/magento setup:config:set developer

Fix file permissions

Set the proper permission for the whole Magento 2 installation directory by using below command

find . -type d -exec chmod 755 {} \; && find . -type f -exec chmod 755 {} \;

Info: In some cases, you can not use 770 or 660 permissions (Fast-CGI systems, for example). Instead, you can use 755 and 644 respectively.


Permissions in docker container

  • chmod 777 -R var
  • chmod 777 -R generated
  • chmod 777 -R app/etc
  • rm -rf var/cache/* var/page_cache/* var/generation/*

After that run php bin/magento setup:di:compile

Link guide


Enable error log

enable display_errors from file app/bootstrap.php around line 11 remove #

Link - Stackexchange


🐳 Docker

To start containers use docker-sync-stack start — this will start docker-sync process as well as the server

Docker-sync

COMMAND START SYNC CLEAN SYNC STOP SYNC LIST SYNCS
docker-sync start clean stop list

Full guide


Docker containers

COMMAND DOCKER START DOCKER DOWN DIG INTO CONTAINER
docker-compose up -d down docker exec -it [CONTAINER-ID] bash

Re-build docker containers

Remove ALL containers, networks not used by at least one container, dangling images, dangling build cache etc

docker-compose up -d --build --force-recreate

Delete all volumes

docker volume rm $(docker volume ls -q)

Delete all images

docker system prune -a
docker system prune --volumes

Permission errors

Nginx is showing 404 error not found

Head into nginx/php-fpm container and type:

chmod 755 application/  

Permission error (usually cache error)

In application folder

chown -R www-data:www-data .

Clear dummy data

Guide from magento.stackexchange.com

magento2-clear.sql


🤖 Magento commands

Run below command unless alias is different.

php bin/magento

Admin

Command Info
admin:user:create Creates an administrator

App

Command Info
app:config:import Import data from shared configuration files to appropriate data storage

i18n

Command Info
i18n:collect-phrases Discovers phrases in the codebase
i18n:pack Saves language package

Info

Command Info
info:adminuri Displays the Magento Admin URI
info:backups:list Prints list of available backup files
info:currency:list Displays the list of available currencies
info:dependencies:show-framework Shows number of dependencies on Magento framework
info:dependencies:show-modules Shows number of dependencies between modules
info:dependencies:show-modules-circular Shows number of circular dependencies between modules
info:language:list Displays the list of available language locales
info:timezone:list Displays the list of available timezones

Maintenance

Command Info
maintenance:allow-ips Sets maintenance mode exempt IPs
maintenance:disable Disables maintenance mode
maintenance:enable Enables maintenance mode
maintenance:status Displays maintenance mode status

Module

Command Info
module:config:status Checks the modules configuration in the 'app/etc/config.php' file and reports if they are up to date or not
module:disable Disables specified modules
module:enable Enables specified modules
module:status Displays status of modules
module:uninstall Uninstalls modules installed by composer

Sampledata

Command Info
sampledata:deploy Deploy sample data modules for composer-based Magento installations
sampledata:remove Remove all sample data packages from composer.json

Setup

Command Info
setup:backup Takes backup of Magento Application code base, media and database
setup:config:set Creates or modifies the deployment configuration
setup:db-data:upgrade Installs and upgrades data in the DB
setup:db-schema:upgrade Installs and upgrades the DB schema
setup:db:status Checks if DB schema or data requires upgrade
setup:di:compile Generates DI configuration and all missing classes that can be auto-generated
setup:install Installs the Magento application
setup:performance:generate-fixtures Generates fixtures
setup:rollback Rolls back Magento Application codebase, media and database
setup:static-content:deploy Deploys static view files
setup:store-config:set Installs the store configuration. Deprecated since 2.2.0. Use config:set instead
setup:uninstall Uninstalls the Magento application
setup:upgrade Upgrades the Magento application, DB data, and schema

About

Not really in use anymore. Fun to see.

Resources

Stars

Watchers

Forks