diff --git a/docker/build.sh b/docker/build.sh new file mode 100644 index 0000000..fa6c06a --- /dev/null +++ b/docker/build.sh @@ -0,0 +1,2 @@ +#!/usr/bin/env bash +docker-compose build --force-rm --no-cache diff --git a/docker/docker-compose.yml b/docker/docker-compose.yml new file mode 100644 index 0000000..9121d2d --- /dev/null +++ b/docker/docker-compose.yml @@ -0,0 +1,4 @@ +version: '2' +services: + fitness-ub-php-7: + build: ./service/ub-php diff --git a/docker/service/ub-php/000-default.conf b/docker/service/ub-php/000-default.conf new file mode 100644 index 0000000..da2537a --- /dev/null +++ b/docker/service/ub-php/000-default.conf @@ -0,0 +1,42 @@ + + # The ServerName directive sets the request scheme, hostname and port that + # the server uses to identify itself. This is used when creating + # redirection URLs. In the context of virtual hosts, the ServerName + # specifies what hostname must appear in the request's Host: header to + # match this virtual host. For the default virtual host (this file) this + # value is not decisive as it is used as a last resort host regardless. + # However, you must set it for any further virtual host explicitly. + #ServerName www.example.com + + ServerAdmin webmaster@localhost + DocumentRoot /var/www/html + + # Available loglevels: trace8, ..., trace1, debug, info, notice, warn, + # error, crit, alert, emerg. + # It is also possible to configure the loglevel for particular + # modules, e.g. + #LogLevel info ssl:warn + + ErrorLog ${APACHE_LOG_DIR}/error.log + CustomLog ${APACHE_LOG_DIR}/access.log combined + + # For most configuration files from conf-available/, which are + # enabled or disabled at a global level, it is possible to + # include a line for only one particular virtual host. For example the + # following line enables the CGI configuration for this host only + # after it has been globally disabled with "a2disconf". + #Include conf-available/serve-cgi-bin.conf + + # Always set these headers. + Header always set Access-Control-Allow-Origin "*" + Header always set Access-Control-Allow-Methods "POST, GET, OPTIONS, DELETE, PUT" + Header always set Access-Control-Max-Age "1000" + Header always set Access-Control-Allow-Headers "x-requested-with, Content-Type, origin, authorization, accept, client-security-token" + + # Added a rewrite to respond with a 200 SUCCESS on every OPTIONS request. + RewriteEngine On + RewriteCond %{REQUEST_METHOD} OPTIONS + RewriteRule ^(.*)$ $1 [R=200,L] + + + diff --git a/docker/service/ub-php/Dockerfile b/docker/service/ub-php/Dockerfile new file mode 100644 index 0000000..a4bb694 --- /dev/null +++ b/docker/service/ub-php/Dockerfile @@ -0,0 +1,59 @@ +FROM ubuntu:16.04 +MAINTAINER rocho02@gmail.com + +# apt-get +RUN apt-get update \ + && apt-get -y install bzip2 git nano wget zip unzip curl vim \ + && apt-get -y install libmcrypt-dev libzzip-dev zziplib-bin zlib1g-dev \ + && apt-get -y install apache2 +# && ufw allow in "Apache Full" \ + +RUN apt-get -y install php \ + libapache2-mod-php \ + php-mcrypt \ + php-mysql \ + php-xml \ + php7.0-gd \ + php7.0-mbstring + +RUN apt-get -y install php-xdebug php-soap php-curl + +RUN apt-get -y install \ + # Required by composer + git \ + zlib1g-dev \ + --no-install-recommends + +# Install composer +COPY install-composer /install-composer +RUN /install-composer && rm /install-composer + +RUN mkdir -p /var/www/html/api && mkdir -p /var/www/html/admin && mkdir -p /var/www/html/public + +WORKDIR /var/www + +RUN a2enmod headers +RUN a2enmod rewrite + +COPY 000-default.conf /etc/apache2/sites-available/ + +# Ports +EXPOSE 80 + +RUN FILE=/etc/php/7.0/apache2/php.ini \ + && echo "\n" >> $FILE \ + && echo "\n# Added for xdebug" >> $FILE \ + && echo "\nzend_extension=\"/usr/lib/php/20151012/xdebug.so\" " >> $FILE \ + && echo "\nxdebug.remote_enable=1 " >> $FILE \ + && echo "\nxdebug.remote_handler=dbgp " >> $FILE \ + && echo "\nxdebug.remote_mode=req " >> $FILE \ + && echo "\nxdebug.remote_host=172.17.0.1 " >> $FILE \ + && echo "\nxdebug.remote_port=9000 " >> $FILE \ + && echo "\nxdebug.remote_connect_back=1 " >> $FILE \ + && echo "\n" >> $FILE + +ENV XDEBUG_CONFIG="idekey=PHPSTORM" + +# Default command +CMD ["apachectl", "-D", "FOREGROUND"] + diff --git a/docker/service/ub-php/install-composer b/docker/service/ub-php/install-composer new file mode 100644 index 0000000..f7d34be --- /dev/null +++ b/docker/service/ub-php/install-composer @@ -0,0 +1,17 @@ +#!/bin/sh + +EXPECTED_SIGNATURE=$(curl https://composer.github.io/installer.sig) +php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');" +ACTUAL_SIGNATURE=$(php -r "echo hash_file('SHA384', 'composer-setup.php');") + +if [ "$EXPECTED_SIGNATURE" != "$ACTUAL_SIGNATURE" ] +then + >&2 echo 'ERROR: Invalid installer signature' + rm composer-setup.php + exit 1 +fi + +php composer-setup.php --install-dir=/usr/bin --filename=composer +RESULT=$? +rm composer-setup.php +exit $RESULT diff --git a/docker/start.sh b/docker/start.sh new file mode 100644 index 0000000..1a10592 --- /dev/null +++ b/docker/start.sh @@ -0,0 +1,13 @@ +#!/usr/bin/env bash + +PROJECT_DIR=$(pwd)/.. + +docker run \ + -v ${PROJECT_DIR}:/var/www/html/fitness_web \ + --rm \ + -d \ + -p 86:80 \ + --name fitness-web \ + --hostname test.fintess_web.hu \ + -e XDEBUG_CONFIG="idekey=PHPSTORM" \ + docker_fitness-ub-php-7:latest diff --git a/start.sh b/start.sh new file mode 100644 index 0000000..1067df1 --- /dev/null +++ b/start.sh @@ -0,0 +1,3 @@ +#!/usr/bin/env bash + +./docker/start.sh \ No newline at end of file