From 193b5663ce40717bf86257566d4c38f3cc17b57b Mon Sep 17 00:00:00 2001 From: manuelgonzz Date: Thu, 19 Dec 2019 20:55:01 +0000 Subject: [PATCH 1/2] Task1 --- *Task1*/Dockerfile | 85 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 85 insertions(+) create mode 100644 *Task1*/Dockerfile diff --git a/*Task1*/Dockerfile b/*Task1*/Dockerfile new file mode 100644 index 0000000..a93124f --- /dev/null +++ b/*Task1*/Dockerfile @@ -0,0 +1,85 @@ +FROM php:7.4-fpm-alpine + +# persistent dependencies +RUN apk add --no-cache \ +# in theory, docker-entrypoint.sh is POSIX-compliant, but priority is a working, consistent image + bash \ +# BusyBox sed is not sufficient for some of our sed expressions + sed \ +# Ghostscript is required for rendering PDF previews + ghostscript + +# install the PHP extensions we need (https://make.wordpress.org/hosting/handbook/handbook/server-environment/#php-extensions) +RUN set -ex; \ + \ + apk add --no-cache --virtual .build-deps \ + $PHPIZE_DEPS \ + freetype-dev \ + imagemagick-dev \ + libjpeg-turbo-dev \ + libpng-dev \ + libzip-dev \ + ; \ + \ + docker-php-ext-configure gd --with-freetype --with-jpeg; \ + docker-php-ext-install -j "$(nproc)" \ + bcmath \ + exif \ + gd \ + mysqli \ + opcache \ + zip \ + ; \ + pecl install imagick-3.4.4; \ + docker-php-ext-enable imagick; \ + \ + runDeps="$( \ + scanelf --needed --nobanner --format '%n#p' --recursive /usr/local/lib/php/extensions \ + | tr ',' '\n' \ + | sort -u \ + | awk 'system("[ -e /usr/local/lib/" $1 " ]") == 0 { next } { print "so:" $1 }' \ + )"; \ + apk add --virtual .wordpress-phpexts-rundeps $runDeps; \ + apk del .build-deps + +# set recommended PHP.ini settings +# see https://secure.php.net/manual/en/opcache.installation.php +RUN { \ + echo 'opcache.memory_consumption=128'; \ + echo 'opcache.interned_strings_buffer=8'; \ + echo 'opcache.max_accelerated_files=4000'; \ + echo 'opcache.revalidate_freq=2'; \ + echo 'opcache.fast_shutdown=1'; \ + } > /usr/local/etc/php/conf.d/opcache-recommended.ini +# https://wordpress.org/support/article/editing-wp-config-php/#configure-error-logging +RUN { \ +# https://www.php.net/manual/en/errorfunc.constants.php +# https://github.com/docker-library/wordpress/issues/420#issuecomment-517839670 + echo 'error_reporting = E_ERROR | E_WARNING | E_PARSE | E_CORE_ERROR | E_CORE_WARNING | E_COMPILE_ERROR | E_COMPILE_WARNING | E_RECOVERABLE_ERROR'; \ + echo 'display_errors = Off'; \ + echo 'display_startup_errors = Off'; \ + echo 'log_errors = On'; \ + echo 'error_log = /dev/stderr'; \ + echo 'log_errors_max_len = 1024'; \ + echo 'ignore_repeated_errors = On'; \ + echo 'ignore_repeated_source = Off'; \ + echo 'html_errors = Off'; \ + } > /usr/local/etc/php/conf.d/error-logging.ini + +VOLUME /var/www/html + +ENV WORDPRESS_VERSION 5.3.2 +ENV WORDPRESS_SHA1 fded476f112dbab14e3b5acddd2bcfa550e7b01b + +RUN set -ex; \ + curl -o wordpress.tar.gz -fSL "https://wordpress.org/wordpress-${WORDPRESS_VERSION}.tar.gz"; \ + echo "$WORDPRESS_SHA1 *wordpress.tar.gz" | sha1sum -c -; \ +# upstream tarballs include ./wordpress/ so this gives us /usr/src/wordpress + tar -xzf wordpress.tar.gz -C /usr/src/; \ + rm wordpress.tar.gz; \ + chown -R www-data:www-data /usr/src/wordpress + +COPY docker-entrypoint.sh /usr/local/bin/ + +ENTRYPOINT ["docker-entrypoint.sh"] +CMD ["php-fpm"] From c8b93103421a591dd45ebec96cb9386808de86e7 Mon Sep 17 00:00:00 2001 From: manuelgonzz Date: Fri, 20 Dec 2019 03:49:24 +0000 Subject: [PATCH 2/2] Task2 --- *Task1*/Dockerfile | 85 -------------------------------------- *Task2*/docker-compose.yml | 69 +++++++++++++++++++++++++++++++ 2 files changed, 69 insertions(+), 85 deletions(-) delete mode 100644 *Task1*/Dockerfile create mode 100644 *Task2*/docker-compose.yml diff --git a/*Task1*/Dockerfile b/*Task1*/Dockerfile deleted file mode 100644 index a93124f..0000000 --- a/*Task1*/Dockerfile +++ /dev/null @@ -1,85 +0,0 @@ -FROM php:7.4-fpm-alpine - -# persistent dependencies -RUN apk add --no-cache \ -# in theory, docker-entrypoint.sh is POSIX-compliant, but priority is a working, consistent image - bash \ -# BusyBox sed is not sufficient for some of our sed expressions - sed \ -# Ghostscript is required for rendering PDF previews - ghostscript - -# install the PHP extensions we need (https://make.wordpress.org/hosting/handbook/handbook/server-environment/#php-extensions) -RUN set -ex; \ - \ - apk add --no-cache --virtual .build-deps \ - $PHPIZE_DEPS \ - freetype-dev \ - imagemagick-dev \ - libjpeg-turbo-dev \ - libpng-dev \ - libzip-dev \ - ; \ - \ - docker-php-ext-configure gd --with-freetype --with-jpeg; \ - docker-php-ext-install -j "$(nproc)" \ - bcmath \ - exif \ - gd \ - mysqli \ - opcache \ - zip \ - ; \ - pecl install imagick-3.4.4; \ - docker-php-ext-enable imagick; \ - \ - runDeps="$( \ - scanelf --needed --nobanner --format '%n#p' --recursive /usr/local/lib/php/extensions \ - | tr ',' '\n' \ - | sort -u \ - | awk 'system("[ -e /usr/local/lib/" $1 " ]") == 0 { next } { print "so:" $1 }' \ - )"; \ - apk add --virtual .wordpress-phpexts-rundeps $runDeps; \ - apk del .build-deps - -# set recommended PHP.ini settings -# see https://secure.php.net/manual/en/opcache.installation.php -RUN { \ - echo 'opcache.memory_consumption=128'; \ - echo 'opcache.interned_strings_buffer=8'; \ - echo 'opcache.max_accelerated_files=4000'; \ - echo 'opcache.revalidate_freq=2'; \ - echo 'opcache.fast_shutdown=1'; \ - } > /usr/local/etc/php/conf.d/opcache-recommended.ini -# https://wordpress.org/support/article/editing-wp-config-php/#configure-error-logging -RUN { \ -# https://www.php.net/manual/en/errorfunc.constants.php -# https://github.com/docker-library/wordpress/issues/420#issuecomment-517839670 - echo 'error_reporting = E_ERROR | E_WARNING | E_PARSE | E_CORE_ERROR | E_CORE_WARNING | E_COMPILE_ERROR | E_COMPILE_WARNING | E_RECOVERABLE_ERROR'; \ - echo 'display_errors = Off'; \ - echo 'display_startup_errors = Off'; \ - echo 'log_errors = On'; \ - echo 'error_log = /dev/stderr'; \ - echo 'log_errors_max_len = 1024'; \ - echo 'ignore_repeated_errors = On'; \ - echo 'ignore_repeated_source = Off'; \ - echo 'html_errors = Off'; \ - } > /usr/local/etc/php/conf.d/error-logging.ini - -VOLUME /var/www/html - -ENV WORDPRESS_VERSION 5.3.2 -ENV WORDPRESS_SHA1 fded476f112dbab14e3b5acddd2bcfa550e7b01b - -RUN set -ex; \ - curl -o wordpress.tar.gz -fSL "https://wordpress.org/wordpress-${WORDPRESS_VERSION}.tar.gz"; \ - echo "$WORDPRESS_SHA1 *wordpress.tar.gz" | sha1sum -c -; \ -# upstream tarballs include ./wordpress/ so this gives us /usr/src/wordpress - tar -xzf wordpress.tar.gz -C /usr/src/; \ - rm wordpress.tar.gz; \ - chown -R www-data:www-data /usr/src/wordpress - -COPY docker-entrypoint.sh /usr/local/bin/ - -ENTRYPOINT ["docker-entrypoint.sh"] -CMD ["php-fpm"] diff --git a/*Task2*/docker-compose.yml b/*Task2*/docker-compose.yml new file mode 100644 index 0000000..385a8e6 --- /dev/null +++ b/*Task2*/docker-compose.yml @@ -0,0 +1,69 @@ +version: '3' + +services: + db: + image: mysql:8.0 + container_name: db + restart: unless-stopped + env_file: .env + environment: + - MYSQL_DATABASE=wordpress + volumes: + - dbdata:/var/lib/mysql + command: '--default-authentication-plugin=mysql_native_password' + networks: + - app-network + + wordpress: + depends_on: + - db + image: wordpress:5.3.1-php7.4-fpm-alpine + container_name: wordpress + restart: unless-stopped + ports: + - "9000:9000" + env_file: .env + environment: + - WORDPRESS_DB_HOST=db:3306 + - WORDPRESS_DB_USER=$MYSQL_USER + - WORDPRESS_DB_PASSWORD=$MYSQL_PASSWORD + - WORDPRESS_DB_NAME=wordpress + volumes: + - wordpress:/var/www/html + networks: + - app-network + + webserver: + depends_on: + - wordpress + image: nginx:1.15.12-alpine + container_name: webserver + restart: unless-stopped + ports: + - "80:80" + - "443:443" + volumes: + - wordpress:/var/www/html + - ./nginx-conf:/etc/nginx/conf.d + - certbot-etc:/etc/letsencrypt + networks: + - app-network + + certbot: + depends_on: + - webserver + image: certbot/certbot + container_name: certbot + volumes: + - certbot-etc:/etc/letsencrypt + - wordpress:/var/www/html + command: certonly --webroot --webroot-path=/var/www/html --email root@retevisa-devops.com --agree-tos --no-eff-email --force-renewal -d retevisa-devops.com -d www.retevisa-devops.com + +volumes: + certbot-etc: + wordpress: + dbdata: + +networks: + app-network: + driver: bridge