diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..a4d2e18 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,23 @@ +version: '3' +services: + web: + build: ./docker/web + ports: + - "80:80" + volumes: + - .:/var/www/html + restart: always + depends_on: + - db + db: + image: mysql:5 + ports: + - "1234:3306" + volumes: + - ./docker/db/data:/var/lib/mysql + restart: always + environment: + MYSQL_ROOT_PASSWORD: mysql + MYSQL_DATABASE: mysql + MYSQL_USER: mysql + MYSQL_PASSWORD: mysql \ No newline at end of file diff --git a/docker/web/Dockerfile b/docker/web/Dockerfile new file mode 100644 index 0000000..aeb7149 --- /dev/null +++ b/docker/web/Dockerfile @@ -0,0 +1,44 @@ +# This docker image will be created from the official Docker PHP 7 image with Apache +FROM php:7-apache + +# Copy PHP configuration file to comply with Symfony requirements +COPY ./config/php.ini /usr/local/etc/php/ + +# Copy Apache virtualhost config file +COPY ./config/000-default.conf /etc/apache2/sites-available/ + +# Download, compile and install ICU library required by intl PHP extension +RUN curl -sS -o /tmp/icu.tar.gz -L http://download.icu-project.org/files/icu4c/58.2/icu4c-58_2-src.tgz && \ + tar -zxf /tmp/icu.tar.gz -C /tmp && \ + cd /tmp/icu/source && \ + ./configure --prefix=/usr/local && \ + make && \ + make install + +# Delete ICU source files from /tmp directory +RUN rm /tmp/icu.tar.gz +RUN rm -r /tmp/icu + +# Install PHP extensions required or recommended by Symfony (intl and opcache) +RUN docker-php-ext-configure intl --with-icu-dir=/usr/local && \ + docker-php-ext-install intl opcache + +# Install PHP MySQL PDO driver +RUN docker-php-ext-install pdo_mysql + +# Enable mod_rewrite module on Apache to make .htaccess files work +RUN a2enmod rewrite + +# Update apt-get and install tools required by Composer +RUN apt-get -y update +RUN apt-get -y install git +RUN apt-get -y install zip + +# Install Composer globally +WORKDIR /tmp +RUN php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');" +RUN php -r "if (hash_file('SHA384', 'composer-setup.php') === '669656bab3166a7aff8a7506b8cb2d1c292f042046c5a994c43155c0be6190fa0355160742ab2e1c88d40d5be660b410') { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;" +RUN php composer-setup.php +RUN php -r "unlink('composer-setup.php');" +RUN echo "Moving composer to /usr/local/bin/composer" && mv composer.phar /usr/local/bin/composer +WORKDIR /var/www/html \ No newline at end of file diff --git a/docker/web/config/000-default.conf b/docker/web/config/000-default.conf new file mode 100644 index 0000000..c10937f --- /dev/null +++ b/docker/web/config/000-default.conf @@ -0,0 +1,31 @@ + + # 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/web + + # 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 + + +# vim: syntax=apache ts=4 sw=4 sts=4 sr noet diff --git a/docker/web/config/php.ini b/docker/web/config/php.ini new file mode 100644 index 0000000..8a6de5d --- /dev/null +++ b/docker/web/config/php.ini @@ -0,0 +1,3 @@ +; Directives required by Symfony +date.timezone = "America/Guatemala" +short_open_tag = Off \ No newline at end of file