Skip to content

Commit 56c2544

Browse files
author
Igor Sydorenko
committed
[2.0.0] Release
1 parent b27ee02 commit 56c2544

File tree

6 files changed

+172
-43
lines changed

6 files changed

+172
-43
lines changed

CHANGELOG.md

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,21 @@
11
# Changelog
22

3+
## [2.0.0] - 2019-03-05
4+
### Added
5+
- MailHog container
6+
- Redis container
7+
- Container names
8+
- Certificate generation for web container
9+
- healthcheck for db container
10+
11+
### Updated
12+
- Documentation
13+
- Renamed hostname
14+
315
## [1.0.0] - 2018-08-15
416
### Added
517
- CHANGELOG.md file to keep changes between versions.
6-
- README.dm file for repository description.
18+
- README.md file for repository description.
719
- docker-compose.yml file with directives to run required containers.
820
- php/Dockerfile with instructions to raise php-fpm with required extensions and scripts to install Magento2 instance.
921
- nginx/Dockerfile to raise latest nginx image and copy configuration file from host to container.

README.md

Lines changed: 103 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,103 @@
1-
# Magento 2 Docker project
1+
# Magento 2 Docker for Developer project
2+
3+
Using this docker project you can initiate a new project or import the existent one.
4+
5+
## Preparation
6+
1. Open https://www.docker.com/
7+
1. Register new account or login with an existent one
8+
1. Download and install docker app
9+
10+
11+
## Install a vanilla Magento
12+
1. Import "magento2-docker" repository
13+
2. Open "magento2-docker" folder in terminal app
14+
3. Create "magento" folder:
15+
`mkdir magento`
16+
4. Build and run all docker components:
17+
`docker-compose up --build`
18+
5. After configuration is build and running open a new terminal tab and connect to php container:
19+
`docker exec -it php bash`
20+
6. Open "magento" folder and verify that the folder is empty:
21+
`cd /var/www/magento; ls -la`
22+
7. Choose your approach below and install the project
23+
24+
7.1 If you want to install a vanilla Magento instance you need to go to https://devdocs.magento.com/guides/v2.3/install-gde/composer.html
25+
and create a new project to the current directory.
26+
27+
Example:
28+
`composer create-project --repository=https://repo.magento.com/ magento/project-enterprise-edition .`
29+
30+
7.2 If you want to install an existent project you need to clone project repository to the "magento" folder:
31+
`git clone <--project_repository_url--> .`
32+
33+
When prompted, enter your Magento authentication keys.
34+
35+
8\. Once composer install is done run Magento install command:
36+
```
37+
php bin/magento setup:install \
38+
--db-host=db \
39+
--db-name=magento \
40+
--db-user=magento \
41+
--db-password=123123q \
42+
--base-url=http://magento.local \
43+
--backend-frontname=admin \
44+
--admin-user=admin \
45+
--admin-password=123123q \
46+
--admin-email=admin@test.com \
47+
--admin-firstname=Magento \
48+
--admin-lastname=User \
49+
--language=en_US \
50+
--currency=USD \
51+
--timezone=America/Chicago \
52+
--skip-db-validation \
53+
&& chown -R www-data:www-data .
54+
```
55+
56+
9\. Update your laptop hosts file: `127.0.0.1 magento.local`
57+
58+
10\. Open http://magento.local/
59+
60+
## Connect to containers via SSH
61+
Docker configuration contains such components as:
62+
- web (nginx service)
63+
- php (php-fpm service)
64+
- db (MySQL service)
65+
- redis (redis service)
66+
- mail (mailhog mail service)
67+
68+
For connecting to container via SSH you need use the command:
69+
`docker exec -it <--container_name--> bash`, where <--container_name--> is container name
70+
71+
Example:
72+
`docker exec -it web`
73+
74+
## Reloading services
75+
76+
### Reload ngnix
77+
```
78+
docker exec -it web
79+
/etc/init.d/nginx reload
80+
```
81+
82+
### Reload php
83+
```
84+
docker docker-compose restart php
85+
```
86+
87+
## Connect to MySQL from your laptop
88+
You're able to connect to MySQL using "0.0.0.0" as host, port should be default one - "3306", credentials from .env file
89+
90+
## Using MailHog for sending emails
91+
You're able to find all the email you send from Magento instance on http://localhost:8025/
92+
93+
## Switch to PHP 7.x
94+
1\. Shutdown your current docker instance
95+
96+
2\. Change PHP version in ./php/Docker file to needed version
97+
98+
Example:
99+
100+
If you need to change PHP version from 7.2 to 7.1 you need to change `FROM php:7.2-fpm` to `FROM php:7.1-fpm`
101+
102+
3\. Build and run all docker components:
103+
`docker-compose up --build`

docker-compose.yml

Lines changed: 23 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,45 @@
11
version: "3"
22
services:
33
web:
4+
container_name: web
45
build: ./nginx
56
ports:
67
- "80:80"
78
links:
89
- php
910
volumes:
10-
- magento:/var/www/magento
11-
- magento-vendor:/var/www/magento/vendor
11+
- ./magento:/var/www/magento
1212
php:
13+
container_name: php
1314
build: ./php
1415
expose:
1516
- 9000
1617
volumes:
17-
- magento:/var/www/magento
18-
- magento-vendor:/var/www/magento/vendor
18+
- ./magento:/var/www/magento
1919
depends_on:
2020
- db
2121
db:
22+
container_name: db
2223
image: mariadb:latest
24+
ports:
25+
- "3306:3306"
2326
expose:
2427
- 3306
25-
environment:
26-
MYSQL_ROOT_PASSWORD: 123123q
27-
MYSQL_DATABASE: magento
28-
MYSQL_USER: magento
29-
MYSQL_PASSWORD: 123123q
28+
env_file: .env
29+
healthcheck:
30+
test: ["CMD", "mysqladmin" ,"ping", "-h", "localhost", "-p$MYSQL_ROOT_PASSWORD"]
31+
timeout: 20s
32+
retries: 10
33+
mailhog:
34+
container_name: mail
35+
image: mailhog/mailhog:latest
36+
links:
37+
- php
38+
ports:
39+
- "1025:1025"
40+
- "8025:8025"
41+
redis:
42+
container_name: redis
43+
image: redis:latest
3044
volumes:
3145
magento:
32-
magento-vendor:

nginx/Dockerfile

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
11
FROM nginx:latest
22

3-
COPY ./conf/test.com.conf /etc/nginx/conf.d/test.com.conf
3+
RUN apt-get update && apt-get install -y \
4+
vim \
5+
nano
6+
7+
COPY ./conf/magento.local.conf /etc/nginx/conf.d/magento.local.conf
8+
9+
RUN apt-get -qq update && apt-get -qq -y install openssl && mkdir -p /etc/nginx/ssl && cd /etc/nginx/ssl
10+
RUN cd /etc/nginx/ssl && openssl req -newkey rsa:2048 -nodes -keyout magento.key -x509 -days 365 \
11+
-out magento.pem -subj "/C=UA/ST=Kyiv/L=Kyiv/O=magento.local/OU=magento.local/CN=magento.local"
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
server {
22
listen 80;
33
listen [::]:80;
4-
server_name test.com;
4+
server_name magento.local;
55

66
set $MAGE_MODE production;
77
set $MAGE_ROOT /var/www/magento;

php/Dockerfile

Lines changed: 23 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,46 +1,40 @@
1-
FROM php:7.0-fpm
1+
FROM php:7.2-fpm
22

3-
RUN apt-get update && apt-get install -y \
3+
RUN apt-get update && apt-get -qq install -y \
44
apt-utils \
55
git \
66
curl \
77
unzip \
8+
vim \
9+
nano \
810
libmcrypt-dev \
911
libicu-dev \
1012
libxml2-dev libxslt1-dev \
1113
libfreetype6-dev \
1214
libjpeg62-turbo-dev \
1315
mysql-client \
16+
ssmtp \
17+
mailutils \
1418
&& docker-php-ext-configure gd --with-freetype-dir=/usr/include/ --with-jpeg-dir=/usr/include/ \
1519
&& docker-php-ext-configure hash --with-mhash \
16-
&& docker-php-ext-install -j$(nproc) mcrypt intl xsl gd zip pdo_mysql opcache soap bcmath json iconv
20+
&& docker-php-ext-install -j$(nproc) intl xsl gd zip pdo_mysql opcache soap bcmath json iconv pcntl sockets
1721

18-
RUN git clone https://github.com/magento/magento2.git /var/www/magento \
19-
&& curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer
22+
# Install xdebug extension
23+
RUN pecl install xdebug-2.6.1 && docker-php-ext-enable xdebug \
24+
&& echo "xdebug.default_enable = 0" >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini \
25+
&& echo "xdebug.idekey = PHPSTORM" >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini \
26+
&& echo "xdebug.remote_enable = 1" >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini \
27+
&& echo "xdebug.remote_host = host.docker.internal" >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini \
28+
&& echo "xdebug.remote_port = 9007" >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini
2029

21-
WORKDIR /var/www/magento
30+
# Configure MailHog
31+
RUN echo "mailhub=mail:1025" >> /etc/ssmtp/ssmtp.conf \
32+
&& echo 'sendmail_path = "/usr/sbin/ssmtp -t"' > /usr/local/etc/php/conf.d/mail.ini
33+
34+
# Install Composer
35+
RUN cd /usr/src && curl -sS http://getcomposer.org/installer | php
36+
RUN cd /usr/src && mv composer.phar /usr/bin/composer
2237

23-
RUN composer install \
24-
&& find var generated vendor pub/static pub/media app/etc -type f -exec chmod u+w {} \; \
25-
&& find var vendor generated pub/static pub/media app/etc -type d -exec chmod u+w {} \; \
26-
&& chmod u+x bin/magento \
27-
&& chown -R www-data:www-data .
38+
WORKDIR /var/www/magento
2839

29-
CMD php bin/magento setup:install \
30-
--db-host=db \
31-
--db-name=magento \
32-
--db-user=magento \
33-
--db-password=123123q \
34-
--base-url=http://test.com \
35-
--backend-frontname=admin \
36-
--admin-user=admin \
37-
--admin-password=123123q \
38-
--admin-email=admin@test.com \
39-
--admin-firstname=Magento \
40-
--admin-lastname=User \
41-
--language=en_US \
42-
--currency=USD \
43-
--timezone=America/Chicago \
44-
--skip-db-validation \
45-
&& chown -R www-data:www-data . \
46-
&& php-fpm
40+
CMD php-fpm

0 commit comments

Comments
 (0)