Skip to content

Commit b27ee02

Browse files
author
Dmytro Yushkin
committed
[1.0.0] Initial commit
- Added CHANGELOG.md - Added README.md - Added docker-compose.yml - Added php/Dockerfile - Added nginx/Dockerfile - Added nginx/conf/test.com.conf
0 parents  commit b27ee02

File tree

6 files changed

+276
-0
lines changed

6 files changed

+276
-0
lines changed

CHANGELOG.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# Changelog
2+
3+
## [1.0.0] - 2018-08-15
4+
### Added
5+
- CHANGELOG.md file to keep changes between versions.
6+
- README.dm file for repository description.
7+
- docker-compose.yml file with directives to run required containers.
8+
- php/Dockerfile with instructions to raise php-fpm with required extensions and scripts to install Magento2 instance.
9+
- nginx/Dockerfile to raise latest nginx image and copy configuration file from host to container.
10+
- nginx/conf/test.com.conf file with required nginx configuration to run Magento2 instance.

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# Magento 2 Docker project

docker-compose.yml

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
version: "3"
2+
services:
3+
web:
4+
build: ./nginx
5+
ports:
6+
- "80:80"
7+
links:
8+
- php
9+
volumes:
10+
- magento:/var/www/magento
11+
- magento-vendor:/var/www/magento/vendor
12+
php:
13+
build: ./php
14+
expose:
15+
- 9000
16+
volumes:
17+
- magento:/var/www/magento
18+
- magento-vendor:/var/www/magento/vendor
19+
depends_on:
20+
- db
21+
db:
22+
image: mariadb:latest
23+
expose:
24+
- 3306
25+
environment:
26+
MYSQL_ROOT_PASSWORD: 123123q
27+
MYSQL_DATABASE: magento
28+
MYSQL_USER: magento
29+
MYSQL_PASSWORD: 123123q
30+
volumes:
31+
magento:
32+
magento-vendor:

nginx/Dockerfile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
FROM nginx:latest
2+
3+
COPY ./conf/test.com.conf /etc/nginx/conf.d/test.com.conf

nginx/conf/test.com.conf

Lines changed: 184 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,184 @@
1+
server {
2+
listen 80;
3+
listen [::]:80;
4+
server_name test.com;
5+
6+
set $MAGE_MODE production;
7+
set $MAGE_ROOT /var/www/magento;
8+
root $MAGE_ROOT/pub;
9+
10+
index index.php;
11+
autoindex off;
12+
charset UTF-8;
13+
error_page 404 403 = /errors/404.php;
14+
#add_header "X-UA-Compatible" "IE=Edge";
15+
16+
# PHP entry point for setup application
17+
location ~* ^/setup($|/) {
18+
root $MAGE_ROOT;
19+
location ~ ^/setup/index.php {
20+
fastcgi_pass php:9000;
21+
22+
fastcgi_param PHP_FLAG "session.auto_start=off \n suhosin.session.cryptua=off";
23+
fastcgi_param PHP_VALUE "memory_limit=756M \n max_execution_time=600";
24+
fastcgi_read_timeout 600s;
25+
fastcgi_connect_timeout 600s;
26+
27+
fastcgi_index index.php;
28+
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
29+
include fastcgi_params;
30+
}
31+
32+
location ~ ^/setup/(?!pub/). {
33+
deny all;
34+
}
35+
36+
location ~ ^/setup/pub/ {
37+
add_header X-Frame-Options "SAMEORIGIN";
38+
}
39+
}
40+
41+
# PHP entry point for update application
42+
location ~* ^/update($|/) {
43+
root $MAGE_ROOT;
44+
45+
location ~ ^/update/index.php {
46+
fastcgi_split_path_info ^(/update/index.php)(/.+)$;
47+
fastcgi_pass php:9000;
48+
fastcgi_index index.php;
49+
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
50+
fastcgi_param PATH_INFO $fastcgi_path_info;
51+
include fastcgi_params;
52+
}
53+
54+
# Deny everything but index.php
55+
location ~ ^/update/(?!pub/). {
56+
deny all;
57+
}
58+
59+
location ~ ^/update/pub/ {
60+
add_header X-Frame-Options "SAMEORIGIN";
61+
}
62+
}
63+
64+
location / {
65+
try_files $uri $uri/ /index.php$is_args$args;
66+
}
67+
68+
location /pub/ {
69+
location ~ ^/pub/media/(downloadable|customer|import|theme_customization/.*\.xml) {
70+
deny all;
71+
}
72+
alias $MAGE_ROOT/pub/;
73+
add_header X-Frame-Options "SAMEORIGIN";
74+
}
75+
76+
location /static/ {
77+
# Uncomment the following line in production mode
78+
# expires max;
79+
80+
# Remove signature of the static files that is used to overcome the browser cache
81+
location ~ ^/static/version {
82+
rewrite ^/static/(version[^/]+/)?(.*)$ /static/$2 last;
83+
}
84+
85+
location ~* \.(ico|jpg|jpeg|png|gif|svg|js|css|swf|eot|ttf|otf|woff|woff2|json)$ {
86+
add_header Cache-Control "public";
87+
add_header X-Frame-Options "SAMEORIGIN";
88+
expires +1y;
89+
90+
if (!-f $request_filename) {
91+
rewrite ^/static/?(.*)$ /static.php?resource=$1 last;
92+
}
93+
}
94+
location ~* \.(zip|gz|gzip|bz2|csv|xml)$ {
95+
add_header Cache-Control "no-store";
96+
add_header X-Frame-Options "SAMEORIGIN";
97+
expires off;
98+
99+
if (!-f $request_filename) {
100+
rewrite ^/static/?(.*)$ /static.php?resource=$1 last;
101+
}
102+
}
103+
if (!-f $request_filename) {
104+
rewrite ^/static/?(.*)$ /static.php?resource=$1 last;
105+
}
106+
add_header X-Frame-Options "SAMEORIGIN";
107+
}
108+
109+
location /media/ {
110+
try_files $uri $uri/ /get.php$is_args$args;
111+
112+
location ~ ^/media/theme_customization/.*\.xml {
113+
deny all;
114+
}
115+
116+
location ~* \.(ico|jpg|jpeg|png|gif|svg|js|css|swf|eot|ttf|otf|woff|woff2)$ {
117+
add_header Cache-Control "public";
118+
add_header X-Frame-Options "SAMEORIGIN";
119+
expires +1y;
120+
try_files $uri $uri/ /get.php$is_args$args;
121+
}
122+
location ~* \.(zip|gz|gzip|bz2|csv|xml)$ {
123+
add_header Cache-Control "no-store";
124+
add_header X-Frame-Options "SAMEORIGIN";
125+
expires off;
126+
try_files $uri $uri/ /get.php$is_args$args;
127+
}
128+
add_header X-Frame-Options "SAMEORIGIN";
129+
}
130+
131+
location /media/customer/ {
132+
deny all;
133+
}
134+
135+
location /media/downloadable/ {
136+
deny all;
137+
}
138+
139+
location /media/import/ {
140+
deny all;
141+
}
142+
143+
# PHP entry point for main application
144+
location ~ (index|get|static|report|404|503|health_check)\.php$ {
145+
try_files $uri =404;
146+
fastcgi_pass php:9000;
147+
fastcgi_buffers 1024 4k;
148+
149+
fastcgi_param PHP_FLAG "session.auto_start=off \n suhosin.session.cryptua=off";
150+
fastcgi_param PHP_VALUE "memory_limit=756M \n max_execution_time=18000";
151+
fastcgi_read_timeout 600s;
152+
fastcgi_connect_timeout 600s;
153+
154+
fastcgi_index index.php;
155+
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
156+
include fastcgi_params;
157+
}
158+
159+
gzip on;
160+
gzip_disable "msie6";
161+
162+
gzip_comp_level 6;
163+
gzip_min_length 1100;
164+
gzip_buffers 16 8k;
165+
gzip_proxied any;
166+
gzip_types
167+
text/plain
168+
text/css
169+
text/js
170+
text/xml
171+
text/javascript
172+
application/javascript
173+
application/x-javascript
174+
application/json
175+
application/xml
176+
application/xml+rss
177+
image/svg+xml;
178+
gzip_vary on;
179+
180+
# Banned locations (only reached if the earlier PHP entry point regexes don't match)
181+
location ~* (\.php$|\.htaccess$|\.git) {
182+
deny all;
183+
}
184+
}

php/Dockerfile

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
FROM php:7.0-fpm
2+
3+
RUN apt-get update && apt-get install -y \
4+
apt-utils \
5+
git \
6+
curl \
7+
unzip \
8+
libmcrypt-dev \
9+
libicu-dev \
10+
libxml2-dev libxslt1-dev \
11+
libfreetype6-dev \
12+
libjpeg62-turbo-dev \
13+
mysql-client \
14+
&& docker-php-ext-configure gd --with-freetype-dir=/usr/include/ --with-jpeg-dir=/usr/include/ \
15+
&& 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
17+
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
20+
21+
WORKDIR /var/www/magento
22+
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 .
28+
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

0 commit comments

Comments
 (0)