A repository documenting, and building local development environments created in docker.
1.3K
A single repository for maintaining local Magento development environments using docker.
Get added to the project by the Magento contact, once server setup is complete.
Login to https://magento.com and navigate to https://account.magento.com/cloud/project/subscriptions/, then click on the project.
Navigate to the Infrastructure Access and open the Project Access (Web UI).
Clone the project from Magento Cloud to your local environment and setup in phpstorm, making sure to switch to the integration branch.
Create the auth.json file from the env:COMPOSER_AUTH variable under the settings menu.
Add the following under repositories in the composer.json.
"briteskies-local-docker": {
"type": "vcs",
"url": "[email protected]:briteskies/local-docker.git"
},
"briteskies-magento-pipelines": {
"type": "vcs",
"url": "[email protected]:briteskies/magento-pipelines.git"
},
"artifacts": {
"type": "path",
"url": "artifacts/*/*",
"options": {
"symlink": false
}
}
Run composer require "briteskies/local-docker:dev-2_3 as 2.3.0" "briteskies/magento-pipelines:dev-2_3 as 2.3.0" --ignore-platform-reqs
Add the following require-dev and scripts
"scripts": {
"codestyle-fixer": [
"phpcbf --standard=psr2 --ignore=*.css,*.js --warning-severity=8 app/code/",
"phpcbf --standard=EcgM2 --ignore=*.css,*.js --runtime-set installed_paths vendor/magento-ecg/coding-standard --warning-severity=8 app/code/"
],
"codestyle-check": [
"phpcs --standard=psr2 --ignore=*.css,*.js --warning-severity=8 app/code/",
"phpcs --standard=EcgM2 --ignore=*.css,*.js --runtime-set installed_paths vendor/magento-ecg/coding-standard --warning-severity=8 app/code/"
],
"codestyle-check-warnings": [
"phpcs --standard=psr2 --ignore=*.css,*.js --runtime-set ignore_warnings_on_exit true app/code/",
"phpcs --standard=EcgM2 --ignore=*.css,*.js --runtime-set installed_paths vendor/magento-ecg/coding-standard --runtime-set ignore_warnings_on_exit true app/code/"
],
"vulnerabilities-check": [
"security-checker security:check"
]
},
"require-dev": {
"cweagans/composer-patches": "^1.6",
"lusitanian/oauth": "~0.8.10",
"magento-ecg/coding-standard": "^3.1",
"pdepend/pdepend": "2.5.2",
"phpmd/phpmd": "^2.6",
"phpunit/phpunit": "~6.2.0",
"sebastian/phpcpd": "~3.0.0",
"squizlabs/php_codesniffer": "3.2.2",
"friendsofphp/php-cs-fixer": "~2.10.1",
"briteskies/local-docker": "^1.0"
}
Run composer update
Add any urls required (including local and integration) to magento-var.php.
Adjust the settings of .magento.env.yaml
relationships add elasticsearch: "elasticsearch:elasticsearch"web > locations > rules should be updated from |svgz| to |svgz?|disk = 4096Add the following rules to the magento/routes.yaml with redirects for each production url without a www.
"https://{default}/":
type: upstream
upstream: "mymagento:php"
"http://*.{default}/":
type: upstream
upstream: "mymagento:php"
"https://*.{default}/":
type: upstream
upstream: "mymagento:php"
https://DOMAIN.com/:
type: redirect
redirects:
expires: -1s
paths: {}
tls:
strict_transport_security:
enabled: null
include_subdomains: null
preload: null
min_version: null
client_authentication: null
client_certificate_authorities: []
to: https://www.DOMAIN.com/
Add the following to magento/services.yaml
elasticsearch:
type: elasticsearch:5.2
disk: 1024
configuration:
plugins:
- analysis-icu
- analysis-phonetic
Create an empty frontend theme for the project based off of Magento/blank. EG Cvi/default
Create the following files for grunt and force add them to the git repo: package.json, grunt-config.json, Gruntfile.js, dev/tools/grunt/configs/local-themes.js
Copy examples/docker-compose.example.yml and examples/docker-compose.windows-example.yml the root of the project and force add them into git.
Use one of the example files to setup your docker-compose.yml and customize the volumes as needed.
Copy examples/env.php.docker to app/etc/examples/env.php.docker and examples/env.php and force app/etc/examples/env.php.docker into git.
Run bash .docker/fresh-build.sh to create an empty site.
Verify that the site runs and commit changes back to the repository.
See the magento-pipelines project for setup of Bitbucket, Servers.
Login to bitbucket.
Create a new repository
Clone the repository locally.
Edit the README.md to contain something along the lines of the following where [project-slug] is the url path for the project.
# [project-slug]
###### A repository for the [project-slug] magento site.
### Getting Started
- Follow the instructions in https://bitbucket.org/briteskies/local-docker/src/2_3/ to setup a local docker environment.
- Follow the instructions under "New Development/Deployment Process Overview" https://bitbucket.org/briteskies/magento-pipelines/src/2_3/ to learn how to work with this project.
- If bugs arise, search through this jira board for any known solutions https://briteskies.atlassian.net/projects/MAG/board/.
### Please document any peculiarities or recommendations for working the project here.
- Update the above lines accordingly when the Magento Version changes.
Copy examples/.gitignore.example into the root of the project as .gitignore.
Copy examples/composer.json into the root of the project.
Copy examples/docker-compose.yml into the root of the project as both docker-compose.yml and docker-compose.yml.example.\
Copy examples/env.php.docker to app/etc/examples/env.php.docker and examples/env.php.
Apply any customizations required to the docker-compose.yml.
Run composer install.
Run the following command on the host for magento 2.3 changing the root dir as needed. php dev/tools/UpgradeScripts/pre_composer_update_2.3.php --root ~/html/magento2-ee-2.3
Run composer update --ignore-platform-reqs.
Run bash .docker/docker-restart.sh.
Create a .docker/sql/scrub-db-variables.sql file from .docker/sql/scrub-db-variables.default.sql and customize it as needed.
Run bash .docker/fresh-build.sh.
Verify that the site runs and commit changes back to the repository.
Set the minimum-stability to beta in the composer.json of the project.
Add the following to the composer.json of the project under the repositories section. The key is optional depending on the file.
"briteskies-local-docker": {
"type": "vcs",
"url": "[email protected]:briteskies/local-docker.git"
},
Run composer require briteskies/local-docker:dev-2_3 as 2.3.0 --ignore-platform-reqs.
Copy .docker/examples/env.php to app/etc/env.php.docker and apply and customizations that are desired for the project.
cp .docker/examples/env.php.docker app/etc/env.php.docker
Copy .docker/examples/docker-compose.yml to docker-compose.yml.example and apply and customizations that are desired for the project.
cp .docker/examples/docker-compose.yml docker-compose.yml.example
Add the following to the .gitignore file for the project or use the .docker/examples/.gitignore
# Docker
.docker
docker-compose.yml
Commit and push the updates to back to the project repository.
cd to your project directory.composer install --ignore-platform-reqs.app/etc/env.php.docker to app/etc/env.php
.docker-compose.yml.example to docker-compose.yml.
volumes in the file and adjust the host paths (the part before the :)to match the actual file and folder location on your system.
custom. to the beginning of the file.sudo chmod +x .docker/*.sh to fix file permissions.bash .docker/sync-with-vendor.sh or bash .docker/sync-with-artifacts.sh to copy files that magento misses.bash .docker/docker-restart.sh or docker-compose up -d.
docker-compose.yml (the part before the :) to ones that are available on your host..docker/sql/scrub-db-variables.default.sql to .docker/sql/scrub-db-variables.sql and customize any variables to your liking..docker/sql/backups and run bash .docker/refresh-database.sh
bash .docker/fresh-build.sh or bash .docker/install-database.sh (TODO for Setup Performance and Demo sites.)bash .docker/php-connect.sh and run your own commands to install the database.127.0.0.1 local.briteskies.com to your hosts file, or add an entry for the new url if you changed the site url in the above step..docker/fresh-install.sh (~15m)
bash .docker/deploy-site.sh (~6m), .docker/deploy-site-fast.sh (~6m - ~30s), bash docker/refresh-database.sh (~6m), or bash docker/reindex.sh (~6m) as needed.docker-compose downbash .docker/php-connect.shxdebug.remote_connect_back=1 in .docker/contexts/apache/httpd-vhosts.conf.docker/contexts/apache/httpd-vhosts.conf:20 mataches both the name and host of the server in phpstorm.docker-compose.yml)| Service | Location | User | Pass |
|---|---|---|---|
| Magento | http://local.briteskies.com | [email protected] | [email protected] |
| Magento Admin | http://local.briteskies.com/admin | [email protected] | [email protected] |
| Magento Ignore Varnish | http://local.briteskies.com:8080 | [email protected] | [email protected] |
| MailDev | http://localhost:1080 | ||
| PhpMyAdmin | http://localhost:8888 | root | root |
| Kibana (ElasticSearch UI) | http://localhost:5601 | username | password |
| Redis Commander | http://localhost:8081 | ||
| RabbitMQ Admin | http://localhost:15672 | guest | guest |
Download this repo.
If downloaded a part of a project, this environment can be edited directly by copying the .git folder from the vendor directory
cp -a vendor/briteskies/local-docker/ .docker
Test building from the docker-compose.yml:
# starting the from this repositories root.
cd examples
# build docker environment (requires symlinks to be working)
docker-compose down ; docker-compose up --build --remove-orphans --verbose
# view http://localhost:8080/info.php in a browser to confirm
# add any additional sites or data for testing to `examples/pub`
Edit, Commit, and Push changes branching accordingly (eg 1_14, 2_0, 2_1, 2_3, etc).
hub.docker.com is automatically triggered to build/rebuild the docker image. (TODO for Setup Performance)
After build completes download and use. (TODO for Setup Performance)
Docker Creation Overview or cd .docker in an existing project and use it like any other git repo.composer require briteskies/local-docker:dev-X_X --ignore-platform-reqs where X_X are the first two Magento version numbers.docker-compose.yml.example and app/etc/env.php.docker..git/hooks in the project's repository.
pub/media archives for local use.scrub-db-* will place it at the end.docker/refresh-database.sh, .docker/deploy-site.sh, anddocker/reindex.sh repectively.mage and magerun are available aliases)sql/backups..default. file then include the one without default like the scrub-db-variables.default.sql
docker-compose.yml.example has been updated.&& from shell scripting is used prolifically to reduce build steps.| Term | Definition |
|---|---|
| Docker | A tool to create, run, and network containers that encapsulate a specific set of programs. Unlike Virtual Machines, they don't contain a full operating system and share a kernel with the host. |
| Image | A downloadable binary file that preserves a perfect copy of the software until it is intentionally edited. |
| Container | The runtime version of an image that has a unique name and may have additional arguments, volumes, and networking. Changes inside a container are lost on shutdown unless explicitly saved. |
| Dockerfile | Instructions for building a docker image. |
| Context | Additional files that are used by the Dockerfile to build an image. By default it includes the contents of the directory the Dockerfile is in and upwards. |
| .docker-ignore | Like .git-ignore, but used to prevent files in the Context from being loaded while building an image from the Dockerfile. |
| Volume | A mounting point between the host and a container that can share entire folders or individual files. |
| Storage Volume | A special volume that is used by containers to persist data between shutdowns. (Eg. databases) |
| docker-compose.yml | A file with instructions for how to turn multiple images or builds into containers along with any additional arguments, volumes, or networking. |
Content type
Image
Digest
Size
455 MB
Last updated
over 6 years ago
docker pull briteskies/local-docker:2_3_3-elasticsearch