Skip to content

Pwa apache #114

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 14 commits into
base: master
Choose a base branch
from
6 changes: 5 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
/src/*
.DS_Store
/.idea
/docker-compose.yml
src
db
server/proxy/logs/
src/index.php
server/proxy/ssl/
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
128 changes: 128 additions & 0 deletions Dockerfile/apache/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,128 @@
FROM php:7.2-apache

MAINTAINER Rafael Corrêa Gomes <[email protected]>

ENV XDEBUG_PORT 9000

# Install System Dependencies

RUN apt-get update \
&& DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \
software-properties-common \
&& apt-get update \
&& DEBIAN_FRONTEND=noninteractive apt-get install -y \
libfreetype6-dev \
libicu-dev \
libssl-dev \
libjpeg62-turbo-dev \
libmcrypt-dev \
libedit-dev \
libedit2 \
libxslt1-dev \
apt-utils \
gnupg \
redis-tools \
mariadb-client \
git \
vim \
wget \
curl \
lynx \
psmisc \
unzip \
tar \
cron \
bash-completion \
libsodium-dev \
&& apt-get clean

# Install Magento Dependencies

RUN docker-php-ext-configure \
gd --with-freetype-dir=/usr/include/ --with-jpeg-dir=/usr/include/; \
docker-php-ext-install \
opcache \
gd \
bcmath \
intl \
mbstring \
# mcrypt \
pdo_mysql \
soap \
xsl \
zip \
sockets

# Install oAuth

RUN apt-get update \
&& apt-get install -y \
libpcre3 \
libpcre3-dev \
# php-pear \
&& pecl install oauth \
&& echo "extension=oauth.so" > /usr/local/etc/php/conf.d/docker-php-ext-oauth.ini

# Install Node, NVM, NPM and Grunt

RUN curl -sL https://deb.nodesource.com/setup_11.x | bash - \
&& apt-get install -y nodejs build-essential \
&& curl https://raw.githubusercontent.com/creationix/nvm/v0.16.1/install.sh | sh \
&& npm i -g grunt-cli yarn

# Install Composer

RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin/ --filename=composer
RUN composer global require hirak/prestissimo

# Install Code Sniffer

RUN git clone https://github.com/magento/marketplace-eqp.git ~/.composer/vendor/magento/marketplace-eqp
RUN cd ~/.composer/vendor/magento/marketplace-eqp && composer install
RUN ln -s ~/.composer/vendor/magento/marketplace-eqp/vendor/bin/phpcs /usr/local/bin;

ENV PATH="/var/www/.composer/vendor/bin/:${PATH}"

# Install XDebug

RUN yes | pecl install xdebug && \
echo "zend_extension=$(find /usr/local/lib/php/extensions/ -name xdebug.so)" > /usr/local/etc/php/conf.d/xdebug.iniOLD

# Install Mhsendmail

RUN DEBIAN_FRONTEND=noninteractive apt-get -y install golang-go \
&& mkdir /opt/go \
&& export GOPATH=/opt/go \
&& go get github.com/mailhog/mhsendmail

# Install Magerun 2

RUN wget https://files.magerun.net/n98-magerun2.phar \
&& chmod +x ./n98-magerun2.phar \
&& mv ./n98-magerun2.phar /usr/local/bin/

# Configuring system

ADD .docker/config/php.ini /usr/local/etc/php/php.ini
ADD .docker/config/magento.conf /etc/apache2/sites-available/magento.conf
ADD .docker/config/custom-xdebug.ini /usr/local/etc/php/conf.d/custom-xdebug.ini
COPY .docker/bin/* /usr/local/bin/
COPY .docker/users/* /var/www/
RUN chmod +x /usr/local/bin/*
RUN ln -s /etc/apache2/sites-available/magento.conf /etc/apache2/sites-enabled/magento.conf

RUN curl -o /etc/bash_completion.d/m2install-bash-completion https://raw.githubusercontent.com/yvoronoy/m2install/master/m2install-bash-completion
RUN curl -o /etc/bash_completion.d/n98-magerun2.phar.bash https://raw.githubusercontent.com/netz98/n98-magerun2/master/res/autocompletion/bash/n98-magerun2.phar.bash
RUN echo "source /etc/bash_completion" >> /root/.bashrc
RUN echo "source /etc/bash_completion" >> /var/www/.bashrc

RUN chmod 777 -Rf /var/www /var/www/.* \
&& chown -Rf www-data:www-data /var/www /var/www/.* \
&& usermod -u 1000 www-data \
&& chsh -s /bin/bash www-data\
&& a2enmod rewrite \
&& a2enmod headers \
&& a2enmod ssl

VOLUME /var/www/html
WORKDIR /var/www/html
18 changes: 18 additions & 0 deletions Dockerfile/pwa/.docker/bin/fix-permission
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#!/usr/bin/env bash
chmod -R 777 /var/www/
# find /var/www/html/ -type f -exec chmod 644 {} \; # 644 permission for files
# find /var/www/html/ -type d -exec chmod 755 {} \; # 755 permission for directory
# if [ -d /var/www/html/var/ ]; then
# find /var/www/html/var/ -type d -exec chmod 777 {} \; # 777 permission for var folder
# fi
# if [ -d /var/www/html/pub/ ]; then
# find /var/www/html/pub/ -type d -exec chmod 777 {} \;
# fi
# if [ -d /var/www/html/app/etc ]; then
# chmod 777 /var/www/html/app/etc
# chmod 644 /var/www/html/app/etc/*.xml
# fi
# chown -R :www-data /var/www/html/
if [ -e "/var/www/html/bin/magento" ]; then
chmod u+x /var/www/html/bin/magento
fi
47 changes: 47 additions & 0 deletions Dockerfile/pwa/.docker/bin/install-magento2
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
#!/usr/bin/env bash
if [ $@ ]; then
composer create-project --repository-url=https://repo.magento.com/ magento/project-community-edition:$1 . ;
else
composer create-project --repository-url=https://repo.magento.com/ magento/project-community-edition . ;
fi
chmod u+w -R ./var ./vendor ./pub/static ./pub/media ./app/etc \
&& chmod u+x ./bin/magento \
&& php -f ./bin/magento setup:install --base-url=http://localhost/ \
--db-host=db \
--db-name=magento \
--db-user=magento \
--db-password=magento \
--admin-firstname=Magento \
--admin-lastname=Commerce \
[email protected] \
--admin-user=admin \
--admin-password=admin123 \
--language=en_US \
--currency=USD \
--timezone=America/Chicago \
--use-rewrites=1 \
--backend-frontname=admin \
--use-sample-data \
&& mv ./app/etc/env.php ./app/etc/env.original.php;
cp -rv /var/www/env.sample.php ./app/etc/env.php;
n98 cron:install;
php -f ./bin/magento indexer:set-mode schedule;
cp ~/.composer/auth.json var/composer_home/auth.json \
&& php -f ./bin/magento sampledata:deploy \
&& php -f ./bin/magento setup:upgrade \
&& php -f ./bin/magento indexer:reindex \
&& php -f ./bin/magento cache:flush;
mv package.json.sample package.json ; mv Gruntfile.js.sample Gruntfile.js;
npm i;
php -f ./bin/magento deploy:mode:set production \
&& composer dump-autoload -o \
&& clear && echo "
===================== 🚀 Done 🚀 ===================

Magento 2 Installed successfully!

🌎 Admin: http://localhost/admin
👤 User: admin
🔑 Password: admin123

===================== 🚀 Done 🚀 ==================="
11 changes: 11 additions & 0 deletions Dockerfile/pwa/.docker/bin/opcache
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/usr/bin/env bash

if [ -s "/usr/local/etc/php/conf.d/docker-php-ext-opcache.ini" ]; then
mv /usr/local/etc/php/conf.d/docker-php-ext-opcache.ini /usr/local/etc/php/conf.d/docker-php-ext-opcache.iniOLD \
&& /etc/init.d/apache2 force-reload \
&& echo '========= OPCache was disabled ========='
else
mv /usr/local/etc/php/conf.d/docker-php-ext-opcache.iniOLD /usr/local/etc/php/conf.d/docker-php-ext-opcache.ini \
&& /etc/init.d/apache2 force-reload \
&& echo '========= OPCache was enabled ========='
fi
3 changes: 3 additions & 0 deletions Dockerfile/pwa/.docker/bin/redis-flush
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/usr/bin/env bash
redis-cli -h redis-session flushall
redis-cli -h redis flushall
11 changes: 11 additions & 0 deletions Dockerfile/pwa/.docker/bin/xdebug
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/usr/bin/env bash

if [ -s "/usr/local/etc/php/conf.d/xdebug.ini" ]; then
mv /usr/local/etc/php/conf.d/xdebug.ini /usr/local/etc/php/conf.d/xdebug.iniOLD \
&& /etc/init.d/apache2 force-reload \
&& echo '========= XDebug was disabled ========='
else
mv /usr/local/etc/php/conf.d/xdebug.iniOLD /usr/local/etc/php/conf.d/xdebug.ini \
&& /etc/init.d/apache2 force-reload \
&& echo '========= XDebug was enabled ========='
fi
11 changes: 11 additions & 0 deletions Dockerfile/pwa/.docker/config/custom-xdebug.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
xdebug.idekey="PHPSTORM"
xdebug.default_enable=1
xdebug.remote_port=9000
xdebug.remote_autostart=1
xdebug.remote_enable=1
xdebug.remote_handler=dbgp
xdebug.profiler_enable=0
xdebug.profiler_output_dir="/var/www/html"
xdebug.remote_connect_back=1
xdebug.cli_color=1
xdebug.var_display_max_depth=10
14 changes: 14 additions & 0 deletions Dockerfile/pwa/.docker/config/magento.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<VirtualHost *:80>
ServerAdmin [email protected]
DocumentRoot /var/www/html/
# ServerName dev.local
# ServerAlias www.dev.local
<Directory /var/www/html/>
Options FollowSymLinks
AllowOverride All
Order allow,deny
allow from all
</Directory>
ErrorLog /var/log/apache2/magento2-error_log
CustomLog /var/log/apache2/magento2-access_log common
</VirtualHost>
10 changes: 10 additions & 0 deletions Dockerfile/pwa/.docker/config/opcache.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
opcache.enable = 1
opcache.enable_cli = 1
opcache.memory_consumption = 512M
opcache.max_accelerated_files = 100000
opcache.validate_timestamps=0
opcache.consistency_checks=0
opcache.interned_strings_buffer=8
opcache.fast_shutdown=1
opcache.revalidate_freq = 0
opcache.revalidate_path = 1
9 changes: 9 additions & 0 deletions Dockerfile/pwa/.docker/config/php.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
memory_limit = 2048M
max_execution_time = 38000
always_populate_raw_post_data = -1
date.timezone = "UTC"
upload_max_filesize = 128M
zlib.output_compression = on
log_errors = On
display_errors = Off
sendmail_path = "/opt/go/bin/mhsendmail --smtp-addr='mailhog:1025'"
12 changes: 12 additions & 0 deletions Dockerfile/pwa/.docker/users/.bashrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# Alias

alias n98='n98-magerun2.phar'
alias magerun='n98-magerun2.phar'
alias mage='php -d memory_limit=-1 -f bin/magento'
alias magento='php -d memory_limit=-1 -f bin/magento'
alias node='nodejs'

# NVM

export NVM_DIR="/var/www/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh" # This loads nvm
File renamed without changes.
12 changes: 7 additions & 5 deletions Dockerfile → Dockerfile/pwa/Dockerfile
100755 → 100644
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM php:7.1-apache
FROM php:7.2-apache

MAINTAINER Rafael Corrêa Gomes <[email protected]>

Expand All @@ -22,7 +22,7 @@ RUN apt-get update \
apt-utils \
gnupg \
redis-tools \
mysql-client \
mariadb-client \
git \
vim \
wget \
Expand All @@ -33,6 +33,7 @@ RUN apt-get update \
tar \
cron \
bash-completion \
libsodium-dev \
&& apt-get clean

# Install Magento Dependencies
Expand All @@ -45,11 +46,12 @@ RUN docker-php-ext-configure \
bcmath \
intl \
mbstring \
mcrypt \
# mcrypt \
pdo_mysql \
soap \
xsl \
zip
zip \
sockets

# Install oAuth

Expand All @@ -63,7 +65,7 @@ RUN apt-get update \

# Install Node, NVM, NPM and Grunt

RUN curl -sL https://deb.nodesource.com/setup_6.x | bash - \
RUN curl -sL https://deb.nodesource.com/setup_10.x | bash - \
&& apt-get install -y nodejs build-essential \
&& curl https://raw.githubusercontent.com/creationix/nvm/v0.16.1/install.sh | sh \
&& npm i -g grunt-cli yarn
Expand Down
Loading