Skip to content

Commit

Permalink
Fixed GH-3
Browse files Browse the repository at this point in the history
  • Loading branch information
Rafael Grigorian committed Aug 15, 2018
1 parent dc118d1 commit d95e274
Show file tree
Hide file tree
Showing 21 changed files with 6,157 additions and 9 deletions.
15 changes: 12 additions & 3 deletions build.yml
Original file line number Diff line number Diff line change
@@ -1,15 +1,24 @@
version: "2"

services:
php-fpm:
php-fpm-7.1:
image: jetrails/magento-alpine:php-fpm-7.1
build: src/php-fpm-7.1
php-cli:
php-cli-7.1:
image: jetrails/magento-alpine:php-cli-7.1
build: src/php-cli-7.1
php-cron:
php-cron-7.1:
image: jetrails/magento-alpine:php-cron-7.1
build: src/php-cron-7.1
php-fpm-5.6:
image: jetrails/magento-alpine:php-fpm-5.6
build: src/php-fpm-5.6
php-cli-5.6:
image: jetrails/magento-alpine:php-cli-5.6
build: src/php-cli-5.6
php-cron-5.6:
image: jetrails/magento-alpine:php-cron-5.6
build: src/php-cron-5.6
nginx:
image: jetrails/magento-alpine:nginx
build: src/nginx
Expand Down
108 changes: 108 additions & 0 deletions dist/magento-1.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
version: "2"

volumes:
database:
app-sync:
external: true
networks:
default:
driver: bridge
ipam:
config:
- subnet: "192.168.7.0/28"
services:
php-fpm:
image: jetrails/magento-alpine:php-fpm-5.6
restart: unless-stopped
volumes:
- app-sync:/var/www/html:rw
networks:
default:
aliases:
- php-fpm.docker.internal
environment:
- VERBOSE=true
expose:
- "9000"
links:
- mysql
- redis
php-cli:
image: jetrails/magento-alpine:php-cli-5.6
volumes:
- app-sync:/var/www/html:rw
networks:
default:
aliases:
- php-cli.docker.internal
links:
- mysql
- redis
php-cron:
image: jetrails/magento-alpine:php-cron-5.6
restart: unless-stopped
volumes:
- app-sync:/var/www/html:rw
networks:
default:
aliases:
- php-cron.docker.internal
environment:
- VERBOSE=false
links:
- mysql
- redis
nginx:
image: jetrails/magento-alpine:nginx
restart: unless-stopped
volumes:
- app-sync:/var/www/html:rw
networks:
default:
aliases:
- nginx.docker.internal
environment:
- VERBOSE=true
- MAGENTO_VERSION=1
links:
- php-fpm
ports:
- "443:443"
mysql:
image: jetrails/magento-alpine:mysql
restart: unless-stopped
volumes:
- database:/var/lib/mysql
networks:
default:
aliases:
- localhost
- mysql.docker.internal
environment:
- VERBOSE=false
- MYSQL_ROOT_PASSWORD=magento
- MYSQL_USER_NAME=magento
- MYSQL_USER_PASSWORD=magento
- MYSQL_DATABASE=magento
varnish:
image: jetrails/magento-alpine:varnish
restart: unless-stopped
environment:
- VERBOSE=false
networks:
default:
aliases:
- varnish.docker.internal
links:
- nginx
ports:
- "80:80"
redis:
image: jetrails/magento-alpine:redis
restart: unless-stopped
networks:
default:
aliases:
- redis.docker.internal
environment:
- VERBOSE=false
5 changes: 3 additions & 2 deletions dist/docker-compose.yml → dist/magento-2.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ services:
aliases:
- php-fpm.docker.internal
environment:
- VERBOSE=false
- VERBOSE=true
links:
- mysql
- redis
Expand Down Expand Up @@ -60,7 +60,8 @@ services:
aliases:
- nginx.docker.internal
environment:
- VERBOSE=false
- VERBOSE=true
- MAGENTO_VERSION=2
links:
- php-fpm
ports:
Expand Down
3 changes: 2 additions & 1 deletion src/nginx/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,9 @@ RUN mkdir -p /var/www/ssl && \

COPY ./bin/startup.sh /usr/local/bin/startup.sh
COPY ./conf/nginx.conf /etc/nginx/nginx.conf
COPY ./conf/http.conf /etc/nginx/conf.d/http.conf
COPY ./conf/https.conf /etc/nginx/conf.d/https.conf
COPY ./conf/magento-1.conf /etc/nginx/available.d/magento-1.conf
COPY ./conf/magento-2.conf /etc/nginx/available.d/magento-2.conf

EXPOSE 8080 443
WORKDIR /var/www/html
Expand Down
8 changes: 8 additions & 0 deletions src/nginx/bin/startup.sh
Original file line number Diff line number Diff line change
@@ -1,8 +1,16 @@
#!/usr/bin/env sh

if [[ "$MAGENTO_VERSION" != "1" ]] && [[ "$MAGENTO_VERSION" != "2" ]]; then
echo "Valid value for MAGENTO_VERSION is not found ... using default value 2"
MAGENTO_VERSION="2"
fi

if [[ "$VERBOSE" == "true" ]]; then
mkdir -p /var/log/nginx
touch /var/log/nginx/error.log /var/log/nginx/access.log
tail -f /var/log/nginx/*.log &
fi

cp "/etc/nginx/available.d/magento-$MAGENTO_VERSION.conf" "/etc/nginx/conf.d/http.conf"
chown -R nginx:nginx /var/www
nginx -g 'daemon off;'
61 changes: 61 additions & 0 deletions src/nginx/conf/magento-1.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
server {
listen 8080 default_server;
listen [::]:8080 default_server;

root /var/www/html;
index index.html index.php;

access_log /var/log/nginx/access.log;
error_log /var/log/nginx/error.log;

location / {
try_files $uri $uri/ @handler;
expires 30d;
}
location /app/ { deny all; }
location /downloader/ { deny all; }
location /includes/ { deny all; }
location /lib/ { deny all; }
location /media/downloadable/ { deny all; }
location /pkginfo/ { deny all; }
location /report/config.xml { deny all; }
location /rss/ { deny all; }
location /var/ { deny all; }

location /var/export/ {
auth_basic "Restricted";
auth_basic_user_file htpasswd;
autoindex on;
}
location /. {
return 404;
}

location @handler {
rewrite / /index.php;
}

location ~ .php/ {
rewrite ^(.*.php)/ $1 last;
}

location ~ \.php$ {
try_files $uri =404;
expires off;
fastcgi_read_timeout 900s;
fastcgi_index index.php;
fastcgi_pass php-fpm.docker.internal:9000;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include /etc/nginx/fastcgi_params;
}
rewrite ^/minify/([0-9]+)(/.*.(js|css))$ /lib/minify/m.php?f=$2&d=$1 last;
rewrite ^/skin/m/([0-9]+)(/.*.(js|css))$ /lib/minify/m.php?f=$2&d=$1 last;

location /lib/minify/ {
allow all;
}
gzip on;
gzip_min_length 1000;
gzip_proxied any;
gzip_types text/plain application/xml text/css text/js application/x-javascript;
}
File renamed without changes.
44 changes: 44 additions & 0 deletions src/php-cli-5.6/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
FROM alpine:3.6
LABEL maintainer development@jetrails.com

RUN apk --update --no-cache add \
shadow \
curl \
vim \
git \
tree \
php5 \
php5-bcmath \
php5-cli \
php5-ctype \
php5-curl \
php5-dom \
php5-gd \
php5-iconv \
php5-intl \
php5-json \
php5-mcrypt \
php5-mysql \
php5-openssl \
php5-pdo \
php5-pdo_mysql \
php5-phar \
php5-soap \
php5-xml \
php5-xsl \
php5-zip \
php5-zlib

RUN addgroup -g 1000 magento && \
adduser -D -S -G magento -u 1000 -s /bin/sh magento

RUN ln -s "$(which php5)" "$(dirname $(which php5))/php" && \
curl --silent --show-error https://getcomposer.org/installer | php && \
mv composer.phar /usr/bin/composer

COPY ./conf/php.ini /etc/php5/php.ini
COPY ./conf/aliases.sh /etc/profile.d/aliases.sh

USER magento
WORKDIR /var/www/html
ENTRYPOINT [ "sh", "-l" ]
2 changes: 2 additions & 0 deletions src/php-cli-5.6/conf/aliases.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
alias ll='ls -la --color'
alias magento='chmod +x ./mage && ./mage'
Loading

0 comments on commit d95e274

Please sign in to comment.