A dockerized magento 2 community environment ready for development or production.

Overview

Painless Magento 2 & 1

License

A dockerized magento 2 community environment ready for development or production. It supports magento 1.9.x for development

Inspired from dockerize-magento2

Advantages

  1. All containers run on Alpine Linux. As a result, the images are smaller, faster and all the containers work with the same rules.

  2. Magento is totally independant from Painless Magento 2. Magento lives inside the src directory. This is a volume in the php container, so you can use Painless Magento 2 to develop stores, websites or Magento extensions. After, you can use the same system for production or take your code from the source directory to use as you need.

  3. Composer runs out the containers. Composer is left outside on purpose to keep the containers small and facilitate their use. You always have access to the code in the volume src. You should use Composer in the host machine. You can apply your changes without stoping the containers. To run compose commands, go to src directory.

    ex: install Fooman Goolge Analytics.

     cd src
     composer require fooman/googleanalyticsplus-m2
     cd ..
     sh bin/console.sh mage setup:upgrade
  4. It includes, alpine latest, php 7,2 , nginx run by socket, mariadb, redis, opcache and let's encrypt; xdebug is only install when the enviroment is set in .env file as developer.

Software Requirements

For Linux users you must have a recent version of docker and docker-compose installed.

If you are a Mac or Windows user, use Docker Desktop or Docker Toolbox.

  • Docker Desktop: nginx container needs the port 80 in your machine, please verify it is free. Many times in windows the problem is the W3SVC service (World Wide Web Publishing Service) , please disable it.

You need to have php and composer installed on your host machine.

You need to have all php extensions required by magento installed on your host machine :

  • ext-bcmath

  • ext-ctype

  • ext-curl

  • ext-dom

  • ext-gd

  • ext-hash

  • ext-iconv

  • ext-intl

  • ext-mbstring

  • ext-openssl

  • ext-pdo_mysql

  • ext-simplexml

  • ext-soap

  • ext-spl

  • ext-xsl

  • ext-zip

  • lib-libxml

Installation

The instalation process is the same for development, staging or production. The difference is in the information you use to fill the .env file.

To start, use .env.sample to create this file.

  cp .evn.sample .env

Open the file and fill each variable. Each variable has values by default, you can use them as it for development but please for your own safety change all for your installation in production.

  • Old Magento projects:

    • take a backup from your data base.

    • Add your existing Magento 2 code inside the src directory.

    • Magento 2 only: In the root directory of this project run the installer.

      sh bin/console.sh install
    • Connect with the phpadmin you just install and use your data base backup for apply your last version. Just use the port you set on .env file.

      • If you prefer, you can use docker-compose exec comand in the mariadb container and apply your backup using mysql, you should add your backup in the directory config/backups it will appears inside container at the address /backups
        docker-compose exec mysql sh -c="mysql -u $DATABASE_USER -p $DATABASE_NAME < /backups/$BACKUP_FILE_NAME"
    • Done, you can start to use or develop your old magento project.

  • Magento 2 from scratch

    • In the root directory of this projet, run this line:

       rm src/.gitkeep && composer create-project --repository=https://repo.magento.com/ magento/project-community-edition src && touch src/.gitkeep

      The first time it will ask for your magento authentication keys, click here for obtain yours if you don't have ones.

    • In the root directory of this project run the installer.

      sh bin/console.sh install
    • Done, you can start to use or develop magento 2

Usage

Painless Magento 2 comes with bin/console.sh script that can be used to install Magento, execute Magento's commands, create config files and manage docker containers:

Trigger the Magento 2 installation process:

sh bin/console.sh install

Start the docker containers:

sh bin/console.sh start

Stop the docker containers:

sh bin/console.sh stop

Execute bin/magento inside the docker container:

sh bin/console.sh mage [arguments]

For more information on how to use docker-compose visit: https://docs.docker.com/compose/

Variables

You can customize them in the .env file before run the instalation

Variable Default Value Notes
MAGE_DOMAIN painlessmagento.test
ROOT_PROJECT Commented DOCKER-TOOLS USERS ONLY
patch for use volumes, outsite c:/Users in windows,
1) add the project's directory to the shared directories in your VM.
2) uncomment ROOT_PROJECT line and write the address you add inside the VM.
U_ID 33 Use the uid of the host owner of /src directory
Using bash or bash for windows you can get this using
echo $UID
WEB_USER www-data Using bash or bash for windows you can get this using
echo $USERNAME
NETWORK_BASE 169.254.81 first 3 parts of local ip network you like to use
PHPMYADMIN_PORT 8080 You can access phpmyadmin using http://MAGE_DOMAIN:PHPMYADMIN_PORT
TODO: add phpadmin to nginx adding a subdomain and add SSL certification
MAGENTO VARIABLES
ENVIROMENT developer Magento accepts this three enviroments:
- default
- developer
- production
DATABASE_NAME painlessmagento
DATABASE_USER magento
DATABASE_PASSWORD magneto123
DATABASE_ROOT_PASSWORD magento123_root
ORDER_PREFIX inv
BACKEND_FRONTNAME management
ADMIN_USERNAME admin
ADMIN_FIRSTNAME Jhon
ADMIN_LASTNAME Doe
ADMIN_EMAIL [email protected]
ADMIN_PASSWORD Magento123
DEFAULT_LANGUAGE en_US
DEFAULT_CURRENCY USD
DEFAULT_TIMEZONE America/New_York
EMAIL_SENDER [email protected]
SMTP_SERVER smtp.mailtrap.io I like use mailtrap for development
SMTP_PORT 587
SMTP_USER Your_User
SMTP_PASS Your_Password

Warnigs

Use at your own risk, no waranties included.

You can use the default enviroment values for development, it's not big deal but.

I strongly recomemnd change ALL the values in the .env when you use PainlessMagento for production.

Licensing

Painless Magento 2 is licensed under the Apache License, Version 2.0. See LICENSE for the full license text.

References and Lectures

starting point and base of this project:

https://github.com/arvatoSCM/dockerize-magento2

use docker in windows home:

https://medium.freecodecamp.org/how-to-set-up-docker-and-windows-subsystem-for-linux-a-love-story-35c856968991

docker-compose file reference:

https://docs.docker.com/compose/compose-file/

Handling permissions with docker volumes:

https://denibertovic.com/posts/handling-permissions-with-docker-volumes/

docker nginx, let's encrypt configuration:

https://www.digitalocean.com/community/tutorials/how-to-secure-a-containerized-node-js-application-with-nginx-let-s-encrypt-and-docker-compose

Add users in alpine linux:

https://stackoverflow.com/questions/49955097/how-do-i-add-a-user-when-im-using-alpine-as-a-base-image

Redis configuration:

https://devdocs.magento.com/guides/v2.3/config-guide/redis/redis-session.html

https://devdocs.magento.com/guides/v2.3/config-guide/redis/redis-pg-cache.html

magento cli instalation guide:

https://devdocs.magento.com/guides/v2.3/install-gde/install/cli/install-cli-install.html#instgde-install-cli-magento

set cronjob in bash file:

https://www.digitalocean.com/community/tutorials/how-to-secure-a-containerized-node-js-application-with-nginx-let-s-encrypt-and-docker-compose

You might also like...
Contracts for Rule Doc Generator. Useful for production code with minimum dependencies.

Rule Doc Generator Contracts Contracts for Rule Doc Generator. Useful for production code with minimum dependencies. Install composer require symplify

PaaS template based on production template using platform.sh

Shopware for Platform.sh This template builds Shopware on Platform.sh using Composer. To get started on Platform.sh, please visit https://docs.platfor

 Official OpenMage LTS codebase | Migrate easily from Magento Community Edition in minutes
Official OpenMage LTS codebase | Migrate easily from Magento Community Edition in minutes

Official OpenMage LTS codebase | Migrate easily from Magento Community Edition in minutes! Download the source code for free or contribute to OpenMage LTS | Security vulnerability patches, bug fixes, performance improvements and more.

A htaccess boilerplate for all Magento Community installations. Features focus on speed, SEO and security.

magento-htaccess A htaccess boilerplate for all Magento Community installations. Features focus on speed, SEO and security. The file should be placed

A Magento 1.x module which facilitates automatic purging of static assets from HTTP caches such as browser cache, CDN, Varnish, etc using best practices outlined within the HTML5 boilerplate community.

Magento Cachebuster Cachebuster is a Magento module which facilitates automatic purging of static assets from HTTP caches such as browser cache, CDN,

A Magento community sourced security pre-flight checklist.

Magento Security Checklist This is a community sourced checklist of security measures to take before launching your store. Think of it as a pre-flight

Magento React Native Community
Magento React Native Community

Magento React Native Community New version of the https://github.com/troublediehard/magento-react-native based on GraphQL api. Which will be covered w

Deutsches Sprachpaket für Magento 2 Community Edition

Magento 2 German LocalePack de_DE Deutsches Sprachpaket für Magento 2 Community Edition (Version 2.4.2) Die Übersetzung wurde von deutschen Mutterspra

A simple shell script which loads a magento environment

A simple shell script to load up a Magento environment and execute PHP code Very experimental and should only be ran on dev servers REQUIRES php pcntl

Releases(v1.2.1)
  • v1.2.1(Nov 5, 2020)

  • v1.1.0(Jul 10, 2019)

    Docker Tools is a legacy Desktop solution, Painless Magento still suport them but I prefer give support to Docker Desktop as docker for development in Windows and Mac.

    Source code(tar.gz)
    Source code(zip)
  • 1.0.0(Apr 30, 2019)

    includes:

    • phpMyAdmin: alpine
    • mariadb: alpine
    • nginx: alpine
    • php7.2-fqm-alpine run with socket
    • redis: alpine
    • let's encrypt: alpine
    • an script bin/console for facilitate the use.
    Source code(tar.gz)
    Source code(zip)
Owner
Cocoa Web Studio
Cocoa Web Studio
Production-grade rapid controller development with built in love for API and Search

Installation For CakePHP 4.x compatible version: composer require friendsofcake/crud For CakePHP 3.x compatible version: composer require friendsofca

Friends Of Cake 357 Jan 2, 2023
A Magento Development Environment Made of Docker Containers

Docker for Magento 1 Extension Development Tl;dr How do I use this? Clone it. Type docker-compose up -d. Install a Magento Mount your file share. Deve

Michael A. Smith 99 May 10, 2021
Mage2click toolset to create and manage the Magento Docker development environment with mutagen.io file-sync for macOS and native filesystem mounts on Linux.

Mage2click - Magento Docker Toolset Mage2click toolset is a system-wide command-line tool for creating and managing simultaneously running Magento Doc

Mage2click 69 Nov 28, 2022
Magento - Magento Community Editions

Magento Community Edition /// THIS REPOSITORY IS DEPREACTED /// 1.9.4.1 will be the last version update. Please switch over to OpenMage! Either to the

FireGento e. V. 107 Oct 17, 2022
A dockerized PHP application containing some file upload vulnerability challenges (scenarios)

File Upload Vulnerability Scenarios (Challenges) This repository is a dockerized PHP application containing some file upload vulnerability challenges

Moein Fatehi 15 Dec 23, 2022
Fully covered with tests, documented by Swagger and dockerized API based on enterprise-level framework with optional queue worker.

symfony-api Fully covered with tests, documented by Swagger and dockerized API based on enterprise-level framework with optional queue worker. ⚙️ Depl

Oleksii Velychko 1 Nov 20, 2022
Full PHP development environment for Docker.

Full PHP development environment based on Docker. Use Docker First - Learn About It Later! Join Us Awesome People Laradock is an MIT-licensed open sou

laradock 11.7k Jan 7, 2023
Rubix Server is a library for bringing your trained Rubix ML models into production.

Rubix Server is a library for bringing your trained Rubix ML models into production. Inference servers are stand-alone services that run on your private or public network and wrap your trained estimator in an API that can be queried locally or over the network in real-time using standard protocols. In addition, the library provides async-compatible client implementations for making queries to the server from your PHP applications.

Rubix 50 Aug 15, 2022