diff --git a/Makefile b/Makefile index 962f2ef84..1ba89c7e4 100644 --- a/Makefile +++ b/Makefile @@ -57,7 +57,7 @@ graph-full: python ./bin/console generate:graph --all --filename docker-image-full-layout.gv documentation: - docker run -t -i --rm -p 8080:8000 -v "$$(pwd)/documentation/docs/:/opt/docs" -e "VIRTUAL_HOST=documentation.docker" -e "VIRTUAL_PORT=8000" webdevops/sphinx sphinx-autobuild --poll -H 0.0.0.0 /opt/docs html + docker run -t -i --rm -p 8000 -v "$$(pwd)/documentation/docs/:/opt/docs" -e "VIRTUAL_HOST=documentation.docker" -e "VIRTUAL_PORT=8000" webdevops/sphinx sphinx-autobuild --poll -H 0.0.0.0 /opt/docs html webdevops/bootstrap: python ./bin/console docker:build --threads=auto --whitelist=webdevops/bootstrap diff --git a/baselayout/usr/local/bin/apt-add-repository b/baselayout/usr/local/bin/apt-add-repository new file mode 100755 index 000000000..5e6ba6d2f --- /dev/null +++ b/baselayout/usr/local/bin/apt-add-repository @@ -0,0 +1,8 @@ +#!/bin/sh + +set -o nounset ## set -u : exit the script if you try to use an uninitialised variable +set -o errexit ## set -e : exit the script if any statement returns a non-true return value + +apt-install software-properties-common +add-apt-repository $@ +apt-get purge -y -f software-properties-common diff --git a/baselayout/usr/local/bin/apt-install b/baselayout/usr/local/bin/apt-install index c9db1442f..ef3f327f9 100755 --- a/baselayout/usr/local/bin/apt-install +++ b/baselayout/usr/local/bin/apt-install @@ -7,12 +7,18 @@ set -o errexit ## set -e : exit the script if any statement returns a non-true export DEBIAN_FRONTEND=noninteractive -# Update apt cache -apt-get update +if [[ -f "/tmp/.apt-update" ]]; then + echo "Detected prefetched 'apt-get update'" + # Install packages + apt-get install -y -f --no-install-recommends $* +else + # Update apt cache + apt-get update -# Install packages -apt-get install -y -f --no-install-recommends $* + # Install packages + apt-get install -y -f --no-install-recommends $* -# Clear files (reduce snapshot size) -rm -rf /var/lib/apt/lists/* -apt-get clean -y + # Clear files (reduce snapshot size) + rm -rf /var/lib/apt/lists/* + apt-get clean -y +fi diff --git a/baselayout/usr/local/bin/apt-update b/baselayout/usr/local/bin/apt-update new file mode 100755 index 000000000..d3019cc0c --- /dev/null +++ b/baselayout/usr/local/bin/apt-update @@ -0,0 +1,9 @@ +#!/bin/bash + +set -o pipefail # trace ERR through pipes +set -o errtrace # trace ERR through 'time command' and other functions +set -o nounset ## set -u : exit the script if you try to use an uninitialised variable +set -o errexit ## set -e : exit the script if any statement returns a non-true return value + +apt-get update +touch /tmp/.apt-update diff --git a/baselayout/usr/local/bin/apt-upgrade b/baselayout/usr/local/bin/apt-upgrade index c92612f02..bda7c3acf 100755 --- a/baselayout/usr/local/bin/apt-upgrade +++ b/baselayout/usr/local/bin/apt-upgrade @@ -7,12 +7,18 @@ set -o errexit ## set -e : exit the script if any statement returns a non-true export DEBIAN_FRONTEND=noninteractive -# Update apt cache -apt-get update +if [[ -f "/tmp/.apt-update" ]]; then + echo "Detected prefetched 'apt-get update'" + # Update packages + apt-get dist-upgrade -y -f +else + # Update apt cache + apt-get update -# Install packages -apt-get dist-upgrade -y -f + # Update packages + apt-get dist-upgrade -y -f -# Clear files (reduce snapshot size) -rm -rf /var/lib/apt/lists/* -apt-get clean -y + # Clear files (reduce snapshot size) + rm -rf /var/lib/apt/lists/* + apt-get clean -y +fi diff --git a/baselayout/usr/local/bin/docker-image-cleanup b/baselayout/usr/local/bin/docker-image-cleanup new file mode 100755 index 000000000..e63d1b3c4 --- /dev/null +++ b/baselayout/usr/local/bin/docker-image-cleanup @@ -0,0 +1,36 @@ +#!/bin/sh + +set -o nounset ## set -u : exit the script if you try to use an uninitialised variable +set -o errexit ## set -e : exit the script if any statement returns a non-true return value + +LSB_FAMILY=$(docker-image-info family) + +case "$LSB_FAMILY" in + Debian) + rm -f /tmp/.apt-update + apt-get autoremove -y -f + apt-get clean -y + rm -rf /var/lib/apt/lists/* + ;; + + RedHat) + yum autoremove --assumeyes + yum clean all + ;; + + Alpine) + find /var/lib/apk/ -mindepth 1 -delete + ;; + + Arch) + pacman -Sc + ;; + + *) + echo "ERROR: Distribution $LSB_FAMILY not supported" + exit 1 + ;; +esac + +find /tmp/ /var/log/ -mindepth 1 -delete +rm -rf /root/.cache diff --git a/baselayout/usr/local/bin/docker-image-info b/baselayout/usr/local/bin/docker-image-info new file mode 100755 index 000000000..fb9248fc2 --- /dev/null +++ b/baselayout/usr/local/bin/docker-image-info @@ -0,0 +1,87 @@ +#!/bin/sh + +set -o nounset ## set -u : exit the script if you try to use an uninitialised variable +set -o errexit ## set -e : exit the script if any statement returns a non-true return value + +help() { + if [ -n "$1" ]; then + echo "$1" + echo "" + fi + + echo "Usage: $0 " + echo "" + echo " Application arguments:" + echo " family Get distribution family" + echo " dist Get distribution name" + echo " dist-version Get distribution version" + echo " dist-release Get distribution release" + echo " dist-codename Get distribution codename" + echo " lsb Get lsb informations (if available)" + echo " lsb-desc Get lsb description (if available)" + echo " buildtime Get buildtime of docker image" + echo "" + + exit $2 + +} + +if [ "$#" -ne 1 ]; then + help "[ERROR] Invalid argument" 1 +fi + +INFO_FILE="" + +case "$1" in + dist-family|distribution-family|family) + INFO_FILE=/opt/docker/etc/.registry/image_info_distribution_family + ;; + + dist|distribution) + INFO_FILE=/opt/docker/etc/.registry/image_info_distribution + ;; + + dist-version|distribution-version) + INFO_FILE=/opt/docker/etc/.registry/image_info_distribution_version + ;; + + dist-release|distribution-release) + INFO_FILE=/opt/docker/etc/.registry/image_info_lsb_release + ;; + + dist-codename|distribution-codename) + INFO_FILE=/opt/docker/etc/.registry/image_info_lsb_codename + ;; + + lsb) + INFO_FILE=/opt/docker/etc/.registry/image_info_lsb + ;; + + lsb-desc|lsb-description) + INFO_FILE=/opt/docker/etc/.registry/image_info_lsb_description + ;; + + buildtime) + INFO_FILE=/opt/docker/etc/.registry/image_info_buildtime + ;; + + help) + help "" 0 + ;; + + *) + help "[ERROR] Invalid argument" 1 + ;; +esac + +if [ -n "$INFO_FILE" ]; then + if [ -f "$INFO_FILE" ]; then + cat -- "$INFO_FILE" + else + echo "[ERROR] Infomation file $INFO_FILE not found!" + echo " Please run generate-dockerimage-info on docker image creation!" + exit 2 + fi +else + help "" 1 +fi diff --git a/baselayout/usr/local/bin/generate-dockerimage-info b/baselayout/usr/local/bin/generate-dockerimage-info new file mode 100755 index 000000000..25417e0a4 --- /dev/null +++ b/baselayout/usr/local/bin/generate-dockerimage-info @@ -0,0 +1,96 @@ +#!/bin/sh + +set -o nounset ## set -u : exit the script if you try to use an uninitialised variable +set -o errexit ## set -e : exit the script if any statement returns a non-true return value + +LSB_FAMILY="" + +############################# +# Distribution detection +############################# + +if [ -x "/usr/bin/apt-get" ]; then + # Debian family + LSB_FAMILY="Debian" + +elif [ -x "/bin/yum" ]; then + # RedHat family + LSB_FAMILY="RedHat" + +elif [ -x "/sbin/apk" ]; then + # Alpine family + LSB_FAMILY="Alpine" + +elif [ -f "/etc/arch-release" ]; then + # Alpine family + LSB_FAMILY="Arch" + +else + # Unknown + echo "ERROR: Distribution detection failed" + exit 1 +fi + +############################# +# Install +############################# + +case "$LSB_FAMILY" in + Debian) + apt-install lsb-release + ;; + + RedHat) + yum-install redhat-lsb-core + ;; +esac + +############################# +# Set distribution information +############################# + +echo "Detected $LSB_FAMILY" + +mkdir -p /opt/docker/etc/.registry/ +echo "$LSB_FAMILY" > /opt/docker/etc/.registry/image_info_distribution_family +echo "$LSB_FAMILY" > /opt/docker/etc/.registry/image_info_distribution +date +%s >/opt/docker/etc/.registry/image_info_buildtime + +# Create all files +touch /opt/docker/etc/.registry/image_info_distribution_version +touch /opt/docker/etc/.registry/image_info_lsb +touch /opt/docker/etc/.registry/image_info_lsb_description +touch /opt/docker/etc/.registry/image_info_lsb_release +touch /opt/docker/etc/.registry/image_info_lsb_codename + +# Collect distribution specific informations +case "$LSB_FAMILY" in + Debian|RedHat) + lsb_release -i -s > /opt/docker/etc/.registry/image_info_distribution + lsb_release -r -s > /opt/docker/etc/.registry/image_info_distribution_version + lsb_release -a > /opt/docker/etc/.registry/image_info_lsb + lsb_release -d -s > /opt/docker/etc/.registry/image_info_lsb_description + lsb_release -r -s > /opt/docker/etc/.registry/image_info_lsb_release + lsb_release -c -s > /opt/docker/etc/.registry/image_info_lsb_codename + ;; + + Alpine) + cat /etc/alpine-release > /opt/docker/etc/.registry/image_info_distribution_version + ;; +esac + + +############################# +# Uninstall +############################# + +case "$LSB_FAMILY" in + Debian) + apt-get purge -y -f lsb-release + ;; + + RedHat) + yum erase --assumeyes redhat-lsb-core + yum autoremove --assumeyes + ;; +esac diff --git a/baselayout/usr/local/bin/generate-locales b/baselayout/usr/local/bin/generate-locales index 4be4fc424..505bf0786 100755 --- a/baselayout/usr/local/bin/generate-locales +++ b/baselayout/usr/local/bin/generate-locales @@ -1,16 +1,19 @@ #!/bin/bash -set -o pipefail # trace ERR through pipes -set -o errtrace # trace ERR through 'time command' and other functions +set -o pipefail ## trace ERR through pipes +set -o errtrace ## trace ERR through 'time command' and other functions set -o nounset ## set -u : exit the script if you try to use an uninitialised variable set -o errexit ## set -e : exit the script if any statement returns a non-true return value +IMAGE_DISTRIBUTION_FAMILY=$(docker-image-info family) +IMAGE_DISTRIBUTION=$(docker-image-info distribution) +IMAGE_DISTRIBUTION_VERSION=$(docker-image-info distribution-version) ####################################### ## Debian ####################################### -if [[ "$(lsb_release -i -s)" == "Debian" ]]; then +if [[ "$IMAGE_DISTRIBUTION" == "Debian" ]]; then /usr/local/bin/apt-install locales-all fi @@ -18,8 +21,8 @@ fi ## Ubuntu ####################################### -if [[ "$(lsb_release -i -s)" == "Ubuntu" ]]; then - if [[ "$(lsb_release -r -s | cut -f 1 -d .)" -ge "16" ]]; then +if [[ "$IMAGE_DISTRIBUTION" == "Ubuntu" ]]; then + if [[ "$(echo $IMAGE_DISTRIBUTION_VERSION| cut -f 1 -d .)" -ge "16" ]]; then # Ubuntu 16.04 or later /usr/local/bin/apt-install locales-all else @@ -33,12 +36,12 @@ fi ## RedHat family ####################################### -function localedefdebug() { - echo $* - localedef "$@" -} +if [[ "$IMAGE_DISTRIBUTION_FAMILY" == "RedHat" ]]; then -if [[ -f /etc/redhat-release ]]; then + function localedefdebug() { + echo $* + localedef "$@" + } # Failing locales ## && localedefdebug -c -i bo_CN -f UTF-8 bo_CN.utf8 \ diff --git a/bin/webdevops/DockerfileUtility.py b/bin/webdevops/DockerfileUtility.py index b1cccb404..547dfe9f1 100644 --- a/bin/webdevops/DockerfileUtility.py +++ b/bin/webdevops/DockerfileUtility.py @@ -79,6 +79,8 @@ def parse_docker_info_from_path(path): image_name = (image_name_info['image'] if 'image' in image_name_info else '') image_tag = (image_name_info['tag'] if 'tag' in image_name_info else '') + image_is_duplicate = False + # check if path is linked if os.path.islink(os.path.dirname(path)): linked_image_name_info = ([m.groupdict() for m in path_regex.finditer(os.path.realpath(path))])[0] @@ -88,6 +90,7 @@ def parse_docker_info_from_path(path): linked_image_tag = (linked_image_name_info['tag'] if 'tag' in linked_image_name_info else '') image_from = image_prefix + linked_image_repository + '/' + linked_image_name + ':' + linked_image_tag + image_is_duplicate = True else: image_from = parse_dockerfile_from_statement(path) @@ -97,7 +100,8 @@ def parse_docker_info_from_path(path): 'tag': image_tag, 'repository': image_prefix + image_repository, 'imageName': image_name, - 'from': image_from + 'from': image_from, + 'duplicate': image_is_duplicate } return imageInfo diff --git a/bin/webdevops/command/BaseCommand.py b/bin/webdevops/command/BaseCommand.py index ba7bb0137..6734f5917 100644 --- a/bin/webdevops/command/BaseCommand.py +++ b/bin/webdevops/command/BaseCommand.py @@ -23,6 +23,7 @@ import multiprocessing from cleo import Command from webdevops import Configuration +from ..doit.DoitReporter import DoitReporter class BaseCommand(Command): configuration = False @@ -86,6 +87,8 @@ def startup(self): if 'dryRun' in self.configuration and self.configuration.get('dryRun'): options.append('dry-run') + DoitReporter.simulation_mode = True + print 'Executing %s (%s)' % (self.name, ', '.join(options)) print '' diff --git a/bin/webdevops/doit/DoitReporter.py b/bin/webdevops/doit/DoitReporter.py index 15f917b37..a347a0733 100644 --- a/bin/webdevops/doit/DoitReporter.py +++ b/bin/webdevops/doit/DoitReporter.py @@ -95,10 +95,15 @@ class DoitReporter(object): output results after finish """ + skip_detection = True + simulation_mode = False + desc = 'output after finish' show_out = False show_err = False + task_finished = 0 + task_total = 0 def __init__(self, outstream, options=None): #pylint: disable=W0613 # result is sent to stdout when doit finishes running @@ -130,15 +135,19 @@ def execute_task(self, task): """ self.t_results[task.name].start() + def add_failure(self, task, exception): """ called when excution finishes with a failure """ self.t_results[task.name].set_result('fail', exception.get_msg()) + self.task_finished += 1 + if task.actions and (task.name[0] != '_'): duration = self.duration(self.t_results[task.name].elapsed) - self.writeln(colored('. %s FAILED (%s)' % (BaseTaskLoader.human_task_name(task.title()), duration), 'red')) + progress = self.calc_progress() + self.writeln(colored('. %s FAILED (%s, #%s)' % (BaseTaskLoader.human_task_name(task.title()), duration, progress), 'red')) self.failures.append({'task': task, 'exception': exception}) def add_success(self, task): @@ -147,9 +156,26 @@ def add_success(self, task): """ self.t_results[task.name].set_result('success') + self.task_finished += 1 + if task.actions and (task.name[0] != '_'): - duration = self.duration(self.t_results[task.name].elapsed) - self.writeln(colored('. %s finished (%s)' % (BaseTaskLoader.human_task_name(task.title()), duration), 'green')) + durationSeconds = self.t_results[task.name].elapsed + duration = self.duration(durationSeconds) + progress = self.calc_progress() + + if DoitReporter.simulation_mode: + self.writeln( + colored('. %s simulated (%s, %s)' % (BaseTaskLoader.human_task_name(task.title()), duration, progress), 'blue') + ) + else: + if DoitReporter.skip_detection and durationSeconds < 1: + self.writeln( + colored('. %s SKIPPED (%s, %s)' % (BaseTaskLoader.human_task_name(task.title()), duration, progress), 'yellow') + ) + else: + self.writeln( + colored('. %s finished (%s, %s)' % (BaseTaskLoader.human_task_name(task.title()), duration, progress), 'green') + ) def skip_uptodate(self, task): """ @@ -211,13 +237,14 @@ def complete_run(self): if 'FinishChain|' in task['name']: continue - self.task_stdout( - title=task['name'], - duration=task['elapsed'], - stdout=task['out'], - stderr=task['err'], - error=task['error'] - ) + if task['result'] != 'fail': + self.task_stdout( + title=task['name'], + duration=task['elapsed'], + stdout=task['out'], + stderr=task['err'], + error=task['error'] + ) # show failed tasks (at the end) for task in task_result_list: @@ -283,6 +310,10 @@ def duration(self, duration): """ return 'duration: %s' % str(datetime.timedelta(seconds=int(duration))) + def calc_progress(self): + percentage = 100 * float(self.task_finished)/float(BaseTaskLoader.TASK_COUNT) + return 'task %s/%s, progress %d%%' % (self.task_finished, BaseTaskLoader.TASK_COUNT, percentage) + def writeln(self, text=''): """ Output diff --git a/bin/webdevops/taskloader/BaseDockerTaskLoader.py b/bin/webdevops/taskloader/BaseDockerTaskLoader.py index 969e399e4..37c75de0b 100644 --- a/bin/webdevops/taskloader/BaseDockerTaskLoader.py +++ b/bin/webdevops/taskloader/BaseDockerTaskLoader.py @@ -68,17 +68,10 @@ def process_dockerfile_list(self, dockerfile_list): Prepare dockerfile list with dependency and also add "auto latest tag" images """ - image_list = [x['image']['fullname'] for x in dockerfile_list if x['image']['fullname']] - + # Process auto latest tag autoLatestTagImageList = [] - + image_list = [x['image']['fullname'] for x in dockerfile_list if x['image']['fullname']] for dockerfile in dockerfile_list: - # Calculate dependency - dockerfile['dependency'] = False - if dockerfile['image']['from'] and dockerfile['image']['from'] in image_list: - dockerfile['dependency'] = dockerfile['image']['from'] - - # Process auto latest tag if self.configuration.get('docker.autoLatestTag') and dockerfile['image']['tag'] == self.configuration.get('docker.autoLatestTag'): imageNameLatest = DockerfileUtility.generate_image_name_with_tag_latest(dockerfile['image']['fullname']) if imageNameLatest not in image_list: @@ -87,10 +80,17 @@ def process_dockerfile_list(self, dockerfile_list): autoLatestTagImage['image']['tag'] = 'latest' autoLatestTagImage['dependency'] = dockerfile['image']['fullname'] autoLatestTagImageList.append(autoLatestTagImage) - # Add auto latest tag images to dockerfile list dockerfile_list.extend(autoLatestTagImageList) + # Calculate dependency + image_list = [x['image']['fullname'] for x in dockerfile_list if x['image']['fullname']] + for dockerfile in dockerfile_list: + if not 'dependency' in dockerfile: + dockerfile['dependency'] = False + if dockerfile['image']['from'] and dockerfile['image']['from'] in image_list: + dockerfile['dependency'] = dockerfile['image']['from'] + return dockerfile_list def generate_task_list(self, dockerfile_list): diff --git a/bin/webdevops/taskloader/BaseTaskLoader.py b/bin/webdevops/taskloader/BaseTaskLoader.py index 6a3aeed59..1f97a1cb5 100644 --- a/bin/webdevops/taskloader/BaseTaskLoader.py +++ b/bin/webdevops/taskloader/BaseTaskLoader.py @@ -23,8 +23,11 @@ from doit.cmd_base import TaskLoader from doit.task import dict_to_task + class BaseTaskLoader(TaskLoader): configuration = False + reporter = False + TASK_COUNT = 0 def __init__(self, configuration): """ @@ -33,7 +36,6 @@ def __init__(self, configuration): # Build configuration as namespace object self.configuration = configuration - def process_tasklist(self, tasklist): """ Process task list and create task objects @@ -44,6 +46,8 @@ def process_tasklist(self, tasklist): print 'Starting execution of %s tasks...' % (len(ret)) + BaseTaskLoader.TASK_COUNT = len(ret) + return ret diff --git a/bin/webdevops/taskloader/DockerBuildTaskLoader.py b/bin/webdevops/taskloader/DockerBuildTaskLoader.py index 3ef95a450..470aeb3e5 100644 --- a/bin/webdevops/taskloader/DockerBuildTaskLoader.py +++ b/bin/webdevops/taskloader/DockerBuildTaskLoader.py @@ -59,6 +59,13 @@ def task_run(docker_client, dockerfile, configuration, task): Build one Dockerfile """ + # check if dockerfile is symlink, skipping tests if just a duplicate image + # image is using the same hashes + if dockerfile['image']['duplicate'] and not task.task_dep: + print ' Docker image %s is build from symlink but not included in build chain, please include %s' % (dockerfile['image']['fullname'], dockerfile['image']['from']) + print ' -> failing build' + return False + pull_parent_image = DockerfileUtility.check_if_base_image_needs_pull(dockerfile, configuration) if configuration.get('dryRun'): diff --git a/bin/webdevops/taskloader/DockerTestServerspecTaskLoader.py b/bin/webdevops/taskloader/DockerTestServerspecTaskLoader.py index ccf319f95..f4f2c429a 100644 --- a/bin/webdevops/taskloader/DockerTestServerspecTaskLoader.py +++ b/bin/webdevops/taskloader/DockerTestServerspecTaskLoader.py @@ -41,8 +41,8 @@ def generate_task_list(self, dockerfile_list): 'task_dep': [] } - if dockerfile['dependency']: - task['task_dep'].append('DockerTestServerspec|%s' % dockerfile['dependency']) + #if dockerfile['dependency']: + # task['task_dep'].append('DockerTestServerspec|%s' % dockerfile['dependency']) tasklist.append(task) @@ -61,6 +61,14 @@ def task_run(dockerfile, configuration, task): """ Run test """ + + # check if dockerfile is symlink, skipping tests if just a duplicate image + # image is using the same hashes + if dockerfile['image']['duplicate']: + print ' Docker image %s is build from symlink and duplicate of %s' % (dockerfile['image']['fullname'], dockerfile['image']['from']) + print ' -> skipping tests' + return True + # Check if current image is a toolimage (no daemon) is_toolimage = False for term in configuration.get('dockerTest.toolImages', {}): @@ -170,7 +178,9 @@ def generate_serverspec_configuration(path, dockerfile, configuration, is_toolim if image_env_list: image_env_list = image_env_list.to_dict().copy() for term in image_env_list: - if term in dockerfile['image']['fullname']: + regex = r'.*%s.*' % term + match = re.match(regex, dockerfile['image']['fullname'], re.IGNORECASE) + if match: for key in image_env_list[term]: ret[key] = str(image_env_list[term][key]) diff --git a/conf/console.yml b/conf/console.yml index 421671505..bfb843423 100644 --- a/conf/console.yml +++ b/conf/console.yml @@ -37,7 +37,7 @@ dockerTest: - 'ENV VARNISH_BACKEND_HOST webdevops.io' configuration: - imageConfigurationRegex: ':(?Palpine|debian|ubuntu|centos)-(?P[^-]+)' + imageConfigurationRegex: ':(?Palpine|debian|ubuntu|centos)-?(?P[^-]+)?' default: OS_FAMILY: 'ubuntu' OS_VERSION: '16.04' @@ -45,7 +45,8 @@ dockerTest: ':centos': OS_FAMILY: 'redhat' ':alpine': - PHP_MHASH: '0' + OS_FAMILY: 'alpine' + OS_VERSION: '3' PHP_REDIS: '0' ':ubuntu-12.04': PHP_REDIS: '0' @@ -58,6 +59,10 @@ dockerTest: ':centos-7-php56': PHP_APCU: '0' PHP_REDIS: '0' + 'php[^:]*:[0-9]': + OS_FAMILY: 'debian' + OS_VERSION: '8' + PHP_OFFICIAL: '1' '/liquibase': OS_FAMILY: 'alpine' OS_VERSION: '3' diff --git a/conf/provision.yml b/conf/provision.yml index 68465a9c2..beb2db3c9 100644 --- a/conf/provision.yml +++ b/conf/provision.yml @@ -6,7 +6,7 @@ provision: configuration: base/general: '*' base/centos: centos-* - base/alpine: alpine-* + base/alpine: alpine base-app: configuration: base-app/general: '*' @@ -14,7 +14,7 @@ provision: configuration: apache/general : '*' apache/centos : centos-* - apache/alpine : alpine-* + apache/alpine : alpine apache-dev: configuration: apache-dev/general: '*' @@ -22,7 +22,7 @@ provision: configuration: nginx/general : '*' nginx/centos : centos-* - nginx/alpine : alpine-* + nginx/alpine : alpine nginx-dev: configuration: nginx-dev/general : '*' @@ -40,26 +40,20 @@ provision: hhvm-nginx/general: '*' php: configuration: - php/general : '*' + php/general : '(debian|ubuntu|centos|alpine)' php/ubuntu-12.04 : ubuntu-12.04 - php/alpine : alpine-* - # deploy php7 configuration to *-php7 containers - php/php7 : - - '*-php7' - - debian-9 - - ubuntu-16.04 - - ubuntu-16.10 + php/alpine : alpine php-apache: configuration: apache/general : '*' apache/centos : centos-* - apache/alpine : alpine-* + apache/alpine : alpine php-apache/general: '*' php-nginx: configuration: nginx/general : '*' nginx/centos : centos-* - nginx/alpine : alpine-* + nginx/alpine : alpine php-nginx/general : '*' php-dev: configuration: @@ -69,7 +63,7 @@ provision: configuration: apache/general : '*' apache/centos : centos-* - apache/alpine : alpine-* + apache/alpine : alpine php-apache/general: '*' php-dev/general : '*' apache-dev/general: '*' @@ -77,10 +71,17 @@ provision: configuration: nginx/general : '*' nginx/centos : centos-* - nginx/alpine : alpine-* + nginx/alpine : alpine php-nginx/general : '*' php-dev/general : '*' nginx-dev/general : '*' + php-official: + baselayout: on + configuration: + base/general : '*' + base-app/general : '*' + php/general : '*' + php/official : '*' postfix: configuration: postfix/general : '*' @@ -96,6 +97,8 @@ provision: piwik: configuration: piwik/general : '*' + typo3-solr: + baselayout: on varnish: configuration: varnish/general : '*' diff --git a/docker/ansible/alpine-3 b/docker/ansible/alpine-3 new file mode 120000 index 000000000..0120374ca --- /dev/null +++ b/docker/ansible/alpine-3 @@ -0,0 +1 @@ +alpine \ No newline at end of file diff --git a/docker/ansible/alpine-3/Dockerfile b/docker/ansible/alpine-3/Dockerfile deleted file mode 100644 index 548242cbe..000000000 --- a/docker/ansible/alpine-3/Dockerfile +++ /dev/null @@ -1,11 +0,0 @@ -#+++++++++++++++++++++++++++++++++++++++ -# Dockerfile for webdevops/ansible:alpine-3 -# -- automatically generated -- -#+++++++++++++++++++++++++++++++++++++++ - -FROM webdevops/bootstrap:alpine-3 - -MAINTAINER info@webdevops.io -LABEL vendor=WebDevOps.io -LABEL io.webdevops.layout=8 -LABEL io.webdevops.version=1.5.0 diff --git a/docker/ansible/alpine-3/Dockerfile.jinja2 b/docker/ansible/alpine-3/Dockerfile.jinja2 deleted file mode 100644 index fa7d167f0..000000000 --- a/docker/ansible/alpine-3/Dockerfile.jinja2 +++ /dev/null @@ -1,3 +0,0 @@ -{{ docker.from("bootstrap", "alpine-3") }} - -{{ docker.version() }} diff --git a/docker/ansible/alpine/Dockerfile b/docker/ansible/alpine/Dockerfile new file mode 100644 index 000000000..ec35128d8 --- /dev/null +++ b/docker/ansible/alpine/Dockerfile @@ -0,0 +1,28 @@ +#+++++++++++++++++++++++++++++++++++++++ +# Dockerfile for webdevops/ansible:alpine +# -- automatically generated -- +#+++++++++++++++++++++++++++++++++++++++ + +FROM webdevops/bootstrap:alpine + +# Install ansible +RUN /usr/local/bin/apk-install \ + python \ + python-dev \ + py-setuptools \ + py-crypto \ + py2-pip \ + py-cparser \ + py-cryptography \ + py-markupsafe \ + py-cffi \ + py-yaml \ + py-jinja2 \ + py-paramiko \ + && pip install --upgrade pip \ + && hash -r \ + && pip install --no-cache-dir ansible \ + && chmod 750 /usr/bin/ansible* \ + # Cleanup + && apk del python-dev \ + && docker-image-cleanup diff --git a/docker/ansible/alpine/Dockerfile.jinja2 b/docker/ansible/alpine/Dockerfile.jinja2 new file mode 100644 index 000000000..a5a3ede42 --- /dev/null +++ b/docker/ansible/alpine/Dockerfile.jinja2 @@ -0,0 +1,3 @@ +{{ docker.from("bootstrap", "alpine") }} + +{{ ansible.alpine() }} diff --git a/docker/ansible/centos-7/Dockerfile b/docker/ansible/centos-7/Dockerfile index 6cd2e4586..9d7ccdd29 100644 --- a/docker/ansible/centos-7/Dockerfile +++ b/docker/ansible/centos-7/Dockerfile @@ -5,7 +5,24 @@ FROM webdevops/bootstrap:centos-7 -MAINTAINER info@webdevops.io -LABEL vendor=WebDevOps.io -LABEL io.webdevops.layout=8 -LABEL io.webdevops.version=1.5.0 +# Install ansible +RUN /usr/local/bin/yum-install \ + epel-release \ + PyYAML \ + python-jinja2 \ + python-httplib2 \ + python-keyczar \ + python-paramiko \ + python-setuptools \ + python-setuptools-devel \ + libffi \ + python-devel \ + libffi-devel \ + && easy_install pip \ + && pip install --upgrade pip \ + && hash -r \ + && pip install --no-cache-dir ansible \ + && chmod 750 /usr/bin/ansible* \ + # Cleanup + && yum erase -y python-devel \ + && docker-image-cleanup diff --git a/docker/ansible/centos-7/Dockerfile.jinja2 b/docker/ansible/centos-7/Dockerfile.jinja2 index df6600e50..7576c6ac4 100644 --- a/docker/ansible/centos-7/Dockerfile.jinja2 +++ b/docker/ansible/centos-7/Dockerfile.jinja2 @@ -1,3 +1,3 @@ {{ docker.from("bootstrap", "centos-7") }} -{{ docker.version() }} +{{ ansible.centos() }} diff --git a/docker/ansible/debian-7/Dockerfile b/docker/ansible/debian-7/Dockerfile index 0ccdb3387..98ac51767 100644 --- a/docker/ansible/debian-7/Dockerfile +++ b/docker/ansible/debian-7/Dockerfile @@ -5,7 +5,26 @@ FROM webdevops/bootstrap:debian-7 -MAINTAINER info@webdevops.io -LABEL vendor=WebDevOps.io -LABEL io.webdevops.layout=8 -LABEL io.webdevops.version=1.5.0 +# Install ansible +RUN /usr/local/bin/apt-install \ + # Install ansible + python-minimal \ + python-setuptools \ + python-pip \ + python-paramiko \ + python-jinja2 \ + python-dev \ + libffi-dev \ + libssl-dev \ + build-essential \ + && pip install --upgrade pip \ + && hash -r \ + && pip install --no-cache-dir ansible \ + && chmod 750 /usr/local/bin/ansible* \ + # Cleanup + && apt-get purge -y -f --force-yes \ + python-dev \ + build-essential \ + libssl-dev \ + libffi-dev \ + && docker-image-cleanup diff --git a/docker/ansible/debian-7/Dockerfile.jinja2 b/docker/ansible/debian-7/Dockerfile.jinja2 index d4f9bd541..a2c68b5a9 100644 --- a/docker/ansible/debian-7/Dockerfile.jinja2 +++ b/docker/ansible/debian-7/Dockerfile.jinja2 @@ -1,3 +1,3 @@ {{ docker.from("bootstrap", "debian-7") }} -{{ docker.version() }} +{{ ansible.debian() }} diff --git a/docker/ansible/debian-8/Dockerfile b/docker/ansible/debian-8/Dockerfile index 8d479d45a..9dbc99f79 100644 --- a/docker/ansible/debian-8/Dockerfile +++ b/docker/ansible/debian-8/Dockerfile @@ -5,7 +5,26 @@ FROM webdevops/bootstrap:debian-8 -MAINTAINER info@webdevops.io -LABEL vendor=WebDevOps.io -LABEL io.webdevops.layout=8 -LABEL io.webdevops.version=1.5.0 +# Install ansible +RUN /usr/local/bin/apt-install \ + # Install ansible + python-minimal \ + python-setuptools \ + python-pip \ + python-paramiko \ + python-jinja2 \ + python-dev \ + libffi-dev \ + libssl-dev \ + build-essential \ + && pip install --upgrade pip \ + && hash -r \ + && pip install --no-cache-dir ansible \ + && chmod 750 /usr/local/bin/ansible* \ + # Cleanup + && apt-get purge -y -f --force-yes \ + python-dev \ + build-essential \ + libssl-dev \ + libffi-dev \ + && docker-image-cleanup diff --git a/docker/ansible/debian-8/Dockerfile.jinja2 b/docker/ansible/debian-8/Dockerfile.jinja2 index db21f396f..ab9791753 100644 --- a/docker/ansible/debian-8/Dockerfile.jinja2 +++ b/docker/ansible/debian-8/Dockerfile.jinja2 @@ -1,3 +1,3 @@ {{ docker.from("bootstrap", "debian-8") }} -{{ docker.version() }} +{{ ansible.debian() }} diff --git a/docker/ansible/debian-9/Dockerfile b/docker/ansible/debian-9/Dockerfile index a003af70b..0e77bb72f 100644 --- a/docker/ansible/debian-9/Dockerfile +++ b/docker/ansible/debian-9/Dockerfile @@ -5,7 +5,26 @@ FROM webdevops/bootstrap:debian-9 -MAINTAINER info@webdevops.io -LABEL vendor=WebDevOps.io -LABEL io.webdevops.layout=8 -LABEL io.webdevops.version=1.5.0 +# Install ansible +RUN /usr/local/bin/apt-install \ + # Install ansible + python-minimal \ + python-setuptools \ + python-pip \ + python-paramiko \ + python-jinja2 \ + python-dev \ + libffi-dev \ + libssl-dev \ + build-essential \ + && pip install --upgrade pip \ + && hash -r \ + && pip install --no-cache-dir ansible \ + && chmod 750 /usr/local/bin/ansible* \ + # Cleanup + && apt-get purge -y -f --force-yes \ + python-dev \ + build-essential \ + libssl-dev \ + libffi-dev \ + && docker-image-cleanup diff --git a/docker/ansible/debian-9/Dockerfile.jinja2 b/docker/ansible/debian-9/Dockerfile.jinja2 index 421b2acff..4c0a6d9b1 100644 --- a/docker/ansible/debian-9/Dockerfile.jinja2 +++ b/docker/ansible/debian-9/Dockerfile.jinja2 @@ -1,3 +1,3 @@ {{ docker.from("bootstrap", "debian-9") }} -{{ docker.version() }} +{{ ansible.debian() }} diff --git a/docker/ansible/ubuntu-12.04/Dockerfile b/docker/ansible/ubuntu-12.04/Dockerfile index a76342092..fe3bbbdc1 100644 --- a/docker/ansible/ubuntu-12.04/Dockerfile +++ b/docker/ansible/ubuntu-12.04/Dockerfile @@ -5,7 +5,25 @@ FROM webdevops/bootstrap:ubuntu-12.04 -MAINTAINER info@webdevops.io -LABEL vendor=WebDevOps.io -LABEL io.webdevops.layout=8 -LABEL io.webdevops.version=1.5.0 +# Install ansible +RUN /usr/local/bin/apt-install \ + python-minimal \ + python-setuptools \ + python-pip \ + python-paramiko \ + python-jinja2 \ + python-dev \ + libffi-dev \ + libssl-dev \ + build-essential \ + && pip install --upgrade pip \ + && hash -r \ + && pip install --no-cache-dir ansible \ + && chmod 750 /usr/local/bin/ansible* \ + # Cleanup + && apt-get purge -y -f --force-yes \ + python-dev \ + build-essential \ + libssl-dev \ + libffi-dev \ + && docker-image-cleanup diff --git a/docker/ansible/ubuntu-12.04/Dockerfile.jinja2 b/docker/ansible/ubuntu-12.04/Dockerfile.jinja2 index 12c464c01..f196c3603 100644 --- a/docker/ansible/ubuntu-12.04/Dockerfile.jinja2 +++ b/docker/ansible/ubuntu-12.04/Dockerfile.jinja2 @@ -1,3 +1,3 @@ {{ docker.from("bootstrap", "ubuntu-12.04") }} -{{ docker.version() }} +{{ ansible.ubuntu() }} diff --git a/docker/ansible/ubuntu-14.04/Dockerfile b/docker/ansible/ubuntu-14.04/Dockerfile index 4a2bf36fc..edf666bb6 100644 --- a/docker/ansible/ubuntu-14.04/Dockerfile +++ b/docker/ansible/ubuntu-14.04/Dockerfile @@ -5,7 +5,25 @@ FROM webdevops/bootstrap:ubuntu-14.04 -MAINTAINER info@webdevops.io -LABEL vendor=WebDevOps.io -LABEL io.webdevops.layout=8 -LABEL io.webdevops.version=1.5.0 +# Install ansible +RUN /usr/local/bin/apt-install \ + python-minimal \ + python-setuptools \ + python-pip \ + python-paramiko \ + python-jinja2 \ + python-dev \ + libffi-dev \ + libssl-dev \ + build-essential \ + && pip install --upgrade pip \ + && hash -r \ + && pip install --no-cache-dir ansible \ + && chmod 750 /usr/local/bin/ansible* \ + # Cleanup + && apt-get purge -y -f --force-yes \ + python-dev \ + build-essential \ + libssl-dev \ + libffi-dev \ + && docker-image-cleanup diff --git a/docker/ansible/ubuntu-14.04/Dockerfile.jinja2 b/docker/ansible/ubuntu-14.04/Dockerfile.jinja2 index 9b61a0b6d..5392838c9 100644 --- a/docker/ansible/ubuntu-14.04/Dockerfile.jinja2 +++ b/docker/ansible/ubuntu-14.04/Dockerfile.jinja2 @@ -1,3 +1,3 @@ {{ docker.from("bootstrap", "ubuntu-14.04") }} -{{ docker.version() }} +{{ ansible.ubuntu() }} diff --git a/docker/ansible/ubuntu-15.04/Dockerfile b/docker/ansible/ubuntu-15.04/Dockerfile index ae02cf0c7..98f71b57e 100644 --- a/docker/ansible/ubuntu-15.04/Dockerfile +++ b/docker/ansible/ubuntu-15.04/Dockerfile @@ -5,7 +5,25 @@ FROM webdevops/bootstrap:ubuntu-15.04 -MAINTAINER info@webdevops.io -LABEL vendor=WebDevOps.io -LABEL io.webdevops.layout=8 -LABEL io.webdevops.version=1.5.0 +# Install ansible +RUN /usr/local/bin/apt-install \ + python-minimal \ + python-setuptools \ + python-pip \ + python-paramiko \ + python-jinja2 \ + python-dev \ + libffi-dev \ + libssl-dev \ + build-essential \ + && pip install --upgrade pip \ + && hash -r \ + && pip install --no-cache-dir ansible \ + && chmod 750 /usr/local/bin/ansible* \ + # Cleanup + && apt-get purge -y -f --force-yes \ + python-dev \ + build-essential \ + libssl-dev \ + libffi-dev \ + && docker-image-cleanup diff --git a/docker/ansible/ubuntu-15.04/Dockerfile.jinja2 b/docker/ansible/ubuntu-15.04/Dockerfile.jinja2 index 2feaab03a..d40ceda61 100644 --- a/docker/ansible/ubuntu-15.04/Dockerfile.jinja2 +++ b/docker/ansible/ubuntu-15.04/Dockerfile.jinja2 @@ -1,3 +1,3 @@ {{ docker.from("bootstrap", "ubuntu-15.04") }} -{{ docker.version() }} +{{ ansible.ubuntu() }} diff --git a/docker/ansible/ubuntu-15.10/Dockerfile b/docker/ansible/ubuntu-15.10/Dockerfile index 19e2f5aaf..a9f00de2c 100644 --- a/docker/ansible/ubuntu-15.10/Dockerfile +++ b/docker/ansible/ubuntu-15.10/Dockerfile @@ -5,7 +5,25 @@ FROM webdevops/bootstrap:ubuntu-15.10 -MAINTAINER info@webdevops.io -LABEL vendor=WebDevOps.io -LABEL io.webdevops.layout=8 -LABEL io.webdevops.version=1.5.0 +# Install ansible +RUN /usr/local/bin/apt-install \ + python-minimal \ + python-setuptools \ + python-pip \ + python-paramiko \ + python-jinja2 \ + python-dev \ + libffi-dev \ + libssl-dev \ + build-essential \ + && pip install --upgrade pip \ + && hash -r \ + && pip install --no-cache-dir ansible \ + && chmod 750 /usr/local/bin/ansible* \ + # Cleanup + && apt-get purge -y -f --force-yes \ + python-dev \ + build-essential \ + libssl-dev \ + libffi-dev \ + && docker-image-cleanup diff --git a/docker/ansible/ubuntu-15.10/Dockerfile.jinja2 b/docker/ansible/ubuntu-15.10/Dockerfile.jinja2 index f8df16c71..25e140e60 100644 --- a/docker/ansible/ubuntu-15.10/Dockerfile.jinja2 +++ b/docker/ansible/ubuntu-15.10/Dockerfile.jinja2 @@ -1,3 +1,3 @@ {{ docker.from("bootstrap", "ubuntu-15.10") }} -{{ docker.version() }} +{{ ansible.ubuntu() }} diff --git a/docker/ansible/ubuntu-16.04/Dockerfile b/docker/ansible/ubuntu-16.04/Dockerfile index 3122de821..3c00ba751 100644 --- a/docker/ansible/ubuntu-16.04/Dockerfile +++ b/docker/ansible/ubuntu-16.04/Dockerfile @@ -5,7 +5,25 @@ FROM webdevops/bootstrap:ubuntu-16.04 -MAINTAINER info@webdevops.io -LABEL vendor=WebDevOps.io -LABEL io.webdevops.layout=8 -LABEL io.webdevops.version=1.5.0 +# Install ansible +RUN /usr/local/bin/apt-install \ + python-minimal \ + python-setuptools \ + python-pip \ + python-paramiko \ + python-jinja2 \ + python-dev \ + libffi-dev \ + libssl-dev \ + build-essential \ + && pip install --upgrade pip \ + && hash -r \ + && pip install --no-cache-dir ansible \ + && chmod 750 /usr/local/bin/ansible* \ + # Cleanup + && apt-get purge -y -f --force-yes \ + python-dev \ + build-essential \ + libssl-dev \ + libffi-dev \ + && docker-image-cleanup diff --git a/docker/ansible/ubuntu-16.04/Dockerfile.jinja2 b/docker/ansible/ubuntu-16.04/Dockerfile.jinja2 index 3c1a9b9c0..22fa88807 100644 --- a/docker/ansible/ubuntu-16.04/Dockerfile.jinja2 +++ b/docker/ansible/ubuntu-16.04/Dockerfile.jinja2 @@ -1,3 +1,3 @@ {{ docker.from("bootstrap", "ubuntu-16.04") }} -{{ docker.version() }} +{{ ansible.ubuntu() }} diff --git a/docker/apache-dev/alpine-3 b/docker/apache-dev/alpine-3 new file mode 120000 index 000000000..0120374ca --- /dev/null +++ b/docker/apache-dev/alpine-3 @@ -0,0 +1 @@ +alpine \ No newline at end of file diff --git a/docker/apache-dev/alpine-3/Dockerfile b/docker/apache-dev/alpine-3/Dockerfile deleted file mode 100644 index 68f7c0fec..000000000 --- a/docker/apache-dev/alpine-3/Dockerfile +++ /dev/null @@ -1,25 +0,0 @@ -#+++++++++++++++++++++++++++++++++++++++ -# Dockerfile for webdevops/apache-dev:alpine-3 -# -- automatically generated -- -#+++++++++++++++++++++++++++++++++++++++ - -FROM webdevops/apache:alpine-3 - -MAINTAINER info@webdevops.io -LABEL vendor=WebDevOps.io -LABEL io.webdevops.layout=8 -LABEL io.webdevops.version=1.5.0 - -ENV WEB_DOCUMENT_ROOT /app -ENV WEB_DOCUMENT_INDEX index.php -ENV WEB_ALIAS_DOMAIN *.vm - -COPY conf/ /opt/docker/ - -# Install apache -RUN echo \ - && /opt/docker/bin/provision run --tag bootstrap --role webdevops-apache-dev \ - && /opt/docker/bin/bootstrap.sh - - -EXPOSE 80 443 diff --git a/docker/apache-dev/alpine-3/Dockerfile.jinja2 b/docker/apache-dev/alpine-3/Dockerfile.jinja2 deleted file mode 100644 index 4f8c82060..000000000 --- a/docker/apache-dev/alpine-3/Dockerfile.jinja2 +++ /dev/null @@ -1,11 +0,0 @@ -{{ docker.from("apache", "alpine-3") }} - -{{ docker.version() }} - -{{ environment.web() }} - -{{ docker.copy('conf/', '/opt/docker/') }} - -{{ apachedev.general() }} - -{{ docker.expose('80 443') }} diff --git a/docker/apache-dev/alpine-3/conf/bin/service.d/httpd.d/12-development.sh b/docker/apache-dev/alpine-3/conf/bin/service.d/httpd.d/12-development.sh deleted file mode 100644 index 299f67e2f..000000000 --- a/docker/apache-dev/alpine-3/conf/bin/service.d/httpd.d/12-development.sh +++ /dev/null @@ -1 +0,0 @@ -find /opt/docker/etc/httpd/ -iname '*.conf' -print0 | xargs -0 -r rpl --quiet "" "$WEB_NO_CACHE_PATTERN" > /dev/null diff --git a/docker/apache-dev/alpine/Dockerfile b/docker/apache-dev/alpine/Dockerfile new file mode 100644 index 000000000..022a18ddc --- /dev/null +++ b/docker/apache-dev/alpine/Dockerfile @@ -0,0 +1,20 @@ +#+++++++++++++++++++++++++++++++++++++++ +# Dockerfile for webdevops/apache-dev:alpine +# -- automatically generated -- +#+++++++++++++++++++++++++++++++++++++++ + +FROM webdevops/apache:alpine + +ENV WEB_DOCUMENT_ROOT=/app \ + WEB_DOCUMENT_INDEX=index.php \ + WEB_ALIAS_DOMAIN=*.vm + +COPY conf/ /opt/docker/ + +# Install apache +RUN echo \ + && /opt/docker/bin/provision run --tag bootstrap --role webdevops-apache-dev \ + && /opt/docker/bin/bootstrap.sh \ + && docker-image-cleanup + +EXPOSE 80 443 diff --git a/docker/apache-dev/alpine/Dockerfile.jinja2 b/docker/apache-dev/alpine/Dockerfile.jinja2 new file mode 100644 index 000000000..7ce5b72cb --- /dev/null +++ b/docker/apache-dev/alpine/Dockerfile.jinja2 @@ -0,0 +1,9 @@ +{{ docker.from("apache", "alpine") }} + +{{ environment.web() }} + +{{ docker.copy('conf/', '/opt/docker/') }} + +{{ apachedev.general() }} + +{{ docker.expose('80 443') }} diff --git a/docker/apache-dev/alpine/conf/bin/service.d/httpd.d/12-development.sh b/docker/apache-dev/alpine/conf/bin/service.d/httpd.d/12-development.sh new file mode 100644 index 000000000..a9d2c6e92 --- /dev/null +++ b/docker/apache-dev/alpine/conf/bin/service.d/httpd.d/12-development.sh @@ -0,0 +1,5 @@ +go-replace \ + -s "" -r "$WEB_NO_CACHE_PATTERN" \ + --path=/opt/docker/etc/httpd/ \ + --path-pattern='*.conf' \ + --ignore-empty diff --git a/docker/apache-dev/alpine-3/conf/etc/httpd/conf.d/02-dev.conf b/docker/apache-dev/alpine/conf/etc/httpd/conf.d/02-dev.conf similarity index 100% rename from docker/apache-dev/alpine-3/conf/etc/httpd/conf.d/02-dev.conf rename to docker/apache-dev/alpine/conf/etc/httpd/conf.d/02-dev.conf diff --git a/docker/apache-dev/alpine-3/conf/etc/httpd/vhost.common.d/.gitkeep b/docker/apache-dev/alpine/conf/etc/httpd/vhost.common.d/.gitkeep similarity index 100% rename from docker/apache-dev/alpine-3/conf/etc/httpd/vhost.common.d/.gitkeep rename to docker/apache-dev/alpine/conf/etc/httpd/vhost.common.d/.gitkeep diff --git a/docker/apache-dev/alpine-3/conf/etc/httpd/vhost.common.d/02-dev.conf b/docker/apache-dev/alpine/conf/etc/httpd/vhost.common.d/02-dev.conf similarity index 100% rename from docker/apache-dev/alpine-3/conf/etc/httpd/vhost.common.d/02-dev.conf rename to docker/apache-dev/alpine/conf/etc/httpd/vhost.common.d/02-dev.conf diff --git a/docker/apache-dev/alpine-3/conf/provision/roles/webdevops-apache-dev/defaults/main.yml b/docker/apache-dev/alpine/conf/provision/roles/webdevops-apache-dev/defaults/main.yml similarity index 100% rename from docker/apache-dev/alpine-3/conf/provision/roles/webdevops-apache-dev/defaults/main.yml rename to docker/apache-dev/alpine/conf/provision/roles/webdevops-apache-dev/defaults/main.yml diff --git a/docker/apache-dev/alpine-3/conf/provision/roles/webdevops-apache-dev/tasks/bootstrap.yml b/docker/apache-dev/alpine/conf/provision/roles/webdevops-apache-dev/tasks/bootstrap.yml similarity index 100% rename from docker/apache-dev/alpine-3/conf/provision/roles/webdevops-apache-dev/tasks/bootstrap.yml rename to docker/apache-dev/alpine/conf/provision/roles/webdevops-apache-dev/tasks/bootstrap.yml diff --git a/docker/apache-dev/alpine-3/conf/provision/roles/webdevops-apache-dev/tasks/main.yml b/docker/apache-dev/alpine/conf/provision/roles/webdevops-apache-dev/tasks/main.yml similarity index 100% rename from docker/apache-dev/alpine-3/conf/provision/roles/webdevops-apache-dev/tasks/main.yml rename to docker/apache-dev/alpine/conf/provision/roles/webdevops-apache-dev/tasks/main.yml diff --git a/docker/apache-dev/centos-7/Dockerfile b/docker/apache-dev/centos-7/Dockerfile index b58f2f8fe..5f5527845 100644 --- a/docker/apache-dev/centos-7/Dockerfile +++ b/docker/apache-dev/centos-7/Dockerfile @@ -5,21 +5,16 @@ FROM webdevops/apache:centos-7 -MAINTAINER info@webdevops.io -LABEL vendor=WebDevOps.io -LABEL io.webdevops.layout=8 -LABEL io.webdevops.version=1.5.0 - -ENV WEB_DOCUMENT_ROOT /app -ENV WEB_DOCUMENT_INDEX index.php -ENV WEB_ALIAS_DOMAIN *.vm +ENV WEB_DOCUMENT_ROOT=/app \ + WEB_DOCUMENT_INDEX=index.php \ + WEB_ALIAS_DOMAIN=*.vm COPY conf/ /opt/docker/ # Install apache RUN echo \ && /opt/docker/bin/provision run --tag bootstrap --role webdevops-apache-dev \ - && /opt/docker/bin/bootstrap.sh - + && /opt/docker/bin/bootstrap.sh \ + && docker-image-cleanup EXPOSE 80 443 diff --git a/docker/apache-dev/centos-7/Dockerfile.jinja2 b/docker/apache-dev/centos-7/Dockerfile.jinja2 index 2df2e82e9..99e7363fa 100644 --- a/docker/apache-dev/centos-7/Dockerfile.jinja2 +++ b/docker/apache-dev/centos-7/Dockerfile.jinja2 @@ -1,7 +1,5 @@ {{ docker.from("apache", "centos-7") }} -{{ docker.version() }} - {{ environment.web() }} {{ docker.copy('conf/', '/opt/docker/') }} diff --git a/docker/apache-dev/centos-7/conf/bin/service.d/httpd.d/12-development.sh b/docker/apache-dev/centos-7/conf/bin/service.d/httpd.d/12-development.sh index 299f67e2f..a9d2c6e92 100644 --- a/docker/apache-dev/centos-7/conf/bin/service.d/httpd.d/12-development.sh +++ b/docker/apache-dev/centos-7/conf/bin/service.d/httpd.d/12-development.sh @@ -1 +1,5 @@ -find /opt/docker/etc/httpd/ -iname '*.conf' -print0 | xargs -0 -r rpl --quiet "" "$WEB_NO_CACHE_PATTERN" > /dev/null +go-replace \ + -s "" -r "$WEB_NO_CACHE_PATTERN" \ + --path=/opt/docker/etc/httpd/ \ + --path-pattern='*.conf' \ + --ignore-empty diff --git a/docker/apache-dev/debian-7/Dockerfile b/docker/apache-dev/debian-7/Dockerfile index d14bbb456..28de61268 100644 --- a/docker/apache-dev/debian-7/Dockerfile +++ b/docker/apache-dev/debian-7/Dockerfile @@ -5,21 +5,16 @@ FROM webdevops/apache:debian-7 -MAINTAINER info@webdevops.io -LABEL vendor=WebDevOps.io -LABEL io.webdevops.layout=8 -LABEL io.webdevops.version=1.5.0 - -ENV WEB_DOCUMENT_ROOT /app -ENV WEB_DOCUMENT_INDEX index.php -ENV WEB_ALIAS_DOMAIN *.vm +ENV WEB_DOCUMENT_ROOT=/app \ + WEB_DOCUMENT_INDEX=index.php \ + WEB_ALIAS_DOMAIN=*.vm COPY conf/ /opt/docker/ # Install apache RUN echo \ && /opt/docker/bin/provision run --tag bootstrap --role webdevops-apache-dev \ - && /opt/docker/bin/bootstrap.sh - + && /opt/docker/bin/bootstrap.sh \ + && docker-image-cleanup EXPOSE 80 443 diff --git a/docker/apache-dev/debian-7/Dockerfile.jinja2 b/docker/apache-dev/debian-7/Dockerfile.jinja2 index 170f1fd82..5a35c40f0 100644 --- a/docker/apache-dev/debian-7/Dockerfile.jinja2 +++ b/docker/apache-dev/debian-7/Dockerfile.jinja2 @@ -1,7 +1,5 @@ {{ docker.from("apache", "debian-7") }} -{{ docker.version() }} - {{ environment.web() }} {{ docker.copy('conf/', '/opt/docker/') }} diff --git a/docker/apache-dev/debian-7/conf/bin/service.d/httpd.d/12-development.sh b/docker/apache-dev/debian-7/conf/bin/service.d/httpd.d/12-development.sh index 299f67e2f..a9d2c6e92 100644 --- a/docker/apache-dev/debian-7/conf/bin/service.d/httpd.d/12-development.sh +++ b/docker/apache-dev/debian-7/conf/bin/service.d/httpd.d/12-development.sh @@ -1 +1,5 @@ -find /opt/docker/etc/httpd/ -iname '*.conf' -print0 | xargs -0 -r rpl --quiet "" "$WEB_NO_CACHE_PATTERN" > /dev/null +go-replace \ + -s "" -r "$WEB_NO_CACHE_PATTERN" \ + --path=/opt/docker/etc/httpd/ \ + --path-pattern='*.conf' \ + --ignore-empty diff --git a/docker/apache-dev/debian-8/Dockerfile b/docker/apache-dev/debian-8/Dockerfile index 0f67ddaac..005acc5c9 100644 --- a/docker/apache-dev/debian-8/Dockerfile +++ b/docker/apache-dev/debian-8/Dockerfile @@ -5,21 +5,16 @@ FROM webdevops/apache:debian-8 -MAINTAINER info@webdevops.io -LABEL vendor=WebDevOps.io -LABEL io.webdevops.layout=8 -LABEL io.webdevops.version=1.5.0 - -ENV WEB_DOCUMENT_ROOT /app -ENV WEB_DOCUMENT_INDEX index.php -ENV WEB_ALIAS_DOMAIN *.vm +ENV WEB_DOCUMENT_ROOT=/app \ + WEB_DOCUMENT_INDEX=index.php \ + WEB_ALIAS_DOMAIN=*.vm COPY conf/ /opt/docker/ # Install apache RUN echo \ && /opt/docker/bin/provision run --tag bootstrap --role webdevops-apache-dev \ - && /opt/docker/bin/bootstrap.sh - + && /opt/docker/bin/bootstrap.sh \ + && docker-image-cleanup EXPOSE 80 443 diff --git a/docker/apache-dev/debian-8/Dockerfile.jinja2 b/docker/apache-dev/debian-8/Dockerfile.jinja2 index 417d75e1e..0455155eb 100644 --- a/docker/apache-dev/debian-8/Dockerfile.jinja2 +++ b/docker/apache-dev/debian-8/Dockerfile.jinja2 @@ -1,7 +1,5 @@ {{ docker.from("apache", "debian-8") }} -{{ docker.version() }} - {{ environment.web() }} {{ docker.copy('conf/', '/opt/docker/') }} diff --git a/docker/apache-dev/debian-8/conf/bin/service.d/httpd.d/12-development.sh b/docker/apache-dev/debian-8/conf/bin/service.d/httpd.d/12-development.sh index 299f67e2f..a9d2c6e92 100644 --- a/docker/apache-dev/debian-8/conf/bin/service.d/httpd.d/12-development.sh +++ b/docker/apache-dev/debian-8/conf/bin/service.d/httpd.d/12-development.sh @@ -1 +1,5 @@ -find /opt/docker/etc/httpd/ -iname '*.conf' -print0 | xargs -0 -r rpl --quiet "" "$WEB_NO_CACHE_PATTERN" > /dev/null +go-replace \ + -s "" -r "$WEB_NO_CACHE_PATTERN" \ + --path=/opt/docker/etc/httpd/ \ + --path-pattern='*.conf' \ + --ignore-empty diff --git a/docker/apache-dev/debian-9/Dockerfile b/docker/apache-dev/debian-9/Dockerfile index 5d31ab98a..56d1d5fef 100644 --- a/docker/apache-dev/debian-9/Dockerfile +++ b/docker/apache-dev/debian-9/Dockerfile @@ -5,21 +5,16 @@ FROM webdevops/apache:debian-9 -MAINTAINER info@webdevops.io -LABEL vendor=WebDevOps.io -LABEL io.webdevops.layout=8 -LABEL io.webdevops.version=1.5.0 - -ENV WEB_DOCUMENT_ROOT /app -ENV WEB_DOCUMENT_INDEX index.php -ENV WEB_ALIAS_DOMAIN *.vm +ENV WEB_DOCUMENT_ROOT=/app \ + WEB_DOCUMENT_INDEX=index.php \ + WEB_ALIAS_DOMAIN=*.vm COPY conf/ /opt/docker/ # Install apache RUN echo \ && /opt/docker/bin/provision run --tag bootstrap --role webdevops-apache-dev \ - && /opt/docker/bin/bootstrap.sh - + && /opt/docker/bin/bootstrap.sh \ + && docker-image-cleanup EXPOSE 80 443 diff --git a/docker/apache-dev/debian-9/Dockerfile.jinja2 b/docker/apache-dev/debian-9/Dockerfile.jinja2 index 703871b7e..1484de6cc 100644 --- a/docker/apache-dev/debian-9/Dockerfile.jinja2 +++ b/docker/apache-dev/debian-9/Dockerfile.jinja2 @@ -1,7 +1,5 @@ {{ docker.from("apache", "debian-9") }} -{{ docker.version() }} - {{ environment.web() }} {{ docker.copy('conf/', '/opt/docker/') }} diff --git a/docker/apache-dev/debian-9/conf/bin/service.d/httpd.d/12-development.sh b/docker/apache-dev/debian-9/conf/bin/service.d/httpd.d/12-development.sh index 299f67e2f..a9d2c6e92 100644 --- a/docker/apache-dev/debian-9/conf/bin/service.d/httpd.d/12-development.sh +++ b/docker/apache-dev/debian-9/conf/bin/service.d/httpd.d/12-development.sh @@ -1 +1,5 @@ -find /opt/docker/etc/httpd/ -iname '*.conf' -print0 | xargs -0 -r rpl --quiet "" "$WEB_NO_CACHE_PATTERN" > /dev/null +go-replace \ + -s "" -r "$WEB_NO_CACHE_PATTERN" \ + --path=/opt/docker/etc/httpd/ \ + --path-pattern='*.conf' \ + --ignore-empty diff --git a/docker/apache-dev/ubuntu-12.04/Dockerfile b/docker/apache-dev/ubuntu-12.04/Dockerfile index 517cf76d9..4c485c071 100644 --- a/docker/apache-dev/ubuntu-12.04/Dockerfile +++ b/docker/apache-dev/ubuntu-12.04/Dockerfile @@ -5,21 +5,16 @@ FROM webdevops/apache:ubuntu-12.04 -MAINTAINER info@webdevops.io -LABEL vendor=WebDevOps.io -LABEL io.webdevops.layout=8 -LABEL io.webdevops.version=1.5.0 - -ENV WEB_DOCUMENT_ROOT /app -ENV WEB_DOCUMENT_INDEX index.php -ENV WEB_ALIAS_DOMAIN *.vm +ENV WEB_DOCUMENT_ROOT=/app \ + WEB_DOCUMENT_INDEX=index.php \ + WEB_ALIAS_DOMAIN=*.vm COPY conf/ /opt/docker/ # Install apache RUN echo \ && /opt/docker/bin/provision run --tag bootstrap --role webdevops-apache-dev \ - && /opt/docker/bin/bootstrap.sh - + && /opt/docker/bin/bootstrap.sh \ + && docker-image-cleanup EXPOSE 80 443 diff --git a/docker/apache-dev/ubuntu-12.04/Dockerfile.jinja2 b/docker/apache-dev/ubuntu-12.04/Dockerfile.jinja2 index 1ebf21f16..e418a4877 100644 --- a/docker/apache-dev/ubuntu-12.04/Dockerfile.jinja2 +++ b/docker/apache-dev/ubuntu-12.04/Dockerfile.jinja2 @@ -1,7 +1,5 @@ {{ docker.from("apache", "ubuntu-12.04") }} -{{ docker.version() }} - {{ environment.web() }} {{ docker.copy('conf/', '/opt/docker/') }} diff --git a/docker/apache-dev/ubuntu-12.04/conf/bin/service.d/httpd.d/12-development.sh b/docker/apache-dev/ubuntu-12.04/conf/bin/service.d/httpd.d/12-development.sh index 299f67e2f..a9d2c6e92 100644 --- a/docker/apache-dev/ubuntu-12.04/conf/bin/service.d/httpd.d/12-development.sh +++ b/docker/apache-dev/ubuntu-12.04/conf/bin/service.d/httpd.d/12-development.sh @@ -1 +1,5 @@ -find /opt/docker/etc/httpd/ -iname '*.conf' -print0 | xargs -0 -r rpl --quiet "" "$WEB_NO_CACHE_PATTERN" > /dev/null +go-replace \ + -s "" -r "$WEB_NO_CACHE_PATTERN" \ + --path=/opt/docker/etc/httpd/ \ + --path-pattern='*.conf' \ + --ignore-empty diff --git a/docker/apache-dev/ubuntu-14.04/Dockerfile b/docker/apache-dev/ubuntu-14.04/Dockerfile index 0ba61658a..19e2565a8 100644 --- a/docker/apache-dev/ubuntu-14.04/Dockerfile +++ b/docker/apache-dev/ubuntu-14.04/Dockerfile @@ -5,21 +5,16 @@ FROM webdevops/apache:ubuntu-14.04 -MAINTAINER info@webdevops.io -LABEL vendor=WebDevOps.io -LABEL io.webdevops.layout=8 -LABEL io.webdevops.version=1.5.0 - -ENV WEB_DOCUMENT_ROOT /app -ENV WEB_DOCUMENT_INDEX index.php -ENV WEB_ALIAS_DOMAIN *.vm +ENV WEB_DOCUMENT_ROOT=/app \ + WEB_DOCUMENT_INDEX=index.php \ + WEB_ALIAS_DOMAIN=*.vm COPY conf/ /opt/docker/ # Install apache RUN echo \ && /opt/docker/bin/provision run --tag bootstrap --role webdevops-apache-dev \ - && /opt/docker/bin/bootstrap.sh - + && /opt/docker/bin/bootstrap.sh \ + && docker-image-cleanup EXPOSE 80 443 diff --git a/docker/apache-dev/ubuntu-14.04/Dockerfile.jinja2 b/docker/apache-dev/ubuntu-14.04/Dockerfile.jinja2 index 640029ebe..8f088e4a6 100644 --- a/docker/apache-dev/ubuntu-14.04/Dockerfile.jinja2 +++ b/docker/apache-dev/ubuntu-14.04/Dockerfile.jinja2 @@ -1,7 +1,5 @@ {{ docker.from("apache", "ubuntu-14.04") }} -{{ docker.version() }} - {{ environment.web() }} {{ docker.copy('conf/', '/opt/docker/') }} diff --git a/docker/apache-dev/ubuntu-14.04/conf/bin/service.d/httpd.d/12-development.sh b/docker/apache-dev/ubuntu-14.04/conf/bin/service.d/httpd.d/12-development.sh index 299f67e2f..a9d2c6e92 100644 --- a/docker/apache-dev/ubuntu-14.04/conf/bin/service.d/httpd.d/12-development.sh +++ b/docker/apache-dev/ubuntu-14.04/conf/bin/service.d/httpd.d/12-development.sh @@ -1 +1,5 @@ -find /opt/docker/etc/httpd/ -iname '*.conf' -print0 | xargs -0 -r rpl --quiet "" "$WEB_NO_CACHE_PATTERN" > /dev/null +go-replace \ + -s "" -r "$WEB_NO_CACHE_PATTERN" \ + --path=/opt/docker/etc/httpd/ \ + --path-pattern='*.conf' \ + --ignore-empty diff --git a/docker/apache-dev/ubuntu-15.04/Dockerfile b/docker/apache-dev/ubuntu-15.04/Dockerfile index a0372a283..959496a17 100644 --- a/docker/apache-dev/ubuntu-15.04/Dockerfile +++ b/docker/apache-dev/ubuntu-15.04/Dockerfile @@ -5,21 +5,16 @@ FROM webdevops/apache:ubuntu-15.04 -MAINTAINER info@webdevops.io -LABEL vendor=WebDevOps.io -LABEL io.webdevops.layout=8 -LABEL io.webdevops.version=1.5.0 - -ENV WEB_DOCUMENT_ROOT /app -ENV WEB_DOCUMENT_INDEX index.php -ENV WEB_ALIAS_DOMAIN *.vm +ENV WEB_DOCUMENT_ROOT=/app \ + WEB_DOCUMENT_INDEX=index.php \ + WEB_ALIAS_DOMAIN=*.vm COPY conf/ /opt/docker/ # Install apache RUN echo \ && /opt/docker/bin/provision run --tag bootstrap --role webdevops-apache-dev \ - && /opt/docker/bin/bootstrap.sh - + && /opt/docker/bin/bootstrap.sh \ + && docker-image-cleanup EXPOSE 80 443 diff --git a/docker/apache-dev/ubuntu-15.04/Dockerfile.jinja2 b/docker/apache-dev/ubuntu-15.04/Dockerfile.jinja2 index 9dc653089..6ea2a21b2 100644 --- a/docker/apache-dev/ubuntu-15.04/Dockerfile.jinja2 +++ b/docker/apache-dev/ubuntu-15.04/Dockerfile.jinja2 @@ -1,7 +1,5 @@ {{ docker.from("apache", "ubuntu-15.04") }} -{{ docker.version() }} - {{ environment.web() }} {{ docker.copy('conf/', '/opt/docker/') }} diff --git a/docker/apache-dev/ubuntu-15.04/conf/bin/service.d/httpd.d/12-development.sh b/docker/apache-dev/ubuntu-15.04/conf/bin/service.d/httpd.d/12-development.sh index 299f67e2f..a9d2c6e92 100644 --- a/docker/apache-dev/ubuntu-15.04/conf/bin/service.d/httpd.d/12-development.sh +++ b/docker/apache-dev/ubuntu-15.04/conf/bin/service.d/httpd.d/12-development.sh @@ -1 +1,5 @@ -find /opt/docker/etc/httpd/ -iname '*.conf' -print0 | xargs -0 -r rpl --quiet "" "$WEB_NO_CACHE_PATTERN" > /dev/null +go-replace \ + -s "" -r "$WEB_NO_CACHE_PATTERN" \ + --path=/opt/docker/etc/httpd/ \ + --path-pattern='*.conf' \ + --ignore-empty diff --git a/docker/apache-dev/ubuntu-15.10/Dockerfile b/docker/apache-dev/ubuntu-15.10/Dockerfile index 3628c0008..dbdc6d643 100644 --- a/docker/apache-dev/ubuntu-15.10/Dockerfile +++ b/docker/apache-dev/ubuntu-15.10/Dockerfile @@ -5,21 +5,16 @@ FROM webdevops/apache:ubuntu-15.10 -MAINTAINER info@webdevops.io -LABEL vendor=WebDevOps.io -LABEL io.webdevops.layout=8 -LABEL io.webdevops.version=1.5.0 - -ENV WEB_DOCUMENT_ROOT /app -ENV WEB_DOCUMENT_INDEX index.php -ENV WEB_ALIAS_DOMAIN *.vm +ENV WEB_DOCUMENT_ROOT=/app \ + WEB_DOCUMENT_INDEX=index.php \ + WEB_ALIAS_DOMAIN=*.vm COPY conf/ /opt/docker/ # Install apache RUN echo \ && /opt/docker/bin/provision run --tag bootstrap --role webdevops-apache-dev \ - && /opt/docker/bin/bootstrap.sh - + && /opt/docker/bin/bootstrap.sh \ + && docker-image-cleanup EXPOSE 80 443 diff --git a/docker/apache-dev/ubuntu-15.10/Dockerfile.jinja2 b/docker/apache-dev/ubuntu-15.10/Dockerfile.jinja2 index 20742a279..11620723c 100644 --- a/docker/apache-dev/ubuntu-15.10/Dockerfile.jinja2 +++ b/docker/apache-dev/ubuntu-15.10/Dockerfile.jinja2 @@ -1,7 +1,5 @@ {{ docker.from("apache", "ubuntu-15.10") }} -{{ docker.version() }} - {{ environment.web() }} {{ docker.copy('conf/', '/opt/docker/') }} diff --git a/docker/apache-dev/ubuntu-15.10/conf/bin/service.d/httpd.d/12-development.sh b/docker/apache-dev/ubuntu-15.10/conf/bin/service.d/httpd.d/12-development.sh index 299f67e2f..a9d2c6e92 100644 --- a/docker/apache-dev/ubuntu-15.10/conf/bin/service.d/httpd.d/12-development.sh +++ b/docker/apache-dev/ubuntu-15.10/conf/bin/service.d/httpd.d/12-development.sh @@ -1 +1,5 @@ -find /opt/docker/etc/httpd/ -iname '*.conf' -print0 | xargs -0 -r rpl --quiet "" "$WEB_NO_CACHE_PATTERN" > /dev/null +go-replace \ + -s "" -r "$WEB_NO_CACHE_PATTERN" \ + --path=/opt/docker/etc/httpd/ \ + --path-pattern='*.conf' \ + --ignore-empty diff --git a/docker/apache-dev/ubuntu-16.04/Dockerfile b/docker/apache-dev/ubuntu-16.04/Dockerfile index 20d4e05c3..67105047d 100644 --- a/docker/apache-dev/ubuntu-16.04/Dockerfile +++ b/docker/apache-dev/ubuntu-16.04/Dockerfile @@ -5,21 +5,16 @@ FROM webdevops/apache:ubuntu-16.04 -MAINTAINER info@webdevops.io -LABEL vendor=WebDevOps.io -LABEL io.webdevops.layout=8 -LABEL io.webdevops.version=1.5.0 - -ENV WEB_DOCUMENT_ROOT /app -ENV WEB_DOCUMENT_INDEX index.php -ENV WEB_ALIAS_DOMAIN *.vm +ENV WEB_DOCUMENT_ROOT=/app \ + WEB_DOCUMENT_INDEX=index.php \ + WEB_ALIAS_DOMAIN=*.vm COPY conf/ /opt/docker/ # Install apache RUN echo \ && /opt/docker/bin/provision run --tag bootstrap --role webdevops-apache-dev \ - && /opt/docker/bin/bootstrap.sh - + && /opt/docker/bin/bootstrap.sh \ + && docker-image-cleanup EXPOSE 80 443 diff --git a/docker/apache-dev/ubuntu-16.04/Dockerfile.jinja2 b/docker/apache-dev/ubuntu-16.04/Dockerfile.jinja2 index 248fcb5ad..6ff17cde4 100644 --- a/docker/apache-dev/ubuntu-16.04/Dockerfile.jinja2 +++ b/docker/apache-dev/ubuntu-16.04/Dockerfile.jinja2 @@ -1,7 +1,5 @@ {{ docker.from("apache", "ubuntu-16.04") }} -{{ docker.version() }} - {{ environment.web() }} {{ docker.copy('conf/', '/opt/docker/') }} diff --git a/docker/apache-dev/ubuntu-16.04/conf/bin/service.d/httpd.d/12-development.sh b/docker/apache-dev/ubuntu-16.04/conf/bin/service.d/httpd.d/12-development.sh index 299f67e2f..a9d2c6e92 100644 --- a/docker/apache-dev/ubuntu-16.04/conf/bin/service.d/httpd.d/12-development.sh +++ b/docker/apache-dev/ubuntu-16.04/conf/bin/service.d/httpd.d/12-development.sh @@ -1 +1,5 @@ -find /opt/docker/etc/httpd/ -iname '*.conf' -print0 | xargs -0 -r rpl --quiet "" "$WEB_NO_CACHE_PATTERN" > /dev/null +go-replace \ + -s "" -r "$WEB_NO_CACHE_PATTERN" \ + --path=/opt/docker/etc/httpd/ \ + --path-pattern='*.conf' \ + --ignore-empty diff --git a/docker/apache-dev/ubuntu-16.10/Dockerfile b/docker/apache-dev/ubuntu-16.10/Dockerfile index 455506522..b09b4d889 100644 --- a/docker/apache-dev/ubuntu-16.10/Dockerfile +++ b/docker/apache-dev/ubuntu-16.10/Dockerfile @@ -5,21 +5,16 @@ FROM webdevops/apache:ubuntu-16.10 -MAINTAINER info@webdevops.io -LABEL vendor=WebDevOps.io -LABEL io.webdevops.layout=8 -LABEL io.webdevops.version=1.5.0 - -ENV WEB_DOCUMENT_ROOT /app -ENV WEB_DOCUMENT_INDEX index.php -ENV WEB_ALIAS_DOMAIN *.vm +ENV WEB_DOCUMENT_ROOT=/app \ + WEB_DOCUMENT_INDEX=index.php \ + WEB_ALIAS_DOMAIN=*.vm COPY conf/ /opt/docker/ # Install apache RUN echo \ && /opt/docker/bin/provision run --tag bootstrap --role webdevops-apache-dev \ - && /opt/docker/bin/bootstrap.sh - + && /opt/docker/bin/bootstrap.sh \ + && docker-image-cleanup EXPOSE 80 443 diff --git a/docker/apache-dev/ubuntu-16.10/Dockerfile.jinja2 b/docker/apache-dev/ubuntu-16.10/Dockerfile.jinja2 index e18477a69..8714adf91 100644 --- a/docker/apache-dev/ubuntu-16.10/Dockerfile.jinja2 +++ b/docker/apache-dev/ubuntu-16.10/Dockerfile.jinja2 @@ -1,7 +1,5 @@ {{ docker.from("apache", "ubuntu-16.10") }} -{{ docker.version() }} - {{ environment.web() }} {{ docker.copy('conf/', '/opt/docker/') }} diff --git a/docker/apache-dev/ubuntu-16.10/conf/bin/service.d/httpd.d/12-development.sh b/docker/apache-dev/ubuntu-16.10/conf/bin/service.d/httpd.d/12-development.sh index 299f67e2f..a9d2c6e92 100644 --- a/docker/apache-dev/ubuntu-16.10/conf/bin/service.d/httpd.d/12-development.sh +++ b/docker/apache-dev/ubuntu-16.10/conf/bin/service.d/httpd.d/12-development.sh @@ -1 +1,5 @@ -find /opt/docker/etc/httpd/ -iname '*.conf' -print0 | xargs -0 -r rpl --quiet "" "$WEB_NO_CACHE_PATTERN" > /dev/null +go-replace \ + -s "" -r "$WEB_NO_CACHE_PATTERN" \ + --path=/opt/docker/etc/httpd/ \ + --path-pattern='*.conf' \ + --ignore-empty diff --git a/docker/apache/alpine-3 b/docker/apache/alpine-3 new file mode 120000 index 000000000..0120374ca --- /dev/null +++ b/docker/apache/alpine-3 @@ -0,0 +1 @@ +alpine \ No newline at end of file diff --git a/docker/apache/alpine-3/Dockerfile b/docker/apache/alpine-3/Dockerfile deleted file mode 100644 index 946f1ae4e..000000000 --- a/docker/apache/alpine-3/Dockerfile +++ /dev/null @@ -1,33 +0,0 @@ -#+++++++++++++++++++++++++++++++++++++++ -# Dockerfile for webdevops/apache:alpine-3 -# -- automatically generated -- -#+++++++++++++++++++++++++++++++++++++++ - -FROM webdevops/base:alpine-3 - -MAINTAINER info@webdevops.io -LABEL vendor=WebDevOps.io -LABEL io.webdevops.layout=8 -LABEL io.webdevops.version=1.5.0 - -ENV WEB_DOCUMENT_ROOT /app -ENV WEB_DOCUMENT_INDEX index.php -ENV WEB_ALIAS_DOMAIN *.vm - -COPY conf/ /opt/docker/ - -# Install apache -RUN /usr/local/bin/apk-install \ - apache2 \ - apache2-utils \ - apache2-proxy \ - apache2-ssl \ - && sed -ri ' \ - s!^(\s*CustomLog)\s+\S+!\1 /proc/self/fd/1!g; \ - s!^(\s*ErrorLog)\s+\S+!\1 /proc/self/fd/2!g; \ - ' /etc/apache2/httpd.conf \ - && /opt/docker/bin/provision run --tag bootstrap --role webdevops-apache \ - && /opt/docker/bin/bootstrap.sh - - -EXPOSE 80 443 diff --git a/docker/apache/alpine-3/Dockerfile.jinja2 b/docker/apache/alpine-3/Dockerfile.jinja2 deleted file mode 100644 index ea3af4101..000000000 --- a/docker/apache/alpine-3/Dockerfile.jinja2 +++ /dev/null @@ -1,11 +0,0 @@ -{{ docker.from("base", "alpine-3") }} - -{{ docker.version() }} - -{{ environment.web() }} - -{{ docker.copy('conf/', '/opt/docker/') }} - -{{ apache.alpine() }} - -{{ docker.expose('80 443') }} diff --git a/docker/apache/alpine-3/conf/bin/service.d/httpd.d/10-init.sh b/docker/apache/alpine-3/conf/bin/service.d/httpd.d/10-init.sh deleted file mode 100644 index d3f1a0c9c..000000000 --- a/docker/apache/alpine-3/conf/bin/service.d/httpd.d/10-init.sh +++ /dev/null @@ -1,19 +0,0 @@ -if [[ ! -e "$WEB_DOCUMENT_ROOT" ]]; then - echo "" - echo "[WARNING] WEB_DOCUMENT_ROOT does not exists with path \"$WEB_DOCUMENT_ROOT\"!" - echo "" -fi - -# Replace markers -find /opt/docker/etc/httpd/ -iname '*.conf' -print0 | xargs -0 -r rpl --quiet "" "$WEB_DOCUMENT_INDEX" > /dev/null -find /opt/docker/etc/httpd/ -iname '*.conf' -print0 | xargs -0 -r rpl --quiet "" "$WEB_DOCUMENT_ROOT" > /dev/null -find /opt/docker/etc/httpd/ -iname '*.conf' -print0 | xargs -0 -r rpl --quiet "" "$WEB_ALIAS_DOMAIN" > /dev/null -find /opt/docker/etc/httpd/ -iname '*.conf' -print0 | xargs -0 -r rpl --quiet "" "$HOSTNAME" > /dev/null - -if [[ -n "${WEB_PHP_SOCKET+x}" ]]; then - ## WEB_PHP_SOCKET is set - find /opt/docker/etc/httpd/ -iname '*.conf' -print0 | xargs -0 -r rpl --quiet "" "$WEB_PHP_SOCKET" > /dev/null -else - ## WEB_PHP_SOCKET is not set, remove PHP files - rm -f -- /opt/docker/etc/httpd/conf.d/10-php.conf -fi diff --git a/docker/apache/alpine-3/conf/etc/httpd/conf.d/10-log.conf b/docker/apache/alpine-3/conf/etc/httpd/conf.d/10-log.conf deleted file mode 100644 index e4c4be4f2..000000000 --- a/docker/apache/alpine-3/conf/etc/httpd/conf.d/10-log.conf +++ /dev/null @@ -1,4 +0,0 @@ -LogFormat "[httpd:access] %V:%p %h %l %u %t \"%r\" %>s bytesIn:%I bytesOut:%O reqTime:%T" dockerlog -LogLevel warn -CustomLog /proc/self/fd/1 dockerlog -ErrorLog /proc/self/fd/2 diff --git a/docker/apache/alpine-3/conf/provision/roles/webdevops-apache/tasks/bootstrap.yml b/docker/apache/alpine-3/conf/provision/roles/webdevops-apache/tasks/bootstrap.yml deleted file mode 100644 index 2be18b0e0..000000000 --- a/docker/apache/alpine-3/conf/provision/roles/webdevops-apache/tasks/bootstrap.yml +++ /dev/null @@ -1,156 +0,0 @@ ---- - -- name: Set apache vhost file [RedHat family] - set_fact: - apache_main_path: /etc/httpd/ - apache_docker_vhost: /etc/httpd/conf.d/zzz-docker.conf - when: ansible_os_family == 'RedHat' - -- name: Set apache vhost file [Debian family] - set_fact: - apache_main_path: /etc/apache2/ - apache_docker_vhost: /etc/apache2/sites-enabled/10-docker.conf - when: ansible_os_family == 'Debian' - -- name: Set apache vhost file [Alpine family] - set_fact: - apache_main_path: /etc/apache2/ - apache_docker_vhost: /etc/apache2/conf.d/zzz-docker.conf - when: ansible_os_family == 'Alpine' - -- name: Enable apache main config - file: - src: '/opt/docker/etc/httpd/main.conf' - dest: '{{ apache_docker_vhost }}' - state: link - force: yes - -- name: Ensure document root is available - file: - path: "{{ DOCUMENT_ROOT }}" - state: directory - recurse: yes - -- name: Ensure /var/run/apache2 exists - file: - path: '/var/run/apache2' - state: directory - recurse: yes - -- name: Ensure /run/apache2 exists - file: - path: '/run/apache2' - state: directory - recurse: yes - when: ansible_os_family == 'Alpine' - -- name: Find apache2 files - shell: "find '{{ apache_main_path }}' -type f -iname '*.conf' -o -iname 'default*' -o -iname '*log'" - register: apache2_conf_files - -- name: Change CustomLog to Docker stdout - replace: - dest: '{{ item }}' - regexp: '^[\s]*CustomLog ([^\s]+)(.*)' - replace: 'CustomLog /docker.stdout \2' - with_items: "{{ apache2_conf_files.stdout_lines }}" - -- name: Change CustomLog to Docker stdout - replace: - dest: '{{ item }}' - regexp: '^[\s]*ErrorLog ([^\s]+)(.*)' - replace: 'ErrorLog /docker.stdout \2' - with_items: "{{ apache2_conf_files.stdout_lines }}" - -- name: Change TransferLog to Docker stdout - replace: - dest: '{{ item }}' - regexp: '^[\s]*TransferLog ([^\s]+)(.*)' - replace: 'TransferLog /docker.stdout \2' - with_items: "{{ apache2_conf_files.stdout_lines }}" - -- name: Switch MPM to worker [RedHat family] - lineinfile: - dest: '/etc/httpd/conf.modules.d/00-mpm.conf' - regexp: '^[\s#]*{{ item.line }}' - line: '{{ item.prefix }}{{ item.line }}' - with_items: - - { line: 'LoadModule mpm_prefork_module modules/mod_mpm_prefork.so', prefix: "#" } - - { line: 'LoadModule mpm_event_module modules/mod_mpm_event.so', prefix: "" } - when: ansible_os_family == 'RedHat' - -- name: Switch MPM to event for Apache 2.4 and higher [Ubuntu family] - command: "{{ item }}" - with_items: - - 'a2dismod mpm_event' - - 'a2enmod mpm_event' - when: (ansible_distribution == 'Ubuntu' and ansible_lsb.major_release|int >= 14) or (ansible_distribution == 'Debian' and ansible_lsb.major_release|int >= 8) - -- name: Manage modules [Alpine family] - lineinfile: - dest: '/etc/apache2/httpd.conf' - regexp: '^[\s#]*{{ item.line }}' - line: '{{ item.prefix }}{{ item.line }}' - with_items: - - { line: 'LoadModule mpm_prefork_module modules/mod_mpm_prefork.so', prefix: "#" } - - { line: 'LoadModule mpm_event_module modules/mod_mpm_event.so', prefix: "" } - - { line: 'LoadModule deflate_module modules/mod_deflate.so', prefix: "" } - - { line: 'LoadModule rewrite_module modules/mod_rewrite.so', prefix: "" } - - { line: 'LoadModule logio_module modules/mod_logio.so', prefix: "" } - - { line: 'LoadModule slotmem_shm_module modules/mod_slotmem_shm.so', prefix: "" } - - { line: 'LoadModule actions_module modules/mod_actions.so', prefix: "" } - - { line: 'LoadModule expires_module modules/mod_expires.so', prefix: "" } - when: ansible_os_family == 'Alpine' - -- name: Fix ssl support [Alpine family] - lineinfile: - dest: '/etc/apache2/conf.d/ssl.conf' - regexp: '{{ item.regexp }}' - line: '{{ item.line }}' - with_items: - - { regexp: 'LoadModule ssl_module', line: 'LoadModule ssl_module /usr/lib/apache2/mod_ssl.so' } - - { regexp: 'LoadModule socache_shmcb_module', line: 'LoadModule socache_shmcb_module /usr/lib/apache2/mod_socache_shmcb.so' } - when: ansible_os_family == 'Alpine' - -- name: Remove default vhost from ssl configuration [Alpine family] - command: sed -i -e '1h;2,$H;$!d;g' -e 's//#-> removed vhost/g' /etc/apache2/conf.d/ssl.conf - when: ansible_os_family == 'Alpine' - -- name: Disable proxy [Alpine family] - lineinfile: - dest: '/etc/apache2/conf.d/proxy.conf' - regexp: '^[\s#]*{{ item.line }}' - line: '{{ item.prefix }}{{ item.line }}' - with_items: - - { line: 'LoadModule proxy_ajp_module modules/mod_proxy_ajp.so', prefix: "#" } - - { line: 'LoadModule proxy_connect_module modules/mod_proxy_connect.so', prefix: "#" } - - { line: 'LoadModule proxy_balancer_module modules/mod_proxy_balancer.so', prefix: "#" } - - { line: 'LoadModule proxy_express_module modules/mod_proxy_express.so', prefix: "#" } - - { line: 'LoadModule proxy_fcgi_module modules/mod_proxy_fcgi.so', prefix: "" } - - { line: 'LoadModule proxy_fdpass_module modules/mod_proxy_fdpass.so', prefix: "#" } - - { line: 'LoadModule proxy_ftp_module modules/mod_proxy_ftp.so', prefix: "#" } - - { line: 'LoadModule proxy_http_module modules/mod_proxy_http.so', prefix: "#" } - - { line: 'LoadModule proxy_scgi_module modules/mod_proxy_scgi.so', prefix: "#" } - when: ansible_os_family == 'Alpine' - -- name: Fix rights of ssl files - file: - path: "{{ item.path }}" - state: "{{ item.state }}" - mode: "{{ item.mode }}" - owner: "root" - group: "root" - with_items: - - { path: '/opt/docker/etc/httpd/ssl', state: 'directory', mode: '0750' } - - { path: '/opt/docker/etc/httpd/ssl/server.crt', state: 'file', mode: '0640' } - - { path: '/opt/docker/etc/httpd/ssl/server.csr', state: 'file', mode: '0640' } - - { path: '/opt/docker/etc/httpd/ssl/server.key', state: 'file', mode: '0640' } - -- name: Maintain lock directory [Debian family] - file: - path: "/var/lock/apache2" - state: "directory" - mode: "0750" - owner: "www-data" - group: "www-data" - when: ansible_os_family == 'Debian' diff --git a/docker/apache/alpine/Dockerfile b/docker/apache/alpine/Dockerfile new file mode 100644 index 000000000..11d956a08 --- /dev/null +++ b/docker/apache/alpine/Dockerfile @@ -0,0 +1,28 @@ +#+++++++++++++++++++++++++++++++++++++++ +# Dockerfile for webdevops/apache:alpine +# -- automatically generated -- +#+++++++++++++++++++++++++++++++++++++++ + +FROM webdevops/base:alpine + +ENV WEB_DOCUMENT_ROOT=/app \ + WEB_DOCUMENT_INDEX=index.php \ + WEB_ALIAS_DOMAIN=*.vm + +COPY conf/ /opt/docker/ + +# Install apache +RUN /usr/local/bin/apk-install \ + apache2 \ + apache2-utils \ + apache2-proxy \ + apache2-ssl \ + && sed -ri ' \ + s!^(\s*CustomLog)\s+\S+!\1 /proc/self/fd/1!g; \ + s!^(\s*ErrorLog)\s+\S+!\1 /proc/self/fd/2!g; \ + ' /etc/apache2/httpd.conf \ + && /opt/docker/bin/provision run --tag bootstrap --role webdevops-apache \ + && /opt/docker/bin/bootstrap.sh \ + && docker-image-cleanup + +EXPOSE 80 443 diff --git a/docker/apache/alpine/Dockerfile.jinja2 b/docker/apache/alpine/Dockerfile.jinja2 new file mode 100644 index 000000000..c7872662f --- /dev/null +++ b/docker/apache/alpine/Dockerfile.jinja2 @@ -0,0 +1,9 @@ +{{ docker.from("base", "alpine") }} + +{{ environment.web() }} + +{{ docker.copy('conf/', '/opt/docker/') }} + +{{ apache.alpine() }} + +{{ docker.expose('80 443') }} diff --git a/docker/apache/alpine/Dockerfile.jinja2-e b/docker/apache/alpine/Dockerfile.jinja2-e new file mode 100644 index 000000000..c7872662f --- /dev/null +++ b/docker/apache/alpine/Dockerfile.jinja2-e @@ -0,0 +1,9 @@ +{{ docker.from("base", "alpine") }} + +{{ environment.web() }} + +{{ docker.copy('conf/', '/opt/docker/') }} + +{{ apache.alpine() }} + +{{ docker.expose('80 443') }} diff --git a/docker/apache/alpine/conf/bin/service.d/httpd.d/10-init.sh b/docker/apache/alpine/conf/bin/service.d/httpd.d/10-init.sh new file mode 100644 index 000000000..b9d57997e --- /dev/null +++ b/docker/apache/alpine/conf/bin/service.d/httpd.d/10-init.sh @@ -0,0 +1,21 @@ +if [[ ! -e "$WEB_DOCUMENT_ROOT" ]]; then + echo "" + echo "[WARNING] WEB_DOCUMENT_ROOT does not exists with path \"$WEB_DOCUMENT_ROOT\"!" + echo "" +fi + +# Replace markers +go-replace \ + -s "" -r "$WEB_DOCUMENT_INDEX" \ + -s "" -r "$WEB_DOCUMENT_ROOT" \ + -s "" -r "$WEB_ALIAS_DOMAIN" \ + -s "" -r "$HOSTNAME" \ + -s "" -r "$WEB_PHP_SOCKET" \ + --path=/opt/docker/etc/httpd/ \ + --path-pattern='*.conf' \ + --ignore-empty + +if [[ -z "${WEB_PHP_SOCKET+x}" ]]; then + ## WEB_PHP_SOCKET is not set, remove PHP files + rm -f -- /opt/docker/etc/httpd/conf.d/10-php.conf +fi diff --git a/docker/apache/alpine-3/conf/bin/service.d/httpd.sh b/docker/apache/alpine/conf/bin/service.d/httpd.sh similarity index 100% rename from docker/apache/alpine-3/conf/bin/service.d/httpd.sh rename to docker/apache/alpine/conf/bin/service.d/httpd.sh diff --git a/docker/apache/alpine-3/conf/etc/httpd/conf.d/.gitkeep b/docker/apache/alpine/conf/etc/httpd/conf.d/.gitkeep similarity index 100% rename from docker/apache/alpine-3/conf/etc/httpd/conf.d/.gitkeep rename to docker/apache/alpine/conf/etc/httpd/conf.d/.gitkeep diff --git a/docker/apache/alpine-3/conf/etc/httpd/conf.d/10-error-document.conf b/docker/apache/alpine/conf/etc/httpd/conf.d/10-error-document.conf similarity index 100% rename from docker/apache/alpine-3/conf/etc/httpd/conf.d/10-error-document.conf rename to docker/apache/alpine/conf/etc/httpd/conf.d/10-error-document.conf diff --git a/docker/apache/alpine/conf/etc/httpd/conf.d/10-log.conf b/docker/apache/alpine/conf/etc/httpd/conf.d/10-log.conf new file mode 100644 index 000000000..ef0c73d38 --- /dev/null +++ b/docker/apache/alpine/conf/etc/httpd/conf.d/10-log.conf @@ -0,0 +1,4 @@ +LogFormat "[httpd:access] %V:%p %h %l %u %t \"%r\" %>s bytesIn:%I bytesOut:%O reqTime:%T" dockerlog +LogLevel warn +CustomLog /docker.stdout dockerlog +ErrorLog /docker.stderr diff --git a/docker/apache/alpine-3/conf/etc/httpd/conf.d/10-php.conf b/docker/apache/alpine/conf/etc/httpd/conf.d/10-php.conf similarity index 100% rename from docker/apache/alpine-3/conf/etc/httpd/conf.d/10-php.conf rename to docker/apache/alpine/conf/etc/httpd/conf.d/10-php.conf diff --git a/docker/apache/alpine-3/conf/etc/httpd/conf.d/10-server.conf b/docker/apache/alpine/conf/etc/httpd/conf.d/10-server.conf similarity index 100% rename from docker/apache/alpine-3/conf/etc/httpd/conf.d/10-server.conf rename to docker/apache/alpine/conf/etc/httpd/conf.d/10-server.conf diff --git a/docker/apache/alpine-3/conf/etc/httpd/global.conf b/docker/apache/alpine/conf/etc/httpd/global.conf similarity index 100% rename from docker/apache/alpine-3/conf/etc/httpd/global.conf rename to docker/apache/alpine/conf/etc/httpd/global.conf diff --git a/docker/apache/alpine-3/conf/etc/httpd/main.conf b/docker/apache/alpine/conf/etc/httpd/main.conf similarity index 100% rename from docker/apache/alpine-3/conf/etc/httpd/main.conf rename to docker/apache/alpine/conf/etc/httpd/main.conf diff --git a/docker/apache/alpine-3/conf/etc/httpd/php.conf b/docker/apache/alpine/conf/etc/httpd/php.conf similarity index 100% rename from docker/apache/alpine-3/conf/etc/httpd/php.conf rename to docker/apache/alpine/conf/etc/httpd/php.conf diff --git a/docker/apache/alpine-3/conf/etc/httpd/ssl/server.crt b/docker/apache/alpine/conf/etc/httpd/ssl/server.crt similarity index 100% rename from docker/apache/alpine-3/conf/etc/httpd/ssl/server.crt rename to docker/apache/alpine/conf/etc/httpd/ssl/server.crt diff --git a/docker/apache/alpine-3/conf/etc/httpd/ssl/server.csr b/docker/apache/alpine/conf/etc/httpd/ssl/server.csr similarity index 100% rename from docker/apache/alpine-3/conf/etc/httpd/ssl/server.csr rename to docker/apache/alpine/conf/etc/httpd/ssl/server.csr diff --git a/docker/apache/alpine-3/conf/etc/httpd/ssl/server.key b/docker/apache/alpine/conf/etc/httpd/ssl/server.key similarity index 100% rename from docker/apache/alpine-3/conf/etc/httpd/ssl/server.key rename to docker/apache/alpine/conf/etc/httpd/ssl/server.key diff --git a/docker/apache/alpine-3/conf/etc/httpd/vhost.common.conf b/docker/apache/alpine/conf/etc/httpd/vhost.common.conf similarity index 100% rename from docker/apache/alpine-3/conf/etc/httpd/vhost.common.conf rename to docker/apache/alpine/conf/etc/httpd/vhost.common.conf diff --git a/docker/apache/alpine-3/conf/etc/httpd/vhost.common.d/.gitkeep b/docker/apache/alpine/conf/etc/httpd/vhost.common.d/.gitkeep similarity index 100% rename from docker/apache/alpine-3/conf/etc/httpd/vhost.common.d/.gitkeep rename to docker/apache/alpine/conf/etc/httpd/vhost.common.d/.gitkeep diff --git a/docker/apache/alpine-3/conf/etc/httpd/vhost.common.d/01-boilerplate.conf b/docker/apache/alpine/conf/etc/httpd/vhost.common.d/01-boilerplate.conf similarity index 100% rename from docker/apache/alpine-3/conf/etc/httpd/vhost.common.d/01-boilerplate.conf rename to docker/apache/alpine/conf/etc/httpd/vhost.common.d/01-boilerplate.conf diff --git a/docker/apache/alpine-3/conf/etc/httpd/vhost.conf b/docker/apache/alpine/conf/etc/httpd/vhost.conf similarity index 100% rename from docker/apache/alpine-3/conf/etc/httpd/vhost.conf rename to docker/apache/alpine/conf/etc/httpd/vhost.conf diff --git a/docker/apache/alpine-3/conf/etc/httpd/vhost.ssl.conf b/docker/apache/alpine/conf/etc/httpd/vhost.ssl.conf similarity index 100% rename from docker/apache/alpine-3/conf/etc/httpd/vhost.ssl.conf rename to docker/apache/alpine/conf/etc/httpd/vhost.ssl.conf diff --git a/docker/apache/alpine-3/conf/etc/supervisor.d/apache.conf b/docker/apache/alpine/conf/etc/supervisor.d/apache.conf similarity index 100% rename from docker/apache/alpine-3/conf/etc/supervisor.d/apache.conf rename to docker/apache/alpine/conf/etc/supervisor.d/apache.conf diff --git a/docker/apache/alpine-3/conf/provision/roles/webdevops-apache/defaults/main.yml b/docker/apache/alpine/conf/provision/roles/webdevops-apache/defaults/main.yml similarity index 100% rename from docker/apache/alpine-3/conf/provision/roles/webdevops-apache/defaults/main.yml rename to docker/apache/alpine/conf/provision/roles/webdevops-apache/defaults/main.yml diff --git a/docker/apache/alpine/conf/provision/roles/webdevops-apache/tasks/bootstrap.yml b/docker/apache/alpine/conf/provision/roles/webdevops-apache/tasks/bootstrap.yml new file mode 100644 index 000000000..c285be286 --- /dev/null +++ b/docker/apache/alpine/conf/provision/roles/webdevops-apache/tasks/bootstrap.yml @@ -0,0 +1,156 @@ +--- + +- name: Set apache vhost file [RedHat family] + set_fact: + apache_main_path: /etc/httpd/ + apache_docker_vhost: /etc/httpd/conf.d/zzz-docker.conf + when: ansible_os_family == 'RedHat' + +- name: Set apache vhost file [Debian family] + set_fact: + apache_main_path: /etc/apache2/ + apache_docker_vhost: /etc/apache2/sites-enabled/10-docker.conf + when: ansible_os_family == 'Debian' + +- name: Set apache vhost file [Alpine family] + set_fact: + apache_main_path: /etc/apache2/ + apache_docker_vhost: /etc/apache2/conf.d/zzz-docker.conf + when: ansible_os_family == 'Alpine' + +- name: Enable apache main config + file: + src: '/opt/docker/etc/httpd/main.conf' + dest: '{{ apache_docker_vhost }}' + state: link + force: yes + +- name: Ensure document root is available + file: + path: "{{ DOCUMENT_ROOT }}" + state: directory + recurse: yes + +- name: Ensure /var/run/apache2 exists + file: + path: '/var/run/apache2' + state: directory + recurse: yes + +- name: Ensure /run/apache2 exists + file: + path: '/run/apache2' + state: directory + recurse: yes + when: ansible_os_family == 'Alpine' + +- name: Find apache2 files + shell: "find '{{ apache_main_path }}' -type f -iname '*.conf' -o -iname 'default*' -o -iname '*log'" + register: apache2_conf_files + +- name: Change CustomLog to Docker stdout + replace: + dest: '{{ item }}' + regexp: '^[\s]*CustomLog ([^\s]+)(.*)' + replace: 'CustomLog /docker.stdout \2' + with_items: "{{ apache2_conf_files.stdout_lines }}" + +- name: Change CustomLog to Docker stdout + replace: + dest: '{{ item }}' + regexp: '^[\s]*ErrorLog ([^\s]+)(.*)' + replace: 'ErrorLog /docker.stdout \2' + with_items: "{{ apache2_conf_files.stdout_lines }}" + +- name: Change TransferLog to Docker stdout + replace: + dest: '{{ item }}' + regexp: '^[\s]*TransferLog ([^\s]+)(.*)' + replace: 'TransferLog /docker.stdout \2' + with_items: "{{ apache2_conf_files.stdout_lines }}" + +- name: Switch MPM to worker [RedHat family] + lineinfile: + dest: '/etc/httpd/conf.modules.d/00-mpm.conf' + regexp: '^[\s#]*{{ item.line }}' + line: '{{ item.prefix }}{{ item.line }}' + with_items: + - { line: 'LoadModule mpm_prefork_module modules/mod_mpm_prefork.so', prefix: "#" } + - { line: 'LoadModule mpm_event_module modules/mod_mpm_event.so', prefix: "" } + when: ansible_os_family == 'RedHat' + +- name: Switch MPM to event for Apache 2.4 and higher [Ubuntu family] + command: "{{ item }}" + with_items: + - 'a2dismod mpm_event' + - 'a2enmod mpm_event' + when: (ansible_distribution == 'Ubuntu' and docker_image_info_distribution_version|int >= 14) or (ansible_distribution == 'Debian' and docker_image_info_distribution_version|int >= 8) + +- name: Manage modules [Alpine family] + lineinfile: + dest: '/etc/apache2/httpd.conf' + regexp: '^[\s#]*{{ item.line }}' + line: '{{ item.prefix }}{{ item.line }}' + with_items: + - { line: 'LoadModule mpm_prefork_module modules/mod_mpm_prefork.so', prefix: "#" } + - { line: 'LoadModule mpm_event_module modules/mod_mpm_event.so', prefix: "" } + - { line: 'LoadModule deflate_module modules/mod_deflate.so', prefix: "" } + - { line: 'LoadModule rewrite_module modules/mod_rewrite.so', prefix: "" } + - { line: 'LoadModule logio_module modules/mod_logio.so', prefix: "" } + - { line: 'LoadModule slotmem_shm_module modules/mod_slotmem_shm.so', prefix: "" } + - { line: 'LoadModule actions_module modules/mod_actions.so', prefix: "" } + - { line: 'LoadModule expires_module modules/mod_expires.so', prefix: "" } + when: ansible_os_family == 'Alpine' + +- name: Fix ssl support [Alpine family] + lineinfile: + dest: '/etc/apache2/conf.d/ssl.conf' + regexp: '{{ item.regexp }}' + line: '{{ item.line }}' + with_items: + - { regexp: 'LoadModule ssl_module', line: 'LoadModule ssl_module /usr/lib/apache2/mod_ssl.so' } + - { regexp: 'LoadModule socache_shmcb_module', line: 'LoadModule socache_shmcb_module /usr/lib/apache2/mod_socache_shmcb.so' } + when: ansible_os_family == 'Alpine' + +- name: Remove default vhost from ssl configuration [Alpine family] + command: sed -i -e '1h;2,$H;$!d;g' -e 's//#-> removed vhost/g' /etc/apache2/conf.d/ssl.conf + when: ansible_os_family == 'Alpine' + +- name: Disable proxy [Alpine family] + lineinfile: + dest: '/etc/apache2/conf.d/proxy.conf' + regexp: '^[\s#]*{{ item.line }}' + line: '{{ item.prefix }}{{ item.line }}' + with_items: + - { line: 'LoadModule proxy_ajp_module modules/mod_proxy_ajp.so', prefix: "#" } + - { line: 'LoadModule proxy_connect_module modules/mod_proxy_connect.so', prefix: "#" } + - { line: 'LoadModule proxy_balancer_module modules/mod_proxy_balancer.so', prefix: "#" } + - { line: 'LoadModule proxy_express_module modules/mod_proxy_express.so', prefix: "#" } + - { line: 'LoadModule proxy_fcgi_module modules/mod_proxy_fcgi.so', prefix: "" } + - { line: 'LoadModule proxy_fdpass_module modules/mod_proxy_fdpass.so', prefix: "#" } + - { line: 'LoadModule proxy_ftp_module modules/mod_proxy_ftp.so', prefix: "#" } + - { line: 'LoadModule proxy_http_module modules/mod_proxy_http.so', prefix: "#" } + - { line: 'LoadModule proxy_scgi_module modules/mod_proxy_scgi.so', prefix: "#" } + when: ansible_os_family == 'Alpine' + +- name: Fix rights of ssl files + file: + path: "{{ item.path }}" + state: "{{ item.state }}" + mode: "{{ item.mode }}" + owner: "root" + group: "root" + with_items: + - { path: '/opt/docker/etc/httpd/ssl', state: 'directory', mode: '0750' } + - { path: '/opt/docker/etc/httpd/ssl/server.crt', state: 'file', mode: '0640' } + - { path: '/opt/docker/etc/httpd/ssl/server.csr', state: 'file', mode: '0640' } + - { path: '/opt/docker/etc/httpd/ssl/server.key', state: 'file', mode: '0640' } + +- name: Maintain lock directory [Debian family] + file: + path: "/var/lock/apache2" + state: "directory" + mode: "0750" + owner: "www-data" + group: "www-data" + when: ansible_os_family == 'Debian' diff --git a/docker/apache/alpine-3/conf/provision/roles/webdevops-apache/tasks/main.yml b/docker/apache/alpine/conf/provision/roles/webdevops-apache/tasks/main.yml similarity index 100% rename from docker/apache/alpine-3/conf/provision/roles/webdevops-apache/tasks/main.yml rename to docker/apache/alpine/conf/provision/roles/webdevops-apache/tasks/main.yml diff --git a/docker/apache/centos-7/Dockerfile b/docker/apache/centos-7/Dockerfile index b00059c4c..9dca2bc0d 100644 --- a/docker/apache/centos-7/Dockerfile +++ b/docker/apache/centos-7/Dockerfile @@ -5,14 +5,9 @@ FROM webdevops/base:centos-7 -MAINTAINER info@webdevops.io -LABEL vendor=WebDevOps.io -LABEL io.webdevops.layout=8 -LABEL io.webdevops.version=1.5.0 - -ENV WEB_DOCUMENT_ROOT /app -ENV WEB_DOCUMENT_INDEX index.php -ENV WEB_ALIAS_DOMAIN *.vm +ENV WEB_DOCUMENT_ROOT=/app \ + WEB_DOCUMENT_INDEX=index.php \ + WEB_ALIAS_DOMAIN=*.vm COPY conf/ /opt/docker/ @@ -25,7 +20,7 @@ RUN /usr/local/bin/yum-install \ s!^(\s*ErrorLog)\s+\S+!\1 /proc/self/fd/2!g; \ ' /etc/httpd/conf/httpd.conf /etc/httpd/conf.d/ssl.conf \ && /opt/docker/bin/provision run --tag bootstrap --role webdevops-apache \ - && /opt/docker/bin/bootstrap.sh - + && /opt/docker/bin/bootstrap.sh \ + && docker-image-cleanup EXPOSE 80 443 diff --git a/docker/apache/centos-7/Dockerfile.jinja2 b/docker/apache/centos-7/Dockerfile.jinja2 index f70a561ef..374557686 100644 --- a/docker/apache/centos-7/Dockerfile.jinja2 +++ b/docker/apache/centos-7/Dockerfile.jinja2 @@ -1,7 +1,5 @@ {{ docker.from("base", "centos-7") }} -{{ docker.version() }} - {{ environment.web() }} {{ docker.copy('conf/', '/opt/docker/') }} diff --git a/docker/apache/centos-7/conf/bin/service.d/httpd.d/10-init.sh b/docker/apache/centos-7/conf/bin/service.d/httpd.d/10-init.sh index d3f1a0c9c..b9d57997e 100644 --- a/docker/apache/centos-7/conf/bin/service.d/httpd.d/10-init.sh +++ b/docker/apache/centos-7/conf/bin/service.d/httpd.d/10-init.sh @@ -5,15 +5,17 @@ if [[ ! -e "$WEB_DOCUMENT_ROOT" ]]; then fi # Replace markers -find /opt/docker/etc/httpd/ -iname '*.conf' -print0 | xargs -0 -r rpl --quiet "" "$WEB_DOCUMENT_INDEX" > /dev/null -find /opt/docker/etc/httpd/ -iname '*.conf' -print0 | xargs -0 -r rpl --quiet "" "$WEB_DOCUMENT_ROOT" > /dev/null -find /opt/docker/etc/httpd/ -iname '*.conf' -print0 | xargs -0 -r rpl --quiet "" "$WEB_ALIAS_DOMAIN" > /dev/null -find /opt/docker/etc/httpd/ -iname '*.conf' -print0 | xargs -0 -r rpl --quiet "" "$HOSTNAME" > /dev/null +go-replace \ + -s "" -r "$WEB_DOCUMENT_INDEX" \ + -s "" -r "$WEB_DOCUMENT_ROOT" \ + -s "" -r "$WEB_ALIAS_DOMAIN" \ + -s "" -r "$HOSTNAME" \ + -s "" -r "$WEB_PHP_SOCKET" \ + --path=/opt/docker/etc/httpd/ \ + --path-pattern='*.conf' \ + --ignore-empty -if [[ -n "${WEB_PHP_SOCKET+x}" ]]; then - ## WEB_PHP_SOCKET is set - find /opt/docker/etc/httpd/ -iname '*.conf' -print0 | xargs -0 -r rpl --quiet "" "$WEB_PHP_SOCKET" > /dev/null -else +if [[ -z "${WEB_PHP_SOCKET+x}" ]]; then ## WEB_PHP_SOCKET is not set, remove PHP files rm -f -- /opt/docker/etc/httpd/conf.d/10-php.conf fi diff --git a/docker/apache/centos-7/conf/etc/httpd/conf.d/10-log.conf b/docker/apache/centos-7/conf/etc/httpd/conf.d/10-log.conf index e4c4be4f2..ef0c73d38 100644 --- a/docker/apache/centos-7/conf/etc/httpd/conf.d/10-log.conf +++ b/docker/apache/centos-7/conf/etc/httpd/conf.d/10-log.conf @@ -1,4 +1,4 @@ LogFormat "[httpd:access] %V:%p %h %l %u %t \"%r\" %>s bytesIn:%I bytesOut:%O reqTime:%T" dockerlog LogLevel warn -CustomLog /proc/self/fd/1 dockerlog -ErrorLog /proc/self/fd/2 +CustomLog /docker.stdout dockerlog +ErrorLog /docker.stderr diff --git a/docker/apache/centos-7/conf/provision/roles/webdevops-apache/tasks/bootstrap.yml b/docker/apache/centos-7/conf/provision/roles/webdevops-apache/tasks/bootstrap.yml index 2be18b0e0..c285be286 100644 --- a/docker/apache/centos-7/conf/provision/roles/webdevops-apache/tasks/bootstrap.yml +++ b/docker/apache/centos-7/conf/provision/roles/webdevops-apache/tasks/bootstrap.yml @@ -84,7 +84,7 @@ with_items: - 'a2dismod mpm_event' - 'a2enmod mpm_event' - when: (ansible_distribution == 'Ubuntu' and ansible_lsb.major_release|int >= 14) or (ansible_distribution == 'Debian' and ansible_lsb.major_release|int >= 8) + when: (ansible_distribution == 'Ubuntu' and docker_image_info_distribution_version|int >= 14) or (ansible_distribution == 'Debian' and docker_image_info_distribution_version|int >= 8) - name: Manage modules [Alpine family] lineinfile: diff --git a/docker/apache/debian-7/Dockerfile b/docker/apache/debian-7/Dockerfile index d64f8cf0e..0e7b45a39 100644 --- a/docker/apache/debian-7/Dockerfile +++ b/docker/apache/debian-7/Dockerfile @@ -5,14 +5,9 @@ FROM webdevops/base:debian-7 -MAINTAINER info@webdevops.io -LABEL vendor=WebDevOps.io -LABEL io.webdevops.layout=8 -LABEL io.webdevops.version=1.5.0 - -ENV WEB_DOCUMENT_ROOT /app -ENV WEB_DOCUMENT_INDEX index.php -ENV WEB_ALIAS_DOMAIN *.vm +ENV WEB_DOCUMENT_ROOT=/app \ + WEB_DOCUMENT_INDEX=index.php \ + WEB_ALIAS_DOMAIN=*.vm COPY conf/ /opt/docker/ @@ -28,7 +23,7 @@ RUN /usr/local/bin/apt-install \ && rm -f /etc/apache2/sites-enabled/* \ && a2enmod actions fastcgi ssl rewrite headers expires \ && /opt/docker/bin/provision run --tag bootstrap --role webdevops-apache \ - && /opt/docker/bin/bootstrap.sh - + && /opt/docker/bin/bootstrap.sh \ + && docker-image-cleanup EXPOSE 80 443 diff --git a/docker/apache/debian-7/Dockerfile.jinja2 b/docker/apache/debian-7/Dockerfile.jinja2 index 94dde9aa2..686bb311e 100644 --- a/docker/apache/debian-7/Dockerfile.jinja2 +++ b/docker/apache/debian-7/Dockerfile.jinja2 @@ -1,7 +1,5 @@ {{ docker.from("base", "debian-7") }} -{{ docker.version() }} - {{ environment.web() }} {{ docker.copy('conf/', '/opt/docker/') }} diff --git a/docker/apache/debian-7/conf/bin/service.d/httpd.d/10-init.sh b/docker/apache/debian-7/conf/bin/service.d/httpd.d/10-init.sh index d3f1a0c9c..b9d57997e 100644 --- a/docker/apache/debian-7/conf/bin/service.d/httpd.d/10-init.sh +++ b/docker/apache/debian-7/conf/bin/service.d/httpd.d/10-init.sh @@ -5,15 +5,17 @@ if [[ ! -e "$WEB_DOCUMENT_ROOT" ]]; then fi # Replace markers -find /opt/docker/etc/httpd/ -iname '*.conf' -print0 | xargs -0 -r rpl --quiet "" "$WEB_DOCUMENT_INDEX" > /dev/null -find /opt/docker/etc/httpd/ -iname '*.conf' -print0 | xargs -0 -r rpl --quiet "" "$WEB_DOCUMENT_ROOT" > /dev/null -find /opt/docker/etc/httpd/ -iname '*.conf' -print0 | xargs -0 -r rpl --quiet "" "$WEB_ALIAS_DOMAIN" > /dev/null -find /opt/docker/etc/httpd/ -iname '*.conf' -print0 | xargs -0 -r rpl --quiet "" "$HOSTNAME" > /dev/null +go-replace \ + -s "" -r "$WEB_DOCUMENT_INDEX" \ + -s "" -r "$WEB_DOCUMENT_ROOT" \ + -s "" -r "$WEB_ALIAS_DOMAIN" \ + -s "" -r "$HOSTNAME" \ + -s "" -r "$WEB_PHP_SOCKET" \ + --path=/opt/docker/etc/httpd/ \ + --path-pattern='*.conf' \ + --ignore-empty -if [[ -n "${WEB_PHP_SOCKET+x}" ]]; then - ## WEB_PHP_SOCKET is set - find /opt/docker/etc/httpd/ -iname '*.conf' -print0 | xargs -0 -r rpl --quiet "" "$WEB_PHP_SOCKET" > /dev/null -else +if [[ -z "${WEB_PHP_SOCKET+x}" ]]; then ## WEB_PHP_SOCKET is not set, remove PHP files rm -f -- /opt/docker/etc/httpd/conf.d/10-php.conf fi diff --git a/docker/apache/debian-7/conf/etc/httpd/conf.d/10-log.conf b/docker/apache/debian-7/conf/etc/httpd/conf.d/10-log.conf index e4c4be4f2..ef0c73d38 100644 --- a/docker/apache/debian-7/conf/etc/httpd/conf.d/10-log.conf +++ b/docker/apache/debian-7/conf/etc/httpd/conf.d/10-log.conf @@ -1,4 +1,4 @@ LogFormat "[httpd:access] %V:%p %h %l %u %t \"%r\" %>s bytesIn:%I bytesOut:%O reqTime:%T" dockerlog LogLevel warn -CustomLog /proc/self/fd/1 dockerlog -ErrorLog /proc/self/fd/2 +CustomLog /docker.stdout dockerlog +ErrorLog /docker.stderr diff --git a/docker/apache/debian-7/conf/provision/roles/webdevops-apache/tasks/bootstrap.yml b/docker/apache/debian-7/conf/provision/roles/webdevops-apache/tasks/bootstrap.yml index 2be18b0e0..c285be286 100644 --- a/docker/apache/debian-7/conf/provision/roles/webdevops-apache/tasks/bootstrap.yml +++ b/docker/apache/debian-7/conf/provision/roles/webdevops-apache/tasks/bootstrap.yml @@ -84,7 +84,7 @@ with_items: - 'a2dismod mpm_event' - 'a2enmod mpm_event' - when: (ansible_distribution == 'Ubuntu' and ansible_lsb.major_release|int >= 14) or (ansible_distribution == 'Debian' and ansible_lsb.major_release|int >= 8) + when: (ansible_distribution == 'Ubuntu' and docker_image_info_distribution_version|int >= 14) or (ansible_distribution == 'Debian' and docker_image_info_distribution_version|int >= 8) - name: Manage modules [Alpine family] lineinfile: diff --git a/docker/apache/debian-8/Dockerfile b/docker/apache/debian-8/Dockerfile index 8bdfe34e3..ed5c30c66 100644 --- a/docker/apache/debian-8/Dockerfile +++ b/docker/apache/debian-8/Dockerfile @@ -5,14 +5,9 @@ FROM webdevops/base:debian-8 -MAINTAINER info@webdevops.io -LABEL vendor=WebDevOps.io -LABEL io.webdevops.layout=8 -LABEL io.webdevops.version=1.5.0 - -ENV WEB_DOCUMENT_ROOT /app -ENV WEB_DOCUMENT_INDEX index.php -ENV WEB_ALIAS_DOMAIN *.vm +ENV WEB_DOCUMENT_ROOT=/app \ + WEB_DOCUMENT_INDEX=index.php \ + WEB_ALIAS_DOMAIN=*.vm COPY conf/ /opt/docker/ @@ -27,7 +22,7 @@ RUN /usr/local/bin/apt-install \ && rm -f /etc/apache2/sites-enabled/* \ && a2enmod actions proxy proxy_fcgi ssl rewrite headers expires \ && /opt/docker/bin/provision run --tag bootstrap --role webdevops-apache \ - && /opt/docker/bin/bootstrap.sh - + && /opt/docker/bin/bootstrap.sh \ + && docker-image-cleanup EXPOSE 80 443 diff --git a/docker/apache/debian-8/Dockerfile.jinja2 b/docker/apache/debian-8/Dockerfile.jinja2 index 0f0452e09..74b255c92 100644 --- a/docker/apache/debian-8/Dockerfile.jinja2 +++ b/docker/apache/debian-8/Dockerfile.jinja2 @@ -1,7 +1,5 @@ {{ docker.from("base", "debian-8") }} -{{ docker.version() }} - {{ environment.web() }} {{ docker.copy('conf/', '/opt/docker/') }} diff --git a/docker/apache/debian-8/conf/bin/service.d/httpd.d/10-init.sh b/docker/apache/debian-8/conf/bin/service.d/httpd.d/10-init.sh index d3f1a0c9c..b9d57997e 100644 --- a/docker/apache/debian-8/conf/bin/service.d/httpd.d/10-init.sh +++ b/docker/apache/debian-8/conf/bin/service.d/httpd.d/10-init.sh @@ -5,15 +5,17 @@ if [[ ! -e "$WEB_DOCUMENT_ROOT" ]]; then fi # Replace markers -find /opt/docker/etc/httpd/ -iname '*.conf' -print0 | xargs -0 -r rpl --quiet "" "$WEB_DOCUMENT_INDEX" > /dev/null -find /opt/docker/etc/httpd/ -iname '*.conf' -print0 | xargs -0 -r rpl --quiet "" "$WEB_DOCUMENT_ROOT" > /dev/null -find /opt/docker/etc/httpd/ -iname '*.conf' -print0 | xargs -0 -r rpl --quiet "" "$WEB_ALIAS_DOMAIN" > /dev/null -find /opt/docker/etc/httpd/ -iname '*.conf' -print0 | xargs -0 -r rpl --quiet "" "$HOSTNAME" > /dev/null +go-replace \ + -s "" -r "$WEB_DOCUMENT_INDEX" \ + -s "" -r "$WEB_DOCUMENT_ROOT" \ + -s "" -r "$WEB_ALIAS_DOMAIN" \ + -s "" -r "$HOSTNAME" \ + -s "" -r "$WEB_PHP_SOCKET" \ + --path=/opt/docker/etc/httpd/ \ + --path-pattern='*.conf' \ + --ignore-empty -if [[ -n "${WEB_PHP_SOCKET+x}" ]]; then - ## WEB_PHP_SOCKET is set - find /opt/docker/etc/httpd/ -iname '*.conf' -print0 | xargs -0 -r rpl --quiet "" "$WEB_PHP_SOCKET" > /dev/null -else +if [[ -z "${WEB_PHP_SOCKET+x}" ]]; then ## WEB_PHP_SOCKET is not set, remove PHP files rm -f -- /opt/docker/etc/httpd/conf.d/10-php.conf fi diff --git a/docker/apache/debian-8/conf/etc/httpd/conf.d/10-log.conf b/docker/apache/debian-8/conf/etc/httpd/conf.d/10-log.conf index e4c4be4f2..ef0c73d38 100644 --- a/docker/apache/debian-8/conf/etc/httpd/conf.d/10-log.conf +++ b/docker/apache/debian-8/conf/etc/httpd/conf.d/10-log.conf @@ -1,4 +1,4 @@ LogFormat "[httpd:access] %V:%p %h %l %u %t \"%r\" %>s bytesIn:%I bytesOut:%O reqTime:%T" dockerlog LogLevel warn -CustomLog /proc/self/fd/1 dockerlog -ErrorLog /proc/self/fd/2 +CustomLog /docker.stdout dockerlog +ErrorLog /docker.stderr diff --git a/docker/apache/debian-8/conf/provision/roles/webdevops-apache/tasks/bootstrap.yml b/docker/apache/debian-8/conf/provision/roles/webdevops-apache/tasks/bootstrap.yml index 2be18b0e0..c285be286 100644 --- a/docker/apache/debian-8/conf/provision/roles/webdevops-apache/tasks/bootstrap.yml +++ b/docker/apache/debian-8/conf/provision/roles/webdevops-apache/tasks/bootstrap.yml @@ -84,7 +84,7 @@ with_items: - 'a2dismod mpm_event' - 'a2enmod mpm_event' - when: (ansible_distribution == 'Ubuntu' and ansible_lsb.major_release|int >= 14) or (ansible_distribution == 'Debian' and ansible_lsb.major_release|int >= 8) + when: (ansible_distribution == 'Ubuntu' and docker_image_info_distribution_version|int >= 14) or (ansible_distribution == 'Debian' and docker_image_info_distribution_version|int >= 8) - name: Manage modules [Alpine family] lineinfile: diff --git a/docker/apache/debian-9/Dockerfile b/docker/apache/debian-9/Dockerfile index 96943087c..5e22976b5 100644 --- a/docker/apache/debian-9/Dockerfile +++ b/docker/apache/debian-9/Dockerfile @@ -5,14 +5,9 @@ FROM webdevops/base:debian-9 -MAINTAINER info@webdevops.io -LABEL vendor=WebDevOps.io -LABEL io.webdevops.layout=8 -LABEL io.webdevops.version=1.5.0 - -ENV WEB_DOCUMENT_ROOT /app -ENV WEB_DOCUMENT_INDEX index.php -ENV WEB_ALIAS_DOMAIN *.vm +ENV WEB_DOCUMENT_ROOT=/app \ + WEB_DOCUMENT_INDEX=index.php \ + WEB_ALIAS_DOMAIN=*.vm COPY conf/ /opt/docker/ @@ -26,7 +21,7 @@ RUN /usr/local/bin/apt-install \ && rm -f /etc/apache2/sites-enabled/* \ && a2enmod actions proxy proxy_fcgi ssl rewrite headers expires \ && /opt/docker/bin/provision run --tag bootstrap --role webdevops-apache \ - && /opt/docker/bin/bootstrap.sh - + && /opt/docker/bin/bootstrap.sh \ + && docker-image-cleanup EXPOSE 80 443 diff --git a/docker/apache/debian-9/Dockerfile.jinja2 b/docker/apache/debian-9/Dockerfile.jinja2 index 768a16da4..856df6a14 100644 --- a/docker/apache/debian-9/Dockerfile.jinja2 +++ b/docker/apache/debian-9/Dockerfile.jinja2 @@ -1,7 +1,5 @@ {{ docker.from("base", "debian-9") }} -{{ docker.version() }} - {{ environment.web() }} {{ docker.copy('conf/', '/opt/docker/') }} diff --git a/docker/apache/debian-9/conf/bin/service.d/httpd.d/10-init.sh b/docker/apache/debian-9/conf/bin/service.d/httpd.d/10-init.sh index d3f1a0c9c..b9d57997e 100644 --- a/docker/apache/debian-9/conf/bin/service.d/httpd.d/10-init.sh +++ b/docker/apache/debian-9/conf/bin/service.d/httpd.d/10-init.sh @@ -5,15 +5,17 @@ if [[ ! -e "$WEB_DOCUMENT_ROOT" ]]; then fi # Replace markers -find /opt/docker/etc/httpd/ -iname '*.conf' -print0 | xargs -0 -r rpl --quiet "" "$WEB_DOCUMENT_INDEX" > /dev/null -find /opt/docker/etc/httpd/ -iname '*.conf' -print0 | xargs -0 -r rpl --quiet "" "$WEB_DOCUMENT_ROOT" > /dev/null -find /opt/docker/etc/httpd/ -iname '*.conf' -print0 | xargs -0 -r rpl --quiet "" "$WEB_ALIAS_DOMAIN" > /dev/null -find /opt/docker/etc/httpd/ -iname '*.conf' -print0 | xargs -0 -r rpl --quiet "" "$HOSTNAME" > /dev/null +go-replace \ + -s "" -r "$WEB_DOCUMENT_INDEX" \ + -s "" -r "$WEB_DOCUMENT_ROOT" \ + -s "" -r "$WEB_ALIAS_DOMAIN" \ + -s "" -r "$HOSTNAME" \ + -s "" -r "$WEB_PHP_SOCKET" \ + --path=/opt/docker/etc/httpd/ \ + --path-pattern='*.conf' \ + --ignore-empty -if [[ -n "${WEB_PHP_SOCKET+x}" ]]; then - ## WEB_PHP_SOCKET is set - find /opt/docker/etc/httpd/ -iname '*.conf' -print0 | xargs -0 -r rpl --quiet "" "$WEB_PHP_SOCKET" > /dev/null -else +if [[ -z "${WEB_PHP_SOCKET+x}" ]]; then ## WEB_PHP_SOCKET is not set, remove PHP files rm -f -- /opt/docker/etc/httpd/conf.d/10-php.conf fi diff --git a/docker/apache/debian-9/conf/etc/httpd/conf.d/10-log.conf b/docker/apache/debian-9/conf/etc/httpd/conf.d/10-log.conf index e4c4be4f2..ef0c73d38 100644 --- a/docker/apache/debian-9/conf/etc/httpd/conf.d/10-log.conf +++ b/docker/apache/debian-9/conf/etc/httpd/conf.d/10-log.conf @@ -1,4 +1,4 @@ LogFormat "[httpd:access] %V:%p %h %l %u %t \"%r\" %>s bytesIn:%I bytesOut:%O reqTime:%T" dockerlog LogLevel warn -CustomLog /proc/self/fd/1 dockerlog -ErrorLog /proc/self/fd/2 +CustomLog /docker.stdout dockerlog +ErrorLog /docker.stderr diff --git a/docker/apache/debian-9/conf/provision/roles/webdevops-apache/tasks/bootstrap.yml b/docker/apache/debian-9/conf/provision/roles/webdevops-apache/tasks/bootstrap.yml index 2be18b0e0..c285be286 100644 --- a/docker/apache/debian-9/conf/provision/roles/webdevops-apache/tasks/bootstrap.yml +++ b/docker/apache/debian-9/conf/provision/roles/webdevops-apache/tasks/bootstrap.yml @@ -84,7 +84,7 @@ with_items: - 'a2dismod mpm_event' - 'a2enmod mpm_event' - when: (ansible_distribution == 'Ubuntu' and ansible_lsb.major_release|int >= 14) or (ansible_distribution == 'Debian' and ansible_lsb.major_release|int >= 8) + when: (ansible_distribution == 'Ubuntu' and docker_image_info_distribution_version|int >= 14) or (ansible_distribution == 'Debian' and docker_image_info_distribution_version|int >= 8) - name: Manage modules [Alpine family] lineinfile: diff --git a/docker/apache/ubuntu-12.04/Dockerfile b/docker/apache/ubuntu-12.04/Dockerfile index e99f5e41d..f48e73fc3 100644 --- a/docker/apache/ubuntu-12.04/Dockerfile +++ b/docker/apache/ubuntu-12.04/Dockerfile @@ -5,14 +5,9 @@ FROM webdevops/base:ubuntu-12.04 -MAINTAINER info@webdevops.io -LABEL vendor=WebDevOps.io -LABEL io.webdevops.layout=8 -LABEL io.webdevops.version=1.5.0 - -ENV WEB_DOCUMENT_ROOT /app -ENV WEB_DOCUMENT_INDEX index.php -ENV WEB_ALIAS_DOMAIN *.vm +ENV WEB_DOCUMENT_ROOT=/app \ + WEB_DOCUMENT_INDEX=index.php \ + WEB_ALIAS_DOMAIN=*.vm COPY conf/ /opt/docker/ @@ -29,7 +24,7 @@ RUN /usr/local/bin/apt-install \ && a2enmod actions fastcgi ssl rewrite headers version expires \ && mkdir -p /var/lock/apache2 \ && /opt/docker/bin/provision run --tag bootstrap --role webdevops-apache \ - && /opt/docker/bin/bootstrap.sh - + && /opt/docker/bin/bootstrap.sh \ + && docker-image-cleanup EXPOSE 80 443 diff --git a/docker/apache/ubuntu-12.04/Dockerfile.jinja2 b/docker/apache/ubuntu-12.04/Dockerfile.jinja2 index 02866dc2d..e46ca3571 100644 --- a/docker/apache/ubuntu-12.04/Dockerfile.jinja2 +++ b/docker/apache/ubuntu-12.04/Dockerfile.jinja2 @@ -1,7 +1,5 @@ {{ docker.from("base", "ubuntu-12.04") }} -{{ docker.version() }} - {{ environment.web() }} {{ docker.copy('conf/', '/opt/docker/') }} diff --git a/docker/apache/ubuntu-12.04/conf/bin/service.d/httpd.d/10-init.sh b/docker/apache/ubuntu-12.04/conf/bin/service.d/httpd.d/10-init.sh index d3f1a0c9c..b9d57997e 100644 --- a/docker/apache/ubuntu-12.04/conf/bin/service.d/httpd.d/10-init.sh +++ b/docker/apache/ubuntu-12.04/conf/bin/service.d/httpd.d/10-init.sh @@ -5,15 +5,17 @@ if [[ ! -e "$WEB_DOCUMENT_ROOT" ]]; then fi # Replace markers -find /opt/docker/etc/httpd/ -iname '*.conf' -print0 | xargs -0 -r rpl --quiet "" "$WEB_DOCUMENT_INDEX" > /dev/null -find /opt/docker/etc/httpd/ -iname '*.conf' -print0 | xargs -0 -r rpl --quiet "" "$WEB_DOCUMENT_ROOT" > /dev/null -find /opt/docker/etc/httpd/ -iname '*.conf' -print0 | xargs -0 -r rpl --quiet "" "$WEB_ALIAS_DOMAIN" > /dev/null -find /opt/docker/etc/httpd/ -iname '*.conf' -print0 | xargs -0 -r rpl --quiet "" "$HOSTNAME" > /dev/null +go-replace \ + -s "" -r "$WEB_DOCUMENT_INDEX" \ + -s "" -r "$WEB_DOCUMENT_ROOT" \ + -s "" -r "$WEB_ALIAS_DOMAIN" \ + -s "" -r "$HOSTNAME" \ + -s "" -r "$WEB_PHP_SOCKET" \ + --path=/opt/docker/etc/httpd/ \ + --path-pattern='*.conf' \ + --ignore-empty -if [[ -n "${WEB_PHP_SOCKET+x}" ]]; then - ## WEB_PHP_SOCKET is set - find /opt/docker/etc/httpd/ -iname '*.conf' -print0 | xargs -0 -r rpl --quiet "" "$WEB_PHP_SOCKET" > /dev/null -else +if [[ -z "${WEB_PHP_SOCKET+x}" ]]; then ## WEB_PHP_SOCKET is not set, remove PHP files rm -f -- /opt/docker/etc/httpd/conf.d/10-php.conf fi diff --git a/docker/apache/ubuntu-12.04/conf/etc/httpd/conf.d/10-log.conf b/docker/apache/ubuntu-12.04/conf/etc/httpd/conf.d/10-log.conf index e4c4be4f2..ef0c73d38 100644 --- a/docker/apache/ubuntu-12.04/conf/etc/httpd/conf.d/10-log.conf +++ b/docker/apache/ubuntu-12.04/conf/etc/httpd/conf.d/10-log.conf @@ -1,4 +1,4 @@ LogFormat "[httpd:access] %V:%p %h %l %u %t \"%r\" %>s bytesIn:%I bytesOut:%O reqTime:%T" dockerlog LogLevel warn -CustomLog /proc/self/fd/1 dockerlog -ErrorLog /proc/self/fd/2 +CustomLog /docker.stdout dockerlog +ErrorLog /docker.stderr diff --git a/docker/apache/ubuntu-12.04/conf/provision/roles/webdevops-apache/tasks/bootstrap.yml b/docker/apache/ubuntu-12.04/conf/provision/roles/webdevops-apache/tasks/bootstrap.yml index 2be18b0e0..c285be286 100644 --- a/docker/apache/ubuntu-12.04/conf/provision/roles/webdevops-apache/tasks/bootstrap.yml +++ b/docker/apache/ubuntu-12.04/conf/provision/roles/webdevops-apache/tasks/bootstrap.yml @@ -84,7 +84,7 @@ with_items: - 'a2dismod mpm_event' - 'a2enmod mpm_event' - when: (ansible_distribution == 'Ubuntu' and ansible_lsb.major_release|int >= 14) or (ansible_distribution == 'Debian' and ansible_lsb.major_release|int >= 8) + when: (ansible_distribution == 'Ubuntu' and docker_image_info_distribution_version|int >= 14) or (ansible_distribution == 'Debian' and docker_image_info_distribution_version|int >= 8) - name: Manage modules [Alpine family] lineinfile: diff --git a/docker/apache/ubuntu-14.04/Dockerfile b/docker/apache/ubuntu-14.04/Dockerfile index 566642d62..240842b3a 100644 --- a/docker/apache/ubuntu-14.04/Dockerfile +++ b/docker/apache/ubuntu-14.04/Dockerfile @@ -5,14 +5,9 @@ FROM webdevops/base:ubuntu-14.04 -MAINTAINER info@webdevops.io -LABEL vendor=WebDevOps.io -LABEL io.webdevops.layout=8 -LABEL io.webdevops.version=1.5.0 - -ENV WEB_DOCUMENT_ROOT /app -ENV WEB_DOCUMENT_INDEX index.php -ENV WEB_ALIAS_DOMAIN *.vm +ENV WEB_DOCUMENT_ROOT=/app \ + WEB_DOCUMENT_INDEX=index.php \ + WEB_ALIAS_DOMAIN=*.vm COPY conf/ /opt/docker/ @@ -29,7 +24,7 @@ RUN /usr/local/bin/apt-install \ && a2enmod actions fastcgi ssl rewrite headers expires \ && mkdir -p /var/lock/apache2 \ && /opt/docker/bin/provision run --tag bootstrap --role webdevops-apache \ - && /opt/docker/bin/bootstrap.sh - + && /opt/docker/bin/bootstrap.sh \ + && docker-image-cleanup EXPOSE 80 443 diff --git a/docker/apache/ubuntu-14.04/Dockerfile.jinja2 b/docker/apache/ubuntu-14.04/Dockerfile.jinja2 index d72bf7c01..c1084f2f9 100644 --- a/docker/apache/ubuntu-14.04/Dockerfile.jinja2 +++ b/docker/apache/ubuntu-14.04/Dockerfile.jinja2 @@ -1,7 +1,5 @@ {{ docker.from("base", "ubuntu-14.04") }} -{{ docker.version() }} - {{ environment.web() }} {{ docker.copy('conf/', '/opt/docker/') }} diff --git a/docker/apache/ubuntu-14.04/conf/bin/service.d/httpd.d/10-init.sh b/docker/apache/ubuntu-14.04/conf/bin/service.d/httpd.d/10-init.sh index d3f1a0c9c..b9d57997e 100644 --- a/docker/apache/ubuntu-14.04/conf/bin/service.d/httpd.d/10-init.sh +++ b/docker/apache/ubuntu-14.04/conf/bin/service.d/httpd.d/10-init.sh @@ -5,15 +5,17 @@ if [[ ! -e "$WEB_DOCUMENT_ROOT" ]]; then fi # Replace markers -find /opt/docker/etc/httpd/ -iname '*.conf' -print0 | xargs -0 -r rpl --quiet "" "$WEB_DOCUMENT_INDEX" > /dev/null -find /opt/docker/etc/httpd/ -iname '*.conf' -print0 | xargs -0 -r rpl --quiet "" "$WEB_DOCUMENT_ROOT" > /dev/null -find /opt/docker/etc/httpd/ -iname '*.conf' -print0 | xargs -0 -r rpl --quiet "" "$WEB_ALIAS_DOMAIN" > /dev/null -find /opt/docker/etc/httpd/ -iname '*.conf' -print0 | xargs -0 -r rpl --quiet "" "$HOSTNAME" > /dev/null +go-replace \ + -s "" -r "$WEB_DOCUMENT_INDEX" \ + -s "" -r "$WEB_DOCUMENT_ROOT" \ + -s "" -r "$WEB_ALIAS_DOMAIN" \ + -s "" -r "$HOSTNAME" \ + -s "" -r "$WEB_PHP_SOCKET" \ + --path=/opt/docker/etc/httpd/ \ + --path-pattern='*.conf' \ + --ignore-empty -if [[ -n "${WEB_PHP_SOCKET+x}" ]]; then - ## WEB_PHP_SOCKET is set - find /opt/docker/etc/httpd/ -iname '*.conf' -print0 | xargs -0 -r rpl --quiet "" "$WEB_PHP_SOCKET" > /dev/null -else +if [[ -z "${WEB_PHP_SOCKET+x}" ]]; then ## WEB_PHP_SOCKET is not set, remove PHP files rm -f -- /opt/docker/etc/httpd/conf.d/10-php.conf fi diff --git a/docker/apache/ubuntu-14.04/conf/etc/httpd/conf.d/10-log.conf b/docker/apache/ubuntu-14.04/conf/etc/httpd/conf.d/10-log.conf index e4c4be4f2..ef0c73d38 100644 --- a/docker/apache/ubuntu-14.04/conf/etc/httpd/conf.d/10-log.conf +++ b/docker/apache/ubuntu-14.04/conf/etc/httpd/conf.d/10-log.conf @@ -1,4 +1,4 @@ LogFormat "[httpd:access] %V:%p %h %l %u %t \"%r\" %>s bytesIn:%I bytesOut:%O reqTime:%T" dockerlog LogLevel warn -CustomLog /proc/self/fd/1 dockerlog -ErrorLog /proc/self/fd/2 +CustomLog /docker.stdout dockerlog +ErrorLog /docker.stderr diff --git a/docker/apache/ubuntu-14.04/conf/provision/roles/webdevops-apache/tasks/bootstrap.yml b/docker/apache/ubuntu-14.04/conf/provision/roles/webdevops-apache/tasks/bootstrap.yml index 2be18b0e0..c285be286 100644 --- a/docker/apache/ubuntu-14.04/conf/provision/roles/webdevops-apache/tasks/bootstrap.yml +++ b/docker/apache/ubuntu-14.04/conf/provision/roles/webdevops-apache/tasks/bootstrap.yml @@ -84,7 +84,7 @@ with_items: - 'a2dismod mpm_event' - 'a2enmod mpm_event' - when: (ansible_distribution == 'Ubuntu' and ansible_lsb.major_release|int >= 14) or (ansible_distribution == 'Debian' and ansible_lsb.major_release|int >= 8) + when: (ansible_distribution == 'Ubuntu' and docker_image_info_distribution_version|int >= 14) or (ansible_distribution == 'Debian' and docker_image_info_distribution_version|int >= 8) - name: Manage modules [Alpine family] lineinfile: diff --git a/docker/apache/ubuntu-15.04/Dockerfile b/docker/apache/ubuntu-15.04/Dockerfile index 5c903a026..422a632be 100644 --- a/docker/apache/ubuntu-15.04/Dockerfile +++ b/docker/apache/ubuntu-15.04/Dockerfile @@ -5,14 +5,9 @@ FROM webdevops/base:ubuntu-15.04 -MAINTAINER info@webdevops.io -LABEL vendor=WebDevOps.io -LABEL io.webdevops.layout=8 -LABEL io.webdevops.version=1.5.0 - -ENV WEB_DOCUMENT_ROOT /app -ENV WEB_DOCUMENT_INDEX index.php -ENV WEB_ALIAS_DOMAIN *.vm +ENV WEB_DOCUMENT_ROOT=/app \ + WEB_DOCUMENT_INDEX=index.php \ + WEB_ALIAS_DOMAIN=*.vm COPY conf/ /opt/docker/ @@ -27,7 +22,7 @@ RUN /usr/local/bin/apt-install \ && ln -sf /opt/docker/etc/httpd/main.conf /etc/apache2/sites-enabled/10-docker.conf \ && a2enmod actions proxy proxy_fcgi ssl rewrite headers expires \ && /opt/docker/bin/provision run --tag bootstrap --role webdevops-apache \ - && /opt/docker/bin/bootstrap.sh - + && /opt/docker/bin/bootstrap.sh \ + && docker-image-cleanup EXPOSE 80 443 diff --git a/docker/apache/ubuntu-15.04/Dockerfile.jinja2 b/docker/apache/ubuntu-15.04/Dockerfile.jinja2 index 600c3a135..10c695cc7 100644 --- a/docker/apache/ubuntu-15.04/Dockerfile.jinja2 +++ b/docker/apache/ubuntu-15.04/Dockerfile.jinja2 @@ -1,7 +1,5 @@ {{ docker.from("base", "ubuntu-15.04") }} -{{ docker.version() }} - {{ environment.web() }} {{ docker.copy('conf/', '/opt/docker/') }} diff --git a/docker/apache/ubuntu-15.04/conf/bin/service.d/httpd.d/10-init.sh b/docker/apache/ubuntu-15.04/conf/bin/service.d/httpd.d/10-init.sh index d3f1a0c9c..b9d57997e 100644 --- a/docker/apache/ubuntu-15.04/conf/bin/service.d/httpd.d/10-init.sh +++ b/docker/apache/ubuntu-15.04/conf/bin/service.d/httpd.d/10-init.sh @@ -5,15 +5,17 @@ if [[ ! -e "$WEB_DOCUMENT_ROOT" ]]; then fi # Replace markers -find /opt/docker/etc/httpd/ -iname '*.conf' -print0 | xargs -0 -r rpl --quiet "" "$WEB_DOCUMENT_INDEX" > /dev/null -find /opt/docker/etc/httpd/ -iname '*.conf' -print0 | xargs -0 -r rpl --quiet "" "$WEB_DOCUMENT_ROOT" > /dev/null -find /opt/docker/etc/httpd/ -iname '*.conf' -print0 | xargs -0 -r rpl --quiet "" "$WEB_ALIAS_DOMAIN" > /dev/null -find /opt/docker/etc/httpd/ -iname '*.conf' -print0 | xargs -0 -r rpl --quiet "" "$HOSTNAME" > /dev/null +go-replace \ + -s "" -r "$WEB_DOCUMENT_INDEX" \ + -s "" -r "$WEB_DOCUMENT_ROOT" \ + -s "" -r "$WEB_ALIAS_DOMAIN" \ + -s "" -r "$HOSTNAME" \ + -s "" -r "$WEB_PHP_SOCKET" \ + --path=/opt/docker/etc/httpd/ \ + --path-pattern='*.conf' \ + --ignore-empty -if [[ -n "${WEB_PHP_SOCKET+x}" ]]; then - ## WEB_PHP_SOCKET is set - find /opt/docker/etc/httpd/ -iname '*.conf' -print0 | xargs -0 -r rpl --quiet "" "$WEB_PHP_SOCKET" > /dev/null -else +if [[ -z "${WEB_PHP_SOCKET+x}" ]]; then ## WEB_PHP_SOCKET is not set, remove PHP files rm -f -- /opt/docker/etc/httpd/conf.d/10-php.conf fi diff --git a/docker/apache/ubuntu-15.04/conf/etc/httpd/conf.d/10-log.conf b/docker/apache/ubuntu-15.04/conf/etc/httpd/conf.d/10-log.conf index e4c4be4f2..ef0c73d38 100644 --- a/docker/apache/ubuntu-15.04/conf/etc/httpd/conf.d/10-log.conf +++ b/docker/apache/ubuntu-15.04/conf/etc/httpd/conf.d/10-log.conf @@ -1,4 +1,4 @@ LogFormat "[httpd:access] %V:%p %h %l %u %t \"%r\" %>s bytesIn:%I bytesOut:%O reqTime:%T" dockerlog LogLevel warn -CustomLog /proc/self/fd/1 dockerlog -ErrorLog /proc/self/fd/2 +CustomLog /docker.stdout dockerlog +ErrorLog /docker.stderr diff --git a/docker/apache/ubuntu-15.04/conf/provision/roles/webdevops-apache/tasks/bootstrap.yml b/docker/apache/ubuntu-15.04/conf/provision/roles/webdevops-apache/tasks/bootstrap.yml index 2be18b0e0..c285be286 100644 --- a/docker/apache/ubuntu-15.04/conf/provision/roles/webdevops-apache/tasks/bootstrap.yml +++ b/docker/apache/ubuntu-15.04/conf/provision/roles/webdevops-apache/tasks/bootstrap.yml @@ -84,7 +84,7 @@ with_items: - 'a2dismod mpm_event' - 'a2enmod mpm_event' - when: (ansible_distribution == 'Ubuntu' and ansible_lsb.major_release|int >= 14) or (ansible_distribution == 'Debian' and ansible_lsb.major_release|int >= 8) + when: (ansible_distribution == 'Ubuntu' and docker_image_info_distribution_version|int >= 14) or (ansible_distribution == 'Debian' and docker_image_info_distribution_version|int >= 8) - name: Manage modules [Alpine family] lineinfile: diff --git a/docker/apache/ubuntu-15.10/Dockerfile b/docker/apache/ubuntu-15.10/Dockerfile index f29507207..d2b6478f7 100644 --- a/docker/apache/ubuntu-15.10/Dockerfile +++ b/docker/apache/ubuntu-15.10/Dockerfile @@ -5,14 +5,9 @@ FROM webdevops/base:ubuntu-15.10 -MAINTAINER info@webdevops.io -LABEL vendor=WebDevOps.io -LABEL io.webdevops.layout=8 -LABEL io.webdevops.version=1.5.0 - -ENV WEB_DOCUMENT_ROOT /app -ENV WEB_DOCUMENT_INDEX index.php -ENV WEB_ALIAS_DOMAIN *.vm +ENV WEB_DOCUMENT_ROOT=/app \ + WEB_DOCUMENT_INDEX=index.php \ + WEB_ALIAS_DOMAIN=*.vm COPY conf/ /opt/docker/ @@ -27,7 +22,7 @@ RUN /usr/local/bin/apt-install \ && ln -sf /opt/docker/etc/httpd/main.conf /etc/apache2/sites-enabled/10-docker.conf \ && a2enmod actions proxy proxy_fcgi ssl rewrite headers expires \ && /opt/docker/bin/provision run --tag bootstrap --role webdevops-apache \ - && /opt/docker/bin/bootstrap.sh - + && /opt/docker/bin/bootstrap.sh \ + && docker-image-cleanup EXPOSE 80 443 diff --git a/docker/apache/ubuntu-15.10/Dockerfile.jinja2 b/docker/apache/ubuntu-15.10/Dockerfile.jinja2 index 6b77e572c..3e1e4b43f 100644 --- a/docker/apache/ubuntu-15.10/Dockerfile.jinja2 +++ b/docker/apache/ubuntu-15.10/Dockerfile.jinja2 @@ -1,7 +1,5 @@ {{ docker.from("base", "ubuntu-15.10") }} -{{ docker.version() }} - {{ environment.web() }} {{ docker.copy('conf/', '/opt/docker/') }} diff --git a/docker/apache/ubuntu-15.10/conf/bin/service.d/httpd.d/10-init.sh b/docker/apache/ubuntu-15.10/conf/bin/service.d/httpd.d/10-init.sh index d3f1a0c9c..b9d57997e 100644 --- a/docker/apache/ubuntu-15.10/conf/bin/service.d/httpd.d/10-init.sh +++ b/docker/apache/ubuntu-15.10/conf/bin/service.d/httpd.d/10-init.sh @@ -5,15 +5,17 @@ if [[ ! -e "$WEB_DOCUMENT_ROOT" ]]; then fi # Replace markers -find /opt/docker/etc/httpd/ -iname '*.conf' -print0 | xargs -0 -r rpl --quiet "" "$WEB_DOCUMENT_INDEX" > /dev/null -find /opt/docker/etc/httpd/ -iname '*.conf' -print0 | xargs -0 -r rpl --quiet "" "$WEB_DOCUMENT_ROOT" > /dev/null -find /opt/docker/etc/httpd/ -iname '*.conf' -print0 | xargs -0 -r rpl --quiet "" "$WEB_ALIAS_DOMAIN" > /dev/null -find /opt/docker/etc/httpd/ -iname '*.conf' -print0 | xargs -0 -r rpl --quiet "" "$HOSTNAME" > /dev/null +go-replace \ + -s "" -r "$WEB_DOCUMENT_INDEX" \ + -s "" -r "$WEB_DOCUMENT_ROOT" \ + -s "" -r "$WEB_ALIAS_DOMAIN" \ + -s "" -r "$HOSTNAME" \ + -s "" -r "$WEB_PHP_SOCKET" \ + --path=/opt/docker/etc/httpd/ \ + --path-pattern='*.conf' \ + --ignore-empty -if [[ -n "${WEB_PHP_SOCKET+x}" ]]; then - ## WEB_PHP_SOCKET is set - find /opt/docker/etc/httpd/ -iname '*.conf' -print0 | xargs -0 -r rpl --quiet "" "$WEB_PHP_SOCKET" > /dev/null -else +if [[ -z "${WEB_PHP_SOCKET+x}" ]]; then ## WEB_PHP_SOCKET is not set, remove PHP files rm -f -- /opt/docker/etc/httpd/conf.d/10-php.conf fi diff --git a/docker/apache/ubuntu-15.10/conf/etc/httpd/conf.d/10-log.conf b/docker/apache/ubuntu-15.10/conf/etc/httpd/conf.d/10-log.conf index e4c4be4f2..ef0c73d38 100644 --- a/docker/apache/ubuntu-15.10/conf/etc/httpd/conf.d/10-log.conf +++ b/docker/apache/ubuntu-15.10/conf/etc/httpd/conf.d/10-log.conf @@ -1,4 +1,4 @@ LogFormat "[httpd:access] %V:%p %h %l %u %t \"%r\" %>s bytesIn:%I bytesOut:%O reqTime:%T" dockerlog LogLevel warn -CustomLog /proc/self/fd/1 dockerlog -ErrorLog /proc/self/fd/2 +CustomLog /docker.stdout dockerlog +ErrorLog /docker.stderr diff --git a/docker/apache/ubuntu-15.10/conf/provision/roles/webdevops-apache/tasks/bootstrap.yml b/docker/apache/ubuntu-15.10/conf/provision/roles/webdevops-apache/tasks/bootstrap.yml index 2be18b0e0..c285be286 100644 --- a/docker/apache/ubuntu-15.10/conf/provision/roles/webdevops-apache/tasks/bootstrap.yml +++ b/docker/apache/ubuntu-15.10/conf/provision/roles/webdevops-apache/tasks/bootstrap.yml @@ -84,7 +84,7 @@ with_items: - 'a2dismod mpm_event' - 'a2enmod mpm_event' - when: (ansible_distribution == 'Ubuntu' and ansible_lsb.major_release|int >= 14) or (ansible_distribution == 'Debian' and ansible_lsb.major_release|int >= 8) + when: (ansible_distribution == 'Ubuntu' and docker_image_info_distribution_version|int >= 14) or (ansible_distribution == 'Debian' and docker_image_info_distribution_version|int >= 8) - name: Manage modules [Alpine family] lineinfile: diff --git a/docker/apache/ubuntu-16.04/Dockerfile b/docker/apache/ubuntu-16.04/Dockerfile index 5e1ae400a..f23e859aa 100644 --- a/docker/apache/ubuntu-16.04/Dockerfile +++ b/docker/apache/ubuntu-16.04/Dockerfile @@ -5,14 +5,9 @@ FROM webdevops/base:ubuntu-16.04 -MAINTAINER info@webdevops.io -LABEL vendor=WebDevOps.io -LABEL io.webdevops.layout=8 -LABEL io.webdevops.version=1.5.0 - -ENV WEB_DOCUMENT_ROOT /app -ENV WEB_DOCUMENT_INDEX index.php -ENV WEB_ALIAS_DOMAIN *.vm +ENV WEB_DOCUMENT_ROOT=/app \ + WEB_DOCUMENT_INDEX=index.php \ + WEB_ALIAS_DOMAIN=*.vm COPY conf/ /opt/docker/ @@ -27,7 +22,7 @@ RUN /usr/local/bin/apt-install \ && ln -sf /opt/docker/etc/httpd/main.conf /etc/apache2/sites-enabled/10-docker.conf \ && a2enmod actions proxy proxy_fcgi ssl rewrite headers expires \ && /opt/docker/bin/provision run --tag bootstrap --role webdevops-apache \ - && /opt/docker/bin/bootstrap.sh - + && /opt/docker/bin/bootstrap.sh \ + && docker-image-cleanup EXPOSE 80 443 diff --git a/docker/apache/ubuntu-16.04/Dockerfile.jinja2 b/docker/apache/ubuntu-16.04/Dockerfile.jinja2 index 45da1db24..943bf8a5f 100644 --- a/docker/apache/ubuntu-16.04/Dockerfile.jinja2 +++ b/docker/apache/ubuntu-16.04/Dockerfile.jinja2 @@ -1,7 +1,5 @@ {{ docker.from("base", "ubuntu-16.04") }} -{{ docker.version() }} - {{ environment.web() }} {{ docker.copy('conf/', '/opt/docker/') }} diff --git a/docker/apache/ubuntu-16.04/conf/bin/service.d/httpd.d/10-init.sh b/docker/apache/ubuntu-16.04/conf/bin/service.d/httpd.d/10-init.sh index d3f1a0c9c..b9d57997e 100644 --- a/docker/apache/ubuntu-16.04/conf/bin/service.d/httpd.d/10-init.sh +++ b/docker/apache/ubuntu-16.04/conf/bin/service.d/httpd.d/10-init.sh @@ -5,15 +5,17 @@ if [[ ! -e "$WEB_DOCUMENT_ROOT" ]]; then fi # Replace markers -find /opt/docker/etc/httpd/ -iname '*.conf' -print0 | xargs -0 -r rpl --quiet "" "$WEB_DOCUMENT_INDEX" > /dev/null -find /opt/docker/etc/httpd/ -iname '*.conf' -print0 | xargs -0 -r rpl --quiet "" "$WEB_DOCUMENT_ROOT" > /dev/null -find /opt/docker/etc/httpd/ -iname '*.conf' -print0 | xargs -0 -r rpl --quiet "" "$WEB_ALIAS_DOMAIN" > /dev/null -find /opt/docker/etc/httpd/ -iname '*.conf' -print0 | xargs -0 -r rpl --quiet "" "$HOSTNAME" > /dev/null +go-replace \ + -s "" -r "$WEB_DOCUMENT_INDEX" \ + -s "" -r "$WEB_DOCUMENT_ROOT" \ + -s "" -r "$WEB_ALIAS_DOMAIN" \ + -s "" -r "$HOSTNAME" \ + -s "" -r "$WEB_PHP_SOCKET" \ + --path=/opt/docker/etc/httpd/ \ + --path-pattern='*.conf' \ + --ignore-empty -if [[ -n "${WEB_PHP_SOCKET+x}" ]]; then - ## WEB_PHP_SOCKET is set - find /opt/docker/etc/httpd/ -iname '*.conf' -print0 | xargs -0 -r rpl --quiet "" "$WEB_PHP_SOCKET" > /dev/null -else +if [[ -z "${WEB_PHP_SOCKET+x}" ]]; then ## WEB_PHP_SOCKET is not set, remove PHP files rm -f -- /opt/docker/etc/httpd/conf.d/10-php.conf fi diff --git a/docker/apache/ubuntu-16.04/conf/etc/httpd/conf.d/10-log.conf b/docker/apache/ubuntu-16.04/conf/etc/httpd/conf.d/10-log.conf index e4c4be4f2..ef0c73d38 100644 --- a/docker/apache/ubuntu-16.04/conf/etc/httpd/conf.d/10-log.conf +++ b/docker/apache/ubuntu-16.04/conf/etc/httpd/conf.d/10-log.conf @@ -1,4 +1,4 @@ LogFormat "[httpd:access] %V:%p %h %l %u %t \"%r\" %>s bytesIn:%I bytesOut:%O reqTime:%T" dockerlog LogLevel warn -CustomLog /proc/self/fd/1 dockerlog -ErrorLog /proc/self/fd/2 +CustomLog /docker.stdout dockerlog +ErrorLog /docker.stderr diff --git a/docker/apache/ubuntu-16.04/conf/provision/roles/webdevops-apache/tasks/bootstrap.yml b/docker/apache/ubuntu-16.04/conf/provision/roles/webdevops-apache/tasks/bootstrap.yml index 2be18b0e0..c285be286 100644 --- a/docker/apache/ubuntu-16.04/conf/provision/roles/webdevops-apache/tasks/bootstrap.yml +++ b/docker/apache/ubuntu-16.04/conf/provision/roles/webdevops-apache/tasks/bootstrap.yml @@ -84,7 +84,7 @@ with_items: - 'a2dismod mpm_event' - 'a2enmod mpm_event' - when: (ansible_distribution == 'Ubuntu' and ansible_lsb.major_release|int >= 14) or (ansible_distribution == 'Debian' and ansible_lsb.major_release|int >= 8) + when: (ansible_distribution == 'Ubuntu' and docker_image_info_distribution_version|int >= 14) or (ansible_distribution == 'Debian' and docker_image_info_distribution_version|int >= 8) - name: Manage modules [Alpine family] lineinfile: diff --git a/docker/apache/ubuntu-16.10/Dockerfile b/docker/apache/ubuntu-16.10/Dockerfile index b6633b428..c94a90d76 100644 --- a/docker/apache/ubuntu-16.10/Dockerfile +++ b/docker/apache/ubuntu-16.10/Dockerfile @@ -5,14 +5,9 @@ FROM webdevops/base:ubuntu-16.10 -MAINTAINER info@webdevops.io -LABEL vendor=WebDevOps.io -LABEL io.webdevops.layout=8 -LABEL io.webdevops.version=1.5.0 - -ENV WEB_DOCUMENT_ROOT /app -ENV WEB_DOCUMENT_INDEX index.php -ENV WEB_ALIAS_DOMAIN *.vm +ENV WEB_DOCUMENT_ROOT=/app \ + WEB_DOCUMENT_INDEX=index.php \ + WEB_ALIAS_DOMAIN=*.vm COPY conf/ /opt/docker/ @@ -27,7 +22,7 @@ RUN /usr/local/bin/apt-install \ && ln -sf /opt/docker/etc/httpd/main.conf /etc/apache2/sites-enabled/10-docker.conf \ && a2enmod actions proxy proxy_fcgi ssl rewrite headers expires \ && /opt/docker/bin/provision run --tag bootstrap --role webdevops-apache \ - && /opt/docker/bin/bootstrap.sh - + && /opt/docker/bin/bootstrap.sh \ + && docker-image-cleanup EXPOSE 80 443 diff --git a/docker/apache/ubuntu-16.10/Dockerfile.jinja2 b/docker/apache/ubuntu-16.10/Dockerfile.jinja2 index 524506fc6..72516f12a 100644 --- a/docker/apache/ubuntu-16.10/Dockerfile.jinja2 +++ b/docker/apache/ubuntu-16.10/Dockerfile.jinja2 @@ -1,7 +1,5 @@ {{ docker.from("base", "ubuntu-16.10") }} -{{ docker.version() }} - {{ environment.web() }} {{ docker.copy('conf/', '/opt/docker/') }} diff --git a/docker/apache/ubuntu-16.10/conf/bin/service.d/httpd.d/10-init.sh b/docker/apache/ubuntu-16.10/conf/bin/service.d/httpd.d/10-init.sh index d3f1a0c9c..b9d57997e 100644 --- a/docker/apache/ubuntu-16.10/conf/bin/service.d/httpd.d/10-init.sh +++ b/docker/apache/ubuntu-16.10/conf/bin/service.d/httpd.d/10-init.sh @@ -5,15 +5,17 @@ if [[ ! -e "$WEB_DOCUMENT_ROOT" ]]; then fi # Replace markers -find /opt/docker/etc/httpd/ -iname '*.conf' -print0 | xargs -0 -r rpl --quiet "" "$WEB_DOCUMENT_INDEX" > /dev/null -find /opt/docker/etc/httpd/ -iname '*.conf' -print0 | xargs -0 -r rpl --quiet "" "$WEB_DOCUMENT_ROOT" > /dev/null -find /opt/docker/etc/httpd/ -iname '*.conf' -print0 | xargs -0 -r rpl --quiet "" "$WEB_ALIAS_DOMAIN" > /dev/null -find /opt/docker/etc/httpd/ -iname '*.conf' -print0 | xargs -0 -r rpl --quiet "" "$HOSTNAME" > /dev/null +go-replace \ + -s "" -r "$WEB_DOCUMENT_INDEX" \ + -s "" -r "$WEB_DOCUMENT_ROOT" \ + -s "" -r "$WEB_ALIAS_DOMAIN" \ + -s "" -r "$HOSTNAME" \ + -s "" -r "$WEB_PHP_SOCKET" \ + --path=/opt/docker/etc/httpd/ \ + --path-pattern='*.conf' \ + --ignore-empty -if [[ -n "${WEB_PHP_SOCKET+x}" ]]; then - ## WEB_PHP_SOCKET is set - find /opt/docker/etc/httpd/ -iname '*.conf' -print0 | xargs -0 -r rpl --quiet "" "$WEB_PHP_SOCKET" > /dev/null -else +if [[ -z "${WEB_PHP_SOCKET+x}" ]]; then ## WEB_PHP_SOCKET is not set, remove PHP files rm -f -- /opt/docker/etc/httpd/conf.d/10-php.conf fi diff --git a/docker/apache/ubuntu-16.10/conf/etc/httpd/conf.d/10-log.conf b/docker/apache/ubuntu-16.10/conf/etc/httpd/conf.d/10-log.conf index e4c4be4f2..ef0c73d38 100644 --- a/docker/apache/ubuntu-16.10/conf/etc/httpd/conf.d/10-log.conf +++ b/docker/apache/ubuntu-16.10/conf/etc/httpd/conf.d/10-log.conf @@ -1,4 +1,4 @@ LogFormat "[httpd:access] %V:%p %h %l %u %t \"%r\" %>s bytesIn:%I bytesOut:%O reqTime:%T" dockerlog LogLevel warn -CustomLog /proc/self/fd/1 dockerlog -ErrorLog /proc/self/fd/2 +CustomLog /docker.stdout dockerlog +ErrorLog /docker.stderr diff --git a/docker/apache/ubuntu-16.10/conf/provision/roles/webdevops-apache/tasks/bootstrap.yml b/docker/apache/ubuntu-16.10/conf/provision/roles/webdevops-apache/tasks/bootstrap.yml index 2be18b0e0..c285be286 100644 --- a/docker/apache/ubuntu-16.10/conf/provision/roles/webdevops-apache/tasks/bootstrap.yml +++ b/docker/apache/ubuntu-16.10/conf/provision/roles/webdevops-apache/tasks/bootstrap.yml @@ -84,7 +84,7 @@ with_items: - 'a2dismod mpm_event' - 'a2enmod mpm_event' - when: (ansible_distribution == 'Ubuntu' and ansible_lsb.major_release|int >= 14) or (ansible_distribution == 'Debian' and ansible_lsb.major_release|int >= 8) + when: (ansible_distribution == 'Ubuntu' and docker_image_info_distribution_version|int >= 14) or (ansible_distribution == 'Debian' and docker_image_info_distribution_version|int >= 8) - name: Manage modules [Alpine family] lineinfile: diff --git a/docker/base-app/alpine-3 b/docker/base-app/alpine-3 new file mode 120000 index 000000000..0120374ca --- /dev/null +++ b/docker/base-app/alpine-3 @@ -0,0 +1 @@ +alpine \ No newline at end of file diff --git a/docker/base-app/alpine-3/Dockerfile b/docker/base-app/alpine-3/Dockerfile deleted file mode 100644 index 22be56586..000000000 --- a/docker/base-app/alpine-3/Dockerfile +++ /dev/null @@ -1,46 +0,0 @@ -#+++++++++++++++++++++++++++++++++++++++ -# Dockerfile for webdevops/base-app:alpine-3 -# -- automatically generated -- -#+++++++++++++++++++++++++++++++++++++++ - -FROM webdevops/base:alpine-3 - -MAINTAINER info@webdevops.io -LABEL vendor=WebDevOps.io -LABEL io.webdevops.layout=8 -LABEL io.webdevops.version=1.5.0 - -ENV APPLICATION_USER application -ENV APPLICATION_GROUP application -ENV APPLICATION_PATH /app -ENV APPLICATION_UID 1000 -ENV APPLICATION_GID 1000 - -COPY conf/ /opt/docker/ - -RUN /usr/local/bin/apk-install-edge shadow \ - && /usr/local/bin/apk-install \ - # Install services - openssh \ - mysql-client \ - sqlite \ - dnsmasq \ - postfix \ - # Install common tools - sudo \ - zip \ - unzip \ - bzip2 \ - wget \ - curl \ - net-tools \ - drill \ - ldns \ - openssh-client \ - rsync \ - git \ - nano \ - vim \ - && /opt/docker/bin/provision run --tag bootstrap --role webdevops-base-app \ - && /opt/docker/bin/bootstrap.sh - diff --git a/docker/base-app/alpine-3/Dockerfile.jinja2 b/docker/base-app/alpine-3/Dockerfile.jinja2 deleted file mode 100644 index 07b2464e3..000000000 --- a/docker/base-app/alpine-3/Dockerfile.jinja2 +++ /dev/null @@ -1,9 +0,0 @@ -{{ docker.from("base", "alpine-3") }} - -{{ docker.version() }} - -{{ environment.app() }} - -{{ docker.copy('conf/', '/opt/docker/') }} - -{{ baseapp.alpine() }} diff --git a/docker/base-app/alpine-3/conf/bin/service.d/postfix.d/10-init.sh b/docker/base-app/alpine-3/conf/bin/service.d/postfix.d/10-init.sh deleted file mode 100644 index 7a604874f..000000000 --- a/docker/base-app/alpine-3/conf/bin/service.d/postfix.d/10-init.sh +++ /dev/null @@ -1,24 +0,0 @@ -# force new copy of hosts there (otherwise links could be outdated) -mkdir -p /var/spool/postfix/etc -cp -f /etc/hosts /var/spool/postfix/etc/hosts -cp -f /etc/resolv.conf /var/spool/postfix/etc/resolv.conf -cp -f /etc/services /var/spool/postfix/etc/services - -## MYHOSTNAME -# replace line -sed -i '/myhostname[ ]* =/c\' main.cf -echo "myhostname = $(hostname)" >> /etc/postfix/main.cf - -## REPLAYHOST -if [[ -n "${POSTFIX_RELAYHOST+x}" ]]; then - # replace line - sed -i '/relayhost[ ]* =/c\' main.cf - echo "relayhost = $POSTFIX_RELAYHOST" >> /etc/postfix/main.cf -fi - -## MYNETWORKS -if [[ -n "${POSTFIX_MYNETWORKS+x}" ]]; then - # replace line - sed -i '/mynetworks[ ]* =/c\' main.cf - echo "mynetworks = $POSTFIX_MYNETWORKS" >> /etc/postfix/main.cf -fi diff --git a/docker/base-app/alpine-3/conf/bin/service.d/ssh.d/10-init.sh b/docker/base-app/alpine-3/conf/bin/service.d/ssh.d/10-init.sh deleted file mode 100644 index e3192fe01..000000000 --- a/docker/base-app/alpine-3/conf/bin/service.d/ssh.d/10-init.sh +++ /dev/null @@ -1,2 +0,0 @@ -# generate host keys -ssh-keygen -A diff --git a/docker/base-app/alpine-3/conf/etc/supervisor.d/dnsmasq.conf b/docker/base-app/alpine-3/conf/etc/supervisor.d/dnsmasq.conf deleted file mode 100644 index a0ad2de88..000000000 --- a/docker/base-app/alpine-3/conf/etc/supervisor.d/dnsmasq.conf +++ /dev/null @@ -1,14 +0,0 @@ -[group:dnsmasq] -programs=dnsmasqd -priority=15 - -[program:dnsmasqd] -command = /opt/docker/bin/service.d/dnsmasq.sh -process_name=%(program_name)s -startsecs = 0 -autostart = true -autorestart = true -stdout_logfile=/dev/stdout -stdout_logfile_maxbytes=0 -stderr_logfile=/dev/stderr -stderr_logfile_maxbytes=0 diff --git a/docker/base-app/alpine-3/conf/provision/roles/webdevops-base-app/tasks/bootstrap.yml b/docker/base-app/alpine-3/conf/provision/roles/webdevops-base-app/tasks/bootstrap.yml deleted file mode 100644 index ea9e54682..000000000 --- a/docker/base-app/alpine-3/conf/provision/roles/webdevops-base-app/tasks/bootstrap.yml +++ /dev/null @@ -1,7 +0,0 @@ ---- - -- include: bootstrap/user.yml -- include: bootstrap/application.yml -- include: bootstrap/dnsmasq.yml -- include: bootstrap/postfix.yml -- include: bootstrap/ssh.yml diff --git a/docker/base-app/alpine-3/conf/provision/roles/webdevops-base-app/tasks/bootstrap/dnsmasq.yml b/docker/base-app/alpine-3/conf/provision/roles/webdevops-base-app/tasks/bootstrap/dnsmasq.yml deleted file mode 100644 index 962a7953a..000000000 --- a/docker/base-app/alpine-3/conf/provision/roles/webdevops-base-app/tasks/bootstrap/dnsmasq.yml +++ /dev/null @@ -1,10 +0,0 @@ ---- - -- name: Configure dnsmasq - lineinfile: - dest: /etc/dnsmasq.conf - regexp: '^[\s]*{{ item.key }}[\s]*=' - line: '{{ item.key }}={{ item.value }}' - with_items: - - { key: 'user', value: 'root' } - - { key: 'conf-dir', value: '/etc/dnsmasq.d' } diff --git a/docker/base-app/alpine-3/conf/provision/roles/webdevops-base-app/tasks/bootstrap/postfix.yml b/docker/base-app/alpine-3/conf/provision/roles/webdevops-base-app/tasks/bootstrap/postfix.yml deleted file mode 100644 index f05ff660c..000000000 --- a/docker/base-app/alpine-3/conf/provision/roles/webdevops-base-app/tasks/bootstrap/postfix.yml +++ /dev/null @@ -1,29 +0,0 @@ ---- - -- name: Link aliases file to postfix aliases - file: - src: '/etc/postfix/aliases' - dest: '/etc/aliases' - state: link - force: yes - when: ansible_os_family == 'Alpine' - -- name: Configure postfix - lineinfile: - dest: /etc/postfix/main.cf - regexp: '^[\s]*{{ item.key }}[\s]*=' - line: '{{ item.key }}={{ item.value }}' - with_items: - - { key: 'mydestination', value: '' } - - { key: 'message_size_limit', value: '15240000' } - # Hardening - - { key: 'smtp_use_tls', value: 'yes' } - - { key: 'smtp_tls_security_level', value: 'may' } - -- name: Remove dynamic configuration for postfix - lineinfile: - dest: /etc/postfix/main.cf - regexp: '^[\s]*{{ item }}[\s]*=' - state: absent - with_items: - - 'myhostname' diff --git a/docker/base-app/alpine-3/conf/provision/roles/webdevops-base-app/tasks/bootstrap/ssh.yml b/docker/base-app/alpine-3/conf/provision/roles/webdevops-base-app/tasks/bootstrap/ssh.yml deleted file mode 100644 index a69c72633..000000000 --- a/docker/base-app/alpine-3/conf/provision/roles/webdevops-base-app/tasks/bootstrap/ssh.yml +++ /dev/null @@ -1,12 +0,0 @@ ---- - -- name: Init ssh privilege separation directory - file: - path: "/var/run/sshd" - state: directory - mode: 0755 - owner: "root" - group: "root" - recurse: yes - - diff --git a/docker/base-app/alpine-3/conf/provision/roles/webdevops-base-app/tasks/bootstrap/user.yml b/docker/base-app/alpine-3/conf/provision/roles/webdevops-base-app/tasks/bootstrap/user.yml deleted file mode 100644 index cf6968a01..000000000 --- a/docker/base-app/alpine-3/conf/provision/roles/webdevops-base-app/tasks/bootstrap/user.yml +++ /dev/null @@ -1,41 +0,0 @@ ---- - -- name: Move dnsmasq group (Alpine family) - group: - name: dnsmasq - gid: 153 - when: ansible_distribution == 'Alpine' - -- name: Create application group - group: - name: "{{ APPLICATION_GROUP }}" - gid: "{{ APPLICATION_GID }}" - -- name: Create application user - user: - name: "{{ APPLICATION_USER }}" - uid: "{{ APPLICATION_UID }}" - group: "{{ APPLICATION_GROUP }}" - shell: "/bin/bash" - home: "/home/{{ APPLICATION_USER }}" - -- name: Init home directory - file: - path: "/home/{{ APPLICATION_USER }}" - state: directory - mode: 0755 - owner: "{{ APPLICATION_USER }}" - group: "{{ APPLICATION_GROUP }}" - recurse: yes - -- name: Init bashrc - lineinfile: - dest: "/home/{{ APPLICATION_USER }}/.bashrc" - mode: 0770 - owner: "{{ APPLICATION_USER }}" - group: "{{ APPLICATION_GROUP }}" - create: yes - regexp: "export TERM=xterm" - line: "export TERM=xterm" - -- action: setup diff --git a/docker/base-app/alpine/Dockerfile b/docker/base-app/alpine/Dockerfile new file mode 100644 index 000000000..3339af9e4 --- /dev/null +++ b/docker/base-app/alpine/Dockerfile @@ -0,0 +1,32 @@ +#+++++++++++++++++++++++++++++++++++++++ +# Dockerfile for webdevops/base-app:alpine +# -- automatically generated -- +#+++++++++++++++++++++++++++++++++++++++ + +FROM webdevops/base:alpine + +ENV APPLICATION_USER=application \ + APPLICATION_GROUP=application \ + APPLICATION_PATH=/app \ + APPLICATION_UID=1000 \ + APPLICATION_GID=1000 + +COPY conf/ /opt/docker/ + +RUN /usr/local/bin/apk-install-edge shadow \ + && /usr/local/bin/apk-install \ + # Install common tools + zip \ + unzip \ + bzip2 \ + wget \ + curl \ + net-tools \ + drill \ + ldns \ + openssh-client \ + rsync \ + git \ + && /opt/docker/bin/provision run --tag bootstrap --role webdevops-base-app \ + && /opt/docker/bin/bootstrap.sh \ + && docker-image-cleanup diff --git a/docker/base-app/alpine/Dockerfile.jinja2 b/docker/base-app/alpine/Dockerfile.jinja2 new file mode 100644 index 000000000..a96521ef7 --- /dev/null +++ b/docker/base-app/alpine/Dockerfile.jinja2 @@ -0,0 +1,7 @@ +{{ docker.from("base", "alpine") }} + +{{ environment.baseApp() }} + +{{ docker.copy('conf/', '/opt/docker/') }} + +{{ baseapp.alpine() }} diff --git a/docker/base-app/alpine-3/conf/provision/onbuild.d/.gitkeep b/docker/base-app/alpine/conf/provision/onbuild.d/.gitkeep similarity index 100% rename from docker/base-app/alpine-3/conf/provision/onbuild.d/.gitkeep rename to docker/base-app/alpine/conf/provision/onbuild.d/.gitkeep diff --git a/docker/base-app/alpine-3/conf/provision/roles/webdevops-base-app/defaults/main.yml b/docker/base-app/alpine/conf/provision/roles/webdevops-base-app/defaults/main.yml similarity index 100% rename from docker/base-app/alpine-3/conf/provision/roles/webdevops-base-app/defaults/main.yml rename to docker/base-app/alpine/conf/provision/roles/webdevops-base-app/defaults/main.yml diff --git a/docker/base-app/alpine/conf/provision/roles/webdevops-base-app/tasks/bootstrap.yml b/docker/base-app/alpine/conf/provision/roles/webdevops-base-app/tasks/bootstrap.yml new file mode 100644 index 000000000..3fdce9a74 --- /dev/null +++ b/docker/base-app/alpine/conf/provision/roles/webdevops-base-app/tasks/bootstrap.yml @@ -0,0 +1,4 @@ +--- + +- include: bootstrap/user.yml +- include: bootstrap/application.yml diff --git a/docker/base-app/alpine-3/conf/provision/roles/webdevops-base-app/tasks/bootstrap/application.yml b/docker/base-app/alpine/conf/provision/roles/webdevops-base-app/tasks/bootstrap/application.yml similarity index 100% rename from docker/base-app/alpine-3/conf/provision/roles/webdevops-base-app/tasks/bootstrap/application.yml rename to docker/base-app/alpine/conf/provision/roles/webdevops-base-app/tasks/bootstrap/application.yml diff --git a/docker/base-app/alpine/conf/provision/roles/webdevops-base-app/tasks/bootstrap/user.yml b/docker/base-app/alpine/conf/provision/roles/webdevops-base-app/tasks/bootstrap/user.yml new file mode 100644 index 000000000..fd58b329f --- /dev/null +++ b/docker/base-app/alpine/conf/provision/roles/webdevops-base-app/tasks/bootstrap/user.yml @@ -0,0 +1,35 @@ +--- + +- name: Create application group + group: + name: "{{ APPLICATION_GROUP }}" + gid: "{{ APPLICATION_GID }}" + +- name: Create application user + user: + name: "{{ APPLICATION_USER }}" + uid: "{{ APPLICATION_UID }}" + group: "{{ APPLICATION_GROUP }}" + shell: "/bin/bash" + home: "/home/{{ APPLICATION_USER }}" + +- name: Init home directory + file: + path: "/home/{{ APPLICATION_USER }}" + state: directory + mode: 0755 + owner: "{{ APPLICATION_USER }}" + group: "{{ APPLICATION_GROUP }}" + recurse: yes + +- name: Init bashrc + lineinfile: + dest: "/home/{{ APPLICATION_USER }}/.bashrc" + mode: 0770 + owner: "{{ APPLICATION_USER }}" + group: "{{ APPLICATION_GROUP }}" + create: yes + regexp: "export TERM=xterm" + line: "export TERM=xterm" + +- action: setup diff --git a/docker/base-app/alpine-3/conf/provision/roles/webdevops-base-app/tasks/main.yml b/docker/base-app/alpine/conf/provision/roles/webdevops-base-app/tasks/main.yml similarity index 100% rename from docker/base-app/alpine-3/conf/provision/roles/webdevops-base-app/tasks/main.yml rename to docker/base-app/alpine/conf/provision/roles/webdevops-base-app/tasks/main.yml diff --git a/docker/base-app/centos-7/Dockerfile b/docker/base-app/centos-7/Dockerfile index d3823f398..172d3d521 100644 --- a/docker/base-app/centos-7/Dockerfile +++ b/docker/base-app/centos-7/Dockerfile @@ -5,28 +5,17 @@ FROM webdevops/base:centos-7 -MAINTAINER info@webdevops.io -LABEL vendor=WebDevOps.io -LABEL io.webdevops.layout=8 -LABEL io.webdevops.version=1.5.0 - -ENV APPLICATION_USER application -ENV APPLICATION_GROUP application -ENV APPLICATION_PATH /app -ENV APPLICATION_UID 1000 -ENV APPLICATION_GID 1000 +ENV APPLICATION_USER=application \ + APPLICATION_GROUP=application \ + APPLICATION_PATH=/app \ + APPLICATION_UID=1000 \ + APPLICATION_GID=1000 COPY conf/ /opt/docker/ # Install services RUN /usr/local/bin/yum-install \ - openssh-server \ - mysql \ - sqlite \ - dnsmasq \ - postfix \ # Install tools - sudo \ zip \ unzip \ bzip2 \ @@ -39,9 +28,7 @@ RUN /usr/local/bin/yum-install \ rsync \ git \ pygpgme \ - nano \ - vim \ && /usr/local/bin/generate-locales \ && /opt/docker/bin/provision run --tag bootstrap --role webdevops-base-app \ - && /opt/docker/bin/bootstrap.sh - + && /opt/docker/bin/bootstrap.sh \ + && docker-image-cleanup diff --git a/docker/base-app/centos-7/Dockerfile.jinja2 b/docker/base-app/centos-7/Dockerfile.jinja2 index 8dc4762a5..5e982fab5 100644 --- a/docker/base-app/centos-7/Dockerfile.jinja2 +++ b/docker/base-app/centos-7/Dockerfile.jinja2 @@ -1,8 +1,6 @@ {{ docker.from("base", "centos-7") }} -{{ docker.version() }} - -{{ environment.app() }} +{{ environment.baseApp() }} {{ docker.copy('conf/', '/opt/docker/') }} diff --git a/docker/base-app/centos-7/conf/bin/service.d/postfix.d/10-init.sh b/docker/base-app/centos-7/conf/bin/service.d/postfix.d/10-init.sh deleted file mode 100644 index 7a604874f..000000000 --- a/docker/base-app/centos-7/conf/bin/service.d/postfix.d/10-init.sh +++ /dev/null @@ -1,24 +0,0 @@ -# force new copy of hosts there (otherwise links could be outdated) -mkdir -p /var/spool/postfix/etc -cp -f /etc/hosts /var/spool/postfix/etc/hosts -cp -f /etc/resolv.conf /var/spool/postfix/etc/resolv.conf -cp -f /etc/services /var/spool/postfix/etc/services - -## MYHOSTNAME -# replace line -sed -i '/myhostname[ ]* =/c\' main.cf -echo "myhostname = $(hostname)" >> /etc/postfix/main.cf - -## REPLAYHOST -if [[ -n "${POSTFIX_RELAYHOST+x}" ]]; then - # replace line - sed -i '/relayhost[ ]* =/c\' main.cf - echo "relayhost = $POSTFIX_RELAYHOST" >> /etc/postfix/main.cf -fi - -## MYNETWORKS -if [[ -n "${POSTFIX_MYNETWORKS+x}" ]]; then - # replace line - sed -i '/mynetworks[ ]* =/c\' main.cf - echo "mynetworks = $POSTFIX_MYNETWORKS" >> /etc/postfix/main.cf -fi diff --git a/docker/base-app/centos-7/conf/bin/service.d/ssh.d/10-init.sh b/docker/base-app/centos-7/conf/bin/service.d/ssh.d/10-init.sh deleted file mode 100644 index e3192fe01..000000000 --- a/docker/base-app/centos-7/conf/bin/service.d/ssh.d/10-init.sh +++ /dev/null @@ -1,2 +0,0 @@ -# generate host keys -ssh-keygen -A diff --git a/docker/base-app/centos-7/conf/etc/supervisor.d/dnsmasq.conf b/docker/base-app/centos-7/conf/etc/supervisor.d/dnsmasq.conf deleted file mode 100644 index a0ad2de88..000000000 --- a/docker/base-app/centos-7/conf/etc/supervisor.d/dnsmasq.conf +++ /dev/null @@ -1,14 +0,0 @@ -[group:dnsmasq] -programs=dnsmasqd -priority=15 - -[program:dnsmasqd] -command = /opt/docker/bin/service.d/dnsmasq.sh -process_name=%(program_name)s -startsecs = 0 -autostart = true -autorestart = true -stdout_logfile=/dev/stdout -stdout_logfile_maxbytes=0 -stderr_logfile=/dev/stderr -stderr_logfile_maxbytes=0 diff --git a/docker/base-app/centos-7/conf/provision/roles/webdevops-base-app/tasks/bootstrap.yml b/docker/base-app/centos-7/conf/provision/roles/webdevops-base-app/tasks/bootstrap.yml index ea9e54682..3fdce9a74 100644 --- a/docker/base-app/centos-7/conf/provision/roles/webdevops-base-app/tasks/bootstrap.yml +++ b/docker/base-app/centos-7/conf/provision/roles/webdevops-base-app/tasks/bootstrap.yml @@ -2,6 +2,3 @@ - include: bootstrap/user.yml - include: bootstrap/application.yml -- include: bootstrap/dnsmasq.yml -- include: bootstrap/postfix.yml -- include: bootstrap/ssh.yml diff --git a/docker/base-app/centos-7/conf/provision/roles/webdevops-base-app/tasks/bootstrap/dnsmasq.yml b/docker/base-app/centos-7/conf/provision/roles/webdevops-base-app/tasks/bootstrap/dnsmasq.yml deleted file mode 100644 index 962a7953a..000000000 --- a/docker/base-app/centos-7/conf/provision/roles/webdevops-base-app/tasks/bootstrap/dnsmasq.yml +++ /dev/null @@ -1,10 +0,0 @@ ---- - -- name: Configure dnsmasq - lineinfile: - dest: /etc/dnsmasq.conf - regexp: '^[\s]*{{ item.key }}[\s]*=' - line: '{{ item.key }}={{ item.value }}' - with_items: - - { key: 'user', value: 'root' } - - { key: 'conf-dir', value: '/etc/dnsmasq.d' } diff --git a/docker/base-app/centos-7/conf/provision/roles/webdevops-base-app/tasks/bootstrap/postfix.yml b/docker/base-app/centos-7/conf/provision/roles/webdevops-base-app/tasks/bootstrap/postfix.yml deleted file mode 100644 index f05ff660c..000000000 --- a/docker/base-app/centos-7/conf/provision/roles/webdevops-base-app/tasks/bootstrap/postfix.yml +++ /dev/null @@ -1,29 +0,0 @@ ---- - -- name: Link aliases file to postfix aliases - file: - src: '/etc/postfix/aliases' - dest: '/etc/aliases' - state: link - force: yes - when: ansible_os_family == 'Alpine' - -- name: Configure postfix - lineinfile: - dest: /etc/postfix/main.cf - regexp: '^[\s]*{{ item.key }}[\s]*=' - line: '{{ item.key }}={{ item.value }}' - with_items: - - { key: 'mydestination', value: '' } - - { key: 'message_size_limit', value: '15240000' } - # Hardening - - { key: 'smtp_use_tls', value: 'yes' } - - { key: 'smtp_tls_security_level', value: 'may' } - -- name: Remove dynamic configuration for postfix - lineinfile: - dest: /etc/postfix/main.cf - regexp: '^[\s]*{{ item }}[\s]*=' - state: absent - with_items: - - 'myhostname' diff --git a/docker/base-app/centos-7/conf/provision/roles/webdevops-base-app/tasks/bootstrap/ssh.yml b/docker/base-app/centos-7/conf/provision/roles/webdevops-base-app/tasks/bootstrap/ssh.yml deleted file mode 100644 index a69c72633..000000000 --- a/docker/base-app/centos-7/conf/provision/roles/webdevops-base-app/tasks/bootstrap/ssh.yml +++ /dev/null @@ -1,12 +0,0 @@ ---- - -- name: Init ssh privilege separation directory - file: - path: "/var/run/sshd" - state: directory - mode: 0755 - owner: "root" - group: "root" - recurse: yes - - diff --git a/docker/base-app/centos-7/conf/provision/roles/webdevops-base-app/tasks/bootstrap/user.yml b/docker/base-app/centos-7/conf/provision/roles/webdevops-base-app/tasks/bootstrap/user.yml index cf6968a01..fd58b329f 100644 --- a/docker/base-app/centos-7/conf/provision/roles/webdevops-base-app/tasks/bootstrap/user.yml +++ b/docker/base-app/centos-7/conf/provision/roles/webdevops-base-app/tasks/bootstrap/user.yml @@ -1,11 +1,5 @@ --- -- name: Move dnsmasq group (Alpine family) - group: - name: dnsmasq - gid: 153 - when: ansible_distribution == 'Alpine' - - name: Create application group group: name: "{{ APPLICATION_GROUP }}" diff --git a/docker/base-app/debian-7/Dockerfile b/docker/base-app/debian-7/Dockerfile index 81a1d9dbc..7f5fc64f3 100644 --- a/docker/base-app/debian-7/Dockerfile +++ b/docker/base-app/debian-7/Dockerfile @@ -5,29 +5,17 @@ FROM webdevops/base:debian-7 -MAINTAINER info@webdevops.io -LABEL vendor=WebDevOps.io -LABEL io.webdevops.layout=8 -LABEL io.webdevops.version=1.5.0 - -ENV APPLICATION_USER application -ENV APPLICATION_GROUP application -ENV APPLICATION_PATH /app -ENV APPLICATION_UID 1000 -ENV APPLICATION_GID 1000 +ENV APPLICATION_USER=application \ + APPLICATION_GROUP=application \ + APPLICATION_PATH=/app \ + APPLICATION_UID=1000 \ + APPLICATION_GID=1000 COPY conf/ /opt/docker/ # Install services RUN /usr/local/bin/apt-install \ - # Install services - openssh-server \ - mysql-client \ - sqlite \ - dnsmasq \ - postfix \ # Install common tools - sudo \ zip \ unzip \ bzip2 \ @@ -39,9 +27,7 @@ RUN /usr/local/bin/apt-install \ openssh-client \ rsync \ git \ - nano \ - vim \ && /usr/local/bin/generate-locales \ && /opt/docker/bin/provision run --tag bootstrap --role webdevops-base-app \ - && /opt/docker/bin/bootstrap.sh - + && /opt/docker/bin/bootstrap.sh \ + && docker-image-cleanup diff --git a/docker/base-app/debian-7/Dockerfile.jinja2 b/docker/base-app/debian-7/Dockerfile.jinja2 index 495bfb1de..953db323a 100644 --- a/docker/base-app/debian-7/Dockerfile.jinja2 +++ b/docker/base-app/debian-7/Dockerfile.jinja2 @@ -1,8 +1,6 @@ {{ docker.from("base", "debian-7") }} -{{ docker.version() }} - -{{ environment.app() }} +{{ environment.baseApp() }} {{ docker.copy('conf/', '/opt/docker/') }} diff --git a/docker/base-app/debian-7/conf/bin/service.d/postfix.d/10-init.sh b/docker/base-app/debian-7/conf/bin/service.d/postfix.d/10-init.sh deleted file mode 100644 index 7a604874f..000000000 --- a/docker/base-app/debian-7/conf/bin/service.d/postfix.d/10-init.sh +++ /dev/null @@ -1,24 +0,0 @@ -# force new copy of hosts there (otherwise links could be outdated) -mkdir -p /var/spool/postfix/etc -cp -f /etc/hosts /var/spool/postfix/etc/hosts -cp -f /etc/resolv.conf /var/spool/postfix/etc/resolv.conf -cp -f /etc/services /var/spool/postfix/etc/services - -## MYHOSTNAME -# replace line -sed -i '/myhostname[ ]* =/c\' main.cf -echo "myhostname = $(hostname)" >> /etc/postfix/main.cf - -## REPLAYHOST -if [[ -n "${POSTFIX_RELAYHOST+x}" ]]; then - # replace line - sed -i '/relayhost[ ]* =/c\' main.cf - echo "relayhost = $POSTFIX_RELAYHOST" >> /etc/postfix/main.cf -fi - -## MYNETWORKS -if [[ -n "${POSTFIX_MYNETWORKS+x}" ]]; then - # replace line - sed -i '/mynetworks[ ]* =/c\' main.cf - echo "mynetworks = $POSTFIX_MYNETWORKS" >> /etc/postfix/main.cf -fi diff --git a/docker/base-app/debian-7/conf/bin/service.d/ssh.d/10-init.sh b/docker/base-app/debian-7/conf/bin/service.d/ssh.d/10-init.sh deleted file mode 100644 index e3192fe01..000000000 --- a/docker/base-app/debian-7/conf/bin/service.d/ssh.d/10-init.sh +++ /dev/null @@ -1,2 +0,0 @@ -# generate host keys -ssh-keygen -A diff --git a/docker/base-app/debian-7/conf/etc/supervisor.d/dnsmasq.conf b/docker/base-app/debian-7/conf/etc/supervisor.d/dnsmasq.conf deleted file mode 100644 index a0ad2de88..000000000 --- a/docker/base-app/debian-7/conf/etc/supervisor.d/dnsmasq.conf +++ /dev/null @@ -1,14 +0,0 @@ -[group:dnsmasq] -programs=dnsmasqd -priority=15 - -[program:dnsmasqd] -command = /opt/docker/bin/service.d/dnsmasq.sh -process_name=%(program_name)s -startsecs = 0 -autostart = true -autorestart = true -stdout_logfile=/dev/stdout -stdout_logfile_maxbytes=0 -stderr_logfile=/dev/stderr -stderr_logfile_maxbytes=0 diff --git a/docker/base-app/debian-7/conf/provision/roles/webdevops-base-app/tasks/bootstrap.yml b/docker/base-app/debian-7/conf/provision/roles/webdevops-base-app/tasks/bootstrap.yml index ea9e54682..3fdce9a74 100644 --- a/docker/base-app/debian-7/conf/provision/roles/webdevops-base-app/tasks/bootstrap.yml +++ b/docker/base-app/debian-7/conf/provision/roles/webdevops-base-app/tasks/bootstrap.yml @@ -2,6 +2,3 @@ - include: bootstrap/user.yml - include: bootstrap/application.yml -- include: bootstrap/dnsmasq.yml -- include: bootstrap/postfix.yml -- include: bootstrap/ssh.yml diff --git a/docker/base-app/debian-7/conf/provision/roles/webdevops-base-app/tasks/bootstrap/dnsmasq.yml b/docker/base-app/debian-7/conf/provision/roles/webdevops-base-app/tasks/bootstrap/dnsmasq.yml deleted file mode 100644 index 962a7953a..000000000 --- a/docker/base-app/debian-7/conf/provision/roles/webdevops-base-app/tasks/bootstrap/dnsmasq.yml +++ /dev/null @@ -1,10 +0,0 @@ ---- - -- name: Configure dnsmasq - lineinfile: - dest: /etc/dnsmasq.conf - regexp: '^[\s]*{{ item.key }}[\s]*=' - line: '{{ item.key }}={{ item.value }}' - with_items: - - { key: 'user', value: 'root' } - - { key: 'conf-dir', value: '/etc/dnsmasq.d' } diff --git a/docker/base-app/debian-7/conf/provision/roles/webdevops-base-app/tasks/bootstrap/postfix.yml b/docker/base-app/debian-7/conf/provision/roles/webdevops-base-app/tasks/bootstrap/postfix.yml deleted file mode 100644 index f05ff660c..000000000 --- a/docker/base-app/debian-7/conf/provision/roles/webdevops-base-app/tasks/bootstrap/postfix.yml +++ /dev/null @@ -1,29 +0,0 @@ ---- - -- name: Link aliases file to postfix aliases - file: - src: '/etc/postfix/aliases' - dest: '/etc/aliases' - state: link - force: yes - when: ansible_os_family == 'Alpine' - -- name: Configure postfix - lineinfile: - dest: /etc/postfix/main.cf - regexp: '^[\s]*{{ item.key }}[\s]*=' - line: '{{ item.key }}={{ item.value }}' - with_items: - - { key: 'mydestination', value: '' } - - { key: 'message_size_limit', value: '15240000' } - # Hardening - - { key: 'smtp_use_tls', value: 'yes' } - - { key: 'smtp_tls_security_level', value: 'may' } - -- name: Remove dynamic configuration for postfix - lineinfile: - dest: /etc/postfix/main.cf - regexp: '^[\s]*{{ item }}[\s]*=' - state: absent - with_items: - - 'myhostname' diff --git a/docker/base-app/debian-7/conf/provision/roles/webdevops-base-app/tasks/bootstrap/ssh.yml b/docker/base-app/debian-7/conf/provision/roles/webdevops-base-app/tasks/bootstrap/ssh.yml deleted file mode 100644 index a69c72633..000000000 --- a/docker/base-app/debian-7/conf/provision/roles/webdevops-base-app/tasks/bootstrap/ssh.yml +++ /dev/null @@ -1,12 +0,0 @@ ---- - -- name: Init ssh privilege separation directory - file: - path: "/var/run/sshd" - state: directory - mode: 0755 - owner: "root" - group: "root" - recurse: yes - - diff --git a/docker/base-app/debian-7/conf/provision/roles/webdevops-base-app/tasks/bootstrap/user.yml b/docker/base-app/debian-7/conf/provision/roles/webdevops-base-app/tasks/bootstrap/user.yml index cf6968a01..fd58b329f 100644 --- a/docker/base-app/debian-7/conf/provision/roles/webdevops-base-app/tasks/bootstrap/user.yml +++ b/docker/base-app/debian-7/conf/provision/roles/webdevops-base-app/tasks/bootstrap/user.yml @@ -1,11 +1,5 @@ --- -- name: Move dnsmasq group (Alpine family) - group: - name: dnsmasq - gid: 153 - when: ansible_distribution == 'Alpine' - - name: Create application group group: name: "{{ APPLICATION_GROUP }}" diff --git a/docker/base-app/debian-8/Dockerfile b/docker/base-app/debian-8/Dockerfile index 00796bfb1..d3a23b603 100644 --- a/docker/base-app/debian-8/Dockerfile +++ b/docker/base-app/debian-8/Dockerfile @@ -5,29 +5,17 @@ FROM webdevops/base:debian-8 -MAINTAINER info@webdevops.io -LABEL vendor=WebDevOps.io -LABEL io.webdevops.layout=8 -LABEL io.webdevops.version=1.5.0 - -ENV APPLICATION_USER application -ENV APPLICATION_GROUP application -ENV APPLICATION_PATH /app -ENV APPLICATION_UID 1000 -ENV APPLICATION_GID 1000 +ENV APPLICATION_USER=application \ + APPLICATION_GROUP=application \ + APPLICATION_PATH=/app \ + APPLICATION_UID=1000 \ + APPLICATION_GID=1000 COPY conf/ /opt/docker/ # Install services RUN /usr/local/bin/apt-install \ - # Install services - openssh-server \ - mysql-client \ - sqlite \ - dnsmasq \ - postfix \ # Install common tools - sudo \ zip \ unzip \ bzip2 \ @@ -39,9 +27,7 @@ RUN /usr/local/bin/apt-install \ openssh-client \ rsync \ git \ - nano \ - vim \ && /usr/local/bin/generate-locales \ && /opt/docker/bin/provision run --tag bootstrap --role webdevops-base-app \ - && /opt/docker/bin/bootstrap.sh - + && /opt/docker/bin/bootstrap.sh \ + && docker-image-cleanup diff --git a/docker/base-app/debian-8/Dockerfile.jinja2 b/docker/base-app/debian-8/Dockerfile.jinja2 index 913957eab..935081352 100644 --- a/docker/base-app/debian-8/Dockerfile.jinja2 +++ b/docker/base-app/debian-8/Dockerfile.jinja2 @@ -1,8 +1,6 @@ {{ docker.from("base", "debian-8") }} -{{ docker.version() }} - -{{ environment.app() }} +{{ environment.baseApp() }} {{ docker.copy('conf/', '/opt/docker/') }} diff --git a/docker/base-app/debian-8/conf/bin/service.d/postfix.d/10-init.sh b/docker/base-app/debian-8/conf/bin/service.d/postfix.d/10-init.sh deleted file mode 100644 index 7a604874f..000000000 --- a/docker/base-app/debian-8/conf/bin/service.d/postfix.d/10-init.sh +++ /dev/null @@ -1,24 +0,0 @@ -# force new copy of hosts there (otherwise links could be outdated) -mkdir -p /var/spool/postfix/etc -cp -f /etc/hosts /var/spool/postfix/etc/hosts -cp -f /etc/resolv.conf /var/spool/postfix/etc/resolv.conf -cp -f /etc/services /var/spool/postfix/etc/services - -## MYHOSTNAME -# replace line -sed -i '/myhostname[ ]* =/c\' main.cf -echo "myhostname = $(hostname)" >> /etc/postfix/main.cf - -## REPLAYHOST -if [[ -n "${POSTFIX_RELAYHOST+x}" ]]; then - # replace line - sed -i '/relayhost[ ]* =/c\' main.cf - echo "relayhost = $POSTFIX_RELAYHOST" >> /etc/postfix/main.cf -fi - -## MYNETWORKS -if [[ -n "${POSTFIX_MYNETWORKS+x}" ]]; then - # replace line - sed -i '/mynetworks[ ]* =/c\' main.cf - echo "mynetworks = $POSTFIX_MYNETWORKS" >> /etc/postfix/main.cf -fi diff --git a/docker/base-app/debian-8/conf/bin/service.d/ssh.d/10-init.sh b/docker/base-app/debian-8/conf/bin/service.d/ssh.d/10-init.sh deleted file mode 100644 index e3192fe01..000000000 --- a/docker/base-app/debian-8/conf/bin/service.d/ssh.d/10-init.sh +++ /dev/null @@ -1,2 +0,0 @@ -# generate host keys -ssh-keygen -A diff --git a/docker/base-app/debian-8/conf/etc/supervisor.d/dnsmasq.conf b/docker/base-app/debian-8/conf/etc/supervisor.d/dnsmasq.conf deleted file mode 100644 index a0ad2de88..000000000 --- a/docker/base-app/debian-8/conf/etc/supervisor.d/dnsmasq.conf +++ /dev/null @@ -1,14 +0,0 @@ -[group:dnsmasq] -programs=dnsmasqd -priority=15 - -[program:dnsmasqd] -command = /opt/docker/bin/service.d/dnsmasq.sh -process_name=%(program_name)s -startsecs = 0 -autostart = true -autorestart = true -stdout_logfile=/dev/stdout -stdout_logfile_maxbytes=0 -stderr_logfile=/dev/stderr -stderr_logfile_maxbytes=0 diff --git a/docker/base-app/debian-8/conf/provision/roles/webdevops-base-app/tasks/bootstrap.yml b/docker/base-app/debian-8/conf/provision/roles/webdevops-base-app/tasks/bootstrap.yml index ea9e54682..3fdce9a74 100644 --- a/docker/base-app/debian-8/conf/provision/roles/webdevops-base-app/tasks/bootstrap.yml +++ b/docker/base-app/debian-8/conf/provision/roles/webdevops-base-app/tasks/bootstrap.yml @@ -2,6 +2,3 @@ - include: bootstrap/user.yml - include: bootstrap/application.yml -- include: bootstrap/dnsmasq.yml -- include: bootstrap/postfix.yml -- include: bootstrap/ssh.yml diff --git a/docker/base-app/debian-8/conf/provision/roles/webdevops-base-app/tasks/bootstrap/dnsmasq.yml b/docker/base-app/debian-8/conf/provision/roles/webdevops-base-app/tasks/bootstrap/dnsmasq.yml deleted file mode 100644 index 962a7953a..000000000 --- a/docker/base-app/debian-8/conf/provision/roles/webdevops-base-app/tasks/bootstrap/dnsmasq.yml +++ /dev/null @@ -1,10 +0,0 @@ ---- - -- name: Configure dnsmasq - lineinfile: - dest: /etc/dnsmasq.conf - regexp: '^[\s]*{{ item.key }}[\s]*=' - line: '{{ item.key }}={{ item.value }}' - with_items: - - { key: 'user', value: 'root' } - - { key: 'conf-dir', value: '/etc/dnsmasq.d' } diff --git a/docker/base-app/debian-8/conf/provision/roles/webdevops-base-app/tasks/bootstrap/postfix.yml b/docker/base-app/debian-8/conf/provision/roles/webdevops-base-app/tasks/bootstrap/postfix.yml deleted file mode 100644 index f05ff660c..000000000 --- a/docker/base-app/debian-8/conf/provision/roles/webdevops-base-app/tasks/bootstrap/postfix.yml +++ /dev/null @@ -1,29 +0,0 @@ ---- - -- name: Link aliases file to postfix aliases - file: - src: '/etc/postfix/aliases' - dest: '/etc/aliases' - state: link - force: yes - when: ansible_os_family == 'Alpine' - -- name: Configure postfix - lineinfile: - dest: /etc/postfix/main.cf - regexp: '^[\s]*{{ item.key }}[\s]*=' - line: '{{ item.key }}={{ item.value }}' - with_items: - - { key: 'mydestination', value: '' } - - { key: 'message_size_limit', value: '15240000' } - # Hardening - - { key: 'smtp_use_tls', value: 'yes' } - - { key: 'smtp_tls_security_level', value: 'may' } - -- name: Remove dynamic configuration for postfix - lineinfile: - dest: /etc/postfix/main.cf - regexp: '^[\s]*{{ item }}[\s]*=' - state: absent - with_items: - - 'myhostname' diff --git a/docker/base-app/debian-8/conf/provision/roles/webdevops-base-app/tasks/bootstrap/ssh.yml b/docker/base-app/debian-8/conf/provision/roles/webdevops-base-app/tasks/bootstrap/ssh.yml deleted file mode 100644 index a69c72633..000000000 --- a/docker/base-app/debian-8/conf/provision/roles/webdevops-base-app/tasks/bootstrap/ssh.yml +++ /dev/null @@ -1,12 +0,0 @@ ---- - -- name: Init ssh privilege separation directory - file: - path: "/var/run/sshd" - state: directory - mode: 0755 - owner: "root" - group: "root" - recurse: yes - - diff --git a/docker/base-app/debian-8/conf/provision/roles/webdevops-base-app/tasks/bootstrap/user.yml b/docker/base-app/debian-8/conf/provision/roles/webdevops-base-app/tasks/bootstrap/user.yml index cf6968a01..fd58b329f 100644 --- a/docker/base-app/debian-8/conf/provision/roles/webdevops-base-app/tasks/bootstrap/user.yml +++ b/docker/base-app/debian-8/conf/provision/roles/webdevops-base-app/tasks/bootstrap/user.yml @@ -1,11 +1,5 @@ --- -- name: Move dnsmasq group (Alpine family) - group: - name: dnsmasq - gid: 153 - when: ansible_distribution == 'Alpine' - - name: Create application group group: name: "{{ APPLICATION_GROUP }}" diff --git a/docker/base-app/debian-9/Dockerfile b/docker/base-app/debian-9/Dockerfile index 562c1d0d2..048e2545b 100644 --- a/docker/base-app/debian-9/Dockerfile +++ b/docker/base-app/debian-9/Dockerfile @@ -5,29 +5,17 @@ FROM webdevops/base:debian-9 -MAINTAINER info@webdevops.io -LABEL vendor=WebDevOps.io -LABEL io.webdevops.layout=8 -LABEL io.webdevops.version=1.5.0 - -ENV APPLICATION_USER application -ENV APPLICATION_GROUP application -ENV APPLICATION_PATH /app -ENV APPLICATION_UID 1000 -ENV APPLICATION_GID 1000 +ENV APPLICATION_USER=application \ + APPLICATION_GROUP=application \ + APPLICATION_PATH=/app \ + APPLICATION_UID=1000 \ + APPLICATION_GID=1000 COPY conf/ /opt/docker/ # Install services RUN /usr/local/bin/apt-install \ - # Install services - openssh-server \ - mariadb-client \ - sqlite \ - dnsmasq \ - postfix \ # Install common tools - sudo \ zip \ unzip \ bzip2 \ @@ -39,9 +27,7 @@ RUN /usr/local/bin/apt-install \ openssh-client \ rsync \ git \ - nano \ - vim \ && /usr/local/bin/generate-locales \ && /opt/docker/bin/provision run --tag bootstrap --role webdevops-base-app \ - && /opt/docker/bin/bootstrap.sh - + && /opt/docker/bin/bootstrap.sh \ + && docker-image-cleanup diff --git a/docker/base-app/debian-9/Dockerfile.jinja2 b/docker/base-app/debian-9/Dockerfile.jinja2 index 9b225906a..178bf2679 100644 --- a/docker/base-app/debian-9/Dockerfile.jinja2 +++ b/docker/base-app/debian-9/Dockerfile.jinja2 @@ -1,8 +1,6 @@ {{ docker.from("base", "debian-9") }} -{{ docker.version() }} - -{{ environment.app() }} +{{ environment.baseApp() }} {{ docker.copy('conf/', '/opt/docker/') }} diff --git a/docker/base-app/debian-9/conf/bin/service.d/postfix.d/10-init.sh b/docker/base-app/debian-9/conf/bin/service.d/postfix.d/10-init.sh deleted file mode 100644 index 7a604874f..000000000 --- a/docker/base-app/debian-9/conf/bin/service.d/postfix.d/10-init.sh +++ /dev/null @@ -1,24 +0,0 @@ -# force new copy of hosts there (otherwise links could be outdated) -mkdir -p /var/spool/postfix/etc -cp -f /etc/hosts /var/spool/postfix/etc/hosts -cp -f /etc/resolv.conf /var/spool/postfix/etc/resolv.conf -cp -f /etc/services /var/spool/postfix/etc/services - -## MYHOSTNAME -# replace line -sed -i '/myhostname[ ]* =/c\' main.cf -echo "myhostname = $(hostname)" >> /etc/postfix/main.cf - -## REPLAYHOST -if [[ -n "${POSTFIX_RELAYHOST+x}" ]]; then - # replace line - sed -i '/relayhost[ ]* =/c\' main.cf - echo "relayhost = $POSTFIX_RELAYHOST" >> /etc/postfix/main.cf -fi - -## MYNETWORKS -if [[ -n "${POSTFIX_MYNETWORKS+x}" ]]; then - # replace line - sed -i '/mynetworks[ ]* =/c\' main.cf - echo "mynetworks = $POSTFIX_MYNETWORKS" >> /etc/postfix/main.cf -fi diff --git a/docker/base-app/debian-9/conf/bin/service.d/ssh.d/10-init.sh b/docker/base-app/debian-9/conf/bin/service.d/ssh.d/10-init.sh deleted file mode 100644 index e3192fe01..000000000 --- a/docker/base-app/debian-9/conf/bin/service.d/ssh.d/10-init.sh +++ /dev/null @@ -1,2 +0,0 @@ -# generate host keys -ssh-keygen -A diff --git a/docker/base-app/debian-9/conf/etc/supervisor.d/dnsmasq.conf b/docker/base-app/debian-9/conf/etc/supervisor.d/dnsmasq.conf deleted file mode 100644 index a0ad2de88..000000000 --- a/docker/base-app/debian-9/conf/etc/supervisor.d/dnsmasq.conf +++ /dev/null @@ -1,14 +0,0 @@ -[group:dnsmasq] -programs=dnsmasqd -priority=15 - -[program:dnsmasqd] -command = /opt/docker/bin/service.d/dnsmasq.sh -process_name=%(program_name)s -startsecs = 0 -autostart = true -autorestart = true -stdout_logfile=/dev/stdout -stdout_logfile_maxbytes=0 -stderr_logfile=/dev/stderr -stderr_logfile_maxbytes=0 diff --git a/docker/base-app/debian-9/conf/provision/roles/webdevops-base-app/tasks/bootstrap.yml b/docker/base-app/debian-9/conf/provision/roles/webdevops-base-app/tasks/bootstrap.yml index ea9e54682..3fdce9a74 100644 --- a/docker/base-app/debian-9/conf/provision/roles/webdevops-base-app/tasks/bootstrap.yml +++ b/docker/base-app/debian-9/conf/provision/roles/webdevops-base-app/tasks/bootstrap.yml @@ -2,6 +2,3 @@ - include: bootstrap/user.yml - include: bootstrap/application.yml -- include: bootstrap/dnsmasq.yml -- include: bootstrap/postfix.yml -- include: bootstrap/ssh.yml diff --git a/docker/base-app/debian-9/conf/provision/roles/webdevops-base-app/tasks/bootstrap/dnsmasq.yml b/docker/base-app/debian-9/conf/provision/roles/webdevops-base-app/tasks/bootstrap/dnsmasq.yml deleted file mode 100644 index 962a7953a..000000000 --- a/docker/base-app/debian-9/conf/provision/roles/webdevops-base-app/tasks/bootstrap/dnsmasq.yml +++ /dev/null @@ -1,10 +0,0 @@ ---- - -- name: Configure dnsmasq - lineinfile: - dest: /etc/dnsmasq.conf - regexp: '^[\s]*{{ item.key }}[\s]*=' - line: '{{ item.key }}={{ item.value }}' - with_items: - - { key: 'user', value: 'root' } - - { key: 'conf-dir', value: '/etc/dnsmasq.d' } diff --git a/docker/base-app/debian-9/conf/provision/roles/webdevops-base-app/tasks/bootstrap/postfix.yml b/docker/base-app/debian-9/conf/provision/roles/webdevops-base-app/tasks/bootstrap/postfix.yml deleted file mode 100644 index f05ff660c..000000000 --- a/docker/base-app/debian-9/conf/provision/roles/webdevops-base-app/tasks/bootstrap/postfix.yml +++ /dev/null @@ -1,29 +0,0 @@ ---- - -- name: Link aliases file to postfix aliases - file: - src: '/etc/postfix/aliases' - dest: '/etc/aliases' - state: link - force: yes - when: ansible_os_family == 'Alpine' - -- name: Configure postfix - lineinfile: - dest: /etc/postfix/main.cf - regexp: '^[\s]*{{ item.key }}[\s]*=' - line: '{{ item.key }}={{ item.value }}' - with_items: - - { key: 'mydestination', value: '' } - - { key: 'message_size_limit', value: '15240000' } - # Hardening - - { key: 'smtp_use_tls', value: 'yes' } - - { key: 'smtp_tls_security_level', value: 'may' } - -- name: Remove dynamic configuration for postfix - lineinfile: - dest: /etc/postfix/main.cf - regexp: '^[\s]*{{ item }}[\s]*=' - state: absent - with_items: - - 'myhostname' diff --git a/docker/base-app/debian-9/conf/provision/roles/webdevops-base-app/tasks/bootstrap/ssh.yml b/docker/base-app/debian-9/conf/provision/roles/webdevops-base-app/tasks/bootstrap/ssh.yml deleted file mode 100644 index a69c72633..000000000 --- a/docker/base-app/debian-9/conf/provision/roles/webdevops-base-app/tasks/bootstrap/ssh.yml +++ /dev/null @@ -1,12 +0,0 @@ ---- - -- name: Init ssh privilege separation directory - file: - path: "/var/run/sshd" - state: directory - mode: 0755 - owner: "root" - group: "root" - recurse: yes - - diff --git a/docker/base-app/debian-9/conf/provision/roles/webdevops-base-app/tasks/bootstrap/user.yml b/docker/base-app/debian-9/conf/provision/roles/webdevops-base-app/tasks/bootstrap/user.yml index cf6968a01..fd58b329f 100644 --- a/docker/base-app/debian-9/conf/provision/roles/webdevops-base-app/tasks/bootstrap/user.yml +++ b/docker/base-app/debian-9/conf/provision/roles/webdevops-base-app/tasks/bootstrap/user.yml @@ -1,11 +1,5 @@ --- -- name: Move dnsmasq group (Alpine family) - group: - name: dnsmasq - gid: 153 - when: ansible_distribution == 'Alpine' - - name: Create application group group: name: "{{ APPLICATION_GROUP }}" diff --git a/docker/base-app/ubuntu-12.04/Dockerfile b/docker/base-app/ubuntu-12.04/Dockerfile index 6643262e1..e9bd39ac8 100644 --- a/docker/base-app/ubuntu-12.04/Dockerfile +++ b/docker/base-app/ubuntu-12.04/Dockerfile @@ -5,29 +5,17 @@ FROM webdevops/base:ubuntu-12.04 -MAINTAINER info@webdevops.io -LABEL vendor=WebDevOps.io -LABEL io.webdevops.layout=8 -LABEL io.webdevops.version=1.5.0 - -ENV APPLICATION_USER application -ENV APPLICATION_GROUP application -ENV APPLICATION_PATH /app -ENV APPLICATION_UID 1000 -ENV APPLICATION_GID 1000 +ENV APPLICATION_USER=application \ + APPLICATION_GROUP=application \ + APPLICATION_PATH=/app \ + APPLICATION_UID=1000 \ + APPLICATION_GID=1000 COPY conf/ /opt/docker/ # Install services RUN /usr/local/bin/apt-install \ - # Install services - openssh-server \ - mysql-client \ - sqlite \ - dnsmasq \ - postfix \ # Install common tools - sudo \ zip \ unzip \ bzip2 \ @@ -39,10 +27,8 @@ RUN /usr/local/bin/apt-install \ openssh-client \ rsync \ git \ - nano \ - vim \ && mkdir -p /var/lib/syslog-ng/ \ && /usr/local/bin/generate-locales \ && /opt/docker/bin/provision run --tag bootstrap --role webdevops-base-app \ - && /opt/docker/bin/bootstrap.sh - + && /opt/docker/bin/bootstrap.sh \ + && docker-image-cleanup diff --git a/docker/base-app/ubuntu-12.04/Dockerfile.jinja2 b/docker/base-app/ubuntu-12.04/Dockerfile.jinja2 index e4e7bd863..5a1424074 100644 --- a/docker/base-app/ubuntu-12.04/Dockerfile.jinja2 +++ b/docker/base-app/ubuntu-12.04/Dockerfile.jinja2 @@ -1,8 +1,6 @@ {{ docker.from("base", "ubuntu-12.04") }} -{{ docker.version() }} - -{{ environment.app() }} +{{ environment.baseApp() }} {{ docker.copy('conf/', '/opt/docker/') }} diff --git a/docker/base-app/ubuntu-12.04/conf/bin/service.d/postfix.d/10-init.sh b/docker/base-app/ubuntu-12.04/conf/bin/service.d/postfix.d/10-init.sh deleted file mode 100644 index 7a604874f..000000000 --- a/docker/base-app/ubuntu-12.04/conf/bin/service.d/postfix.d/10-init.sh +++ /dev/null @@ -1,24 +0,0 @@ -# force new copy of hosts there (otherwise links could be outdated) -mkdir -p /var/spool/postfix/etc -cp -f /etc/hosts /var/spool/postfix/etc/hosts -cp -f /etc/resolv.conf /var/spool/postfix/etc/resolv.conf -cp -f /etc/services /var/spool/postfix/etc/services - -## MYHOSTNAME -# replace line -sed -i '/myhostname[ ]* =/c\' main.cf -echo "myhostname = $(hostname)" >> /etc/postfix/main.cf - -## REPLAYHOST -if [[ -n "${POSTFIX_RELAYHOST+x}" ]]; then - # replace line - sed -i '/relayhost[ ]* =/c\' main.cf - echo "relayhost = $POSTFIX_RELAYHOST" >> /etc/postfix/main.cf -fi - -## MYNETWORKS -if [[ -n "${POSTFIX_MYNETWORKS+x}" ]]; then - # replace line - sed -i '/mynetworks[ ]* =/c\' main.cf - echo "mynetworks = $POSTFIX_MYNETWORKS" >> /etc/postfix/main.cf -fi diff --git a/docker/base-app/ubuntu-12.04/conf/bin/service.d/ssh.d/10-init.sh b/docker/base-app/ubuntu-12.04/conf/bin/service.d/ssh.d/10-init.sh deleted file mode 100644 index e3192fe01..000000000 --- a/docker/base-app/ubuntu-12.04/conf/bin/service.d/ssh.d/10-init.sh +++ /dev/null @@ -1,2 +0,0 @@ -# generate host keys -ssh-keygen -A diff --git a/docker/base-app/ubuntu-12.04/conf/etc/supervisor.d/dnsmasq.conf b/docker/base-app/ubuntu-12.04/conf/etc/supervisor.d/dnsmasq.conf deleted file mode 100644 index a0ad2de88..000000000 --- a/docker/base-app/ubuntu-12.04/conf/etc/supervisor.d/dnsmasq.conf +++ /dev/null @@ -1,14 +0,0 @@ -[group:dnsmasq] -programs=dnsmasqd -priority=15 - -[program:dnsmasqd] -command = /opt/docker/bin/service.d/dnsmasq.sh -process_name=%(program_name)s -startsecs = 0 -autostart = true -autorestart = true -stdout_logfile=/dev/stdout -stdout_logfile_maxbytes=0 -stderr_logfile=/dev/stderr -stderr_logfile_maxbytes=0 diff --git a/docker/base-app/ubuntu-12.04/conf/provision/roles/webdevops-base-app/tasks/bootstrap.yml b/docker/base-app/ubuntu-12.04/conf/provision/roles/webdevops-base-app/tasks/bootstrap.yml index ea9e54682..3fdce9a74 100644 --- a/docker/base-app/ubuntu-12.04/conf/provision/roles/webdevops-base-app/tasks/bootstrap.yml +++ b/docker/base-app/ubuntu-12.04/conf/provision/roles/webdevops-base-app/tasks/bootstrap.yml @@ -2,6 +2,3 @@ - include: bootstrap/user.yml - include: bootstrap/application.yml -- include: bootstrap/dnsmasq.yml -- include: bootstrap/postfix.yml -- include: bootstrap/ssh.yml diff --git a/docker/base-app/ubuntu-12.04/conf/provision/roles/webdevops-base-app/tasks/bootstrap/dnsmasq.yml b/docker/base-app/ubuntu-12.04/conf/provision/roles/webdevops-base-app/tasks/bootstrap/dnsmasq.yml deleted file mode 100644 index 962a7953a..000000000 --- a/docker/base-app/ubuntu-12.04/conf/provision/roles/webdevops-base-app/tasks/bootstrap/dnsmasq.yml +++ /dev/null @@ -1,10 +0,0 @@ ---- - -- name: Configure dnsmasq - lineinfile: - dest: /etc/dnsmasq.conf - regexp: '^[\s]*{{ item.key }}[\s]*=' - line: '{{ item.key }}={{ item.value }}' - with_items: - - { key: 'user', value: 'root' } - - { key: 'conf-dir', value: '/etc/dnsmasq.d' } diff --git a/docker/base-app/ubuntu-12.04/conf/provision/roles/webdevops-base-app/tasks/bootstrap/postfix.yml b/docker/base-app/ubuntu-12.04/conf/provision/roles/webdevops-base-app/tasks/bootstrap/postfix.yml deleted file mode 100644 index f05ff660c..000000000 --- a/docker/base-app/ubuntu-12.04/conf/provision/roles/webdevops-base-app/tasks/bootstrap/postfix.yml +++ /dev/null @@ -1,29 +0,0 @@ ---- - -- name: Link aliases file to postfix aliases - file: - src: '/etc/postfix/aliases' - dest: '/etc/aliases' - state: link - force: yes - when: ansible_os_family == 'Alpine' - -- name: Configure postfix - lineinfile: - dest: /etc/postfix/main.cf - regexp: '^[\s]*{{ item.key }}[\s]*=' - line: '{{ item.key }}={{ item.value }}' - with_items: - - { key: 'mydestination', value: '' } - - { key: 'message_size_limit', value: '15240000' } - # Hardening - - { key: 'smtp_use_tls', value: 'yes' } - - { key: 'smtp_tls_security_level', value: 'may' } - -- name: Remove dynamic configuration for postfix - lineinfile: - dest: /etc/postfix/main.cf - regexp: '^[\s]*{{ item }}[\s]*=' - state: absent - with_items: - - 'myhostname' diff --git a/docker/base-app/ubuntu-12.04/conf/provision/roles/webdevops-base-app/tasks/bootstrap/ssh.yml b/docker/base-app/ubuntu-12.04/conf/provision/roles/webdevops-base-app/tasks/bootstrap/ssh.yml deleted file mode 100644 index a69c72633..000000000 --- a/docker/base-app/ubuntu-12.04/conf/provision/roles/webdevops-base-app/tasks/bootstrap/ssh.yml +++ /dev/null @@ -1,12 +0,0 @@ ---- - -- name: Init ssh privilege separation directory - file: - path: "/var/run/sshd" - state: directory - mode: 0755 - owner: "root" - group: "root" - recurse: yes - - diff --git a/docker/base-app/ubuntu-12.04/conf/provision/roles/webdevops-base-app/tasks/bootstrap/user.yml b/docker/base-app/ubuntu-12.04/conf/provision/roles/webdevops-base-app/tasks/bootstrap/user.yml index cf6968a01..fd58b329f 100644 --- a/docker/base-app/ubuntu-12.04/conf/provision/roles/webdevops-base-app/tasks/bootstrap/user.yml +++ b/docker/base-app/ubuntu-12.04/conf/provision/roles/webdevops-base-app/tasks/bootstrap/user.yml @@ -1,11 +1,5 @@ --- -- name: Move dnsmasq group (Alpine family) - group: - name: dnsmasq - gid: 153 - when: ansible_distribution == 'Alpine' - - name: Create application group group: name: "{{ APPLICATION_GROUP }}" diff --git a/docker/base-app/ubuntu-14.04/Dockerfile b/docker/base-app/ubuntu-14.04/Dockerfile index 51517afa2..2b9a73338 100644 --- a/docker/base-app/ubuntu-14.04/Dockerfile +++ b/docker/base-app/ubuntu-14.04/Dockerfile @@ -5,29 +5,17 @@ FROM webdevops/base:ubuntu-14.04 -MAINTAINER info@webdevops.io -LABEL vendor=WebDevOps.io -LABEL io.webdevops.layout=8 -LABEL io.webdevops.version=1.5.0 - -ENV APPLICATION_USER application -ENV APPLICATION_GROUP application -ENV APPLICATION_PATH /app -ENV APPLICATION_UID 1000 -ENV APPLICATION_GID 1000 +ENV APPLICATION_USER=application \ + APPLICATION_GROUP=application \ + APPLICATION_PATH=/app \ + APPLICATION_UID=1000 \ + APPLICATION_GID=1000 COPY conf/ /opt/docker/ # Install services RUN /usr/local/bin/apt-install \ - # Install services - openssh-server \ - mysql-client \ - sqlite \ - dnsmasq \ - postfix \ # Install common tools - sudo \ zip \ unzip \ bzip2 \ @@ -39,10 +27,8 @@ RUN /usr/local/bin/apt-install \ openssh-client \ rsync \ git \ - nano \ - vim \ && mkdir -p /var/lib/syslog-ng/ \ && /usr/local/bin/generate-locales \ && /opt/docker/bin/provision run --tag bootstrap --role webdevops-base-app \ - && /opt/docker/bin/bootstrap.sh - + && /opt/docker/bin/bootstrap.sh \ + && docker-image-cleanup diff --git a/docker/base-app/ubuntu-14.04/Dockerfile.jinja2 b/docker/base-app/ubuntu-14.04/Dockerfile.jinja2 index c896ae0c4..91a9ff3ac 100644 --- a/docker/base-app/ubuntu-14.04/Dockerfile.jinja2 +++ b/docker/base-app/ubuntu-14.04/Dockerfile.jinja2 @@ -1,8 +1,6 @@ {{ docker.from("base", "ubuntu-14.04") }} -{{ docker.version() }} - -{{ environment.app() }} +{{ environment.baseApp() }} {{ docker.copy('conf/', '/opt/docker/') }} diff --git a/docker/base-app/ubuntu-14.04/conf/bin/service.d/postfix.d/10-init.sh b/docker/base-app/ubuntu-14.04/conf/bin/service.d/postfix.d/10-init.sh deleted file mode 100644 index 7a604874f..000000000 --- a/docker/base-app/ubuntu-14.04/conf/bin/service.d/postfix.d/10-init.sh +++ /dev/null @@ -1,24 +0,0 @@ -# force new copy of hosts there (otherwise links could be outdated) -mkdir -p /var/spool/postfix/etc -cp -f /etc/hosts /var/spool/postfix/etc/hosts -cp -f /etc/resolv.conf /var/spool/postfix/etc/resolv.conf -cp -f /etc/services /var/spool/postfix/etc/services - -## MYHOSTNAME -# replace line -sed -i '/myhostname[ ]* =/c\' main.cf -echo "myhostname = $(hostname)" >> /etc/postfix/main.cf - -## REPLAYHOST -if [[ -n "${POSTFIX_RELAYHOST+x}" ]]; then - # replace line - sed -i '/relayhost[ ]* =/c\' main.cf - echo "relayhost = $POSTFIX_RELAYHOST" >> /etc/postfix/main.cf -fi - -## MYNETWORKS -if [[ -n "${POSTFIX_MYNETWORKS+x}" ]]; then - # replace line - sed -i '/mynetworks[ ]* =/c\' main.cf - echo "mynetworks = $POSTFIX_MYNETWORKS" >> /etc/postfix/main.cf -fi diff --git a/docker/base-app/ubuntu-14.04/conf/bin/service.d/ssh.d/10-init.sh b/docker/base-app/ubuntu-14.04/conf/bin/service.d/ssh.d/10-init.sh deleted file mode 100644 index e3192fe01..000000000 --- a/docker/base-app/ubuntu-14.04/conf/bin/service.d/ssh.d/10-init.sh +++ /dev/null @@ -1,2 +0,0 @@ -# generate host keys -ssh-keygen -A diff --git a/docker/base-app/ubuntu-14.04/conf/etc/supervisor.d/dnsmasq.conf b/docker/base-app/ubuntu-14.04/conf/etc/supervisor.d/dnsmasq.conf deleted file mode 100644 index a0ad2de88..000000000 --- a/docker/base-app/ubuntu-14.04/conf/etc/supervisor.d/dnsmasq.conf +++ /dev/null @@ -1,14 +0,0 @@ -[group:dnsmasq] -programs=dnsmasqd -priority=15 - -[program:dnsmasqd] -command = /opt/docker/bin/service.d/dnsmasq.sh -process_name=%(program_name)s -startsecs = 0 -autostart = true -autorestart = true -stdout_logfile=/dev/stdout -stdout_logfile_maxbytes=0 -stderr_logfile=/dev/stderr -stderr_logfile_maxbytes=0 diff --git a/docker/base-app/ubuntu-14.04/conf/provision/roles/webdevops-base-app/tasks/bootstrap.yml b/docker/base-app/ubuntu-14.04/conf/provision/roles/webdevops-base-app/tasks/bootstrap.yml index ea9e54682..3fdce9a74 100644 --- a/docker/base-app/ubuntu-14.04/conf/provision/roles/webdevops-base-app/tasks/bootstrap.yml +++ b/docker/base-app/ubuntu-14.04/conf/provision/roles/webdevops-base-app/tasks/bootstrap.yml @@ -2,6 +2,3 @@ - include: bootstrap/user.yml - include: bootstrap/application.yml -- include: bootstrap/dnsmasq.yml -- include: bootstrap/postfix.yml -- include: bootstrap/ssh.yml diff --git a/docker/base-app/ubuntu-14.04/conf/provision/roles/webdevops-base-app/tasks/bootstrap/dnsmasq.yml b/docker/base-app/ubuntu-14.04/conf/provision/roles/webdevops-base-app/tasks/bootstrap/dnsmasq.yml deleted file mode 100644 index 962a7953a..000000000 --- a/docker/base-app/ubuntu-14.04/conf/provision/roles/webdevops-base-app/tasks/bootstrap/dnsmasq.yml +++ /dev/null @@ -1,10 +0,0 @@ ---- - -- name: Configure dnsmasq - lineinfile: - dest: /etc/dnsmasq.conf - regexp: '^[\s]*{{ item.key }}[\s]*=' - line: '{{ item.key }}={{ item.value }}' - with_items: - - { key: 'user', value: 'root' } - - { key: 'conf-dir', value: '/etc/dnsmasq.d' } diff --git a/docker/base-app/ubuntu-14.04/conf/provision/roles/webdevops-base-app/tasks/bootstrap/postfix.yml b/docker/base-app/ubuntu-14.04/conf/provision/roles/webdevops-base-app/tasks/bootstrap/postfix.yml deleted file mode 100644 index f05ff660c..000000000 --- a/docker/base-app/ubuntu-14.04/conf/provision/roles/webdevops-base-app/tasks/bootstrap/postfix.yml +++ /dev/null @@ -1,29 +0,0 @@ ---- - -- name: Link aliases file to postfix aliases - file: - src: '/etc/postfix/aliases' - dest: '/etc/aliases' - state: link - force: yes - when: ansible_os_family == 'Alpine' - -- name: Configure postfix - lineinfile: - dest: /etc/postfix/main.cf - regexp: '^[\s]*{{ item.key }}[\s]*=' - line: '{{ item.key }}={{ item.value }}' - with_items: - - { key: 'mydestination', value: '' } - - { key: 'message_size_limit', value: '15240000' } - # Hardening - - { key: 'smtp_use_tls', value: 'yes' } - - { key: 'smtp_tls_security_level', value: 'may' } - -- name: Remove dynamic configuration for postfix - lineinfile: - dest: /etc/postfix/main.cf - regexp: '^[\s]*{{ item }}[\s]*=' - state: absent - with_items: - - 'myhostname' diff --git a/docker/base-app/ubuntu-14.04/conf/provision/roles/webdevops-base-app/tasks/bootstrap/ssh.yml b/docker/base-app/ubuntu-14.04/conf/provision/roles/webdevops-base-app/tasks/bootstrap/ssh.yml deleted file mode 100644 index a69c72633..000000000 --- a/docker/base-app/ubuntu-14.04/conf/provision/roles/webdevops-base-app/tasks/bootstrap/ssh.yml +++ /dev/null @@ -1,12 +0,0 @@ ---- - -- name: Init ssh privilege separation directory - file: - path: "/var/run/sshd" - state: directory - mode: 0755 - owner: "root" - group: "root" - recurse: yes - - diff --git a/docker/base-app/ubuntu-14.04/conf/provision/roles/webdevops-base-app/tasks/bootstrap/user.yml b/docker/base-app/ubuntu-14.04/conf/provision/roles/webdevops-base-app/tasks/bootstrap/user.yml index cf6968a01..fd58b329f 100644 --- a/docker/base-app/ubuntu-14.04/conf/provision/roles/webdevops-base-app/tasks/bootstrap/user.yml +++ b/docker/base-app/ubuntu-14.04/conf/provision/roles/webdevops-base-app/tasks/bootstrap/user.yml @@ -1,11 +1,5 @@ --- -- name: Move dnsmasq group (Alpine family) - group: - name: dnsmasq - gid: 153 - when: ansible_distribution == 'Alpine' - - name: Create application group group: name: "{{ APPLICATION_GROUP }}" diff --git a/docker/base-app/ubuntu-15.04/Dockerfile b/docker/base-app/ubuntu-15.04/Dockerfile index 8d0a88b67..19e2be442 100644 --- a/docker/base-app/ubuntu-15.04/Dockerfile +++ b/docker/base-app/ubuntu-15.04/Dockerfile @@ -5,29 +5,17 @@ FROM webdevops/base:ubuntu-15.04 -MAINTAINER info@webdevops.io -LABEL vendor=WebDevOps.io -LABEL io.webdevops.layout=8 -LABEL io.webdevops.version=1.5.0 - -ENV APPLICATION_USER application -ENV APPLICATION_GROUP application -ENV APPLICATION_PATH /app -ENV APPLICATION_UID 1000 -ENV APPLICATION_GID 1000 +ENV APPLICATION_USER=application \ + APPLICATION_GROUP=application \ + APPLICATION_PATH=/app \ + APPLICATION_UID=1000 \ + APPLICATION_GID=1000 COPY conf/ /opt/docker/ # Install services RUN /usr/local/bin/apt-install \ - # Install services - openssh-server \ - mysql-client \ - sqlite \ - dnsmasq \ - postfix \ # Install common tools - sudo \ zip \ unzip \ bzip2 \ @@ -39,10 +27,8 @@ RUN /usr/local/bin/apt-install \ openssh-client \ rsync \ git \ - nano \ - vim \ && mkdir -p /var/lib/syslog-ng/ \ && /usr/local/bin/generate-locales \ && /opt/docker/bin/provision run --tag bootstrap --role webdevops-base-app \ - && /opt/docker/bin/bootstrap.sh - + && /opt/docker/bin/bootstrap.sh \ + && docker-image-cleanup diff --git a/docker/base-app/ubuntu-15.04/Dockerfile.jinja2 b/docker/base-app/ubuntu-15.04/Dockerfile.jinja2 index 0d8bdcf1b..423457dde 100644 --- a/docker/base-app/ubuntu-15.04/Dockerfile.jinja2 +++ b/docker/base-app/ubuntu-15.04/Dockerfile.jinja2 @@ -1,8 +1,6 @@ {{ docker.from("base", "ubuntu-15.04") }} -{{ docker.version() }} - -{{ environment.app() }} +{{ environment.baseApp() }} {{ docker.copy('conf/', '/opt/docker/') }} diff --git a/docker/base-app/ubuntu-15.04/conf/bin/service.d/postfix.d/10-init.sh b/docker/base-app/ubuntu-15.04/conf/bin/service.d/postfix.d/10-init.sh deleted file mode 100644 index 7a604874f..000000000 --- a/docker/base-app/ubuntu-15.04/conf/bin/service.d/postfix.d/10-init.sh +++ /dev/null @@ -1,24 +0,0 @@ -# force new copy of hosts there (otherwise links could be outdated) -mkdir -p /var/spool/postfix/etc -cp -f /etc/hosts /var/spool/postfix/etc/hosts -cp -f /etc/resolv.conf /var/spool/postfix/etc/resolv.conf -cp -f /etc/services /var/spool/postfix/etc/services - -## MYHOSTNAME -# replace line -sed -i '/myhostname[ ]* =/c\' main.cf -echo "myhostname = $(hostname)" >> /etc/postfix/main.cf - -## REPLAYHOST -if [[ -n "${POSTFIX_RELAYHOST+x}" ]]; then - # replace line - sed -i '/relayhost[ ]* =/c\' main.cf - echo "relayhost = $POSTFIX_RELAYHOST" >> /etc/postfix/main.cf -fi - -## MYNETWORKS -if [[ -n "${POSTFIX_MYNETWORKS+x}" ]]; then - # replace line - sed -i '/mynetworks[ ]* =/c\' main.cf - echo "mynetworks = $POSTFIX_MYNETWORKS" >> /etc/postfix/main.cf -fi diff --git a/docker/base-app/ubuntu-15.04/conf/bin/service.d/ssh.d/10-init.sh b/docker/base-app/ubuntu-15.04/conf/bin/service.d/ssh.d/10-init.sh deleted file mode 100644 index e3192fe01..000000000 --- a/docker/base-app/ubuntu-15.04/conf/bin/service.d/ssh.d/10-init.sh +++ /dev/null @@ -1,2 +0,0 @@ -# generate host keys -ssh-keygen -A diff --git a/docker/base-app/ubuntu-15.04/conf/etc/supervisor.d/dnsmasq.conf b/docker/base-app/ubuntu-15.04/conf/etc/supervisor.d/dnsmasq.conf deleted file mode 100644 index a0ad2de88..000000000 --- a/docker/base-app/ubuntu-15.04/conf/etc/supervisor.d/dnsmasq.conf +++ /dev/null @@ -1,14 +0,0 @@ -[group:dnsmasq] -programs=dnsmasqd -priority=15 - -[program:dnsmasqd] -command = /opt/docker/bin/service.d/dnsmasq.sh -process_name=%(program_name)s -startsecs = 0 -autostart = true -autorestart = true -stdout_logfile=/dev/stdout -stdout_logfile_maxbytes=0 -stderr_logfile=/dev/stderr -stderr_logfile_maxbytes=0 diff --git a/docker/base-app/ubuntu-15.04/conf/provision/roles/webdevops-base-app/tasks/bootstrap.yml b/docker/base-app/ubuntu-15.04/conf/provision/roles/webdevops-base-app/tasks/bootstrap.yml index ea9e54682..3fdce9a74 100644 --- a/docker/base-app/ubuntu-15.04/conf/provision/roles/webdevops-base-app/tasks/bootstrap.yml +++ b/docker/base-app/ubuntu-15.04/conf/provision/roles/webdevops-base-app/tasks/bootstrap.yml @@ -2,6 +2,3 @@ - include: bootstrap/user.yml - include: bootstrap/application.yml -- include: bootstrap/dnsmasq.yml -- include: bootstrap/postfix.yml -- include: bootstrap/ssh.yml diff --git a/docker/base-app/ubuntu-15.04/conf/provision/roles/webdevops-base-app/tasks/bootstrap/dnsmasq.yml b/docker/base-app/ubuntu-15.04/conf/provision/roles/webdevops-base-app/tasks/bootstrap/dnsmasq.yml deleted file mode 100644 index 962a7953a..000000000 --- a/docker/base-app/ubuntu-15.04/conf/provision/roles/webdevops-base-app/tasks/bootstrap/dnsmasq.yml +++ /dev/null @@ -1,10 +0,0 @@ ---- - -- name: Configure dnsmasq - lineinfile: - dest: /etc/dnsmasq.conf - regexp: '^[\s]*{{ item.key }}[\s]*=' - line: '{{ item.key }}={{ item.value }}' - with_items: - - { key: 'user', value: 'root' } - - { key: 'conf-dir', value: '/etc/dnsmasq.d' } diff --git a/docker/base-app/ubuntu-15.04/conf/provision/roles/webdevops-base-app/tasks/bootstrap/postfix.yml b/docker/base-app/ubuntu-15.04/conf/provision/roles/webdevops-base-app/tasks/bootstrap/postfix.yml deleted file mode 100644 index f05ff660c..000000000 --- a/docker/base-app/ubuntu-15.04/conf/provision/roles/webdevops-base-app/tasks/bootstrap/postfix.yml +++ /dev/null @@ -1,29 +0,0 @@ ---- - -- name: Link aliases file to postfix aliases - file: - src: '/etc/postfix/aliases' - dest: '/etc/aliases' - state: link - force: yes - when: ansible_os_family == 'Alpine' - -- name: Configure postfix - lineinfile: - dest: /etc/postfix/main.cf - regexp: '^[\s]*{{ item.key }}[\s]*=' - line: '{{ item.key }}={{ item.value }}' - with_items: - - { key: 'mydestination', value: '' } - - { key: 'message_size_limit', value: '15240000' } - # Hardening - - { key: 'smtp_use_tls', value: 'yes' } - - { key: 'smtp_tls_security_level', value: 'may' } - -- name: Remove dynamic configuration for postfix - lineinfile: - dest: /etc/postfix/main.cf - regexp: '^[\s]*{{ item }}[\s]*=' - state: absent - with_items: - - 'myhostname' diff --git a/docker/base-app/ubuntu-15.04/conf/provision/roles/webdevops-base-app/tasks/bootstrap/ssh.yml b/docker/base-app/ubuntu-15.04/conf/provision/roles/webdevops-base-app/tasks/bootstrap/ssh.yml deleted file mode 100644 index a69c72633..000000000 --- a/docker/base-app/ubuntu-15.04/conf/provision/roles/webdevops-base-app/tasks/bootstrap/ssh.yml +++ /dev/null @@ -1,12 +0,0 @@ ---- - -- name: Init ssh privilege separation directory - file: - path: "/var/run/sshd" - state: directory - mode: 0755 - owner: "root" - group: "root" - recurse: yes - - diff --git a/docker/base-app/ubuntu-15.04/conf/provision/roles/webdevops-base-app/tasks/bootstrap/user.yml b/docker/base-app/ubuntu-15.04/conf/provision/roles/webdevops-base-app/tasks/bootstrap/user.yml index cf6968a01..fd58b329f 100644 --- a/docker/base-app/ubuntu-15.04/conf/provision/roles/webdevops-base-app/tasks/bootstrap/user.yml +++ b/docker/base-app/ubuntu-15.04/conf/provision/roles/webdevops-base-app/tasks/bootstrap/user.yml @@ -1,11 +1,5 @@ --- -- name: Move dnsmasq group (Alpine family) - group: - name: dnsmasq - gid: 153 - when: ansible_distribution == 'Alpine' - - name: Create application group group: name: "{{ APPLICATION_GROUP }}" diff --git a/docker/base-app/ubuntu-15.10/Dockerfile b/docker/base-app/ubuntu-15.10/Dockerfile index 90fc6ac7a..eccf6b3b7 100644 --- a/docker/base-app/ubuntu-15.10/Dockerfile +++ b/docker/base-app/ubuntu-15.10/Dockerfile @@ -5,29 +5,17 @@ FROM webdevops/base:ubuntu-15.10 -MAINTAINER info@webdevops.io -LABEL vendor=WebDevOps.io -LABEL io.webdevops.layout=8 -LABEL io.webdevops.version=1.5.0 - -ENV APPLICATION_USER application -ENV APPLICATION_GROUP application -ENV APPLICATION_PATH /app -ENV APPLICATION_UID 1000 -ENV APPLICATION_GID 1000 +ENV APPLICATION_USER=application \ + APPLICATION_GROUP=application \ + APPLICATION_PATH=/app \ + APPLICATION_UID=1000 \ + APPLICATION_GID=1000 COPY conf/ /opt/docker/ # Install services RUN /usr/local/bin/apt-install \ - # Install services - openssh-server \ - mysql-client \ - sqlite \ - dnsmasq \ - postfix \ # Install common tools - sudo \ zip \ unzip \ bzip2 \ @@ -39,10 +27,8 @@ RUN /usr/local/bin/apt-install \ openssh-client \ rsync \ git \ - nano \ - vim \ && mkdir -p /var/lib/syslog-ng/ \ && /usr/local/bin/generate-locales \ && /opt/docker/bin/provision run --tag bootstrap --role webdevops-base-app \ - && /opt/docker/bin/bootstrap.sh - + && /opt/docker/bin/bootstrap.sh \ + && docker-image-cleanup diff --git a/docker/base-app/ubuntu-15.10/Dockerfile.jinja2 b/docker/base-app/ubuntu-15.10/Dockerfile.jinja2 index 35ff82770..37aa2669f 100644 --- a/docker/base-app/ubuntu-15.10/Dockerfile.jinja2 +++ b/docker/base-app/ubuntu-15.10/Dockerfile.jinja2 @@ -1,8 +1,6 @@ {{ docker.from("base", "ubuntu-15.10") }} -{{ docker.version() }} - -{{ environment.app() }} +{{ environment.baseApp() }} {{ docker.copy('conf/', '/opt/docker/') }} diff --git a/docker/base-app/ubuntu-15.10/conf/bin/service.d/postfix.d/10-init.sh b/docker/base-app/ubuntu-15.10/conf/bin/service.d/postfix.d/10-init.sh deleted file mode 100644 index 7a604874f..000000000 --- a/docker/base-app/ubuntu-15.10/conf/bin/service.d/postfix.d/10-init.sh +++ /dev/null @@ -1,24 +0,0 @@ -# force new copy of hosts there (otherwise links could be outdated) -mkdir -p /var/spool/postfix/etc -cp -f /etc/hosts /var/spool/postfix/etc/hosts -cp -f /etc/resolv.conf /var/spool/postfix/etc/resolv.conf -cp -f /etc/services /var/spool/postfix/etc/services - -## MYHOSTNAME -# replace line -sed -i '/myhostname[ ]* =/c\' main.cf -echo "myhostname = $(hostname)" >> /etc/postfix/main.cf - -## REPLAYHOST -if [[ -n "${POSTFIX_RELAYHOST+x}" ]]; then - # replace line - sed -i '/relayhost[ ]* =/c\' main.cf - echo "relayhost = $POSTFIX_RELAYHOST" >> /etc/postfix/main.cf -fi - -## MYNETWORKS -if [[ -n "${POSTFIX_MYNETWORKS+x}" ]]; then - # replace line - sed -i '/mynetworks[ ]* =/c\' main.cf - echo "mynetworks = $POSTFIX_MYNETWORKS" >> /etc/postfix/main.cf -fi diff --git a/docker/base-app/ubuntu-15.10/conf/bin/service.d/ssh.d/10-init.sh b/docker/base-app/ubuntu-15.10/conf/bin/service.d/ssh.d/10-init.sh deleted file mode 100644 index e3192fe01..000000000 --- a/docker/base-app/ubuntu-15.10/conf/bin/service.d/ssh.d/10-init.sh +++ /dev/null @@ -1,2 +0,0 @@ -# generate host keys -ssh-keygen -A diff --git a/docker/base-app/ubuntu-15.10/conf/etc/supervisor.d/dnsmasq.conf b/docker/base-app/ubuntu-15.10/conf/etc/supervisor.d/dnsmasq.conf deleted file mode 100644 index a0ad2de88..000000000 --- a/docker/base-app/ubuntu-15.10/conf/etc/supervisor.d/dnsmasq.conf +++ /dev/null @@ -1,14 +0,0 @@ -[group:dnsmasq] -programs=dnsmasqd -priority=15 - -[program:dnsmasqd] -command = /opt/docker/bin/service.d/dnsmasq.sh -process_name=%(program_name)s -startsecs = 0 -autostart = true -autorestart = true -stdout_logfile=/dev/stdout -stdout_logfile_maxbytes=0 -stderr_logfile=/dev/stderr -stderr_logfile_maxbytes=0 diff --git a/docker/base-app/ubuntu-15.10/conf/provision/roles/webdevops-base-app/tasks/bootstrap.yml b/docker/base-app/ubuntu-15.10/conf/provision/roles/webdevops-base-app/tasks/bootstrap.yml index ea9e54682..3fdce9a74 100644 --- a/docker/base-app/ubuntu-15.10/conf/provision/roles/webdevops-base-app/tasks/bootstrap.yml +++ b/docker/base-app/ubuntu-15.10/conf/provision/roles/webdevops-base-app/tasks/bootstrap.yml @@ -2,6 +2,3 @@ - include: bootstrap/user.yml - include: bootstrap/application.yml -- include: bootstrap/dnsmasq.yml -- include: bootstrap/postfix.yml -- include: bootstrap/ssh.yml diff --git a/docker/base-app/ubuntu-15.10/conf/provision/roles/webdevops-base-app/tasks/bootstrap/dnsmasq.yml b/docker/base-app/ubuntu-15.10/conf/provision/roles/webdevops-base-app/tasks/bootstrap/dnsmasq.yml deleted file mode 100644 index 962a7953a..000000000 --- a/docker/base-app/ubuntu-15.10/conf/provision/roles/webdevops-base-app/tasks/bootstrap/dnsmasq.yml +++ /dev/null @@ -1,10 +0,0 @@ ---- - -- name: Configure dnsmasq - lineinfile: - dest: /etc/dnsmasq.conf - regexp: '^[\s]*{{ item.key }}[\s]*=' - line: '{{ item.key }}={{ item.value }}' - with_items: - - { key: 'user', value: 'root' } - - { key: 'conf-dir', value: '/etc/dnsmasq.d' } diff --git a/docker/base-app/ubuntu-15.10/conf/provision/roles/webdevops-base-app/tasks/bootstrap/postfix.yml b/docker/base-app/ubuntu-15.10/conf/provision/roles/webdevops-base-app/tasks/bootstrap/postfix.yml deleted file mode 100644 index f05ff660c..000000000 --- a/docker/base-app/ubuntu-15.10/conf/provision/roles/webdevops-base-app/tasks/bootstrap/postfix.yml +++ /dev/null @@ -1,29 +0,0 @@ ---- - -- name: Link aliases file to postfix aliases - file: - src: '/etc/postfix/aliases' - dest: '/etc/aliases' - state: link - force: yes - when: ansible_os_family == 'Alpine' - -- name: Configure postfix - lineinfile: - dest: /etc/postfix/main.cf - regexp: '^[\s]*{{ item.key }}[\s]*=' - line: '{{ item.key }}={{ item.value }}' - with_items: - - { key: 'mydestination', value: '' } - - { key: 'message_size_limit', value: '15240000' } - # Hardening - - { key: 'smtp_use_tls', value: 'yes' } - - { key: 'smtp_tls_security_level', value: 'may' } - -- name: Remove dynamic configuration for postfix - lineinfile: - dest: /etc/postfix/main.cf - regexp: '^[\s]*{{ item }}[\s]*=' - state: absent - with_items: - - 'myhostname' diff --git a/docker/base-app/ubuntu-15.10/conf/provision/roles/webdevops-base-app/tasks/bootstrap/ssh.yml b/docker/base-app/ubuntu-15.10/conf/provision/roles/webdevops-base-app/tasks/bootstrap/ssh.yml deleted file mode 100644 index a69c72633..000000000 --- a/docker/base-app/ubuntu-15.10/conf/provision/roles/webdevops-base-app/tasks/bootstrap/ssh.yml +++ /dev/null @@ -1,12 +0,0 @@ ---- - -- name: Init ssh privilege separation directory - file: - path: "/var/run/sshd" - state: directory - mode: 0755 - owner: "root" - group: "root" - recurse: yes - - diff --git a/docker/base-app/ubuntu-15.10/conf/provision/roles/webdevops-base-app/tasks/bootstrap/user.yml b/docker/base-app/ubuntu-15.10/conf/provision/roles/webdevops-base-app/tasks/bootstrap/user.yml index cf6968a01..fd58b329f 100644 --- a/docker/base-app/ubuntu-15.10/conf/provision/roles/webdevops-base-app/tasks/bootstrap/user.yml +++ b/docker/base-app/ubuntu-15.10/conf/provision/roles/webdevops-base-app/tasks/bootstrap/user.yml @@ -1,11 +1,5 @@ --- -- name: Move dnsmasq group (Alpine family) - group: - name: dnsmasq - gid: 153 - when: ansible_distribution == 'Alpine' - - name: Create application group group: name: "{{ APPLICATION_GROUP }}" diff --git a/docker/base-app/ubuntu-16.04/Dockerfile b/docker/base-app/ubuntu-16.04/Dockerfile index 54ef72a04..dda43786c 100644 --- a/docker/base-app/ubuntu-16.04/Dockerfile +++ b/docker/base-app/ubuntu-16.04/Dockerfile @@ -5,29 +5,17 @@ FROM webdevops/base:ubuntu-16.04 -MAINTAINER info@webdevops.io -LABEL vendor=WebDevOps.io -LABEL io.webdevops.layout=8 -LABEL io.webdevops.version=1.5.0 - -ENV APPLICATION_USER application -ENV APPLICATION_GROUP application -ENV APPLICATION_PATH /app -ENV APPLICATION_UID 1000 -ENV APPLICATION_GID 1000 +ENV APPLICATION_USER=application \ + APPLICATION_GROUP=application \ + APPLICATION_PATH=/app \ + APPLICATION_UID=1000 \ + APPLICATION_GID=1000 COPY conf/ /opt/docker/ # Install services RUN /usr/local/bin/apt-install \ - # Install services - openssh-server \ - mysql-client \ - sqlite \ - dnsmasq \ - postfix \ # Install common tools - sudo \ zip \ unzip \ bzip2 \ @@ -39,10 +27,8 @@ RUN /usr/local/bin/apt-install \ openssh-client \ rsync \ git \ - nano \ - vim \ && mkdir -p /var/lib/syslog-ng/ \ && /usr/local/bin/generate-locales \ && /opt/docker/bin/provision run --tag bootstrap --role webdevops-base-app \ - && /opt/docker/bin/bootstrap.sh - + && /opt/docker/bin/bootstrap.sh \ + && docker-image-cleanup diff --git a/docker/base-app/ubuntu-16.04/Dockerfile.jinja2 b/docker/base-app/ubuntu-16.04/Dockerfile.jinja2 index 6aeaa7f4c..a8a6affb6 100644 --- a/docker/base-app/ubuntu-16.04/Dockerfile.jinja2 +++ b/docker/base-app/ubuntu-16.04/Dockerfile.jinja2 @@ -1,8 +1,6 @@ {{ docker.from("base", "ubuntu-16.04") }} -{{ docker.version() }} - -{{ environment.app() }} +{{ environment.baseApp() }} {{ docker.copy('conf/', '/opt/docker/') }} diff --git a/docker/base-app/ubuntu-16.04/conf/bin/service.d/postfix.d/10-init.sh b/docker/base-app/ubuntu-16.04/conf/bin/service.d/postfix.d/10-init.sh deleted file mode 100644 index 7a604874f..000000000 --- a/docker/base-app/ubuntu-16.04/conf/bin/service.d/postfix.d/10-init.sh +++ /dev/null @@ -1,24 +0,0 @@ -# force new copy of hosts there (otherwise links could be outdated) -mkdir -p /var/spool/postfix/etc -cp -f /etc/hosts /var/spool/postfix/etc/hosts -cp -f /etc/resolv.conf /var/spool/postfix/etc/resolv.conf -cp -f /etc/services /var/spool/postfix/etc/services - -## MYHOSTNAME -# replace line -sed -i '/myhostname[ ]* =/c\' main.cf -echo "myhostname = $(hostname)" >> /etc/postfix/main.cf - -## REPLAYHOST -if [[ -n "${POSTFIX_RELAYHOST+x}" ]]; then - # replace line - sed -i '/relayhost[ ]* =/c\' main.cf - echo "relayhost = $POSTFIX_RELAYHOST" >> /etc/postfix/main.cf -fi - -## MYNETWORKS -if [[ -n "${POSTFIX_MYNETWORKS+x}" ]]; then - # replace line - sed -i '/mynetworks[ ]* =/c\' main.cf - echo "mynetworks = $POSTFIX_MYNETWORKS" >> /etc/postfix/main.cf -fi diff --git a/docker/base-app/ubuntu-16.04/conf/bin/service.d/ssh.d/10-init.sh b/docker/base-app/ubuntu-16.04/conf/bin/service.d/ssh.d/10-init.sh deleted file mode 100644 index e3192fe01..000000000 --- a/docker/base-app/ubuntu-16.04/conf/bin/service.d/ssh.d/10-init.sh +++ /dev/null @@ -1,2 +0,0 @@ -# generate host keys -ssh-keygen -A diff --git a/docker/base-app/ubuntu-16.04/conf/etc/supervisor.d/dnsmasq.conf b/docker/base-app/ubuntu-16.04/conf/etc/supervisor.d/dnsmasq.conf deleted file mode 100644 index a0ad2de88..000000000 --- a/docker/base-app/ubuntu-16.04/conf/etc/supervisor.d/dnsmasq.conf +++ /dev/null @@ -1,14 +0,0 @@ -[group:dnsmasq] -programs=dnsmasqd -priority=15 - -[program:dnsmasqd] -command = /opt/docker/bin/service.d/dnsmasq.sh -process_name=%(program_name)s -startsecs = 0 -autostart = true -autorestart = true -stdout_logfile=/dev/stdout -stdout_logfile_maxbytes=0 -stderr_logfile=/dev/stderr -stderr_logfile_maxbytes=0 diff --git a/docker/base-app/ubuntu-16.04/conf/provision/roles/webdevops-base-app/tasks/bootstrap.yml b/docker/base-app/ubuntu-16.04/conf/provision/roles/webdevops-base-app/tasks/bootstrap.yml index ea9e54682..3fdce9a74 100644 --- a/docker/base-app/ubuntu-16.04/conf/provision/roles/webdevops-base-app/tasks/bootstrap.yml +++ b/docker/base-app/ubuntu-16.04/conf/provision/roles/webdevops-base-app/tasks/bootstrap.yml @@ -2,6 +2,3 @@ - include: bootstrap/user.yml - include: bootstrap/application.yml -- include: bootstrap/dnsmasq.yml -- include: bootstrap/postfix.yml -- include: bootstrap/ssh.yml diff --git a/docker/base-app/ubuntu-16.04/conf/provision/roles/webdevops-base-app/tasks/bootstrap/dnsmasq.yml b/docker/base-app/ubuntu-16.04/conf/provision/roles/webdevops-base-app/tasks/bootstrap/dnsmasq.yml deleted file mode 100644 index 962a7953a..000000000 --- a/docker/base-app/ubuntu-16.04/conf/provision/roles/webdevops-base-app/tasks/bootstrap/dnsmasq.yml +++ /dev/null @@ -1,10 +0,0 @@ ---- - -- name: Configure dnsmasq - lineinfile: - dest: /etc/dnsmasq.conf - regexp: '^[\s]*{{ item.key }}[\s]*=' - line: '{{ item.key }}={{ item.value }}' - with_items: - - { key: 'user', value: 'root' } - - { key: 'conf-dir', value: '/etc/dnsmasq.d' } diff --git a/docker/base-app/ubuntu-16.04/conf/provision/roles/webdevops-base-app/tasks/bootstrap/postfix.yml b/docker/base-app/ubuntu-16.04/conf/provision/roles/webdevops-base-app/tasks/bootstrap/postfix.yml deleted file mode 100644 index f05ff660c..000000000 --- a/docker/base-app/ubuntu-16.04/conf/provision/roles/webdevops-base-app/tasks/bootstrap/postfix.yml +++ /dev/null @@ -1,29 +0,0 @@ ---- - -- name: Link aliases file to postfix aliases - file: - src: '/etc/postfix/aliases' - dest: '/etc/aliases' - state: link - force: yes - when: ansible_os_family == 'Alpine' - -- name: Configure postfix - lineinfile: - dest: /etc/postfix/main.cf - regexp: '^[\s]*{{ item.key }}[\s]*=' - line: '{{ item.key }}={{ item.value }}' - with_items: - - { key: 'mydestination', value: '' } - - { key: 'message_size_limit', value: '15240000' } - # Hardening - - { key: 'smtp_use_tls', value: 'yes' } - - { key: 'smtp_tls_security_level', value: 'may' } - -- name: Remove dynamic configuration for postfix - lineinfile: - dest: /etc/postfix/main.cf - regexp: '^[\s]*{{ item }}[\s]*=' - state: absent - with_items: - - 'myhostname' diff --git a/docker/base-app/ubuntu-16.04/conf/provision/roles/webdevops-base-app/tasks/bootstrap/ssh.yml b/docker/base-app/ubuntu-16.04/conf/provision/roles/webdevops-base-app/tasks/bootstrap/ssh.yml deleted file mode 100644 index a69c72633..000000000 --- a/docker/base-app/ubuntu-16.04/conf/provision/roles/webdevops-base-app/tasks/bootstrap/ssh.yml +++ /dev/null @@ -1,12 +0,0 @@ ---- - -- name: Init ssh privilege separation directory - file: - path: "/var/run/sshd" - state: directory - mode: 0755 - owner: "root" - group: "root" - recurse: yes - - diff --git a/docker/base-app/ubuntu-16.04/conf/provision/roles/webdevops-base-app/tasks/bootstrap/user.yml b/docker/base-app/ubuntu-16.04/conf/provision/roles/webdevops-base-app/tasks/bootstrap/user.yml index cf6968a01..fd58b329f 100644 --- a/docker/base-app/ubuntu-16.04/conf/provision/roles/webdevops-base-app/tasks/bootstrap/user.yml +++ b/docker/base-app/ubuntu-16.04/conf/provision/roles/webdevops-base-app/tasks/bootstrap/user.yml @@ -1,11 +1,5 @@ --- -- name: Move dnsmasq group (Alpine family) - group: - name: dnsmasq - gid: 153 - when: ansible_distribution == 'Alpine' - - name: Create application group group: name: "{{ APPLICATION_GROUP }}" diff --git a/docker/base-app/ubuntu-16.10/Dockerfile b/docker/base-app/ubuntu-16.10/Dockerfile index 0f3b005ba..b729fda59 100644 --- a/docker/base-app/ubuntu-16.10/Dockerfile +++ b/docker/base-app/ubuntu-16.10/Dockerfile @@ -5,29 +5,17 @@ FROM webdevops/base:ubuntu-16.10 -MAINTAINER info@webdevops.io -LABEL vendor=WebDevOps.io -LABEL io.webdevops.layout=8 -LABEL io.webdevops.version=1.5.0 - -ENV APPLICATION_USER application -ENV APPLICATION_GROUP application -ENV APPLICATION_PATH /app -ENV APPLICATION_UID 1000 -ENV APPLICATION_GID 1000 +ENV APPLICATION_USER=application \ + APPLICATION_GROUP=application \ + APPLICATION_PATH=/app \ + APPLICATION_UID=1000 \ + APPLICATION_GID=1000 COPY conf/ /opt/docker/ # Install services RUN /usr/local/bin/apt-install \ - # Install services - openssh-server \ - mysql-client \ - sqlite \ - dnsmasq \ - postfix \ # Install common tools - sudo \ zip \ unzip \ bzip2 \ @@ -39,10 +27,8 @@ RUN /usr/local/bin/apt-install \ openssh-client \ rsync \ git \ - nano \ - vim \ && mkdir -p /var/lib/syslog-ng/ \ && /usr/local/bin/generate-locales \ && /opt/docker/bin/provision run --tag bootstrap --role webdevops-base-app \ - && /opt/docker/bin/bootstrap.sh - + && /opt/docker/bin/bootstrap.sh \ + && docker-image-cleanup diff --git a/docker/base-app/ubuntu-16.10/Dockerfile.jinja2 b/docker/base-app/ubuntu-16.10/Dockerfile.jinja2 index b82f21ea3..b32493033 100644 --- a/docker/base-app/ubuntu-16.10/Dockerfile.jinja2 +++ b/docker/base-app/ubuntu-16.10/Dockerfile.jinja2 @@ -1,8 +1,6 @@ {{ docker.from("base", "ubuntu-16.10") }} -{{ docker.version() }} - -{{ environment.app() }} +{{ environment.baseApp() }} {{ docker.copy('conf/', '/opt/docker/') }} diff --git a/docker/base-app/ubuntu-16.10/conf/bin/service.d/postfix.d/10-init.sh b/docker/base-app/ubuntu-16.10/conf/bin/service.d/postfix.d/10-init.sh deleted file mode 100644 index 7a604874f..000000000 --- a/docker/base-app/ubuntu-16.10/conf/bin/service.d/postfix.d/10-init.sh +++ /dev/null @@ -1,24 +0,0 @@ -# force new copy of hosts there (otherwise links could be outdated) -mkdir -p /var/spool/postfix/etc -cp -f /etc/hosts /var/spool/postfix/etc/hosts -cp -f /etc/resolv.conf /var/spool/postfix/etc/resolv.conf -cp -f /etc/services /var/spool/postfix/etc/services - -## MYHOSTNAME -# replace line -sed -i '/myhostname[ ]* =/c\' main.cf -echo "myhostname = $(hostname)" >> /etc/postfix/main.cf - -## REPLAYHOST -if [[ -n "${POSTFIX_RELAYHOST+x}" ]]; then - # replace line - sed -i '/relayhost[ ]* =/c\' main.cf - echo "relayhost = $POSTFIX_RELAYHOST" >> /etc/postfix/main.cf -fi - -## MYNETWORKS -if [[ -n "${POSTFIX_MYNETWORKS+x}" ]]; then - # replace line - sed -i '/mynetworks[ ]* =/c\' main.cf - echo "mynetworks = $POSTFIX_MYNETWORKS" >> /etc/postfix/main.cf -fi diff --git a/docker/base-app/ubuntu-16.10/conf/bin/service.d/ssh.d/10-init.sh b/docker/base-app/ubuntu-16.10/conf/bin/service.d/ssh.d/10-init.sh deleted file mode 100644 index e3192fe01..000000000 --- a/docker/base-app/ubuntu-16.10/conf/bin/service.d/ssh.d/10-init.sh +++ /dev/null @@ -1,2 +0,0 @@ -# generate host keys -ssh-keygen -A diff --git a/docker/base-app/ubuntu-16.10/conf/etc/supervisor.d/dnsmasq.conf b/docker/base-app/ubuntu-16.10/conf/etc/supervisor.d/dnsmasq.conf deleted file mode 100644 index a0ad2de88..000000000 --- a/docker/base-app/ubuntu-16.10/conf/etc/supervisor.d/dnsmasq.conf +++ /dev/null @@ -1,14 +0,0 @@ -[group:dnsmasq] -programs=dnsmasqd -priority=15 - -[program:dnsmasqd] -command = /opt/docker/bin/service.d/dnsmasq.sh -process_name=%(program_name)s -startsecs = 0 -autostart = true -autorestart = true -stdout_logfile=/dev/stdout -stdout_logfile_maxbytes=0 -stderr_logfile=/dev/stderr -stderr_logfile_maxbytes=0 diff --git a/docker/base-app/ubuntu-16.10/conf/provision/roles/webdevops-base-app/tasks/bootstrap.yml b/docker/base-app/ubuntu-16.10/conf/provision/roles/webdevops-base-app/tasks/bootstrap.yml index ea9e54682..3fdce9a74 100644 --- a/docker/base-app/ubuntu-16.10/conf/provision/roles/webdevops-base-app/tasks/bootstrap.yml +++ b/docker/base-app/ubuntu-16.10/conf/provision/roles/webdevops-base-app/tasks/bootstrap.yml @@ -2,6 +2,3 @@ - include: bootstrap/user.yml - include: bootstrap/application.yml -- include: bootstrap/dnsmasq.yml -- include: bootstrap/postfix.yml -- include: bootstrap/ssh.yml diff --git a/docker/base-app/ubuntu-16.10/conf/provision/roles/webdevops-base-app/tasks/bootstrap/dnsmasq.yml b/docker/base-app/ubuntu-16.10/conf/provision/roles/webdevops-base-app/tasks/bootstrap/dnsmasq.yml deleted file mode 100644 index 962a7953a..000000000 --- a/docker/base-app/ubuntu-16.10/conf/provision/roles/webdevops-base-app/tasks/bootstrap/dnsmasq.yml +++ /dev/null @@ -1,10 +0,0 @@ ---- - -- name: Configure dnsmasq - lineinfile: - dest: /etc/dnsmasq.conf - regexp: '^[\s]*{{ item.key }}[\s]*=' - line: '{{ item.key }}={{ item.value }}' - with_items: - - { key: 'user', value: 'root' } - - { key: 'conf-dir', value: '/etc/dnsmasq.d' } diff --git a/docker/base-app/ubuntu-16.10/conf/provision/roles/webdevops-base-app/tasks/bootstrap/postfix.yml b/docker/base-app/ubuntu-16.10/conf/provision/roles/webdevops-base-app/tasks/bootstrap/postfix.yml deleted file mode 100644 index f05ff660c..000000000 --- a/docker/base-app/ubuntu-16.10/conf/provision/roles/webdevops-base-app/tasks/bootstrap/postfix.yml +++ /dev/null @@ -1,29 +0,0 @@ ---- - -- name: Link aliases file to postfix aliases - file: - src: '/etc/postfix/aliases' - dest: '/etc/aliases' - state: link - force: yes - when: ansible_os_family == 'Alpine' - -- name: Configure postfix - lineinfile: - dest: /etc/postfix/main.cf - regexp: '^[\s]*{{ item.key }}[\s]*=' - line: '{{ item.key }}={{ item.value }}' - with_items: - - { key: 'mydestination', value: '' } - - { key: 'message_size_limit', value: '15240000' } - # Hardening - - { key: 'smtp_use_tls', value: 'yes' } - - { key: 'smtp_tls_security_level', value: 'may' } - -- name: Remove dynamic configuration for postfix - lineinfile: - dest: /etc/postfix/main.cf - regexp: '^[\s]*{{ item }}[\s]*=' - state: absent - with_items: - - 'myhostname' diff --git a/docker/base-app/ubuntu-16.10/conf/provision/roles/webdevops-base-app/tasks/bootstrap/ssh.yml b/docker/base-app/ubuntu-16.10/conf/provision/roles/webdevops-base-app/tasks/bootstrap/ssh.yml deleted file mode 100644 index a69c72633..000000000 --- a/docker/base-app/ubuntu-16.10/conf/provision/roles/webdevops-base-app/tasks/bootstrap/ssh.yml +++ /dev/null @@ -1,12 +0,0 @@ ---- - -- name: Init ssh privilege separation directory - file: - path: "/var/run/sshd" - state: directory - mode: 0755 - owner: "root" - group: "root" - recurse: yes - - diff --git a/docker/base-app/ubuntu-16.10/conf/provision/roles/webdevops-base-app/tasks/bootstrap/user.yml b/docker/base-app/ubuntu-16.10/conf/provision/roles/webdevops-base-app/tasks/bootstrap/user.yml index cf6968a01..fd58b329f 100644 --- a/docker/base-app/ubuntu-16.10/conf/provision/roles/webdevops-base-app/tasks/bootstrap/user.yml +++ b/docker/base-app/ubuntu-16.10/conf/provision/roles/webdevops-base-app/tasks/bootstrap/user.yml @@ -1,11 +1,5 @@ --- -- name: Move dnsmasq group (Alpine family) - group: - name: dnsmasq - gid: 153 - when: ansible_distribution == 'Alpine' - - name: Create application group group: name: "{{ APPLICATION_GROUP }}" diff --git a/docker/base/alpine-3 b/docker/base/alpine-3 new file mode 120000 index 000000000..0120374ca --- /dev/null +++ b/docker/base/alpine-3 @@ -0,0 +1 @@ +alpine \ No newline at end of file diff --git a/docker/base/alpine-3/Dockerfile b/docker/base/alpine-3/Dockerfile deleted file mode 100644 index a4c28357f..000000000 --- a/docker/base/alpine-3/Dockerfile +++ /dev/null @@ -1,33 +0,0 @@ -#+++++++++++++++++++++++++++++++++++++++ -# Dockerfile for webdevops/base:alpine-3 -# -- automatically generated -- -#+++++++++++++++++++++++++++++++++++++++ - -FROM webdevops/bootstrap:alpine-3 - -MAINTAINER info@webdevops.io -LABEL vendor=WebDevOps.io -LABEL io.webdevops.layout=8 -LABEL io.webdevops.version=1.5.0 - -ENV DOCKER_CONF_HOME /opt/docker/ - -COPY conf/ /opt/docker/ - -# Install services -RUN chmod +x /opt/docker/bin/* \ - && /usr/local/bin/apk-install \ - supervisor \ - syslog-ng \ - logrotate \ - wget \ - curl \ - sed \ - gnupg \ - && chmod +s /usr/local/bin/gosu \ - && /opt/docker/bin/provision run --tag bootstrap --role webdevops-base \ - && /opt/docker/bin/bootstrap.sh - - -ENTRYPOINT ["/opt/docker/bin/entrypoint.sh"] -CMD ["supervisord"] diff --git a/docker/base/alpine-3/Dockerfile.jinja2 b/docker/base/alpine-3/Dockerfile.jinja2 deleted file mode 100644 index 09a16ecd4..000000000 --- a/docker/base/alpine-3/Dockerfile.jinja2 +++ /dev/null @@ -1,12 +0,0 @@ -{{ docker.from("bootstrap", "alpine-3") }} - -{{ docker.version() }} - -{{ environment.homePath() }} - -{{ docker.copy('conf/', '/opt/docker/') }} - -{{ base.alpine() }} - -{{ docker.entrypoint("/opt/docker/bin/entrypoint.sh") }} -{{ docker.cmd("supervisord") }} diff --git a/docker/base/alpine-3/conf/bin/bootstrap.sh b/docker/base/alpine-3/conf/bin/bootstrap.sh deleted file mode 100644 index 1d1a30f72..000000000 --- a/docker/base/alpine-3/conf/bin/bootstrap.sh +++ /dev/null @@ -1,49 +0,0 @@ -#!/usr/bin/env bash - -BOOTSTRAP_MODE="bootstrap" - -if [ -n "$1" ]; then - BOOTSTRAP_MODE="$1" -fi - -set -o pipefail # trace ERR through pipes -set -o errtrace # trace ERR through 'time command' and other functions -set -o nounset ## set -u : exit the script if you try to use an uninitialised variable -set -o errexit ## set -e : exit the script if any statement returns a non-true return value - -source /opt/docker/bin/config.sh - -rootCheck "$0" - -# Save the buildtime -date +%s > /opt/docker/BUILDTIME - -# Make all scripts executable -find /opt/docker/bin/ -type f -iname '*.sh' -print0 | xargs --no-run-if-empty -0 chmod +x - - -case "$BOOTSTRAP_MODE" in - ################################### - # When container will be build next time - ################################### - "onbuild") - # Init and run bootstrap system - runProvisionOnBuild - ;; - - ################################### - # When container is build this time - ################################### - "bootstrap") - # Init and run bootstrap system - runProvisionBootstrap - runProvisionBuild - ;; - - *) - echo "[ERROR] Bootstrap mode '$BOOTSTRAP_MODE' not defined" - exit 1 - ;; - -esac - diff --git a/docker/base/alpine-3/conf/bin/config.sh b/docker/base/alpine-3/conf/bin/config.sh deleted file mode 100644 index 3155728e8..000000000 --- a/docker/base/alpine-3/conf/bin/config.sh +++ /dev/null @@ -1,166 +0,0 @@ -#!/usr/bin/env bash - -shopt -s nullglob - -### - # Check if current user is root - # - ## -function rootCheck() { - # Root check - if [ "$(/usr/bin/whoami)" != "root" ]; then - echo "[ERROR] $* must be run as root" - exit 1 - fi -} - -### - # Create named pipe - # - # $1 -> name of file - # - ## -function createNamedPipe() { - rm --force -- "$1" - mknod "$1" p -} - -### - # Escape value for sed usage - # - # $1 -> value - # STDOUT -> escaped value - # - ## -function sedEscape() { - echo "$(echo $* |sed -e 's/[]\/$*.^|[]/\\&/g')" -} - -### - # Replace text inside a file - # - # $1 -> source value - # $2 -> target value - # $3 -> path to file - # - ## -function replaceTextInFile() { - SOURCE="$(sedEscape $1)" - REPLACE="$(sedEscape $2)" - TARGET="$3" - - sed -i "s/${SOURCE}/${REPLACE}/" "${TARGET}" -} - - -### - # Include script directory text inside a file - # - # $1 -> path - # - ## -function includeScriptDir() { - if [[ -d "$1" ]]; then - for FILE in "$1"/*.sh; do - # run custom scripts, only once - . "$FILE" - done - fi -} - -### - # Show deprecation notice - # - ## -function deprecationNotice() { - echo "" - echo "###############################################################################" - echo "### THIS CALL IS DEPRECATED AND WILL BE REMOVED IN THE FUTURE" - echo "###" - echo "### $*" - echo "###" - echo "###############################################################################" - echo "" -} - -### - # Run "entrypoint" scripts - ## -function runEntrypoints() { - ############### - # Try to find entrypoint - ############### - - ENTRYPOINT_SCRIPT="/opt/docker/bin/entrypoint.d/${TASK}.sh" - - if [ -f "$ENTRYPOINT_SCRIPT" ]; then - . "$ENTRYPOINT_SCRIPT" - fi - - ############### - # Run default - ############### - if [ -f "/opt/docker/bin/entrypoint.d/default.sh" ]; then - . /opt/docker/bin/entrypoint.d/default.sh - fi - - exit -} - -### - # Run "bootstrap" provisioning - ## -function runProvisionBootstrap() { - for FILE in /opt/docker/provision/bootstrap.d/*.sh; do - # run custom scripts, only once - . "$FILE" - rm -f -- "$FILE" - done - - runDockerProvision bootstrap -} - -### - # Run "build" provisioning - ## -function runProvisionBuild() { - for FILE in /opt/docker/provision/build.d/*.sh; do - # run custom scripts, only once - . "$FILE" - done - - runDockerProvision build -} - -### - # Run "onbuild" provisioning - ## -function runProvisionOnBuild() { - includeScriptDir "/opt/docker/provision/onbuild.d" - - runDockerProvision onbuild -} - -### - # Run "entrypoint" provisioning - ## -function runProvisionEntrypoint() { - includeScriptDir "/opt/docker/provision/entrypoint.d" - includeScriptDir "/entrypoint.d" - - runDockerProvision entrypoint -} - - -### - # Run docker provisioning with dyniamic playbook generation - # - # $1 -> playbook tag (bootstrap, onbuild, entrypoint) - # - ## -function runDockerProvision() { - ANSIBLE_TAG="$1" - - /opt/docker/bin/provision run --tag "$ANSIBLE_TAG" --use-registry -} - diff --git a/docker/base/alpine-3/conf/bin/control.sh b/docker/base/alpine-3/conf/bin/control.sh deleted file mode 100644 index a6697092d..000000000 --- a/docker/base/alpine-3/conf/bin/control.sh +++ /dev/null @@ -1,170 +0,0 @@ -#!/usr/bin/env bash - -set -o pipefail # trace ERR through pipes -set -o errtrace # trace ERR through 'time command' and other functions -set -o nounset ## set -u : exit the script if you try to use an uninitialised variable -set -o errexit ## set -e : exit the script if any statement returns a non-true return value - -source /opt/docker/bin/config.sh - -rootCheck "$0" - -CONTROL_COMMAND="$1" -shift - -case "$CONTROL_COMMAND" in - - ## ------------------------------------------ - ## PROVISION - ## ------------------------------------------ - - ## main roles - "provision.role") - deprecationNotice " Please use >>/opt/docker/bin/provision add --tag bootstrap --tag build --tag onbuild [role]<< for adding provision roles" - /opt/docker/bin/provision add --tag bootstrap --tag build --tag onbuild --tag entrypoint "$1" - ;; - - "provision.role.bootstrap") - deprecationNotice " Please use >>/opt/docker/bin/provision add --tag bootstrap [role]<< for adding provision roles" - /opt/docker/bin/provision add --tag bootstrap "$1" - ;; - - "provision.role.build") - deprecationNotice " Please use >>/opt/docker/bin/provision add --tag build [role]<< for adding provision roles" - /opt/docker/bin/provision add --tag build "$1" - ;; - - "provision.role.onbuild") - deprecationNotice " Please use >>/opt/docker/bin/provision add --tag onbuild [role]<< for adding provision roles" - /opt/docker/bin/provision add --tag onbuild "$1" - ;; - - "provision.role.entrypoint") - deprecationNotice " Please use >>/opt/docker/bin/provision add --tag entrypoint [role]<< for adding provision roles" - /opt/docker/bin/provision add --tag entrypoint "$1" - ;; - - ## startup roles - "provision.role.startup") - deprecationNotice " Please use >>/opt/docker/bin/provision add --tag bootstrap --tag build --tag onbuild --priority 50 [role]<< for adding provision roles" - /opt/docker/bin/provision add --tag bootstrap --tag build --tag onbuild --tag entrypoint --priority 50 "$1" - ;; - - "provision.role.startup.bootstrap") - deprecationNotice " Please use >>/opt/docker/bin/provision add --tag bootstrap --priority 50 [role]<< for adding provision roles" - /opt/docker/bin/provision add --tag bootstrap --priority 50 "$1" - ;; - - "provision.role.startup.build") - deprecationNotice " Please use >>/opt/docker/bin/provision add --tag build --priority 50 [role]<< for adding provision roles" - /opt/docker/bin/provision add --tag build --priority 50 "$1" - ;; - - "provision.role.startup.onbuild") - deprecationNotice " Please use >>/opt/docker/bin/provision add --tag onbuild --priority 50 [role]<< for adding provision roles" - /opt/docker/bin/provision add --tag onbuild --priority 50 "$1" - ;; - - "provision.role.startup.entrypoint") - deprecationNotice " Please use >>/opt/docker/bin/provision add --tag entrypoint --priority 50 [role]<< for adding provision roles" - /opt/docker/bin/provision add --tag entrypoint --priority 50 "$1" - ;; - - ## finish roles - "provision.role.finish") - deprecationNotice " Please use >>/opt/docker/bin/provision add --tag bootstrap --tag build --tag onbuild --priority 200 [role]<< for adding provision roles" - /opt/docker/bin/provision add --tag bootstrap --tag build --tag onbuild --tag entrypoint --priority 200 "$1" - ;; - - "provision.role.finish.bootstrap") - deprecationNotice " Please use >>/opt/docker/bin/provision add --tag bootstrap --priority 200 [role]<< for adding provision roles" - /opt/docker/bin/provision add --tag bootstrap --priority 200 "$1" - ;; - - "provision.role.finish.build") - deprecationNotice " Please use >>/opt/docker/bin/provision add --tag build --priority 200 [role]<< for adding provision roles" - /opt/docker/bin/provision add --tag build --priority 200 "$1" - ;; - - "provision.role.finish.onbuild") - deprecationNotice " Please use >>/opt/docker/bin/provision add --tag onbuild --priority 200 [role]<< for adding provision roles" - /opt/docker/bin/provision add --tag onbuild --priority 200 "$1" - ;; - - "provision.role.finish.entrypoint") - deprecationNotice " Please use >>/opt/docker/bin/provision add --tag entrypoint --priority 200 [role]<< for adding provision roles" - /opt/docker/bin/provision add --tag entrypoint --priority 200 "$1" - ;; - - ## ------------------------------------------ - ## Service - ## ------------------------------------------ - - "service.enable") - SERVICE_FILE="/opt/docker/etc/supervisor.d/$1.conf" - if [ -f "$SERVICE_FILE" ]; then - sed -i '/autostart = /c\autostart = true' -- "$SERVICE_FILE" - else - echo "[ERROR] Service '${1}' not found (tried ${SERVICE_FILE})" - exit 1 - fi - ;; - - "service.disable") - SERVICE_FILE="/opt/docker/etc/supervisor.d/$1.conf" - if [ -f "$SERVICE_FILE" ]; then - sed -i '/autostart = /c\autostart = false' -- "$SERVICE_FILE" - else - echo "[ERROR] Service '${1}' not found (tried ${SERVICE_FILE})" - exit 1 - fi - ;; - - ## ------------------------------------------ - ## Version - ## ------------------------------------------ - - "version.get") - cat /opt/docker/VERSION - ;; - - "version.require.min") - EXPECTED_VERSION="$1" - CURRENT_VERSION="$(cat /opt/docker/VERSION)" - if [ "$CURRENT_VERSION" -lt "$EXPECTED_VERSION" ]; then - echo "-----------------------------------------------------------" - echo "--- This docker image is not up2date!" - echo "--- " - echo "--- Version expected min: $EXPECTED_VERSION" - echo "--- Version current: $CURRENT_VERSION" - echo "--- " - echo "--- Run 'docker pull ' to update image" - echo "-----------------------------------------------------------" - exit 1 - fi - ;; - - "version.require.max") - EXPECTED_VERSION="$1" - CURRENT_VERSION="$(cat /opt/docker/VERSION)" - if [ "$CURRENT_VERSION" -gt "$EXPECTED_VERSION" ]; then - echo "-----------------------------------------------------------" - echo "--- This docker image is too new!" - echo "--- " - echo "--- Version expected max: $EXPECTED_VERSION" - echo "--- Version current: $CURRENT_VERSION" - echo "-----------------------------------------------------------" - exit 1 - fi - ;; - - - "buildtime.get") - cat /opt/docker/BUILDTIME - ;; - - *) - echo "[ERROR] Invalid controll command: \"${CONTROL_COMMAND}\"" - exit 1 - ;; -esac diff --git a/docker/base/alpine-3/conf/bin/entrypoint.d/cli.sh b/docker/base/alpine-3/conf/bin/entrypoint.d/cli.sh deleted file mode 100644 index 2ca68926c..000000000 --- a/docker/base/alpine-3/conf/bin/entrypoint.d/cli.sh +++ /dev/null @@ -1,19 +0,0 @@ -#!/usr/bin/env bash - -############################################# -## Run CLI_SCRIPT from environment variable -############################################# - -if [ -n "${CLI_SCRIPT}" ]; then - if [ -n "$APPLICATION_USER" ]; then - # Run as EFFECTIVE_USER - shift - exec sudo -H -E -u "${APPLICATION_USER}" ${CLI_SCRIPT} "$@" - else - # Run as root - exec ${CLI_SCRIPT} "$@" - fi -else - echo "[ERROR] No CLI_SCRIPT in in docker environment defined" - exit 1 -fi diff --git a/docker/base/alpine-3/conf/bin/entrypoint.d/noop.sh b/docker/base/alpine-3/conf/bin/entrypoint.d/noop.sh deleted file mode 100644 index 967920837..000000000 --- a/docker/base/alpine-3/conf/bin/entrypoint.d/noop.sh +++ /dev/null @@ -1,8 +0,0 @@ -#!/usr/bin/env bash - -############################################# -## NOOP (no operation) -############################################# - -tail -f /dev/null -exit diff --git a/docker/base/alpine-3/conf/bin/entrypoint.d/supervisord.sh b/docker/base/alpine-3/conf/bin/entrypoint.d/supervisord.sh deleted file mode 100644 index ead991551..000000000 --- a/docker/base/alpine-3/conf/bin/entrypoint.d/supervisord.sh +++ /dev/null @@ -1,11 +0,0 @@ -#!/usr/bin/env bash - -############################################# -## Supervisord (start daemons) -############################################# - -rootCheck "supervisord" - -## Start services -exec /opt/docker/bin/service.d/supervisor.sh - diff --git a/docker/base/alpine-3/conf/bin/entrypoint.sh b/docker/base/alpine-3/conf/bin/entrypoint.sh deleted file mode 100644 index bbabcdddb..000000000 --- a/docker/base/alpine-3/conf/bin/entrypoint.sh +++ /dev/null @@ -1,49 +0,0 @@ -#!/usr/bin/env bash - -if [[ -z "$CONTAINER_UID" ]]; then - export CONTAINER_UID="application" -fi - -set -o pipefail # trace ERR through pipes -set -o errtrace # trace ERR through 'time command' and other functions -set -o nounset ## set -u : exit the script if you try to use an uninitialised variable -set -o errexit ## set -e : exit the script if any statement returns a non-true return value - -# auto elevate privileges (if container is not started as root) -if [[ "$UID" -ne 0 ]]; then - export CONTAINER_UID="$UID" - exec gosu root "$0" "$@" -fi -# remove suid bit on gosu -chmod -s /usr/local/bin/gosu - -trap 'echo sigterm ; exit' SIGTERM -trap 'echo sigkill ; exit' SIGKILL - -# link stdout from docker -ln -f -s "/proc/$$/fd/1" /docker.stdout -ln -f -s "/proc/$$/fd/2" /docker.stderr -chmod 600 /docker.stdout /docker.stderr - -# sanitize input and set task -TASK="$(echo $1| sed 's/[^-_a-zA-Z0-9]*//g')" - -source /opt/docker/bin/config.sh - -if [[ "$UID" -eq 0 ]]; then - # Only run provision if user is root - - if [ "$TASK" == "supervisord" -o "$TASK" == "noop" ]; then - # Visible provisioning - runProvisionEntrypoint - else - # Hidden provisioning - runProvisionEntrypoint > /dev/null - fi -fi - -############################# -## COMMAND -############################# - -runEntrypoints "$@" diff --git a/docker/base/alpine-3/conf/bin/logwatch.sh b/docker/base/alpine-3/conf/bin/logwatch.sh deleted file mode 100644 index 1a5b486c7..000000000 --- a/docker/base/alpine-3/conf/bin/logwatch.sh +++ /dev/null @@ -1,14 +0,0 @@ -#!/usr/bin/env bash - -set -o pipefail # trace ERR through pipes -set -o errtrace # trace ERR through 'time command' and other functions -set -o nounset ## set -u : exit the script if you try to use an uninitialised variable -set -o errexit ## set -e : exit the script if any statement returns a non-true return value - -sleep 0.5 - -if [ -p "$2" ]; then - sed --unbuffered -e "s/^/\[$1\] /" -- "$2" -else - tail -n 0 -F -q "$2" | sed --unbuffered -e "s/^/\[$1\] /" -fi diff --git a/docker/base/alpine-3/conf/bin/provision b/docker/base/alpine-3/conf/bin/provision deleted file mode 100755 index f7b5ad0a8..000000000 --- a/docker/base/alpine-3/conf/bin/provision +++ /dev/null @@ -1,327 +0,0 @@ -#!/usr/bin/env python - -import os -import argparse -import json -import sys -from string import Template -from subprocess import call -import tempfile -import time - -STORAGE = '/opt/docker/etc/.registry/provision.json' -PROVISION_DIR = '/opt/docker/provision/' - -PLAYBOOK_TAGS=['bootstrap', 'build', 'onbuild', 'entrypoint'] - -PLAYBOOK = Template( -"""--- - -- hosts: all - vars_files: - - ./variables.yml - roles: - - $roles -""") - - - -def readJson(): - ret = {} - - # create registry directory if it doesn't exists - if not os.path.exists(os.path.dirname(STORAGE)): - os.mkdir(os.path.dirname(STORAGE)) - - # try to read file - if os.path.isfile(STORAGE): - f=open(STORAGE).read() - ret = json.loads(f) - - return ret - - - -def saveJson(data): - with open(STORAGE, 'w') as f: - json.dump(data, f) - - - -def buildRoleList(tags): - json = readJson() - roleList = {} - - # fetch roles list for each tag - for tag in tags: - if tag in json: - for role in json[tag]: - roleRow = json[tag][role] - if role not in roleList: - roleList[role] = {} - - if 'tags' not in roleList[role]: - roleList[role]['tags'] = {} - - roleList[role]['role'] = role - roleList[role]['added'] = roleRow['added'] - roleList[role]['priority'] = roleRow['priority'] - roleList[role]['tags'][tag] = tag - - return roleList - - -def buildSortedRoleList(tags): - roleList = buildRoleList(tags) - - # sort list - roleList = sorted(roleList, key=lambda x: (roleList[x]['priority'], roleList[x]['added'])) - - return roleList - - - -def buildPlaybook(roleList): - ## build playbook - ret = PLAYBOOK.substitute( - roles = "\n - ".join(roleList) - ) - - return ret - - -def buildPlaybookFromArgs(args): - roleList = [] - - ## add roles from tag (if use registry is active) - if args.useRegistry and args.tags: - roleList.extend(buildSortedRoleList(args.tags)) - - ## add roles from command arguments - if args.roles: - for role in args.roles: - roleList.extend(role.split(',')) - - if roleList: - return buildPlaybook(roleList) - else: - return False - - - -def actionRun(args): - if args.playbook: - ## predefined playbook - playbook = args.playbook - else: - ## dynamic playbook - playbookContent = buildPlaybookFromArgs(args) - - if playbookContent: - f = tempfile.NamedTemporaryFile(dir=PROVISION_DIR, prefix='playbook.', suffix='.yml', delete=False) - f.write(playbookContent) - f.close() - playbook = f.name - else: - ## nothing to do - sys.exit(0) - - ## build ansible command with args - cmd = [ - 'ansible-playbook', - playbook, - '-i', 'localhost,', - '--connection=local', - ] - - if args.tags: - cmd.extend([ - '--tags=' + ','.join(args.tags) - ]) - - if args.args: - cmd.extend(args.args) - - ## run ansible - retval = call(cmd) - - ## cleanup dynamic playbook - if not args.playbook: - os.unlink(playbook) - - sys.exit(retval) - - - -def actionPlaybook(args): - playbook = buildPlaybookFromArgs(args) - - if playbook: - print playbook - else: - sys.exit(1) - - - -def actionList(args): - json = readJson() - list = {} - - for tag in args.tags: - if tag in json: - for role in json[tag]: - print role - - - -def actionAdd(args): - json = readJson() - - for tag in args.tags: - for role in args.role: - if tag not in json: - json[tag] = {} - - json[tag][role] = { - 'name': role, - 'added': int(time.time()), - 'priority': args.priority - } - - saveJson(json); - - - -def actionSummary(args): - # list all roles in each possible tag - for tag in PLAYBOOK_TAGS: - roleList = buildRoleList([tag]) - if roleList: - maxLength = len(max(roleList.keys(), key=len)) - - print "Roles in " + tag + ":" - for role in roleList: - print ' - ' + role.ljust(maxLength, ' ') + ' [priority: ' + str(roleList[role]['priority']) + ']' - print '' - - - -def main(args): - actions = { - 'list': actionList, - 'add': actionAdd, - 'summary': actionSummary, - 'playbook': actionPlaybook, - 'run': actionRun - } - - func = actions.get(args.action, lambda: "nothing") - return func(args) - - - - -if __name__ == '__main__': - parser = argparse.ArgumentParser() - subparsers = parser.add_subparsers( - title='subcommands', - dest='action' - ) - - ################################### - ## SUMMARY command - summary = subparsers.add_parser('summary') - - ################################### - ## RUN command - run = subparsers.add_parser('run') - run.add_argument( - '--tag', - dest='tags', - choices=PLAYBOOK_TAGS, - required=True, - action='append', - help='Ansible tag' - ) - run.add_argument( - '--playbook', - dest='playbook', - help='Ansible playbook' - ) - run.add_argument( - '--use-registry', - dest='useRegistry', - action='store_true', - help='Use registred roles' - ) - run.add_argument( - '--role', - dest='roles', - action='append', - help='Ansible role' - ) - run.add_argument('args', nargs=argparse.REMAINDER) - - ################################### - ## PLAYBOOK command - playbook = subparsers.add_parser('playbook') - playbook.add_argument( - '--tag', - dest='tags', - choices=PLAYBOOK_TAGS, - required=True, - action='append', - help='Ansible tag' - ) - playbook.add_argument( - '--use-registry', - dest='useRegistry', - action='store_true', - help='Use registred roles' - ) - playbook.add_argument( - '--role', - dest='roles', - action='append', - help='Ansible tag' - ) - playbook.add_argument('args', nargs=argparse.REMAINDER) - - ################################### - ## LIST command - list = subparsers.add_parser('list') - list.add_argument( - '--tag', - dest='tags', - choices=PLAYBOOK_TAGS, - required=True, - action='append', - help='Ansible tag' - ) - list.add_argument('args', nargs=argparse.REMAINDER) - - ################################### - ## ADD command - add = subparsers.add_parser('add') - add.add_argument( - '--tag', - dest='tags', - choices=PLAYBOOK_TAGS, - required=True, - action='append', - help='Ansible tag' - ) - add.add_argument( - '--priority', - type=int, - default=100, - dest='priority', - help='Priority for role [default 100, 1 is most important]' - ) - add.add_argument('role', metavar='roles', nargs='+', help='Ansible roles') - - add.add_argument('args', nargs=argparse.REMAINDER) - - ## Execute - args = parser.parse_args() - main(args) diff --git a/docker/base/alpine-3/conf/bin/provision.sh b/docker/base/alpine-3/conf/bin/provision.sh deleted file mode 100644 index 4079dd7f0..000000000 --- a/docker/base/alpine-3/conf/bin/provision.sh +++ /dev/null @@ -1,30 +0,0 @@ - #!/usr/bin/env bash - -# -# Example: -# provision.sh /opt/foobar/playbook.yml tag -# -# - -set -o pipefail # trace ERR through pipes -set -o errtrace # trace ERR through 'time command' and other functions -set -o nounset ## set -u : exit the script if you try to use an uninitialised variable -set -o errexit ## set -e : exit the script if any statement returns a non-true return value - -. config.sh - -deprecationNotice " Please use >>/opt/docker/bin/provision run --playbook playbook.yml --tag=bootstrap [args]<< for running provision" - - -if [ "$#" -lt 2 ]; then - echo "[ERROR] $0: Playbook or tag is missing" - exit 1 -fi - -ANSIBLE_PLAYBOOK="$1" -shift -ANSIBLE_TAG="$1" -shift -ANSIBLE_OPTS="$@" - -/opt/docker/bin/provision run --playbook "${ANSIBLE_PLAYBOOK}" --use-registry --tag "${ANSIBLE_TAG}" $ANSIBLE_OPTS diff --git a/docker/base/alpine-3/conf/bin/service.d/syslog-ng.d/10-init.sh b/docker/base/alpine-3/conf/bin/service.d/syslog-ng.d/10-init.sh deleted file mode 100644 index 22621d2ad..000000000 --- a/docker/base/alpine-3/conf/bin/service.d/syslog-ng.d/10-init.sh +++ /dev/null @@ -1,10 +0,0 @@ -# If /dev/log is either a named pipe or it was placed there accidentally, -# e.g. because of the issue documented at https://github.com/phusion/baseimage-docker/pull/25, -# then we remove it. -if [ ! -S /dev/log ]; then rm -f /dev/log; fi -if [ ! -S /var/lib/syslog-ng/syslog-ng.ctl ]; then rm -f /var/lib/syslog-ng/syslog-ng.ctl; fi - -if [[ ! -p /docker.stdout ]]; then - # Switch to file (tty docker mode) - rpl --quiet 'pipe("/docker.stdout")' 'file("/docker.stdout")' -- /opt/docker/etc/syslog-ng/syslog-ng.conf > /dev/null -fi diff --git a/docker/base/alpine-3/conf/etc/supervisor.conf b/docker/base/alpine-3/conf/etc/supervisor.conf deleted file mode 100644 index 14a6223fc..000000000 --- a/docker/base/alpine-3/conf/etc/supervisor.conf +++ /dev/null @@ -1,11 +0,0 @@ -[supervisord] -nodaemon=true - -[unix_http_server] -file = /run/supervisord.sock - -[rpcinterface:supervisor] -supervisor.rpcinterface_factory = supervisor.rpcinterface:make_main_rpcinterface - -[include] -files = /opt/docker/etc/supervisor.d/*.conf diff --git a/docker/base/alpine-3/conf/etc/supervisor.d/syslog-ng.conf b/docker/base/alpine-3/conf/etc/supervisor.d/syslog-ng.conf deleted file mode 100644 index 247fd1a25..000000000 --- a/docker/base/alpine-3/conf/etc/supervisor.d/syslog-ng.conf +++ /dev/null @@ -1,13 +0,0 @@ -[group:syslog] -programs=syslogd -priority=10 - -[program:syslogd] -command = /opt/docker/bin/service.d/syslog-ng.sh -process_name=%(program_name)s -autostart = true -autorestart = true -stdout_logfile=/dev/stdout -stdout_logfile_maxbytes=0 -stderr_logfile=/dev/stderr -stderr_logfile_maxbytes=0 diff --git a/docker/base/alpine-3/conf/provision/roles/webdevops-base/tasks/bootstrap.yml b/docker/base/alpine-3/conf/provision/roles/webdevops-base/tasks/bootstrap.yml deleted file mode 100644 index 30be03c38..000000000 --- a/docker/base/alpine-3/conf/provision/roles/webdevops-base/tasks/bootstrap.yml +++ /dev/null @@ -1,9 +0,0 @@ ---- - -- include: bootstrap/system.yml -- include: bootstrap/misc.yml -- include: bootstrap/root.yml -- include: bootstrap/supervisor.yml -- include: bootstrap/syslog-ng.yml -- include: bootstrap/logrotate.yml -- include: bootstrap/pam.yml diff --git a/docker/base/alpine-3/conf/provision/roles/webdevops-base/tasks/bootstrap/logrotate.yml b/docker/base/alpine-3/conf/provision/roles/webdevops-base/tasks/bootstrap/logrotate.yml deleted file mode 100644 index d87926be2..000000000 --- a/docker/base/alpine-3/conf/provision/roles/webdevops-base/tasks/bootstrap/logrotate.yml +++ /dev/null @@ -1,33 +0,0 @@ ---- - -- name: Configure logrotate running user - lineinfile: - dest: /etc/logrotate.conf - regexp: '^su [-_a-zA-Z0-9]+ [-_a-zA-Z0-9]+' - line: 'su root adm' - -- name: Register logrotate configurations - file: - src: '{{ item }}' - dest: '/etc/logrotate.d/{{ item | basename }}' - state: link - force: yes - with_fileglob: - - /opt/docker/etc/logrotate.d/* - -- name: Remove system logrotates (not needed) - file: - path: '{{ item }}' - state: absent - with_items: - # Debian/Ubuntu - - /etc/cron.daily/logrotate - - /etc/cron.daily/apt-compat - - /etc/cron.daily/dpkg - - /etc/cron.daily/passwd - # RedHat - - /etc/cron.daily/0yum-daily.cron - - /etc/cron.daily/logrotate - - /etc/cron.hourly/0yum-hourly.cron - # Alpine - - /etc/periodic/daily/logrotate diff --git a/docker/base/alpine-3/conf/provision/roles/webdevops-base/tasks/bootstrap/supervisor.yml b/docker/base/alpine-3/conf/provision/roles/webdevops-base/tasks/bootstrap/supervisor.yml deleted file mode 100644 index bda0394b6..000000000 --- a/docker/base/alpine-3/conf/provision/roles/webdevops-base/tasks/bootstrap/supervisor.yml +++ /dev/null @@ -1,6 +0,0 @@ ---- - -- name: Remove /usr/sbin/service - file: - path: '/usr/sbin/service' - state: absent diff --git a/docker/base/alpine-3/conf/provision/roles/webdevops-base/tasks/bootstrap/syslog-ng.yml b/docker/base/alpine-3/conf/provision/roles/webdevops-base/tasks/bootstrap/syslog-ng.yml deleted file mode 100644 index 27c8f6a30..000000000 --- a/docker/base/alpine-3/conf/provision/roles/webdevops-base/tasks/bootstrap/syslog-ng.yml +++ /dev/null @@ -1,33 +0,0 @@ ---- - -- name: Get syslog-ng version - shell: "syslog-ng --version | grep -E -e '^syslog-ng[ ]+[0-9]+\\.[0-9]+' | head -n 1 | awk '{print $2}' | cut -f 1,2 -d ." - register: syslogng_version - -- name: Configure syslog-ng (default) - lineinfile: - dest: /etc/default/syslog-ng - regexp: '^[\s]*{{ item.key }}[\s]*=' - line: '{{ item.key }}="{{ item.value }}"' - create: yes - with_items: - - { key: 'SYSLOGNG_OPTS', value: '--no-caps' } - -- name: Enable syslog-ng config - file: - src: '/opt/docker/etc/syslog-ng/syslog-ng.conf' - dest: '/etc/syslog-ng/syslog-ng.conf' - state: link - force: yes - -- name: Set version of syslog-ng file - lineinfile: - dest: '/etc/syslog-ng/syslog-ng.conf' - regexp: '^@version:' - line: '@version: {{ syslogng_version.stdout }}' - -- name: Ensure /var/lib/syslog-ng exists - file: - path: '/var/lib/syslog-ng' - state: directory - recurse: yes diff --git a/docker/base/alpine-3/conf/provision/roles/webdevops-base/tasks/bootstrap/system.yml b/docker/base/alpine-3/conf/provision/roles/webdevops-base/tasks/bootstrap/system.yml deleted file mode 100644 index 8dfbf9665..000000000 --- a/docker/base/alpine-3/conf/provision/roles/webdevops-base/tasks/bootstrap/system.yml +++ /dev/null @@ -1,16 +0,0 @@ ---- - -- name: Create /entrypoint.d - file: - path: "/entrypoint.d" - state: directory - owner: "root" - group: "root" - mode: 0700 - -- name: Create /entrypoint.cmd - file: - src: '/opt/docker/bin/entrypoint.d' - dest: '/entrypoint.cmd' - state: link - force: yes diff --git a/docker/base/alpine-3/conf/provision/roles/webdevops-base/tasks/build/logrotate.yml b/docker/base/alpine-3/conf/provision/roles/webdevops-base/tasks/build/logrotate.yml deleted file mode 100644 index 10f7e6644..000000000 --- a/docker/base/alpine-3/conf/provision/roles/webdevops-base/tasks/build/logrotate.yml +++ /dev/null @@ -1,10 +0,0 @@ ---- - -- name: Register logrotate configurations - file: - src: '{{ item }}' - dest: '/etc/logrotate.d/{{ item | basename }}' - state: link - force: yes - with_fileglob: - - /opt/docker/etc/logrotate.d/* diff --git a/docker/base/alpine/Dockerfile b/docker/base/alpine/Dockerfile new file mode 100644 index 000000000..da3859e1b --- /dev/null +++ b/docker/base/alpine/Dockerfile @@ -0,0 +1,50 @@ +#+++++++++++++++++++++++++++++++++++++++ +# Dockerfile for webdevops/base:alpine +# -- automatically generated -- +#+++++++++++++++++++++++++++++++++++++++ + +FROM webdevops/bootstrap:alpine + +ENV DOCKER_CONF_HOME=/opt/docker/ \ + LOG_STDOUT="" \ + LOG_STDERR="" + +COPY conf/ /opt/docker/ + +# Install ansible +RUN /usr/local/bin/apk-install \ + python \ + python-dev \ + py-setuptools \ + py-crypto \ + py2-pip \ + py-cparser \ + py-cryptography \ + py-markupsafe \ + py-cffi \ + py-yaml \ + py-jinja2 \ + py-paramiko \ + && pip install --upgrade pip \ + && hash -r \ + && pip install --no-cache-dir ansible \ + && chmod 750 /usr/bin/ansible* \ + # Cleanup + && apk del python-dev \ + && docker-image-cleanup + +# Install services +RUN chmod +x /opt/docker/bin/* \ + && /usr/local/bin/apk-install \ + supervisor \ + wget \ + curl \ + sed \ + gnupg \ + && chmod +s /usr/local/bin/gosu \ + && /opt/docker/bin/provision run --tag bootstrap --role webdevops-base \ + && /opt/docker/bin/bootstrap.sh \ + && docker-image-cleanup + +ENTRYPOINT ["/opt/docker/bin/entrypoint.sh"] +CMD ["supervisord"] diff --git a/docker/base/alpine/Dockerfile.jinja2 b/docker/base/alpine/Dockerfile.jinja2 new file mode 100644 index 000000000..7d9c25585 --- /dev/null +++ b/docker/base/alpine/Dockerfile.jinja2 @@ -0,0 +1,12 @@ +{{ docker.from("bootstrap", "alpine") }} + +{{ environment.base() }} + +{{ docker.copy('conf/', '/opt/docker/') }} + +{{ ansible.alpine() }} + +{{ base.alpine() }} + +{{ docker.entrypoint("/opt/docker/bin/entrypoint.sh") }} +{{ docker.cmd("supervisord") }} diff --git a/docker/base/alpine-3/conf/VERSION b/docker/base/alpine/conf/VERSION similarity index 100% rename from docker/base/alpine-3/conf/VERSION rename to docker/base/alpine/conf/VERSION diff --git a/docker/base/alpine/conf/bin/bootstrap.sh b/docker/base/alpine/conf/bin/bootstrap.sh new file mode 100644 index 000000000..855c10782 --- /dev/null +++ b/docker/base/alpine/conf/bin/bootstrap.sh @@ -0,0 +1,72 @@ +#!/usr/bin/env bash + +BOOTSTRAP_MODE="bootstrap" + +if [ -n "$1" ]; then + BOOTSTRAP_MODE="$1" +fi + +set -o pipefail # trace ERR through pipes +set -o errtrace # trace ERR through 'time command' and other functions +set -o nounset ## set -u : exit the script if you try to use an uninitialised variable +set -o errexit ## set -e : exit the script if any statement returns a non-true return value + +source /opt/docker/bin/config.sh + +rootCheck "$0" + +# Save the buildtime +date +%s > /opt/docker/BUILDTIME +date +%s >/opt/docker/etc/.registry/image_info_buildtime + +# Make all scripts executable +find /opt/docker/bin/ -type f -iname '*.sh' -print0 | xargs --no-run-if-empty -0 chmod +x + +# Enable usr-bin executables +find /opt/docker/bin/usr-bin -type f | while read USR_BIN_FILE; do + chmod +x -- "$USR_BIN_FILE" + ln -n -f -- "$USR_BIN_FILE" "/usr/local/bin/$(basename "$USR_BIN_FILE")" +done + +case "$BOOTSTRAP_MODE" in + ################################### + # When container will be build next time + ################################### + "onbuild") + # Init and run bootstrap system + runProvisionOnBuild + ;; + + ################################### + # When container is build this time + ################################### + "bootstrap") + # Init and run bootstrap system + runProvisionBootstrap + runProvisionBuild + ;; + + *) + echo "[ERROR] Bootstrap mode '$BOOTSTRAP_MODE' not defined" + exit 1 + ;; +esac + + +###################### +# Check if entrypoint provisioning is available +###################### + +echo "Checking provision status..." +for PROVISION_TAG in onbuild build bootstrap entrypoint; do + ROLES=$(docker-provision list --tag "$PROVISION_TAG") + if [[ -n "$ROLES" ]]; then + PROVISION_ROLE_COUNT=$(echo "$ROLES" | wc -l) + echo " - found ${PROVISION_ROLE_COUNT} for provision tag ${PROVISION_TAG}, caching info for execution" + echo -n "$PROVISION_ROLE_COUNT" > "/opt/docker/etc/.registry/provision-availale.${PROVISION_TAG}" + else + echo " - no roles found for provision tag ${PROVISION_TAG}" + echo -n '' > "/opt/docker/etc/.registry/provision-availale.${PROVISION_TAG}" + fi +done + diff --git a/docker/base/alpine/conf/bin/config.sh b/docker/base/alpine/conf/bin/config.sh new file mode 100644 index 000000000..049756c26 --- /dev/null +++ b/docker/base/alpine/conf/bin/config.sh @@ -0,0 +1,151 @@ +#!/usr/bin/env bash + +shopt -s nullglob + +### + # Check if current user is root + # + ## +function rootCheck() { + # Root check + if [ "$(/usr/bin/whoami)" != "root" ]; then + echo "[ERROR] $* must be run as root" + exit 1 + fi +} + +### + # Create /docker.stdout and /docker.stderr + # + ## +function createDockerStdoutStderr() { + # link stdout from docker + if [[ -z "$LOG_STDOUT" ]]; then + LOG_STDOUT="/proc/$$/fd/1" + fi + + if [[ -z "$LOG_STDERR" ]]; then + LOG_STDERR="/proc/$$/fd/2" + fi + + ln -f -s "$LOG_STDOUT" /docker.stdout + ln -f -s "$LOG_STDERR" /docker.stderr + chmod 600 /docker.stdout /docker.stderr +} +### + # Include script directory text inside a file + # + # $1 -> path + # + ## +function includeScriptDir() { + if [[ -d "$1" ]]; then + for FILE in "$1"/*.sh; do + # run custom scripts, only once + . "$FILE" + done + fi +} + +### + # Show deprecation notice + # + ## +function deprecationNotice() { + echo "" + echo "###############################################################################" + echo "### THIS CALL IS DEPRECATED AND WILL BE REMOVED IN THE FUTURE" + echo "###" + echo "### $*" + echo "###" + echo "###############################################################################" + echo "" +} + +### + # Run "entrypoint" scripts + ## +function runEntrypoints() { + ############### + # Try to find entrypoint + ############### + + ENTRYPOINT_SCRIPT="/opt/docker/bin/entrypoint.d/${TASK}.sh" + + if [ -f "$ENTRYPOINT_SCRIPT" ]; then + . "$ENTRYPOINT_SCRIPT" + fi + + ############### + # Run default + ############### + if [ -f "/opt/docker/bin/entrypoint.d/default.sh" ]; then + . /opt/docker/bin/entrypoint.d/default.sh + fi + + exit 1 +} + +### + # Run "bootstrap" provisioning + ## +function runProvisionBootstrap() { + for FILE in /opt/docker/provision/bootstrap.d/*.sh; do + # run custom scripts, only once + . "$FILE" + rm -f -- "$FILE" + done + + runDockerProvision bootstrap +} + +### + # Run "build" provisioning + ## +function runProvisionBuild() { + for FILE in /opt/docker/provision/build.d/*.sh; do + # run custom scripts, only once + . "$FILE" + done + + runDockerProvision build +} + +### + # Run "onbuild" provisioning + ## +function runProvisionOnBuild() { + includeScriptDir "/opt/docker/provision/onbuild.d" + + runDockerProvision onbuild +} + +### + # Run "entrypoint" provisioning + ## +function runProvisionEntrypoint() { + includeScriptDir "/opt/docker/provision/entrypoint.d" + includeScriptDir "/entrypoint.d" + + runDockerProvision entrypoint +} + + +### + # Run docker provisioning with dyniamic playbook generation + # + # $1 -> playbook tag (bootstrap, onbuild, entrypoint) + # + ## +function runDockerProvision() { + ANSIBLE_TAG="$1" + + PROVISION_STATS_FILE="/opt/docker/etc/.registry/provision-stats.${ANSIBLE_TAG}" + + # run provision if stats file doesn't exists (unknown mode) + # or if stats file is not empty + if [[ ! -f "$PROVISION_STATS_FILE" ]] || [[ -s "$PROVISION_STATS_FILE" ]]; then + /opt/docker/bin/provision run --tag "${ANSIBLE_TAG}" --use-registry + fi +} + diff --git a/docker/base/alpine/conf/bin/control.sh b/docker/base/alpine/conf/bin/control.sh new file mode 100644 index 000000000..22d189745 --- /dev/null +++ b/docker/base/alpine/conf/bin/control.sh @@ -0,0 +1,160 @@ +#!/usr/bin/env bash + +set -o pipefail # trace ERR through pipes +set -o errtrace # trace ERR through 'time command' and other functions +set -o nounset ## set -u : exit the script if you try to use an uninitialised variable +set -o errexit ## set -e : exit the script if any statement returns a non-true return value + +source /opt/docker/bin/config.sh + +rootCheck "$0" + +CONTROL_COMMAND="$1" +shift + +case "$CONTROL_COMMAND" in + + ## ------------------------------------------ + ## PROVISION + ## ------------------------------------------ + + ## main roles + "provision.role") + deprecationNotice " Please use >>/opt/docker/bin/provision add --tag bootstrap --tag build --tag onbuild [role]<< for adding provision roles" + /opt/docker/bin/provision add --tag bootstrap --tag build --tag onbuild --tag entrypoint "$1" + ;; + + "provision.role.bootstrap") + deprecationNotice " Please use >>/opt/docker/bin/provision add --tag bootstrap [role]<< for adding provision roles" + /opt/docker/bin/provision add --tag bootstrap "$1" + ;; + + "provision.role.build") + deprecationNotice " Please use >>/opt/docker/bin/provision add --tag build [role]<< for adding provision roles" + /opt/docker/bin/provision add --tag build "$1" + ;; + + "provision.role.onbuild") + deprecationNotice " Please use >>/opt/docker/bin/provision add --tag onbuild [role]<< for adding provision roles" + /opt/docker/bin/provision add --tag onbuild "$1" + ;; + + "provision.role.entrypoint") + deprecationNotice " Please use >>/opt/docker/bin/provision add --tag entrypoint [role]<< for adding provision roles" + /opt/docker/bin/provision add --tag entrypoint "$1" + ;; + + ## startup roles + "provision.role.startup") + deprecationNotice " Please use >>/opt/docker/bin/provision add --tag bootstrap --tag build --tag onbuild --priority 50 [role]<< for adding provision roles" + /opt/docker/bin/provision add --tag bootstrap --tag build --tag onbuild --tag entrypoint --priority 50 "$1" + ;; + + "provision.role.startup.bootstrap") + deprecationNotice " Please use >>/opt/docker/bin/provision add --tag bootstrap --priority 50 [role]<< for adding provision roles" + /opt/docker/bin/provision add --tag bootstrap --priority 50 "$1" + ;; + + "provision.role.startup.build") + deprecationNotice " Please use >>/opt/docker/bin/provision add --tag build --priority 50 [role]<< for adding provision roles" + /opt/docker/bin/provision add --tag build --priority 50 "$1" + ;; + + "provision.role.startup.onbuild") + deprecationNotice " Please use >>/opt/docker/bin/provision add --tag onbuild --priority 50 [role]<< for adding provision roles" + /opt/docker/bin/provision add --tag onbuild --priority 50 "$1" + ;; + + "provision.role.startup.entrypoint") + deprecationNotice " Please use >>/opt/docker/bin/provision add --tag entrypoint --priority 50 [role]<< for adding provision roles" + /opt/docker/bin/provision add --tag entrypoint --priority 50 "$1" + ;; + + ## finish roles + "provision.role.finish") + deprecationNotice " Please use >>/opt/docker/bin/provision add --tag bootstrap --tag build --tag onbuild --priority 200 [role]<< for adding provision roles" + /opt/docker/bin/provision add --tag bootstrap --tag build --tag onbuild --tag entrypoint --priority 200 "$1" + ;; + + "provision.role.finish.bootstrap") + deprecationNotice " Please use >>/opt/docker/bin/provision add --tag bootstrap --priority 200 [role]<< for adding provision roles" + /opt/docker/bin/provision add --tag bootstrap --priority 200 "$1" + ;; + + "provision.role.finish.build") + deprecationNotice " Please use >>/opt/docker/bin/provision add --tag build --priority 200 [role]<< for adding provision roles" + /opt/docker/bin/provision add --tag build --priority 200 "$1" + ;; + + "provision.role.finish.onbuild") + deprecationNotice " Please use >>/opt/docker/bin/provision add --tag onbuild --priority 200 [role]<< for adding provision roles" + /opt/docker/bin/provision add --tag onbuild --priority 200 "$1" + ;; + + "provision.role.finish.entrypoint") + deprecationNotice " Please use >>/opt/docker/bin/provision add --tag entrypoint --priority 200 [role]<< for adding provision roles" + /opt/docker/bin/provision add --tag entrypoint --priority 200 "$1" + ;; + + ## ------------------------------------------ + ## Service + ## ------------------------------------------ + + "service.enable") + deprecationNotice " Please use >>docker-service-enable [service]<<" + docker-service-enable "$1" + ;; + + "service.disable") + deprecationNotice " Please use >>docker-service-disable [service]<<" + docker-service-disable "$1" + ;; + + ## ------------------------------------------ + ## Version + ## ------------------------------------------ + + "version.get") + cat /opt/docker/VERSION + ;; + + "version.require.min") + EXPECTED_VERSION="$1" + CURRENT_VERSION="$(cat /opt/docker/VERSION)" + if [ "$CURRENT_VERSION" -lt "$EXPECTED_VERSION" ]; then + echo "-----------------------------------------------------------" + echo "--- This docker image is not up2date!" + echo "--- " + echo "--- Version expected min: $EXPECTED_VERSION" + echo "--- Version current: $CURRENT_VERSION" + echo "--- " + echo "--- Run 'docker pull ' to update image" + echo "-----------------------------------------------------------" + exit 1 + fi + ;; + + "version.require.max") + EXPECTED_VERSION="$1" + CURRENT_VERSION="$(cat /opt/docker/VERSION)" + if [ "$CURRENT_VERSION" -gt "$EXPECTED_VERSION" ]; then + echo "-----------------------------------------------------------" + echo "--- This docker image is too new!" + echo "--- " + echo "--- Version expected max: $EXPECTED_VERSION" + echo "--- Version current: $CURRENT_VERSION" + echo "-----------------------------------------------------------" + exit 1 + fi + ;; + + + "buildtime.get") + cat /opt/docker/BUILDTIME + ;; + + *) + echo "[ERROR] Invalid controll command: \"${CONTROL_COMMAND}\"" + exit 1 + ;; +esac diff --git a/docker/base/alpine/conf/bin/entrypoint.d/cli.sh b/docker/base/alpine/conf/bin/entrypoint.d/cli.sh new file mode 100644 index 000000000..fe212a8ea --- /dev/null +++ b/docker/base/alpine/conf/bin/entrypoint.d/cli.sh @@ -0,0 +1,19 @@ +#!/usr/bin/env bash + +############################################# +## Run CLI_SCRIPT from environment variable +############################################# + +if [ -n "${CLI_SCRIPT}" ]; then + if [ -n "$APPLICATION_USER" ]; then + # Run as EFFECTIVE_USER + shift + exec gosu "${APPLICATION_USER}" ${CLI_SCRIPT} "$@" + else + # Run as root + exec ${CLI_SCRIPT} "$@" + fi +else + echo "[ERROR] No CLI_SCRIPT in in docker environment defined" + exit 1 +fi diff --git a/docker/base/alpine-3/conf/bin/entrypoint.d/default.sh b/docker/base/alpine/conf/bin/entrypoint.d/default.sh similarity index 100% rename from docker/base/alpine-3/conf/bin/entrypoint.d/default.sh rename to docker/base/alpine/conf/bin/entrypoint.d/default.sh diff --git a/docker/base/alpine/conf/bin/entrypoint.d/noop.sh b/docker/base/alpine/conf/bin/entrypoint.d/noop.sh new file mode 100644 index 000000000..092d55d8b --- /dev/null +++ b/docker/base/alpine/conf/bin/entrypoint.d/noop.sh @@ -0,0 +1,7 @@ +#!/usr/bin/env bash + +############################################# +## NOOP (no operation) +############################################# + +exec tail -f /dev/null diff --git a/docker/base/alpine-3/conf/bin/entrypoint.d/root.sh b/docker/base/alpine/conf/bin/entrypoint.d/root.sh similarity index 100% rename from docker/base/alpine-3/conf/bin/entrypoint.d/root.sh rename to docker/base/alpine/conf/bin/entrypoint.d/root.sh diff --git a/docker/base/alpine/conf/bin/entrypoint.d/supervisord.sh b/docker/base/alpine/conf/bin/entrypoint.d/supervisord.sh new file mode 100644 index 000000000..f21489667 --- /dev/null +++ b/docker/base/alpine/conf/bin/entrypoint.d/supervisord.sh @@ -0,0 +1,9 @@ +#!/usr/bin/env bash + +############################################# +## Supervisord (start daemons) +############################################# + +## Start services +exec /opt/docker/bin/service.d/supervisor.sh + diff --git a/docker/base/alpine/conf/bin/entrypoint.sh b/docker/base/alpine/conf/bin/entrypoint.sh new file mode 100644 index 000000000..01f59660c --- /dev/null +++ b/docker/base/alpine/conf/bin/entrypoint.sh @@ -0,0 +1,46 @@ +#!/usr/bin/env bash + +if [[ -z "$CONTAINER_UID" ]]; then + export CONTAINER_UID="application" +fi + +set -o pipefail # trace ERR through pipes +set -o errtrace # trace ERR through 'time command' and other functions +set -o nounset ## set -u : exit the script if you try to use an uninitialised variable +set -o errexit ## set -e : exit the script if any statement returns a non-true return value + +# auto elevate privileges (if container is not started as root) +if [[ "$UID" -ne 0 ]]; then + export CONTAINER_UID="$UID" + exec gosu root "$0" "$@" +fi +# remove suid bit on gosu +chmod -s /usr/local/bin/gosu + +trap 'echo sigterm ; exit' SIGTERM +trap 'echo sigkill ; exit' SIGKILL + +# sanitize input and set task +TASK="$(echo $1| sed 's/[^-_a-zA-Z0-9]*//g')" + +source /opt/docker/bin/config.sh + +createDockerStdoutStderr + +if [[ "$UID" -eq 0 ]]; then + # Only run provision if user is root + + if [ "$TASK" == "supervisord" -o "$TASK" == "noop" ]; then + # Visible provisioning + runProvisionEntrypoint + else + # Hidden provisioning + runProvisionEntrypoint > /dev/null + fi +fi + +############################# +## COMMAND +############################# + +runEntrypoints "$@" diff --git a/docker/base/alpine/conf/bin/provision b/docker/base/alpine/conf/bin/provision new file mode 100755 index 000000000..d367c2812 --- /dev/null +++ b/docker/base/alpine/conf/bin/provision @@ -0,0 +1,328 @@ +#!/usr/bin/env python + +import os +import argparse +import json +import sys +from string import Template +from subprocess import call +import tempfile +import time + +STORAGE = '/opt/docker/etc/.registry/provision.json' +PROVISION_DIR = '/opt/docker/provision/' + +PLAYBOOK_TAGS=['bootstrap', 'build', 'onbuild', 'entrypoint'] + +PLAYBOOK = Template( +"""--- + +- hosts: all + vars_files: + - ./variables-webdevops.yml + - ./variables.yml + roles: + - $roles +""") + + + +def readJson(): + ret = {} + + # create registry directory if it doesn't exists + if not os.path.exists(os.path.dirname(STORAGE)): + os.mkdir(os.path.dirname(STORAGE)) + + # try to read file + if os.path.isfile(STORAGE): + f=open(STORAGE).read() + ret = json.loads(f) + + return ret + + + +def saveJson(data): + with open(STORAGE, 'w') as f: + json.dump(data, f) + + + +def buildRoleList(tags): + json = readJson() + roleList = {} + + # fetch roles list for each tag + for tag in tags: + if tag in json: + for role in json[tag]: + roleRow = json[tag][role] + if role not in roleList: + roleList[role] = {} + + if 'tags' not in roleList[role]: + roleList[role]['tags'] = {} + + roleList[role]['role'] = role + roleList[role]['added'] = roleRow['added'] + roleList[role]['priority'] = roleRow['priority'] + roleList[role]['tags'][tag] = tag + + return roleList + + +def buildSortedRoleList(tags): + roleList = buildRoleList(tags) + + # sort list + roleList = sorted(roleList, key=lambda x: (roleList[x]['priority'], roleList[x]['added'])) + + return roleList + + + +def buildPlaybook(roleList): + ## build playbook + ret = PLAYBOOK.substitute( + roles = "\n - ".join(roleList) + ) + + return ret + + +def buildPlaybookFromArgs(args): + roleList = [] + + ## add roles from tag (if use registry is active) + if args.useRegistry and args.tags: + roleList.extend(buildSortedRoleList(args.tags)) + + ## add roles from command arguments + if args.roles: + for role in args.roles: + roleList.extend(role.split(',')) + + if roleList: + return buildPlaybook(roleList) + else: + return False + + + +def actionRun(args): + if args.playbook: + ## predefined playbook + playbook = args.playbook + else: + ## dynamic playbook + playbookContent = buildPlaybookFromArgs(args) + + if playbookContent: + f = tempfile.NamedTemporaryFile(dir=PROVISION_DIR, prefix='playbook.', suffix='.yml', delete=False) + f.write(playbookContent) + f.close() + playbook = f.name + else: + ## nothing to do + sys.exit(0) + + ## build ansible command with args + cmd = [ + 'ansible-playbook', + playbook, + '-i', 'localhost,', + '--connection=local', + ] + + if args.tags: + cmd.extend([ + '--tags=' + ','.join(args.tags) + ]) + + if args.args: + cmd.extend(args.args) + + ## run ansible + retval = call(cmd) + + ## cleanup dynamic playbook + if not args.playbook: + os.unlink(playbook) + + sys.exit(retval) + + + +def actionPlaybook(args): + playbook = buildPlaybookFromArgs(args) + + if playbook: + print playbook + else: + sys.exit(1) + + + +def actionList(args): + json = readJson() + list = {} + + for tag in args.tags: + if tag in json: + for role in json[tag]: + print role + + + +def actionAdd(args): + json = readJson() + + for tag in args.tags: + for role in args.role: + if tag not in json: + json[tag] = {} + + json[tag][role] = { + 'name': role, + 'added': int(time.time()), + 'priority': args.priority + } + + saveJson(json) + + + +def actionSummary(args): + # list all roles in each possible tag + for tag in PLAYBOOK_TAGS: + roleList = buildRoleList([tag]) + if roleList: + maxLength = len(max(roleList.keys(), key=len)) + + print "Roles in " + tag + ":" + for role in roleList: + print ' - ' + role.ljust(maxLength, ' ') + ' [priority: ' + str(roleList[role]['priority']) + ']' + print '' + + + +def main(args): + actions = { + 'list': actionList, + 'add': actionAdd, + 'summary': actionSummary, + 'playbook': actionPlaybook, + 'run': actionRun + } + + func = actions.get(args.action, lambda: "nothing") + return func(args) + + + + +if __name__ == '__main__': + parser = argparse.ArgumentParser() + subparsers = parser.add_subparsers( + title='subcommands', + dest='action' + ) + + ################################### + ## SUMMARY command + summary = subparsers.add_parser('summary') + + ################################### + ## RUN command + run = subparsers.add_parser('run') + run.add_argument( + '--tag', + dest='tags', + choices=PLAYBOOK_TAGS, + required=True, + action='append', + help='Ansible tag' + ) + run.add_argument( + '--playbook', + dest='playbook', + help='Ansible playbook' + ) + run.add_argument( + '--use-registry', + dest='useRegistry', + action='store_true', + help='Use registred roles' + ) + run.add_argument( + '--role', + dest='roles', + action='append', + help='Ansible role' + ) + run.add_argument('args', nargs=argparse.REMAINDER) + + ################################### + ## PLAYBOOK command + playbook = subparsers.add_parser('playbook') + playbook.add_argument( + '--tag', + dest='tags', + choices=PLAYBOOK_TAGS, + required=True, + action='append', + help='Ansible tag' + ) + playbook.add_argument( + '--use-registry', + dest='useRegistry', + action='store_true', + help='Use registred roles' + ) + playbook.add_argument( + '--role', + dest='roles', + action='append', + help='Ansible tag' + ) + playbook.add_argument('args', nargs=argparse.REMAINDER) + + ################################### + ## LIST command + list = subparsers.add_parser('list') + list.add_argument( + '--tag', + dest='tags', + choices=PLAYBOOK_TAGS, + required=True, + action='append', + help='Ansible tag' + ) + list.add_argument('args', nargs=argparse.REMAINDER) + + ################################### + ## ADD command + add = subparsers.add_parser('add') + add.add_argument( + '--tag', + dest='tags', + choices=PLAYBOOK_TAGS, + required=True, + action='append', + help='Ansible tag' + ) + add.add_argument( + '--priority', + type=int, + default=100, + dest='priority', + help='Priority for role [default 100, 1 is most important]' + ) + add.add_argument('role', metavar='roles', nargs='+', help='Ansible roles') + + add.add_argument('args', nargs=argparse.REMAINDER) + + ## Execute + args = parser.parse_args() + main(args) diff --git a/docker/base/alpine-3/conf/bin/service.d/cron.d/10-init.sh b/docker/base/alpine/conf/bin/service.d/cron.d/10-init.sh similarity index 100% rename from docker/base/alpine-3/conf/bin/service.d/cron.d/10-init.sh rename to docker/base/alpine/conf/bin/service.d/cron.d/10-init.sh diff --git a/docker/base/alpine-3/conf/bin/service.d/cron.sh b/docker/base/alpine/conf/bin/service.d/cron.sh similarity index 100% rename from docker/base/alpine-3/conf/bin/service.d/cron.sh rename to docker/base/alpine/conf/bin/service.d/cron.sh diff --git a/docker/base-app/alpine-3/conf/bin/service.d/dnsmasq.d/10-init.sh b/docker/base/alpine/conf/bin/service.d/dnsmasq.d/10-init.sh similarity index 100% rename from docker/base-app/alpine-3/conf/bin/service.d/dnsmasq.d/10-init.sh rename to docker/base/alpine/conf/bin/service.d/dnsmasq.d/10-init.sh diff --git a/docker/base-app/alpine-3/conf/bin/service.d/dnsmasq.sh b/docker/base/alpine/conf/bin/service.d/dnsmasq.sh similarity index 100% rename from docker/base-app/alpine-3/conf/bin/service.d/dnsmasq.sh rename to docker/base/alpine/conf/bin/service.d/dnsmasq.sh diff --git a/docker/base/alpine/conf/bin/service.d/postfix.d/10-init.sh b/docker/base/alpine/conf/bin/service.d/postfix.d/10-init.sh new file mode 100644 index 000000000..cfd876955 --- /dev/null +++ b/docker/base/alpine/conf/bin/service.d/postfix.d/10-init.sh @@ -0,0 +1,27 @@ +# force new copy of hosts there (otherwise links could be outdated) +mkdir -p /var/spool/postfix/etc +cp -f /etc/hosts /var/spool/postfix/etc/hosts +cp -f /etc/resolv.conf /var/spool/postfix/etc/resolv.conf +cp -f /etc/services /var/spool/postfix/etc/services + +## MYHOSTNAME +# replace line +sed -i '/myhostname[ ]* =/c\' main.cf +echo "myhostname = $(hostname)" >> /etc/postfix/main.cf + +## REPLAYHOST +if [[ -n "${POSTFIX_RELAYHOST+x}" ]]; then + # replace line + sed -i '/relayhost[ ]* =/c\' main.cf + echo "relayhost = $POSTFIX_RELAYHOST" >> /etc/postfix/main.cf +fi + +## MYNETWORKS +if [[ -n "${POSTFIX_MYNETWORKS+x}" ]]; then + # replace line + sed -i '/mynetworks[ ]* =/c\' main.cf + echo "mynetworks = $POSTFIX_MYNETWORKS" >> /etc/postfix/main.cf +fi + +# generate aliases db +newaliases || : diff --git a/docker/base-app/alpine-3/conf/bin/service.d/postfix.sh b/docker/base/alpine/conf/bin/service.d/postfix.sh similarity index 100% rename from docker/base-app/alpine-3/conf/bin/service.d/postfix.sh rename to docker/base/alpine/conf/bin/service.d/postfix.sh diff --git a/docker/base/alpine/conf/bin/service.d/ssh.d/10-init.sh b/docker/base/alpine/conf/bin/service.d/ssh.d/10-init.sh new file mode 100644 index 000000000..f2b600312 --- /dev/null +++ b/docker/base/alpine/conf/bin/service.d/ssh.d/10-init.sh @@ -0,0 +1,7 @@ +# Init ssh privilege separation directory +mkdir -p /var/run/sshd +chown root:root /var/run/sshd +chmod 755 /var/run/sshd + +# generate host keys +ssh-keygen -A diff --git a/docker/base-app/alpine-3/conf/bin/service.d/ssh.sh b/docker/base/alpine/conf/bin/service.d/ssh.sh similarity index 100% rename from docker/base-app/alpine-3/conf/bin/service.d/ssh.sh rename to docker/base/alpine/conf/bin/service.d/ssh.sh diff --git a/docker/base/alpine-3/conf/bin/service.d/supervisor.d/10-init.sh b/docker/base/alpine/conf/bin/service.d/supervisor.d/10-init.sh similarity index 100% rename from docker/base/alpine-3/conf/bin/service.d/supervisor.d/10-init.sh rename to docker/base/alpine/conf/bin/service.d/supervisor.d/10-init.sh diff --git a/docker/base/alpine-3/conf/bin/service.d/supervisor.sh b/docker/base/alpine/conf/bin/service.d/supervisor.sh similarity index 100% rename from docker/base/alpine-3/conf/bin/service.d/supervisor.sh rename to docker/base/alpine/conf/bin/service.d/supervisor.sh diff --git a/docker/base/alpine/conf/bin/service.d/syslog-ng.d/10-init.sh b/docker/base/alpine/conf/bin/service.d/syslog-ng.d/10-init.sh new file mode 100644 index 000000000..326207e52 --- /dev/null +++ b/docker/base/alpine/conf/bin/service.d/syslog-ng.d/10-init.sh @@ -0,0 +1,10 @@ +# If /dev/log is either a named pipe or it was placed there accidentally, +# e.g. because of the issue documented at https://github.com/phusion/baseimage-docker/pull/25, +# then we remove it. +if [ ! -S /dev/log ]; then rm -f /dev/log; fi +if [ ! -S /var/lib/syslog-ng/syslog-ng.ctl ]; then rm -f /var/lib/syslog-ng/syslog-ng.ctl; fi + +if [[ ! -p /docker.stdout ]]; then + # Switch to file (tty docker mode) + go-replace -s 'pipe("/docker.stdout")' -r 'file("/docker.stdout")' -- /opt/docker/etc/syslog-ng/syslog-ng.conf +fi diff --git a/docker/base/alpine-3/conf/bin/service.d/syslog-ng.sh b/docker/base/alpine/conf/bin/service.d/syslog-ng.sh similarity index 100% rename from docker/base/alpine-3/conf/bin/service.d/syslog-ng.sh rename to docker/base/alpine/conf/bin/service.d/syslog-ng.sh diff --git a/docker/base/alpine/conf/bin/usr-bin/docker-provision b/docker/base/alpine/conf/bin/usr-bin/docker-provision new file mode 100644 index 000000000..4ee715c64 --- /dev/null +++ b/docker/base/alpine/conf/bin/usr-bin/docker-provision @@ -0,0 +1,9 @@ +#!/usr/bin/env bash + +set -o pipefail # trace ERR through pipes +set -o errtrace # trace ERR through 'time command' and other functions +set -o nounset ## set -u : exit the script if you try to use an uninitialised variable +set -o errexit ## set -e : exit the script if any statement returns a non-true return value + +# wrapper +exec /opt/docker/bin/provision "$@" diff --git a/docker/base/alpine/conf/bin/usr-bin/docker-service-disable b/docker/base/alpine/conf/bin/usr-bin/docker-service-disable new file mode 100644 index 000000000..2b5b31bb4 --- /dev/null +++ b/docker/base/alpine/conf/bin/usr-bin/docker-service-disable @@ -0,0 +1,30 @@ +#!/usr/bin/env bash + +set -o pipefail # trace ERR through pipes +set -o errtrace # trace ERR through 'time command' and other functions +set -o nounset ## set -u : exit the script if you try to use an uninitialised variable +set -o errexit ## set -e : exit the script if any statement returns a non-true return value + +source /opt/docker/bin/config.sh + +rootCheck "$0" + +if [[ "$#" -eq 0 ]]; then + echo "Usage: $0 " + exit 1 +fi + +for SERVICE in "$@"; do + SERVICE_FILE="/opt/docker/etc/supervisor.d/${SERVICE}.conf" + + ## Disable service + if [[ -f "$SERVICE_FILE" ]]; then + go-replace --mode=lineinfile \ + -s 'autostart =' -r 'autostart = false' \ + -- "$SERVICE_FILE" + else + echo "[ERROR] Service '${SERVICE}' not found (tried ${SERVICE_FILE})" + exit 1 + fi +done + diff --git a/docker/base/alpine/conf/bin/usr-bin/docker-service-enable b/docker/base/alpine/conf/bin/usr-bin/docker-service-enable new file mode 100644 index 000000000..8d36a14a9 --- /dev/null +++ b/docker/base/alpine/conf/bin/usr-bin/docker-service-enable @@ -0,0 +1,41 @@ +#!/usr/bin/env bash + +set -o pipefail # trace ERR through pipes +set -o errtrace # trace ERR through 'time command' and other functions +set -o nounset ## set -u : exit the script if you try to use an uninitialised variable +set -o errexit ## set -e : exit the script if any statement returns a non-true return value + +source /opt/docker/bin/config.sh + +rootCheck "$0" + +if [[ "$#" -eq 0 ]]; then + echo "Usage: $0 " + exit 1 +fi + +for SERVICE in "$@"; do + SERVICE_FILE="/opt/docker/etc/supervisor.d/${SERVICE}.conf" + PROVISION_FILE="/opt/docker/provision/service.d/${SERVICE}.sh" + + # Run on demand installation/provisioning + if [[ -f "$PROVISION_FILE" ]]; then + echo "Running provisioning for ${SERVICE}, please wait..." + + ## execute scripts + . "$PROVISION_FILE" + + ## remove directory (one run time) + rm -f -- "$PROVISION_FILE" + fi + + ## Enable service + if [[ -f "$SERVICE_FILE" ]]; then + go-replace --mode=lineinfile \ + -s 'autostart =' -r 'autostart = true' \ + -- "$SERVICE_FILE" + else + echo "[ERROR] Service '${SERVICE}' not found (tried ${SERVICE_FILE})" + exit 1 + fi +done diff --git a/baselayout/usr/local/bin/service b/docker/base/alpine/conf/bin/usr-bin/service similarity index 100% rename from baselayout/usr/local/bin/service rename to docker/base/alpine/conf/bin/usr-bin/service diff --git a/docker/base/alpine-3/conf/etc/logrotate.d/syslog-ng b/docker/base/alpine/conf/etc/logrotate.d/syslog-ng similarity index 100% rename from docker/base/alpine-3/conf/etc/logrotate.d/syslog-ng rename to docker/base/alpine/conf/etc/logrotate.d/syslog-ng diff --git a/docker/base/alpine/conf/etc/supervisor.conf b/docker/base/alpine/conf/etc/supervisor.conf new file mode 100644 index 000000000..479e0db08 --- /dev/null +++ b/docker/base/alpine/conf/etc/supervisor.conf @@ -0,0 +1,20 @@ +[supervisord] +nodaemon=true + +[unix_http_server] +file = /.supervisor.sock +chmod = 0700 +chown = root:root +username = root +password = {SHA}e982f17bcbe0f724063b708a4f76db211a999304 + +[supervisorctl] +serverurl = unix:///.supervisor.sock +username = root +password = docker + +[rpcinterface:supervisor] +supervisor.rpcinterface_factory = supervisor.rpcinterface:make_main_rpcinterface + +[include] +files = /opt/docker/etc/supervisor.d/*.conf diff --git a/docker/base/alpine-3/conf/etc/supervisor.d/.gitkeep b/docker/base/alpine/conf/etc/supervisor.d/.gitkeep similarity index 100% rename from docker/base/alpine-3/conf/etc/supervisor.d/.gitkeep rename to docker/base/alpine/conf/etc/supervisor.d/.gitkeep diff --git a/docker/base/alpine-3/conf/etc/supervisor.d/cron.conf b/docker/base/alpine/conf/etc/supervisor.d/cron.conf similarity index 100% rename from docker/base/alpine-3/conf/etc/supervisor.d/cron.conf rename to docker/base/alpine/conf/etc/supervisor.d/cron.conf diff --git a/docker/base/alpine/conf/etc/supervisor.d/dnsmasq.conf b/docker/base/alpine/conf/etc/supervisor.d/dnsmasq.conf new file mode 100644 index 000000000..9832ffca7 --- /dev/null +++ b/docker/base/alpine/conf/etc/supervisor.d/dnsmasq.conf @@ -0,0 +1,14 @@ +[group:dnsmasq] +programs=dnsmasqd +priority=15 + +[program:dnsmasqd] +command = /opt/docker/bin/service.d/dnsmasq.sh +process_name=%(program_name)s +startsecs = 0 +autostart = false +autorestart = true +stdout_logfile=/dev/stdout +stdout_logfile_maxbytes=0 +stderr_logfile=/dev/stderr +stderr_logfile_maxbytes=0 diff --git a/docker/base-app/alpine-3/conf/etc/supervisor.d/postfix.conf b/docker/base/alpine/conf/etc/supervisor.d/postfix.conf similarity index 100% rename from docker/base-app/alpine-3/conf/etc/supervisor.d/postfix.conf rename to docker/base/alpine/conf/etc/supervisor.d/postfix.conf diff --git a/docker/base-app/alpine-3/conf/etc/supervisor.d/ssh.conf b/docker/base/alpine/conf/etc/supervisor.d/ssh.conf similarity index 100% rename from docker/base-app/alpine-3/conf/etc/supervisor.d/ssh.conf rename to docker/base/alpine/conf/etc/supervisor.d/ssh.conf diff --git a/docker/base/alpine/conf/etc/supervisor.d/syslog.conf b/docker/base/alpine/conf/etc/supervisor.d/syslog.conf new file mode 100644 index 000000000..20d1e238c --- /dev/null +++ b/docker/base/alpine/conf/etc/supervisor.d/syslog.conf @@ -0,0 +1,13 @@ +[group:syslog] +programs=syslogd +priority=10 + +[program:syslogd] +command = /opt/docker/bin/service.d/syslog-ng.sh +process_name=%(program_name)s +autostart = false +autorestart = true +stdout_logfile=/dev/stdout +stdout_logfile_maxbytes=0 +stderr_logfile=/dev/stderr +stderr_logfile_maxbytes=0 diff --git a/docker/base/alpine-3/conf/etc/syslog-ng/syslog-ng.conf b/docker/base/alpine/conf/etc/syslog-ng/syslog-ng.conf similarity index 100% rename from docker/base/alpine-3/conf/etc/syslog-ng/syslog-ng.conf rename to docker/base/alpine/conf/etc/syslog-ng/syslog-ng.conf diff --git a/docker/base/alpine-3/conf/provision/ansible.cfg b/docker/base/alpine/conf/provision/ansible.cfg similarity index 100% rename from docker/base/alpine-3/conf/provision/ansible.cfg rename to docker/base/alpine/conf/provision/ansible.cfg diff --git a/docker/base/alpine-3/conf/provision/bootstrap.d/.gitkeep b/docker/base/alpine/conf/provision/bootstrap.d/.gitkeep similarity index 100% rename from docker/base/alpine-3/conf/provision/bootstrap.d/.gitkeep rename to docker/base/alpine/conf/provision/bootstrap.d/.gitkeep diff --git a/docker/base/alpine-3/conf/provision/build.d/.gitkeep b/docker/base/alpine/conf/provision/build.d/.gitkeep similarity index 100% rename from docker/base/alpine-3/conf/provision/build.d/.gitkeep rename to docker/base/alpine/conf/provision/build.d/.gitkeep diff --git a/docker/base/alpine-3/conf/provision/build.d/10-cleanup.sh b/docker/base/alpine/conf/provision/build.d/10-cleanup.sh similarity index 100% rename from docker/base/alpine-3/conf/provision/build.d/10-cleanup.sh rename to docker/base/alpine/conf/provision/build.d/10-cleanup.sh diff --git a/docker/base/alpine-3/conf/provision/entrypoint.d/.gitkeep b/docker/base/alpine/conf/provision/entrypoint.d/.gitkeep similarity index 100% rename from docker/base/alpine-3/conf/provision/entrypoint.d/.gitkeep rename to docker/base/alpine/conf/provision/entrypoint.d/.gitkeep diff --git a/docker/base/alpine-3/conf/provision/entrypoint.d/05-permissions.sh b/docker/base/alpine/conf/provision/entrypoint.d/05-permissions.sh similarity index 100% rename from docker/base/alpine-3/conf/provision/entrypoint.d/05-permissions.sh rename to docker/base/alpine/conf/provision/entrypoint.d/05-permissions.sh diff --git a/docker/base/alpine-3/conf/provision/onbuild.d/.gitkeep b/docker/base/alpine/conf/provision/onbuild.d/.gitkeep similarity index 100% rename from docker/base/alpine-3/conf/provision/onbuild.d/.gitkeep rename to docker/base/alpine/conf/provision/onbuild.d/.gitkeep diff --git a/docker/base/alpine-3/conf/provision/roles/webdevops-base/defaults/main.yml b/docker/base/alpine/conf/provision/roles/webdevops-base/defaults/main.yml similarity index 100% rename from docker/base/alpine-3/conf/provision/roles/webdevops-base/defaults/main.yml rename to docker/base/alpine/conf/provision/roles/webdevops-base/defaults/main.yml diff --git a/docker/base/alpine/conf/provision/roles/webdevops-base/tasks/bootstrap.yml b/docker/base/alpine/conf/provision/roles/webdevops-base/tasks/bootstrap.yml new file mode 100644 index 000000000..9f842336c --- /dev/null +++ b/docker/base/alpine/conf/provision/roles/webdevops-base/tasks/bootstrap.yml @@ -0,0 +1,8 @@ +--- + +- include: bootstrap/system.yml +- include: bootstrap/misc.yml +- include: bootstrap/root.yml +- include: bootstrap/supervisor.yml +- include: bootstrap/pam.yml +- include: bootstrap/entrypoint.yml diff --git a/docker/base/alpine/conf/provision/roles/webdevops-base/tasks/bootstrap/entrypoint.yml b/docker/base/alpine/conf/provision/roles/webdevops-base/tasks/bootstrap/entrypoint.yml new file mode 100644 index 000000000..d5d8809f4 --- /dev/null +++ b/docker/base/alpine/conf/provision/roles/webdevops-base/tasks/bootstrap/entrypoint.yml @@ -0,0 +1,8 @@ +--- + +- name: Create link for entrypoint + file: + src: '/opt/docker/bin/entrypoint.sh' + dest: '/entrypoint' + state: link + force: yes diff --git a/docker/base/alpine-3/conf/provision/roles/webdevops-base/tasks/bootstrap/misc.yml b/docker/base/alpine/conf/provision/roles/webdevops-base/tasks/bootstrap/misc.yml similarity index 100% rename from docker/base/alpine-3/conf/provision/roles/webdevops-base/tasks/bootstrap/misc.yml rename to docker/base/alpine/conf/provision/roles/webdevops-base/tasks/bootstrap/misc.yml diff --git a/docker/base/alpine-3/conf/provision/roles/webdevops-base/tasks/bootstrap/pam.yml b/docker/base/alpine/conf/provision/roles/webdevops-base/tasks/bootstrap/pam.yml similarity index 100% rename from docker/base/alpine-3/conf/provision/roles/webdevops-base/tasks/bootstrap/pam.yml rename to docker/base/alpine/conf/provision/roles/webdevops-base/tasks/bootstrap/pam.yml diff --git a/docker/base/alpine-3/conf/provision/roles/webdevops-base/tasks/bootstrap/root.yml b/docker/base/alpine/conf/provision/roles/webdevops-base/tasks/bootstrap/root.yml similarity index 100% rename from docker/base/alpine-3/conf/provision/roles/webdevops-base/tasks/bootstrap/root.yml rename to docker/base/alpine/conf/provision/roles/webdevops-base/tasks/bootstrap/root.yml diff --git a/docker/base/alpine/conf/provision/roles/webdevops-base/tasks/bootstrap/supervisor.yml b/docker/base/alpine/conf/provision/roles/webdevops-base/tasks/bootstrap/supervisor.yml new file mode 100644 index 000000000..2ce07ac26 --- /dev/null +++ b/docker/base/alpine/conf/provision/roles/webdevops-base/tasks/bootstrap/supervisor.yml @@ -0,0 +1,13 @@ +--- + +- name: Remove /usr/sbin/service + file: + path: '/usr/sbin/service' + state: absent + +- name: Create link for supervisor.conf + file: + src: '/opt/docker/etc/supervisor.conf' + dest: '/etc/supervisord.conf' + state: link + force: yes diff --git a/docker/base/alpine/conf/provision/roles/webdevops-base/tasks/bootstrap/system.yml b/docker/base/alpine/conf/provision/roles/webdevops-base/tasks/bootstrap/system.yml new file mode 100644 index 000000000..0741d7cae --- /dev/null +++ b/docker/base/alpine/conf/provision/roles/webdevops-base/tasks/bootstrap/system.yml @@ -0,0 +1,33 @@ +--- + +- name: Create /entrypoint.d + file: + path: "/entrypoint.d" + state: directory + owner: "root" + group: "root" + mode: 0700 + +- name: Create /entrypoint.cmd + file: + src: '/opt/docker/bin/entrypoint.d' + dest: '/entrypoint.cmd' + state: link + force: yes + +- name: Remove system logrotate and cronjobs (not needed) + file: + path: '{{ item }}' + state: absent + with_items: + # Debian/Ubuntu + - /etc/cron.daily/logrotate + - /etc/cron.daily/apt-compat + - /etc/cron.daily/dpkg + - /etc/cron.daily/passwd + # RedHat + - /etc/cron.daily/0yum-daily.cron + - /etc/cron.daily/logrotate + - /etc/cron.hourly/0yum-hourly.cron + # Alpine + - /etc/periodic/daily/logrotate diff --git a/docker/base/alpine-3/conf/provision/roles/webdevops-base/tasks/build.yml b/docker/base/alpine/conf/provision/roles/webdevops-base/tasks/build.yml similarity index 100% rename from docker/base/alpine-3/conf/provision/roles/webdevops-base/tasks/build.yml rename to docker/base/alpine/conf/provision/roles/webdevops-base/tasks/build.yml diff --git a/docker/base/alpine-3/conf/provision/roles/webdevops-base/tasks/entrypoint/.gitkeep b/docker/base/alpine/conf/provision/roles/webdevops-base/tasks/build/.gitkeep similarity index 100% rename from docker/base/alpine-3/conf/provision/roles/webdevops-base/tasks/entrypoint/.gitkeep rename to docker/base/alpine/conf/provision/roles/webdevops-base/tasks/build/.gitkeep diff --git a/docker/base/alpine-3/conf/provision/roles/webdevops-base/tasks/entrypoint.yml b/docker/base/alpine/conf/provision/roles/webdevops-base/tasks/entrypoint.yml similarity index 100% rename from docker/base/alpine-3/conf/provision/roles/webdevops-base/tasks/entrypoint.yml rename to docker/base/alpine/conf/provision/roles/webdevops-base/tasks/entrypoint.yml diff --git a/docker/nginx-dev/alpine-3/conf/etc/nginx/vhost.common.d/.gitkeep b/docker/base/alpine/conf/provision/roles/webdevops-base/tasks/entrypoint/.gitkeep similarity index 100% rename from docker/nginx-dev/alpine-3/conf/etc/nginx/vhost.common.d/.gitkeep rename to docker/base/alpine/conf/provision/roles/webdevops-base/tasks/entrypoint/.gitkeep diff --git a/docker/base/alpine-3/conf/provision/roles/webdevops-base/tasks/main.yml b/docker/base/alpine/conf/provision/roles/webdevops-base/tasks/main.yml similarity index 100% rename from docker/base/alpine-3/conf/provision/roles/webdevops-base/tasks/main.yml rename to docker/base/alpine/conf/provision/roles/webdevops-base/tasks/main.yml diff --git a/docker/base/alpine-3/conf/provision/roles/webdevops-cleanup/tasks/cleanup.yml b/docker/base/alpine/conf/provision/roles/webdevops-cleanup/tasks/cleanup.yml similarity index 100% rename from docker/base/alpine-3/conf/provision/roles/webdevops-cleanup/tasks/cleanup.yml rename to docker/base/alpine/conf/provision/roles/webdevops-cleanup/tasks/cleanup.yml diff --git a/docker/base/alpine-3/conf/provision/roles/webdevops-cleanup/tasks/main.yml b/docker/base/alpine/conf/provision/roles/webdevops-cleanup/tasks/main.yml similarity index 100% rename from docker/base/alpine-3/conf/provision/roles/webdevops-cleanup/tasks/main.yml rename to docker/base/alpine/conf/provision/roles/webdevops-cleanup/tasks/main.yml diff --git a/docker/nginx/alpine-3/conf/etc/nginx/conf.d/.gitkeep b/docker/base/alpine/conf/provision/service.d/.gitkeep similarity index 100% rename from docker/nginx/alpine-3/conf/etc/nginx/conf.d/.gitkeep rename to docker/base/alpine/conf/provision/service.d/.gitkeep diff --git a/docker/base/alpine/conf/provision/service.d/cron.sh b/docker/base/alpine/conf/provision/service.d/cron.sh new file mode 100644 index 000000000..bd8a54781 --- /dev/null +++ b/docker/base/alpine/conf/provision/service.d/cron.sh @@ -0,0 +1,13 @@ +#!/usr/bin/env bash + +IMAGE_FAMILY=$(docker-image-info family) + +case "$IMAGE_FAMILY" in + Debian|Ubuntu) + apt-install cron + ;; + + RedHat) + yum-install cronie + ;; +esac diff --git a/docker/base/alpine/conf/provision/service.d/dnsmasq.sh b/docker/base/alpine/conf/provision/service.d/dnsmasq.sh new file mode 100644 index 000000000..9e5c3228c --- /dev/null +++ b/docker/base/alpine/conf/provision/service.d/dnsmasq.sh @@ -0,0 +1,24 @@ +#!/usr/bin/env bash + +IMAGE_FAMILY=$(docker-image-info family) + +# Installation +case "$IMAGE_FAMILY" in + Debian|Ubuntu) + apt-install dnsmasq + ;; + + RedHat) + yum-install dnsmasq + ;; + + Alpine) + apk-install dnsmasq + ;; +esac + +# Configuration +go-replace --mode=line \ + -s '^[\s]*user[\s]*=' -r 'user = root' \ + -s '^[\s]*conf-dir[\s]*=' -r 'conf-dir = /etc/dnsmasq.d' \ + -- /etc/dnsmasq.conf diff --git a/docker/base/alpine/conf/provision/service.d/postfix.sh b/docker/base/alpine/conf/provision/service.d/postfix.sh new file mode 100644 index 000000000..ff1879345 --- /dev/null +++ b/docker/base/alpine/conf/provision/service.d/postfix.sh @@ -0,0 +1,28 @@ +#!/usr/bin/env bash + +IMAGE_FAMILY=$(docker-image-info family) + +# Installation +case "$IMAGE_FAMILY" in + Debian|Ubuntu) + apt-install postfix + ;; + + RedHat) + yum-install postfix + ;; + + Alpine) + apk-install postfix + ln -s -f /etc/postfix/aliases /etc/aliases + ;; +esac + +# Configuration +go-replace --mode=line \ + -s '^[\s]*mydestination[\s]*=' -r 'mydestination = ' \ + -s '^[\s]*message_size_limit[\s]*=' -r 'message_size_limit = 15240000' \ + -s '^[\s]*smtp_use_tls[\s]*=' -r 'smtp_use_tls = yes' \ + -s '^[\s]*smtp_tls_security_level[\s]*=' -r 'smtp_tls_security_level = may' \ + -s '^[\s]*myhostname[\s]*=' -r '# myhostname' \ + -- /etc/postfix/main.cf diff --git a/docker/base/alpine/conf/provision/service.d/ssh.sh b/docker/base/alpine/conf/provision/service.d/ssh.sh new file mode 100644 index 000000000..63d7a9f3a --- /dev/null +++ b/docker/base/alpine/conf/provision/service.d/ssh.sh @@ -0,0 +1,17 @@ +#!/usr/bin/env bash + +IMAGE_FAMILY=$(docker-image-info family) + +case "$IMAGE_FAMILY" in + Debian|Ubuntu) + apt-install openssh-server + ;; + + RedHat) + yum-install openssh-server + ;; + + Alpine) + apk-install openssh + ;; +esac diff --git a/docker/base/alpine/conf/provision/service.d/syslog.sh b/docker/base/alpine/conf/provision/service.d/syslog.sh new file mode 100644 index 000000000..7e8b8e0a9 --- /dev/null +++ b/docker/base/alpine/conf/provision/service.d/syslog.sh @@ -0,0 +1,41 @@ +#!/usr/bin/env bash + +IMAGE_FAMILY=$(docker-image-info family) + +# Installation +case "$IMAGE_FAMILY" in + Debian|Ubuntu) + apt-install syslog-ng syslog-ng-core + ;; + + RedHat) + yum-install syslog-ng + + # remove logrotate (not needed for docker) + rm -f "/etc/cron.daily/logrotate" + ;; + + Alpine) + apk-install syslog-ng + ;; +esac + +## Configuration +SYSLOG_NG_VERSION=$(syslog-ng --version | grep -E -e '^syslog-ng[ ]+[0-9]+\.[0-9]+' | head -n 1 | awk '{print $2}' | cut -f 1,2 -d .) + +# Disable caps inside container +if [[ -f /etc/default/syslog-ng ]]; then + go-replace --mode=lineinfile \ + -s "SYSLOGNG_OPTS" -r "SYSLOGNG_OPTS = --no-caps" \ + -- /etc/default/syslog-ng +fi + +# Symlink configuration +ln -s -f /opt/docker/etc/syslog-ng/syslog-ng.conf /etc/syslog-ng/syslog-ng.conf + +go-replace --mode=lineinfile \ + -s "@version" -r "@version: ${SYSLOG_NG_VERSION}" \ + -- /etc/syslog-ng/syslog-ng.conf + +# Ensure /var/lib/syslog-ng exists +mkdir -p /var/lib/syslog-ng diff --git a/docker/base/alpine/conf/provision/variables-webdevops.yml b/docker/base/alpine/conf/provision/variables-webdevops.yml new file mode 100644 index 000000000..0b2a21a95 --- /dev/null +++ b/docker/base/alpine/conf/provision/variables-webdevops.yml @@ -0,0 +1,7 @@ +--- + +docker_image_info_family: "{{ lookup('pipe', 'docker-image-info family') }}" +docker_image_info_distribution: "{{ lookup('pipe', 'docker-image-info dist') }}" +docker_image_info_distribution_version: "{{ lookup('pipe', 'docker-image-info dist-version') }}" +docker_image_info_distribution_release: "{{ lookup('pipe', 'docker-image-info dist-release') }}" +docker_image_info_distribution_codename: "{{ lookup('pipe', 'docker-image-info dist-codename') }}" diff --git a/docker/base/alpine/conf/provision/variables.yml b/docker/base/alpine/conf/provision/variables.yml new file mode 100644 index 000000000..0b2a21a95 --- /dev/null +++ b/docker/base/alpine/conf/provision/variables.yml @@ -0,0 +1,7 @@ +--- + +docker_image_info_family: "{{ lookup('pipe', 'docker-image-info family') }}" +docker_image_info_distribution: "{{ lookup('pipe', 'docker-image-info dist') }}" +docker_image_info_distribution_version: "{{ lookup('pipe', 'docker-image-info dist-version') }}" +docker_image_info_distribution_release: "{{ lookup('pipe', 'docker-image-info dist-release') }}" +docker_image_info_distribution_codename: "{{ lookup('pipe', 'docker-image-info dist-codename') }}" diff --git a/docker/base/centos-7/Dockerfile b/docker/base/centos-7/Dockerfile index 7259b65e2..7a18b1693 100644 --- a/docker/base/centos-7/Dockerfile +++ b/docker/base/centos-7/Dockerfile @@ -5,30 +5,46 @@ FROM webdevops/bootstrap:centos-7 -MAINTAINER info@webdevops.io -LABEL vendor=WebDevOps.io -LABEL io.webdevops.layout=8 -LABEL io.webdevops.version=1.5.0 - -ENV DOCKER_CONF_HOME /opt/docker/ +ENV DOCKER_CONF_HOME=/opt/docker/ \ + LOG_STDOUT="" \ + LOG_STDERR="" COPY conf/ /opt/docker/ +# Install ansible +RUN /usr/local/bin/yum-install \ + epel-release \ + PyYAML \ + python-jinja2 \ + python-httplib2 \ + python-keyczar \ + python-paramiko \ + python-setuptools \ + python-setuptools-devel \ + libffi \ + python-devel \ + libffi-devel \ + && easy_install pip \ + && pip install --upgrade pip \ + && hash -r \ + && pip install --no-cache-dir ansible \ + && chmod 750 /usr/bin/ansible* \ + # Cleanup + && yum erase -y python-devel \ + && docker-image-cleanup + # Install services RUN chmod +x /opt/docker/bin/* \ && /usr/local/bin/yum-install \ - cronie \ supervisor \ - syslog-ng \ - logrotate \ wget \ curl \ net-tools \ gnupg2 \ && chmod +s /usr/local/bin/gosu \ && /opt/docker/bin/provision run --tag bootstrap --role webdevops-base \ - && /opt/docker/bin/bootstrap.sh - + && /opt/docker/bin/bootstrap.sh \ + && docker-image-cleanup ENTRYPOINT ["/opt/docker/bin/entrypoint.sh"] CMD ["supervisord"] diff --git a/docker/base/centos-7/Dockerfile.jinja2 b/docker/base/centos-7/Dockerfile.jinja2 index 04251e84a..66367f569 100644 --- a/docker/base/centos-7/Dockerfile.jinja2 +++ b/docker/base/centos-7/Dockerfile.jinja2 @@ -1,11 +1,11 @@ {{ docker.from("bootstrap", "centos-7") }} -{{ docker.version() }} - -{{ environment.homePath() }} +{{ environment.base() }} {{ docker.copy('conf/', '/opt/docker/') }} +{{ ansible.centos() }} + {{ base.centos() }} {{ docker.entrypoint("/opt/docker/bin/entrypoint.sh") }} diff --git a/docker/base/centos-7/conf/bin/bootstrap.sh b/docker/base/centos-7/conf/bin/bootstrap.sh index 1d1a30f72..855c10782 100644 --- a/docker/base/centos-7/conf/bin/bootstrap.sh +++ b/docker/base/centos-7/conf/bin/bootstrap.sh @@ -17,10 +17,16 @@ rootCheck "$0" # Save the buildtime date +%s > /opt/docker/BUILDTIME +date +%s >/opt/docker/etc/.registry/image_info_buildtime # Make all scripts executable find /opt/docker/bin/ -type f -iname '*.sh' -print0 | xargs --no-run-if-empty -0 chmod +x +# Enable usr-bin executables +find /opt/docker/bin/usr-bin -type f | while read USR_BIN_FILE; do + chmod +x -- "$USR_BIN_FILE" + ln -n -f -- "$USR_BIN_FILE" "/usr/local/bin/$(basename "$USR_BIN_FILE")" +done case "$BOOTSTRAP_MODE" in ################################### @@ -44,6 +50,23 @@ case "$BOOTSTRAP_MODE" in echo "[ERROR] Bootstrap mode '$BOOTSTRAP_MODE' not defined" exit 1 ;; - esac + +###################### +# Check if entrypoint provisioning is available +###################### + +echo "Checking provision status..." +for PROVISION_TAG in onbuild build bootstrap entrypoint; do + ROLES=$(docker-provision list --tag "$PROVISION_TAG") + if [[ -n "$ROLES" ]]; then + PROVISION_ROLE_COUNT=$(echo "$ROLES" | wc -l) + echo " - found ${PROVISION_ROLE_COUNT} for provision tag ${PROVISION_TAG}, caching info for execution" + echo -n "$PROVISION_ROLE_COUNT" > "/opt/docker/etc/.registry/provision-availale.${PROVISION_TAG}" + else + echo " - no roles found for provision tag ${PROVISION_TAG}" + echo -n '' > "/opt/docker/etc/.registry/provision-availale.${PROVISION_TAG}" + fi +done + diff --git a/docker/base/centos-7/conf/bin/config.sh b/docker/base/centos-7/conf/bin/config.sh index 3155728e8..049756c26 100644 --- a/docker/base/centos-7/conf/bin/config.sh +++ b/docker/base/centos-7/conf/bin/config.sh @@ -15,44 +15,23 @@ function rootCheck() { } ### - # Create named pipe - # - # $1 -> name of file + # Create /docker.stdout and /docker.stderr # ## -function createNamedPipe() { - rm --force -- "$1" - mknod "$1" p -} - -### - # Escape value for sed usage - # - # $1 -> value - # STDOUT -> escaped value - # - ## -function sedEscape() { - echo "$(echo $* |sed -e 's/[]\/$*.^|[]/\\&/g')" -} +function createDockerStdoutStderr() { + # link stdout from docker + if [[ -z "$LOG_STDOUT" ]]; then + LOG_STDOUT="/proc/$$/fd/1" + fi -### - # Replace text inside a file - # - # $1 -> source value - # $2 -> target value - # $3 -> path to file - # - ## -function replaceTextInFile() { - SOURCE="$(sedEscape $1)" - REPLACE="$(sedEscape $2)" - TARGET="$3" + if [[ -z "$LOG_STDERR" ]]; then + LOG_STDERR="/proc/$$/fd/2" + fi - sed -i "s/${SOURCE}/${REPLACE}/" "${TARGET}" + ln -f -s "$LOG_STDOUT" /docker.stdout + ln -f -s "$LOG_STDERR" /docker.stderr + chmod 600 /docker.stdout /docker.stderr } - - ### # Include script directory text inside a file # @@ -104,7 +83,7 @@ function runEntrypoints() { . /opt/docker/bin/entrypoint.d/default.sh fi - exit + exit 1 } ### @@ -161,6 +140,12 @@ function runProvisionEntrypoint() { function runDockerProvision() { ANSIBLE_TAG="$1" - /opt/docker/bin/provision run --tag "$ANSIBLE_TAG" --use-registry + PROVISION_STATS_FILE="/opt/docker/etc/.registry/provision-stats.${ANSIBLE_TAG}" + + # run provision if stats file doesn't exists (unknown mode) + # or if stats file is not empty + if [[ ! -f "$PROVISION_STATS_FILE" ]] || [[ -s "$PROVISION_STATS_FILE" ]]; then + /opt/docker/bin/provision run --tag "${ANSIBLE_TAG}" --use-registry + fi } diff --git a/docker/base/centos-7/conf/bin/control.sh b/docker/base/centos-7/conf/bin/control.sh index a6697092d..22d189745 100644 --- a/docker/base/centos-7/conf/bin/control.sh +++ b/docker/base/centos-7/conf/bin/control.sh @@ -101,23 +101,13 @@ case "$CONTROL_COMMAND" in ## ------------------------------------------ "service.enable") - SERVICE_FILE="/opt/docker/etc/supervisor.d/$1.conf" - if [ -f "$SERVICE_FILE" ]; then - sed -i '/autostart = /c\autostart = true' -- "$SERVICE_FILE" - else - echo "[ERROR] Service '${1}' not found (tried ${SERVICE_FILE})" - exit 1 - fi + deprecationNotice " Please use >>docker-service-enable [service]<<" + docker-service-enable "$1" ;; "service.disable") - SERVICE_FILE="/opt/docker/etc/supervisor.d/$1.conf" - if [ -f "$SERVICE_FILE" ]; then - sed -i '/autostart = /c\autostart = false' -- "$SERVICE_FILE" - else - echo "[ERROR] Service '${1}' not found (tried ${SERVICE_FILE})" - exit 1 - fi + deprecationNotice " Please use >>docker-service-disable [service]<<" + docker-service-disable "$1" ;; ## ------------------------------------------ diff --git a/docker/base/centos-7/conf/bin/entrypoint.d/cli.sh b/docker/base/centos-7/conf/bin/entrypoint.d/cli.sh index 2ca68926c..fe212a8ea 100644 --- a/docker/base/centos-7/conf/bin/entrypoint.d/cli.sh +++ b/docker/base/centos-7/conf/bin/entrypoint.d/cli.sh @@ -8,7 +8,7 @@ if [ -n "${CLI_SCRIPT}" ]; then if [ -n "$APPLICATION_USER" ]; then # Run as EFFECTIVE_USER shift - exec sudo -H -E -u "${APPLICATION_USER}" ${CLI_SCRIPT} "$@" + exec gosu "${APPLICATION_USER}" ${CLI_SCRIPT} "$@" else # Run as root exec ${CLI_SCRIPT} "$@" diff --git a/docker/base/centos-7/conf/bin/entrypoint.d/noop.sh b/docker/base/centos-7/conf/bin/entrypoint.d/noop.sh index 967920837..092d55d8b 100644 --- a/docker/base/centos-7/conf/bin/entrypoint.d/noop.sh +++ b/docker/base/centos-7/conf/bin/entrypoint.d/noop.sh @@ -4,5 +4,4 @@ ## NOOP (no operation) ############################################# -tail -f /dev/null -exit +exec tail -f /dev/null diff --git a/docker/base/centos-7/conf/bin/entrypoint.d/supervisord.sh b/docker/base/centos-7/conf/bin/entrypoint.d/supervisord.sh index ead991551..f21489667 100644 --- a/docker/base/centos-7/conf/bin/entrypoint.d/supervisord.sh +++ b/docker/base/centos-7/conf/bin/entrypoint.d/supervisord.sh @@ -4,8 +4,6 @@ ## Supervisord (start daemons) ############################################# -rootCheck "supervisord" - ## Start services exec /opt/docker/bin/service.d/supervisor.sh diff --git a/docker/base/centos-7/conf/bin/entrypoint.sh b/docker/base/centos-7/conf/bin/entrypoint.sh index bbabcdddb..01f59660c 100644 --- a/docker/base/centos-7/conf/bin/entrypoint.sh +++ b/docker/base/centos-7/conf/bin/entrypoint.sh @@ -20,16 +20,13 @@ chmod -s /usr/local/bin/gosu trap 'echo sigterm ; exit' SIGTERM trap 'echo sigkill ; exit' SIGKILL -# link stdout from docker -ln -f -s "/proc/$$/fd/1" /docker.stdout -ln -f -s "/proc/$$/fd/2" /docker.stderr -chmod 600 /docker.stdout /docker.stderr - # sanitize input and set task TASK="$(echo $1| sed 's/[^-_a-zA-Z0-9]*//g')" source /opt/docker/bin/config.sh +createDockerStdoutStderr + if [[ "$UID" -eq 0 ]]; then # Only run provision if user is root diff --git a/docker/base/centos-7/conf/bin/logwatch.sh b/docker/base/centos-7/conf/bin/logwatch.sh deleted file mode 100644 index 1a5b486c7..000000000 --- a/docker/base/centos-7/conf/bin/logwatch.sh +++ /dev/null @@ -1,14 +0,0 @@ -#!/usr/bin/env bash - -set -o pipefail # trace ERR through pipes -set -o errtrace # trace ERR through 'time command' and other functions -set -o nounset ## set -u : exit the script if you try to use an uninitialised variable -set -o errexit ## set -e : exit the script if any statement returns a non-true return value - -sleep 0.5 - -if [ -p "$2" ]; then - sed --unbuffered -e "s/^/\[$1\] /" -- "$2" -else - tail -n 0 -F -q "$2" | sed --unbuffered -e "s/^/\[$1\] /" -fi diff --git a/docker/base/centos-7/conf/bin/provision b/docker/base/centos-7/conf/bin/provision index f7b5ad0a8..d367c2812 100755 --- a/docker/base/centos-7/conf/bin/provision +++ b/docker/base/centos-7/conf/bin/provision @@ -19,6 +19,7 @@ PLAYBOOK = Template( - hosts: all vars_files: + - ./variables-webdevops.yml - ./variables.yml roles: - $roles @@ -188,7 +189,7 @@ def actionAdd(args): 'priority': args.priority } - saveJson(json); + saveJson(json) diff --git a/docker/base/centos-7/conf/bin/provision.sh b/docker/base/centos-7/conf/bin/provision.sh deleted file mode 100644 index 4079dd7f0..000000000 --- a/docker/base/centos-7/conf/bin/provision.sh +++ /dev/null @@ -1,30 +0,0 @@ - #!/usr/bin/env bash - -# -# Example: -# provision.sh /opt/foobar/playbook.yml tag -# -# - -set -o pipefail # trace ERR through pipes -set -o errtrace # trace ERR through 'time command' and other functions -set -o nounset ## set -u : exit the script if you try to use an uninitialised variable -set -o errexit ## set -e : exit the script if any statement returns a non-true return value - -. config.sh - -deprecationNotice " Please use >>/opt/docker/bin/provision run --playbook playbook.yml --tag=bootstrap [args]<< for running provision" - - -if [ "$#" -lt 2 ]; then - echo "[ERROR] $0: Playbook or tag is missing" - exit 1 -fi - -ANSIBLE_PLAYBOOK="$1" -shift -ANSIBLE_TAG="$1" -shift -ANSIBLE_OPTS="$@" - -/opt/docker/bin/provision run --playbook "${ANSIBLE_PLAYBOOK}" --use-registry --tag "${ANSIBLE_TAG}" $ANSIBLE_OPTS diff --git a/docker/base-app/centos-7/conf/bin/service.d/dnsmasq.d/10-init.sh b/docker/base/centos-7/conf/bin/service.d/dnsmasq.d/10-init.sh similarity index 100% rename from docker/base-app/centos-7/conf/bin/service.d/dnsmasq.d/10-init.sh rename to docker/base/centos-7/conf/bin/service.d/dnsmasq.d/10-init.sh diff --git a/docker/base-app/centos-7/conf/bin/service.d/dnsmasq.sh b/docker/base/centos-7/conf/bin/service.d/dnsmasq.sh similarity index 100% rename from docker/base-app/centos-7/conf/bin/service.d/dnsmasq.sh rename to docker/base/centos-7/conf/bin/service.d/dnsmasq.sh diff --git a/docker/base/centos-7/conf/bin/service.d/postfix.d/10-init.sh b/docker/base/centos-7/conf/bin/service.d/postfix.d/10-init.sh new file mode 100644 index 000000000..cfd876955 --- /dev/null +++ b/docker/base/centos-7/conf/bin/service.d/postfix.d/10-init.sh @@ -0,0 +1,27 @@ +# force new copy of hosts there (otherwise links could be outdated) +mkdir -p /var/spool/postfix/etc +cp -f /etc/hosts /var/spool/postfix/etc/hosts +cp -f /etc/resolv.conf /var/spool/postfix/etc/resolv.conf +cp -f /etc/services /var/spool/postfix/etc/services + +## MYHOSTNAME +# replace line +sed -i '/myhostname[ ]* =/c\' main.cf +echo "myhostname = $(hostname)" >> /etc/postfix/main.cf + +## REPLAYHOST +if [[ -n "${POSTFIX_RELAYHOST+x}" ]]; then + # replace line + sed -i '/relayhost[ ]* =/c\' main.cf + echo "relayhost = $POSTFIX_RELAYHOST" >> /etc/postfix/main.cf +fi + +## MYNETWORKS +if [[ -n "${POSTFIX_MYNETWORKS+x}" ]]; then + # replace line + sed -i '/mynetworks[ ]* =/c\' main.cf + echo "mynetworks = $POSTFIX_MYNETWORKS" >> /etc/postfix/main.cf +fi + +# generate aliases db +newaliases || : diff --git a/docker/base-app/centos-7/conf/bin/service.d/postfix.sh b/docker/base/centos-7/conf/bin/service.d/postfix.sh similarity index 100% rename from docker/base-app/centos-7/conf/bin/service.d/postfix.sh rename to docker/base/centos-7/conf/bin/service.d/postfix.sh diff --git a/docker/base/centos-7/conf/bin/service.d/ssh.d/10-init.sh b/docker/base/centos-7/conf/bin/service.d/ssh.d/10-init.sh new file mode 100644 index 000000000..f2b600312 --- /dev/null +++ b/docker/base/centos-7/conf/bin/service.d/ssh.d/10-init.sh @@ -0,0 +1,7 @@ +# Init ssh privilege separation directory +mkdir -p /var/run/sshd +chown root:root /var/run/sshd +chmod 755 /var/run/sshd + +# generate host keys +ssh-keygen -A diff --git a/docker/base-app/centos-7/conf/bin/service.d/ssh.sh b/docker/base/centos-7/conf/bin/service.d/ssh.sh similarity index 100% rename from docker/base-app/centos-7/conf/bin/service.d/ssh.sh rename to docker/base/centos-7/conf/bin/service.d/ssh.sh diff --git a/docker/base/centos-7/conf/bin/service.d/syslog-ng.d/10-init.sh b/docker/base/centos-7/conf/bin/service.d/syslog-ng.d/10-init.sh index 22621d2ad..326207e52 100644 --- a/docker/base/centos-7/conf/bin/service.d/syslog-ng.d/10-init.sh +++ b/docker/base/centos-7/conf/bin/service.d/syslog-ng.d/10-init.sh @@ -6,5 +6,5 @@ if [ ! -S /var/lib/syslog-ng/syslog-ng.ctl ]; then rm -f /var/lib/syslog-ng/sysl if [[ ! -p /docker.stdout ]]; then # Switch to file (tty docker mode) - rpl --quiet 'pipe("/docker.stdout")' 'file("/docker.stdout")' -- /opt/docker/etc/syslog-ng/syslog-ng.conf > /dev/null + go-replace -s 'pipe("/docker.stdout")' -r 'file("/docker.stdout")' -- /opt/docker/etc/syslog-ng/syslog-ng.conf fi diff --git a/docker/base/centos-7/conf/bin/usr-bin/docker-provision b/docker/base/centos-7/conf/bin/usr-bin/docker-provision new file mode 100644 index 000000000..4ee715c64 --- /dev/null +++ b/docker/base/centos-7/conf/bin/usr-bin/docker-provision @@ -0,0 +1,9 @@ +#!/usr/bin/env bash + +set -o pipefail # trace ERR through pipes +set -o errtrace # trace ERR through 'time command' and other functions +set -o nounset ## set -u : exit the script if you try to use an uninitialised variable +set -o errexit ## set -e : exit the script if any statement returns a non-true return value + +# wrapper +exec /opt/docker/bin/provision "$@" diff --git a/docker/base/centos-7/conf/bin/usr-bin/docker-service-disable b/docker/base/centos-7/conf/bin/usr-bin/docker-service-disable new file mode 100644 index 000000000..2b5b31bb4 --- /dev/null +++ b/docker/base/centos-7/conf/bin/usr-bin/docker-service-disable @@ -0,0 +1,30 @@ +#!/usr/bin/env bash + +set -o pipefail # trace ERR through pipes +set -o errtrace # trace ERR through 'time command' and other functions +set -o nounset ## set -u : exit the script if you try to use an uninitialised variable +set -o errexit ## set -e : exit the script if any statement returns a non-true return value + +source /opt/docker/bin/config.sh + +rootCheck "$0" + +if [[ "$#" -eq 0 ]]; then + echo "Usage: $0 " + exit 1 +fi + +for SERVICE in "$@"; do + SERVICE_FILE="/opt/docker/etc/supervisor.d/${SERVICE}.conf" + + ## Disable service + if [[ -f "$SERVICE_FILE" ]]; then + go-replace --mode=lineinfile \ + -s 'autostart =' -r 'autostart = false' \ + -- "$SERVICE_FILE" + else + echo "[ERROR] Service '${SERVICE}' not found (tried ${SERVICE_FILE})" + exit 1 + fi +done + diff --git a/docker/base/centos-7/conf/bin/usr-bin/docker-service-enable b/docker/base/centos-7/conf/bin/usr-bin/docker-service-enable new file mode 100644 index 000000000..8d36a14a9 --- /dev/null +++ b/docker/base/centos-7/conf/bin/usr-bin/docker-service-enable @@ -0,0 +1,41 @@ +#!/usr/bin/env bash + +set -o pipefail # trace ERR through pipes +set -o errtrace # trace ERR through 'time command' and other functions +set -o nounset ## set -u : exit the script if you try to use an uninitialised variable +set -o errexit ## set -e : exit the script if any statement returns a non-true return value + +source /opt/docker/bin/config.sh + +rootCheck "$0" + +if [[ "$#" -eq 0 ]]; then + echo "Usage: $0 " + exit 1 +fi + +for SERVICE in "$@"; do + SERVICE_FILE="/opt/docker/etc/supervisor.d/${SERVICE}.conf" + PROVISION_FILE="/opt/docker/provision/service.d/${SERVICE}.sh" + + # Run on demand installation/provisioning + if [[ -f "$PROVISION_FILE" ]]; then + echo "Running provisioning for ${SERVICE}, please wait..." + + ## execute scripts + . "$PROVISION_FILE" + + ## remove directory (one run time) + rm -f -- "$PROVISION_FILE" + fi + + ## Enable service + if [[ -f "$SERVICE_FILE" ]]; then + go-replace --mode=lineinfile \ + -s 'autostart =' -r 'autostart = true' \ + -- "$SERVICE_FILE" + else + echo "[ERROR] Service '${SERVICE}' not found (tried ${SERVICE_FILE})" + exit 1 + fi +done diff --git a/docker/base/centos-7/conf/bin/usr-bin/service b/docker/base/centos-7/conf/bin/usr-bin/service new file mode 100755 index 000000000..55ea12bf7 --- /dev/null +++ b/docker/base/centos-7/conf/bin/usr-bin/service @@ -0,0 +1,86 @@ +#!/bin/bash + +set -o pipefail # trace ERR through pipes +set -o errtrace # trace ERR through 'time command' and other functions +set -o nounset ## set -u : exit the script if you try to use an uninitialised variable +set -o errexit ## set -e : exit the script if any statement returns a non-true return value + +# Root check +if [ "$(/usr/bin/whoami)" != "root" ]; then + echo "[ERROR] Must be run as root" + exit 1 +fi + +function serviceHelp() { + echo "Usage: $(basename "$0") " +} + +function getServicePid() { + local serviceName="$1" + local servicePid=$(supervisorctl pid "${serviceName}:${serviceName}d") + + if [[ -z "$servicePid" ]] || [[ "$servicePid" == "0" ]]; then + echo "not running" + exit 1 + fi + + echo $servicePid +} + +# Param check +if [ "$#" -lt 2 ]; then + echo "[ERROR] Missing parameters" + serviceHelp + exit 1 +fi + +############################# +# Param init +############################# + +SERVICENAME="$1" +ACTION="$2" + +############################# +# Service aliases +############################# +case "$SERVICENAME" in + apache2|httpd) + SERVICENAME="apache" + ;; +esac + +############################# +# Action runner +############################# +case "$ACTION" in + stop|start|restart|status) + exec supervisorctl "$ACTION" "${SERVICENAME}:${SERVICENAME}d" + ;; + + pid) + echo $(getServicePid "${SERVICENAME}") + ;; + + check) + FIRST_PID=$(getServicePid "${SERVICENAME}") + sleep 5 + SECOND_PID=$(getServicePid "${SERVICENAME}") + + if [[ "$FIRST_PID" == "$SECOND_PID" ]]; then + echo "ok" + exit 0 + else + echo "not running" + exit 1 + fi + ;; + + + *) + echo "[ERROR] Invalid action" + serviceHelp + exit 1 + ;; + +esac diff --git a/docker/base/centos-7/conf/etc/logrotate.d/syslog b/docker/base/centos-7/conf/etc/logrotate.d/syslog deleted file mode 100644 index 4597c7b48..000000000 --- a/docker/base/centos-7/conf/etc/logrotate.d/syslog +++ /dev/null @@ -1 +0,0 @@ -# placeholder -> overwrite system default \ No newline at end of file diff --git a/docker/base/centos-7/conf/etc/supervisor.conf b/docker/base/centos-7/conf/etc/supervisor.conf index 440721076..479e0db08 100644 --- a/docker/base/centos-7/conf/etc/supervisor.conf +++ b/docker/base/centos-7/conf/etc/supervisor.conf @@ -2,7 +2,16 @@ nodaemon=true [unix_http_server] -file = /var/run/supervisor/supervisor.sock +file = /.supervisor.sock +chmod = 0700 +chown = root:root +username = root +password = {SHA}e982f17bcbe0f724063b708a4f76db211a999304 + +[supervisorctl] +serverurl = unix:///.supervisor.sock +username = root +password = docker [rpcinterface:supervisor] supervisor.rpcinterface_factory = supervisor.rpcinterface:make_main_rpcinterface diff --git a/docker/base/centos-7/conf/etc/supervisor.d/dnsmasq.conf b/docker/base/centos-7/conf/etc/supervisor.d/dnsmasq.conf new file mode 100644 index 000000000..9832ffca7 --- /dev/null +++ b/docker/base/centos-7/conf/etc/supervisor.d/dnsmasq.conf @@ -0,0 +1,14 @@ +[group:dnsmasq] +programs=dnsmasqd +priority=15 + +[program:dnsmasqd] +command = /opt/docker/bin/service.d/dnsmasq.sh +process_name=%(program_name)s +startsecs = 0 +autostart = false +autorestart = true +stdout_logfile=/dev/stdout +stdout_logfile_maxbytes=0 +stderr_logfile=/dev/stderr +stderr_logfile_maxbytes=0 diff --git a/docker/base-app/centos-7/conf/etc/supervisor.d/postfix.conf b/docker/base/centos-7/conf/etc/supervisor.d/postfix.conf similarity index 100% rename from docker/base-app/centos-7/conf/etc/supervisor.d/postfix.conf rename to docker/base/centos-7/conf/etc/supervisor.d/postfix.conf diff --git a/docker/base-app/centos-7/conf/etc/supervisor.d/ssh.conf b/docker/base/centos-7/conf/etc/supervisor.d/ssh.conf similarity index 100% rename from docker/base-app/centos-7/conf/etc/supervisor.d/ssh.conf rename to docker/base/centos-7/conf/etc/supervisor.d/ssh.conf diff --git a/docker/base/centos-7/conf/etc/supervisor.d/syslog-ng.conf b/docker/base/centos-7/conf/etc/supervisor.d/syslog-ng.conf deleted file mode 100644 index 247fd1a25..000000000 --- a/docker/base/centos-7/conf/etc/supervisor.d/syslog-ng.conf +++ /dev/null @@ -1,13 +0,0 @@ -[group:syslog] -programs=syslogd -priority=10 - -[program:syslogd] -command = /opt/docker/bin/service.d/syslog-ng.sh -process_name=%(program_name)s -autostart = true -autorestart = true -stdout_logfile=/dev/stdout -stdout_logfile_maxbytes=0 -stderr_logfile=/dev/stderr -stderr_logfile_maxbytes=0 diff --git a/docker/base/centos-7/conf/etc/supervisor.d/syslog.conf b/docker/base/centos-7/conf/etc/supervisor.d/syslog.conf new file mode 100644 index 000000000..20d1e238c --- /dev/null +++ b/docker/base/centos-7/conf/etc/supervisor.d/syslog.conf @@ -0,0 +1,13 @@ +[group:syslog] +programs=syslogd +priority=10 + +[program:syslogd] +command = /opt/docker/bin/service.d/syslog-ng.sh +process_name=%(program_name)s +autostart = false +autorestart = true +stdout_logfile=/dev/stdout +stdout_logfile_maxbytes=0 +stderr_logfile=/dev/stderr +stderr_logfile_maxbytes=0 diff --git a/docker/base/centos-7/conf/provision/roles/webdevops-base/tasks/bootstrap.yml b/docker/base/centos-7/conf/provision/roles/webdevops-base/tasks/bootstrap.yml index 30be03c38..9f842336c 100644 --- a/docker/base/centos-7/conf/provision/roles/webdevops-base/tasks/bootstrap.yml +++ b/docker/base/centos-7/conf/provision/roles/webdevops-base/tasks/bootstrap.yml @@ -4,6 +4,5 @@ - include: bootstrap/misc.yml - include: bootstrap/root.yml - include: bootstrap/supervisor.yml -- include: bootstrap/syslog-ng.yml -- include: bootstrap/logrotate.yml - include: bootstrap/pam.yml +- include: bootstrap/entrypoint.yml diff --git a/docker/base/centos-7/conf/provision/roles/webdevops-base/tasks/bootstrap/entrypoint.yml b/docker/base/centos-7/conf/provision/roles/webdevops-base/tasks/bootstrap/entrypoint.yml new file mode 100644 index 000000000..d5d8809f4 --- /dev/null +++ b/docker/base/centos-7/conf/provision/roles/webdevops-base/tasks/bootstrap/entrypoint.yml @@ -0,0 +1,8 @@ +--- + +- name: Create link for entrypoint + file: + src: '/opt/docker/bin/entrypoint.sh' + dest: '/entrypoint' + state: link + force: yes diff --git a/docker/base/centos-7/conf/provision/roles/webdevops-base/tasks/bootstrap/logrotate.yml b/docker/base/centos-7/conf/provision/roles/webdevops-base/tasks/bootstrap/logrotate.yml deleted file mode 100644 index d87926be2..000000000 --- a/docker/base/centos-7/conf/provision/roles/webdevops-base/tasks/bootstrap/logrotate.yml +++ /dev/null @@ -1,33 +0,0 @@ ---- - -- name: Configure logrotate running user - lineinfile: - dest: /etc/logrotate.conf - regexp: '^su [-_a-zA-Z0-9]+ [-_a-zA-Z0-9]+' - line: 'su root adm' - -- name: Register logrotate configurations - file: - src: '{{ item }}' - dest: '/etc/logrotate.d/{{ item | basename }}' - state: link - force: yes - with_fileglob: - - /opt/docker/etc/logrotate.d/* - -- name: Remove system logrotates (not needed) - file: - path: '{{ item }}' - state: absent - with_items: - # Debian/Ubuntu - - /etc/cron.daily/logrotate - - /etc/cron.daily/apt-compat - - /etc/cron.daily/dpkg - - /etc/cron.daily/passwd - # RedHat - - /etc/cron.daily/0yum-daily.cron - - /etc/cron.daily/logrotate - - /etc/cron.hourly/0yum-hourly.cron - # Alpine - - /etc/periodic/daily/logrotate diff --git a/docker/base/centos-7/conf/provision/roles/webdevops-base/tasks/bootstrap/supervisor.yml b/docker/base/centos-7/conf/provision/roles/webdevops-base/tasks/bootstrap/supervisor.yml index bda0394b6..2ce07ac26 100644 --- a/docker/base/centos-7/conf/provision/roles/webdevops-base/tasks/bootstrap/supervisor.yml +++ b/docker/base/centos-7/conf/provision/roles/webdevops-base/tasks/bootstrap/supervisor.yml @@ -4,3 +4,10 @@ file: path: '/usr/sbin/service' state: absent + +- name: Create link for supervisor.conf + file: + src: '/opt/docker/etc/supervisor.conf' + dest: '/etc/supervisord.conf' + state: link + force: yes diff --git a/docker/base/centos-7/conf/provision/roles/webdevops-base/tasks/bootstrap/syslog-ng.yml b/docker/base/centos-7/conf/provision/roles/webdevops-base/tasks/bootstrap/syslog-ng.yml deleted file mode 100644 index 27c8f6a30..000000000 --- a/docker/base/centos-7/conf/provision/roles/webdevops-base/tasks/bootstrap/syslog-ng.yml +++ /dev/null @@ -1,33 +0,0 @@ ---- - -- name: Get syslog-ng version - shell: "syslog-ng --version | grep -E -e '^syslog-ng[ ]+[0-9]+\\.[0-9]+' | head -n 1 | awk '{print $2}' | cut -f 1,2 -d ." - register: syslogng_version - -- name: Configure syslog-ng (default) - lineinfile: - dest: /etc/default/syslog-ng - regexp: '^[\s]*{{ item.key }}[\s]*=' - line: '{{ item.key }}="{{ item.value }}"' - create: yes - with_items: - - { key: 'SYSLOGNG_OPTS', value: '--no-caps' } - -- name: Enable syslog-ng config - file: - src: '/opt/docker/etc/syslog-ng/syslog-ng.conf' - dest: '/etc/syslog-ng/syslog-ng.conf' - state: link - force: yes - -- name: Set version of syslog-ng file - lineinfile: - dest: '/etc/syslog-ng/syslog-ng.conf' - regexp: '^@version:' - line: '@version: {{ syslogng_version.stdout }}' - -- name: Ensure /var/lib/syslog-ng exists - file: - path: '/var/lib/syslog-ng' - state: directory - recurse: yes diff --git a/docker/base/centos-7/conf/provision/roles/webdevops-base/tasks/bootstrap/system.yml b/docker/base/centos-7/conf/provision/roles/webdevops-base/tasks/bootstrap/system.yml index 8dfbf9665..0741d7cae 100644 --- a/docker/base/centos-7/conf/provision/roles/webdevops-base/tasks/bootstrap/system.yml +++ b/docker/base/centos-7/conf/provision/roles/webdevops-base/tasks/bootstrap/system.yml @@ -14,3 +14,20 @@ dest: '/entrypoint.cmd' state: link force: yes + +- name: Remove system logrotate and cronjobs (not needed) + file: + path: '{{ item }}' + state: absent + with_items: + # Debian/Ubuntu + - /etc/cron.daily/logrotate + - /etc/cron.daily/apt-compat + - /etc/cron.daily/dpkg + - /etc/cron.daily/passwd + # RedHat + - /etc/cron.daily/0yum-daily.cron + - /etc/cron.daily/logrotate + - /etc/cron.hourly/0yum-hourly.cron + # Alpine + - /etc/periodic/daily/logrotate diff --git a/docker/nginx/alpine-3/conf/etc/nginx/vhost.common.d/.gitkeep b/docker/base/centos-7/conf/provision/roles/webdevops-base/tasks/build/.gitkeep similarity index 100% rename from docker/nginx/alpine-3/conf/etc/nginx/vhost.common.d/.gitkeep rename to docker/base/centos-7/conf/provision/roles/webdevops-base/tasks/build/.gitkeep diff --git a/docker/base/centos-7/conf/provision/roles/webdevops-base/tasks/build/logrotate.yml b/docker/base/centos-7/conf/provision/roles/webdevops-base/tasks/build/logrotate.yml deleted file mode 100644 index 10f7e6644..000000000 --- a/docker/base/centos-7/conf/provision/roles/webdevops-base/tasks/build/logrotate.yml +++ /dev/null @@ -1,10 +0,0 @@ ---- - -- name: Register logrotate configurations - file: - src: '{{ item }}' - dest: '/etc/logrotate.d/{{ item | basename }}' - state: link - force: yes - with_fileglob: - - /opt/docker/etc/logrotate.d/* diff --git a/docker/php-apache-dev/alpine-3-php7/conf/etc/httpd/conf.d/.gitkeep b/docker/base/centos-7/conf/provision/service.d/.gitkeep similarity index 100% rename from docker/php-apache-dev/alpine-3-php7/conf/etc/httpd/conf.d/.gitkeep rename to docker/base/centos-7/conf/provision/service.d/.gitkeep diff --git a/docker/base/centos-7/conf/provision/service.d/cron.sh b/docker/base/centos-7/conf/provision/service.d/cron.sh new file mode 100644 index 000000000..bd8a54781 --- /dev/null +++ b/docker/base/centos-7/conf/provision/service.d/cron.sh @@ -0,0 +1,13 @@ +#!/usr/bin/env bash + +IMAGE_FAMILY=$(docker-image-info family) + +case "$IMAGE_FAMILY" in + Debian|Ubuntu) + apt-install cron + ;; + + RedHat) + yum-install cronie + ;; +esac diff --git a/docker/base/centos-7/conf/provision/service.d/dnsmasq.sh b/docker/base/centos-7/conf/provision/service.d/dnsmasq.sh new file mode 100644 index 000000000..9e5c3228c --- /dev/null +++ b/docker/base/centos-7/conf/provision/service.d/dnsmasq.sh @@ -0,0 +1,24 @@ +#!/usr/bin/env bash + +IMAGE_FAMILY=$(docker-image-info family) + +# Installation +case "$IMAGE_FAMILY" in + Debian|Ubuntu) + apt-install dnsmasq + ;; + + RedHat) + yum-install dnsmasq + ;; + + Alpine) + apk-install dnsmasq + ;; +esac + +# Configuration +go-replace --mode=line \ + -s '^[\s]*user[\s]*=' -r 'user = root' \ + -s '^[\s]*conf-dir[\s]*=' -r 'conf-dir = /etc/dnsmasq.d' \ + -- /etc/dnsmasq.conf diff --git a/docker/base/centos-7/conf/provision/service.d/postfix.sh b/docker/base/centos-7/conf/provision/service.d/postfix.sh new file mode 100644 index 000000000..ff1879345 --- /dev/null +++ b/docker/base/centos-7/conf/provision/service.d/postfix.sh @@ -0,0 +1,28 @@ +#!/usr/bin/env bash + +IMAGE_FAMILY=$(docker-image-info family) + +# Installation +case "$IMAGE_FAMILY" in + Debian|Ubuntu) + apt-install postfix + ;; + + RedHat) + yum-install postfix + ;; + + Alpine) + apk-install postfix + ln -s -f /etc/postfix/aliases /etc/aliases + ;; +esac + +# Configuration +go-replace --mode=line \ + -s '^[\s]*mydestination[\s]*=' -r 'mydestination = ' \ + -s '^[\s]*message_size_limit[\s]*=' -r 'message_size_limit = 15240000' \ + -s '^[\s]*smtp_use_tls[\s]*=' -r 'smtp_use_tls = yes' \ + -s '^[\s]*smtp_tls_security_level[\s]*=' -r 'smtp_tls_security_level = may' \ + -s '^[\s]*myhostname[\s]*=' -r '# myhostname' \ + -- /etc/postfix/main.cf diff --git a/docker/base/centos-7/conf/provision/service.d/ssh.sh b/docker/base/centos-7/conf/provision/service.d/ssh.sh new file mode 100644 index 000000000..63d7a9f3a --- /dev/null +++ b/docker/base/centos-7/conf/provision/service.d/ssh.sh @@ -0,0 +1,17 @@ +#!/usr/bin/env bash + +IMAGE_FAMILY=$(docker-image-info family) + +case "$IMAGE_FAMILY" in + Debian|Ubuntu) + apt-install openssh-server + ;; + + RedHat) + yum-install openssh-server + ;; + + Alpine) + apk-install openssh + ;; +esac diff --git a/docker/base/centos-7/conf/provision/service.d/syslog.sh b/docker/base/centos-7/conf/provision/service.d/syslog.sh new file mode 100644 index 000000000..7e8b8e0a9 --- /dev/null +++ b/docker/base/centos-7/conf/provision/service.d/syslog.sh @@ -0,0 +1,41 @@ +#!/usr/bin/env bash + +IMAGE_FAMILY=$(docker-image-info family) + +# Installation +case "$IMAGE_FAMILY" in + Debian|Ubuntu) + apt-install syslog-ng syslog-ng-core + ;; + + RedHat) + yum-install syslog-ng + + # remove logrotate (not needed for docker) + rm -f "/etc/cron.daily/logrotate" + ;; + + Alpine) + apk-install syslog-ng + ;; +esac + +## Configuration +SYSLOG_NG_VERSION=$(syslog-ng --version | grep -E -e '^syslog-ng[ ]+[0-9]+\.[0-9]+' | head -n 1 | awk '{print $2}' | cut -f 1,2 -d .) + +# Disable caps inside container +if [[ -f /etc/default/syslog-ng ]]; then + go-replace --mode=lineinfile \ + -s "SYSLOGNG_OPTS" -r "SYSLOGNG_OPTS = --no-caps" \ + -- /etc/default/syslog-ng +fi + +# Symlink configuration +ln -s -f /opt/docker/etc/syslog-ng/syslog-ng.conf /etc/syslog-ng/syslog-ng.conf + +go-replace --mode=lineinfile \ + -s "@version" -r "@version: ${SYSLOG_NG_VERSION}" \ + -- /etc/syslog-ng/syslog-ng.conf + +# Ensure /var/lib/syslog-ng exists +mkdir -p /var/lib/syslog-ng diff --git a/docker/base/centos-7/conf/provision/variables-webdevops.yml b/docker/base/centos-7/conf/provision/variables-webdevops.yml new file mode 100644 index 000000000..0b2a21a95 --- /dev/null +++ b/docker/base/centos-7/conf/provision/variables-webdevops.yml @@ -0,0 +1,7 @@ +--- + +docker_image_info_family: "{{ lookup('pipe', 'docker-image-info family') }}" +docker_image_info_distribution: "{{ lookup('pipe', 'docker-image-info dist') }}" +docker_image_info_distribution_version: "{{ lookup('pipe', 'docker-image-info dist-version') }}" +docker_image_info_distribution_release: "{{ lookup('pipe', 'docker-image-info dist-release') }}" +docker_image_info_distribution_codename: "{{ lookup('pipe', 'docker-image-info dist-codename') }}" diff --git a/docker/base/centos-7/conf/provision/variables.yml b/docker/base/centos-7/conf/provision/variables.yml index ed97d539c..0b2a21a95 100644 --- a/docker/base/centos-7/conf/provision/variables.yml +++ b/docker/base/centos-7/conf/provision/variables.yml @@ -1 +1,7 @@ --- + +docker_image_info_family: "{{ lookup('pipe', 'docker-image-info family') }}" +docker_image_info_distribution: "{{ lookup('pipe', 'docker-image-info dist') }}" +docker_image_info_distribution_version: "{{ lookup('pipe', 'docker-image-info dist-version') }}" +docker_image_info_distribution_release: "{{ lookup('pipe', 'docker-image-info dist-release') }}" +docker_image_info_distribution_codename: "{{ lookup('pipe', 'docker-image-info dist-codename') }}" diff --git a/docker/base/debian-7/Dockerfile b/docker/base/debian-7/Dockerfile index f064df54a..6da91faa9 100644 --- a/docker/base/debian-7/Dockerfile +++ b/docker/base/debian-7/Dockerfile @@ -5,31 +5,48 @@ FROM webdevops/bootstrap:debian-7 -MAINTAINER info@webdevops.io -LABEL vendor=WebDevOps.io -LABEL io.webdevops.layout=8 -LABEL io.webdevops.version=1.5.0 - -ENV DOCKER_CONF_HOME /opt/docker/ +ENV DOCKER_CONF_HOME=/opt/docker/ \ + LOG_STDOUT="" \ + LOG_STDERR="" COPY conf/ /opt/docker/ +# Install ansible +RUN /usr/local/bin/apt-install \ + # Install ansible + python-minimal \ + python-setuptools \ + python-pip \ + python-paramiko \ + python-jinja2 \ + python-dev \ + libffi-dev \ + libssl-dev \ + build-essential \ + && pip install --upgrade pip \ + && hash -r \ + && pip install --no-cache-dir ansible \ + && chmod 750 /usr/local/bin/ansible* \ + # Cleanup + && apt-get purge -y -f --force-yes \ + python-dev \ + build-essential \ + libssl-dev \ + libffi-dev \ + && docker-image-cleanup + # Install packages RUN chmod +x /opt/docker/bin/* \ && /usr/local/bin/apt-install \ supervisor \ - syslog-ng \ - syslog-ng-core \ - logrotate \ - cron \ wget \ curl \ net-tools \ gnupg \ && chmod +s /usr/local/bin/gosu \ && /opt/docker/bin/provision run --tag bootstrap --role webdevops-base \ - && /opt/docker/bin/bootstrap.sh - + && /opt/docker/bin/bootstrap.sh \ + && docker-image-cleanup ENTRYPOINT ["/opt/docker/bin/entrypoint.sh"] CMD ["supervisord"] diff --git a/docker/base/debian-7/Dockerfile.jinja2 b/docker/base/debian-7/Dockerfile.jinja2 index 0712c0d90..5de057921 100644 --- a/docker/base/debian-7/Dockerfile.jinja2 +++ b/docker/base/debian-7/Dockerfile.jinja2 @@ -1,11 +1,11 @@ {{ docker.from("bootstrap", "debian-7") }} -{{ docker.version() }} - -{{ environment.homePath() }} +{{ environment.base() }} {{ docker.copy('conf/', '/opt/docker/') }} +{{ ansible.debian() }} + {{ base.debian() }} {{ docker.entrypoint("/opt/docker/bin/entrypoint.sh") }} diff --git a/docker/base/debian-7/conf/bin/bootstrap.sh b/docker/base/debian-7/conf/bin/bootstrap.sh index 1d1a30f72..855c10782 100644 --- a/docker/base/debian-7/conf/bin/bootstrap.sh +++ b/docker/base/debian-7/conf/bin/bootstrap.sh @@ -17,10 +17,16 @@ rootCheck "$0" # Save the buildtime date +%s > /opt/docker/BUILDTIME +date +%s >/opt/docker/etc/.registry/image_info_buildtime # Make all scripts executable find /opt/docker/bin/ -type f -iname '*.sh' -print0 | xargs --no-run-if-empty -0 chmod +x +# Enable usr-bin executables +find /opt/docker/bin/usr-bin -type f | while read USR_BIN_FILE; do + chmod +x -- "$USR_BIN_FILE" + ln -n -f -- "$USR_BIN_FILE" "/usr/local/bin/$(basename "$USR_BIN_FILE")" +done case "$BOOTSTRAP_MODE" in ################################### @@ -44,6 +50,23 @@ case "$BOOTSTRAP_MODE" in echo "[ERROR] Bootstrap mode '$BOOTSTRAP_MODE' not defined" exit 1 ;; - esac + +###################### +# Check if entrypoint provisioning is available +###################### + +echo "Checking provision status..." +for PROVISION_TAG in onbuild build bootstrap entrypoint; do + ROLES=$(docker-provision list --tag "$PROVISION_TAG") + if [[ -n "$ROLES" ]]; then + PROVISION_ROLE_COUNT=$(echo "$ROLES" | wc -l) + echo " - found ${PROVISION_ROLE_COUNT} for provision tag ${PROVISION_TAG}, caching info for execution" + echo -n "$PROVISION_ROLE_COUNT" > "/opt/docker/etc/.registry/provision-availale.${PROVISION_TAG}" + else + echo " - no roles found for provision tag ${PROVISION_TAG}" + echo -n '' > "/opt/docker/etc/.registry/provision-availale.${PROVISION_TAG}" + fi +done + diff --git a/docker/base/debian-7/conf/bin/config.sh b/docker/base/debian-7/conf/bin/config.sh index 3155728e8..049756c26 100644 --- a/docker/base/debian-7/conf/bin/config.sh +++ b/docker/base/debian-7/conf/bin/config.sh @@ -15,44 +15,23 @@ function rootCheck() { } ### - # Create named pipe - # - # $1 -> name of file + # Create /docker.stdout and /docker.stderr # ## -function createNamedPipe() { - rm --force -- "$1" - mknod "$1" p -} - -### - # Escape value for sed usage - # - # $1 -> value - # STDOUT -> escaped value - # - ## -function sedEscape() { - echo "$(echo $* |sed -e 's/[]\/$*.^|[]/\\&/g')" -} +function createDockerStdoutStderr() { + # link stdout from docker + if [[ -z "$LOG_STDOUT" ]]; then + LOG_STDOUT="/proc/$$/fd/1" + fi -### - # Replace text inside a file - # - # $1 -> source value - # $2 -> target value - # $3 -> path to file - # - ## -function replaceTextInFile() { - SOURCE="$(sedEscape $1)" - REPLACE="$(sedEscape $2)" - TARGET="$3" + if [[ -z "$LOG_STDERR" ]]; then + LOG_STDERR="/proc/$$/fd/2" + fi - sed -i "s/${SOURCE}/${REPLACE}/" "${TARGET}" + ln -f -s "$LOG_STDOUT" /docker.stdout + ln -f -s "$LOG_STDERR" /docker.stderr + chmod 600 /docker.stdout /docker.stderr } - - ### # Include script directory text inside a file # @@ -104,7 +83,7 @@ function runEntrypoints() { . /opt/docker/bin/entrypoint.d/default.sh fi - exit + exit 1 } ### @@ -161,6 +140,12 @@ function runProvisionEntrypoint() { function runDockerProvision() { ANSIBLE_TAG="$1" - /opt/docker/bin/provision run --tag "$ANSIBLE_TAG" --use-registry + PROVISION_STATS_FILE="/opt/docker/etc/.registry/provision-stats.${ANSIBLE_TAG}" + + # run provision if stats file doesn't exists (unknown mode) + # or if stats file is not empty + if [[ ! -f "$PROVISION_STATS_FILE" ]] || [[ -s "$PROVISION_STATS_FILE" ]]; then + /opt/docker/bin/provision run --tag "${ANSIBLE_TAG}" --use-registry + fi } diff --git a/docker/base/debian-7/conf/bin/control.sh b/docker/base/debian-7/conf/bin/control.sh index a6697092d..22d189745 100644 --- a/docker/base/debian-7/conf/bin/control.sh +++ b/docker/base/debian-7/conf/bin/control.sh @@ -101,23 +101,13 @@ case "$CONTROL_COMMAND" in ## ------------------------------------------ "service.enable") - SERVICE_FILE="/opt/docker/etc/supervisor.d/$1.conf" - if [ -f "$SERVICE_FILE" ]; then - sed -i '/autostart = /c\autostart = true' -- "$SERVICE_FILE" - else - echo "[ERROR] Service '${1}' not found (tried ${SERVICE_FILE})" - exit 1 - fi + deprecationNotice " Please use >>docker-service-enable [service]<<" + docker-service-enable "$1" ;; "service.disable") - SERVICE_FILE="/opt/docker/etc/supervisor.d/$1.conf" - if [ -f "$SERVICE_FILE" ]; then - sed -i '/autostart = /c\autostart = false' -- "$SERVICE_FILE" - else - echo "[ERROR] Service '${1}' not found (tried ${SERVICE_FILE})" - exit 1 - fi + deprecationNotice " Please use >>docker-service-disable [service]<<" + docker-service-disable "$1" ;; ## ------------------------------------------ diff --git a/docker/base/debian-7/conf/bin/entrypoint.d/cli.sh b/docker/base/debian-7/conf/bin/entrypoint.d/cli.sh index 2ca68926c..fe212a8ea 100644 --- a/docker/base/debian-7/conf/bin/entrypoint.d/cli.sh +++ b/docker/base/debian-7/conf/bin/entrypoint.d/cli.sh @@ -8,7 +8,7 @@ if [ -n "${CLI_SCRIPT}" ]; then if [ -n "$APPLICATION_USER" ]; then # Run as EFFECTIVE_USER shift - exec sudo -H -E -u "${APPLICATION_USER}" ${CLI_SCRIPT} "$@" + exec gosu "${APPLICATION_USER}" ${CLI_SCRIPT} "$@" else # Run as root exec ${CLI_SCRIPT} "$@" diff --git a/docker/base/debian-7/conf/bin/entrypoint.d/noop.sh b/docker/base/debian-7/conf/bin/entrypoint.d/noop.sh index 967920837..092d55d8b 100644 --- a/docker/base/debian-7/conf/bin/entrypoint.d/noop.sh +++ b/docker/base/debian-7/conf/bin/entrypoint.d/noop.sh @@ -4,5 +4,4 @@ ## NOOP (no operation) ############################################# -tail -f /dev/null -exit +exec tail -f /dev/null diff --git a/docker/base/debian-7/conf/bin/entrypoint.d/supervisord.sh b/docker/base/debian-7/conf/bin/entrypoint.d/supervisord.sh index ead991551..f21489667 100644 --- a/docker/base/debian-7/conf/bin/entrypoint.d/supervisord.sh +++ b/docker/base/debian-7/conf/bin/entrypoint.d/supervisord.sh @@ -4,8 +4,6 @@ ## Supervisord (start daemons) ############################################# -rootCheck "supervisord" - ## Start services exec /opt/docker/bin/service.d/supervisor.sh diff --git a/docker/base/debian-7/conf/bin/entrypoint.sh b/docker/base/debian-7/conf/bin/entrypoint.sh index bbabcdddb..01f59660c 100644 --- a/docker/base/debian-7/conf/bin/entrypoint.sh +++ b/docker/base/debian-7/conf/bin/entrypoint.sh @@ -20,16 +20,13 @@ chmod -s /usr/local/bin/gosu trap 'echo sigterm ; exit' SIGTERM trap 'echo sigkill ; exit' SIGKILL -# link stdout from docker -ln -f -s "/proc/$$/fd/1" /docker.stdout -ln -f -s "/proc/$$/fd/2" /docker.stderr -chmod 600 /docker.stdout /docker.stderr - # sanitize input and set task TASK="$(echo $1| sed 's/[^-_a-zA-Z0-9]*//g')" source /opt/docker/bin/config.sh +createDockerStdoutStderr + if [[ "$UID" -eq 0 ]]; then # Only run provision if user is root diff --git a/docker/base/debian-7/conf/bin/logwatch.sh b/docker/base/debian-7/conf/bin/logwatch.sh deleted file mode 100644 index 1a5b486c7..000000000 --- a/docker/base/debian-7/conf/bin/logwatch.sh +++ /dev/null @@ -1,14 +0,0 @@ -#!/usr/bin/env bash - -set -o pipefail # trace ERR through pipes -set -o errtrace # trace ERR through 'time command' and other functions -set -o nounset ## set -u : exit the script if you try to use an uninitialised variable -set -o errexit ## set -e : exit the script if any statement returns a non-true return value - -sleep 0.5 - -if [ -p "$2" ]; then - sed --unbuffered -e "s/^/\[$1\] /" -- "$2" -else - tail -n 0 -F -q "$2" | sed --unbuffered -e "s/^/\[$1\] /" -fi diff --git a/docker/base/debian-7/conf/bin/provision b/docker/base/debian-7/conf/bin/provision index f7b5ad0a8..d367c2812 100755 --- a/docker/base/debian-7/conf/bin/provision +++ b/docker/base/debian-7/conf/bin/provision @@ -19,6 +19,7 @@ PLAYBOOK = Template( - hosts: all vars_files: + - ./variables-webdevops.yml - ./variables.yml roles: - $roles @@ -188,7 +189,7 @@ def actionAdd(args): 'priority': args.priority } - saveJson(json); + saveJson(json) diff --git a/docker/base/debian-7/conf/bin/provision.sh b/docker/base/debian-7/conf/bin/provision.sh deleted file mode 100644 index 4079dd7f0..000000000 --- a/docker/base/debian-7/conf/bin/provision.sh +++ /dev/null @@ -1,30 +0,0 @@ - #!/usr/bin/env bash - -# -# Example: -# provision.sh /opt/foobar/playbook.yml tag -# -# - -set -o pipefail # trace ERR through pipes -set -o errtrace # trace ERR through 'time command' and other functions -set -o nounset ## set -u : exit the script if you try to use an uninitialised variable -set -o errexit ## set -e : exit the script if any statement returns a non-true return value - -. config.sh - -deprecationNotice " Please use >>/opt/docker/bin/provision run --playbook playbook.yml --tag=bootstrap [args]<< for running provision" - - -if [ "$#" -lt 2 ]; then - echo "[ERROR] $0: Playbook or tag is missing" - exit 1 -fi - -ANSIBLE_PLAYBOOK="$1" -shift -ANSIBLE_TAG="$1" -shift -ANSIBLE_OPTS="$@" - -/opt/docker/bin/provision run --playbook "${ANSIBLE_PLAYBOOK}" --use-registry --tag "${ANSIBLE_TAG}" $ANSIBLE_OPTS diff --git a/docker/base-app/debian-7/conf/bin/service.d/dnsmasq.d/10-init.sh b/docker/base/debian-7/conf/bin/service.d/dnsmasq.d/10-init.sh similarity index 100% rename from docker/base-app/debian-7/conf/bin/service.d/dnsmasq.d/10-init.sh rename to docker/base/debian-7/conf/bin/service.d/dnsmasq.d/10-init.sh diff --git a/docker/base-app/debian-7/conf/bin/service.d/dnsmasq.sh b/docker/base/debian-7/conf/bin/service.d/dnsmasq.sh similarity index 100% rename from docker/base-app/debian-7/conf/bin/service.d/dnsmasq.sh rename to docker/base/debian-7/conf/bin/service.d/dnsmasq.sh diff --git a/docker/base/debian-7/conf/bin/service.d/postfix.d/10-init.sh b/docker/base/debian-7/conf/bin/service.d/postfix.d/10-init.sh new file mode 100644 index 000000000..cfd876955 --- /dev/null +++ b/docker/base/debian-7/conf/bin/service.d/postfix.d/10-init.sh @@ -0,0 +1,27 @@ +# force new copy of hosts there (otherwise links could be outdated) +mkdir -p /var/spool/postfix/etc +cp -f /etc/hosts /var/spool/postfix/etc/hosts +cp -f /etc/resolv.conf /var/spool/postfix/etc/resolv.conf +cp -f /etc/services /var/spool/postfix/etc/services + +## MYHOSTNAME +# replace line +sed -i '/myhostname[ ]* =/c\' main.cf +echo "myhostname = $(hostname)" >> /etc/postfix/main.cf + +## REPLAYHOST +if [[ -n "${POSTFIX_RELAYHOST+x}" ]]; then + # replace line + sed -i '/relayhost[ ]* =/c\' main.cf + echo "relayhost = $POSTFIX_RELAYHOST" >> /etc/postfix/main.cf +fi + +## MYNETWORKS +if [[ -n "${POSTFIX_MYNETWORKS+x}" ]]; then + # replace line + sed -i '/mynetworks[ ]* =/c\' main.cf + echo "mynetworks = $POSTFIX_MYNETWORKS" >> /etc/postfix/main.cf +fi + +# generate aliases db +newaliases || : diff --git a/docker/base-app/debian-7/conf/bin/service.d/postfix.sh b/docker/base/debian-7/conf/bin/service.d/postfix.sh similarity index 100% rename from docker/base-app/debian-7/conf/bin/service.d/postfix.sh rename to docker/base/debian-7/conf/bin/service.d/postfix.sh diff --git a/docker/base/debian-7/conf/bin/service.d/ssh.d/10-init.sh b/docker/base/debian-7/conf/bin/service.d/ssh.d/10-init.sh new file mode 100644 index 000000000..f2b600312 --- /dev/null +++ b/docker/base/debian-7/conf/bin/service.d/ssh.d/10-init.sh @@ -0,0 +1,7 @@ +# Init ssh privilege separation directory +mkdir -p /var/run/sshd +chown root:root /var/run/sshd +chmod 755 /var/run/sshd + +# generate host keys +ssh-keygen -A diff --git a/docker/base-app/debian-7/conf/bin/service.d/ssh.sh b/docker/base/debian-7/conf/bin/service.d/ssh.sh similarity index 100% rename from docker/base-app/debian-7/conf/bin/service.d/ssh.sh rename to docker/base/debian-7/conf/bin/service.d/ssh.sh diff --git a/docker/base/debian-7/conf/bin/service.d/syslog-ng.d/10-init.sh b/docker/base/debian-7/conf/bin/service.d/syslog-ng.d/10-init.sh index 22621d2ad..326207e52 100644 --- a/docker/base/debian-7/conf/bin/service.d/syslog-ng.d/10-init.sh +++ b/docker/base/debian-7/conf/bin/service.d/syslog-ng.d/10-init.sh @@ -6,5 +6,5 @@ if [ ! -S /var/lib/syslog-ng/syslog-ng.ctl ]; then rm -f /var/lib/syslog-ng/sysl if [[ ! -p /docker.stdout ]]; then # Switch to file (tty docker mode) - rpl --quiet 'pipe("/docker.stdout")' 'file("/docker.stdout")' -- /opt/docker/etc/syslog-ng/syslog-ng.conf > /dev/null + go-replace -s 'pipe("/docker.stdout")' -r 'file("/docker.stdout")' -- /opt/docker/etc/syslog-ng/syslog-ng.conf fi diff --git a/docker/base/debian-7/conf/bin/usr-bin/docker-provision b/docker/base/debian-7/conf/bin/usr-bin/docker-provision new file mode 100644 index 000000000..4ee715c64 --- /dev/null +++ b/docker/base/debian-7/conf/bin/usr-bin/docker-provision @@ -0,0 +1,9 @@ +#!/usr/bin/env bash + +set -o pipefail # trace ERR through pipes +set -o errtrace # trace ERR through 'time command' and other functions +set -o nounset ## set -u : exit the script if you try to use an uninitialised variable +set -o errexit ## set -e : exit the script if any statement returns a non-true return value + +# wrapper +exec /opt/docker/bin/provision "$@" diff --git a/docker/base/debian-7/conf/bin/usr-bin/docker-service-disable b/docker/base/debian-7/conf/bin/usr-bin/docker-service-disable new file mode 100644 index 000000000..2b5b31bb4 --- /dev/null +++ b/docker/base/debian-7/conf/bin/usr-bin/docker-service-disable @@ -0,0 +1,30 @@ +#!/usr/bin/env bash + +set -o pipefail # trace ERR through pipes +set -o errtrace # trace ERR through 'time command' and other functions +set -o nounset ## set -u : exit the script if you try to use an uninitialised variable +set -o errexit ## set -e : exit the script if any statement returns a non-true return value + +source /opt/docker/bin/config.sh + +rootCheck "$0" + +if [[ "$#" -eq 0 ]]; then + echo "Usage: $0 " + exit 1 +fi + +for SERVICE in "$@"; do + SERVICE_FILE="/opt/docker/etc/supervisor.d/${SERVICE}.conf" + + ## Disable service + if [[ -f "$SERVICE_FILE" ]]; then + go-replace --mode=lineinfile \ + -s 'autostart =' -r 'autostart = false' \ + -- "$SERVICE_FILE" + else + echo "[ERROR] Service '${SERVICE}' not found (tried ${SERVICE_FILE})" + exit 1 + fi +done + diff --git a/docker/base/debian-7/conf/bin/usr-bin/docker-service-enable b/docker/base/debian-7/conf/bin/usr-bin/docker-service-enable new file mode 100644 index 000000000..8d36a14a9 --- /dev/null +++ b/docker/base/debian-7/conf/bin/usr-bin/docker-service-enable @@ -0,0 +1,41 @@ +#!/usr/bin/env bash + +set -o pipefail # trace ERR through pipes +set -o errtrace # trace ERR through 'time command' and other functions +set -o nounset ## set -u : exit the script if you try to use an uninitialised variable +set -o errexit ## set -e : exit the script if any statement returns a non-true return value + +source /opt/docker/bin/config.sh + +rootCheck "$0" + +if [[ "$#" -eq 0 ]]; then + echo "Usage: $0 " + exit 1 +fi + +for SERVICE in "$@"; do + SERVICE_FILE="/opt/docker/etc/supervisor.d/${SERVICE}.conf" + PROVISION_FILE="/opt/docker/provision/service.d/${SERVICE}.sh" + + # Run on demand installation/provisioning + if [[ -f "$PROVISION_FILE" ]]; then + echo "Running provisioning for ${SERVICE}, please wait..." + + ## execute scripts + . "$PROVISION_FILE" + + ## remove directory (one run time) + rm -f -- "$PROVISION_FILE" + fi + + ## Enable service + if [[ -f "$SERVICE_FILE" ]]; then + go-replace --mode=lineinfile \ + -s 'autostart =' -r 'autostart = true' \ + -- "$SERVICE_FILE" + else + echo "[ERROR] Service '${SERVICE}' not found (tried ${SERVICE_FILE})" + exit 1 + fi +done diff --git a/docker/base/debian-7/conf/bin/usr-bin/service b/docker/base/debian-7/conf/bin/usr-bin/service new file mode 100755 index 000000000..55ea12bf7 --- /dev/null +++ b/docker/base/debian-7/conf/bin/usr-bin/service @@ -0,0 +1,86 @@ +#!/bin/bash + +set -o pipefail # trace ERR through pipes +set -o errtrace # trace ERR through 'time command' and other functions +set -o nounset ## set -u : exit the script if you try to use an uninitialised variable +set -o errexit ## set -e : exit the script if any statement returns a non-true return value + +# Root check +if [ "$(/usr/bin/whoami)" != "root" ]; then + echo "[ERROR] Must be run as root" + exit 1 +fi + +function serviceHelp() { + echo "Usage: $(basename "$0") " +} + +function getServicePid() { + local serviceName="$1" + local servicePid=$(supervisorctl pid "${serviceName}:${serviceName}d") + + if [[ -z "$servicePid" ]] || [[ "$servicePid" == "0" ]]; then + echo "not running" + exit 1 + fi + + echo $servicePid +} + +# Param check +if [ "$#" -lt 2 ]; then + echo "[ERROR] Missing parameters" + serviceHelp + exit 1 +fi + +############################# +# Param init +############################# + +SERVICENAME="$1" +ACTION="$2" + +############################# +# Service aliases +############################# +case "$SERVICENAME" in + apache2|httpd) + SERVICENAME="apache" + ;; +esac + +############################# +# Action runner +############################# +case "$ACTION" in + stop|start|restart|status) + exec supervisorctl "$ACTION" "${SERVICENAME}:${SERVICENAME}d" + ;; + + pid) + echo $(getServicePid "${SERVICENAME}") + ;; + + check) + FIRST_PID=$(getServicePid "${SERVICENAME}") + sleep 5 + SECOND_PID=$(getServicePid "${SERVICENAME}") + + if [[ "$FIRST_PID" == "$SECOND_PID" ]]; then + echo "ok" + exit 0 + else + echo "not running" + exit 1 + fi + ;; + + + *) + echo "[ERROR] Invalid action" + serviceHelp + exit 1 + ;; + +esac diff --git a/docker/base/debian-7/conf/etc/supervisor.conf b/docker/base/debian-7/conf/etc/supervisor.conf index 7c109515a..479e0db08 100644 --- a/docker/base/debian-7/conf/etc/supervisor.conf +++ b/docker/base/debian-7/conf/etc/supervisor.conf @@ -2,9 +2,16 @@ nodaemon=true [unix_http_server] -file = /var/run/supervisor.sock -# username = root -# password = {SHA}e982f17bcbe0f724063b708a4f76db211a999304 +file = /.supervisor.sock +chmod = 0700 +chown = root:root +username = root +password = {SHA}e982f17bcbe0f724063b708a4f76db211a999304 + +[supervisorctl] +serverurl = unix:///.supervisor.sock +username = root +password = docker [rpcinterface:supervisor] supervisor.rpcinterface_factory = supervisor.rpcinterface:make_main_rpcinterface diff --git a/docker/base/debian-7/conf/etc/supervisor.d/dnsmasq.conf b/docker/base/debian-7/conf/etc/supervisor.d/dnsmasq.conf new file mode 100644 index 000000000..9832ffca7 --- /dev/null +++ b/docker/base/debian-7/conf/etc/supervisor.d/dnsmasq.conf @@ -0,0 +1,14 @@ +[group:dnsmasq] +programs=dnsmasqd +priority=15 + +[program:dnsmasqd] +command = /opt/docker/bin/service.d/dnsmasq.sh +process_name=%(program_name)s +startsecs = 0 +autostart = false +autorestart = true +stdout_logfile=/dev/stdout +stdout_logfile_maxbytes=0 +stderr_logfile=/dev/stderr +stderr_logfile_maxbytes=0 diff --git a/docker/base-app/debian-7/conf/etc/supervisor.d/postfix.conf b/docker/base/debian-7/conf/etc/supervisor.d/postfix.conf similarity index 100% rename from docker/base-app/debian-7/conf/etc/supervisor.d/postfix.conf rename to docker/base/debian-7/conf/etc/supervisor.d/postfix.conf diff --git a/docker/base-app/debian-7/conf/etc/supervisor.d/ssh.conf b/docker/base/debian-7/conf/etc/supervisor.d/ssh.conf similarity index 100% rename from docker/base-app/debian-7/conf/etc/supervisor.d/ssh.conf rename to docker/base/debian-7/conf/etc/supervisor.d/ssh.conf diff --git a/docker/base/debian-7/conf/etc/supervisor.d/syslog-ng.conf b/docker/base/debian-7/conf/etc/supervisor.d/syslog-ng.conf deleted file mode 100644 index 247fd1a25..000000000 --- a/docker/base/debian-7/conf/etc/supervisor.d/syslog-ng.conf +++ /dev/null @@ -1,13 +0,0 @@ -[group:syslog] -programs=syslogd -priority=10 - -[program:syslogd] -command = /opt/docker/bin/service.d/syslog-ng.sh -process_name=%(program_name)s -autostart = true -autorestart = true -stdout_logfile=/dev/stdout -stdout_logfile_maxbytes=0 -stderr_logfile=/dev/stderr -stderr_logfile_maxbytes=0 diff --git a/docker/base/debian-7/conf/etc/supervisor.d/syslog.conf b/docker/base/debian-7/conf/etc/supervisor.d/syslog.conf new file mode 100644 index 000000000..20d1e238c --- /dev/null +++ b/docker/base/debian-7/conf/etc/supervisor.d/syslog.conf @@ -0,0 +1,13 @@ +[group:syslog] +programs=syslogd +priority=10 + +[program:syslogd] +command = /opt/docker/bin/service.d/syslog-ng.sh +process_name=%(program_name)s +autostart = false +autorestart = true +stdout_logfile=/dev/stdout +stdout_logfile_maxbytes=0 +stderr_logfile=/dev/stderr +stderr_logfile_maxbytes=0 diff --git a/docker/base/debian-7/conf/provision/roles/webdevops-base/tasks/bootstrap.yml b/docker/base/debian-7/conf/provision/roles/webdevops-base/tasks/bootstrap.yml index 30be03c38..9f842336c 100644 --- a/docker/base/debian-7/conf/provision/roles/webdevops-base/tasks/bootstrap.yml +++ b/docker/base/debian-7/conf/provision/roles/webdevops-base/tasks/bootstrap.yml @@ -4,6 +4,5 @@ - include: bootstrap/misc.yml - include: bootstrap/root.yml - include: bootstrap/supervisor.yml -- include: bootstrap/syslog-ng.yml -- include: bootstrap/logrotate.yml - include: bootstrap/pam.yml +- include: bootstrap/entrypoint.yml diff --git a/docker/base/debian-7/conf/provision/roles/webdevops-base/tasks/bootstrap/entrypoint.yml b/docker/base/debian-7/conf/provision/roles/webdevops-base/tasks/bootstrap/entrypoint.yml new file mode 100644 index 000000000..d5d8809f4 --- /dev/null +++ b/docker/base/debian-7/conf/provision/roles/webdevops-base/tasks/bootstrap/entrypoint.yml @@ -0,0 +1,8 @@ +--- + +- name: Create link for entrypoint + file: + src: '/opt/docker/bin/entrypoint.sh' + dest: '/entrypoint' + state: link + force: yes diff --git a/docker/base/debian-7/conf/provision/roles/webdevops-base/tasks/bootstrap/logrotate.yml b/docker/base/debian-7/conf/provision/roles/webdevops-base/tasks/bootstrap/logrotate.yml deleted file mode 100644 index d87926be2..000000000 --- a/docker/base/debian-7/conf/provision/roles/webdevops-base/tasks/bootstrap/logrotate.yml +++ /dev/null @@ -1,33 +0,0 @@ ---- - -- name: Configure logrotate running user - lineinfile: - dest: /etc/logrotate.conf - regexp: '^su [-_a-zA-Z0-9]+ [-_a-zA-Z0-9]+' - line: 'su root adm' - -- name: Register logrotate configurations - file: - src: '{{ item }}' - dest: '/etc/logrotate.d/{{ item | basename }}' - state: link - force: yes - with_fileglob: - - /opt/docker/etc/logrotate.d/* - -- name: Remove system logrotates (not needed) - file: - path: '{{ item }}' - state: absent - with_items: - # Debian/Ubuntu - - /etc/cron.daily/logrotate - - /etc/cron.daily/apt-compat - - /etc/cron.daily/dpkg - - /etc/cron.daily/passwd - # RedHat - - /etc/cron.daily/0yum-daily.cron - - /etc/cron.daily/logrotate - - /etc/cron.hourly/0yum-hourly.cron - # Alpine - - /etc/periodic/daily/logrotate diff --git a/docker/base/debian-7/conf/provision/roles/webdevops-base/tasks/bootstrap/supervisor.yml b/docker/base/debian-7/conf/provision/roles/webdevops-base/tasks/bootstrap/supervisor.yml index bda0394b6..2ce07ac26 100644 --- a/docker/base/debian-7/conf/provision/roles/webdevops-base/tasks/bootstrap/supervisor.yml +++ b/docker/base/debian-7/conf/provision/roles/webdevops-base/tasks/bootstrap/supervisor.yml @@ -4,3 +4,10 @@ file: path: '/usr/sbin/service' state: absent + +- name: Create link for supervisor.conf + file: + src: '/opt/docker/etc/supervisor.conf' + dest: '/etc/supervisord.conf' + state: link + force: yes diff --git a/docker/base/debian-7/conf/provision/roles/webdevops-base/tasks/bootstrap/syslog-ng.yml b/docker/base/debian-7/conf/provision/roles/webdevops-base/tasks/bootstrap/syslog-ng.yml deleted file mode 100644 index 27c8f6a30..000000000 --- a/docker/base/debian-7/conf/provision/roles/webdevops-base/tasks/bootstrap/syslog-ng.yml +++ /dev/null @@ -1,33 +0,0 @@ ---- - -- name: Get syslog-ng version - shell: "syslog-ng --version | grep -E -e '^syslog-ng[ ]+[0-9]+\\.[0-9]+' | head -n 1 | awk '{print $2}' | cut -f 1,2 -d ." - register: syslogng_version - -- name: Configure syslog-ng (default) - lineinfile: - dest: /etc/default/syslog-ng - regexp: '^[\s]*{{ item.key }}[\s]*=' - line: '{{ item.key }}="{{ item.value }}"' - create: yes - with_items: - - { key: 'SYSLOGNG_OPTS', value: '--no-caps' } - -- name: Enable syslog-ng config - file: - src: '/opt/docker/etc/syslog-ng/syslog-ng.conf' - dest: '/etc/syslog-ng/syslog-ng.conf' - state: link - force: yes - -- name: Set version of syslog-ng file - lineinfile: - dest: '/etc/syslog-ng/syslog-ng.conf' - regexp: '^@version:' - line: '@version: {{ syslogng_version.stdout }}' - -- name: Ensure /var/lib/syslog-ng exists - file: - path: '/var/lib/syslog-ng' - state: directory - recurse: yes diff --git a/docker/base/debian-7/conf/provision/roles/webdevops-base/tasks/bootstrap/system.yml b/docker/base/debian-7/conf/provision/roles/webdevops-base/tasks/bootstrap/system.yml index 8dfbf9665..0741d7cae 100644 --- a/docker/base/debian-7/conf/provision/roles/webdevops-base/tasks/bootstrap/system.yml +++ b/docker/base/debian-7/conf/provision/roles/webdevops-base/tasks/bootstrap/system.yml @@ -14,3 +14,20 @@ dest: '/entrypoint.cmd' state: link force: yes + +- name: Remove system logrotate and cronjobs (not needed) + file: + path: '{{ item }}' + state: absent + with_items: + # Debian/Ubuntu + - /etc/cron.daily/logrotate + - /etc/cron.daily/apt-compat + - /etc/cron.daily/dpkg + - /etc/cron.daily/passwd + # RedHat + - /etc/cron.daily/0yum-daily.cron + - /etc/cron.daily/logrotate + - /etc/cron.hourly/0yum-hourly.cron + # Alpine + - /etc/periodic/daily/logrotate diff --git a/docker/php-apache-dev/alpine-3-php7/conf/etc/httpd/vhost.common.d/.gitkeep b/docker/base/debian-7/conf/provision/roles/webdevops-base/tasks/build/.gitkeep similarity index 100% rename from docker/php-apache-dev/alpine-3-php7/conf/etc/httpd/vhost.common.d/.gitkeep rename to docker/base/debian-7/conf/provision/roles/webdevops-base/tasks/build/.gitkeep diff --git a/docker/base/debian-7/conf/provision/roles/webdevops-base/tasks/build/logrotate.yml b/docker/base/debian-7/conf/provision/roles/webdevops-base/tasks/build/logrotate.yml deleted file mode 100644 index 10f7e6644..000000000 --- a/docker/base/debian-7/conf/provision/roles/webdevops-base/tasks/build/logrotate.yml +++ /dev/null @@ -1,10 +0,0 @@ ---- - -- name: Register logrotate configurations - file: - src: '{{ item }}' - dest: '/etc/logrotate.d/{{ item | basename }}' - state: link - force: yes - with_fileglob: - - /opt/docker/etc/logrotate.d/* diff --git a/docker/php-apache-dev/alpine-3/conf/etc/httpd/conf.d/.gitkeep b/docker/base/debian-7/conf/provision/service.d/.gitkeep similarity index 100% rename from docker/php-apache-dev/alpine-3/conf/etc/httpd/conf.d/.gitkeep rename to docker/base/debian-7/conf/provision/service.d/.gitkeep diff --git a/docker/base/debian-7/conf/provision/service.d/cron.sh b/docker/base/debian-7/conf/provision/service.d/cron.sh new file mode 100644 index 000000000..bd8a54781 --- /dev/null +++ b/docker/base/debian-7/conf/provision/service.d/cron.sh @@ -0,0 +1,13 @@ +#!/usr/bin/env bash + +IMAGE_FAMILY=$(docker-image-info family) + +case "$IMAGE_FAMILY" in + Debian|Ubuntu) + apt-install cron + ;; + + RedHat) + yum-install cronie + ;; +esac diff --git a/docker/base/debian-7/conf/provision/service.d/dnsmasq.sh b/docker/base/debian-7/conf/provision/service.d/dnsmasq.sh new file mode 100644 index 000000000..9e5c3228c --- /dev/null +++ b/docker/base/debian-7/conf/provision/service.d/dnsmasq.sh @@ -0,0 +1,24 @@ +#!/usr/bin/env bash + +IMAGE_FAMILY=$(docker-image-info family) + +# Installation +case "$IMAGE_FAMILY" in + Debian|Ubuntu) + apt-install dnsmasq + ;; + + RedHat) + yum-install dnsmasq + ;; + + Alpine) + apk-install dnsmasq + ;; +esac + +# Configuration +go-replace --mode=line \ + -s '^[\s]*user[\s]*=' -r 'user = root' \ + -s '^[\s]*conf-dir[\s]*=' -r 'conf-dir = /etc/dnsmasq.d' \ + -- /etc/dnsmasq.conf diff --git a/docker/base/debian-7/conf/provision/service.d/postfix.sh b/docker/base/debian-7/conf/provision/service.d/postfix.sh new file mode 100644 index 000000000..ff1879345 --- /dev/null +++ b/docker/base/debian-7/conf/provision/service.d/postfix.sh @@ -0,0 +1,28 @@ +#!/usr/bin/env bash + +IMAGE_FAMILY=$(docker-image-info family) + +# Installation +case "$IMAGE_FAMILY" in + Debian|Ubuntu) + apt-install postfix + ;; + + RedHat) + yum-install postfix + ;; + + Alpine) + apk-install postfix + ln -s -f /etc/postfix/aliases /etc/aliases + ;; +esac + +# Configuration +go-replace --mode=line \ + -s '^[\s]*mydestination[\s]*=' -r 'mydestination = ' \ + -s '^[\s]*message_size_limit[\s]*=' -r 'message_size_limit = 15240000' \ + -s '^[\s]*smtp_use_tls[\s]*=' -r 'smtp_use_tls = yes' \ + -s '^[\s]*smtp_tls_security_level[\s]*=' -r 'smtp_tls_security_level = may' \ + -s '^[\s]*myhostname[\s]*=' -r '# myhostname' \ + -- /etc/postfix/main.cf diff --git a/docker/base/debian-7/conf/provision/service.d/ssh.sh b/docker/base/debian-7/conf/provision/service.d/ssh.sh new file mode 100644 index 000000000..63d7a9f3a --- /dev/null +++ b/docker/base/debian-7/conf/provision/service.d/ssh.sh @@ -0,0 +1,17 @@ +#!/usr/bin/env bash + +IMAGE_FAMILY=$(docker-image-info family) + +case "$IMAGE_FAMILY" in + Debian|Ubuntu) + apt-install openssh-server + ;; + + RedHat) + yum-install openssh-server + ;; + + Alpine) + apk-install openssh + ;; +esac diff --git a/docker/base/debian-7/conf/provision/service.d/syslog.sh b/docker/base/debian-7/conf/provision/service.d/syslog.sh new file mode 100644 index 000000000..7e8b8e0a9 --- /dev/null +++ b/docker/base/debian-7/conf/provision/service.d/syslog.sh @@ -0,0 +1,41 @@ +#!/usr/bin/env bash + +IMAGE_FAMILY=$(docker-image-info family) + +# Installation +case "$IMAGE_FAMILY" in + Debian|Ubuntu) + apt-install syslog-ng syslog-ng-core + ;; + + RedHat) + yum-install syslog-ng + + # remove logrotate (not needed for docker) + rm -f "/etc/cron.daily/logrotate" + ;; + + Alpine) + apk-install syslog-ng + ;; +esac + +## Configuration +SYSLOG_NG_VERSION=$(syslog-ng --version | grep -E -e '^syslog-ng[ ]+[0-9]+\.[0-9]+' | head -n 1 | awk '{print $2}' | cut -f 1,2 -d .) + +# Disable caps inside container +if [[ -f /etc/default/syslog-ng ]]; then + go-replace --mode=lineinfile \ + -s "SYSLOGNG_OPTS" -r "SYSLOGNG_OPTS = --no-caps" \ + -- /etc/default/syslog-ng +fi + +# Symlink configuration +ln -s -f /opt/docker/etc/syslog-ng/syslog-ng.conf /etc/syslog-ng/syslog-ng.conf + +go-replace --mode=lineinfile \ + -s "@version" -r "@version: ${SYSLOG_NG_VERSION}" \ + -- /etc/syslog-ng/syslog-ng.conf + +# Ensure /var/lib/syslog-ng exists +mkdir -p /var/lib/syslog-ng diff --git a/docker/base/debian-7/conf/provision/variables-webdevops.yml b/docker/base/debian-7/conf/provision/variables-webdevops.yml new file mode 100644 index 000000000..0b2a21a95 --- /dev/null +++ b/docker/base/debian-7/conf/provision/variables-webdevops.yml @@ -0,0 +1,7 @@ +--- + +docker_image_info_family: "{{ lookup('pipe', 'docker-image-info family') }}" +docker_image_info_distribution: "{{ lookup('pipe', 'docker-image-info dist') }}" +docker_image_info_distribution_version: "{{ lookup('pipe', 'docker-image-info dist-version') }}" +docker_image_info_distribution_release: "{{ lookup('pipe', 'docker-image-info dist-release') }}" +docker_image_info_distribution_codename: "{{ lookup('pipe', 'docker-image-info dist-codename') }}" diff --git a/docker/base/debian-7/conf/provision/variables.yml b/docker/base/debian-7/conf/provision/variables.yml index ed97d539c..0b2a21a95 100644 --- a/docker/base/debian-7/conf/provision/variables.yml +++ b/docker/base/debian-7/conf/provision/variables.yml @@ -1 +1,7 @@ --- + +docker_image_info_family: "{{ lookup('pipe', 'docker-image-info family') }}" +docker_image_info_distribution: "{{ lookup('pipe', 'docker-image-info dist') }}" +docker_image_info_distribution_version: "{{ lookup('pipe', 'docker-image-info dist-version') }}" +docker_image_info_distribution_release: "{{ lookup('pipe', 'docker-image-info dist-release') }}" +docker_image_info_distribution_codename: "{{ lookup('pipe', 'docker-image-info dist-codename') }}" diff --git a/docker/base/debian-8/Dockerfile b/docker/base/debian-8/Dockerfile index 9249ec988..cafd0431e 100644 --- a/docker/base/debian-8/Dockerfile +++ b/docker/base/debian-8/Dockerfile @@ -5,31 +5,48 @@ FROM webdevops/bootstrap:debian-8 -MAINTAINER info@webdevops.io -LABEL vendor=WebDevOps.io -LABEL io.webdevops.layout=8 -LABEL io.webdevops.version=1.5.0 - -ENV DOCKER_CONF_HOME /opt/docker/ +ENV DOCKER_CONF_HOME=/opt/docker/ \ + LOG_STDOUT="" \ + LOG_STDERR="" COPY conf/ /opt/docker/ +# Install ansible +RUN /usr/local/bin/apt-install \ + # Install ansible + python-minimal \ + python-setuptools \ + python-pip \ + python-paramiko \ + python-jinja2 \ + python-dev \ + libffi-dev \ + libssl-dev \ + build-essential \ + && pip install --upgrade pip \ + && hash -r \ + && pip install --no-cache-dir ansible \ + && chmod 750 /usr/local/bin/ansible* \ + # Cleanup + && apt-get purge -y -f --force-yes \ + python-dev \ + build-essential \ + libssl-dev \ + libffi-dev \ + && docker-image-cleanup + # Install packages RUN chmod +x /opt/docker/bin/* \ && /usr/local/bin/apt-install \ supervisor \ - syslog-ng \ - syslog-ng-core \ - logrotate \ - cron \ wget \ curl \ net-tools \ gnupg \ && chmod +s /usr/local/bin/gosu \ && /opt/docker/bin/provision run --tag bootstrap --role webdevops-base \ - && /opt/docker/bin/bootstrap.sh - + && /opt/docker/bin/bootstrap.sh \ + && docker-image-cleanup ENTRYPOINT ["/opt/docker/bin/entrypoint.sh"] CMD ["supervisord"] diff --git a/docker/base/debian-8/Dockerfile.jinja2 b/docker/base/debian-8/Dockerfile.jinja2 index b8e1602cf..1a98267d3 100644 --- a/docker/base/debian-8/Dockerfile.jinja2 +++ b/docker/base/debian-8/Dockerfile.jinja2 @@ -1,11 +1,11 @@ {{ docker.from("bootstrap", "debian-8") }} -{{ docker.version() }} - -{{ environment.homePath() }} +{{ environment.base() }} {{ docker.copy('conf/', '/opt/docker/') }} +{{ ansible.debian() }} + {{ base.debian() }} {{ docker.entrypoint("/opt/docker/bin/entrypoint.sh") }} diff --git a/docker/base/debian-8/conf/bin/bootstrap.sh b/docker/base/debian-8/conf/bin/bootstrap.sh index 1d1a30f72..855c10782 100644 --- a/docker/base/debian-8/conf/bin/bootstrap.sh +++ b/docker/base/debian-8/conf/bin/bootstrap.sh @@ -17,10 +17,16 @@ rootCheck "$0" # Save the buildtime date +%s > /opt/docker/BUILDTIME +date +%s >/opt/docker/etc/.registry/image_info_buildtime # Make all scripts executable find /opt/docker/bin/ -type f -iname '*.sh' -print0 | xargs --no-run-if-empty -0 chmod +x +# Enable usr-bin executables +find /opt/docker/bin/usr-bin -type f | while read USR_BIN_FILE; do + chmod +x -- "$USR_BIN_FILE" + ln -n -f -- "$USR_BIN_FILE" "/usr/local/bin/$(basename "$USR_BIN_FILE")" +done case "$BOOTSTRAP_MODE" in ################################### @@ -44,6 +50,23 @@ case "$BOOTSTRAP_MODE" in echo "[ERROR] Bootstrap mode '$BOOTSTRAP_MODE' not defined" exit 1 ;; - esac + +###################### +# Check if entrypoint provisioning is available +###################### + +echo "Checking provision status..." +for PROVISION_TAG in onbuild build bootstrap entrypoint; do + ROLES=$(docker-provision list --tag "$PROVISION_TAG") + if [[ -n "$ROLES" ]]; then + PROVISION_ROLE_COUNT=$(echo "$ROLES" | wc -l) + echo " - found ${PROVISION_ROLE_COUNT} for provision tag ${PROVISION_TAG}, caching info for execution" + echo -n "$PROVISION_ROLE_COUNT" > "/opt/docker/etc/.registry/provision-availale.${PROVISION_TAG}" + else + echo " - no roles found for provision tag ${PROVISION_TAG}" + echo -n '' > "/opt/docker/etc/.registry/provision-availale.${PROVISION_TAG}" + fi +done + diff --git a/docker/base/debian-8/conf/bin/config.sh b/docker/base/debian-8/conf/bin/config.sh index 3155728e8..049756c26 100644 --- a/docker/base/debian-8/conf/bin/config.sh +++ b/docker/base/debian-8/conf/bin/config.sh @@ -15,44 +15,23 @@ function rootCheck() { } ### - # Create named pipe - # - # $1 -> name of file + # Create /docker.stdout and /docker.stderr # ## -function createNamedPipe() { - rm --force -- "$1" - mknod "$1" p -} - -### - # Escape value for sed usage - # - # $1 -> value - # STDOUT -> escaped value - # - ## -function sedEscape() { - echo "$(echo $* |sed -e 's/[]\/$*.^|[]/\\&/g')" -} +function createDockerStdoutStderr() { + # link stdout from docker + if [[ -z "$LOG_STDOUT" ]]; then + LOG_STDOUT="/proc/$$/fd/1" + fi -### - # Replace text inside a file - # - # $1 -> source value - # $2 -> target value - # $3 -> path to file - # - ## -function replaceTextInFile() { - SOURCE="$(sedEscape $1)" - REPLACE="$(sedEscape $2)" - TARGET="$3" + if [[ -z "$LOG_STDERR" ]]; then + LOG_STDERR="/proc/$$/fd/2" + fi - sed -i "s/${SOURCE}/${REPLACE}/" "${TARGET}" + ln -f -s "$LOG_STDOUT" /docker.stdout + ln -f -s "$LOG_STDERR" /docker.stderr + chmod 600 /docker.stdout /docker.stderr } - - ### # Include script directory text inside a file # @@ -104,7 +83,7 @@ function runEntrypoints() { . /opt/docker/bin/entrypoint.d/default.sh fi - exit + exit 1 } ### @@ -161,6 +140,12 @@ function runProvisionEntrypoint() { function runDockerProvision() { ANSIBLE_TAG="$1" - /opt/docker/bin/provision run --tag "$ANSIBLE_TAG" --use-registry + PROVISION_STATS_FILE="/opt/docker/etc/.registry/provision-stats.${ANSIBLE_TAG}" + + # run provision if stats file doesn't exists (unknown mode) + # or if stats file is not empty + if [[ ! -f "$PROVISION_STATS_FILE" ]] || [[ -s "$PROVISION_STATS_FILE" ]]; then + /opt/docker/bin/provision run --tag "${ANSIBLE_TAG}" --use-registry + fi } diff --git a/docker/base/debian-8/conf/bin/control.sh b/docker/base/debian-8/conf/bin/control.sh index a6697092d..22d189745 100644 --- a/docker/base/debian-8/conf/bin/control.sh +++ b/docker/base/debian-8/conf/bin/control.sh @@ -101,23 +101,13 @@ case "$CONTROL_COMMAND" in ## ------------------------------------------ "service.enable") - SERVICE_FILE="/opt/docker/etc/supervisor.d/$1.conf" - if [ -f "$SERVICE_FILE" ]; then - sed -i '/autostart = /c\autostart = true' -- "$SERVICE_FILE" - else - echo "[ERROR] Service '${1}' not found (tried ${SERVICE_FILE})" - exit 1 - fi + deprecationNotice " Please use >>docker-service-enable [service]<<" + docker-service-enable "$1" ;; "service.disable") - SERVICE_FILE="/opt/docker/etc/supervisor.d/$1.conf" - if [ -f "$SERVICE_FILE" ]; then - sed -i '/autostart = /c\autostart = false' -- "$SERVICE_FILE" - else - echo "[ERROR] Service '${1}' not found (tried ${SERVICE_FILE})" - exit 1 - fi + deprecationNotice " Please use >>docker-service-disable [service]<<" + docker-service-disable "$1" ;; ## ------------------------------------------ diff --git a/docker/base/debian-8/conf/bin/entrypoint.d/cli.sh b/docker/base/debian-8/conf/bin/entrypoint.d/cli.sh index 2ca68926c..fe212a8ea 100644 --- a/docker/base/debian-8/conf/bin/entrypoint.d/cli.sh +++ b/docker/base/debian-8/conf/bin/entrypoint.d/cli.sh @@ -8,7 +8,7 @@ if [ -n "${CLI_SCRIPT}" ]; then if [ -n "$APPLICATION_USER" ]; then # Run as EFFECTIVE_USER shift - exec sudo -H -E -u "${APPLICATION_USER}" ${CLI_SCRIPT} "$@" + exec gosu "${APPLICATION_USER}" ${CLI_SCRIPT} "$@" else # Run as root exec ${CLI_SCRIPT} "$@" diff --git a/docker/base/debian-8/conf/bin/entrypoint.d/noop.sh b/docker/base/debian-8/conf/bin/entrypoint.d/noop.sh index 967920837..092d55d8b 100644 --- a/docker/base/debian-8/conf/bin/entrypoint.d/noop.sh +++ b/docker/base/debian-8/conf/bin/entrypoint.d/noop.sh @@ -4,5 +4,4 @@ ## NOOP (no operation) ############################################# -tail -f /dev/null -exit +exec tail -f /dev/null diff --git a/docker/base/debian-8/conf/bin/entrypoint.d/supervisord.sh b/docker/base/debian-8/conf/bin/entrypoint.d/supervisord.sh index ead991551..f21489667 100644 --- a/docker/base/debian-8/conf/bin/entrypoint.d/supervisord.sh +++ b/docker/base/debian-8/conf/bin/entrypoint.d/supervisord.sh @@ -4,8 +4,6 @@ ## Supervisord (start daemons) ############################################# -rootCheck "supervisord" - ## Start services exec /opt/docker/bin/service.d/supervisor.sh diff --git a/docker/base/debian-8/conf/bin/entrypoint.sh b/docker/base/debian-8/conf/bin/entrypoint.sh index bbabcdddb..01f59660c 100644 --- a/docker/base/debian-8/conf/bin/entrypoint.sh +++ b/docker/base/debian-8/conf/bin/entrypoint.sh @@ -20,16 +20,13 @@ chmod -s /usr/local/bin/gosu trap 'echo sigterm ; exit' SIGTERM trap 'echo sigkill ; exit' SIGKILL -# link stdout from docker -ln -f -s "/proc/$$/fd/1" /docker.stdout -ln -f -s "/proc/$$/fd/2" /docker.stderr -chmod 600 /docker.stdout /docker.stderr - # sanitize input and set task TASK="$(echo $1| sed 's/[^-_a-zA-Z0-9]*//g')" source /opt/docker/bin/config.sh +createDockerStdoutStderr + if [[ "$UID" -eq 0 ]]; then # Only run provision if user is root diff --git a/docker/base/debian-8/conf/bin/logwatch.sh b/docker/base/debian-8/conf/bin/logwatch.sh deleted file mode 100644 index 1a5b486c7..000000000 --- a/docker/base/debian-8/conf/bin/logwatch.sh +++ /dev/null @@ -1,14 +0,0 @@ -#!/usr/bin/env bash - -set -o pipefail # trace ERR through pipes -set -o errtrace # trace ERR through 'time command' and other functions -set -o nounset ## set -u : exit the script if you try to use an uninitialised variable -set -o errexit ## set -e : exit the script if any statement returns a non-true return value - -sleep 0.5 - -if [ -p "$2" ]; then - sed --unbuffered -e "s/^/\[$1\] /" -- "$2" -else - tail -n 0 -F -q "$2" | sed --unbuffered -e "s/^/\[$1\] /" -fi diff --git a/docker/base/debian-8/conf/bin/provision b/docker/base/debian-8/conf/bin/provision index f7b5ad0a8..d367c2812 100755 --- a/docker/base/debian-8/conf/bin/provision +++ b/docker/base/debian-8/conf/bin/provision @@ -19,6 +19,7 @@ PLAYBOOK = Template( - hosts: all vars_files: + - ./variables-webdevops.yml - ./variables.yml roles: - $roles @@ -188,7 +189,7 @@ def actionAdd(args): 'priority': args.priority } - saveJson(json); + saveJson(json) diff --git a/docker/base/debian-8/conf/bin/provision.sh b/docker/base/debian-8/conf/bin/provision.sh deleted file mode 100644 index 4079dd7f0..000000000 --- a/docker/base/debian-8/conf/bin/provision.sh +++ /dev/null @@ -1,30 +0,0 @@ - #!/usr/bin/env bash - -# -# Example: -# provision.sh /opt/foobar/playbook.yml tag -# -# - -set -o pipefail # trace ERR through pipes -set -o errtrace # trace ERR through 'time command' and other functions -set -o nounset ## set -u : exit the script if you try to use an uninitialised variable -set -o errexit ## set -e : exit the script if any statement returns a non-true return value - -. config.sh - -deprecationNotice " Please use >>/opt/docker/bin/provision run --playbook playbook.yml --tag=bootstrap [args]<< for running provision" - - -if [ "$#" -lt 2 ]; then - echo "[ERROR] $0: Playbook or tag is missing" - exit 1 -fi - -ANSIBLE_PLAYBOOK="$1" -shift -ANSIBLE_TAG="$1" -shift -ANSIBLE_OPTS="$@" - -/opt/docker/bin/provision run --playbook "${ANSIBLE_PLAYBOOK}" --use-registry --tag "${ANSIBLE_TAG}" $ANSIBLE_OPTS diff --git a/docker/base-app/debian-8/conf/bin/service.d/dnsmasq.d/10-init.sh b/docker/base/debian-8/conf/bin/service.d/dnsmasq.d/10-init.sh similarity index 100% rename from docker/base-app/debian-8/conf/bin/service.d/dnsmasq.d/10-init.sh rename to docker/base/debian-8/conf/bin/service.d/dnsmasq.d/10-init.sh diff --git a/docker/base-app/debian-8/conf/bin/service.d/dnsmasq.sh b/docker/base/debian-8/conf/bin/service.d/dnsmasq.sh similarity index 100% rename from docker/base-app/debian-8/conf/bin/service.d/dnsmasq.sh rename to docker/base/debian-8/conf/bin/service.d/dnsmasq.sh diff --git a/docker/base/debian-8/conf/bin/service.d/postfix.d/10-init.sh b/docker/base/debian-8/conf/bin/service.d/postfix.d/10-init.sh new file mode 100644 index 000000000..cfd876955 --- /dev/null +++ b/docker/base/debian-8/conf/bin/service.d/postfix.d/10-init.sh @@ -0,0 +1,27 @@ +# force new copy of hosts there (otherwise links could be outdated) +mkdir -p /var/spool/postfix/etc +cp -f /etc/hosts /var/spool/postfix/etc/hosts +cp -f /etc/resolv.conf /var/spool/postfix/etc/resolv.conf +cp -f /etc/services /var/spool/postfix/etc/services + +## MYHOSTNAME +# replace line +sed -i '/myhostname[ ]* =/c\' main.cf +echo "myhostname = $(hostname)" >> /etc/postfix/main.cf + +## REPLAYHOST +if [[ -n "${POSTFIX_RELAYHOST+x}" ]]; then + # replace line + sed -i '/relayhost[ ]* =/c\' main.cf + echo "relayhost = $POSTFIX_RELAYHOST" >> /etc/postfix/main.cf +fi + +## MYNETWORKS +if [[ -n "${POSTFIX_MYNETWORKS+x}" ]]; then + # replace line + sed -i '/mynetworks[ ]* =/c\' main.cf + echo "mynetworks = $POSTFIX_MYNETWORKS" >> /etc/postfix/main.cf +fi + +# generate aliases db +newaliases || : diff --git a/docker/base-app/debian-8/conf/bin/service.d/postfix.sh b/docker/base/debian-8/conf/bin/service.d/postfix.sh similarity index 100% rename from docker/base-app/debian-8/conf/bin/service.d/postfix.sh rename to docker/base/debian-8/conf/bin/service.d/postfix.sh diff --git a/docker/base/debian-8/conf/bin/service.d/ssh.d/10-init.sh b/docker/base/debian-8/conf/bin/service.d/ssh.d/10-init.sh new file mode 100644 index 000000000..f2b600312 --- /dev/null +++ b/docker/base/debian-8/conf/bin/service.d/ssh.d/10-init.sh @@ -0,0 +1,7 @@ +# Init ssh privilege separation directory +mkdir -p /var/run/sshd +chown root:root /var/run/sshd +chmod 755 /var/run/sshd + +# generate host keys +ssh-keygen -A diff --git a/docker/base-app/debian-8/conf/bin/service.d/ssh.sh b/docker/base/debian-8/conf/bin/service.d/ssh.sh similarity index 100% rename from docker/base-app/debian-8/conf/bin/service.d/ssh.sh rename to docker/base/debian-8/conf/bin/service.d/ssh.sh diff --git a/docker/base/debian-8/conf/bin/service.d/syslog-ng.d/10-init.sh b/docker/base/debian-8/conf/bin/service.d/syslog-ng.d/10-init.sh index 22621d2ad..326207e52 100644 --- a/docker/base/debian-8/conf/bin/service.d/syslog-ng.d/10-init.sh +++ b/docker/base/debian-8/conf/bin/service.d/syslog-ng.d/10-init.sh @@ -6,5 +6,5 @@ if [ ! -S /var/lib/syslog-ng/syslog-ng.ctl ]; then rm -f /var/lib/syslog-ng/sysl if [[ ! -p /docker.stdout ]]; then # Switch to file (tty docker mode) - rpl --quiet 'pipe("/docker.stdout")' 'file("/docker.stdout")' -- /opt/docker/etc/syslog-ng/syslog-ng.conf > /dev/null + go-replace -s 'pipe("/docker.stdout")' -r 'file("/docker.stdout")' -- /opt/docker/etc/syslog-ng/syslog-ng.conf fi diff --git a/docker/base/debian-8/conf/bin/usr-bin/docker-provision b/docker/base/debian-8/conf/bin/usr-bin/docker-provision new file mode 100644 index 000000000..4ee715c64 --- /dev/null +++ b/docker/base/debian-8/conf/bin/usr-bin/docker-provision @@ -0,0 +1,9 @@ +#!/usr/bin/env bash + +set -o pipefail # trace ERR through pipes +set -o errtrace # trace ERR through 'time command' and other functions +set -o nounset ## set -u : exit the script if you try to use an uninitialised variable +set -o errexit ## set -e : exit the script if any statement returns a non-true return value + +# wrapper +exec /opt/docker/bin/provision "$@" diff --git a/docker/base/debian-8/conf/bin/usr-bin/docker-service-disable b/docker/base/debian-8/conf/bin/usr-bin/docker-service-disable new file mode 100644 index 000000000..2b5b31bb4 --- /dev/null +++ b/docker/base/debian-8/conf/bin/usr-bin/docker-service-disable @@ -0,0 +1,30 @@ +#!/usr/bin/env bash + +set -o pipefail # trace ERR through pipes +set -o errtrace # trace ERR through 'time command' and other functions +set -o nounset ## set -u : exit the script if you try to use an uninitialised variable +set -o errexit ## set -e : exit the script if any statement returns a non-true return value + +source /opt/docker/bin/config.sh + +rootCheck "$0" + +if [[ "$#" -eq 0 ]]; then + echo "Usage: $0 " + exit 1 +fi + +for SERVICE in "$@"; do + SERVICE_FILE="/opt/docker/etc/supervisor.d/${SERVICE}.conf" + + ## Disable service + if [[ -f "$SERVICE_FILE" ]]; then + go-replace --mode=lineinfile \ + -s 'autostart =' -r 'autostart = false' \ + -- "$SERVICE_FILE" + else + echo "[ERROR] Service '${SERVICE}' not found (tried ${SERVICE_FILE})" + exit 1 + fi +done + diff --git a/docker/base/debian-8/conf/bin/usr-bin/docker-service-enable b/docker/base/debian-8/conf/bin/usr-bin/docker-service-enable new file mode 100644 index 000000000..8d36a14a9 --- /dev/null +++ b/docker/base/debian-8/conf/bin/usr-bin/docker-service-enable @@ -0,0 +1,41 @@ +#!/usr/bin/env bash + +set -o pipefail # trace ERR through pipes +set -o errtrace # trace ERR through 'time command' and other functions +set -o nounset ## set -u : exit the script if you try to use an uninitialised variable +set -o errexit ## set -e : exit the script if any statement returns a non-true return value + +source /opt/docker/bin/config.sh + +rootCheck "$0" + +if [[ "$#" -eq 0 ]]; then + echo "Usage: $0 " + exit 1 +fi + +for SERVICE in "$@"; do + SERVICE_FILE="/opt/docker/etc/supervisor.d/${SERVICE}.conf" + PROVISION_FILE="/opt/docker/provision/service.d/${SERVICE}.sh" + + # Run on demand installation/provisioning + if [[ -f "$PROVISION_FILE" ]]; then + echo "Running provisioning for ${SERVICE}, please wait..." + + ## execute scripts + . "$PROVISION_FILE" + + ## remove directory (one run time) + rm -f -- "$PROVISION_FILE" + fi + + ## Enable service + if [[ -f "$SERVICE_FILE" ]]; then + go-replace --mode=lineinfile \ + -s 'autostart =' -r 'autostart = true' \ + -- "$SERVICE_FILE" + else + echo "[ERROR] Service '${SERVICE}' not found (tried ${SERVICE_FILE})" + exit 1 + fi +done diff --git a/docker/base/debian-8/conf/bin/usr-bin/service b/docker/base/debian-8/conf/bin/usr-bin/service new file mode 100755 index 000000000..55ea12bf7 --- /dev/null +++ b/docker/base/debian-8/conf/bin/usr-bin/service @@ -0,0 +1,86 @@ +#!/bin/bash + +set -o pipefail # trace ERR through pipes +set -o errtrace # trace ERR through 'time command' and other functions +set -o nounset ## set -u : exit the script if you try to use an uninitialised variable +set -o errexit ## set -e : exit the script if any statement returns a non-true return value + +# Root check +if [ "$(/usr/bin/whoami)" != "root" ]; then + echo "[ERROR] Must be run as root" + exit 1 +fi + +function serviceHelp() { + echo "Usage: $(basename "$0") " +} + +function getServicePid() { + local serviceName="$1" + local servicePid=$(supervisorctl pid "${serviceName}:${serviceName}d") + + if [[ -z "$servicePid" ]] || [[ "$servicePid" == "0" ]]; then + echo "not running" + exit 1 + fi + + echo $servicePid +} + +# Param check +if [ "$#" -lt 2 ]; then + echo "[ERROR] Missing parameters" + serviceHelp + exit 1 +fi + +############################# +# Param init +############################# + +SERVICENAME="$1" +ACTION="$2" + +############################# +# Service aliases +############################# +case "$SERVICENAME" in + apache2|httpd) + SERVICENAME="apache" + ;; +esac + +############################# +# Action runner +############################# +case "$ACTION" in + stop|start|restart|status) + exec supervisorctl "$ACTION" "${SERVICENAME}:${SERVICENAME}d" + ;; + + pid) + echo $(getServicePid "${SERVICENAME}") + ;; + + check) + FIRST_PID=$(getServicePid "${SERVICENAME}") + sleep 5 + SECOND_PID=$(getServicePid "${SERVICENAME}") + + if [[ "$FIRST_PID" == "$SECOND_PID" ]]; then + echo "ok" + exit 0 + else + echo "not running" + exit 1 + fi + ;; + + + *) + echo "[ERROR] Invalid action" + serviceHelp + exit 1 + ;; + +esac diff --git a/docker/base/debian-8/conf/etc/supervisor.conf b/docker/base/debian-8/conf/etc/supervisor.conf index 7c109515a..479e0db08 100644 --- a/docker/base/debian-8/conf/etc/supervisor.conf +++ b/docker/base/debian-8/conf/etc/supervisor.conf @@ -2,9 +2,16 @@ nodaemon=true [unix_http_server] -file = /var/run/supervisor.sock -# username = root -# password = {SHA}e982f17bcbe0f724063b708a4f76db211a999304 +file = /.supervisor.sock +chmod = 0700 +chown = root:root +username = root +password = {SHA}e982f17bcbe0f724063b708a4f76db211a999304 + +[supervisorctl] +serverurl = unix:///.supervisor.sock +username = root +password = docker [rpcinterface:supervisor] supervisor.rpcinterface_factory = supervisor.rpcinterface:make_main_rpcinterface diff --git a/docker/base/debian-8/conf/etc/supervisor.d/dnsmasq.conf b/docker/base/debian-8/conf/etc/supervisor.d/dnsmasq.conf new file mode 100644 index 000000000..9832ffca7 --- /dev/null +++ b/docker/base/debian-8/conf/etc/supervisor.d/dnsmasq.conf @@ -0,0 +1,14 @@ +[group:dnsmasq] +programs=dnsmasqd +priority=15 + +[program:dnsmasqd] +command = /opt/docker/bin/service.d/dnsmasq.sh +process_name=%(program_name)s +startsecs = 0 +autostart = false +autorestart = true +stdout_logfile=/dev/stdout +stdout_logfile_maxbytes=0 +stderr_logfile=/dev/stderr +stderr_logfile_maxbytes=0 diff --git a/docker/base-app/debian-8/conf/etc/supervisor.d/postfix.conf b/docker/base/debian-8/conf/etc/supervisor.d/postfix.conf similarity index 100% rename from docker/base-app/debian-8/conf/etc/supervisor.d/postfix.conf rename to docker/base/debian-8/conf/etc/supervisor.d/postfix.conf diff --git a/docker/base-app/debian-8/conf/etc/supervisor.d/ssh.conf b/docker/base/debian-8/conf/etc/supervisor.d/ssh.conf similarity index 100% rename from docker/base-app/debian-8/conf/etc/supervisor.d/ssh.conf rename to docker/base/debian-8/conf/etc/supervisor.d/ssh.conf diff --git a/docker/base/debian-8/conf/etc/supervisor.d/syslog-ng.conf b/docker/base/debian-8/conf/etc/supervisor.d/syslog-ng.conf deleted file mode 100644 index 247fd1a25..000000000 --- a/docker/base/debian-8/conf/etc/supervisor.d/syslog-ng.conf +++ /dev/null @@ -1,13 +0,0 @@ -[group:syslog] -programs=syslogd -priority=10 - -[program:syslogd] -command = /opt/docker/bin/service.d/syslog-ng.sh -process_name=%(program_name)s -autostart = true -autorestart = true -stdout_logfile=/dev/stdout -stdout_logfile_maxbytes=0 -stderr_logfile=/dev/stderr -stderr_logfile_maxbytes=0 diff --git a/docker/base/debian-8/conf/etc/supervisor.d/syslog.conf b/docker/base/debian-8/conf/etc/supervisor.d/syslog.conf new file mode 100644 index 000000000..20d1e238c --- /dev/null +++ b/docker/base/debian-8/conf/etc/supervisor.d/syslog.conf @@ -0,0 +1,13 @@ +[group:syslog] +programs=syslogd +priority=10 + +[program:syslogd] +command = /opt/docker/bin/service.d/syslog-ng.sh +process_name=%(program_name)s +autostart = false +autorestart = true +stdout_logfile=/dev/stdout +stdout_logfile_maxbytes=0 +stderr_logfile=/dev/stderr +stderr_logfile_maxbytes=0 diff --git a/docker/base/debian-8/conf/provision/roles/webdevops-base/tasks/bootstrap.yml b/docker/base/debian-8/conf/provision/roles/webdevops-base/tasks/bootstrap.yml index 30be03c38..9f842336c 100644 --- a/docker/base/debian-8/conf/provision/roles/webdevops-base/tasks/bootstrap.yml +++ b/docker/base/debian-8/conf/provision/roles/webdevops-base/tasks/bootstrap.yml @@ -4,6 +4,5 @@ - include: bootstrap/misc.yml - include: bootstrap/root.yml - include: bootstrap/supervisor.yml -- include: bootstrap/syslog-ng.yml -- include: bootstrap/logrotate.yml - include: bootstrap/pam.yml +- include: bootstrap/entrypoint.yml diff --git a/docker/base/debian-8/conf/provision/roles/webdevops-base/tasks/bootstrap/entrypoint.yml b/docker/base/debian-8/conf/provision/roles/webdevops-base/tasks/bootstrap/entrypoint.yml new file mode 100644 index 000000000..d5d8809f4 --- /dev/null +++ b/docker/base/debian-8/conf/provision/roles/webdevops-base/tasks/bootstrap/entrypoint.yml @@ -0,0 +1,8 @@ +--- + +- name: Create link for entrypoint + file: + src: '/opt/docker/bin/entrypoint.sh' + dest: '/entrypoint' + state: link + force: yes diff --git a/docker/base/debian-8/conf/provision/roles/webdevops-base/tasks/bootstrap/logrotate.yml b/docker/base/debian-8/conf/provision/roles/webdevops-base/tasks/bootstrap/logrotate.yml deleted file mode 100644 index d87926be2..000000000 --- a/docker/base/debian-8/conf/provision/roles/webdevops-base/tasks/bootstrap/logrotate.yml +++ /dev/null @@ -1,33 +0,0 @@ ---- - -- name: Configure logrotate running user - lineinfile: - dest: /etc/logrotate.conf - regexp: '^su [-_a-zA-Z0-9]+ [-_a-zA-Z0-9]+' - line: 'su root adm' - -- name: Register logrotate configurations - file: - src: '{{ item }}' - dest: '/etc/logrotate.d/{{ item | basename }}' - state: link - force: yes - with_fileglob: - - /opt/docker/etc/logrotate.d/* - -- name: Remove system logrotates (not needed) - file: - path: '{{ item }}' - state: absent - with_items: - # Debian/Ubuntu - - /etc/cron.daily/logrotate - - /etc/cron.daily/apt-compat - - /etc/cron.daily/dpkg - - /etc/cron.daily/passwd - # RedHat - - /etc/cron.daily/0yum-daily.cron - - /etc/cron.daily/logrotate - - /etc/cron.hourly/0yum-hourly.cron - # Alpine - - /etc/periodic/daily/logrotate diff --git a/docker/base/debian-8/conf/provision/roles/webdevops-base/tasks/bootstrap/supervisor.yml b/docker/base/debian-8/conf/provision/roles/webdevops-base/tasks/bootstrap/supervisor.yml index bda0394b6..2ce07ac26 100644 --- a/docker/base/debian-8/conf/provision/roles/webdevops-base/tasks/bootstrap/supervisor.yml +++ b/docker/base/debian-8/conf/provision/roles/webdevops-base/tasks/bootstrap/supervisor.yml @@ -4,3 +4,10 @@ file: path: '/usr/sbin/service' state: absent + +- name: Create link for supervisor.conf + file: + src: '/opt/docker/etc/supervisor.conf' + dest: '/etc/supervisord.conf' + state: link + force: yes diff --git a/docker/base/debian-8/conf/provision/roles/webdevops-base/tasks/bootstrap/syslog-ng.yml b/docker/base/debian-8/conf/provision/roles/webdevops-base/tasks/bootstrap/syslog-ng.yml deleted file mode 100644 index 27c8f6a30..000000000 --- a/docker/base/debian-8/conf/provision/roles/webdevops-base/tasks/bootstrap/syslog-ng.yml +++ /dev/null @@ -1,33 +0,0 @@ ---- - -- name: Get syslog-ng version - shell: "syslog-ng --version | grep -E -e '^syslog-ng[ ]+[0-9]+\\.[0-9]+' | head -n 1 | awk '{print $2}' | cut -f 1,2 -d ." - register: syslogng_version - -- name: Configure syslog-ng (default) - lineinfile: - dest: /etc/default/syslog-ng - regexp: '^[\s]*{{ item.key }}[\s]*=' - line: '{{ item.key }}="{{ item.value }}"' - create: yes - with_items: - - { key: 'SYSLOGNG_OPTS', value: '--no-caps' } - -- name: Enable syslog-ng config - file: - src: '/opt/docker/etc/syslog-ng/syslog-ng.conf' - dest: '/etc/syslog-ng/syslog-ng.conf' - state: link - force: yes - -- name: Set version of syslog-ng file - lineinfile: - dest: '/etc/syslog-ng/syslog-ng.conf' - regexp: '^@version:' - line: '@version: {{ syslogng_version.stdout }}' - -- name: Ensure /var/lib/syslog-ng exists - file: - path: '/var/lib/syslog-ng' - state: directory - recurse: yes diff --git a/docker/base/debian-8/conf/provision/roles/webdevops-base/tasks/bootstrap/system.yml b/docker/base/debian-8/conf/provision/roles/webdevops-base/tasks/bootstrap/system.yml index 8dfbf9665..0741d7cae 100644 --- a/docker/base/debian-8/conf/provision/roles/webdevops-base/tasks/bootstrap/system.yml +++ b/docker/base/debian-8/conf/provision/roles/webdevops-base/tasks/bootstrap/system.yml @@ -14,3 +14,20 @@ dest: '/entrypoint.cmd' state: link force: yes + +- name: Remove system logrotate and cronjobs (not needed) + file: + path: '{{ item }}' + state: absent + with_items: + # Debian/Ubuntu + - /etc/cron.daily/logrotate + - /etc/cron.daily/apt-compat + - /etc/cron.daily/dpkg + - /etc/cron.daily/passwd + # RedHat + - /etc/cron.daily/0yum-daily.cron + - /etc/cron.daily/logrotate + - /etc/cron.hourly/0yum-hourly.cron + # Alpine + - /etc/periodic/daily/logrotate diff --git a/docker/php-apache-dev/alpine-3/conf/etc/httpd/vhost.common.d/.gitkeep b/docker/base/debian-8/conf/provision/roles/webdevops-base/tasks/build/.gitkeep similarity index 100% rename from docker/php-apache-dev/alpine-3/conf/etc/httpd/vhost.common.d/.gitkeep rename to docker/base/debian-8/conf/provision/roles/webdevops-base/tasks/build/.gitkeep diff --git a/docker/base/debian-8/conf/provision/roles/webdevops-base/tasks/build/logrotate.yml b/docker/base/debian-8/conf/provision/roles/webdevops-base/tasks/build/logrotate.yml deleted file mode 100644 index 10f7e6644..000000000 --- a/docker/base/debian-8/conf/provision/roles/webdevops-base/tasks/build/logrotate.yml +++ /dev/null @@ -1,10 +0,0 @@ ---- - -- name: Register logrotate configurations - file: - src: '{{ item }}' - dest: '/etc/logrotate.d/{{ item | basename }}' - state: link - force: yes - with_fileglob: - - /opt/docker/etc/logrotate.d/* diff --git a/docker/php-apache/alpine-3-php7/conf/etc/httpd/conf.d/.gitkeep b/docker/base/debian-8/conf/provision/service.d/.gitkeep similarity index 100% rename from docker/php-apache/alpine-3-php7/conf/etc/httpd/conf.d/.gitkeep rename to docker/base/debian-8/conf/provision/service.d/.gitkeep diff --git a/docker/base/debian-8/conf/provision/service.d/cron.sh b/docker/base/debian-8/conf/provision/service.d/cron.sh new file mode 100644 index 000000000..bd8a54781 --- /dev/null +++ b/docker/base/debian-8/conf/provision/service.d/cron.sh @@ -0,0 +1,13 @@ +#!/usr/bin/env bash + +IMAGE_FAMILY=$(docker-image-info family) + +case "$IMAGE_FAMILY" in + Debian|Ubuntu) + apt-install cron + ;; + + RedHat) + yum-install cronie + ;; +esac diff --git a/docker/base/debian-8/conf/provision/service.d/dnsmasq.sh b/docker/base/debian-8/conf/provision/service.d/dnsmasq.sh new file mode 100644 index 000000000..9e5c3228c --- /dev/null +++ b/docker/base/debian-8/conf/provision/service.d/dnsmasq.sh @@ -0,0 +1,24 @@ +#!/usr/bin/env bash + +IMAGE_FAMILY=$(docker-image-info family) + +# Installation +case "$IMAGE_FAMILY" in + Debian|Ubuntu) + apt-install dnsmasq + ;; + + RedHat) + yum-install dnsmasq + ;; + + Alpine) + apk-install dnsmasq + ;; +esac + +# Configuration +go-replace --mode=line \ + -s '^[\s]*user[\s]*=' -r 'user = root' \ + -s '^[\s]*conf-dir[\s]*=' -r 'conf-dir = /etc/dnsmasq.d' \ + -- /etc/dnsmasq.conf diff --git a/docker/base/debian-8/conf/provision/service.d/postfix.sh b/docker/base/debian-8/conf/provision/service.d/postfix.sh new file mode 100644 index 000000000..ff1879345 --- /dev/null +++ b/docker/base/debian-8/conf/provision/service.d/postfix.sh @@ -0,0 +1,28 @@ +#!/usr/bin/env bash + +IMAGE_FAMILY=$(docker-image-info family) + +# Installation +case "$IMAGE_FAMILY" in + Debian|Ubuntu) + apt-install postfix + ;; + + RedHat) + yum-install postfix + ;; + + Alpine) + apk-install postfix + ln -s -f /etc/postfix/aliases /etc/aliases + ;; +esac + +# Configuration +go-replace --mode=line \ + -s '^[\s]*mydestination[\s]*=' -r 'mydestination = ' \ + -s '^[\s]*message_size_limit[\s]*=' -r 'message_size_limit = 15240000' \ + -s '^[\s]*smtp_use_tls[\s]*=' -r 'smtp_use_tls = yes' \ + -s '^[\s]*smtp_tls_security_level[\s]*=' -r 'smtp_tls_security_level = may' \ + -s '^[\s]*myhostname[\s]*=' -r '# myhostname' \ + -- /etc/postfix/main.cf diff --git a/docker/base/debian-8/conf/provision/service.d/ssh.sh b/docker/base/debian-8/conf/provision/service.d/ssh.sh new file mode 100644 index 000000000..63d7a9f3a --- /dev/null +++ b/docker/base/debian-8/conf/provision/service.d/ssh.sh @@ -0,0 +1,17 @@ +#!/usr/bin/env bash + +IMAGE_FAMILY=$(docker-image-info family) + +case "$IMAGE_FAMILY" in + Debian|Ubuntu) + apt-install openssh-server + ;; + + RedHat) + yum-install openssh-server + ;; + + Alpine) + apk-install openssh + ;; +esac diff --git a/docker/base/debian-8/conf/provision/service.d/syslog.sh b/docker/base/debian-8/conf/provision/service.d/syslog.sh new file mode 100644 index 000000000..7e8b8e0a9 --- /dev/null +++ b/docker/base/debian-8/conf/provision/service.d/syslog.sh @@ -0,0 +1,41 @@ +#!/usr/bin/env bash + +IMAGE_FAMILY=$(docker-image-info family) + +# Installation +case "$IMAGE_FAMILY" in + Debian|Ubuntu) + apt-install syslog-ng syslog-ng-core + ;; + + RedHat) + yum-install syslog-ng + + # remove logrotate (not needed for docker) + rm -f "/etc/cron.daily/logrotate" + ;; + + Alpine) + apk-install syslog-ng + ;; +esac + +## Configuration +SYSLOG_NG_VERSION=$(syslog-ng --version | grep -E -e '^syslog-ng[ ]+[0-9]+\.[0-9]+' | head -n 1 | awk '{print $2}' | cut -f 1,2 -d .) + +# Disable caps inside container +if [[ -f /etc/default/syslog-ng ]]; then + go-replace --mode=lineinfile \ + -s "SYSLOGNG_OPTS" -r "SYSLOGNG_OPTS = --no-caps" \ + -- /etc/default/syslog-ng +fi + +# Symlink configuration +ln -s -f /opt/docker/etc/syslog-ng/syslog-ng.conf /etc/syslog-ng/syslog-ng.conf + +go-replace --mode=lineinfile \ + -s "@version" -r "@version: ${SYSLOG_NG_VERSION}" \ + -- /etc/syslog-ng/syslog-ng.conf + +# Ensure /var/lib/syslog-ng exists +mkdir -p /var/lib/syslog-ng diff --git a/docker/base/debian-8/conf/provision/variables-webdevops.yml b/docker/base/debian-8/conf/provision/variables-webdevops.yml new file mode 100644 index 000000000..0b2a21a95 --- /dev/null +++ b/docker/base/debian-8/conf/provision/variables-webdevops.yml @@ -0,0 +1,7 @@ +--- + +docker_image_info_family: "{{ lookup('pipe', 'docker-image-info family') }}" +docker_image_info_distribution: "{{ lookup('pipe', 'docker-image-info dist') }}" +docker_image_info_distribution_version: "{{ lookup('pipe', 'docker-image-info dist-version') }}" +docker_image_info_distribution_release: "{{ lookup('pipe', 'docker-image-info dist-release') }}" +docker_image_info_distribution_codename: "{{ lookup('pipe', 'docker-image-info dist-codename') }}" diff --git a/docker/base/debian-8/conf/provision/variables.yml b/docker/base/debian-8/conf/provision/variables.yml index ed97d539c..0b2a21a95 100644 --- a/docker/base/debian-8/conf/provision/variables.yml +++ b/docker/base/debian-8/conf/provision/variables.yml @@ -1 +1,7 @@ --- + +docker_image_info_family: "{{ lookup('pipe', 'docker-image-info family') }}" +docker_image_info_distribution: "{{ lookup('pipe', 'docker-image-info dist') }}" +docker_image_info_distribution_version: "{{ lookup('pipe', 'docker-image-info dist-version') }}" +docker_image_info_distribution_release: "{{ lookup('pipe', 'docker-image-info dist-release') }}" +docker_image_info_distribution_codename: "{{ lookup('pipe', 'docker-image-info dist-codename') }}" diff --git a/docker/base/debian-9/Dockerfile b/docker/base/debian-9/Dockerfile index 92592773b..fe3576750 100644 --- a/docker/base/debian-9/Dockerfile +++ b/docker/base/debian-9/Dockerfile @@ -5,31 +5,48 @@ FROM webdevops/bootstrap:debian-9 -MAINTAINER info@webdevops.io -LABEL vendor=WebDevOps.io -LABEL io.webdevops.layout=8 -LABEL io.webdevops.version=1.5.0 - -ENV DOCKER_CONF_HOME /opt/docker/ +ENV DOCKER_CONF_HOME=/opt/docker/ \ + LOG_STDOUT="" \ + LOG_STDERR="" COPY conf/ /opt/docker/ +# Install ansible +RUN /usr/local/bin/apt-install \ + # Install ansible + python-minimal \ + python-setuptools \ + python-pip \ + python-paramiko \ + python-jinja2 \ + python-dev \ + libffi-dev \ + libssl-dev \ + build-essential \ + && pip install --upgrade pip \ + && hash -r \ + && pip install --no-cache-dir ansible \ + && chmod 750 /usr/local/bin/ansible* \ + # Cleanup + && apt-get purge -y -f --force-yes \ + python-dev \ + build-essential \ + libssl-dev \ + libffi-dev \ + && docker-image-cleanup + # Install packages RUN chmod +x /opt/docker/bin/* \ && /usr/local/bin/apt-install \ supervisor \ - syslog-ng \ - syslog-ng-core \ - logrotate \ - cron \ wget \ curl \ net-tools \ gnupg \ && chmod +s /usr/local/bin/gosu \ && /opt/docker/bin/provision run --tag bootstrap --role webdevops-base \ - && /opt/docker/bin/bootstrap.sh - + && /opt/docker/bin/bootstrap.sh \ + && docker-image-cleanup ENTRYPOINT ["/opt/docker/bin/entrypoint.sh"] CMD ["supervisord"] diff --git a/docker/base/debian-9/Dockerfile.jinja2 b/docker/base/debian-9/Dockerfile.jinja2 index d43d021d2..465e29630 100644 --- a/docker/base/debian-9/Dockerfile.jinja2 +++ b/docker/base/debian-9/Dockerfile.jinja2 @@ -1,11 +1,11 @@ {{ docker.from("bootstrap", "debian-9") }} -{{ docker.version() }} - -{{ environment.homePath() }} +{{ environment.base() }} {{ docker.copy('conf/', '/opt/docker/') }} +{{ ansible.debian() }} + {{ base.debian() }} {{ docker.entrypoint("/opt/docker/bin/entrypoint.sh") }} diff --git a/docker/base/debian-9/conf/bin/bootstrap.sh b/docker/base/debian-9/conf/bin/bootstrap.sh index 1d1a30f72..855c10782 100644 --- a/docker/base/debian-9/conf/bin/bootstrap.sh +++ b/docker/base/debian-9/conf/bin/bootstrap.sh @@ -17,10 +17,16 @@ rootCheck "$0" # Save the buildtime date +%s > /opt/docker/BUILDTIME +date +%s >/opt/docker/etc/.registry/image_info_buildtime # Make all scripts executable find /opt/docker/bin/ -type f -iname '*.sh' -print0 | xargs --no-run-if-empty -0 chmod +x +# Enable usr-bin executables +find /opt/docker/bin/usr-bin -type f | while read USR_BIN_FILE; do + chmod +x -- "$USR_BIN_FILE" + ln -n -f -- "$USR_BIN_FILE" "/usr/local/bin/$(basename "$USR_BIN_FILE")" +done case "$BOOTSTRAP_MODE" in ################################### @@ -44,6 +50,23 @@ case "$BOOTSTRAP_MODE" in echo "[ERROR] Bootstrap mode '$BOOTSTRAP_MODE' not defined" exit 1 ;; - esac + +###################### +# Check if entrypoint provisioning is available +###################### + +echo "Checking provision status..." +for PROVISION_TAG in onbuild build bootstrap entrypoint; do + ROLES=$(docker-provision list --tag "$PROVISION_TAG") + if [[ -n "$ROLES" ]]; then + PROVISION_ROLE_COUNT=$(echo "$ROLES" | wc -l) + echo " - found ${PROVISION_ROLE_COUNT} for provision tag ${PROVISION_TAG}, caching info for execution" + echo -n "$PROVISION_ROLE_COUNT" > "/opt/docker/etc/.registry/provision-availale.${PROVISION_TAG}" + else + echo " - no roles found for provision tag ${PROVISION_TAG}" + echo -n '' > "/opt/docker/etc/.registry/provision-availale.${PROVISION_TAG}" + fi +done + diff --git a/docker/base/debian-9/conf/bin/config.sh b/docker/base/debian-9/conf/bin/config.sh index 3155728e8..049756c26 100644 --- a/docker/base/debian-9/conf/bin/config.sh +++ b/docker/base/debian-9/conf/bin/config.sh @@ -15,44 +15,23 @@ function rootCheck() { } ### - # Create named pipe - # - # $1 -> name of file + # Create /docker.stdout and /docker.stderr # ## -function createNamedPipe() { - rm --force -- "$1" - mknod "$1" p -} - -### - # Escape value for sed usage - # - # $1 -> value - # STDOUT -> escaped value - # - ## -function sedEscape() { - echo "$(echo $* |sed -e 's/[]\/$*.^|[]/\\&/g')" -} +function createDockerStdoutStderr() { + # link stdout from docker + if [[ -z "$LOG_STDOUT" ]]; then + LOG_STDOUT="/proc/$$/fd/1" + fi -### - # Replace text inside a file - # - # $1 -> source value - # $2 -> target value - # $3 -> path to file - # - ## -function replaceTextInFile() { - SOURCE="$(sedEscape $1)" - REPLACE="$(sedEscape $2)" - TARGET="$3" + if [[ -z "$LOG_STDERR" ]]; then + LOG_STDERR="/proc/$$/fd/2" + fi - sed -i "s/${SOURCE}/${REPLACE}/" "${TARGET}" + ln -f -s "$LOG_STDOUT" /docker.stdout + ln -f -s "$LOG_STDERR" /docker.stderr + chmod 600 /docker.stdout /docker.stderr } - - ### # Include script directory text inside a file # @@ -104,7 +83,7 @@ function runEntrypoints() { . /opt/docker/bin/entrypoint.d/default.sh fi - exit + exit 1 } ### @@ -161,6 +140,12 @@ function runProvisionEntrypoint() { function runDockerProvision() { ANSIBLE_TAG="$1" - /opt/docker/bin/provision run --tag "$ANSIBLE_TAG" --use-registry + PROVISION_STATS_FILE="/opt/docker/etc/.registry/provision-stats.${ANSIBLE_TAG}" + + # run provision if stats file doesn't exists (unknown mode) + # or if stats file is not empty + if [[ ! -f "$PROVISION_STATS_FILE" ]] || [[ -s "$PROVISION_STATS_FILE" ]]; then + /opt/docker/bin/provision run --tag "${ANSIBLE_TAG}" --use-registry + fi } diff --git a/docker/base/debian-9/conf/bin/control.sh b/docker/base/debian-9/conf/bin/control.sh index a6697092d..22d189745 100644 --- a/docker/base/debian-9/conf/bin/control.sh +++ b/docker/base/debian-9/conf/bin/control.sh @@ -101,23 +101,13 @@ case "$CONTROL_COMMAND" in ## ------------------------------------------ "service.enable") - SERVICE_FILE="/opt/docker/etc/supervisor.d/$1.conf" - if [ -f "$SERVICE_FILE" ]; then - sed -i '/autostart = /c\autostart = true' -- "$SERVICE_FILE" - else - echo "[ERROR] Service '${1}' not found (tried ${SERVICE_FILE})" - exit 1 - fi + deprecationNotice " Please use >>docker-service-enable [service]<<" + docker-service-enable "$1" ;; "service.disable") - SERVICE_FILE="/opt/docker/etc/supervisor.d/$1.conf" - if [ -f "$SERVICE_FILE" ]; then - sed -i '/autostart = /c\autostart = false' -- "$SERVICE_FILE" - else - echo "[ERROR] Service '${1}' not found (tried ${SERVICE_FILE})" - exit 1 - fi + deprecationNotice " Please use >>docker-service-disable [service]<<" + docker-service-disable "$1" ;; ## ------------------------------------------ diff --git a/docker/base/debian-9/conf/bin/entrypoint.d/cli.sh b/docker/base/debian-9/conf/bin/entrypoint.d/cli.sh index 2ca68926c..fe212a8ea 100644 --- a/docker/base/debian-9/conf/bin/entrypoint.d/cli.sh +++ b/docker/base/debian-9/conf/bin/entrypoint.d/cli.sh @@ -8,7 +8,7 @@ if [ -n "${CLI_SCRIPT}" ]; then if [ -n "$APPLICATION_USER" ]; then # Run as EFFECTIVE_USER shift - exec sudo -H -E -u "${APPLICATION_USER}" ${CLI_SCRIPT} "$@" + exec gosu "${APPLICATION_USER}" ${CLI_SCRIPT} "$@" else # Run as root exec ${CLI_SCRIPT} "$@" diff --git a/docker/base/debian-9/conf/bin/entrypoint.d/noop.sh b/docker/base/debian-9/conf/bin/entrypoint.d/noop.sh index 967920837..092d55d8b 100644 --- a/docker/base/debian-9/conf/bin/entrypoint.d/noop.sh +++ b/docker/base/debian-9/conf/bin/entrypoint.d/noop.sh @@ -4,5 +4,4 @@ ## NOOP (no operation) ############################################# -tail -f /dev/null -exit +exec tail -f /dev/null diff --git a/docker/base/debian-9/conf/bin/entrypoint.d/supervisord.sh b/docker/base/debian-9/conf/bin/entrypoint.d/supervisord.sh index ead991551..f21489667 100644 --- a/docker/base/debian-9/conf/bin/entrypoint.d/supervisord.sh +++ b/docker/base/debian-9/conf/bin/entrypoint.d/supervisord.sh @@ -4,8 +4,6 @@ ## Supervisord (start daemons) ############################################# -rootCheck "supervisord" - ## Start services exec /opt/docker/bin/service.d/supervisor.sh diff --git a/docker/base/debian-9/conf/bin/entrypoint.sh b/docker/base/debian-9/conf/bin/entrypoint.sh index bbabcdddb..01f59660c 100644 --- a/docker/base/debian-9/conf/bin/entrypoint.sh +++ b/docker/base/debian-9/conf/bin/entrypoint.sh @@ -20,16 +20,13 @@ chmod -s /usr/local/bin/gosu trap 'echo sigterm ; exit' SIGTERM trap 'echo sigkill ; exit' SIGKILL -# link stdout from docker -ln -f -s "/proc/$$/fd/1" /docker.stdout -ln -f -s "/proc/$$/fd/2" /docker.stderr -chmod 600 /docker.stdout /docker.stderr - # sanitize input and set task TASK="$(echo $1| sed 's/[^-_a-zA-Z0-9]*//g')" source /opt/docker/bin/config.sh +createDockerStdoutStderr + if [[ "$UID" -eq 0 ]]; then # Only run provision if user is root diff --git a/docker/base/debian-9/conf/bin/logwatch.sh b/docker/base/debian-9/conf/bin/logwatch.sh deleted file mode 100644 index 1a5b486c7..000000000 --- a/docker/base/debian-9/conf/bin/logwatch.sh +++ /dev/null @@ -1,14 +0,0 @@ -#!/usr/bin/env bash - -set -o pipefail # trace ERR through pipes -set -o errtrace # trace ERR through 'time command' and other functions -set -o nounset ## set -u : exit the script if you try to use an uninitialised variable -set -o errexit ## set -e : exit the script if any statement returns a non-true return value - -sleep 0.5 - -if [ -p "$2" ]; then - sed --unbuffered -e "s/^/\[$1\] /" -- "$2" -else - tail -n 0 -F -q "$2" | sed --unbuffered -e "s/^/\[$1\] /" -fi diff --git a/docker/base/debian-9/conf/bin/provision b/docker/base/debian-9/conf/bin/provision index f7b5ad0a8..d367c2812 100755 --- a/docker/base/debian-9/conf/bin/provision +++ b/docker/base/debian-9/conf/bin/provision @@ -19,6 +19,7 @@ PLAYBOOK = Template( - hosts: all vars_files: + - ./variables-webdevops.yml - ./variables.yml roles: - $roles @@ -188,7 +189,7 @@ def actionAdd(args): 'priority': args.priority } - saveJson(json); + saveJson(json) diff --git a/docker/base/debian-9/conf/bin/provision.sh b/docker/base/debian-9/conf/bin/provision.sh deleted file mode 100644 index 4079dd7f0..000000000 --- a/docker/base/debian-9/conf/bin/provision.sh +++ /dev/null @@ -1,30 +0,0 @@ - #!/usr/bin/env bash - -# -# Example: -# provision.sh /opt/foobar/playbook.yml tag -# -# - -set -o pipefail # trace ERR through pipes -set -o errtrace # trace ERR through 'time command' and other functions -set -o nounset ## set -u : exit the script if you try to use an uninitialised variable -set -o errexit ## set -e : exit the script if any statement returns a non-true return value - -. config.sh - -deprecationNotice " Please use >>/opt/docker/bin/provision run --playbook playbook.yml --tag=bootstrap [args]<< for running provision" - - -if [ "$#" -lt 2 ]; then - echo "[ERROR] $0: Playbook or tag is missing" - exit 1 -fi - -ANSIBLE_PLAYBOOK="$1" -shift -ANSIBLE_TAG="$1" -shift -ANSIBLE_OPTS="$@" - -/opt/docker/bin/provision run --playbook "${ANSIBLE_PLAYBOOK}" --use-registry --tag "${ANSIBLE_TAG}" $ANSIBLE_OPTS diff --git a/docker/base-app/debian-9/conf/bin/service.d/dnsmasq.d/10-init.sh b/docker/base/debian-9/conf/bin/service.d/dnsmasq.d/10-init.sh similarity index 100% rename from docker/base-app/debian-9/conf/bin/service.d/dnsmasq.d/10-init.sh rename to docker/base/debian-9/conf/bin/service.d/dnsmasq.d/10-init.sh diff --git a/docker/base-app/debian-9/conf/bin/service.d/dnsmasq.sh b/docker/base/debian-9/conf/bin/service.d/dnsmasq.sh similarity index 100% rename from docker/base-app/debian-9/conf/bin/service.d/dnsmasq.sh rename to docker/base/debian-9/conf/bin/service.d/dnsmasq.sh diff --git a/docker/base/debian-9/conf/bin/service.d/postfix.d/10-init.sh b/docker/base/debian-9/conf/bin/service.d/postfix.d/10-init.sh new file mode 100644 index 000000000..cfd876955 --- /dev/null +++ b/docker/base/debian-9/conf/bin/service.d/postfix.d/10-init.sh @@ -0,0 +1,27 @@ +# force new copy of hosts there (otherwise links could be outdated) +mkdir -p /var/spool/postfix/etc +cp -f /etc/hosts /var/spool/postfix/etc/hosts +cp -f /etc/resolv.conf /var/spool/postfix/etc/resolv.conf +cp -f /etc/services /var/spool/postfix/etc/services + +## MYHOSTNAME +# replace line +sed -i '/myhostname[ ]* =/c\' main.cf +echo "myhostname = $(hostname)" >> /etc/postfix/main.cf + +## REPLAYHOST +if [[ -n "${POSTFIX_RELAYHOST+x}" ]]; then + # replace line + sed -i '/relayhost[ ]* =/c\' main.cf + echo "relayhost = $POSTFIX_RELAYHOST" >> /etc/postfix/main.cf +fi + +## MYNETWORKS +if [[ -n "${POSTFIX_MYNETWORKS+x}" ]]; then + # replace line + sed -i '/mynetworks[ ]* =/c\' main.cf + echo "mynetworks = $POSTFIX_MYNETWORKS" >> /etc/postfix/main.cf +fi + +# generate aliases db +newaliases || : diff --git a/docker/base-app/debian-9/conf/bin/service.d/postfix.sh b/docker/base/debian-9/conf/bin/service.d/postfix.sh similarity index 100% rename from docker/base-app/debian-9/conf/bin/service.d/postfix.sh rename to docker/base/debian-9/conf/bin/service.d/postfix.sh diff --git a/docker/base/debian-9/conf/bin/service.d/ssh.d/10-init.sh b/docker/base/debian-9/conf/bin/service.d/ssh.d/10-init.sh new file mode 100644 index 000000000..f2b600312 --- /dev/null +++ b/docker/base/debian-9/conf/bin/service.d/ssh.d/10-init.sh @@ -0,0 +1,7 @@ +# Init ssh privilege separation directory +mkdir -p /var/run/sshd +chown root:root /var/run/sshd +chmod 755 /var/run/sshd + +# generate host keys +ssh-keygen -A diff --git a/docker/base-app/debian-9/conf/bin/service.d/ssh.sh b/docker/base/debian-9/conf/bin/service.d/ssh.sh similarity index 100% rename from docker/base-app/debian-9/conf/bin/service.d/ssh.sh rename to docker/base/debian-9/conf/bin/service.d/ssh.sh diff --git a/docker/base/debian-9/conf/bin/service.d/syslog-ng.d/10-init.sh b/docker/base/debian-9/conf/bin/service.d/syslog-ng.d/10-init.sh index 22621d2ad..326207e52 100644 --- a/docker/base/debian-9/conf/bin/service.d/syslog-ng.d/10-init.sh +++ b/docker/base/debian-9/conf/bin/service.d/syslog-ng.d/10-init.sh @@ -6,5 +6,5 @@ if [ ! -S /var/lib/syslog-ng/syslog-ng.ctl ]; then rm -f /var/lib/syslog-ng/sysl if [[ ! -p /docker.stdout ]]; then # Switch to file (tty docker mode) - rpl --quiet 'pipe("/docker.stdout")' 'file("/docker.stdout")' -- /opt/docker/etc/syslog-ng/syslog-ng.conf > /dev/null + go-replace -s 'pipe("/docker.stdout")' -r 'file("/docker.stdout")' -- /opt/docker/etc/syslog-ng/syslog-ng.conf fi diff --git a/docker/base/debian-9/conf/bin/usr-bin/docker-provision b/docker/base/debian-9/conf/bin/usr-bin/docker-provision new file mode 100644 index 000000000..4ee715c64 --- /dev/null +++ b/docker/base/debian-9/conf/bin/usr-bin/docker-provision @@ -0,0 +1,9 @@ +#!/usr/bin/env bash + +set -o pipefail # trace ERR through pipes +set -o errtrace # trace ERR through 'time command' and other functions +set -o nounset ## set -u : exit the script if you try to use an uninitialised variable +set -o errexit ## set -e : exit the script if any statement returns a non-true return value + +# wrapper +exec /opt/docker/bin/provision "$@" diff --git a/docker/base/debian-9/conf/bin/usr-bin/docker-service-disable b/docker/base/debian-9/conf/bin/usr-bin/docker-service-disable new file mode 100644 index 000000000..2b5b31bb4 --- /dev/null +++ b/docker/base/debian-9/conf/bin/usr-bin/docker-service-disable @@ -0,0 +1,30 @@ +#!/usr/bin/env bash + +set -o pipefail # trace ERR through pipes +set -o errtrace # trace ERR through 'time command' and other functions +set -o nounset ## set -u : exit the script if you try to use an uninitialised variable +set -o errexit ## set -e : exit the script if any statement returns a non-true return value + +source /opt/docker/bin/config.sh + +rootCheck "$0" + +if [[ "$#" -eq 0 ]]; then + echo "Usage: $0 " + exit 1 +fi + +for SERVICE in "$@"; do + SERVICE_FILE="/opt/docker/etc/supervisor.d/${SERVICE}.conf" + + ## Disable service + if [[ -f "$SERVICE_FILE" ]]; then + go-replace --mode=lineinfile \ + -s 'autostart =' -r 'autostart = false' \ + -- "$SERVICE_FILE" + else + echo "[ERROR] Service '${SERVICE}' not found (tried ${SERVICE_FILE})" + exit 1 + fi +done + diff --git a/docker/base/debian-9/conf/bin/usr-bin/docker-service-enable b/docker/base/debian-9/conf/bin/usr-bin/docker-service-enable new file mode 100644 index 000000000..8d36a14a9 --- /dev/null +++ b/docker/base/debian-9/conf/bin/usr-bin/docker-service-enable @@ -0,0 +1,41 @@ +#!/usr/bin/env bash + +set -o pipefail # trace ERR through pipes +set -o errtrace # trace ERR through 'time command' and other functions +set -o nounset ## set -u : exit the script if you try to use an uninitialised variable +set -o errexit ## set -e : exit the script if any statement returns a non-true return value + +source /opt/docker/bin/config.sh + +rootCheck "$0" + +if [[ "$#" -eq 0 ]]; then + echo "Usage: $0 " + exit 1 +fi + +for SERVICE in "$@"; do + SERVICE_FILE="/opt/docker/etc/supervisor.d/${SERVICE}.conf" + PROVISION_FILE="/opt/docker/provision/service.d/${SERVICE}.sh" + + # Run on demand installation/provisioning + if [[ -f "$PROVISION_FILE" ]]; then + echo "Running provisioning for ${SERVICE}, please wait..." + + ## execute scripts + . "$PROVISION_FILE" + + ## remove directory (one run time) + rm -f -- "$PROVISION_FILE" + fi + + ## Enable service + if [[ -f "$SERVICE_FILE" ]]; then + go-replace --mode=lineinfile \ + -s 'autostart =' -r 'autostart = true' \ + -- "$SERVICE_FILE" + else + echo "[ERROR] Service '${SERVICE}' not found (tried ${SERVICE_FILE})" + exit 1 + fi +done diff --git a/docker/base/debian-9/conf/bin/usr-bin/service b/docker/base/debian-9/conf/bin/usr-bin/service new file mode 100755 index 000000000..55ea12bf7 --- /dev/null +++ b/docker/base/debian-9/conf/bin/usr-bin/service @@ -0,0 +1,86 @@ +#!/bin/bash + +set -o pipefail # trace ERR through pipes +set -o errtrace # trace ERR through 'time command' and other functions +set -o nounset ## set -u : exit the script if you try to use an uninitialised variable +set -o errexit ## set -e : exit the script if any statement returns a non-true return value + +# Root check +if [ "$(/usr/bin/whoami)" != "root" ]; then + echo "[ERROR] Must be run as root" + exit 1 +fi + +function serviceHelp() { + echo "Usage: $(basename "$0") " +} + +function getServicePid() { + local serviceName="$1" + local servicePid=$(supervisorctl pid "${serviceName}:${serviceName}d") + + if [[ -z "$servicePid" ]] || [[ "$servicePid" == "0" ]]; then + echo "not running" + exit 1 + fi + + echo $servicePid +} + +# Param check +if [ "$#" -lt 2 ]; then + echo "[ERROR] Missing parameters" + serviceHelp + exit 1 +fi + +############################# +# Param init +############################# + +SERVICENAME="$1" +ACTION="$2" + +############################# +# Service aliases +############################# +case "$SERVICENAME" in + apache2|httpd) + SERVICENAME="apache" + ;; +esac + +############################# +# Action runner +############################# +case "$ACTION" in + stop|start|restart|status) + exec supervisorctl "$ACTION" "${SERVICENAME}:${SERVICENAME}d" + ;; + + pid) + echo $(getServicePid "${SERVICENAME}") + ;; + + check) + FIRST_PID=$(getServicePid "${SERVICENAME}") + sleep 5 + SECOND_PID=$(getServicePid "${SERVICENAME}") + + if [[ "$FIRST_PID" == "$SECOND_PID" ]]; then + echo "ok" + exit 0 + else + echo "not running" + exit 1 + fi + ;; + + + *) + echo "[ERROR] Invalid action" + serviceHelp + exit 1 + ;; + +esac diff --git a/docker/base/debian-9/conf/etc/supervisor.conf b/docker/base/debian-9/conf/etc/supervisor.conf index 7c109515a..479e0db08 100644 --- a/docker/base/debian-9/conf/etc/supervisor.conf +++ b/docker/base/debian-9/conf/etc/supervisor.conf @@ -2,9 +2,16 @@ nodaemon=true [unix_http_server] -file = /var/run/supervisor.sock -# username = root -# password = {SHA}e982f17bcbe0f724063b708a4f76db211a999304 +file = /.supervisor.sock +chmod = 0700 +chown = root:root +username = root +password = {SHA}e982f17bcbe0f724063b708a4f76db211a999304 + +[supervisorctl] +serverurl = unix:///.supervisor.sock +username = root +password = docker [rpcinterface:supervisor] supervisor.rpcinterface_factory = supervisor.rpcinterface:make_main_rpcinterface diff --git a/docker/base/debian-9/conf/etc/supervisor.d/dnsmasq.conf b/docker/base/debian-9/conf/etc/supervisor.d/dnsmasq.conf new file mode 100644 index 000000000..9832ffca7 --- /dev/null +++ b/docker/base/debian-9/conf/etc/supervisor.d/dnsmasq.conf @@ -0,0 +1,14 @@ +[group:dnsmasq] +programs=dnsmasqd +priority=15 + +[program:dnsmasqd] +command = /opt/docker/bin/service.d/dnsmasq.sh +process_name=%(program_name)s +startsecs = 0 +autostart = false +autorestart = true +stdout_logfile=/dev/stdout +stdout_logfile_maxbytes=0 +stderr_logfile=/dev/stderr +stderr_logfile_maxbytes=0 diff --git a/docker/base-app/debian-9/conf/etc/supervisor.d/postfix.conf b/docker/base/debian-9/conf/etc/supervisor.d/postfix.conf similarity index 100% rename from docker/base-app/debian-9/conf/etc/supervisor.d/postfix.conf rename to docker/base/debian-9/conf/etc/supervisor.d/postfix.conf diff --git a/docker/base-app/debian-9/conf/etc/supervisor.d/ssh.conf b/docker/base/debian-9/conf/etc/supervisor.d/ssh.conf similarity index 100% rename from docker/base-app/debian-9/conf/etc/supervisor.d/ssh.conf rename to docker/base/debian-9/conf/etc/supervisor.d/ssh.conf diff --git a/docker/base/debian-9/conf/etc/supervisor.d/syslog-ng.conf b/docker/base/debian-9/conf/etc/supervisor.d/syslog-ng.conf deleted file mode 100644 index 247fd1a25..000000000 --- a/docker/base/debian-9/conf/etc/supervisor.d/syslog-ng.conf +++ /dev/null @@ -1,13 +0,0 @@ -[group:syslog] -programs=syslogd -priority=10 - -[program:syslogd] -command = /opt/docker/bin/service.d/syslog-ng.sh -process_name=%(program_name)s -autostart = true -autorestart = true -stdout_logfile=/dev/stdout -stdout_logfile_maxbytes=0 -stderr_logfile=/dev/stderr -stderr_logfile_maxbytes=0 diff --git a/docker/base/debian-9/conf/etc/supervisor.d/syslog.conf b/docker/base/debian-9/conf/etc/supervisor.d/syslog.conf new file mode 100644 index 000000000..20d1e238c --- /dev/null +++ b/docker/base/debian-9/conf/etc/supervisor.d/syslog.conf @@ -0,0 +1,13 @@ +[group:syslog] +programs=syslogd +priority=10 + +[program:syslogd] +command = /opt/docker/bin/service.d/syslog-ng.sh +process_name=%(program_name)s +autostart = false +autorestart = true +stdout_logfile=/dev/stdout +stdout_logfile_maxbytes=0 +stderr_logfile=/dev/stderr +stderr_logfile_maxbytes=0 diff --git a/docker/base/debian-9/conf/provision/roles/webdevops-base/tasks/bootstrap.yml b/docker/base/debian-9/conf/provision/roles/webdevops-base/tasks/bootstrap.yml index 30be03c38..9f842336c 100644 --- a/docker/base/debian-9/conf/provision/roles/webdevops-base/tasks/bootstrap.yml +++ b/docker/base/debian-9/conf/provision/roles/webdevops-base/tasks/bootstrap.yml @@ -4,6 +4,5 @@ - include: bootstrap/misc.yml - include: bootstrap/root.yml - include: bootstrap/supervisor.yml -- include: bootstrap/syslog-ng.yml -- include: bootstrap/logrotate.yml - include: bootstrap/pam.yml +- include: bootstrap/entrypoint.yml diff --git a/docker/base/debian-9/conf/provision/roles/webdevops-base/tasks/bootstrap/entrypoint.yml b/docker/base/debian-9/conf/provision/roles/webdevops-base/tasks/bootstrap/entrypoint.yml new file mode 100644 index 000000000..d5d8809f4 --- /dev/null +++ b/docker/base/debian-9/conf/provision/roles/webdevops-base/tasks/bootstrap/entrypoint.yml @@ -0,0 +1,8 @@ +--- + +- name: Create link for entrypoint + file: + src: '/opt/docker/bin/entrypoint.sh' + dest: '/entrypoint' + state: link + force: yes diff --git a/docker/base/debian-9/conf/provision/roles/webdevops-base/tasks/bootstrap/logrotate.yml b/docker/base/debian-9/conf/provision/roles/webdevops-base/tasks/bootstrap/logrotate.yml deleted file mode 100644 index d87926be2..000000000 --- a/docker/base/debian-9/conf/provision/roles/webdevops-base/tasks/bootstrap/logrotate.yml +++ /dev/null @@ -1,33 +0,0 @@ ---- - -- name: Configure logrotate running user - lineinfile: - dest: /etc/logrotate.conf - regexp: '^su [-_a-zA-Z0-9]+ [-_a-zA-Z0-9]+' - line: 'su root adm' - -- name: Register logrotate configurations - file: - src: '{{ item }}' - dest: '/etc/logrotate.d/{{ item | basename }}' - state: link - force: yes - with_fileglob: - - /opt/docker/etc/logrotate.d/* - -- name: Remove system logrotates (not needed) - file: - path: '{{ item }}' - state: absent - with_items: - # Debian/Ubuntu - - /etc/cron.daily/logrotate - - /etc/cron.daily/apt-compat - - /etc/cron.daily/dpkg - - /etc/cron.daily/passwd - # RedHat - - /etc/cron.daily/0yum-daily.cron - - /etc/cron.daily/logrotate - - /etc/cron.hourly/0yum-hourly.cron - # Alpine - - /etc/periodic/daily/logrotate diff --git a/docker/base/debian-9/conf/provision/roles/webdevops-base/tasks/bootstrap/supervisor.yml b/docker/base/debian-9/conf/provision/roles/webdevops-base/tasks/bootstrap/supervisor.yml index bda0394b6..2ce07ac26 100644 --- a/docker/base/debian-9/conf/provision/roles/webdevops-base/tasks/bootstrap/supervisor.yml +++ b/docker/base/debian-9/conf/provision/roles/webdevops-base/tasks/bootstrap/supervisor.yml @@ -4,3 +4,10 @@ file: path: '/usr/sbin/service' state: absent + +- name: Create link for supervisor.conf + file: + src: '/opt/docker/etc/supervisor.conf' + dest: '/etc/supervisord.conf' + state: link + force: yes diff --git a/docker/base/debian-9/conf/provision/roles/webdevops-base/tasks/bootstrap/syslog-ng.yml b/docker/base/debian-9/conf/provision/roles/webdevops-base/tasks/bootstrap/syslog-ng.yml deleted file mode 100644 index 27c8f6a30..000000000 --- a/docker/base/debian-9/conf/provision/roles/webdevops-base/tasks/bootstrap/syslog-ng.yml +++ /dev/null @@ -1,33 +0,0 @@ ---- - -- name: Get syslog-ng version - shell: "syslog-ng --version | grep -E -e '^syslog-ng[ ]+[0-9]+\\.[0-9]+' | head -n 1 | awk '{print $2}' | cut -f 1,2 -d ." - register: syslogng_version - -- name: Configure syslog-ng (default) - lineinfile: - dest: /etc/default/syslog-ng - regexp: '^[\s]*{{ item.key }}[\s]*=' - line: '{{ item.key }}="{{ item.value }}"' - create: yes - with_items: - - { key: 'SYSLOGNG_OPTS', value: '--no-caps' } - -- name: Enable syslog-ng config - file: - src: '/opt/docker/etc/syslog-ng/syslog-ng.conf' - dest: '/etc/syslog-ng/syslog-ng.conf' - state: link - force: yes - -- name: Set version of syslog-ng file - lineinfile: - dest: '/etc/syslog-ng/syslog-ng.conf' - regexp: '^@version:' - line: '@version: {{ syslogng_version.stdout }}' - -- name: Ensure /var/lib/syslog-ng exists - file: - path: '/var/lib/syslog-ng' - state: directory - recurse: yes diff --git a/docker/base/debian-9/conf/provision/roles/webdevops-base/tasks/bootstrap/system.yml b/docker/base/debian-9/conf/provision/roles/webdevops-base/tasks/bootstrap/system.yml index 8dfbf9665..0741d7cae 100644 --- a/docker/base/debian-9/conf/provision/roles/webdevops-base/tasks/bootstrap/system.yml +++ b/docker/base/debian-9/conf/provision/roles/webdevops-base/tasks/bootstrap/system.yml @@ -14,3 +14,20 @@ dest: '/entrypoint.cmd' state: link force: yes + +- name: Remove system logrotate and cronjobs (not needed) + file: + path: '{{ item }}' + state: absent + with_items: + # Debian/Ubuntu + - /etc/cron.daily/logrotate + - /etc/cron.daily/apt-compat + - /etc/cron.daily/dpkg + - /etc/cron.daily/passwd + # RedHat + - /etc/cron.daily/0yum-daily.cron + - /etc/cron.daily/logrotate + - /etc/cron.hourly/0yum-hourly.cron + # Alpine + - /etc/periodic/daily/logrotate diff --git a/docker/php-apache/alpine-3-php7/conf/etc/httpd/vhost.common.d/.gitkeep b/docker/base/debian-9/conf/provision/roles/webdevops-base/tasks/build/.gitkeep similarity index 100% rename from docker/php-apache/alpine-3-php7/conf/etc/httpd/vhost.common.d/.gitkeep rename to docker/base/debian-9/conf/provision/roles/webdevops-base/tasks/build/.gitkeep diff --git a/docker/base/debian-9/conf/provision/roles/webdevops-base/tasks/build/logrotate.yml b/docker/base/debian-9/conf/provision/roles/webdevops-base/tasks/build/logrotate.yml deleted file mode 100644 index 10f7e6644..000000000 --- a/docker/base/debian-9/conf/provision/roles/webdevops-base/tasks/build/logrotate.yml +++ /dev/null @@ -1,10 +0,0 @@ ---- - -- name: Register logrotate configurations - file: - src: '{{ item }}' - dest: '/etc/logrotate.d/{{ item | basename }}' - state: link - force: yes - with_fileglob: - - /opt/docker/etc/logrotate.d/* diff --git a/docker/php-apache/alpine-3/conf/etc/httpd/conf.d/.gitkeep b/docker/base/debian-9/conf/provision/service.d/.gitkeep similarity index 100% rename from docker/php-apache/alpine-3/conf/etc/httpd/conf.d/.gitkeep rename to docker/base/debian-9/conf/provision/service.d/.gitkeep diff --git a/docker/base/debian-9/conf/provision/service.d/cron.sh b/docker/base/debian-9/conf/provision/service.d/cron.sh new file mode 100644 index 000000000..bd8a54781 --- /dev/null +++ b/docker/base/debian-9/conf/provision/service.d/cron.sh @@ -0,0 +1,13 @@ +#!/usr/bin/env bash + +IMAGE_FAMILY=$(docker-image-info family) + +case "$IMAGE_FAMILY" in + Debian|Ubuntu) + apt-install cron + ;; + + RedHat) + yum-install cronie + ;; +esac diff --git a/docker/base/debian-9/conf/provision/service.d/dnsmasq.sh b/docker/base/debian-9/conf/provision/service.d/dnsmasq.sh new file mode 100644 index 000000000..9e5c3228c --- /dev/null +++ b/docker/base/debian-9/conf/provision/service.d/dnsmasq.sh @@ -0,0 +1,24 @@ +#!/usr/bin/env bash + +IMAGE_FAMILY=$(docker-image-info family) + +# Installation +case "$IMAGE_FAMILY" in + Debian|Ubuntu) + apt-install dnsmasq + ;; + + RedHat) + yum-install dnsmasq + ;; + + Alpine) + apk-install dnsmasq + ;; +esac + +# Configuration +go-replace --mode=line \ + -s '^[\s]*user[\s]*=' -r 'user = root' \ + -s '^[\s]*conf-dir[\s]*=' -r 'conf-dir = /etc/dnsmasq.d' \ + -- /etc/dnsmasq.conf diff --git a/docker/base/debian-9/conf/provision/service.d/postfix.sh b/docker/base/debian-9/conf/provision/service.d/postfix.sh new file mode 100644 index 000000000..ff1879345 --- /dev/null +++ b/docker/base/debian-9/conf/provision/service.d/postfix.sh @@ -0,0 +1,28 @@ +#!/usr/bin/env bash + +IMAGE_FAMILY=$(docker-image-info family) + +# Installation +case "$IMAGE_FAMILY" in + Debian|Ubuntu) + apt-install postfix + ;; + + RedHat) + yum-install postfix + ;; + + Alpine) + apk-install postfix + ln -s -f /etc/postfix/aliases /etc/aliases + ;; +esac + +# Configuration +go-replace --mode=line \ + -s '^[\s]*mydestination[\s]*=' -r 'mydestination = ' \ + -s '^[\s]*message_size_limit[\s]*=' -r 'message_size_limit = 15240000' \ + -s '^[\s]*smtp_use_tls[\s]*=' -r 'smtp_use_tls = yes' \ + -s '^[\s]*smtp_tls_security_level[\s]*=' -r 'smtp_tls_security_level = may' \ + -s '^[\s]*myhostname[\s]*=' -r '# myhostname' \ + -- /etc/postfix/main.cf diff --git a/docker/base/debian-9/conf/provision/service.d/ssh.sh b/docker/base/debian-9/conf/provision/service.d/ssh.sh new file mode 100644 index 000000000..63d7a9f3a --- /dev/null +++ b/docker/base/debian-9/conf/provision/service.d/ssh.sh @@ -0,0 +1,17 @@ +#!/usr/bin/env bash + +IMAGE_FAMILY=$(docker-image-info family) + +case "$IMAGE_FAMILY" in + Debian|Ubuntu) + apt-install openssh-server + ;; + + RedHat) + yum-install openssh-server + ;; + + Alpine) + apk-install openssh + ;; +esac diff --git a/docker/base/debian-9/conf/provision/service.d/syslog.sh b/docker/base/debian-9/conf/provision/service.d/syslog.sh new file mode 100644 index 000000000..7e8b8e0a9 --- /dev/null +++ b/docker/base/debian-9/conf/provision/service.d/syslog.sh @@ -0,0 +1,41 @@ +#!/usr/bin/env bash + +IMAGE_FAMILY=$(docker-image-info family) + +# Installation +case "$IMAGE_FAMILY" in + Debian|Ubuntu) + apt-install syslog-ng syslog-ng-core + ;; + + RedHat) + yum-install syslog-ng + + # remove logrotate (not needed for docker) + rm -f "/etc/cron.daily/logrotate" + ;; + + Alpine) + apk-install syslog-ng + ;; +esac + +## Configuration +SYSLOG_NG_VERSION=$(syslog-ng --version | grep -E -e '^syslog-ng[ ]+[0-9]+\.[0-9]+' | head -n 1 | awk '{print $2}' | cut -f 1,2 -d .) + +# Disable caps inside container +if [[ -f /etc/default/syslog-ng ]]; then + go-replace --mode=lineinfile \ + -s "SYSLOGNG_OPTS" -r "SYSLOGNG_OPTS = --no-caps" \ + -- /etc/default/syslog-ng +fi + +# Symlink configuration +ln -s -f /opt/docker/etc/syslog-ng/syslog-ng.conf /etc/syslog-ng/syslog-ng.conf + +go-replace --mode=lineinfile \ + -s "@version" -r "@version: ${SYSLOG_NG_VERSION}" \ + -- /etc/syslog-ng/syslog-ng.conf + +# Ensure /var/lib/syslog-ng exists +mkdir -p /var/lib/syslog-ng diff --git a/docker/base/debian-9/conf/provision/variables-webdevops.yml b/docker/base/debian-9/conf/provision/variables-webdevops.yml new file mode 100644 index 000000000..0b2a21a95 --- /dev/null +++ b/docker/base/debian-9/conf/provision/variables-webdevops.yml @@ -0,0 +1,7 @@ +--- + +docker_image_info_family: "{{ lookup('pipe', 'docker-image-info family') }}" +docker_image_info_distribution: "{{ lookup('pipe', 'docker-image-info dist') }}" +docker_image_info_distribution_version: "{{ lookup('pipe', 'docker-image-info dist-version') }}" +docker_image_info_distribution_release: "{{ lookup('pipe', 'docker-image-info dist-release') }}" +docker_image_info_distribution_codename: "{{ lookup('pipe', 'docker-image-info dist-codename') }}" diff --git a/docker/base/debian-9/conf/provision/variables.yml b/docker/base/debian-9/conf/provision/variables.yml index ed97d539c..0b2a21a95 100644 --- a/docker/base/debian-9/conf/provision/variables.yml +++ b/docker/base/debian-9/conf/provision/variables.yml @@ -1 +1,7 @@ --- + +docker_image_info_family: "{{ lookup('pipe', 'docker-image-info family') }}" +docker_image_info_distribution: "{{ lookup('pipe', 'docker-image-info dist') }}" +docker_image_info_distribution_version: "{{ lookup('pipe', 'docker-image-info dist-version') }}" +docker_image_info_distribution_release: "{{ lookup('pipe', 'docker-image-info dist-release') }}" +docker_image_info_distribution_codename: "{{ lookup('pipe', 'docker-image-info dist-codename') }}" diff --git a/docker/base/ubuntu-12.04/Dockerfile b/docker/base/ubuntu-12.04/Dockerfile index 87a7bda21..4c51ff425 100644 --- a/docker/base/ubuntu-12.04/Dockerfile +++ b/docker/base/ubuntu-12.04/Dockerfile @@ -5,31 +5,47 @@ FROM webdevops/bootstrap:ubuntu-12.04 -MAINTAINER info@webdevops.io -LABEL vendor=WebDevOps.io -LABEL io.webdevops.layout=8 -LABEL io.webdevops.version=1.5.0 - -ENV DOCKER_CONF_HOME /opt/docker/ +ENV DOCKER_CONF_HOME=/opt/docker/ \ + LOG_STDOUT="" \ + LOG_STDERR="" COPY conf/ /opt/docker/ +# Install ansible +RUN /usr/local/bin/apt-install \ + python-minimal \ + python-setuptools \ + python-pip \ + python-paramiko \ + python-jinja2 \ + python-dev \ + libffi-dev \ + libssl-dev \ + build-essential \ + && pip install --upgrade pip \ + && hash -r \ + && pip install --no-cache-dir ansible \ + && chmod 750 /usr/local/bin/ansible* \ + # Cleanup + && apt-get purge -y -f --force-yes \ + python-dev \ + build-essential \ + libssl-dev \ + libffi-dev \ + && docker-image-cleanup + # Install services RUN chmod +x /opt/docker/bin/* \ && /usr/local/bin/apt-install \ supervisor \ - syslog-ng \ - syslog-ng-core \ - logrotate \ - cron \ wget \ curl \ net-tools \ gnupg \ && chmod +s /usr/local/bin/gosu \ && /opt/docker/bin/provision run --tag bootstrap --role webdevops-base \ - && /opt/docker/bin/bootstrap.sh - + && /opt/docker/bin/bootstrap.sh \ + && docker-image-cleanup ENTRYPOINT ["/opt/docker/bin/entrypoint.sh"] CMD ["supervisord"] diff --git a/docker/base/ubuntu-12.04/Dockerfile.jinja2 b/docker/base/ubuntu-12.04/Dockerfile.jinja2 index 765843d39..5329168f1 100644 --- a/docker/base/ubuntu-12.04/Dockerfile.jinja2 +++ b/docker/base/ubuntu-12.04/Dockerfile.jinja2 @@ -1,11 +1,11 @@ {{ docker.from("bootstrap", "ubuntu-12.04") }} -{{ docker.version() }} - -{{ environment.homePath() }} +{{ environment.base() }} {{ docker.copy('conf/', '/opt/docker/') }} +{{ ansible.ubuntu() }} + {{ base.ubuntu() }} {{ docker.entrypoint("/opt/docker/bin/entrypoint.sh") }} diff --git a/docker/base/ubuntu-12.04/conf/bin/bootstrap.sh b/docker/base/ubuntu-12.04/conf/bin/bootstrap.sh index 1d1a30f72..855c10782 100644 --- a/docker/base/ubuntu-12.04/conf/bin/bootstrap.sh +++ b/docker/base/ubuntu-12.04/conf/bin/bootstrap.sh @@ -17,10 +17,16 @@ rootCheck "$0" # Save the buildtime date +%s > /opt/docker/BUILDTIME +date +%s >/opt/docker/etc/.registry/image_info_buildtime # Make all scripts executable find /opt/docker/bin/ -type f -iname '*.sh' -print0 | xargs --no-run-if-empty -0 chmod +x +# Enable usr-bin executables +find /opt/docker/bin/usr-bin -type f | while read USR_BIN_FILE; do + chmod +x -- "$USR_BIN_FILE" + ln -n -f -- "$USR_BIN_FILE" "/usr/local/bin/$(basename "$USR_BIN_FILE")" +done case "$BOOTSTRAP_MODE" in ################################### @@ -44,6 +50,23 @@ case "$BOOTSTRAP_MODE" in echo "[ERROR] Bootstrap mode '$BOOTSTRAP_MODE' not defined" exit 1 ;; - esac + +###################### +# Check if entrypoint provisioning is available +###################### + +echo "Checking provision status..." +for PROVISION_TAG in onbuild build bootstrap entrypoint; do + ROLES=$(docker-provision list --tag "$PROVISION_TAG") + if [[ -n "$ROLES" ]]; then + PROVISION_ROLE_COUNT=$(echo "$ROLES" | wc -l) + echo " - found ${PROVISION_ROLE_COUNT} for provision tag ${PROVISION_TAG}, caching info for execution" + echo -n "$PROVISION_ROLE_COUNT" > "/opt/docker/etc/.registry/provision-availale.${PROVISION_TAG}" + else + echo " - no roles found for provision tag ${PROVISION_TAG}" + echo -n '' > "/opt/docker/etc/.registry/provision-availale.${PROVISION_TAG}" + fi +done + diff --git a/docker/base/ubuntu-12.04/conf/bin/config.sh b/docker/base/ubuntu-12.04/conf/bin/config.sh index 3155728e8..049756c26 100644 --- a/docker/base/ubuntu-12.04/conf/bin/config.sh +++ b/docker/base/ubuntu-12.04/conf/bin/config.sh @@ -15,44 +15,23 @@ function rootCheck() { } ### - # Create named pipe - # - # $1 -> name of file + # Create /docker.stdout and /docker.stderr # ## -function createNamedPipe() { - rm --force -- "$1" - mknod "$1" p -} - -### - # Escape value for sed usage - # - # $1 -> value - # STDOUT -> escaped value - # - ## -function sedEscape() { - echo "$(echo $* |sed -e 's/[]\/$*.^|[]/\\&/g')" -} +function createDockerStdoutStderr() { + # link stdout from docker + if [[ -z "$LOG_STDOUT" ]]; then + LOG_STDOUT="/proc/$$/fd/1" + fi -### - # Replace text inside a file - # - # $1 -> source value - # $2 -> target value - # $3 -> path to file - # - ## -function replaceTextInFile() { - SOURCE="$(sedEscape $1)" - REPLACE="$(sedEscape $2)" - TARGET="$3" + if [[ -z "$LOG_STDERR" ]]; then + LOG_STDERR="/proc/$$/fd/2" + fi - sed -i "s/${SOURCE}/${REPLACE}/" "${TARGET}" + ln -f -s "$LOG_STDOUT" /docker.stdout + ln -f -s "$LOG_STDERR" /docker.stderr + chmod 600 /docker.stdout /docker.stderr } - - ### # Include script directory text inside a file # @@ -104,7 +83,7 @@ function runEntrypoints() { . /opt/docker/bin/entrypoint.d/default.sh fi - exit + exit 1 } ### @@ -161,6 +140,12 @@ function runProvisionEntrypoint() { function runDockerProvision() { ANSIBLE_TAG="$1" - /opt/docker/bin/provision run --tag "$ANSIBLE_TAG" --use-registry + PROVISION_STATS_FILE="/opt/docker/etc/.registry/provision-stats.${ANSIBLE_TAG}" + + # run provision if stats file doesn't exists (unknown mode) + # or if stats file is not empty + if [[ ! -f "$PROVISION_STATS_FILE" ]] || [[ -s "$PROVISION_STATS_FILE" ]]; then + /opt/docker/bin/provision run --tag "${ANSIBLE_TAG}" --use-registry + fi } diff --git a/docker/base/ubuntu-12.04/conf/bin/control.sh b/docker/base/ubuntu-12.04/conf/bin/control.sh index a6697092d..22d189745 100644 --- a/docker/base/ubuntu-12.04/conf/bin/control.sh +++ b/docker/base/ubuntu-12.04/conf/bin/control.sh @@ -101,23 +101,13 @@ case "$CONTROL_COMMAND" in ## ------------------------------------------ "service.enable") - SERVICE_FILE="/opt/docker/etc/supervisor.d/$1.conf" - if [ -f "$SERVICE_FILE" ]; then - sed -i '/autostart = /c\autostart = true' -- "$SERVICE_FILE" - else - echo "[ERROR] Service '${1}' not found (tried ${SERVICE_FILE})" - exit 1 - fi + deprecationNotice " Please use >>docker-service-enable [service]<<" + docker-service-enable "$1" ;; "service.disable") - SERVICE_FILE="/opt/docker/etc/supervisor.d/$1.conf" - if [ -f "$SERVICE_FILE" ]; then - sed -i '/autostart = /c\autostart = false' -- "$SERVICE_FILE" - else - echo "[ERROR] Service '${1}' not found (tried ${SERVICE_FILE})" - exit 1 - fi + deprecationNotice " Please use >>docker-service-disable [service]<<" + docker-service-disable "$1" ;; ## ------------------------------------------ diff --git a/docker/base/ubuntu-12.04/conf/bin/entrypoint.d/cli.sh b/docker/base/ubuntu-12.04/conf/bin/entrypoint.d/cli.sh index 2ca68926c..fe212a8ea 100644 --- a/docker/base/ubuntu-12.04/conf/bin/entrypoint.d/cli.sh +++ b/docker/base/ubuntu-12.04/conf/bin/entrypoint.d/cli.sh @@ -8,7 +8,7 @@ if [ -n "${CLI_SCRIPT}" ]; then if [ -n "$APPLICATION_USER" ]; then # Run as EFFECTIVE_USER shift - exec sudo -H -E -u "${APPLICATION_USER}" ${CLI_SCRIPT} "$@" + exec gosu "${APPLICATION_USER}" ${CLI_SCRIPT} "$@" else # Run as root exec ${CLI_SCRIPT} "$@" diff --git a/docker/base/ubuntu-12.04/conf/bin/entrypoint.d/noop.sh b/docker/base/ubuntu-12.04/conf/bin/entrypoint.d/noop.sh index 967920837..092d55d8b 100644 --- a/docker/base/ubuntu-12.04/conf/bin/entrypoint.d/noop.sh +++ b/docker/base/ubuntu-12.04/conf/bin/entrypoint.d/noop.sh @@ -4,5 +4,4 @@ ## NOOP (no operation) ############################################# -tail -f /dev/null -exit +exec tail -f /dev/null diff --git a/docker/base/ubuntu-12.04/conf/bin/entrypoint.d/supervisord.sh b/docker/base/ubuntu-12.04/conf/bin/entrypoint.d/supervisord.sh index ead991551..f21489667 100644 --- a/docker/base/ubuntu-12.04/conf/bin/entrypoint.d/supervisord.sh +++ b/docker/base/ubuntu-12.04/conf/bin/entrypoint.d/supervisord.sh @@ -4,8 +4,6 @@ ## Supervisord (start daemons) ############################################# -rootCheck "supervisord" - ## Start services exec /opt/docker/bin/service.d/supervisor.sh diff --git a/docker/base/ubuntu-12.04/conf/bin/entrypoint.sh b/docker/base/ubuntu-12.04/conf/bin/entrypoint.sh index bbabcdddb..01f59660c 100644 --- a/docker/base/ubuntu-12.04/conf/bin/entrypoint.sh +++ b/docker/base/ubuntu-12.04/conf/bin/entrypoint.sh @@ -20,16 +20,13 @@ chmod -s /usr/local/bin/gosu trap 'echo sigterm ; exit' SIGTERM trap 'echo sigkill ; exit' SIGKILL -# link stdout from docker -ln -f -s "/proc/$$/fd/1" /docker.stdout -ln -f -s "/proc/$$/fd/2" /docker.stderr -chmod 600 /docker.stdout /docker.stderr - # sanitize input and set task TASK="$(echo $1| sed 's/[^-_a-zA-Z0-9]*//g')" source /opt/docker/bin/config.sh +createDockerStdoutStderr + if [[ "$UID" -eq 0 ]]; then # Only run provision if user is root diff --git a/docker/base/ubuntu-12.04/conf/bin/logwatch.sh b/docker/base/ubuntu-12.04/conf/bin/logwatch.sh deleted file mode 100644 index 1a5b486c7..000000000 --- a/docker/base/ubuntu-12.04/conf/bin/logwatch.sh +++ /dev/null @@ -1,14 +0,0 @@ -#!/usr/bin/env bash - -set -o pipefail # trace ERR through pipes -set -o errtrace # trace ERR through 'time command' and other functions -set -o nounset ## set -u : exit the script if you try to use an uninitialised variable -set -o errexit ## set -e : exit the script if any statement returns a non-true return value - -sleep 0.5 - -if [ -p "$2" ]; then - sed --unbuffered -e "s/^/\[$1\] /" -- "$2" -else - tail -n 0 -F -q "$2" | sed --unbuffered -e "s/^/\[$1\] /" -fi diff --git a/docker/base/ubuntu-12.04/conf/bin/provision b/docker/base/ubuntu-12.04/conf/bin/provision index f7b5ad0a8..d367c2812 100755 --- a/docker/base/ubuntu-12.04/conf/bin/provision +++ b/docker/base/ubuntu-12.04/conf/bin/provision @@ -19,6 +19,7 @@ PLAYBOOK = Template( - hosts: all vars_files: + - ./variables-webdevops.yml - ./variables.yml roles: - $roles @@ -188,7 +189,7 @@ def actionAdd(args): 'priority': args.priority } - saveJson(json); + saveJson(json) diff --git a/docker/base/ubuntu-12.04/conf/bin/provision.sh b/docker/base/ubuntu-12.04/conf/bin/provision.sh deleted file mode 100644 index 4079dd7f0..000000000 --- a/docker/base/ubuntu-12.04/conf/bin/provision.sh +++ /dev/null @@ -1,30 +0,0 @@ - #!/usr/bin/env bash - -# -# Example: -# provision.sh /opt/foobar/playbook.yml tag -# -# - -set -o pipefail # trace ERR through pipes -set -o errtrace # trace ERR through 'time command' and other functions -set -o nounset ## set -u : exit the script if you try to use an uninitialised variable -set -o errexit ## set -e : exit the script if any statement returns a non-true return value - -. config.sh - -deprecationNotice " Please use >>/opt/docker/bin/provision run --playbook playbook.yml --tag=bootstrap [args]<< for running provision" - - -if [ "$#" -lt 2 ]; then - echo "[ERROR] $0: Playbook or tag is missing" - exit 1 -fi - -ANSIBLE_PLAYBOOK="$1" -shift -ANSIBLE_TAG="$1" -shift -ANSIBLE_OPTS="$@" - -/opt/docker/bin/provision run --playbook "${ANSIBLE_PLAYBOOK}" --use-registry --tag "${ANSIBLE_TAG}" $ANSIBLE_OPTS diff --git a/docker/base-app/ubuntu-12.04/conf/bin/service.d/dnsmasq.d/10-init.sh b/docker/base/ubuntu-12.04/conf/bin/service.d/dnsmasq.d/10-init.sh similarity index 100% rename from docker/base-app/ubuntu-12.04/conf/bin/service.d/dnsmasq.d/10-init.sh rename to docker/base/ubuntu-12.04/conf/bin/service.d/dnsmasq.d/10-init.sh diff --git a/docker/base-app/ubuntu-12.04/conf/bin/service.d/dnsmasq.sh b/docker/base/ubuntu-12.04/conf/bin/service.d/dnsmasq.sh similarity index 100% rename from docker/base-app/ubuntu-12.04/conf/bin/service.d/dnsmasq.sh rename to docker/base/ubuntu-12.04/conf/bin/service.d/dnsmasq.sh diff --git a/docker/base/ubuntu-12.04/conf/bin/service.d/postfix.d/10-init.sh b/docker/base/ubuntu-12.04/conf/bin/service.d/postfix.d/10-init.sh new file mode 100644 index 000000000..cfd876955 --- /dev/null +++ b/docker/base/ubuntu-12.04/conf/bin/service.d/postfix.d/10-init.sh @@ -0,0 +1,27 @@ +# force new copy of hosts there (otherwise links could be outdated) +mkdir -p /var/spool/postfix/etc +cp -f /etc/hosts /var/spool/postfix/etc/hosts +cp -f /etc/resolv.conf /var/spool/postfix/etc/resolv.conf +cp -f /etc/services /var/spool/postfix/etc/services + +## MYHOSTNAME +# replace line +sed -i '/myhostname[ ]* =/c\' main.cf +echo "myhostname = $(hostname)" >> /etc/postfix/main.cf + +## REPLAYHOST +if [[ -n "${POSTFIX_RELAYHOST+x}" ]]; then + # replace line + sed -i '/relayhost[ ]* =/c\' main.cf + echo "relayhost = $POSTFIX_RELAYHOST" >> /etc/postfix/main.cf +fi + +## MYNETWORKS +if [[ -n "${POSTFIX_MYNETWORKS+x}" ]]; then + # replace line + sed -i '/mynetworks[ ]* =/c\' main.cf + echo "mynetworks = $POSTFIX_MYNETWORKS" >> /etc/postfix/main.cf +fi + +# generate aliases db +newaliases || : diff --git a/docker/base-app/ubuntu-12.04/conf/bin/service.d/postfix.sh b/docker/base/ubuntu-12.04/conf/bin/service.d/postfix.sh similarity index 100% rename from docker/base-app/ubuntu-12.04/conf/bin/service.d/postfix.sh rename to docker/base/ubuntu-12.04/conf/bin/service.d/postfix.sh diff --git a/docker/base/ubuntu-12.04/conf/bin/service.d/ssh.d/10-init.sh b/docker/base/ubuntu-12.04/conf/bin/service.d/ssh.d/10-init.sh new file mode 100644 index 000000000..f2b600312 --- /dev/null +++ b/docker/base/ubuntu-12.04/conf/bin/service.d/ssh.d/10-init.sh @@ -0,0 +1,7 @@ +# Init ssh privilege separation directory +mkdir -p /var/run/sshd +chown root:root /var/run/sshd +chmod 755 /var/run/sshd + +# generate host keys +ssh-keygen -A diff --git a/docker/base-app/ubuntu-12.04/conf/bin/service.d/ssh.sh b/docker/base/ubuntu-12.04/conf/bin/service.d/ssh.sh similarity index 100% rename from docker/base-app/ubuntu-12.04/conf/bin/service.d/ssh.sh rename to docker/base/ubuntu-12.04/conf/bin/service.d/ssh.sh diff --git a/docker/base/ubuntu-12.04/conf/bin/service.d/syslog-ng.d/10-init.sh b/docker/base/ubuntu-12.04/conf/bin/service.d/syslog-ng.d/10-init.sh index 22621d2ad..326207e52 100644 --- a/docker/base/ubuntu-12.04/conf/bin/service.d/syslog-ng.d/10-init.sh +++ b/docker/base/ubuntu-12.04/conf/bin/service.d/syslog-ng.d/10-init.sh @@ -6,5 +6,5 @@ if [ ! -S /var/lib/syslog-ng/syslog-ng.ctl ]; then rm -f /var/lib/syslog-ng/sysl if [[ ! -p /docker.stdout ]]; then # Switch to file (tty docker mode) - rpl --quiet 'pipe("/docker.stdout")' 'file("/docker.stdout")' -- /opt/docker/etc/syslog-ng/syslog-ng.conf > /dev/null + go-replace -s 'pipe("/docker.stdout")' -r 'file("/docker.stdout")' -- /opt/docker/etc/syslog-ng/syslog-ng.conf fi diff --git a/docker/base/ubuntu-12.04/conf/bin/usr-bin/docker-provision b/docker/base/ubuntu-12.04/conf/bin/usr-bin/docker-provision new file mode 100644 index 000000000..4ee715c64 --- /dev/null +++ b/docker/base/ubuntu-12.04/conf/bin/usr-bin/docker-provision @@ -0,0 +1,9 @@ +#!/usr/bin/env bash + +set -o pipefail # trace ERR through pipes +set -o errtrace # trace ERR through 'time command' and other functions +set -o nounset ## set -u : exit the script if you try to use an uninitialised variable +set -o errexit ## set -e : exit the script if any statement returns a non-true return value + +# wrapper +exec /opt/docker/bin/provision "$@" diff --git a/docker/base/ubuntu-12.04/conf/bin/usr-bin/docker-service-disable b/docker/base/ubuntu-12.04/conf/bin/usr-bin/docker-service-disable new file mode 100644 index 000000000..2b5b31bb4 --- /dev/null +++ b/docker/base/ubuntu-12.04/conf/bin/usr-bin/docker-service-disable @@ -0,0 +1,30 @@ +#!/usr/bin/env bash + +set -o pipefail # trace ERR through pipes +set -o errtrace # trace ERR through 'time command' and other functions +set -o nounset ## set -u : exit the script if you try to use an uninitialised variable +set -o errexit ## set -e : exit the script if any statement returns a non-true return value + +source /opt/docker/bin/config.sh + +rootCheck "$0" + +if [[ "$#" -eq 0 ]]; then + echo "Usage: $0 " + exit 1 +fi + +for SERVICE in "$@"; do + SERVICE_FILE="/opt/docker/etc/supervisor.d/${SERVICE}.conf" + + ## Disable service + if [[ -f "$SERVICE_FILE" ]]; then + go-replace --mode=lineinfile \ + -s 'autostart =' -r 'autostart = false' \ + -- "$SERVICE_FILE" + else + echo "[ERROR] Service '${SERVICE}' not found (tried ${SERVICE_FILE})" + exit 1 + fi +done + diff --git a/docker/base/ubuntu-12.04/conf/bin/usr-bin/docker-service-enable b/docker/base/ubuntu-12.04/conf/bin/usr-bin/docker-service-enable new file mode 100644 index 000000000..8d36a14a9 --- /dev/null +++ b/docker/base/ubuntu-12.04/conf/bin/usr-bin/docker-service-enable @@ -0,0 +1,41 @@ +#!/usr/bin/env bash + +set -o pipefail # trace ERR through pipes +set -o errtrace # trace ERR through 'time command' and other functions +set -o nounset ## set -u : exit the script if you try to use an uninitialised variable +set -o errexit ## set -e : exit the script if any statement returns a non-true return value + +source /opt/docker/bin/config.sh + +rootCheck "$0" + +if [[ "$#" -eq 0 ]]; then + echo "Usage: $0 " + exit 1 +fi + +for SERVICE in "$@"; do + SERVICE_FILE="/opt/docker/etc/supervisor.d/${SERVICE}.conf" + PROVISION_FILE="/opt/docker/provision/service.d/${SERVICE}.sh" + + # Run on demand installation/provisioning + if [[ -f "$PROVISION_FILE" ]]; then + echo "Running provisioning for ${SERVICE}, please wait..." + + ## execute scripts + . "$PROVISION_FILE" + + ## remove directory (one run time) + rm -f -- "$PROVISION_FILE" + fi + + ## Enable service + if [[ -f "$SERVICE_FILE" ]]; then + go-replace --mode=lineinfile \ + -s 'autostart =' -r 'autostart = true' \ + -- "$SERVICE_FILE" + else + echo "[ERROR] Service '${SERVICE}' not found (tried ${SERVICE_FILE})" + exit 1 + fi +done diff --git a/docker/base/ubuntu-12.04/conf/bin/usr-bin/service b/docker/base/ubuntu-12.04/conf/bin/usr-bin/service new file mode 100755 index 000000000..55ea12bf7 --- /dev/null +++ b/docker/base/ubuntu-12.04/conf/bin/usr-bin/service @@ -0,0 +1,86 @@ +#!/bin/bash + +set -o pipefail # trace ERR through pipes +set -o errtrace # trace ERR through 'time command' and other functions +set -o nounset ## set -u : exit the script if you try to use an uninitialised variable +set -o errexit ## set -e : exit the script if any statement returns a non-true return value + +# Root check +if [ "$(/usr/bin/whoami)" != "root" ]; then + echo "[ERROR] Must be run as root" + exit 1 +fi + +function serviceHelp() { + echo "Usage: $(basename "$0") " +} + +function getServicePid() { + local serviceName="$1" + local servicePid=$(supervisorctl pid "${serviceName}:${serviceName}d") + + if [[ -z "$servicePid" ]] || [[ "$servicePid" == "0" ]]; then + echo "not running" + exit 1 + fi + + echo $servicePid +} + +# Param check +if [ "$#" -lt 2 ]; then + echo "[ERROR] Missing parameters" + serviceHelp + exit 1 +fi + +############################# +# Param init +############################# + +SERVICENAME="$1" +ACTION="$2" + +############################# +# Service aliases +############################# +case "$SERVICENAME" in + apache2|httpd) + SERVICENAME="apache" + ;; +esac + +############################# +# Action runner +############################# +case "$ACTION" in + stop|start|restart|status) + exec supervisorctl "$ACTION" "${SERVICENAME}:${SERVICENAME}d" + ;; + + pid) + echo $(getServicePid "${SERVICENAME}") + ;; + + check) + FIRST_PID=$(getServicePid "${SERVICENAME}") + sleep 5 + SECOND_PID=$(getServicePid "${SERVICENAME}") + + if [[ "$FIRST_PID" == "$SECOND_PID" ]]; then + echo "ok" + exit 0 + else + echo "not running" + exit 1 + fi + ;; + + + *) + echo "[ERROR] Invalid action" + serviceHelp + exit 1 + ;; + +esac diff --git a/docker/base/ubuntu-12.04/conf/etc/supervisor.conf b/docker/base/ubuntu-12.04/conf/etc/supervisor.conf index 7c109515a..479e0db08 100644 --- a/docker/base/ubuntu-12.04/conf/etc/supervisor.conf +++ b/docker/base/ubuntu-12.04/conf/etc/supervisor.conf @@ -2,9 +2,16 @@ nodaemon=true [unix_http_server] -file = /var/run/supervisor.sock -# username = root -# password = {SHA}e982f17bcbe0f724063b708a4f76db211a999304 +file = /.supervisor.sock +chmod = 0700 +chown = root:root +username = root +password = {SHA}e982f17bcbe0f724063b708a4f76db211a999304 + +[supervisorctl] +serverurl = unix:///.supervisor.sock +username = root +password = docker [rpcinterface:supervisor] supervisor.rpcinterface_factory = supervisor.rpcinterface:make_main_rpcinterface diff --git a/docker/base/ubuntu-12.04/conf/etc/supervisor.d/dnsmasq.conf b/docker/base/ubuntu-12.04/conf/etc/supervisor.d/dnsmasq.conf new file mode 100644 index 000000000..9832ffca7 --- /dev/null +++ b/docker/base/ubuntu-12.04/conf/etc/supervisor.d/dnsmasq.conf @@ -0,0 +1,14 @@ +[group:dnsmasq] +programs=dnsmasqd +priority=15 + +[program:dnsmasqd] +command = /opt/docker/bin/service.d/dnsmasq.sh +process_name=%(program_name)s +startsecs = 0 +autostart = false +autorestart = true +stdout_logfile=/dev/stdout +stdout_logfile_maxbytes=0 +stderr_logfile=/dev/stderr +stderr_logfile_maxbytes=0 diff --git a/docker/base-app/ubuntu-12.04/conf/etc/supervisor.d/postfix.conf b/docker/base/ubuntu-12.04/conf/etc/supervisor.d/postfix.conf similarity index 100% rename from docker/base-app/ubuntu-12.04/conf/etc/supervisor.d/postfix.conf rename to docker/base/ubuntu-12.04/conf/etc/supervisor.d/postfix.conf diff --git a/docker/base-app/ubuntu-12.04/conf/etc/supervisor.d/ssh.conf b/docker/base/ubuntu-12.04/conf/etc/supervisor.d/ssh.conf similarity index 100% rename from docker/base-app/ubuntu-12.04/conf/etc/supervisor.d/ssh.conf rename to docker/base/ubuntu-12.04/conf/etc/supervisor.d/ssh.conf diff --git a/docker/base/ubuntu-12.04/conf/etc/supervisor.d/syslog-ng.conf b/docker/base/ubuntu-12.04/conf/etc/supervisor.d/syslog-ng.conf deleted file mode 100644 index 247fd1a25..000000000 --- a/docker/base/ubuntu-12.04/conf/etc/supervisor.d/syslog-ng.conf +++ /dev/null @@ -1,13 +0,0 @@ -[group:syslog] -programs=syslogd -priority=10 - -[program:syslogd] -command = /opt/docker/bin/service.d/syslog-ng.sh -process_name=%(program_name)s -autostart = true -autorestart = true -stdout_logfile=/dev/stdout -stdout_logfile_maxbytes=0 -stderr_logfile=/dev/stderr -stderr_logfile_maxbytes=0 diff --git a/docker/base/ubuntu-12.04/conf/etc/supervisor.d/syslog.conf b/docker/base/ubuntu-12.04/conf/etc/supervisor.d/syslog.conf new file mode 100644 index 000000000..20d1e238c --- /dev/null +++ b/docker/base/ubuntu-12.04/conf/etc/supervisor.d/syslog.conf @@ -0,0 +1,13 @@ +[group:syslog] +programs=syslogd +priority=10 + +[program:syslogd] +command = /opt/docker/bin/service.d/syslog-ng.sh +process_name=%(program_name)s +autostart = false +autorestart = true +stdout_logfile=/dev/stdout +stdout_logfile_maxbytes=0 +stderr_logfile=/dev/stderr +stderr_logfile_maxbytes=0 diff --git a/docker/base/ubuntu-12.04/conf/provision/roles/webdevops-base/tasks/bootstrap.yml b/docker/base/ubuntu-12.04/conf/provision/roles/webdevops-base/tasks/bootstrap.yml index 30be03c38..9f842336c 100644 --- a/docker/base/ubuntu-12.04/conf/provision/roles/webdevops-base/tasks/bootstrap.yml +++ b/docker/base/ubuntu-12.04/conf/provision/roles/webdevops-base/tasks/bootstrap.yml @@ -4,6 +4,5 @@ - include: bootstrap/misc.yml - include: bootstrap/root.yml - include: bootstrap/supervisor.yml -- include: bootstrap/syslog-ng.yml -- include: bootstrap/logrotate.yml - include: bootstrap/pam.yml +- include: bootstrap/entrypoint.yml diff --git a/docker/base/ubuntu-12.04/conf/provision/roles/webdevops-base/tasks/bootstrap/entrypoint.yml b/docker/base/ubuntu-12.04/conf/provision/roles/webdevops-base/tasks/bootstrap/entrypoint.yml new file mode 100644 index 000000000..d5d8809f4 --- /dev/null +++ b/docker/base/ubuntu-12.04/conf/provision/roles/webdevops-base/tasks/bootstrap/entrypoint.yml @@ -0,0 +1,8 @@ +--- + +- name: Create link for entrypoint + file: + src: '/opt/docker/bin/entrypoint.sh' + dest: '/entrypoint' + state: link + force: yes diff --git a/docker/base/ubuntu-12.04/conf/provision/roles/webdevops-base/tasks/bootstrap/logrotate.yml b/docker/base/ubuntu-12.04/conf/provision/roles/webdevops-base/tasks/bootstrap/logrotate.yml deleted file mode 100644 index d87926be2..000000000 --- a/docker/base/ubuntu-12.04/conf/provision/roles/webdevops-base/tasks/bootstrap/logrotate.yml +++ /dev/null @@ -1,33 +0,0 @@ ---- - -- name: Configure logrotate running user - lineinfile: - dest: /etc/logrotate.conf - regexp: '^su [-_a-zA-Z0-9]+ [-_a-zA-Z0-9]+' - line: 'su root adm' - -- name: Register logrotate configurations - file: - src: '{{ item }}' - dest: '/etc/logrotate.d/{{ item | basename }}' - state: link - force: yes - with_fileglob: - - /opt/docker/etc/logrotate.d/* - -- name: Remove system logrotates (not needed) - file: - path: '{{ item }}' - state: absent - with_items: - # Debian/Ubuntu - - /etc/cron.daily/logrotate - - /etc/cron.daily/apt-compat - - /etc/cron.daily/dpkg - - /etc/cron.daily/passwd - # RedHat - - /etc/cron.daily/0yum-daily.cron - - /etc/cron.daily/logrotate - - /etc/cron.hourly/0yum-hourly.cron - # Alpine - - /etc/periodic/daily/logrotate diff --git a/docker/base/ubuntu-12.04/conf/provision/roles/webdevops-base/tasks/bootstrap/supervisor.yml b/docker/base/ubuntu-12.04/conf/provision/roles/webdevops-base/tasks/bootstrap/supervisor.yml index bda0394b6..2ce07ac26 100644 --- a/docker/base/ubuntu-12.04/conf/provision/roles/webdevops-base/tasks/bootstrap/supervisor.yml +++ b/docker/base/ubuntu-12.04/conf/provision/roles/webdevops-base/tasks/bootstrap/supervisor.yml @@ -4,3 +4,10 @@ file: path: '/usr/sbin/service' state: absent + +- name: Create link for supervisor.conf + file: + src: '/opt/docker/etc/supervisor.conf' + dest: '/etc/supervisord.conf' + state: link + force: yes diff --git a/docker/base/ubuntu-12.04/conf/provision/roles/webdevops-base/tasks/bootstrap/syslog-ng.yml b/docker/base/ubuntu-12.04/conf/provision/roles/webdevops-base/tasks/bootstrap/syslog-ng.yml deleted file mode 100644 index 27c8f6a30..000000000 --- a/docker/base/ubuntu-12.04/conf/provision/roles/webdevops-base/tasks/bootstrap/syslog-ng.yml +++ /dev/null @@ -1,33 +0,0 @@ ---- - -- name: Get syslog-ng version - shell: "syslog-ng --version | grep -E -e '^syslog-ng[ ]+[0-9]+\\.[0-9]+' | head -n 1 | awk '{print $2}' | cut -f 1,2 -d ." - register: syslogng_version - -- name: Configure syslog-ng (default) - lineinfile: - dest: /etc/default/syslog-ng - regexp: '^[\s]*{{ item.key }}[\s]*=' - line: '{{ item.key }}="{{ item.value }}"' - create: yes - with_items: - - { key: 'SYSLOGNG_OPTS', value: '--no-caps' } - -- name: Enable syslog-ng config - file: - src: '/opt/docker/etc/syslog-ng/syslog-ng.conf' - dest: '/etc/syslog-ng/syslog-ng.conf' - state: link - force: yes - -- name: Set version of syslog-ng file - lineinfile: - dest: '/etc/syslog-ng/syslog-ng.conf' - regexp: '^@version:' - line: '@version: {{ syslogng_version.stdout }}' - -- name: Ensure /var/lib/syslog-ng exists - file: - path: '/var/lib/syslog-ng' - state: directory - recurse: yes diff --git a/docker/base/ubuntu-12.04/conf/provision/roles/webdevops-base/tasks/bootstrap/system.yml b/docker/base/ubuntu-12.04/conf/provision/roles/webdevops-base/tasks/bootstrap/system.yml index 8dfbf9665..0741d7cae 100644 --- a/docker/base/ubuntu-12.04/conf/provision/roles/webdevops-base/tasks/bootstrap/system.yml +++ b/docker/base/ubuntu-12.04/conf/provision/roles/webdevops-base/tasks/bootstrap/system.yml @@ -14,3 +14,20 @@ dest: '/entrypoint.cmd' state: link force: yes + +- name: Remove system logrotate and cronjobs (not needed) + file: + path: '{{ item }}' + state: absent + with_items: + # Debian/Ubuntu + - /etc/cron.daily/logrotate + - /etc/cron.daily/apt-compat + - /etc/cron.daily/dpkg + - /etc/cron.daily/passwd + # RedHat + - /etc/cron.daily/0yum-daily.cron + - /etc/cron.daily/logrotate + - /etc/cron.hourly/0yum-hourly.cron + # Alpine + - /etc/periodic/daily/logrotate diff --git a/docker/php-apache/alpine-3/conf/etc/httpd/vhost.common.d/.gitkeep b/docker/base/ubuntu-12.04/conf/provision/roles/webdevops-base/tasks/build/.gitkeep similarity index 100% rename from docker/php-apache/alpine-3/conf/etc/httpd/vhost.common.d/.gitkeep rename to docker/base/ubuntu-12.04/conf/provision/roles/webdevops-base/tasks/build/.gitkeep diff --git a/docker/base/ubuntu-12.04/conf/provision/roles/webdevops-base/tasks/build/logrotate.yml b/docker/base/ubuntu-12.04/conf/provision/roles/webdevops-base/tasks/build/logrotate.yml deleted file mode 100644 index 10f7e6644..000000000 --- a/docker/base/ubuntu-12.04/conf/provision/roles/webdevops-base/tasks/build/logrotate.yml +++ /dev/null @@ -1,10 +0,0 @@ ---- - -- name: Register logrotate configurations - file: - src: '{{ item }}' - dest: '/etc/logrotate.d/{{ item | basename }}' - state: link - force: yes - with_fileglob: - - /opt/docker/etc/logrotate.d/* diff --git a/docker/php-nginx-dev/alpine-3-php7/conf/etc/nginx/conf.d/.gitkeep b/docker/base/ubuntu-12.04/conf/provision/service.d/.gitkeep similarity index 100% rename from docker/php-nginx-dev/alpine-3-php7/conf/etc/nginx/conf.d/.gitkeep rename to docker/base/ubuntu-12.04/conf/provision/service.d/.gitkeep diff --git a/docker/base/ubuntu-12.04/conf/provision/service.d/cron.sh b/docker/base/ubuntu-12.04/conf/provision/service.d/cron.sh new file mode 100644 index 000000000..bd8a54781 --- /dev/null +++ b/docker/base/ubuntu-12.04/conf/provision/service.d/cron.sh @@ -0,0 +1,13 @@ +#!/usr/bin/env bash + +IMAGE_FAMILY=$(docker-image-info family) + +case "$IMAGE_FAMILY" in + Debian|Ubuntu) + apt-install cron + ;; + + RedHat) + yum-install cronie + ;; +esac diff --git a/docker/base/ubuntu-12.04/conf/provision/service.d/dnsmasq.sh b/docker/base/ubuntu-12.04/conf/provision/service.d/dnsmasq.sh new file mode 100644 index 000000000..9e5c3228c --- /dev/null +++ b/docker/base/ubuntu-12.04/conf/provision/service.d/dnsmasq.sh @@ -0,0 +1,24 @@ +#!/usr/bin/env bash + +IMAGE_FAMILY=$(docker-image-info family) + +# Installation +case "$IMAGE_FAMILY" in + Debian|Ubuntu) + apt-install dnsmasq + ;; + + RedHat) + yum-install dnsmasq + ;; + + Alpine) + apk-install dnsmasq + ;; +esac + +# Configuration +go-replace --mode=line \ + -s '^[\s]*user[\s]*=' -r 'user = root' \ + -s '^[\s]*conf-dir[\s]*=' -r 'conf-dir = /etc/dnsmasq.d' \ + -- /etc/dnsmasq.conf diff --git a/docker/base/ubuntu-12.04/conf/provision/service.d/postfix.sh b/docker/base/ubuntu-12.04/conf/provision/service.d/postfix.sh new file mode 100644 index 000000000..ff1879345 --- /dev/null +++ b/docker/base/ubuntu-12.04/conf/provision/service.d/postfix.sh @@ -0,0 +1,28 @@ +#!/usr/bin/env bash + +IMAGE_FAMILY=$(docker-image-info family) + +# Installation +case "$IMAGE_FAMILY" in + Debian|Ubuntu) + apt-install postfix + ;; + + RedHat) + yum-install postfix + ;; + + Alpine) + apk-install postfix + ln -s -f /etc/postfix/aliases /etc/aliases + ;; +esac + +# Configuration +go-replace --mode=line \ + -s '^[\s]*mydestination[\s]*=' -r 'mydestination = ' \ + -s '^[\s]*message_size_limit[\s]*=' -r 'message_size_limit = 15240000' \ + -s '^[\s]*smtp_use_tls[\s]*=' -r 'smtp_use_tls = yes' \ + -s '^[\s]*smtp_tls_security_level[\s]*=' -r 'smtp_tls_security_level = may' \ + -s '^[\s]*myhostname[\s]*=' -r '# myhostname' \ + -- /etc/postfix/main.cf diff --git a/docker/base/ubuntu-12.04/conf/provision/service.d/ssh.sh b/docker/base/ubuntu-12.04/conf/provision/service.d/ssh.sh new file mode 100644 index 000000000..63d7a9f3a --- /dev/null +++ b/docker/base/ubuntu-12.04/conf/provision/service.d/ssh.sh @@ -0,0 +1,17 @@ +#!/usr/bin/env bash + +IMAGE_FAMILY=$(docker-image-info family) + +case "$IMAGE_FAMILY" in + Debian|Ubuntu) + apt-install openssh-server + ;; + + RedHat) + yum-install openssh-server + ;; + + Alpine) + apk-install openssh + ;; +esac diff --git a/docker/base/ubuntu-12.04/conf/provision/service.d/syslog.sh b/docker/base/ubuntu-12.04/conf/provision/service.d/syslog.sh new file mode 100644 index 000000000..7e8b8e0a9 --- /dev/null +++ b/docker/base/ubuntu-12.04/conf/provision/service.d/syslog.sh @@ -0,0 +1,41 @@ +#!/usr/bin/env bash + +IMAGE_FAMILY=$(docker-image-info family) + +# Installation +case "$IMAGE_FAMILY" in + Debian|Ubuntu) + apt-install syslog-ng syslog-ng-core + ;; + + RedHat) + yum-install syslog-ng + + # remove logrotate (not needed for docker) + rm -f "/etc/cron.daily/logrotate" + ;; + + Alpine) + apk-install syslog-ng + ;; +esac + +## Configuration +SYSLOG_NG_VERSION=$(syslog-ng --version | grep -E -e '^syslog-ng[ ]+[0-9]+\.[0-9]+' | head -n 1 | awk '{print $2}' | cut -f 1,2 -d .) + +# Disable caps inside container +if [[ -f /etc/default/syslog-ng ]]; then + go-replace --mode=lineinfile \ + -s "SYSLOGNG_OPTS" -r "SYSLOGNG_OPTS = --no-caps" \ + -- /etc/default/syslog-ng +fi + +# Symlink configuration +ln -s -f /opt/docker/etc/syslog-ng/syslog-ng.conf /etc/syslog-ng/syslog-ng.conf + +go-replace --mode=lineinfile \ + -s "@version" -r "@version: ${SYSLOG_NG_VERSION}" \ + -- /etc/syslog-ng/syslog-ng.conf + +# Ensure /var/lib/syslog-ng exists +mkdir -p /var/lib/syslog-ng diff --git a/docker/base/ubuntu-12.04/conf/provision/variables-webdevops.yml b/docker/base/ubuntu-12.04/conf/provision/variables-webdevops.yml new file mode 100644 index 000000000..0b2a21a95 --- /dev/null +++ b/docker/base/ubuntu-12.04/conf/provision/variables-webdevops.yml @@ -0,0 +1,7 @@ +--- + +docker_image_info_family: "{{ lookup('pipe', 'docker-image-info family') }}" +docker_image_info_distribution: "{{ lookup('pipe', 'docker-image-info dist') }}" +docker_image_info_distribution_version: "{{ lookup('pipe', 'docker-image-info dist-version') }}" +docker_image_info_distribution_release: "{{ lookup('pipe', 'docker-image-info dist-release') }}" +docker_image_info_distribution_codename: "{{ lookup('pipe', 'docker-image-info dist-codename') }}" diff --git a/docker/base/ubuntu-12.04/conf/provision/variables.yml b/docker/base/ubuntu-12.04/conf/provision/variables.yml index ed97d539c..0b2a21a95 100644 --- a/docker/base/ubuntu-12.04/conf/provision/variables.yml +++ b/docker/base/ubuntu-12.04/conf/provision/variables.yml @@ -1 +1,7 @@ --- + +docker_image_info_family: "{{ lookup('pipe', 'docker-image-info family') }}" +docker_image_info_distribution: "{{ lookup('pipe', 'docker-image-info dist') }}" +docker_image_info_distribution_version: "{{ lookup('pipe', 'docker-image-info dist-version') }}" +docker_image_info_distribution_release: "{{ lookup('pipe', 'docker-image-info dist-release') }}" +docker_image_info_distribution_codename: "{{ lookup('pipe', 'docker-image-info dist-codename') }}" diff --git a/docker/base/ubuntu-14.04/Dockerfile b/docker/base/ubuntu-14.04/Dockerfile index 2f116aaef..0c862bb5c 100644 --- a/docker/base/ubuntu-14.04/Dockerfile +++ b/docker/base/ubuntu-14.04/Dockerfile @@ -5,31 +5,47 @@ FROM webdevops/bootstrap:ubuntu-14.04 -MAINTAINER info@webdevops.io -LABEL vendor=WebDevOps.io -LABEL io.webdevops.layout=8 -LABEL io.webdevops.version=1.5.0 - -ENV DOCKER_CONF_HOME /opt/docker/ +ENV DOCKER_CONF_HOME=/opt/docker/ \ + LOG_STDOUT="" \ + LOG_STDERR="" COPY conf/ /opt/docker/ +# Install ansible +RUN /usr/local/bin/apt-install \ + python-minimal \ + python-setuptools \ + python-pip \ + python-paramiko \ + python-jinja2 \ + python-dev \ + libffi-dev \ + libssl-dev \ + build-essential \ + && pip install --upgrade pip \ + && hash -r \ + && pip install --no-cache-dir ansible \ + && chmod 750 /usr/local/bin/ansible* \ + # Cleanup + && apt-get purge -y -f --force-yes \ + python-dev \ + build-essential \ + libssl-dev \ + libffi-dev \ + && docker-image-cleanup + # Install services RUN chmod +x /opt/docker/bin/* \ && /usr/local/bin/apt-install \ supervisor \ - syslog-ng \ - syslog-ng-core \ - logrotate \ - cron \ wget \ curl \ net-tools \ gnupg \ && chmod +s /usr/local/bin/gosu \ && /opt/docker/bin/provision run --tag bootstrap --role webdevops-base \ - && /opt/docker/bin/bootstrap.sh - + && /opt/docker/bin/bootstrap.sh \ + && docker-image-cleanup ENTRYPOINT ["/opt/docker/bin/entrypoint.sh"] CMD ["supervisord"] diff --git a/docker/base/ubuntu-14.04/Dockerfile.jinja2 b/docker/base/ubuntu-14.04/Dockerfile.jinja2 index 88a50dc97..1af91a9d0 100644 --- a/docker/base/ubuntu-14.04/Dockerfile.jinja2 +++ b/docker/base/ubuntu-14.04/Dockerfile.jinja2 @@ -1,11 +1,11 @@ {{ docker.from("bootstrap", "ubuntu-14.04") }} -{{ docker.version() }} - -{{ environment.homePath() }} +{{ environment.base() }} {{ docker.copy('conf/', '/opt/docker/') }} +{{ ansible.ubuntu() }} + {{ base.ubuntu() }} {{ docker.entrypoint("/opt/docker/bin/entrypoint.sh") }} diff --git a/docker/base/ubuntu-14.04/conf/bin/bootstrap.sh b/docker/base/ubuntu-14.04/conf/bin/bootstrap.sh index 1d1a30f72..855c10782 100644 --- a/docker/base/ubuntu-14.04/conf/bin/bootstrap.sh +++ b/docker/base/ubuntu-14.04/conf/bin/bootstrap.sh @@ -17,10 +17,16 @@ rootCheck "$0" # Save the buildtime date +%s > /opt/docker/BUILDTIME +date +%s >/opt/docker/etc/.registry/image_info_buildtime # Make all scripts executable find /opt/docker/bin/ -type f -iname '*.sh' -print0 | xargs --no-run-if-empty -0 chmod +x +# Enable usr-bin executables +find /opt/docker/bin/usr-bin -type f | while read USR_BIN_FILE; do + chmod +x -- "$USR_BIN_FILE" + ln -n -f -- "$USR_BIN_FILE" "/usr/local/bin/$(basename "$USR_BIN_FILE")" +done case "$BOOTSTRAP_MODE" in ################################### @@ -44,6 +50,23 @@ case "$BOOTSTRAP_MODE" in echo "[ERROR] Bootstrap mode '$BOOTSTRAP_MODE' not defined" exit 1 ;; - esac + +###################### +# Check if entrypoint provisioning is available +###################### + +echo "Checking provision status..." +for PROVISION_TAG in onbuild build bootstrap entrypoint; do + ROLES=$(docker-provision list --tag "$PROVISION_TAG") + if [[ -n "$ROLES" ]]; then + PROVISION_ROLE_COUNT=$(echo "$ROLES" | wc -l) + echo " - found ${PROVISION_ROLE_COUNT} for provision tag ${PROVISION_TAG}, caching info for execution" + echo -n "$PROVISION_ROLE_COUNT" > "/opt/docker/etc/.registry/provision-availale.${PROVISION_TAG}" + else + echo " - no roles found for provision tag ${PROVISION_TAG}" + echo -n '' > "/opt/docker/etc/.registry/provision-availale.${PROVISION_TAG}" + fi +done + diff --git a/docker/base/ubuntu-14.04/conf/bin/config.sh b/docker/base/ubuntu-14.04/conf/bin/config.sh index 3155728e8..049756c26 100644 --- a/docker/base/ubuntu-14.04/conf/bin/config.sh +++ b/docker/base/ubuntu-14.04/conf/bin/config.sh @@ -15,44 +15,23 @@ function rootCheck() { } ### - # Create named pipe - # - # $1 -> name of file + # Create /docker.stdout and /docker.stderr # ## -function createNamedPipe() { - rm --force -- "$1" - mknod "$1" p -} - -### - # Escape value for sed usage - # - # $1 -> value - # STDOUT -> escaped value - # - ## -function sedEscape() { - echo "$(echo $* |sed -e 's/[]\/$*.^|[]/\\&/g')" -} +function createDockerStdoutStderr() { + # link stdout from docker + if [[ -z "$LOG_STDOUT" ]]; then + LOG_STDOUT="/proc/$$/fd/1" + fi -### - # Replace text inside a file - # - # $1 -> source value - # $2 -> target value - # $3 -> path to file - # - ## -function replaceTextInFile() { - SOURCE="$(sedEscape $1)" - REPLACE="$(sedEscape $2)" - TARGET="$3" + if [[ -z "$LOG_STDERR" ]]; then + LOG_STDERR="/proc/$$/fd/2" + fi - sed -i "s/${SOURCE}/${REPLACE}/" "${TARGET}" + ln -f -s "$LOG_STDOUT" /docker.stdout + ln -f -s "$LOG_STDERR" /docker.stderr + chmod 600 /docker.stdout /docker.stderr } - - ### # Include script directory text inside a file # @@ -104,7 +83,7 @@ function runEntrypoints() { . /opt/docker/bin/entrypoint.d/default.sh fi - exit + exit 1 } ### @@ -161,6 +140,12 @@ function runProvisionEntrypoint() { function runDockerProvision() { ANSIBLE_TAG="$1" - /opt/docker/bin/provision run --tag "$ANSIBLE_TAG" --use-registry + PROVISION_STATS_FILE="/opt/docker/etc/.registry/provision-stats.${ANSIBLE_TAG}" + + # run provision if stats file doesn't exists (unknown mode) + # or if stats file is not empty + if [[ ! -f "$PROVISION_STATS_FILE" ]] || [[ -s "$PROVISION_STATS_FILE" ]]; then + /opt/docker/bin/provision run --tag "${ANSIBLE_TAG}" --use-registry + fi } diff --git a/docker/base/ubuntu-14.04/conf/bin/control.sh b/docker/base/ubuntu-14.04/conf/bin/control.sh index a6697092d..22d189745 100644 --- a/docker/base/ubuntu-14.04/conf/bin/control.sh +++ b/docker/base/ubuntu-14.04/conf/bin/control.sh @@ -101,23 +101,13 @@ case "$CONTROL_COMMAND" in ## ------------------------------------------ "service.enable") - SERVICE_FILE="/opt/docker/etc/supervisor.d/$1.conf" - if [ -f "$SERVICE_FILE" ]; then - sed -i '/autostart = /c\autostart = true' -- "$SERVICE_FILE" - else - echo "[ERROR] Service '${1}' not found (tried ${SERVICE_FILE})" - exit 1 - fi + deprecationNotice " Please use >>docker-service-enable [service]<<" + docker-service-enable "$1" ;; "service.disable") - SERVICE_FILE="/opt/docker/etc/supervisor.d/$1.conf" - if [ -f "$SERVICE_FILE" ]; then - sed -i '/autostart = /c\autostart = false' -- "$SERVICE_FILE" - else - echo "[ERROR] Service '${1}' not found (tried ${SERVICE_FILE})" - exit 1 - fi + deprecationNotice " Please use >>docker-service-disable [service]<<" + docker-service-disable "$1" ;; ## ------------------------------------------ diff --git a/docker/base/ubuntu-14.04/conf/bin/entrypoint.d/cli.sh b/docker/base/ubuntu-14.04/conf/bin/entrypoint.d/cli.sh index 2ca68926c..fe212a8ea 100644 --- a/docker/base/ubuntu-14.04/conf/bin/entrypoint.d/cli.sh +++ b/docker/base/ubuntu-14.04/conf/bin/entrypoint.d/cli.sh @@ -8,7 +8,7 @@ if [ -n "${CLI_SCRIPT}" ]; then if [ -n "$APPLICATION_USER" ]; then # Run as EFFECTIVE_USER shift - exec sudo -H -E -u "${APPLICATION_USER}" ${CLI_SCRIPT} "$@" + exec gosu "${APPLICATION_USER}" ${CLI_SCRIPT} "$@" else # Run as root exec ${CLI_SCRIPT} "$@" diff --git a/docker/base/ubuntu-14.04/conf/bin/entrypoint.d/noop.sh b/docker/base/ubuntu-14.04/conf/bin/entrypoint.d/noop.sh index 967920837..092d55d8b 100644 --- a/docker/base/ubuntu-14.04/conf/bin/entrypoint.d/noop.sh +++ b/docker/base/ubuntu-14.04/conf/bin/entrypoint.d/noop.sh @@ -4,5 +4,4 @@ ## NOOP (no operation) ############################################# -tail -f /dev/null -exit +exec tail -f /dev/null diff --git a/docker/base/ubuntu-14.04/conf/bin/entrypoint.d/supervisord.sh b/docker/base/ubuntu-14.04/conf/bin/entrypoint.d/supervisord.sh index ead991551..f21489667 100644 --- a/docker/base/ubuntu-14.04/conf/bin/entrypoint.d/supervisord.sh +++ b/docker/base/ubuntu-14.04/conf/bin/entrypoint.d/supervisord.sh @@ -4,8 +4,6 @@ ## Supervisord (start daemons) ############################################# -rootCheck "supervisord" - ## Start services exec /opt/docker/bin/service.d/supervisor.sh diff --git a/docker/base/ubuntu-14.04/conf/bin/entrypoint.sh b/docker/base/ubuntu-14.04/conf/bin/entrypoint.sh index bbabcdddb..01f59660c 100644 --- a/docker/base/ubuntu-14.04/conf/bin/entrypoint.sh +++ b/docker/base/ubuntu-14.04/conf/bin/entrypoint.sh @@ -20,16 +20,13 @@ chmod -s /usr/local/bin/gosu trap 'echo sigterm ; exit' SIGTERM trap 'echo sigkill ; exit' SIGKILL -# link stdout from docker -ln -f -s "/proc/$$/fd/1" /docker.stdout -ln -f -s "/proc/$$/fd/2" /docker.stderr -chmod 600 /docker.stdout /docker.stderr - # sanitize input and set task TASK="$(echo $1| sed 's/[^-_a-zA-Z0-9]*//g')" source /opt/docker/bin/config.sh +createDockerStdoutStderr + if [[ "$UID" -eq 0 ]]; then # Only run provision if user is root diff --git a/docker/base/ubuntu-14.04/conf/bin/logwatch.sh b/docker/base/ubuntu-14.04/conf/bin/logwatch.sh deleted file mode 100644 index 1a5b486c7..000000000 --- a/docker/base/ubuntu-14.04/conf/bin/logwatch.sh +++ /dev/null @@ -1,14 +0,0 @@ -#!/usr/bin/env bash - -set -o pipefail # trace ERR through pipes -set -o errtrace # trace ERR through 'time command' and other functions -set -o nounset ## set -u : exit the script if you try to use an uninitialised variable -set -o errexit ## set -e : exit the script if any statement returns a non-true return value - -sleep 0.5 - -if [ -p "$2" ]; then - sed --unbuffered -e "s/^/\[$1\] /" -- "$2" -else - tail -n 0 -F -q "$2" | sed --unbuffered -e "s/^/\[$1\] /" -fi diff --git a/docker/base/ubuntu-14.04/conf/bin/provision b/docker/base/ubuntu-14.04/conf/bin/provision index f7b5ad0a8..d367c2812 100755 --- a/docker/base/ubuntu-14.04/conf/bin/provision +++ b/docker/base/ubuntu-14.04/conf/bin/provision @@ -19,6 +19,7 @@ PLAYBOOK = Template( - hosts: all vars_files: + - ./variables-webdevops.yml - ./variables.yml roles: - $roles @@ -188,7 +189,7 @@ def actionAdd(args): 'priority': args.priority } - saveJson(json); + saveJson(json) diff --git a/docker/base/ubuntu-14.04/conf/bin/provision.sh b/docker/base/ubuntu-14.04/conf/bin/provision.sh deleted file mode 100644 index 4079dd7f0..000000000 --- a/docker/base/ubuntu-14.04/conf/bin/provision.sh +++ /dev/null @@ -1,30 +0,0 @@ - #!/usr/bin/env bash - -# -# Example: -# provision.sh /opt/foobar/playbook.yml tag -# -# - -set -o pipefail # trace ERR through pipes -set -o errtrace # trace ERR through 'time command' and other functions -set -o nounset ## set -u : exit the script if you try to use an uninitialised variable -set -o errexit ## set -e : exit the script if any statement returns a non-true return value - -. config.sh - -deprecationNotice " Please use >>/opt/docker/bin/provision run --playbook playbook.yml --tag=bootstrap [args]<< for running provision" - - -if [ "$#" -lt 2 ]; then - echo "[ERROR] $0: Playbook or tag is missing" - exit 1 -fi - -ANSIBLE_PLAYBOOK="$1" -shift -ANSIBLE_TAG="$1" -shift -ANSIBLE_OPTS="$@" - -/opt/docker/bin/provision run --playbook "${ANSIBLE_PLAYBOOK}" --use-registry --tag "${ANSIBLE_TAG}" $ANSIBLE_OPTS diff --git a/docker/base-app/ubuntu-14.04/conf/bin/service.d/dnsmasq.d/10-init.sh b/docker/base/ubuntu-14.04/conf/bin/service.d/dnsmasq.d/10-init.sh similarity index 100% rename from docker/base-app/ubuntu-14.04/conf/bin/service.d/dnsmasq.d/10-init.sh rename to docker/base/ubuntu-14.04/conf/bin/service.d/dnsmasq.d/10-init.sh diff --git a/docker/base-app/ubuntu-14.04/conf/bin/service.d/dnsmasq.sh b/docker/base/ubuntu-14.04/conf/bin/service.d/dnsmasq.sh similarity index 100% rename from docker/base-app/ubuntu-14.04/conf/bin/service.d/dnsmasq.sh rename to docker/base/ubuntu-14.04/conf/bin/service.d/dnsmasq.sh diff --git a/docker/base/ubuntu-14.04/conf/bin/service.d/postfix.d/10-init.sh b/docker/base/ubuntu-14.04/conf/bin/service.d/postfix.d/10-init.sh new file mode 100644 index 000000000..cfd876955 --- /dev/null +++ b/docker/base/ubuntu-14.04/conf/bin/service.d/postfix.d/10-init.sh @@ -0,0 +1,27 @@ +# force new copy of hosts there (otherwise links could be outdated) +mkdir -p /var/spool/postfix/etc +cp -f /etc/hosts /var/spool/postfix/etc/hosts +cp -f /etc/resolv.conf /var/spool/postfix/etc/resolv.conf +cp -f /etc/services /var/spool/postfix/etc/services + +## MYHOSTNAME +# replace line +sed -i '/myhostname[ ]* =/c\' main.cf +echo "myhostname = $(hostname)" >> /etc/postfix/main.cf + +## REPLAYHOST +if [[ -n "${POSTFIX_RELAYHOST+x}" ]]; then + # replace line + sed -i '/relayhost[ ]* =/c\' main.cf + echo "relayhost = $POSTFIX_RELAYHOST" >> /etc/postfix/main.cf +fi + +## MYNETWORKS +if [[ -n "${POSTFIX_MYNETWORKS+x}" ]]; then + # replace line + sed -i '/mynetworks[ ]* =/c\' main.cf + echo "mynetworks = $POSTFIX_MYNETWORKS" >> /etc/postfix/main.cf +fi + +# generate aliases db +newaliases || : diff --git a/docker/base-app/ubuntu-14.04/conf/bin/service.d/postfix.sh b/docker/base/ubuntu-14.04/conf/bin/service.d/postfix.sh similarity index 100% rename from docker/base-app/ubuntu-14.04/conf/bin/service.d/postfix.sh rename to docker/base/ubuntu-14.04/conf/bin/service.d/postfix.sh diff --git a/docker/base/ubuntu-14.04/conf/bin/service.d/ssh.d/10-init.sh b/docker/base/ubuntu-14.04/conf/bin/service.d/ssh.d/10-init.sh new file mode 100644 index 000000000..f2b600312 --- /dev/null +++ b/docker/base/ubuntu-14.04/conf/bin/service.d/ssh.d/10-init.sh @@ -0,0 +1,7 @@ +# Init ssh privilege separation directory +mkdir -p /var/run/sshd +chown root:root /var/run/sshd +chmod 755 /var/run/sshd + +# generate host keys +ssh-keygen -A diff --git a/docker/base-app/ubuntu-14.04/conf/bin/service.d/ssh.sh b/docker/base/ubuntu-14.04/conf/bin/service.d/ssh.sh similarity index 100% rename from docker/base-app/ubuntu-14.04/conf/bin/service.d/ssh.sh rename to docker/base/ubuntu-14.04/conf/bin/service.d/ssh.sh diff --git a/docker/base/ubuntu-14.04/conf/bin/service.d/syslog-ng.d/10-init.sh b/docker/base/ubuntu-14.04/conf/bin/service.d/syslog-ng.d/10-init.sh index 22621d2ad..326207e52 100644 --- a/docker/base/ubuntu-14.04/conf/bin/service.d/syslog-ng.d/10-init.sh +++ b/docker/base/ubuntu-14.04/conf/bin/service.d/syslog-ng.d/10-init.sh @@ -6,5 +6,5 @@ if [ ! -S /var/lib/syslog-ng/syslog-ng.ctl ]; then rm -f /var/lib/syslog-ng/sysl if [[ ! -p /docker.stdout ]]; then # Switch to file (tty docker mode) - rpl --quiet 'pipe("/docker.stdout")' 'file("/docker.stdout")' -- /opt/docker/etc/syslog-ng/syslog-ng.conf > /dev/null + go-replace -s 'pipe("/docker.stdout")' -r 'file("/docker.stdout")' -- /opt/docker/etc/syslog-ng/syslog-ng.conf fi diff --git a/docker/base/ubuntu-14.04/conf/bin/usr-bin/docker-provision b/docker/base/ubuntu-14.04/conf/bin/usr-bin/docker-provision new file mode 100644 index 000000000..4ee715c64 --- /dev/null +++ b/docker/base/ubuntu-14.04/conf/bin/usr-bin/docker-provision @@ -0,0 +1,9 @@ +#!/usr/bin/env bash + +set -o pipefail # trace ERR through pipes +set -o errtrace # trace ERR through 'time command' and other functions +set -o nounset ## set -u : exit the script if you try to use an uninitialised variable +set -o errexit ## set -e : exit the script if any statement returns a non-true return value + +# wrapper +exec /opt/docker/bin/provision "$@" diff --git a/docker/base/ubuntu-14.04/conf/bin/usr-bin/docker-service-disable b/docker/base/ubuntu-14.04/conf/bin/usr-bin/docker-service-disable new file mode 100644 index 000000000..2b5b31bb4 --- /dev/null +++ b/docker/base/ubuntu-14.04/conf/bin/usr-bin/docker-service-disable @@ -0,0 +1,30 @@ +#!/usr/bin/env bash + +set -o pipefail # trace ERR through pipes +set -o errtrace # trace ERR through 'time command' and other functions +set -o nounset ## set -u : exit the script if you try to use an uninitialised variable +set -o errexit ## set -e : exit the script if any statement returns a non-true return value + +source /opt/docker/bin/config.sh + +rootCheck "$0" + +if [[ "$#" -eq 0 ]]; then + echo "Usage: $0 " + exit 1 +fi + +for SERVICE in "$@"; do + SERVICE_FILE="/opt/docker/etc/supervisor.d/${SERVICE}.conf" + + ## Disable service + if [[ -f "$SERVICE_FILE" ]]; then + go-replace --mode=lineinfile \ + -s 'autostart =' -r 'autostart = false' \ + -- "$SERVICE_FILE" + else + echo "[ERROR] Service '${SERVICE}' not found (tried ${SERVICE_FILE})" + exit 1 + fi +done + diff --git a/docker/base/ubuntu-14.04/conf/bin/usr-bin/docker-service-enable b/docker/base/ubuntu-14.04/conf/bin/usr-bin/docker-service-enable new file mode 100644 index 000000000..8d36a14a9 --- /dev/null +++ b/docker/base/ubuntu-14.04/conf/bin/usr-bin/docker-service-enable @@ -0,0 +1,41 @@ +#!/usr/bin/env bash + +set -o pipefail # trace ERR through pipes +set -o errtrace # trace ERR through 'time command' and other functions +set -o nounset ## set -u : exit the script if you try to use an uninitialised variable +set -o errexit ## set -e : exit the script if any statement returns a non-true return value + +source /opt/docker/bin/config.sh + +rootCheck "$0" + +if [[ "$#" -eq 0 ]]; then + echo "Usage: $0 " + exit 1 +fi + +for SERVICE in "$@"; do + SERVICE_FILE="/opt/docker/etc/supervisor.d/${SERVICE}.conf" + PROVISION_FILE="/opt/docker/provision/service.d/${SERVICE}.sh" + + # Run on demand installation/provisioning + if [[ -f "$PROVISION_FILE" ]]; then + echo "Running provisioning for ${SERVICE}, please wait..." + + ## execute scripts + . "$PROVISION_FILE" + + ## remove directory (one run time) + rm -f -- "$PROVISION_FILE" + fi + + ## Enable service + if [[ -f "$SERVICE_FILE" ]]; then + go-replace --mode=lineinfile \ + -s 'autostart =' -r 'autostart = true' \ + -- "$SERVICE_FILE" + else + echo "[ERROR] Service '${SERVICE}' not found (tried ${SERVICE_FILE})" + exit 1 + fi +done diff --git a/docker/base/ubuntu-14.04/conf/bin/usr-bin/service b/docker/base/ubuntu-14.04/conf/bin/usr-bin/service new file mode 100755 index 000000000..55ea12bf7 --- /dev/null +++ b/docker/base/ubuntu-14.04/conf/bin/usr-bin/service @@ -0,0 +1,86 @@ +#!/bin/bash + +set -o pipefail # trace ERR through pipes +set -o errtrace # trace ERR through 'time command' and other functions +set -o nounset ## set -u : exit the script if you try to use an uninitialised variable +set -o errexit ## set -e : exit the script if any statement returns a non-true return value + +# Root check +if [ "$(/usr/bin/whoami)" != "root" ]; then + echo "[ERROR] Must be run as root" + exit 1 +fi + +function serviceHelp() { + echo "Usage: $(basename "$0") " +} + +function getServicePid() { + local serviceName="$1" + local servicePid=$(supervisorctl pid "${serviceName}:${serviceName}d") + + if [[ -z "$servicePid" ]] || [[ "$servicePid" == "0" ]]; then + echo "not running" + exit 1 + fi + + echo $servicePid +} + +# Param check +if [ "$#" -lt 2 ]; then + echo "[ERROR] Missing parameters" + serviceHelp + exit 1 +fi + +############################# +# Param init +############################# + +SERVICENAME="$1" +ACTION="$2" + +############################# +# Service aliases +############################# +case "$SERVICENAME" in + apache2|httpd) + SERVICENAME="apache" + ;; +esac + +############################# +# Action runner +############################# +case "$ACTION" in + stop|start|restart|status) + exec supervisorctl "$ACTION" "${SERVICENAME}:${SERVICENAME}d" + ;; + + pid) + echo $(getServicePid "${SERVICENAME}") + ;; + + check) + FIRST_PID=$(getServicePid "${SERVICENAME}") + sleep 5 + SECOND_PID=$(getServicePid "${SERVICENAME}") + + if [[ "$FIRST_PID" == "$SECOND_PID" ]]; then + echo "ok" + exit 0 + else + echo "not running" + exit 1 + fi + ;; + + + *) + echo "[ERROR] Invalid action" + serviceHelp + exit 1 + ;; + +esac diff --git a/docker/base/ubuntu-14.04/conf/etc/supervisor.conf b/docker/base/ubuntu-14.04/conf/etc/supervisor.conf index 7c109515a..479e0db08 100644 --- a/docker/base/ubuntu-14.04/conf/etc/supervisor.conf +++ b/docker/base/ubuntu-14.04/conf/etc/supervisor.conf @@ -2,9 +2,16 @@ nodaemon=true [unix_http_server] -file = /var/run/supervisor.sock -# username = root -# password = {SHA}e982f17bcbe0f724063b708a4f76db211a999304 +file = /.supervisor.sock +chmod = 0700 +chown = root:root +username = root +password = {SHA}e982f17bcbe0f724063b708a4f76db211a999304 + +[supervisorctl] +serverurl = unix:///.supervisor.sock +username = root +password = docker [rpcinterface:supervisor] supervisor.rpcinterface_factory = supervisor.rpcinterface:make_main_rpcinterface diff --git a/docker/base/ubuntu-14.04/conf/etc/supervisor.d/dnsmasq.conf b/docker/base/ubuntu-14.04/conf/etc/supervisor.d/dnsmasq.conf new file mode 100644 index 000000000..9832ffca7 --- /dev/null +++ b/docker/base/ubuntu-14.04/conf/etc/supervisor.d/dnsmasq.conf @@ -0,0 +1,14 @@ +[group:dnsmasq] +programs=dnsmasqd +priority=15 + +[program:dnsmasqd] +command = /opt/docker/bin/service.d/dnsmasq.sh +process_name=%(program_name)s +startsecs = 0 +autostart = false +autorestart = true +stdout_logfile=/dev/stdout +stdout_logfile_maxbytes=0 +stderr_logfile=/dev/stderr +stderr_logfile_maxbytes=0 diff --git a/docker/base-app/ubuntu-14.04/conf/etc/supervisor.d/postfix.conf b/docker/base/ubuntu-14.04/conf/etc/supervisor.d/postfix.conf similarity index 100% rename from docker/base-app/ubuntu-14.04/conf/etc/supervisor.d/postfix.conf rename to docker/base/ubuntu-14.04/conf/etc/supervisor.d/postfix.conf diff --git a/docker/base-app/ubuntu-14.04/conf/etc/supervisor.d/ssh.conf b/docker/base/ubuntu-14.04/conf/etc/supervisor.d/ssh.conf similarity index 100% rename from docker/base-app/ubuntu-14.04/conf/etc/supervisor.d/ssh.conf rename to docker/base/ubuntu-14.04/conf/etc/supervisor.d/ssh.conf diff --git a/docker/base/ubuntu-14.04/conf/etc/supervisor.d/syslog-ng.conf b/docker/base/ubuntu-14.04/conf/etc/supervisor.d/syslog-ng.conf deleted file mode 100644 index 247fd1a25..000000000 --- a/docker/base/ubuntu-14.04/conf/etc/supervisor.d/syslog-ng.conf +++ /dev/null @@ -1,13 +0,0 @@ -[group:syslog] -programs=syslogd -priority=10 - -[program:syslogd] -command = /opt/docker/bin/service.d/syslog-ng.sh -process_name=%(program_name)s -autostart = true -autorestart = true -stdout_logfile=/dev/stdout -stdout_logfile_maxbytes=0 -stderr_logfile=/dev/stderr -stderr_logfile_maxbytes=0 diff --git a/docker/base/ubuntu-14.04/conf/etc/supervisor.d/syslog.conf b/docker/base/ubuntu-14.04/conf/etc/supervisor.d/syslog.conf new file mode 100644 index 000000000..20d1e238c --- /dev/null +++ b/docker/base/ubuntu-14.04/conf/etc/supervisor.d/syslog.conf @@ -0,0 +1,13 @@ +[group:syslog] +programs=syslogd +priority=10 + +[program:syslogd] +command = /opt/docker/bin/service.d/syslog-ng.sh +process_name=%(program_name)s +autostart = false +autorestart = true +stdout_logfile=/dev/stdout +stdout_logfile_maxbytes=0 +stderr_logfile=/dev/stderr +stderr_logfile_maxbytes=0 diff --git a/docker/base/ubuntu-14.04/conf/provision/roles/webdevops-base/tasks/bootstrap.yml b/docker/base/ubuntu-14.04/conf/provision/roles/webdevops-base/tasks/bootstrap.yml index 30be03c38..9f842336c 100644 --- a/docker/base/ubuntu-14.04/conf/provision/roles/webdevops-base/tasks/bootstrap.yml +++ b/docker/base/ubuntu-14.04/conf/provision/roles/webdevops-base/tasks/bootstrap.yml @@ -4,6 +4,5 @@ - include: bootstrap/misc.yml - include: bootstrap/root.yml - include: bootstrap/supervisor.yml -- include: bootstrap/syslog-ng.yml -- include: bootstrap/logrotate.yml - include: bootstrap/pam.yml +- include: bootstrap/entrypoint.yml diff --git a/docker/base/ubuntu-14.04/conf/provision/roles/webdevops-base/tasks/bootstrap/entrypoint.yml b/docker/base/ubuntu-14.04/conf/provision/roles/webdevops-base/tasks/bootstrap/entrypoint.yml new file mode 100644 index 000000000..d5d8809f4 --- /dev/null +++ b/docker/base/ubuntu-14.04/conf/provision/roles/webdevops-base/tasks/bootstrap/entrypoint.yml @@ -0,0 +1,8 @@ +--- + +- name: Create link for entrypoint + file: + src: '/opt/docker/bin/entrypoint.sh' + dest: '/entrypoint' + state: link + force: yes diff --git a/docker/base/ubuntu-14.04/conf/provision/roles/webdevops-base/tasks/bootstrap/logrotate.yml b/docker/base/ubuntu-14.04/conf/provision/roles/webdevops-base/tasks/bootstrap/logrotate.yml deleted file mode 100644 index d87926be2..000000000 --- a/docker/base/ubuntu-14.04/conf/provision/roles/webdevops-base/tasks/bootstrap/logrotate.yml +++ /dev/null @@ -1,33 +0,0 @@ ---- - -- name: Configure logrotate running user - lineinfile: - dest: /etc/logrotate.conf - regexp: '^su [-_a-zA-Z0-9]+ [-_a-zA-Z0-9]+' - line: 'su root adm' - -- name: Register logrotate configurations - file: - src: '{{ item }}' - dest: '/etc/logrotate.d/{{ item | basename }}' - state: link - force: yes - with_fileglob: - - /opt/docker/etc/logrotate.d/* - -- name: Remove system logrotates (not needed) - file: - path: '{{ item }}' - state: absent - with_items: - # Debian/Ubuntu - - /etc/cron.daily/logrotate - - /etc/cron.daily/apt-compat - - /etc/cron.daily/dpkg - - /etc/cron.daily/passwd - # RedHat - - /etc/cron.daily/0yum-daily.cron - - /etc/cron.daily/logrotate - - /etc/cron.hourly/0yum-hourly.cron - # Alpine - - /etc/periodic/daily/logrotate diff --git a/docker/base/ubuntu-14.04/conf/provision/roles/webdevops-base/tasks/bootstrap/supervisor.yml b/docker/base/ubuntu-14.04/conf/provision/roles/webdevops-base/tasks/bootstrap/supervisor.yml index bda0394b6..2ce07ac26 100644 --- a/docker/base/ubuntu-14.04/conf/provision/roles/webdevops-base/tasks/bootstrap/supervisor.yml +++ b/docker/base/ubuntu-14.04/conf/provision/roles/webdevops-base/tasks/bootstrap/supervisor.yml @@ -4,3 +4,10 @@ file: path: '/usr/sbin/service' state: absent + +- name: Create link for supervisor.conf + file: + src: '/opt/docker/etc/supervisor.conf' + dest: '/etc/supervisord.conf' + state: link + force: yes diff --git a/docker/base/ubuntu-14.04/conf/provision/roles/webdevops-base/tasks/bootstrap/syslog-ng.yml b/docker/base/ubuntu-14.04/conf/provision/roles/webdevops-base/tasks/bootstrap/syslog-ng.yml deleted file mode 100644 index 27c8f6a30..000000000 --- a/docker/base/ubuntu-14.04/conf/provision/roles/webdevops-base/tasks/bootstrap/syslog-ng.yml +++ /dev/null @@ -1,33 +0,0 @@ ---- - -- name: Get syslog-ng version - shell: "syslog-ng --version | grep -E -e '^syslog-ng[ ]+[0-9]+\\.[0-9]+' | head -n 1 | awk '{print $2}' | cut -f 1,2 -d ." - register: syslogng_version - -- name: Configure syslog-ng (default) - lineinfile: - dest: /etc/default/syslog-ng - regexp: '^[\s]*{{ item.key }}[\s]*=' - line: '{{ item.key }}="{{ item.value }}"' - create: yes - with_items: - - { key: 'SYSLOGNG_OPTS', value: '--no-caps' } - -- name: Enable syslog-ng config - file: - src: '/opt/docker/etc/syslog-ng/syslog-ng.conf' - dest: '/etc/syslog-ng/syslog-ng.conf' - state: link - force: yes - -- name: Set version of syslog-ng file - lineinfile: - dest: '/etc/syslog-ng/syslog-ng.conf' - regexp: '^@version:' - line: '@version: {{ syslogng_version.stdout }}' - -- name: Ensure /var/lib/syslog-ng exists - file: - path: '/var/lib/syslog-ng' - state: directory - recurse: yes diff --git a/docker/base/ubuntu-14.04/conf/provision/roles/webdevops-base/tasks/bootstrap/system.yml b/docker/base/ubuntu-14.04/conf/provision/roles/webdevops-base/tasks/bootstrap/system.yml index 8dfbf9665..0741d7cae 100644 --- a/docker/base/ubuntu-14.04/conf/provision/roles/webdevops-base/tasks/bootstrap/system.yml +++ b/docker/base/ubuntu-14.04/conf/provision/roles/webdevops-base/tasks/bootstrap/system.yml @@ -14,3 +14,20 @@ dest: '/entrypoint.cmd' state: link force: yes + +- name: Remove system logrotate and cronjobs (not needed) + file: + path: '{{ item }}' + state: absent + with_items: + # Debian/Ubuntu + - /etc/cron.daily/logrotate + - /etc/cron.daily/apt-compat + - /etc/cron.daily/dpkg + - /etc/cron.daily/passwd + # RedHat + - /etc/cron.daily/0yum-daily.cron + - /etc/cron.daily/logrotate + - /etc/cron.hourly/0yum-hourly.cron + # Alpine + - /etc/periodic/daily/logrotate diff --git a/docker/php-nginx-dev/alpine-3-php7/conf/etc/nginx/vhost.common.d/.gitkeep b/docker/base/ubuntu-14.04/conf/provision/roles/webdevops-base/tasks/build/.gitkeep similarity index 100% rename from docker/php-nginx-dev/alpine-3-php7/conf/etc/nginx/vhost.common.d/.gitkeep rename to docker/base/ubuntu-14.04/conf/provision/roles/webdevops-base/tasks/build/.gitkeep diff --git a/docker/base/ubuntu-14.04/conf/provision/roles/webdevops-base/tasks/build/logrotate.yml b/docker/base/ubuntu-14.04/conf/provision/roles/webdevops-base/tasks/build/logrotate.yml deleted file mode 100644 index 10f7e6644..000000000 --- a/docker/base/ubuntu-14.04/conf/provision/roles/webdevops-base/tasks/build/logrotate.yml +++ /dev/null @@ -1,10 +0,0 @@ ---- - -- name: Register logrotate configurations - file: - src: '{{ item }}' - dest: '/etc/logrotate.d/{{ item | basename }}' - state: link - force: yes - with_fileglob: - - /opt/docker/etc/logrotate.d/* diff --git a/docker/php-nginx-dev/alpine-3/conf/etc/nginx/conf.d/.gitkeep b/docker/base/ubuntu-14.04/conf/provision/service.d/.gitkeep similarity index 100% rename from docker/php-nginx-dev/alpine-3/conf/etc/nginx/conf.d/.gitkeep rename to docker/base/ubuntu-14.04/conf/provision/service.d/.gitkeep diff --git a/docker/base/ubuntu-14.04/conf/provision/service.d/cron.sh b/docker/base/ubuntu-14.04/conf/provision/service.d/cron.sh new file mode 100644 index 000000000..bd8a54781 --- /dev/null +++ b/docker/base/ubuntu-14.04/conf/provision/service.d/cron.sh @@ -0,0 +1,13 @@ +#!/usr/bin/env bash + +IMAGE_FAMILY=$(docker-image-info family) + +case "$IMAGE_FAMILY" in + Debian|Ubuntu) + apt-install cron + ;; + + RedHat) + yum-install cronie + ;; +esac diff --git a/docker/base/ubuntu-14.04/conf/provision/service.d/dnsmasq.sh b/docker/base/ubuntu-14.04/conf/provision/service.d/dnsmasq.sh new file mode 100644 index 000000000..9e5c3228c --- /dev/null +++ b/docker/base/ubuntu-14.04/conf/provision/service.d/dnsmasq.sh @@ -0,0 +1,24 @@ +#!/usr/bin/env bash + +IMAGE_FAMILY=$(docker-image-info family) + +# Installation +case "$IMAGE_FAMILY" in + Debian|Ubuntu) + apt-install dnsmasq + ;; + + RedHat) + yum-install dnsmasq + ;; + + Alpine) + apk-install dnsmasq + ;; +esac + +# Configuration +go-replace --mode=line \ + -s '^[\s]*user[\s]*=' -r 'user = root' \ + -s '^[\s]*conf-dir[\s]*=' -r 'conf-dir = /etc/dnsmasq.d' \ + -- /etc/dnsmasq.conf diff --git a/docker/base/ubuntu-14.04/conf/provision/service.d/postfix.sh b/docker/base/ubuntu-14.04/conf/provision/service.d/postfix.sh new file mode 100644 index 000000000..ff1879345 --- /dev/null +++ b/docker/base/ubuntu-14.04/conf/provision/service.d/postfix.sh @@ -0,0 +1,28 @@ +#!/usr/bin/env bash + +IMAGE_FAMILY=$(docker-image-info family) + +# Installation +case "$IMAGE_FAMILY" in + Debian|Ubuntu) + apt-install postfix + ;; + + RedHat) + yum-install postfix + ;; + + Alpine) + apk-install postfix + ln -s -f /etc/postfix/aliases /etc/aliases + ;; +esac + +# Configuration +go-replace --mode=line \ + -s '^[\s]*mydestination[\s]*=' -r 'mydestination = ' \ + -s '^[\s]*message_size_limit[\s]*=' -r 'message_size_limit = 15240000' \ + -s '^[\s]*smtp_use_tls[\s]*=' -r 'smtp_use_tls = yes' \ + -s '^[\s]*smtp_tls_security_level[\s]*=' -r 'smtp_tls_security_level = may' \ + -s '^[\s]*myhostname[\s]*=' -r '# myhostname' \ + -- /etc/postfix/main.cf diff --git a/docker/base/ubuntu-14.04/conf/provision/service.d/ssh.sh b/docker/base/ubuntu-14.04/conf/provision/service.d/ssh.sh new file mode 100644 index 000000000..63d7a9f3a --- /dev/null +++ b/docker/base/ubuntu-14.04/conf/provision/service.d/ssh.sh @@ -0,0 +1,17 @@ +#!/usr/bin/env bash + +IMAGE_FAMILY=$(docker-image-info family) + +case "$IMAGE_FAMILY" in + Debian|Ubuntu) + apt-install openssh-server + ;; + + RedHat) + yum-install openssh-server + ;; + + Alpine) + apk-install openssh + ;; +esac diff --git a/docker/base/ubuntu-14.04/conf/provision/service.d/syslog.sh b/docker/base/ubuntu-14.04/conf/provision/service.d/syslog.sh new file mode 100644 index 000000000..7e8b8e0a9 --- /dev/null +++ b/docker/base/ubuntu-14.04/conf/provision/service.d/syslog.sh @@ -0,0 +1,41 @@ +#!/usr/bin/env bash + +IMAGE_FAMILY=$(docker-image-info family) + +# Installation +case "$IMAGE_FAMILY" in + Debian|Ubuntu) + apt-install syslog-ng syslog-ng-core + ;; + + RedHat) + yum-install syslog-ng + + # remove logrotate (not needed for docker) + rm -f "/etc/cron.daily/logrotate" + ;; + + Alpine) + apk-install syslog-ng + ;; +esac + +## Configuration +SYSLOG_NG_VERSION=$(syslog-ng --version | grep -E -e '^syslog-ng[ ]+[0-9]+\.[0-9]+' | head -n 1 | awk '{print $2}' | cut -f 1,2 -d .) + +# Disable caps inside container +if [[ -f /etc/default/syslog-ng ]]; then + go-replace --mode=lineinfile \ + -s "SYSLOGNG_OPTS" -r "SYSLOGNG_OPTS = --no-caps" \ + -- /etc/default/syslog-ng +fi + +# Symlink configuration +ln -s -f /opt/docker/etc/syslog-ng/syslog-ng.conf /etc/syslog-ng/syslog-ng.conf + +go-replace --mode=lineinfile \ + -s "@version" -r "@version: ${SYSLOG_NG_VERSION}" \ + -- /etc/syslog-ng/syslog-ng.conf + +# Ensure /var/lib/syslog-ng exists +mkdir -p /var/lib/syslog-ng diff --git a/docker/base/ubuntu-14.04/conf/provision/variables-webdevops.yml b/docker/base/ubuntu-14.04/conf/provision/variables-webdevops.yml new file mode 100644 index 000000000..0b2a21a95 --- /dev/null +++ b/docker/base/ubuntu-14.04/conf/provision/variables-webdevops.yml @@ -0,0 +1,7 @@ +--- + +docker_image_info_family: "{{ lookup('pipe', 'docker-image-info family') }}" +docker_image_info_distribution: "{{ lookup('pipe', 'docker-image-info dist') }}" +docker_image_info_distribution_version: "{{ lookup('pipe', 'docker-image-info dist-version') }}" +docker_image_info_distribution_release: "{{ lookup('pipe', 'docker-image-info dist-release') }}" +docker_image_info_distribution_codename: "{{ lookup('pipe', 'docker-image-info dist-codename') }}" diff --git a/docker/base/ubuntu-14.04/conf/provision/variables.yml b/docker/base/ubuntu-14.04/conf/provision/variables.yml index ed97d539c..0b2a21a95 100644 --- a/docker/base/ubuntu-14.04/conf/provision/variables.yml +++ b/docker/base/ubuntu-14.04/conf/provision/variables.yml @@ -1 +1,7 @@ --- + +docker_image_info_family: "{{ lookup('pipe', 'docker-image-info family') }}" +docker_image_info_distribution: "{{ lookup('pipe', 'docker-image-info dist') }}" +docker_image_info_distribution_version: "{{ lookup('pipe', 'docker-image-info dist-version') }}" +docker_image_info_distribution_release: "{{ lookup('pipe', 'docker-image-info dist-release') }}" +docker_image_info_distribution_codename: "{{ lookup('pipe', 'docker-image-info dist-codename') }}" diff --git a/docker/base/ubuntu-15.04/Dockerfile b/docker/base/ubuntu-15.04/Dockerfile index 4f2bc9d4e..7c778f671 100644 --- a/docker/base/ubuntu-15.04/Dockerfile +++ b/docker/base/ubuntu-15.04/Dockerfile @@ -5,31 +5,47 @@ FROM webdevops/bootstrap:ubuntu-15.04 -MAINTAINER info@webdevops.io -LABEL vendor=WebDevOps.io -LABEL io.webdevops.layout=8 -LABEL io.webdevops.version=1.5.0 - -ENV DOCKER_CONF_HOME /opt/docker/ +ENV DOCKER_CONF_HOME=/opt/docker/ \ + LOG_STDOUT="" \ + LOG_STDERR="" COPY conf/ /opt/docker/ +# Install ansible +RUN /usr/local/bin/apt-install \ + python-minimal \ + python-setuptools \ + python-pip \ + python-paramiko \ + python-jinja2 \ + python-dev \ + libffi-dev \ + libssl-dev \ + build-essential \ + && pip install --upgrade pip \ + && hash -r \ + && pip install --no-cache-dir ansible \ + && chmod 750 /usr/local/bin/ansible* \ + # Cleanup + && apt-get purge -y -f --force-yes \ + python-dev \ + build-essential \ + libssl-dev \ + libffi-dev \ + && docker-image-cleanup + # Install services RUN chmod +x /opt/docker/bin/* \ && /usr/local/bin/apt-install \ supervisor \ - syslog-ng \ - syslog-ng-core \ - logrotate \ - cron \ wget \ curl \ net-tools \ gnupg \ && chmod +s /usr/local/bin/gosu \ && /opt/docker/bin/provision run --tag bootstrap --role webdevops-base \ - && /opt/docker/bin/bootstrap.sh - + && /opt/docker/bin/bootstrap.sh \ + && docker-image-cleanup ENTRYPOINT ["/opt/docker/bin/entrypoint.sh"] CMD ["supervisord"] diff --git a/docker/base/ubuntu-15.04/Dockerfile.jinja2 b/docker/base/ubuntu-15.04/Dockerfile.jinja2 index 076c9fe10..72d259e83 100644 --- a/docker/base/ubuntu-15.04/Dockerfile.jinja2 +++ b/docker/base/ubuntu-15.04/Dockerfile.jinja2 @@ -1,11 +1,11 @@ {{ docker.from("bootstrap", "ubuntu-15.04") }} -{{ docker.version() }} - -{{ environment.homePath() }} +{{ environment.base() }} {{ docker.copy('conf/', '/opt/docker/') }} +{{ ansible.ubuntu() }} + {{ base.ubuntu() }} {{ docker.entrypoint("/opt/docker/bin/entrypoint.sh") }} diff --git a/docker/base/ubuntu-15.04/conf/bin/bootstrap.sh b/docker/base/ubuntu-15.04/conf/bin/bootstrap.sh index 1d1a30f72..855c10782 100644 --- a/docker/base/ubuntu-15.04/conf/bin/bootstrap.sh +++ b/docker/base/ubuntu-15.04/conf/bin/bootstrap.sh @@ -17,10 +17,16 @@ rootCheck "$0" # Save the buildtime date +%s > /opt/docker/BUILDTIME +date +%s >/opt/docker/etc/.registry/image_info_buildtime # Make all scripts executable find /opt/docker/bin/ -type f -iname '*.sh' -print0 | xargs --no-run-if-empty -0 chmod +x +# Enable usr-bin executables +find /opt/docker/bin/usr-bin -type f | while read USR_BIN_FILE; do + chmod +x -- "$USR_BIN_FILE" + ln -n -f -- "$USR_BIN_FILE" "/usr/local/bin/$(basename "$USR_BIN_FILE")" +done case "$BOOTSTRAP_MODE" in ################################### @@ -44,6 +50,23 @@ case "$BOOTSTRAP_MODE" in echo "[ERROR] Bootstrap mode '$BOOTSTRAP_MODE' not defined" exit 1 ;; - esac + +###################### +# Check if entrypoint provisioning is available +###################### + +echo "Checking provision status..." +for PROVISION_TAG in onbuild build bootstrap entrypoint; do + ROLES=$(docker-provision list --tag "$PROVISION_TAG") + if [[ -n "$ROLES" ]]; then + PROVISION_ROLE_COUNT=$(echo "$ROLES" | wc -l) + echo " - found ${PROVISION_ROLE_COUNT} for provision tag ${PROVISION_TAG}, caching info for execution" + echo -n "$PROVISION_ROLE_COUNT" > "/opt/docker/etc/.registry/provision-availale.${PROVISION_TAG}" + else + echo " - no roles found for provision tag ${PROVISION_TAG}" + echo -n '' > "/opt/docker/etc/.registry/provision-availale.${PROVISION_TAG}" + fi +done + diff --git a/docker/base/ubuntu-15.04/conf/bin/config.sh b/docker/base/ubuntu-15.04/conf/bin/config.sh index 3155728e8..049756c26 100644 --- a/docker/base/ubuntu-15.04/conf/bin/config.sh +++ b/docker/base/ubuntu-15.04/conf/bin/config.sh @@ -15,44 +15,23 @@ function rootCheck() { } ### - # Create named pipe - # - # $1 -> name of file + # Create /docker.stdout and /docker.stderr # ## -function createNamedPipe() { - rm --force -- "$1" - mknod "$1" p -} - -### - # Escape value for sed usage - # - # $1 -> value - # STDOUT -> escaped value - # - ## -function sedEscape() { - echo "$(echo $* |sed -e 's/[]\/$*.^|[]/\\&/g')" -} +function createDockerStdoutStderr() { + # link stdout from docker + if [[ -z "$LOG_STDOUT" ]]; then + LOG_STDOUT="/proc/$$/fd/1" + fi -### - # Replace text inside a file - # - # $1 -> source value - # $2 -> target value - # $3 -> path to file - # - ## -function replaceTextInFile() { - SOURCE="$(sedEscape $1)" - REPLACE="$(sedEscape $2)" - TARGET="$3" + if [[ -z "$LOG_STDERR" ]]; then + LOG_STDERR="/proc/$$/fd/2" + fi - sed -i "s/${SOURCE}/${REPLACE}/" "${TARGET}" + ln -f -s "$LOG_STDOUT" /docker.stdout + ln -f -s "$LOG_STDERR" /docker.stderr + chmod 600 /docker.stdout /docker.stderr } - - ### # Include script directory text inside a file # @@ -104,7 +83,7 @@ function runEntrypoints() { . /opt/docker/bin/entrypoint.d/default.sh fi - exit + exit 1 } ### @@ -161,6 +140,12 @@ function runProvisionEntrypoint() { function runDockerProvision() { ANSIBLE_TAG="$1" - /opt/docker/bin/provision run --tag "$ANSIBLE_TAG" --use-registry + PROVISION_STATS_FILE="/opt/docker/etc/.registry/provision-stats.${ANSIBLE_TAG}" + + # run provision if stats file doesn't exists (unknown mode) + # or if stats file is not empty + if [[ ! -f "$PROVISION_STATS_FILE" ]] || [[ -s "$PROVISION_STATS_FILE" ]]; then + /opt/docker/bin/provision run --tag "${ANSIBLE_TAG}" --use-registry + fi } diff --git a/docker/base/ubuntu-15.04/conf/bin/control.sh b/docker/base/ubuntu-15.04/conf/bin/control.sh index a6697092d..22d189745 100644 --- a/docker/base/ubuntu-15.04/conf/bin/control.sh +++ b/docker/base/ubuntu-15.04/conf/bin/control.sh @@ -101,23 +101,13 @@ case "$CONTROL_COMMAND" in ## ------------------------------------------ "service.enable") - SERVICE_FILE="/opt/docker/etc/supervisor.d/$1.conf" - if [ -f "$SERVICE_FILE" ]; then - sed -i '/autostart = /c\autostart = true' -- "$SERVICE_FILE" - else - echo "[ERROR] Service '${1}' not found (tried ${SERVICE_FILE})" - exit 1 - fi + deprecationNotice " Please use >>docker-service-enable [service]<<" + docker-service-enable "$1" ;; "service.disable") - SERVICE_FILE="/opt/docker/etc/supervisor.d/$1.conf" - if [ -f "$SERVICE_FILE" ]; then - sed -i '/autostart = /c\autostart = false' -- "$SERVICE_FILE" - else - echo "[ERROR] Service '${1}' not found (tried ${SERVICE_FILE})" - exit 1 - fi + deprecationNotice " Please use >>docker-service-disable [service]<<" + docker-service-disable "$1" ;; ## ------------------------------------------ diff --git a/docker/base/ubuntu-15.04/conf/bin/entrypoint.d/cli.sh b/docker/base/ubuntu-15.04/conf/bin/entrypoint.d/cli.sh index 2ca68926c..fe212a8ea 100644 --- a/docker/base/ubuntu-15.04/conf/bin/entrypoint.d/cli.sh +++ b/docker/base/ubuntu-15.04/conf/bin/entrypoint.d/cli.sh @@ -8,7 +8,7 @@ if [ -n "${CLI_SCRIPT}" ]; then if [ -n "$APPLICATION_USER" ]; then # Run as EFFECTIVE_USER shift - exec sudo -H -E -u "${APPLICATION_USER}" ${CLI_SCRIPT} "$@" + exec gosu "${APPLICATION_USER}" ${CLI_SCRIPT} "$@" else # Run as root exec ${CLI_SCRIPT} "$@" diff --git a/docker/base/ubuntu-15.04/conf/bin/entrypoint.d/noop.sh b/docker/base/ubuntu-15.04/conf/bin/entrypoint.d/noop.sh index 967920837..092d55d8b 100644 --- a/docker/base/ubuntu-15.04/conf/bin/entrypoint.d/noop.sh +++ b/docker/base/ubuntu-15.04/conf/bin/entrypoint.d/noop.sh @@ -4,5 +4,4 @@ ## NOOP (no operation) ############################################# -tail -f /dev/null -exit +exec tail -f /dev/null diff --git a/docker/base/ubuntu-15.04/conf/bin/entrypoint.d/supervisord.sh b/docker/base/ubuntu-15.04/conf/bin/entrypoint.d/supervisord.sh index ead991551..f21489667 100644 --- a/docker/base/ubuntu-15.04/conf/bin/entrypoint.d/supervisord.sh +++ b/docker/base/ubuntu-15.04/conf/bin/entrypoint.d/supervisord.sh @@ -4,8 +4,6 @@ ## Supervisord (start daemons) ############################################# -rootCheck "supervisord" - ## Start services exec /opt/docker/bin/service.d/supervisor.sh diff --git a/docker/base/ubuntu-15.04/conf/bin/entrypoint.sh b/docker/base/ubuntu-15.04/conf/bin/entrypoint.sh index bbabcdddb..01f59660c 100644 --- a/docker/base/ubuntu-15.04/conf/bin/entrypoint.sh +++ b/docker/base/ubuntu-15.04/conf/bin/entrypoint.sh @@ -20,16 +20,13 @@ chmod -s /usr/local/bin/gosu trap 'echo sigterm ; exit' SIGTERM trap 'echo sigkill ; exit' SIGKILL -# link stdout from docker -ln -f -s "/proc/$$/fd/1" /docker.stdout -ln -f -s "/proc/$$/fd/2" /docker.stderr -chmod 600 /docker.stdout /docker.stderr - # sanitize input and set task TASK="$(echo $1| sed 's/[^-_a-zA-Z0-9]*//g')" source /opt/docker/bin/config.sh +createDockerStdoutStderr + if [[ "$UID" -eq 0 ]]; then # Only run provision if user is root diff --git a/docker/base/ubuntu-15.04/conf/bin/logwatch.sh b/docker/base/ubuntu-15.04/conf/bin/logwatch.sh deleted file mode 100644 index 1a5b486c7..000000000 --- a/docker/base/ubuntu-15.04/conf/bin/logwatch.sh +++ /dev/null @@ -1,14 +0,0 @@ -#!/usr/bin/env bash - -set -o pipefail # trace ERR through pipes -set -o errtrace # trace ERR through 'time command' and other functions -set -o nounset ## set -u : exit the script if you try to use an uninitialised variable -set -o errexit ## set -e : exit the script if any statement returns a non-true return value - -sleep 0.5 - -if [ -p "$2" ]; then - sed --unbuffered -e "s/^/\[$1\] /" -- "$2" -else - tail -n 0 -F -q "$2" | sed --unbuffered -e "s/^/\[$1\] /" -fi diff --git a/docker/base/ubuntu-15.04/conf/bin/provision b/docker/base/ubuntu-15.04/conf/bin/provision index f7b5ad0a8..d367c2812 100755 --- a/docker/base/ubuntu-15.04/conf/bin/provision +++ b/docker/base/ubuntu-15.04/conf/bin/provision @@ -19,6 +19,7 @@ PLAYBOOK = Template( - hosts: all vars_files: + - ./variables-webdevops.yml - ./variables.yml roles: - $roles @@ -188,7 +189,7 @@ def actionAdd(args): 'priority': args.priority } - saveJson(json); + saveJson(json) diff --git a/docker/base/ubuntu-15.04/conf/bin/provision.sh b/docker/base/ubuntu-15.04/conf/bin/provision.sh deleted file mode 100644 index 4079dd7f0..000000000 --- a/docker/base/ubuntu-15.04/conf/bin/provision.sh +++ /dev/null @@ -1,30 +0,0 @@ - #!/usr/bin/env bash - -# -# Example: -# provision.sh /opt/foobar/playbook.yml tag -# -# - -set -o pipefail # trace ERR through pipes -set -o errtrace # trace ERR through 'time command' and other functions -set -o nounset ## set -u : exit the script if you try to use an uninitialised variable -set -o errexit ## set -e : exit the script if any statement returns a non-true return value - -. config.sh - -deprecationNotice " Please use >>/opt/docker/bin/provision run --playbook playbook.yml --tag=bootstrap [args]<< for running provision" - - -if [ "$#" -lt 2 ]; then - echo "[ERROR] $0: Playbook or tag is missing" - exit 1 -fi - -ANSIBLE_PLAYBOOK="$1" -shift -ANSIBLE_TAG="$1" -shift -ANSIBLE_OPTS="$@" - -/opt/docker/bin/provision run --playbook "${ANSIBLE_PLAYBOOK}" --use-registry --tag "${ANSIBLE_TAG}" $ANSIBLE_OPTS diff --git a/docker/base-app/ubuntu-15.04/conf/bin/service.d/dnsmasq.d/10-init.sh b/docker/base/ubuntu-15.04/conf/bin/service.d/dnsmasq.d/10-init.sh similarity index 100% rename from docker/base-app/ubuntu-15.04/conf/bin/service.d/dnsmasq.d/10-init.sh rename to docker/base/ubuntu-15.04/conf/bin/service.d/dnsmasq.d/10-init.sh diff --git a/docker/base-app/ubuntu-15.04/conf/bin/service.d/dnsmasq.sh b/docker/base/ubuntu-15.04/conf/bin/service.d/dnsmasq.sh similarity index 100% rename from docker/base-app/ubuntu-15.04/conf/bin/service.d/dnsmasq.sh rename to docker/base/ubuntu-15.04/conf/bin/service.d/dnsmasq.sh diff --git a/docker/base/ubuntu-15.04/conf/bin/service.d/postfix.d/10-init.sh b/docker/base/ubuntu-15.04/conf/bin/service.d/postfix.d/10-init.sh new file mode 100644 index 000000000..cfd876955 --- /dev/null +++ b/docker/base/ubuntu-15.04/conf/bin/service.d/postfix.d/10-init.sh @@ -0,0 +1,27 @@ +# force new copy of hosts there (otherwise links could be outdated) +mkdir -p /var/spool/postfix/etc +cp -f /etc/hosts /var/spool/postfix/etc/hosts +cp -f /etc/resolv.conf /var/spool/postfix/etc/resolv.conf +cp -f /etc/services /var/spool/postfix/etc/services + +## MYHOSTNAME +# replace line +sed -i '/myhostname[ ]* =/c\' main.cf +echo "myhostname = $(hostname)" >> /etc/postfix/main.cf + +## REPLAYHOST +if [[ -n "${POSTFIX_RELAYHOST+x}" ]]; then + # replace line + sed -i '/relayhost[ ]* =/c\' main.cf + echo "relayhost = $POSTFIX_RELAYHOST" >> /etc/postfix/main.cf +fi + +## MYNETWORKS +if [[ -n "${POSTFIX_MYNETWORKS+x}" ]]; then + # replace line + sed -i '/mynetworks[ ]* =/c\' main.cf + echo "mynetworks = $POSTFIX_MYNETWORKS" >> /etc/postfix/main.cf +fi + +# generate aliases db +newaliases || : diff --git a/docker/base-app/ubuntu-15.04/conf/bin/service.d/postfix.sh b/docker/base/ubuntu-15.04/conf/bin/service.d/postfix.sh similarity index 100% rename from docker/base-app/ubuntu-15.04/conf/bin/service.d/postfix.sh rename to docker/base/ubuntu-15.04/conf/bin/service.d/postfix.sh diff --git a/docker/base/ubuntu-15.04/conf/bin/service.d/ssh.d/10-init.sh b/docker/base/ubuntu-15.04/conf/bin/service.d/ssh.d/10-init.sh new file mode 100644 index 000000000..f2b600312 --- /dev/null +++ b/docker/base/ubuntu-15.04/conf/bin/service.d/ssh.d/10-init.sh @@ -0,0 +1,7 @@ +# Init ssh privilege separation directory +mkdir -p /var/run/sshd +chown root:root /var/run/sshd +chmod 755 /var/run/sshd + +# generate host keys +ssh-keygen -A diff --git a/docker/base-app/ubuntu-15.04/conf/bin/service.d/ssh.sh b/docker/base/ubuntu-15.04/conf/bin/service.d/ssh.sh similarity index 100% rename from docker/base-app/ubuntu-15.04/conf/bin/service.d/ssh.sh rename to docker/base/ubuntu-15.04/conf/bin/service.d/ssh.sh diff --git a/docker/base/ubuntu-15.04/conf/bin/service.d/syslog-ng.d/10-init.sh b/docker/base/ubuntu-15.04/conf/bin/service.d/syslog-ng.d/10-init.sh index 22621d2ad..326207e52 100644 --- a/docker/base/ubuntu-15.04/conf/bin/service.d/syslog-ng.d/10-init.sh +++ b/docker/base/ubuntu-15.04/conf/bin/service.d/syslog-ng.d/10-init.sh @@ -6,5 +6,5 @@ if [ ! -S /var/lib/syslog-ng/syslog-ng.ctl ]; then rm -f /var/lib/syslog-ng/sysl if [[ ! -p /docker.stdout ]]; then # Switch to file (tty docker mode) - rpl --quiet 'pipe("/docker.stdout")' 'file("/docker.stdout")' -- /opt/docker/etc/syslog-ng/syslog-ng.conf > /dev/null + go-replace -s 'pipe("/docker.stdout")' -r 'file("/docker.stdout")' -- /opt/docker/etc/syslog-ng/syslog-ng.conf fi diff --git a/docker/base/ubuntu-15.04/conf/bin/usr-bin/docker-provision b/docker/base/ubuntu-15.04/conf/bin/usr-bin/docker-provision new file mode 100644 index 000000000..4ee715c64 --- /dev/null +++ b/docker/base/ubuntu-15.04/conf/bin/usr-bin/docker-provision @@ -0,0 +1,9 @@ +#!/usr/bin/env bash + +set -o pipefail # trace ERR through pipes +set -o errtrace # trace ERR through 'time command' and other functions +set -o nounset ## set -u : exit the script if you try to use an uninitialised variable +set -o errexit ## set -e : exit the script if any statement returns a non-true return value + +# wrapper +exec /opt/docker/bin/provision "$@" diff --git a/docker/base/ubuntu-15.04/conf/bin/usr-bin/docker-service-disable b/docker/base/ubuntu-15.04/conf/bin/usr-bin/docker-service-disable new file mode 100644 index 000000000..2b5b31bb4 --- /dev/null +++ b/docker/base/ubuntu-15.04/conf/bin/usr-bin/docker-service-disable @@ -0,0 +1,30 @@ +#!/usr/bin/env bash + +set -o pipefail # trace ERR through pipes +set -o errtrace # trace ERR through 'time command' and other functions +set -o nounset ## set -u : exit the script if you try to use an uninitialised variable +set -o errexit ## set -e : exit the script if any statement returns a non-true return value + +source /opt/docker/bin/config.sh + +rootCheck "$0" + +if [[ "$#" -eq 0 ]]; then + echo "Usage: $0 " + exit 1 +fi + +for SERVICE in "$@"; do + SERVICE_FILE="/opt/docker/etc/supervisor.d/${SERVICE}.conf" + + ## Disable service + if [[ -f "$SERVICE_FILE" ]]; then + go-replace --mode=lineinfile \ + -s 'autostart =' -r 'autostart = false' \ + -- "$SERVICE_FILE" + else + echo "[ERROR] Service '${SERVICE}' not found (tried ${SERVICE_FILE})" + exit 1 + fi +done + diff --git a/docker/base/ubuntu-15.04/conf/bin/usr-bin/docker-service-enable b/docker/base/ubuntu-15.04/conf/bin/usr-bin/docker-service-enable new file mode 100644 index 000000000..8d36a14a9 --- /dev/null +++ b/docker/base/ubuntu-15.04/conf/bin/usr-bin/docker-service-enable @@ -0,0 +1,41 @@ +#!/usr/bin/env bash + +set -o pipefail # trace ERR through pipes +set -o errtrace # trace ERR through 'time command' and other functions +set -o nounset ## set -u : exit the script if you try to use an uninitialised variable +set -o errexit ## set -e : exit the script if any statement returns a non-true return value + +source /opt/docker/bin/config.sh + +rootCheck "$0" + +if [[ "$#" -eq 0 ]]; then + echo "Usage: $0 " + exit 1 +fi + +for SERVICE in "$@"; do + SERVICE_FILE="/opt/docker/etc/supervisor.d/${SERVICE}.conf" + PROVISION_FILE="/opt/docker/provision/service.d/${SERVICE}.sh" + + # Run on demand installation/provisioning + if [[ -f "$PROVISION_FILE" ]]; then + echo "Running provisioning for ${SERVICE}, please wait..." + + ## execute scripts + . "$PROVISION_FILE" + + ## remove directory (one run time) + rm -f -- "$PROVISION_FILE" + fi + + ## Enable service + if [[ -f "$SERVICE_FILE" ]]; then + go-replace --mode=lineinfile \ + -s 'autostart =' -r 'autostart = true' \ + -- "$SERVICE_FILE" + else + echo "[ERROR] Service '${SERVICE}' not found (tried ${SERVICE_FILE})" + exit 1 + fi +done diff --git a/docker/base/ubuntu-15.04/conf/bin/usr-bin/service b/docker/base/ubuntu-15.04/conf/bin/usr-bin/service new file mode 100755 index 000000000..55ea12bf7 --- /dev/null +++ b/docker/base/ubuntu-15.04/conf/bin/usr-bin/service @@ -0,0 +1,86 @@ +#!/bin/bash + +set -o pipefail # trace ERR through pipes +set -o errtrace # trace ERR through 'time command' and other functions +set -o nounset ## set -u : exit the script if you try to use an uninitialised variable +set -o errexit ## set -e : exit the script if any statement returns a non-true return value + +# Root check +if [ "$(/usr/bin/whoami)" != "root" ]; then + echo "[ERROR] Must be run as root" + exit 1 +fi + +function serviceHelp() { + echo "Usage: $(basename "$0") " +} + +function getServicePid() { + local serviceName="$1" + local servicePid=$(supervisorctl pid "${serviceName}:${serviceName}d") + + if [[ -z "$servicePid" ]] || [[ "$servicePid" == "0" ]]; then + echo "not running" + exit 1 + fi + + echo $servicePid +} + +# Param check +if [ "$#" -lt 2 ]; then + echo "[ERROR] Missing parameters" + serviceHelp + exit 1 +fi + +############################# +# Param init +############################# + +SERVICENAME="$1" +ACTION="$2" + +############################# +# Service aliases +############################# +case "$SERVICENAME" in + apache2|httpd) + SERVICENAME="apache" + ;; +esac + +############################# +# Action runner +############################# +case "$ACTION" in + stop|start|restart|status) + exec supervisorctl "$ACTION" "${SERVICENAME}:${SERVICENAME}d" + ;; + + pid) + echo $(getServicePid "${SERVICENAME}") + ;; + + check) + FIRST_PID=$(getServicePid "${SERVICENAME}") + sleep 5 + SECOND_PID=$(getServicePid "${SERVICENAME}") + + if [[ "$FIRST_PID" == "$SECOND_PID" ]]; then + echo "ok" + exit 0 + else + echo "not running" + exit 1 + fi + ;; + + + *) + echo "[ERROR] Invalid action" + serviceHelp + exit 1 + ;; + +esac diff --git a/docker/base/ubuntu-15.04/conf/etc/supervisor.conf b/docker/base/ubuntu-15.04/conf/etc/supervisor.conf index 7c109515a..479e0db08 100644 --- a/docker/base/ubuntu-15.04/conf/etc/supervisor.conf +++ b/docker/base/ubuntu-15.04/conf/etc/supervisor.conf @@ -2,9 +2,16 @@ nodaemon=true [unix_http_server] -file = /var/run/supervisor.sock -# username = root -# password = {SHA}e982f17bcbe0f724063b708a4f76db211a999304 +file = /.supervisor.sock +chmod = 0700 +chown = root:root +username = root +password = {SHA}e982f17bcbe0f724063b708a4f76db211a999304 + +[supervisorctl] +serverurl = unix:///.supervisor.sock +username = root +password = docker [rpcinterface:supervisor] supervisor.rpcinterface_factory = supervisor.rpcinterface:make_main_rpcinterface diff --git a/docker/base/ubuntu-15.04/conf/etc/supervisor.d/dnsmasq.conf b/docker/base/ubuntu-15.04/conf/etc/supervisor.d/dnsmasq.conf new file mode 100644 index 000000000..9832ffca7 --- /dev/null +++ b/docker/base/ubuntu-15.04/conf/etc/supervisor.d/dnsmasq.conf @@ -0,0 +1,14 @@ +[group:dnsmasq] +programs=dnsmasqd +priority=15 + +[program:dnsmasqd] +command = /opt/docker/bin/service.d/dnsmasq.sh +process_name=%(program_name)s +startsecs = 0 +autostart = false +autorestart = true +stdout_logfile=/dev/stdout +stdout_logfile_maxbytes=0 +stderr_logfile=/dev/stderr +stderr_logfile_maxbytes=0 diff --git a/docker/base-app/ubuntu-15.04/conf/etc/supervisor.d/postfix.conf b/docker/base/ubuntu-15.04/conf/etc/supervisor.d/postfix.conf similarity index 100% rename from docker/base-app/ubuntu-15.04/conf/etc/supervisor.d/postfix.conf rename to docker/base/ubuntu-15.04/conf/etc/supervisor.d/postfix.conf diff --git a/docker/base-app/ubuntu-15.04/conf/etc/supervisor.d/ssh.conf b/docker/base/ubuntu-15.04/conf/etc/supervisor.d/ssh.conf similarity index 100% rename from docker/base-app/ubuntu-15.04/conf/etc/supervisor.d/ssh.conf rename to docker/base/ubuntu-15.04/conf/etc/supervisor.d/ssh.conf diff --git a/docker/base/ubuntu-15.04/conf/etc/supervisor.d/syslog-ng.conf b/docker/base/ubuntu-15.04/conf/etc/supervisor.d/syslog-ng.conf deleted file mode 100644 index 247fd1a25..000000000 --- a/docker/base/ubuntu-15.04/conf/etc/supervisor.d/syslog-ng.conf +++ /dev/null @@ -1,13 +0,0 @@ -[group:syslog] -programs=syslogd -priority=10 - -[program:syslogd] -command = /opt/docker/bin/service.d/syslog-ng.sh -process_name=%(program_name)s -autostart = true -autorestart = true -stdout_logfile=/dev/stdout -stdout_logfile_maxbytes=0 -stderr_logfile=/dev/stderr -stderr_logfile_maxbytes=0 diff --git a/docker/base/ubuntu-15.04/conf/etc/supervisor.d/syslog.conf b/docker/base/ubuntu-15.04/conf/etc/supervisor.d/syslog.conf new file mode 100644 index 000000000..20d1e238c --- /dev/null +++ b/docker/base/ubuntu-15.04/conf/etc/supervisor.d/syslog.conf @@ -0,0 +1,13 @@ +[group:syslog] +programs=syslogd +priority=10 + +[program:syslogd] +command = /opt/docker/bin/service.d/syslog-ng.sh +process_name=%(program_name)s +autostart = false +autorestart = true +stdout_logfile=/dev/stdout +stdout_logfile_maxbytes=0 +stderr_logfile=/dev/stderr +stderr_logfile_maxbytes=0 diff --git a/docker/base/ubuntu-15.04/conf/provision/roles/webdevops-base/tasks/bootstrap.yml b/docker/base/ubuntu-15.04/conf/provision/roles/webdevops-base/tasks/bootstrap.yml index 30be03c38..9f842336c 100644 --- a/docker/base/ubuntu-15.04/conf/provision/roles/webdevops-base/tasks/bootstrap.yml +++ b/docker/base/ubuntu-15.04/conf/provision/roles/webdevops-base/tasks/bootstrap.yml @@ -4,6 +4,5 @@ - include: bootstrap/misc.yml - include: bootstrap/root.yml - include: bootstrap/supervisor.yml -- include: bootstrap/syslog-ng.yml -- include: bootstrap/logrotate.yml - include: bootstrap/pam.yml +- include: bootstrap/entrypoint.yml diff --git a/docker/base/ubuntu-15.04/conf/provision/roles/webdevops-base/tasks/bootstrap/entrypoint.yml b/docker/base/ubuntu-15.04/conf/provision/roles/webdevops-base/tasks/bootstrap/entrypoint.yml new file mode 100644 index 000000000..d5d8809f4 --- /dev/null +++ b/docker/base/ubuntu-15.04/conf/provision/roles/webdevops-base/tasks/bootstrap/entrypoint.yml @@ -0,0 +1,8 @@ +--- + +- name: Create link for entrypoint + file: + src: '/opt/docker/bin/entrypoint.sh' + dest: '/entrypoint' + state: link + force: yes diff --git a/docker/base/ubuntu-15.04/conf/provision/roles/webdevops-base/tasks/bootstrap/logrotate.yml b/docker/base/ubuntu-15.04/conf/provision/roles/webdevops-base/tasks/bootstrap/logrotate.yml deleted file mode 100644 index d87926be2..000000000 --- a/docker/base/ubuntu-15.04/conf/provision/roles/webdevops-base/tasks/bootstrap/logrotate.yml +++ /dev/null @@ -1,33 +0,0 @@ ---- - -- name: Configure logrotate running user - lineinfile: - dest: /etc/logrotate.conf - regexp: '^su [-_a-zA-Z0-9]+ [-_a-zA-Z0-9]+' - line: 'su root adm' - -- name: Register logrotate configurations - file: - src: '{{ item }}' - dest: '/etc/logrotate.d/{{ item | basename }}' - state: link - force: yes - with_fileglob: - - /opt/docker/etc/logrotate.d/* - -- name: Remove system logrotates (not needed) - file: - path: '{{ item }}' - state: absent - with_items: - # Debian/Ubuntu - - /etc/cron.daily/logrotate - - /etc/cron.daily/apt-compat - - /etc/cron.daily/dpkg - - /etc/cron.daily/passwd - # RedHat - - /etc/cron.daily/0yum-daily.cron - - /etc/cron.daily/logrotate - - /etc/cron.hourly/0yum-hourly.cron - # Alpine - - /etc/periodic/daily/logrotate diff --git a/docker/base/ubuntu-15.04/conf/provision/roles/webdevops-base/tasks/bootstrap/supervisor.yml b/docker/base/ubuntu-15.04/conf/provision/roles/webdevops-base/tasks/bootstrap/supervisor.yml index bda0394b6..2ce07ac26 100644 --- a/docker/base/ubuntu-15.04/conf/provision/roles/webdevops-base/tasks/bootstrap/supervisor.yml +++ b/docker/base/ubuntu-15.04/conf/provision/roles/webdevops-base/tasks/bootstrap/supervisor.yml @@ -4,3 +4,10 @@ file: path: '/usr/sbin/service' state: absent + +- name: Create link for supervisor.conf + file: + src: '/opt/docker/etc/supervisor.conf' + dest: '/etc/supervisord.conf' + state: link + force: yes diff --git a/docker/base/ubuntu-15.04/conf/provision/roles/webdevops-base/tasks/bootstrap/syslog-ng.yml b/docker/base/ubuntu-15.04/conf/provision/roles/webdevops-base/tasks/bootstrap/syslog-ng.yml deleted file mode 100644 index 27c8f6a30..000000000 --- a/docker/base/ubuntu-15.04/conf/provision/roles/webdevops-base/tasks/bootstrap/syslog-ng.yml +++ /dev/null @@ -1,33 +0,0 @@ ---- - -- name: Get syslog-ng version - shell: "syslog-ng --version | grep -E -e '^syslog-ng[ ]+[0-9]+\\.[0-9]+' | head -n 1 | awk '{print $2}' | cut -f 1,2 -d ." - register: syslogng_version - -- name: Configure syslog-ng (default) - lineinfile: - dest: /etc/default/syslog-ng - regexp: '^[\s]*{{ item.key }}[\s]*=' - line: '{{ item.key }}="{{ item.value }}"' - create: yes - with_items: - - { key: 'SYSLOGNG_OPTS', value: '--no-caps' } - -- name: Enable syslog-ng config - file: - src: '/opt/docker/etc/syslog-ng/syslog-ng.conf' - dest: '/etc/syslog-ng/syslog-ng.conf' - state: link - force: yes - -- name: Set version of syslog-ng file - lineinfile: - dest: '/etc/syslog-ng/syslog-ng.conf' - regexp: '^@version:' - line: '@version: {{ syslogng_version.stdout }}' - -- name: Ensure /var/lib/syslog-ng exists - file: - path: '/var/lib/syslog-ng' - state: directory - recurse: yes diff --git a/docker/base/ubuntu-15.04/conf/provision/roles/webdevops-base/tasks/bootstrap/system.yml b/docker/base/ubuntu-15.04/conf/provision/roles/webdevops-base/tasks/bootstrap/system.yml index 8dfbf9665..0741d7cae 100644 --- a/docker/base/ubuntu-15.04/conf/provision/roles/webdevops-base/tasks/bootstrap/system.yml +++ b/docker/base/ubuntu-15.04/conf/provision/roles/webdevops-base/tasks/bootstrap/system.yml @@ -14,3 +14,20 @@ dest: '/entrypoint.cmd' state: link force: yes + +- name: Remove system logrotate and cronjobs (not needed) + file: + path: '{{ item }}' + state: absent + with_items: + # Debian/Ubuntu + - /etc/cron.daily/logrotate + - /etc/cron.daily/apt-compat + - /etc/cron.daily/dpkg + - /etc/cron.daily/passwd + # RedHat + - /etc/cron.daily/0yum-daily.cron + - /etc/cron.daily/logrotate + - /etc/cron.hourly/0yum-hourly.cron + # Alpine + - /etc/periodic/daily/logrotate diff --git a/docker/php-nginx-dev/alpine-3/conf/etc/nginx/vhost.common.d/.gitkeep b/docker/base/ubuntu-15.04/conf/provision/roles/webdevops-base/tasks/build/.gitkeep similarity index 100% rename from docker/php-nginx-dev/alpine-3/conf/etc/nginx/vhost.common.d/.gitkeep rename to docker/base/ubuntu-15.04/conf/provision/roles/webdevops-base/tasks/build/.gitkeep diff --git a/docker/base/ubuntu-15.04/conf/provision/roles/webdevops-base/tasks/build/logrotate.yml b/docker/base/ubuntu-15.04/conf/provision/roles/webdevops-base/tasks/build/logrotate.yml deleted file mode 100644 index 10f7e6644..000000000 --- a/docker/base/ubuntu-15.04/conf/provision/roles/webdevops-base/tasks/build/logrotate.yml +++ /dev/null @@ -1,10 +0,0 @@ ---- - -- name: Register logrotate configurations - file: - src: '{{ item }}' - dest: '/etc/logrotate.d/{{ item | basename }}' - state: link - force: yes - with_fileglob: - - /opt/docker/etc/logrotate.d/* diff --git a/docker/php-nginx/alpine-3-php7/conf/etc/nginx/conf.d/.gitkeep b/docker/base/ubuntu-15.04/conf/provision/service.d/.gitkeep similarity index 100% rename from docker/php-nginx/alpine-3-php7/conf/etc/nginx/conf.d/.gitkeep rename to docker/base/ubuntu-15.04/conf/provision/service.d/.gitkeep diff --git a/docker/base/ubuntu-15.04/conf/provision/service.d/cron.sh b/docker/base/ubuntu-15.04/conf/provision/service.d/cron.sh new file mode 100644 index 000000000..bd8a54781 --- /dev/null +++ b/docker/base/ubuntu-15.04/conf/provision/service.d/cron.sh @@ -0,0 +1,13 @@ +#!/usr/bin/env bash + +IMAGE_FAMILY=$(docker-image-info family) + +case "$IMAGE_FAMILY" in + Debian|Ubuntu) + apt-install cron + ;; + + RedHat) + yum-install cronie + ;; +esac diff --git a/docker/base/ubuntu-15.04/conf/provision/service.d/dnsmasq.sh b/docker/base/ubuntu-15.04/conf/provision/service.d/dnsmasq.sh new file mode 100644 index 000000000..9e5c3228c --- /dev/null +++ b/docker/base/ubuntu-15.04/conf/provision/service.d/dnsmasq.sh @@ -0,0 +1,24 @@ +#!/usr/bin/env bash + +IMAGE_FAMILY=$(docker-image-info family) + +# Installation +case "$IMAGE_FAMILY" in + Debian|Ubuntu) + apt-install dnsmasq + ;; + + RedHat) + yum-install dnsmasq + ;; + + Alpine) + apk-install dnsmasq + ;; +esac + +# Configuration +go-replace --mode=line \ + -s '^[\s]*user[\s]*=' -r 'user = root' \ + -s '^[\s]*conf-dir[\s]*=' -r 'conf-dir = /etc/dnsmasq.d' \ + -- /etc/dnsmasq.conf diff --git a/docker/base/ubuntu-15.04/conf/provision/service.d/postfix.sh b/docker/base/ubuntu-15.04/conf/provision/service.d/postfix.sh new file mode 100644 index 000000000..ff1879345 --- /dev/null +++ b/docker/base/ubuntu-15.04/conf/provision/service.d/postfix.sh @@ -0,0 +1,28 @@ +#!/usr/bin/env bash + +IMAGE_FAMILY=$(docker-image-info family) + +# Installation +case "$IMAGE_FAMILY" in + Debian|Ubuntu) + apt-install postfix + ;; + + RedHat) + yum-install postfix + ;; + + Alpine) + apk-install postfix + ln -s -f /etc/postfix/aliases /etc/aliases + ;; +esac + +# Configuration +go-replace --mode=line \ + -s '^[\s]*mydestination[\s]*=' -r 'mydestination = ' \ + -s '^[\s]*message_size_limit[\s]*=' -r 'message_size_limit = 15240000' \ + -s '^[\s]*smtp_use_tls[\s]*=' -r 'smtp_use_tls = yes' \ + -s '^[\s]*smtp_tls_security_level[\s]*=' -r 'smtp_tls_security_level = may' \ + -s '^[\s]*myhostname[\s]*=' -r '# myhostname' \ + -- /etc/postfix/main.cf diff --git a/docker/base/ubuntu-15.04/conf/provision/service.d/ssh.sh b/docker/base/ubuntu-15.04/conf/provision/service.d/ssh.sh new file mode 100644 index 000000000..63d7a9f3a --- /dev/null +++ b/docker/base/ubuntu-15.04/conf/provision/service.d/ssh.sh @@ -0,0 +1,17 @@ +#!/usr/bin/env bash + +IMAGE_FAMILY=$(docker-image-info family) + +case "$IMAGE_FAMILY" in + Debian|Ubuntu) + apt-install openssh-server + ;; + + RedHat) + yum-install openssh-server + ;; + + Alpine) + apk-install openssh + ;; +esac diff --git a/docker/base/ubuntu-15.04/conf/provision/service.d/syslog.sh b/docker/base/ubuntu-15.04/conf/provision/service.d/syslog.sh new file mode 100644 index 000000000..7e8b8e0a9 --- /dev/null +++ b/docker/base/ubuntu-15.04/conf/provision/service.d/syslog.sh @@ -0,0 +1,41 @@ +#!/usr/bin/env bash + +IMAGE_FAMILY=$(docker-image-info family) + +# Installation +case "$IMAGE_FAMILY" in + Debian|Ubuntu) + apt-install syslog-ng syslog-ng-core + ;; + + RedHat) + yum-install syslog-ng + + # remove logrotate (not needed for docker) + rm -f "/etc/cron.daily/logrotate" + ;; + + Alpine) + apk-install syslog-ng + ;; +esac + +## Configuration +SYSLOG_NG_VERSION=$(syslog-ng --version | grep -E -e '^syslog-ng[ ]+[0-9]+\.[0-9]+' | head -n 1 | awk '{print $2}' | cut -f 1,2 -d .) + +# Disable caps inside container +if [[ -f /etc/default/syslog-ng ]]; then + go-replace --mode=lineinfile \ + -s "SYSLOGNG_OPTS" -r "SYSLOGNG_OPTS = --no-caps" \ + -- /etc/default/syslog-ng +fi + +# Symlink configuration +ln -s -f /opt/docker/etc/syslog-ng/syslog-ng.conf /etc/syslog-ng/syslog-ng.conf + +go-replace --mode=lineinfile \ + -s "@version" -r "@version: ${SYSLOG_NG_VERSION}" \ + -- /etc/syslog-ng/syslog-ng.conf + +# Ensure /var/lib/syslog-ng exists +mkdir -p /var/lib/syslog-ng diff --git a/docker/base/ubuntu-15.04/conf/provision/variables-webdevops.yml b/docker/base/ubuntu-15.04/conf/provision/variables-webdevops.yml new file mode 100644 index 000000000..0b2a21a95 --- /dev/null +++ b/docker/base/ubuntu-15.04/conf/provision/variables-webdevops.yml @@ -0,0 +1,7 @@ +--- + +docker_image_info_family: "{{ lookup('pipe', 'docker-image-info family') }}" +docker_image_info_distribution: "{{ lookup('pipe', 'docker-image-info dist') }}" +docker_image_info_distribution_version: "{{ lookup('pipe', 'docker-image-info dist-version') }}" +docker_image_info_distribution_release: "{{ lookup('pipe', 'docker-image-info dist-release') }}" +docker_image_info_distribution_codename: "{{ lookup('pipe', 'docker-image-info dist-codename') }}" diff --git a/docker/base/ubuntu-15.04/conf/provision/variables.yml b/docker/base/ubuntu-15.04/conf/provision/variables.yml index ed97d539c..0b2a21a95 100644 --- a/docker/base/ubuntu-15.04/conf/provision/variables.yml +++ b/docker/base/ubuntu-15.04/conf/provision/variables.yml @@ -1 +1,7 @@ --- + +docker_image_info_family: "{{ lookup('pipe', 'docker-image-info family') }}" +docker_image_info_distribution: "{{ lookup('pipe', 'docker-image-info dist') }}" +docker_image_info_distribution_version: "{{ lookup('pipe', 'docker-image-info dist-version') }}" +docker_image_info_distribution_release: "{{ lookup('pipe', 'docker-image-info dist-release') }}" +docker_image_info_distribution_codename: "{{ lookup('pipe', 'docker-image-info dist-codename') }}" diff --git a/docker/base/ubuntu-15.10/Dockerfile b/docker/base/ubuntu-15.10/Dockerfile index db758edc7..2a93d9829 100644 --- a/docker/base/ubuntu-15.10/Dockerfile +++ b/docker/base/ubuntu-15.10/Dockerfile @@ -5,31 +5,47 @@ FROM webdevops/bootstrap:ubuntu-15.10 -MAINTAINER info@webdevops.io -LABEL vendor=WebDevOps.io -LABEL io.webdevops.layout=8 -LABEL io.webdevops.version=1.5.0 - -ENV DOCKER_CONF_HOME /opt/docker/ +ENV DOCKER_CONF_HOME=/opt/docker/ \ + LOG_STDOUT="" \ + LOG_STDERR="" COPY conf/ /opt/docker/ +# Install ansible +RUN /usr/local/bin/apt-install \ + python-minimal \ + python-setuptools \ + python-pip \ + python-paramiko \ + python-jinja2 \ + python-dev \ + libffi-dev \ + libssl-dev \ + build-essential \ + && pip install --upgrade pip \ + && hash -r \ + && pip install --no-cache-dir ansible \ + && chmod 750 /usr/local/bin/ansible* \ + # Cleanup + && apt-get purge -y -f --force-yes \ + python-dev \ + build-essential \ + libssl-dev \ + libffi-dev \ + && docker-image-cleanup + # Install services RUN chmod +x /opt/docker/bin/* \ && /usr/local/bin/apt-install \ supervisor \ - syslog-ng \ - syslog-ng-core \ - logrotate \ - cron \ wget \ curl \ net-tools \ gnupg \ && chmod +s /usr/local/bin/gosu \ && /opt/docker/bin/provision run --tag bootstrap --role webdevops-base \ - && /opt/docker/bin/bootstrap.sh - + && /opt/docker/bin/bootstrap.sh \ + && docker-image-cleanup ENTRYPOINT ["/opt/docker/bin/entrypoint.sh"] CMD ["supervisord"] diff --git a/docker/base/ubuntu-15.10/Dockerfile.jinja2 b/docker/base/ubuntu-15.10/Dockerfile.jinja2 index e6c13ab5e..11f9e8b10 100644 --- a/docker/base/ubuntu-15.10/Dockerfile.jinja2 +++ b/docker/base/ubuntu-15.10/Dockerfile.jinja2 @@ -1,11 +1,11 @@ {{ docker.from("bootstrap", "ubuntu-15.10") }} -{{ docker.version() }} - -{{ environment.homePath() }} +{{ environment.base() }} {{ docker.copy('conf/', '/opt/docker/') }} +{{ ansible.ubuntu() }} + {{ base.ubuntu() }} {{ docker.entrypoint("/opt/docker/bin/entrypoint.sh") }} diff --git a/docker/base/ubuntu-15.10/conf/bin/bootstrap.sh b/docker/base/ubuntu-15.10/conf/bin/bootstrap.sh index 1d1a30f72..855c10782 100644 --- a/docker/base/ubuntu-15.10/conf/bin/bootstrap.sh +++ b/docker/base/ubuntu-15.10/conf/bin/bootstrap.sh @@ -17,10 +17,16 @@ rootCheck "$0" # Save the buildtime date +%s > /opt/docker/BUILDTIME +date +%s >/opt/docker/etc/.registry/image_info_buildtime # Make all scripts executable find /opt/docker/bin/ -type f -iname '*.sh' -print0 | xargs --no-run-if-empty -0 chmod +x +# Enable usr-bin executables +find /opt/docker/bin/usr-bin -type f | while read USR_BIN_FILE; do + chmod +x -- "$USR_BIN_FILE" + ln -n -f -- "$USR_BIN_FILE" "/usr/local/bin/$(basename "$USR_BIN_FILE")" +done case "$BOOTSTRAP_MODE" in ################################### @@ -44,6 +50,23 @@ case "$BOOTSTRAP_MODE" in echo "[ERROR] Bootstrap mode '$BOOTSTRAP_MODE' not defined" exit 1 ;; - esac + +###################### +# Check if entrypoint provisioning is available +###################### + +echo "Checking provision status..." +for PROVISION_TAG in onbuild build bootstrap entrypoint; do + ROLES=$(docker-provision list --tag "$PROVISION_TAG") + if [[ -n "$ROLES" ]]; then + PROVISION_ROLE_COUNT=$(echo "$ROLES" | wc -l) + echo " - found ${PROVISION_ROLE_COUNT} for provision tag ${PROVISION_TAG}, caching info for execution" + echo -n "$PROVISION_ROLE_COUNT" > "/opt/docker/etc/.registry/provision-availale.${PROVISION_TAG}" + else + echo " - no roles found for provision tag ${PROVISION_TAG}" + echo -n '' > "/opt/docker/etc/.registry/provision-availale.${PROVISION_TAG}" + fi +done + diff --git a/docker/base/ubuntu-15.10/conf/bin/config.sh b/docker/base/ubuntu-15.10/conf/bin/config.sh index 3155728e8..049756c26 100644 --- a/docker/base/ubuntu-15.10/conf/bin/config.sh +++ b/docker/base/ubuntu-15.10/conf/bin/config.sh @@ -15,44 +15,23 @@ function rootCheck() { } ### - # Create named pipe - # - # $1 -> name of file + # Create /docker.stdout and /docker.stderr # ## -function createNamedPipe() { - rm --force -- "$1" - mknod "$1" p -} - -### - # Escape value for sed usage - # - # $1 -> value - # STDOUT -> escaped value - # - ## -function sedEscape() { - echo "$(echo $* |sed -e 's/[]\/$*.^|[]/\\&/g')" -} +function createDockerStdoutStderr() { + # link stdout from docker + if [[ -z "$LOG_STDOUT" ]]; then + LOG_STDOUT="/proc/$$/fd/1" + fi -### - # Replace text inside a file - # - # $1 -> source value - # $2 -> target value - # $3 -> path to file - # - ## -function replaceTextInFile() { - SOURCE="$(sedEscape $1)" - REPLACE="$(sedEscape $2)" - TARGET="$3" + if [[ -z "$LOG_STDERR" ]]; then + LOG_STDERR="/proc/$$/fd/2" + fi - sed -i "s/${SOURCE}/${REPLACE}/" "${TARGET}" + ln -f -s "$LOG_STDOUT" /docker.stdout + ln -f -s "$LOG_STDERR" /docker.stderr + chmod 600 /docker.stdout /docker.stderr } - - ### # Include script directory text inside a file # @@ -104,7 +83,7 @@ function runEntrypoints() { . /opt/docker/bin/entrypoint.d/default.sh fi - exit + exit 1 } ### @@ -161,6 +140,12 @@ function runProvisionEntrypoint() { function runDockerProvision() { ANSIBLE_TAG="$1" - /opt/docker/bin/provision run --tag "$ANSIBLE_TAG" --use-registry + PROVISION_STATS_FILE="/opt/docker/etc/.registry/provision-stats.${ANSIBLE_TAG}" + + # run provision if stats file doesn't exists (unknown mode) + # or if stats file is not empty + if [[ ! -f "$PROVISION_STATS_FILE" ]] || [[ -s "$PROVISION_STATS_FILE" ]]; then + /opt/docker/bin/provision run --tag "${ANSIBLE_TAG}" --use-registry + fi } diff --git a/docker/base/ubuntu-15.10/conf/bin/control.sh b/docker/base/ubuntu-15.10/conf/bin/control.sh index a6697092d..22d189745 100644 --- a/docker/base/ubuntu-15.10/conf/bin/control.sh +++ b/docker/base/ubuntu-15.10/conf/bin/control.sh @@ -101,23 +101,13 @@ case "$CONTROL_COMMAND" in ## ------------------------------------------ "service.enable") - SERVICE_FILE="/opt/docker/etc/supervisor.d/$1.conf" - if [ -f "$SERVICE_FILE" ]; then - sed -i '/autostart = /c\autostart = true' -- "$SERVICE_FILE" - else - echo "[ERROR] Service '${1}' not found (tried ${SERVICE_FILE})" - exit 1 - fi + deprecationNotice " Please use >>docker-service-enable [service]<<" + docker-service-enable "$1" ;; "service.disable") - SERVICE_FILE="/opt/docker/etc/supervisor.d/$1.conf" - if [ -f "$SERVICE_FILE" ]; then - sed -i '/autostart = /c\autostart = false' -- "$SERVICE_FILE" - else - echo "[ERROR] Service '${1}' not found (tried ${SERVICE_FILE})" - exit 1 - fi + deprecationNotice " Please use >>docker-service-disable [service]<<" + docker-service-disable "$1" ;; ## ------------------------------------------ diff --git a/docker/base/ubuntu-15.10/conf/bin/entrypoint.d/cli.sh b/docker/base/ubuntu-15.10/conf/bin/entrypoint.d/cli.sh index 2ca68926c..fe212a8ea 100644 --- a/docker/base/ubuntu-15.10/conf/bin/entrypoint.d/cli.sh +++ b/docker/base/ubuntu-15.10/conf/bin/entrypoint.d/cli.sh @@ -8,7 +8,7 @@ if [ -n "${CLI_SCRIPT}" ]; then if [ -n "$APPLICATION_USER" ]; then # Run as EFFECTIVE_USER shift - exec sudo -H -E -u "${APPLICATION_USER}" ${CLI_SCRIPT} "$@" + exec gosu "${APPLICATION_USER}" ${CLI_SCRIPT} "$@" else # Run as root exec ${CLI_SCRIPT} "$@" diff --git a/docker/base/ubuntu-15.10/conf/bin/entrypoint.d/noop.sh b/docker/base/ubuntu-15.10/conf/bin/entrypoint.d/noop.sh index 967920837..092d55d8b 100644 --- a/docker/base/ubuntu-15.10/conf/bin/entrypoint.d/noop.sh +++ b/docker/base/ubuntu-15.10/conf/bin/entrypoint.d/noop.sh @@ -4,5 +4,4 @@ ## NOOP (no operation) ############################################# -tail -f /dev/null -exit +exec tail -f /dev/null diff --git a/docker/base/ubuntu-15.10/conf/bin/entrypoint.d/supervisord.sh b/docker/base/ubuntu-15.10/conf/bin/entrypoint.d/supervisord.sh index ead991551..f21489667 100644 --- a/docker/base/ubuntu-15.10/conf/bin/entrypoint.d/supervisord.sh +++ b/docker/base/ubuntu-15.10/conf/bin/entrypoint.d/supervisord.sh @@ -4,8 +4,6 @@ ## Supervisord (start daemons) ############################################# -rootCheck "supervisord" - ## Start services exec /opt/docker/bin/service.d/supervisor.sh diff --git a/docker/base/ubuntu-15.10/conf/bin/entrypoint.sh b/docker/base/ubuntu-15.10/conf/bin/entrypoint.sh index bbabcdddb..01f59660c 100644 --- a/docker/base/ubuntu-15.10/conf/bin/entrypoint.sh +++ b/docker/base/ubuntu-15.10/conf/bin/entrypoint.sh @@ -20,16 +20,13 @@ chmod -s /usr/local/bin/gosu trap 'echo sigterm ; exit' SIGTERM trap 'echo sigkill ; exit' SIGKILL -# link stdout from docker -ln -f -s "/proc/$$/fd/1" /docker.stdout -ln -f -s "/proc/$$/fd/2" /docker.stderr -chmod 600 /docker.stdout /docker.stderr - # sanitize input and set task TASK="$(echo $1| sed 's/[^-_a-zA-Z0-9]*//g')" source /opt/docker/bin/config.sh +createDockerStdoutStderr + if [[ "$UID" -eq 0 ]]; then # Only run provision if user is root diff --git a/docker/base/ubuntu-15.10/conf/bin/logwatch.sh b/docker/base/ubuntu-15.10/conf/bin/logwatch.sh deleted file mode 100644 index 1a5b486c7..000000000 --- a/docker/base/ubuntu-15.10/conf/bin/logwatch.sh +++ /dev/null @@ -1,14 +0,0 @@ -#!/usr/bin/env bash - -set -o pipefail # trace ERR through pipes -set -o errtrace # trace ERR through 'time command' and other functions -set -o nounset ## set -u : exit the script if you try to use an uninitialised variable -set -o errexit ## set -e : exit the script if any statement returns a non-true return value - -sleep 0.5 - -if [ -p "$2" ]; then - sed --unbuffered -e "s/^/\[$1\] /" -- "$2" -else - tail -n 0 -F -q "$2" | sed --unbuffered -e "s/^/\[$1\] /" -fi diff --git a/docker/base/ubuntu-15.10/conf/bin/provision b/docker/base/ubuntu-15.10/conf/bin/provision index f7b5ad0a8..d367c2812 100755 --- a/docker/base/ubuntu-15.10/conf/bin/provision +++ b/docker/base/ubuntu-15.10/conf/bin/provision @@ -19,6 +19,7 @@ PLAYBOOK = Template( - hosts: all vars_files: + - ./variables-webdevops.yml - ./variables.yml roles: - $roles @@ -188,7 +189,7 @@ def actionAdd(args): 'priority': args.priority } - saveJson(json); + saveJson(json) diff --git a/docker/base/ubuntu-15.10/conf/bin/provision.sh b/docker/base/ubuntu-15.10/conf/bin/provision.sh deleted file mode 100644 index 4079dd7f0..000000000 --- a/docker/base/ubuntu-15.10/conf/bin/provision.sh +++ /dev/null @@ -1,30 +0,0 @@ - #!/usr/bin/env bash - -# -# Example: -# provision.sh /opt/foobar/playbook.yml tag -# -# - -set -o pipefail # trace ERR through pipes -set -o errtrace # trace ERR through 'time command' and other functions -set -o nounset ## set -u : exit the script if you try to use an uninitialised variable -set -o errexit ## set -e : exit the script if any statement returns a non-true return value - -. config.sh - -deprecationNotice " Please use >>/opt/docker/bin/provision run --playbook playbook.yml --tag=bootstrap [args]<< for running provision" - - -if [ "$#" -lt 2 ]; then - echo "[ERROR] $0: Playbook or tag is missing" - exit 1 -fi - -ANSIBLE_PLAYBOOK="$1" -shift -ANSIBLE_TAG="$1" -shift -ANSIBLE_OPTS="$@" - -/opt/docker/bin/provision run --playbook "${ANSIBLE_PLAYBOOK}" --use-registry --tag "${ANSIBLE_TAG}" $ANSIBLE_OPTS diff --git a/docker/base-app/ubuntu-15.10/conf/bin/service.d/dnsmasq.d/10-init.sh b/docker/base/ubuntu-15.10/conf/bin/service.d/dnsmasq.d/10-init.sh similarity index 100% rename from docker/base-app/ubuntu-15.10/conf/bin/service.d/dnsmasq.d/10-init.sh rename to docker/base/ubuntu-15.10/conf/bin/service.d/dnsmasq.d/10-init.sh diff --git a/docker/base-app/ubuntu-15.10/conf/bin/service.d/dnsmasq.sh b/docker/base/ubuntu-15.10/conf/bin/service.d/dnsmasq.sh similarity index 100% rename from docker/base-app/ubuntu-15.10/conf/bin/service.d/dnsmasq.sh rename to docker/base/ubuntu-15.10/conf/bin/service.d/dnsmasq.sh diff --git a/docker/base/ubuntu-15.10/conf/bin/service.d/postfix.d/10-init.sh b/docker/base/ubuntu-15.10/conf/bin/service.d/postfix.d/10-init.sh new file mode 100644 index 000000000..cfd876955 --- /dev/null +++ b/docker/base/ubuntu-15.10/conf/bin/service.d/postfix.d/10-init.sh @@ -0,0 +1,27 @@ +# force new copy of hosts there (otherwise links could be outdated) +mkdir -p /var/spool/postfix/etc +cp -f /etc/hosts /var/spool/postfix/etc/hosts +cp -f /etc/resolv.conf /var/spool/postfix/etc/resolv.conf +cp -f /etc/services /var/spool/postfix/etc/services + +## MYHOSTNAME +# replace line +sed -i '/myhostname[ ]* =/c\' main.cf +echo "myhostname = $(hostname)" >> /etc/postfix/main.cf + +## REPLAYHOST +if [[ -n "${POSTFIX_RELAYHOST+x}" ]]; then + # replace line + sed -i '/relayhost[ ]* =/c\' main.cf + echo "relayhost = $POSTFIX_RELAYHOST" >> /etc/postfix/main.cf +fi + +## MYNETWORKS +if [[ -n "${POSTFIX_MYNETWORKS+x}" ]]; then + # replace line + sed -i '/mynetworks[ ]* =/c\' main.cf + echo "mynetworks = $POSTFIX_MYNETWORKS" >> /etc/postfix/main.cf +fi + +# generate aliases db +newaliases || : diff --git a/docker/base-app/ubuntu-15.10/conf/bin/service.d/postfix.sh b/docker/base/ubuntu-15.10/conf/bin/service.d/postfix.sh similarity index 100% rename from docker/base-app/ubuntu-15.10/conf/bin/service.d/postfix.sh rename to docker/base/ubuntu-15.10/conf/bin/service.d/postfix.sh diff --git a/docker/base/ubuntu-15.10/conf/bin/service.d/ssh.d/10-init.sh b/docker/base/ubuntu-15.10/conf/bin/service.d/ssh.d/10-init.sh new file mode 100644 index 000000000..f2b600312 --- /dev/null +++ b/docker/base/ubuntu-15.10/conf/bin/service.d/ssh.d/10-init.sh @@ -0,0 +1,7 @@ +# Init ssh privilege separation directory +mkdir -p /var/run/sshd +chown root:root /var/run/sshd +chmod 755 /var/run/sshd + +# generate host keys +ssh-keygen -A diff --git a/docker/base-app/ubuntu-15.10/conf/bin/service.d/ssh.sh b/docker/base/ubuntu-15.10/conf/bin/service.d/ssh.sh similarity index 100% rename from docker/base-app/ubuntu-15.10/conf/bin/service.d/ssh.sh rename to docker/base/ubuntu-15.10/conf/bin/service.d/ssh.sh diff --git a/docker/base/ubuntu-15.10/conf/bin/service.d/syslog-ng.d/10-init.sh b/docker/base/ubuntu-15.10/conf/bin/service.d/syslog-ng.d/10-init.sh index 22621d2ad..326207e52 100644 --- a/docker/base/ubuntu-15.10/conf/bin/service.d/syslog-ng.d/10-init.sh +++ b/docker/base/ubuntu-15.10/conf/bin/service.d/syslog-ng.d/10-init.sh @@ -6,5 +6,5 @@ if [ ! -S /var/lib/syslog-ng/syslog-ng.ctl ]; then rm -f /var/lib/syslog-ng/sysl if [[ ! -p /docker.stdout ]]; then # Switch to file (tty docker mode) - rpl --quiet 'pipe("/docker.stdout")' 'file("/docker.stdout")' -- /opt/docker/etc/syslog-ng/syslog-ng.conf > /dev/null + go-replace -s 'pipe("/docker.stdout")' -r 'file("/docker.stdout")' -- /opt/docker/etc/syslog-ng/syslog-ng.conf fi diff --git a/docker/base/ubuntu-15.10/conf/bin/usr-bin/docker-provision b/docker/base/ubuntu-15.10/conf/bin/usr-bin/docker-provision new file mode 100644 index 000000000..4ee715c64 --- /dev/null +++ b/docker/base/ubuntu-15.10/conf/bin/usr-bin/docker-provision @@ -0,0 +1,9 @@ +#!/usr/bin/env bash + +set -o pipefail # trace ERR through pipes +set -o errtrace # trace ERR through 'time command' and other functions +set -o nounset ## set -u : exit the script if you try to use an uninitialised variable +set -o errexit ## set -e : exit the script if any statement returns a non-true return value + +# wrapper +exec /opt/docker/bin/provision "$@" diff --git a/docker/base/ubuntu-15.10/conf/bin/usr-bin/docker-service-disable b/docker/base/ubuntu-15.10/conf/bin/usr-bin/docker-service-disable new file mode 100644 index 000000000..2b5b31bb4 --- /dev/null +++ b/docker/base/ubuntu-15.10/conf/bin/usr-bin/docker-service-disable @@ -0,0 +1,30 @@ +#!/usr/bin/env bash + +set -o pipefail # trace ERR through pipes +set -o errtrace # trace ERR through 'time command' and other functions +set -o nounset ## set -u : exit the script if you try to use an uninitialised variable +set -o errexit ## set -e : exit the script if any statement returns a non-true return value + +source /opt/docker/bin/config.sh + +rootCheck "$0" + +if [[ "$#" -eq 0 ]]; then + echo "Usage: $0 " + exit 1 +fi + +for SERVICE in "$@"; do + SERVICE_FILE="/opt/docker/etc/supervisor.d/${SERVICE}.conf" + + ## Disable service + if [[ -f "$SERVICE_FILE" ]]; then + go-replace --mode=lineinfile \ + -s 'autostart =' -r 'autostart = false' \ + -- "$SERVICE_FILE" + else + echo "[ERROR] Service '${SERVICE}' not found (tried ${SERVICE_FILE})" + exit 1 + fi +done + diff --git a/docker/base/ubuntu-15.10/conf/bin/usr-bin/docker-service-enable b/docker/base/ubuntu-15.10/conf/bin/usr-bin/docker-service-enable new file mode 100644 index 000000000..8d36a14a9 --- /dev/null +++ b/docker/base/ubuntu-15.10/conf/bin/usr-bin/docker-service-enable @@ -0,0 +1,41 @@ +#!/usr/bin/env bash + +set -o pipefail # trace ERR through pipes +set -o errtrace # trace ERR through 'time command' and other functions +set -o nounset ## set -u : exit the script if you try to use an uninitialised variable +set -o errexit ## set -e : exit the script if any statement returns a non-true return value + +source /opt/docker/bin/config.sh + +rootCheck "$0" + +if [[ "$#" -eq 0 ]]; then + echo "Usage: $0 " + exit 1 +fi + +for SERVICE in "$@"; do + SERVICE_FILE="/opt/docker/etc/supervisor.d/${SERVICE}.conf" + PROVISION_FILE="/opt/docker/provision/service.d/${SERVICE}.sh" + + # Run on demand installation/provisioning + if [[ -f "$PROVISION_FILE" ]]; then + echo "Running provisioning for ${SERVICE}, please wait..." + + ## execute scripts + . "$PROVISION_FILE" + + ## remove directory (one run time) + rm -f -- "$PROVISION_FILE" + fi + + ## Enable service + if [[ -f "$SERVICE_FILE" ]]; then + go-replace --mode=lineinfile \ + -s 'autostart =' -r 'autostart = true' \ + -- "$SERVICE_FILE" + else + echo "[ERROR] Service '${SERVICE}' not found (tried ${SERVICE_FILE})" + exit 1 + fi +done diff --git a/docker/base/ubuntu-15.10/conf/bin/usr-bin/service b/docker/base/ubuntu-15.10/conf/bin/usr-bin/service new file mode 100755 index 000000000..55ea12bf7 --- /dev/null +++ b/docker/base/ubuntu-15.10/conf/bin/usr-bin/service @@ -0,0 +1,86 @@ +#!/bin/bash + +set -o pipefail # trace ERR through pipes +set -o errtrace # trace ERR through 'time command' and other functions +set -o nounset ## set -u : exit the script if you try to use an uninitialised variable +set -o errexit ## set -e : exit the script if any statement returns a non-true return value + +# Root check +if [ "$(/usr/bin/whoami)" != "root" ]; then + echo "[ERROR] Must be run as root" + exit 1 +fi + +function serviceHelp() { + echo "Usage: $(basename "$0") " +} + +function getServicePid() { + local serviceName="$1" + local servicePid=$(supervisorctl pid "${serviceName}:${serviceName}d") + + if [[ -z "$servicePid" ]] || [[ "$servicePid" == "0" ]]; then + echo "not running" + exit 1 + fi + + echo $servicePid +} + +# Param check +if [ "$#" -lt 2 ]; then + echo "[ERROR] Missing parameters" + serviceHelp + exit 1 +fi + +############################# +# Param init +############################# + +SERVICENAME="$1" +ACTION="$2" + +############################# +# Service aliases +############################# +case "$SERVICENAME" in + apache2|httpd) + SERVICENAME="apache" + ;; +esac + +############################# +# Action runner +############################# +case "$ACTION" in + stop|start|restart|status) + exec supervisorctl "$ACTION" "${SERVICENAME}:${SERVICENAME}d" + ;; + + pid) + echo $(getServicePid "${SERVICENAME}") + ;; + + check) + FIRST_PID=$(getServicePid "${SERVICENAME}") + sleep 5 + SECOND_PID=$(getServicePid "${SERVICENAME}") + + if [[ "$FIRST_PID" == "$SECOND_PID" ]]; then + echo "ok" + exit 0 + else + echo "not running" + exit 1 + fi + ;; + + + *) + echo "[ERROR] Invalid action" + serviceHelp + exit 1 + ;; + +esac diff --git a/docker/base/ubuntu-15.10/conf/etc/supervisor.conf b/docker/base/ubuntu-15.10/conf/etc/supervisor.conf index 7c109515a..479e0db08 100644 --- a/docker/base/ubuntu-15.10/conf/etc/supervisor.conf +++ b/docker/base/ubuntu-15.10/conf/etc/supervisor.conf @@ -2,9 +2,16 @@ nodaemon=true [unix_http_server] -file = /var/run/supervisor.sock -# username = root -# password = {SHA}e982f17bcbe0f724063b708a4f76db211a999304 +file = /.supervisor.sock +chmod = 0700 +chown = root:root +username = root +password = {SHA}e982f17bcbe0f724063b708a4f76db211a999304 + +[supervisorctl] +serverurl = unix:///.supervisor.sock +username = root +password = docker [rpcinterface:supervisor] supervisor.rpcinterface_factory = supervisor.rpcinterface:make_main_rpcinterface diff --git a/docker/base/ubuntu-15.10/conf/etc/supervisor.d/dnsmasq.conf b/docker/base/ubuntu-15.10/conf/etc/supervisor.d/dnsmasq.conf new file mode 100644 index 000000000..9832ffca7 --- /dev/null +++ b/docker/base/ubuntu-15.10/conf/etc/supervisor.d/dnsmasq.conf @@ -0,0 +1,14 @@ +[group:dnsmasq] +programs=dnsmasqd +priority=15 + +[program:dnsmasqd] +command = /opt/docker/bin/service.d/dnsmasq.sh +process_name=%(program_name)s +startsecs = 0 +autostart = false +autorestart = true +stdout_logfile=/dev/stdout +stdout_logfile_maxbytes=0 +stderr_logfile=/dev/stderr +stderr_logfile_maxbytes=0 diff --git a/docker/base-app/ubuntu-15.10/conf/etc/supervisor.d/postfix.conf b/docker/base/ubuntu-15.10/conf/etc/supervisor.d/postfix.conf similarity index 100% rename from docker/base-app/ubuntu-15.10/conf/etc/supervisor.d/postfix.conf rename to docker/base/ubuntu-15.10/conf/etc/supervisor.d/postfix.conf diff --git a/docker/base-app/ubuntu-15.10/conf/etc/supervisor.d/ssh.conf b/docker/base/ubuntu-15.10/conf/etc/supervisor.d/ssh.conf similarity index 100% rename from docker/base-app/ubuntu-15.10/conf/etc/supervisor.d/ssh.conf rename to docker/base/ubuntu-15.10/conf/etc/supervisor.d/ssh.conf diff --git a/docker/base/ubuntu-15.10/conf/etc/supervisor.d/syslog-ng.conf b/docker/base/ubuntu-15.10/conf/etc/supervisor.d/syslog-ng.conf deleted file mode 100644 index 247fd1a25..000000000 --- a/docker/base/ubuntu-15.10/conf/etc/supervisor.d/syslog-ng.conf +++ /dev/null @@ -1,13 +0,0 @@ -[group:syslog] -programs=syslogd -priority=10 - -[program:syslogd] -command = /opt/docker/bin/service.d/syslog-ng.sh -process_name=%(program_name)s -autostart = true -autorestart = true -stdout_logfile=/dev/stdout -stdout_logfile_maxbytes=0 -stderr_logfile=/dev/stderr -stderr_logfile_maxbytes=0 diff --git a/docker/base/ubuntu-15.10/conf/etc/supervisor.d/syslog.conf b/docker/base/ubuntu-15.10/conf/etc/supervisor.d/syslog.conf new file mode 100644 index 000000000..20d1e238c --- /dev/null +++ b/docker/base/ubuntu-15.10/conf/etc/supervisor.d/syslog.conf @@ -0,0 +1,13 @@ +[group:syslog] +programs=syslogd +priority=10 + +[program:syslogd] +command = /opt/docker/bin/service.d/syslog-ng.sh +process_name=%(program_name)s +autostart = false +autorestart = true +stdout_logfile=/dev/stdout +stdout_logfile_maxbytes=0 +stderr_logfile=/dev/stderr +stderr_logfile_maxbytes=0 diff --git a/docker/base/ubuntu-15.10/conf/provision/roles/webdevops-base/tasks/bootstrap.yml b/docker/base/ubuntu-15.10/conf/provision/roles/webdevops-base/tasks/bootstrap.yml index 30be03c38..9f842336c 100644 --- a/docker/base/ubuntu-15.10/conf/provision/roles/webdevops-base/tasks/bootstrap.yml +++ b/docker/base/ubuntu-15.10/conf/provision/roles/webdevops-base/tasks/bootstrap.yml @@ -4,6 +4,5 @@ - include: bootstrap/misc.yml - include: bootstrap/root.yml - include: bootstrap/supervisor.yml -- include: bootstrap/syslog-ng.yml -- include: bootstrap/logrotate.yml - include: bootstrap/pam.yml +- include: bootstrap/entrypoint.yml diff --git a/docker/base/ubuntu-15.10/conf/provision/roles/webdevops-base/tasks/bootstrap/entrypoint.yml b/docker/base/ubuntu-15.10/conf/provision/roles/webdevops-base/tasks/bootstrap/entrypoint.yml new file mode 100644 index 000000000..d5d8809f4 --- /dev/null +++ b/docker/base/ubuntu-15.10/conf/provision/roles/webdevops-base/tasks/bootstrap/entrypoint.yml @@ -0,0 +1,8 @@ +--- + +- name: Create link for entrypoint + file: + src: '/opt/docker/bin/entrypoint.sh' + dest: '/entrypoint' + state: link + force: yes diff --git a/docker/base/ubuntu-15.10/conf/provision/roles/webdevops-base/tasks/bootstrap/logrotate.yml b/docker/base/ubuntu-15.10/conf/provision/roles/webdevops-base/tasks/bootstrap/logrotate.yml deleted file mode 100644 index d87926be2..000000000 --- a/docker/base/ubuntu-15.10/conf/provision/roles/webdevops-base/tasks/bootstrap/logrotate.yml +++ /dev/null @@ -1,33 +0,0 @@ ---- - -- name: Configure logrotate running user - lineinfile: - dest: /etc/logrotate.conf - regexp: '^su [-_a-zA-Z0-9]+ [-_a-zA-Z0-9]+' - line: 'su root adm' - -- name: Register logrotate configurations - file: - src: '{{ item }}' - dest: '/etc/logrotate.d/{{ item | basename }}' - state: link - force: yes - with_fileglob: - - /opt/docker/etc/logrotate.d/* - -- name: Remove system logrotates (not needed) - file: - path: '{{ item }}' - state: absent - with_items: - # Debian/Ubuntu - - /etc/cron.daily/logrotate - - /etc/cron.daily/apt-compat - - /etc/cron.daily/dpkg - - /etc/cron.daily/passwd - # RedHat - - /etc/cron.daily/0yum-daily.cron - - /etc/cron.daily/logrotate - - /etc/cron.hourly/0yum-hourly.cron - # Alpine - - /etc/periodic/daily/logrotate diff --git a/docker/base/ubuntu-15.10/conf/provision/roles/webdevops-base/tasks/bootstrap/supervisor.yml b/docker/base/ubuntu-15.10/conf/provision/roles/webdevops-base/tasks/bootstrap/supervisor.yml index bda0394b6..2ce07ac26 100644 --- a/docker/base/ubuntu-15.10/conf/provision/roles/webdevops-base/tasks/bootstrap/supervisor.yml +++ b/docker/base/ubuntu-15.10/conf/provision/roles/webdevops-base/tasks/bootstrap/supervisor.yml @@ -4,3 +4,10 @@ file: path: '/usr/sbin/service' state: absent + +- name: Create link for supervisor.conf + file: + src: '/opt/docker/etc/supervisor.conf' + dest: '/etc/supervisord.conf' + state: link + force: yes diff --git a/docker/base/ubuntu-15.10/conf/provision/roles/webdevops-base/tasks/bootstrap/syslog-ng.yml b/docker/base/ubuntu-15.10/conf/provision/roles/webdevops-base/tasks/bootstrap/syslog-ng.yml deleted file mode 100644 index 27c8f6a30..000000000 --- a/docker/base/ubuntu-15.10/conf/provision/roles/webdevops-base/tasks/bootstrap/syslog-ng.yml +++ /dev/null @@ -1,33 +0,0 @@ ---- - -- name: Get syslog-ng version - shell: "syslog-ng --version | grep -E -e '^syslog-ng[ ]+[0-9]+\\.[0-9]+' | head -n 1 | awk '{print $2}' | cut -f 1,2 -d ." - register: syslogng_version - -- name: Configure syslog-ng (default) - lineinfile: - dest: /etc/default/syslog-ng - regexp: '^[\s]*{{ item.key }}[\s]*=' - line: '{{ item.key }}="{{ item.value }}"' - create: yes - with_items: - - { key: 'SYSLOGNG_OPTS', value: '--no-caps' } - -- name: Enable syslog-ng config - file: - src: '/opt/docker/etc/syslog-ng/syslog-ng.conf' - dest: '/etc/syslog-ng/syslog-ng.conf' - state: link - force: yes - -- name: Set version of syslog-ng file - lineinfile: - dest: '/etc/syslog-ng/syslog-ng.conf' - regexp: '^@version:' - line: '@version: {{ syslogng_version.stdout }}' - -- name: Ensure /var/lib/syslog-ng exists - file: - path: '/var/lib/syslog-ng' - state: directory - recurse: yes diff --git a/docker/base/ubuntu-15.10/conf/provision/roles/webdevops-base/tasks/bootstrap/system.yml b/docker/base/ubuntu-15.10/conf/provision/roles/webdevops-base/tasks/bootstrap/system.yml index 8dfbf9665..0741d7cae 100644 --- a/docker/base/ubuntu-15.10/conf/provision/roles/webdevops-base/tasks/bootstrap/system.yml +++ b/docker/base/ubuntu-15.10/conf/provision/roles/webdevops-base/tasks/bootstrap/system.yml @@ -14,3 +14,20 @@ dest: '/entrypoint.cmd' state: link force: yes + +- name: Remove system logrotate and cronjobs (not needed) + file: + path: '{{ item }}' + state: absent + with_items: + # Debian/Ubuntu + - /etc/cron.daily/logrotate + - /etc/cron.daily/apt-compat + - /etc/cron.daily/dpkg + - /etc/cron.daily/passwd + # RedHat + - /etc/cron.daily/0yum-daily.cron + - /etc/cron.daily/logrotate + - /etc/cron.hourly/0yum-hourly.cron + # Alpine + - /etc/periodic/daily/logrotate diff --git a/docker/php-nginx/alpine-3-php7/conf/etc/nginx/vhost.common.d/.gitkeep b/docker/base/ubuntu-15.10/conf/provision/roles/webdevops-base/tasks/build/.gitkeep similarity index 100% rename from docker/php-nginx/alpine-3-php7/conf/etc/nginx/vhost.common.d/.gitkeep rename to docker/base/ubuntu-15.10/conf/provision/roles/webdevops-base/tasks/build/.gitkeep diff --git a/docker/base/ubuntu-15.10/conf/provision/roles/webdevops-base/tasks/build/logrotate.yml b/docker/base/ubuntu-15.10/conf/provision/roles/webdevops-base/tasks/build/logrotate.yml deleted file mode 100644 index 10f7e6644..000000000 --- a/docker/base/ubuntu-15.10/conf/provision/roles/webdevops-base/tasks/build/logrotate.yml +++ /dev/null @@ -1,10 +0,0 @@ ---- - -- name: Register logrotate configurations - file: - src: '{{ item }}' - dest: '/etc/logrotate.d/{{ item | basename }}' - state: link - force: yes - with_fileglob: - - /opt/docker/etc/logrotate.d/* diff --git a/docker/php-nginx/alpine-3/conf/etc/nginx/conf.d/.gitkeep b/docker/base/ubuntu-15.10/conf/provision/service.d/.gitkeep similarity index 100% rename from docker/php-nginx/alpine-3/conf/etc/nginx/conf.d/.gitkeep rename to docker/base/ubuntu-15.10/conf/provision/service.d/.gitkeep diff --git a/docker/base/ubuntu-15.10/conf/provision/service.d/cron.sh b/docker/base/ubuntu-15.10/conf/provision/service.d/cron.sh new file mode 100644 index 000000000..bd8a54781 --- /dev/null +++ b/docker/base/ubuntu-15.10/conf/provision/service.d/cron.sh @@ -0,0 +1,13 @@ +#!/usr/bin/env bash + +IMAGE_FAMILY=$(docker-image-info family) + +case "$IMAGE_FAMILY" in + Debian|Ubuntu) + apt-install cron + ;; + + RedHat) + yum-install cronie + ;; +esac diff --git a/docker/base/ubuntu-15.10/conf/provision/service.d/dnsmasq.sh b/docker/base/ubuntu-15.10/conf/provision/service.d/dnsmasq.sh new file mode 100644 index 000000000..9e5c3228c --- /dev/null +++ b/docker/base/ubuntu-15.10/conf/provision/service.d/dnsmasq.sh @@ -0,0 +1,24 @@ +#!/usr/bin/env bash + +IMAGE_FAMILY=$(docker-image-info family) + +# Installation +case "$IMAGE_FAMILY" in + Debian|Ubuntu) + apt-install dnsmasq + ;; + + RedHat) + yum-install dnsmasq + ;; + + Alpine) + apk-install dnsmasq + ;; +esac + +# Configuration +go-replace --mode=line \ + -s '^[\s]*user[\s]*=' -r 'user = root' \ + -s '^[\s]*conf-dir[\s]*=' -r 'conf-dir = /etc/dnsmasq.d' \ + -- /etc/dnsmasq.conf diff --git a/docker/base/ubuntu-15.10/conf/provision/service.d/postfix.sh b/docker/base/ubuntu-15.10/conf/provision/service.d/postfix.sh new file mode 100644 index 000000000..ff1879345 --- /dev/null +++ b/docker/base/ubuntu-15.10/conf/provision/service.d/postfix.sh @@ -0,0 +1,28 @@ +#!/usr/bin/env bash + +IMAGE_FAMILY=$(docker-image-info family) + +# Installation +case "$IMAGE_FAMILY" in + Debian|Ubuntu) + apt-install postfix + ;; + + RedHat) + yum-install postfix + ;; + + Alpine) + apk-install postfix + ln -s -f /etc/postfix/aliases /etc/aliases + ;; +esac + +# Configuration +go-replace --mode=line \ + -s '^[\s]*mydestination[\s]*=' -r 'mydestination = ' \ + -s '^[\s]*message_size_limit[\s]*=' -r 'message_size_limit = 15240000' \ + -s '^[\s]*smtp_use_tls[\s]*=' -r 'smtp_use_tls = yes' \ + -s '^[\s]*smtp_tls_security_level[\s]*=' -r 'smtp_tls_security_level = may' \ + -s '^[\s]*myhostname[\s]*=' -r '# myhostname' \ + -- /etc/postfix/main.cf diff --git a/docker/base/ubuntu-15.10/conf/provision/service.d/ssh.sh b/docker/base/ubuntu-15.10/conf/provision/service.d/ssh.sh new file mode 100644 index 000000000..63d7a9f3a --- /dev/null +++ b/docker/base/ubuntu-15.10/conf/provision/service.d/ssh.sh @@ -0,0 +1,17 @@ +#!/usr/bin/env bash + +IMAGE_FAMILY=$(docker-image-info family) + +case "$IMAGE_FAMILY" in + Debian|Ubuntu) + apt-install openssh-server + ;; + + RedHat) + yum-install openssh-server + ;; + + Alpine) + apk-install openssh + ;; +esac diff --git a/docker/base/ubuntu-15.10/conf/provision/service.d/syslog.sh b/docker/base/ubuntu-15.10/conf/provision/service.d/syslog.sh new file mode 100644 index 000000000..7e8b8e0a9 --- /dev/null +++ b/docker/base/ubuntu-15.10/conf/provision/service.d/syslog.sh @@ -0,0 +1,41 @@ +#!/usr/bin/env bash + +IMAGE_FAMILY=$(docker-image-info family) + +# Installation +case "$IMAGE_FAMILY" in + Debian|Ubuntu) + apt-install syslog-ng syslog-ng-core + ;; + + RedHat) + yum-install syslog-ng + + # remove logrotate (not needed for docker) + rm -f "/etc/cron.daily/logrotate" + ;; + + Alpine) + apk-install syslog-ng + ;; +esac + +## Configuration +SYSLOG_NG_VERSION=$(syslog-ng --version | grep -E -e '^syslog-ng[ ]+[0-9]+\.[0-9]+' | head -n 1 | awk '{print $2}' | cut -f 1,2 -d .) + +# Disable caps inside container +if [[ -f /etc/default/syslog-ng ]]; then + go-replace --mode=lineinfile \ + -s "SYSLOGNG_OPTS" -r "SYSLOGNG_OPTS = --no-caps" \ + -- /etc/default/syslog-ng +fi + +# Symlink configuration +ln -s -f /opt/docker/etc/syslog-ng/syslog-ng.conf /etc/syslog-ng/syslog-ng.conf + +go-replace --mode=lineinfile \ + -s "@version" -r "@version: ${SYSLOG_NG_VERSION}" \ + -- /etc/syslog-ng/syslog-ng.conf + +# Ensure /var/lib/syslog-ng exists +mkdir -p /var/lib/syslog-ng diff --git a/docker/base/ubuntu-15.10/conf/provision/variables-webdevops.yml b/docker/base/ubuntu-15.10/conf/provision/variables-webdevops.yml new file mode 100644 index 000000000..0b2a21a95 --- /dev/null +++ b/docker/base/ubuntu-15.10/conf/provision/variables-webdevops.yml @@ -0,0 +1,7 @@ +--- + +docker_image_info_family: "{{ lookup('pipe', 'docker-image-info family') }}" +docker_image_info_distribution: "{{ lookup('pipe', 'docker-image-info dist') }}" +docker_image_info_distribution_version: "{{ lookup('pipe', 'docker-image-info dist-version') }}" +docker_image_info_distribution_release: "{{ lookup('pipe', 'docker-image-info dist-release') }}" +docker_image_info_distribution_codename: "{{ lookup('pipe', 'docker-image-info dist-codename') }}" diff --git a/docker/base/ubuntu-15.10/conf/provision/variables.yml b/docker/base/ubuntu-15.10/conf/provision/variables.yml index ed97d539c..0b2a21a95 100644 --- a/docker/base/ubuntu-15.10/conf/provision/variables.yml +++ b/docker/base/ubuntu-15.10/conf/provision/variables.yml @@ -1 +1,7 @@ --- + +docker_image_info_family: "{{ lookup('pipe', 'docker-image-info family') }}" +docker_image_info_distribution: "{{ lookup('pipe', 'docker-image-info dist') }}" +docker_image_info_distribution_version: "{{ lookup('pipe', 'docker-image-info dist-version') }}" +docker_image_info_distribution_release: "{{ lookup('pipe', 'docker-image-info dist-release') }}" +docker_image_info_distribution_codename: "{{ lookup('pipe', 'docker-image-info dist-codename') }}" diff --git a/docker/base/ubuntu-16.04/Dockerfile b/docker/base/ubuntu-16.04/Dockerfile index 4e9ac241d..14468bc67 100644 --- a/docker/base/ubuntu-16.04/Dockerfile +++ b/docker/base/ubuntu-16.04/Dockerfile @@ -5,31 +5,47 @@ FROM webdevops/bootstrap:ubuntu-16.04 -MAINTAINER info@webdevops.io -LABEL vendor=WebDevOps.io -LABEL io.webdevops.layout=8 -LABEL io.webdevops.version=1.5.0 - -ENV DOCKER_CONF_HOME /opt/docker/ +ENV DOCKER_CONF_HOME=/opt/docker/ \ + LOG_STDOUT="" \ + LOG_STDERR="" COPY conf/ /opt/docker/ +# Install ansible +RUN /usr/local/bin/apt-install \ + python-minimal \ + python-setuptools \ + python-pip \ + python-paramiko \ + python-jinja2 \ + python-dev \ + libffi-dev \ + libssl-dev \ + build-essential \ + && pip install --upgrade pip \ + && hash -r \ + && pip install --no-cache-dir ansible \ + && chmod 750 /usr/local/bin/ansible* \ + # Cleanup + && apt-get purge -y -f --force-yes \ + python-dev \ + build-essential \ + libssl-dev \ + libffi-dev \ + && docker-image-cleanup + # Install services RUN chmod +x /opt/docker/bin/* \ && /usr/local/bin/apt-install \ supervisor \ - syslog-ng \ - syslog-ng-core \ - logrotate \ - cron \ wget \ curl \ net-tools \ gnupg \ && chmod +s /usr/local/bin/gosu \ && /opt/docker/bin/provision run --tag bootstrap --role webdevops-base \ - && /opt/docker/bin/bootstrap.sh - + && /opt/docker/bin/bootstrap.sh \ + && docker-image-cleanup ENTRYPOINT ["/opt/docker/bin/entrypoint.sh"] CMD ["supervisord"] diff --git a/docker/base/ubuntu-16.04/Dockerfile.jinja2 b/docker/base/ubuntu-16.04/Dockerfile.jinja2 index b96158a0a..ddcaacb01 100644 --- a/docker/base/ubuntu-16.04/Dockerfile.jinja2 +++ b/docker/base/ubuntu-16.04/Dockerfile.jinja2 @@ -1,11 +1,11 @@ {{ docker.from("bootstrap", "ubuntu-16.04") }} -{{ docker.version() }} - -{{ environment.homePath() }} +{{ environment.base() }} {{ docker.copy('conf/', '/opt/docker/') }} +{{ ansible.ubuntu() }} + {{ base.ubuntu() }} {{ docker.entrypoint("/opt/docker/bin/entrypoint.sh") }} diff --git a/docker/base/ubuntu-16.04/conf/bin/bootstrap.sh b/docker/base/ubuntu-16.04/conf/bin/bootstrap.sh index 1d1a30f72..855c10782 100644 --- a/docker/base/ubuntu-16.04/conf/bin/bootstrap.sh +++ b/docker/base/ubuntu-16.04/conf/bin/bootstrap.sh @@ -17,10 +17,16 @@ rootCheck "$0" # Save the buildtime date +%s > /opt/docker/BUILDTIME +date +%s >/opt/docker/etc/.registry/image_info_buildtime # Make all scripts executable find /opt/docker/bin/ -type f -iname '*.sh' -print0 | xargs --no-run-if-empty -0 chmod +x +# Enable usr-bin executables +find /opt/docker/bin/usr-bin -type f | while read USR_BIN_FILE; do + chmod +x -- "$USR_BIN_FILE" + ln -n -f -- "$USR_BIN_FILE" "/usr/local/bin/$(basename "$USR_BIN_FILE")" +done case "$BOOTSTRAP_MODE" in ################################### @@ -44,6 +50,23 @@ case "$BOOTSTRAP_MODE" in echo "[ERROR] Bootstrap mode '$BOOTSTRAP_MODE' not defined" exit 1 ;; - esac + +###################### +# Check if entrypoint provisioning is available +###################### + +echo "Checking provision status..." +for PROVISION_TAG in onbuild build bootstrap entrypoint; do + ROLES=$(docker-provision list --tag "$PROVISION_TAG") + if [[ -n "$ROLES" ]]; then + PROVISION_ROLE_COUNT=$(echo "$ROLES" | wc -l) + echo " - found ${PROVISION_ROLE_COUNT} for provision tag ${PROVISION_TAG}, caching info for execution" + echo -n "$PROVISION_ROLE_COUNT" > "/opt/docker/etc/.registry/provision-availale.${PROVISION_TAG}" + else + echo " - no roles found for provision tag ${PROVISION_TAG}" + echo -n '' > "/opt/docker/etc/.registry/provision-availale.${PROVISION_TAG}" + fi +done + diff --git a/docker/base/ubuntu-16.04/conf/bin/config.sh b/docker/base/ubuntu-16.04/conf/bin/config.sh index 3155728e8..049756c26 100644 --- a/docker/base/ubuntu-16.04/conf/bin/config.sh +++ b/docker/base/ubuntu-16.04/conf/bin/config.sh @@ -15,44 +15,23 @@ function rootCheck() { } ### - # Create named pipe - # - # $1 -> name of file + # Create /docker.stdout and /docker.stderr # ## -function createNamedPipe() { - rm --force -- "$1" - mknod "$1" p -} - -### - # Escape value for sed usage - # - # $1 -> value - # STDOUT -> escaped value - # - ## -function sedEscape() { - echo "$(echo $* |sed -e 's/[]\/$*.^|[]/\\&/g')" -} +function createDockerStdoutStderr() { + # link stdout from docker + if [[ -z "$LOG_STDOUT" ]]; then + LOG_STDOUT="/proc/$$/fd/1" + fi -### - # Replace text inside a file - # - # $1 -> source value - # $2 -> target value - # $3 -> path to file - # - ## -function replaceTextInFile() { - SOURCE="$(sedEscape $1)" - REPLACE="$(sedEscape $2)" - TARGET="$3" + if [[ -z "$LOG_STDERR" ]]; then + LOG_STDERR="/proc/$$/fd/2" + fi - sed -i "s/${SOURCE}/${REPLACE}/" "${TARGET}" + ln -f -s "$LOG_STDOUT" /docker.stdout + ln -f -s "$LOG_STDERR" /docker.stderr + chmod 600 /docker.stdout /docker.stderr } - - ### # Include script directory text inside a file # @@ -104,7 +83,7 @@ function runEntrypoints() { . /opt/docker/bin/entrypoint.d/default.sh fi - exit + exit 1 } ### @@ -161,6 +140,12 @@ function runProvisionEntrypoint() { function runDockerProvision() { ANSIBLE_TAG="$1" - /opt/docker/bin/provision run --tag "$ANSIBLE_TAG" --use-registry + PROVISION_STATS_FILE="/opt/docker/etc/.registry/provision-stats.${ANSIBLE_TAG}" + + # run provision if stats file doesn't exists (unknown mode) + # or if stats file is not empty + if [[ ! -f "$PROVISION_STATS_FILE" ]] || [[ -s "$PROVISION_STATS_FILE" ]]; then + /opt/docker/bin/provision run --tag "${ANSIBLE_TAG}" --use-registry + fi } diff --git a/docker/base/ubuntu-16.04/conf/bin/control.sh b/docker/base/ubuntu-16.04/conf/bin/control.sh index a6697092d..22d189745 100644 --- a/docker/base/ubuntu-16.04/conf/bin/control.sh +++ b/docker/base/ubuntu-16.04/conf/bin/control.sh @@ -101,23 +101,13 @@ case "$CONTROL_COMMAND" in ## ------------------------------------------ "service.enable") - SERVICE_FILE="/opt/docker/etc/supervisor.d/$1.conf" - if [ -f "$SERVICE_FILE" ]; then - sed -i '/autostart = /c\autostart = true' -- "$SERVICE_FILE" - else - echo "[ERROR] Service '${1}' not found (tried ${SERVICE_FILE})" - exit 1 - fi + deprecationNotice " Please use >>docker-service-enable [service]<<" + docker-service-enable "$1" ;; "service.disable") - SERVICE_FILE="/opt/docker/etc/supervisor.d/$1.conf" - if [ -f "$SERVICE_FILE" ]; then - sed -i '/autostart = /c\autostart = false' -- "$SERVICE_FILE" - else - echo "[ERROR] Service '${1}' not found (tried ${SERVICE_FILE})" - exit 1 - fi + deprecationNotice " Please use >>docker-service-disable [service]<<" + docker-service-disable "$1" ;; ## ------------------------------------------ diff --git a/docker/base/ubuntu-16.04/conf/bin/entrypoint.d/cli.sh b/docker/base/ubuntu-16.04/conf/bin/entrypoint.d/cli.sh index 2ca68926c..fe212a8ea 100644 --- a/docker/base/ubuntu-16.04/conf/bin/entrypoint.d/cli.sh +++ b/docker/base/ubuntu-16.04/conf/bin/entrypoint.d/cli.sh @@ -8,7 +8,7 @@ if [ -n "${CLI_SCRIPT}" ]; then if [ -n "$APPLICATION_USER" ]; then # Run as EFFECTIVE_USER shift - exec sudo -H -E -u "${APPLICATION_USER}" ${CLI_SCRIPT} "$@" + exec gosu "${APPLICATION_USER}" ${CLI_SCRIPT} "$@" else # Run as root exec ${CLI_SCRIPT} "$@" diff --git a/docker/base/ubuntu-16.04/conf/bin/entrypoint.d/noop.sh b/docker/base/ubuntu-16.04/conf/bin/entrypoint.d/noop.sh index 967920837..092d55d8b 100644 --- a/docker/base/ubuntu-16.04/conf/bin/entrypoint.d/noop.sh +++ b/docker/base/ubuntu-16.04/conf/bin/entrypoint.d/noop.sh @@ -4,5 +4,4 @@ ## NOOP (no operation) ############################################# -tail -f /dev/null -exit +exec tail -f /dev/null diff --git a/docker/base/ubuntu-16.04/conf/bin/entrypoint.d/supervisord.sh b/docker/base/ubuntu-16.04/conf/bin/entrypoint.d/supervisord.sh index ead991551..f21489667 100644 --- a/docker/base/ubuntu-16.04/conf/bin/entrypoint.d/supervisord.sh +++ b/docker/base/ubuntu-16.04/conf/bin/entrypoint.d/supervisord.sh @@ -4,8 +4,6 @@ ## Supervisord (start daemons) ############################################# -rootCheck "supervisord" - ## Start services exec /opt/docker/bin/service.d/supervisor.sh diff --git a/docker/base/ubuntu-16.04/conf/bin/entrypoint.sh b/docker/base/ubuntu-16.04/conf/bin/entrypoint.sh index bbabcdddb..01f59660c 100644 --- a/docker/base/ubuntu-16.04/conf/bin/entrypoint.sh +++ b/docker/base/ubuntu-16.04/conf/bin/entrypoint.sh @@ -20,16 +20,13 @@ chmod -s /usr/local/bin/gosu trap 'echo sigterm ; exit' SIGTERM trap 'echo sigkill ; exit' SIGKILL -# link stdout from docker -ln -f -s "/proc/$$/fd/1" /docker.stdout -ln -f -s "/proc/$$/fd/2" /docker.stderr -chmod 600 /docker.stdout /docker.stderr - # sanitize input and set task TASK="$(echo $1| sed 's/[^-_a-zA-Z0-9]*//g')" source /opt/docker/bin/config.sh +createDockerStdoutStderr + if [[ "$UID" -eq 0 ]]; then # Only run provision if user is root diff --git a/docker/base/ubuntu-16.04/conf/bin/logwatch.sh b/docker/base/ubuntu-16.04/conf/bin/logwatch.sh deleted file mode 100644 index 1a5b486c7..000000000 --- a/docker/base/ubuntu-16.04/conf/bin/logwatch.sh +++ /dev/null @@ -1,14 +0,0 @@ -#!/usr/bin/env bash - -set -o pipefail # trace ERR through pipes -set -o errtrace # trace ERR through 'time command' and other functions -set -o nounset ## set -u : exit the script if you try to use an uninitialised variable -set -o errexit ## set -e : exit the script if any statement returns a non-true return value - -sleep 0.5 - -if [ -p "$2" ]; then - sed --unbuffered -e "s/^/\[$1\] /" -- "$2" -else - tail -n 0 -F -q "$2" | sed --unbuffered -e "s/^/\[$1\] /" -fi diff --git a/docker/base/ubuntu-16.04/conf/bin/provision b/docker/base/ubuntu-16.04/conf/bin/provision index f7b5ad0a8..d367c2812 100755 --- a/docker/base/ubuntu-16.04/conf/bin/provision +++ b/docker/base/ubuntu-16.04/conf/bin/provision @@ -19,6 +19,7 @@ PLAYBOOK = Template( - hosts: all vars_files: + - ./variables-webdevops.yml - ./variables.yml roles: - $roles @@ -188,7 +189,7 @@ def actionAdd(args): 'priority': args.priority } - saveJson(json); + saveJson(json) diff --git a/docker/base/ubuntu-16.04/conf/bin/provision.sh b/docker/base/ubuntu-16.04/conf/bin/provision.sh deleted file mode 100644 index 4079dd7f0..000000000 --- a/docker/base/ubuntu-16.04/conf/bin/provision.sh +++ /dev/null @@ -1,30 +0,0 @@ - #!/usr/bin/env bash - -# -# Example: -# provision.sh /opt/foobar/playbook.yml tag -# -# - -set -o pipefail # trace ERR through pipes -set -o errtrace # trace ERR through 'time command' and other functions -set -o nounset ## set -u : exit the script if you try to use an uninitialised variable -set -o errexit ## set -e : exit the script if any statement returns a non-true return value - -. config.sh - -deprecationNotice " Please use >>/opt/docker/bin/provision run --playbook playbook.yml --tag=bootstrap [args]<< for running provision" - - -if [ "$#" -lt 2 ]; then - echo "[ERROR] $0: Playbook or tag is missing" - exit 1 -fi - -ANSIBLE_PLAYBOOK="$1" -shift -ANSIBLE_TAG="$1" -shift -ANSIBLE_OPTS="$@" - -/opt/docker/bin/provision run --playbook "${ANSIBLE_PLAYBOOK}" --use-registry --tag "${ANSIBLE_TAG}" $ANSIBLE_OPTS diff --git a/docker/base-app/ubuntu-16.04/conf/bin/service.d/dnsmasq.d/10-init.sh b/docker/base/ubuntu-16.04/conf/bin/service.d/dnsmasq.d/10-init.sh similarity index 100% rename from docker/base-app/ubuntu-16.04/conf/bin/service.d/dnsmasq.d/10-init.sh rename to docker/base/ubuntu-16.04/conf/bin/service.d/dnsmasq.d/10-init.sh diff --git a/docker/base-app/ubuntu-16.04/conf/bin/service.d/dnsmasq.sh b/docker/base/ubuntu-16.04/conf/bin/service.d/dnsmasq.sh similarity index 100% rename from docker/base-app/ubuntu-16.04/conf/bin/service.d/dnsmasq.sh rename to docker/base/ubuntu-16.04/conf/bin/service.d/dnsmasq.sh diff --git a/docker/base/ubuntu-16.04/conf/bin/service.d/postfix.d/10-init.sh b/docker/base/ubuntu-16.04/conf/bin/service.d/postfix.d/10-init.sh new file mode 100644 index 000000000..cfd876955 --- /dev/null +++ b/docker/base/ubuntu-16.04/conf/bin/service.d/postfix.d/10-init.sh @@ -0,0 +1,27 @@ +# force new copy of hosts there (otherwise links could be outdated) +mkdir -p /var/spool/postfix/etc +cp -f /etc/hosts /var/spool/postfix/etc/hosts +cp -f /etc/resolv.conf /var/spool/postfix/etc/resolv.conf +cp -f /etc/services /var/spool/postfix/etc/services + +## MYHOSTNAME +# replace line +sed -i '/myhostname[ ]* =/c\' main.cf +echo "myhostname = $(hostname)" >> /etc/postfix/main.cf + +## REPLAYHOST +if [[ -n "${POSTFIX_RELAYHOST+x}" ]]; then + # replace line + sed -i '/relayhost[ ]* =/c\' main.cf + echo "relayhost = $POSTFIX_RELAYHOST" >> /etc/postfix/main.cf +fi + +## MYNETWORKS +if [[ -n "${POSTFIX_MYNETWORKS+x}" ]]; then + # replace line + sed -i '/mynetworks[ ]* =/c\' main.cf + echo "mynetworks = $POSTFIX_MYNETWORKS" >> /etc/postfix/main.cf +fi + +# generate aliases db +newaliases || : diff --git a/docker/base-app/ubuntu-16.04/conf/bin/service.d/postfix.sh b/docker/base/ubuntu-16.04/conf/bin/service.d/postfix.sh similarity index 100% rename from docker/base-app/ubuntu-16.04/conf/bin/service.d/postfix.sh rename to docker/base/ubuntu-16.04/conf/bin/service.d/postfix.sh diff --git a/docker/base/ubuntu-16.04/conf/bin/service.d/ssh.d/10-init.sh b/docker/base/ubuntu-16.04/conf/bin/service.d/ssh.d/10-init.sh new file mode 100644 index 000000000..f2b600312 --- /dev/null +++ b/docker/base/ubuntu-16.04/conf/bin/service.d/ssh.d/10-init.sh @@ -0,0 +1,7 @@ +# Init ssh privilege separation directory +mkdir -p /var/run/sshd +chown root:root /var/run/sshd +chmod 755 /var/run/sshd + +# generate host keys +ssh-keygen -A diff --git a/docker/base-app/ubuntu-16.04/conf/bin/service.d/ssh.sh b/docker/base/ubuntu-16.04/conf/bin/service.d/ssh.sh similarity index 100% rename from docker/base-app/ubuntu-16.04/conf/bin/service.d/ssh.sh rename to docker/base/ubuntu-16.04/conf/bin/service.d/ssh.sh diff --git a/docker/base/ubuntu-16.04/conf/bin/service.d/syslog-ng.d/10-init.sh b/docker/base/ubuntu-16.04/conf/bin/service.d/syslog-ng.d/10-init.sh index 22621d2ad..326207e52 100644 --- a/docker/base/ubuntu-16.04/conf/bin/service.d/syslog-ng.d/10-init.sh +++ b/docker/base/ubuntu-16.04/conf/bin/service.d/syslog-ng.d/10-init.sh @@ -6,5 +6,5 @@ if [ ! -S /var/lib/syslog-ng/syslog-ng.ctl ]; then rm -f /var/lib/syslog-ng/sysl if [[ ! -p /docker.stdout ]]; then # Switch to file (tty docker mode) - rpl --quiet 'pipe("/docker.stdout")' 'file("/docker.stdout")' -- /opt/docker/etc/syslog-ng/syslog-ng.conf > /dev/null + go-replace -s 'pipe("/docker.stdout")' -r 'file("/docker.stdout")' -- /opt/docker/etc/syslog-ng/syslog-ng.conf fi diff --git a/docker/base/ubuntu-16.04/conf/bin/usr-bin/docker-provision b/docker/base/ubuntu-16.04/conf/bin/usr-bin/docker-provision new file mode 100644 index 000000000..4ee715c64 --- /dev/null +++ b/docker/base/ubuntu-16.04/conf/bin/usr-bin/docker-provision @@ -0,0 +1,9 @@ +#!/usr/bin/env bash + +set -o pipefail # trace ERR through pipes +set -o errtrace # trace ERR through 'time command' and other functions +set -o nounset ## set -u : exit the script if you try to use an uninitialised variable +set -o errexit ## set -e : exit the script if any statement returns a non-true return value + +# wrapper +exec /opt/docker/bin/provision "$@" diff --git a/docker/base/ubuntu-16.04/conf/bin/usr-bin/docker-service-disable b/docker/base/ubuntu-16.04/conf/bin/usr-bin/docker-service-disable new file mode 100644 index 000000000..2b5b31bb4 --- /dev/null +++ b/docker/base/ubuntu-16.04/conf/bin/usr-bin/docker-service-disable @@ -0,0 +1,30 @@ +#!/usr/bin/env bash + +set -o pipefail # trace ERR through pipes +set -o errtrace # trace ERR through 'time command' and other functions +set -o nounset ## set -u : exit the script if you try to use an uninitialised variable +set -o errexit ## set -e : exit the script if any statement returns a non-true return value + +source /opt/docker/bin/config.sh + +rootCheck "$0" + +if [[ "$#" -eq 0 ]]; then + echo "Usage: $0 " + exit 1 +fi + +for SERVICE in "$@"; do + SERVICE_FILE="/opt/docker/etc/supervisor.d/${SERVICE}.conf" + + ## Disable service + if [[ -f "$SERVICE_FILE" ]]; then + go-replace --mode=lineinfile \ + -s 'autostart =' -r 'autostart = false' \ + -- "$SERVICE_FILE" + else + echo "[ERROR] Service '${SERVICE}' not found (tried ${SERVICE_FILE})" + exit 1 + fi +done + diff --git a/docker/base/ubuntu-16.04/conf/bin/usr-bin/docker-service-enable b/docker/base/ubuntu-16.04/conf/bin/usr-bin/docker-service-enable new file mode 100644 index 000000000..8d36a14a9 --- /dev/null +++ b/docker/base/ubuntu-16.04/conf/bin/usr-bin/docker-service-enable @@ -0,0 +1,41 @@ +#!/usr/bin/env bash + +set -o pipefail # trace ERR through pipes +set -o errtrace # trace ERR through 'time command' and other functions +set -o nounset ## set -u : exit the script if you try to use an uninitialised variable +set -o errexit ## set -e : exit the script if any statement returns a non-true return value + +source /opt/docker/bin/config.sh + +rootCheck "$0" + +if [[ "$#" -eq 0 ]]; then + echo "Usage: $0 " + exit 1 +fi + +for SERVICE in "$@"; do + SERVICE_FILE="/opt/docker/etc/supervisor.d/${SERVICE}.conf" + PROVISION_FILE="/opt/docker/provision/service.d/${SERVICE}.sh" + + # Run on demand installation/provisioning + if [[ -f "$PROVISION_FILE" ]]; then + echo "Running provisioning for ${SERVICE}, please wait..." + + ## execute scripts + . "$PROVISION_FILE" + + ## remove directory (one run time) + rm -f -- "$PROVISION_FILE" + fi + + ## Enable service + if [[ -f "$SERVICE_FILE" ]]; then + go-replace --mode=lineinfile \ + -s 'autostart =' -r 'autostart = true' \ + -- "$SERVICE_FILE" + else + echo "[ERROR] Service '${SERVICE}' not found (tried ${SERVICE_FILE})" + exit 1 + fi +done diff --git a/docker/base/ubuntu-16.04/conf/bin/usr-bin/service b/docker/base/ubuntu-16.04/conf/bin/usr-bin/service new file mode 100755 index 000000000..55ea12bf7 --- /dev/null +++ b/docker/base/ubuntu-16.04/conf/bin/usr-bin/service @@ -0,0 +1,86 @@ +#!/bin/bash + +set -o pipefail # trace ERR through pipes +set -o errtrace # trace ERR through 'time command' and other functions +set -o nounset ## set -u : exit the script if you try to use an uninitialised variable +set -o errexit ## set -e : exit the script if any statement returns a non-true return value + +# Root check +if [ "$(/usr/bin/whoami)" != "root" ]; then + echo "[ERROR] Must be run as root" + exit 1 +fi + +function serviceHelp() { + echo "Usage: $(basename "$0") " +} + +function getServicePid() { + local serviceName="$1" + local servicePid=$(supervisorctl pid "${serviceName}:${serviceName}d") + + if [[ -z "$servicePid" ]] || [[ "$servicePid" == "0" ]]; then + echo "not running" + exit 1 + fi + + echo $servicePid +} + +# Param check +if [ "$#" -lt 2 ]; then + echo "[ERROR] Missing parameters" + serviceHelp + exit 1 +fi + +############################# +# Param init +############################# + +SERVICENAME="$1" +ACTION="$2" + +############################# +# Service aliases +############################# +case "$SERVICENAME" in + apache2|httpd) + SERVICENAME="apache" + ;; +esac + +############################# +# Action runner +############################# +case "$ACTION" in + stop|start|restart|status) + exec supervisorctl "$ACTION" "${SERVICENAME}:${SERVICENAME}d" + ;; + + pid) + echo $(getServicePid "${SERVICENAME}") + ;; + + check) + FIRST_PID=$(getServicePid "${SERVICENAME}") + sleep 5 + SECOND_PID=$(getServicePid "${SERVICENAME}") + + if [[ "$FIRST_PID" == "$SECOND_PID" ]]; then + echo "ok" + exit 0 + else + echo "not running" + exit 1 + fi + ;; + + + *) + echo "[ERROR] Invalid action" + serviceHelp + exit 1 + ;; + +esac diff --git a/docker/base/ubuntu-16.04/conf/etc/supervisor.conf b/docker/base/ubuntu-16.04/conf/etc/supervisor.conf index 7c109515a..479e0db08 100644 --- a/docker/base/ubuntu-16.04/conf/etc/supervisor.conf +++ b/docker/base/ubuntu-16.04/conf/etc/supervisor.conf @@ -2,9 +2,16 @@ nodaemon=true [unix_http_server] -file = /var/run/supervisor.sock -# username = root -# password = {SHA}e982f17bcbe0f724063b708a4f76db211a999304 +file = /.supervisor.sock +chmod = 0700 +chown = root:root +username = root +password = {SHA}e982f17bcbe0f724063b708a4f76db211a999304 + +[supervisorctl] +serverurl = unix:///.supervisor.sock +username = root +password = docker [rpcinterface:supervisor] supervisor.rpcinterface_factory = supervisor.rpcinterface:make_main_rpcinterface diff --git a/docker/base/ubuntu-16.04/conf/etc/supervisor.d/dnsmasq.conf b/docker/base/ubuntu-16.04/conf/etc/supervisor.d/dnsmasq.conf new file mode 100644 index 000000000..9832ffca7 --- /dev/null +++ b/docker/base/ubuntu-16.04/conf/etc/supervisor.d/dnsmasq.conf @@ -0,0 +1,14 @@ +[group:dnsmasq] +programs=dnsmasqd +priority=15 + +[program:dnsmasqd] +command = /opt/docker/bin/service.d/dnsmasq.sh +process_name=%(program_name)s +startsecs = 0 +autostart = false +autorestart = true +stdout_logfile=/dev/stdout +stdout_logfile_maxbytes=0 +stderr_logfile=/dev/stderr +stderr_logfile_maxbytes=0 diff --git a/docker/base-app/ubuntu-16.04/conf/etc/supervisor.d/postfix.conf b/docker/base/ubuntu-16.04/conf/etc/supervisor.d/postfix.conf similarity index 100% rename from docker/base-app/ubuntu-16.04/conf/etc/supervisor.d/postfix.conf rename to docker/base/ubuntu-16.04/conf/etc/supervisor.d/postfix.conf diff --git a/docker/base-app/ubuntu-16.04/conf/etc/supervisor.d/ssh.conf b/docker/base/ubuntu-16.04/conf/etc/supervisor.d/ssh.conf similarity index 100% rename from docker/base-app/ubuntu-16.04/conf/etc/supervisor.d/ssh.conf rename to docker/base/ubuntu-16.04/conf/etc/supervisor.d/ssh.conf diff --git a/docker/base/ubuntu-16.04/conf/etc/supervisor.d/syslog-ng.conf b/docker/base/ubuntu-16.04/conf/etc/supervisor.d/syslog-ng.conf deleted file mode 100644 index 247fd1a25..000000000 --- a/docker/base/ubuntu-16.04/conf/etc/supervisor.d/syslog-ng.conf +++ /dev/null @@ -1,13 +0,0 @@ -[group:syslog] -programs=syslogd -priority=10 - -[program:syslogd] -command = /opt/docker/bin/service.d/syslog-ng.sh -process_name=%(program_name)s -autostart = true -autorestart = true -stdout_logfile=/dev/stdout -stdout_logfile_maxbytes=0 -stderr_logfile=/dev/stderr -stderr_logfile_maxbytes=0 diff --git a/docker/base/ubuntu-16.04/conf/etc/supervisor.d/syslog.conf b/docker/base/ubuntu-16.04/conf/etc/supervisor.d/syslog.conf new file mode 100644 index 000000000..20d1e238c --- /dev/null +++ b/docker/base/ubuntu-16.04/conf/etc/supervisor.d/syslog.conf @@ -0,0 +1,13 @@ +[group:syslog] +programs=syslogd +priority=10 + +[program:syslogd] +command = /opt/docker/bin/service.d/syslog-ng.sh +process_name=%(program_name)s +autostart = false +autorestart = true +stdout_logfile=/dev/stdout +stdout_logfile_maxbytes=0 +stderr_logfile=/dev/stderr +stderr_logfile_maxbytes=0 diff --git a/docker/base/ubuntu-16.04/conf/provision/roles/webdevops-base/tasks/bootstrap.yml b/docker/base/ubuntu-16.04/conf/provision/roles/webdevops-base/tasks/bootstrap.yml index 30be03c38..9f842336c 100644 --- a/docker/base/ubuntu-16.04/conf/provision/roles/webdevops-base/tasks/bootstrap.yml +++ b/docker/base/ubuntu-16.04/conf/provision/roles/webdevops-base/tasks/bootstrap.yml @@ -4,6 +4,5 @@ - include: bootstrap/misc.yml - include: bootstrap/root.yml - include: bootstrap/supervisor.yml -- include: bootstrap/syslog-ng.yml -- include: bootstrap/logrotate.yml - include: bootstrap/pam.yml +- include: bootstrap/entrypoint.yml diff --git a/docker/base/ubuntu-16.04/conf/provision/roles/webdevops-base/tasks/bootstrap/entrypoint.yml b/docker/base/ubuntu-16.04/conf/provision/roles/webdevops-base/tasks/bootstrap/entrypoint.yml new file mode 100644 index 000000000..d5d8809f4 --- /dev/null +++ b/docker/base/ubuntu-16.04/conf/provision/roles/webdevops-base/tasks/bootstrap/entrypoint.yml @@ -0,0 +1,8 @@ +--- + +- name: Create link for entrypoint + file: + src: '/opt/docker/bin/entrypoint.sh' + dest: '/entrypoint' + state: link + force: yes diff --git a/docker/base/ubuntu-16.04/conf/provision/roles/webdevops-base/tasks/bootstrap/logrotate.yml b/docker/base/ubuntu-16.04/conf/provision/roles/webdevops-base/tasks/bootstrap/logrotate.yml deleted file mode 100644 index d87926be2..000000000 --- a/docker/base/ubuntu-16.04/conf/provision/roles/webdevops-base/tasks/bootstrap/logrotate.yml +++ /dev/null @@ -1,33 +0,0 @@ ---- - -- name: Configure logrotate running user - lineinfile: - dest: /etc/logrotate.conf - regexp: '^su [-_a-zA-Z0-9]+ [-_a-zA-Z0-9]+' - line: 'su root adm' - -- name: Register logrotate configurations - file: - src: '{{ item }}' - dest: '/etc/logrotate.d/{{ item | basename }}' - state: link - force: yes - with_fileglob: - - /opt/docker/etc/logrotate.d/* - -- name: Remove system logrotates (not needed) - file: - path: '{{ item }}' - state: absent - with_items: - # Debian/Ubuntu - - /etc/cron.daily/logrotate - - /etc/cron.daily/apt-compat - - /etc/cron.daily/dpkg - - /etc/cron.daily/passwd - # RedHat - - /etc/cron.daily/0yum-daily.cron - - /etc/cron.daily/logrotate - - /etc/cron.hourly/0yum-hourly.cron - # Alpine - - /etc/periodic/daily/logrotate diff --git a/docker/base/ubuntu-16.04/conf/provision/roles/webdevops-base/tasks/bootstrap/supervisor.yml b/docker/base/ubuntu-16.04/conf/provision/roles/webdevops-base/tasks/bootstrap/supervisor.yml index bda0394b6..2ce07ac26 100644 --- a/docker/base/ubuntu-16.04/conf/provision/roles/webdevops-base/tasks/bootstrap/supervisor.yml +++ b/docker/base/ubuntu-16.04/conf/provision/roles/webdevops-base/tasks/bootstrap/supervisor.yml @@ -4,3 +4,10 @@ file: path: '/usr/sbin/service' state: absent + +- name: Create link for supervisor.conf + file: + src: '/opt/docker/etc/supervisor.conf' + dest: '/etc/supervisord.conf' + state: link + force: yes diff --git a/docker/base/ubuntu-16.04/conf/provision/roles/webdevops-base/tasks/bootstrap/syslog-ng.yml b/docker/base/ubuntu-16.04/conf/provision/roles/webdevops-base/tasks/bootstrap/syslog-ng.yml deleted file mode 100644 index 27c8f6a30..000000000 --- a/docker/base/ubuntu-16.04/conf/provision/roles/webdevops-base/tasks/bootstrap/syslog-ng.yml +++ /dev/null @@ -1,33 +0,0 @@ ---- - -- name: Get syslog-ng version - shell: "syslog-ng --version | grep -E -e '^syslog-ng[ ]+[0-9]+\\.[0-9]+' | head -n 1 | awk '{print $2}' | cut -f 1,2 -d ." - register: syslogng_version - -- name: Configure syslog-ng (default) - lineinfile: - dest: /etc/default/syslog-ng - regexp: '^[\s]*{{ item.key }}[\s]*=' - line: '{{ item.key }}="{{ item.value }}"' - create: yes - with_items: - - { key: 'SYSLOGNG_OPTS', value: '--no-caps' } - -- name: Enable syslog-ng config - file: - src: '/opt/docker/etc/syslog-ng/syslog-ng.conf' - dest: '/etc/syslog-ng/syslog-ng.conf' - state: link - force: yes - -- name: Set version of syslog-ng file - lineinfile: - dest: '/etc/syslog-ng/syslog-ng.conf' - regexp: '^@version:' - line: '@version: {{ syslogng_version.stdout }}' - -- name: Ensure /var/lib/syslog-ng exists - file: - path: '/var/lib/syslog-ng' - state: directory - recurse: yes diff --git a/docker/base/ubuntu-16.04/conf/provision/roles/webdevops-base/tasks/bootstrap/system.yml b/docker/base/ubuntu-16.04/conf/provision/roles/webdevops-base/tasks/bootstrap/system.yml index 8dfbf9665..0741d7cae 100644 --- a/docker/base/ubuntu-16.04/conf/provision/roles/webdevops-base/tasks/bootstrap/system.yml +++ b/docker/base/ubuntu-16.04/conf/provision/roles/webdevops-base/tasks/bootstrap/system.yml @@ -14,3 +14,20 @@ dest: '/entrypoint.cmd' state: link force: yes + +- name: Remove system logrotate and cronjobs (not needed) + file: + path: '{{ item }}' + state: absent + with_items: + # Debian/Ubuntu + - /etc/cron.daily/logrotate + - /etc/cron.daily/apt-compat + - /etc/cron.daily/dpkg + - /etc/cron.daily/passwd + # RedHat + - /etc/cron.daily/0yum-daily.cron + - /etc/cron.daily/logrotate + - /etc/cron.hourly/0yum-hourly.cron + # Alpine + - /etc/periodic/daily/logrotate diff --git a/docker/php-nginx/alpine-3/conf/etc/nginx/vhost.common.d/.gitkeep b/docker/base/ubuntu-16.04/conf/provision/roles/webdevops-base/tasks/build/.gitkeep similarity index 100% rename from docker/php-nginx/alpine-3/conf/etc/nginx/vhost.common.d/.gitkeep rename to docker/base/ubuntu-16.04/conf/provision/roles/webdevops-base/tasks/build/.gitkeep diff --git a/docker/base/ubuntu-16.04/conf/provision/roles/webdevops-base/tasks/build/logrotate.yml b/docker/base/ubuntu-16.04/conf/provision/roles/webdevops-base/tasks/build/logrotate.yml deleted file mode 100644 index 10f7e6644..000000000 --- a/docker/base/ubuntu-16.04/conf/provision/roles/webdevops-base/tasks/build/logrotate.yml +++ /dev/null @@ -1,10 +0,0 @@ ---- - -- name: Register logrotate configurations - file: - src: '{{ item }}' - dest: '/etc/logrotate.d/{{ item | basename }}' - state: link - force: yes - with_fileglob: - - /opt/docker/etc/logrotate.d/* diff --git a/docker/php/alpine-3-php7/conf/etc/php/conf.d/.gitkeep b/docker/base/ubuntu-16.04/conf/provision/service.d/.gitkeep similarity index 100% rename from docker/php/alpine-3-php7/conf/etc/php/conf.d/.gitkeep rename to docker/base/ubuntu-16.04/conf/provision/service.d/.gitkeep diff --git a/docker/base/ubuntu-16.04/conf/provision/service.d/cron.sh b/docker/base/ubuntu-16.04/conf/provision/service.d/cron.sh new file mode 100644 index 000000000..bd8a54781 --- /dev/null +++ b/docker/base/ubuntu-16.04/conf/provision/service.d/cron.sh @@ -0,0 +1,13 @@ +#!/usr/bin/env bash + +IMAGE_FAMILY=$(docker-image-info family) + +case "$IMAGE_FAMILY" in + Debian|Ubuntu) + apt-install cron + ;; + + RedHat) + yum-install cronie + ;; +esac diff --git a/docker/base/ubuntu-16.04/conf/provision/service.d/dnsmasq.sh b/docker/base/ubuntu-16.04/conf/provision/service.d/dnsmasq.sh new file mode 100644 index 000000000..9e5c3228c --- /dev/null +++ b/docker/base/ubuntu-16.04/conf/provision/service.d/dnsmasq.sh @@ -0,0 +1,24 @@ +#!/usr/bin/env bash + +IMAGE_FAMILY=$(docker-image-info family) + +# Installation +case "$IMAGE_FAMILY" in + Debian|Ubuntu) + apt-install dnsmasq + ;; + + RedHat) + yum-install dnsmasq + ;; + + Alpine) + apk-install dnsmasq + ;; +esac + +# Configuration +go-replace --mode=line \ + -s '^[\s]*user[\s]*=' -r 'user = root' \ + -s '^[\s]*conf-dir[\s]*=' -r 'conf-dir = /etc/dnsmasq.d' \ + -- /etc/dnsmasq.conf diff --git a/docker/base/ubuntu-16.04/conf/provision/service.d/postfix.sh b/docker/base/ubuntu-16.04/conf/provision/service.d/postfix.sh new file mode 100644 index 000000000..ff1879345 --- /dev/null +++ b/docker/base/ubuntu-16.04/conf/provision/service.d/postfix.sh @@ -0,0 +1,28 @@ +#!/usr/bin/env bash + +IMAGE_FAMILY=$(docker-image-info family) + +# Installation +case "$IMAGE_FAMILY" in + Debian|Ubuntu) + apt-install postfix + ;; + + RedHat) + yum-install postfix + ;; + + Alpine) + apk-install postfix + ln -s -f /etc/postfix/aliases /etc/aliases + ;; +esac + +# Configuration +go-replace --mode=line \ + -s '^[\s]*mydestination[\s]*=' -r 'mydestination = ' \ + -s '^[\s]*message_size_limit[\s]*=' -r 'message_size_limit = 15240000' \ + -s '^[\s]*smtp_use_tls[\s]*=' -r 'smtp_use_tls = yes' \ + -s '^[\s]*smtp_tls_security_level[\s]*=' -r 'smtp_tls_security_level = may' \ + -s '^[\s]*myhostname[\s]*=' -r '# myhostname' \ + -- /etc/postfix/main.cf diff --git a/docker/base/ubuntu-16.04/conf/provision/service.d/ssh.sh b/docker/base/ubuntu-16.04/conf/provision/service.d/ssh.sh new file mode 100644 index 000000000..63d7a9f3a --- /dev/null +++ b/docker/base/ubuntu-16.04/conf/provision/service.d/ssh.sh @@ -0,0 +1,17 @@ +#!/usr/bin/env bash + +IMAGE_FAMILY=$(docker-image-info family) + +case "$IMAGE_FAMILY" in + Debian|Ubuntu) + apt-install openssh-server + ;; + + RedHat) + yum-install openssh-server + ;; + + Alpine) + apk-install openssh + ;; +esac diff --git a/docker/base/ubuntu-16.04/conf/provision/service.d/syslog.sh b/docker/base/ubuntu-16.04/conf/provision/service.d/syslog.sh new file mode 100644 index 000000000..7e8b8e0a9 --- /dev/null +++ b/docker/base/ubuntu-16.04/conf/provision/service.d/syslog.sh @@ -0,0 +1,41 @@ +#!/usr/bin/env bash + +IMAGE_FAMILY=$(docker-image-info family) + +# Installation +case "$IMAGE_FAMILY" in + Debian|Ubuntu) + apt-install syslog-ng syslog-ng-core + ;; + + RedHat) + yum-install syslog-ng + + # remove logrotate (not needed for docker) + rm -f "/etc/cron.daily/logrotate" + ;; + + Alpine) + apk-install syslog-ng + ;; +esac + +## Configuration +SYSLOG_NG_VERSION=$(syslog-ng --version | grep -E -e '^syslog-ng[ ]+[0-9]+\.[0-9]+' | head -n 1 | awk '{print $2}' | cut -f 1,2 -d .) + +# Disable caps inside container +if [[ -f /etc/default/syslog-ng ]]; then + go-replace --mode=lineinfile \ + -s "SYSLOGNG_OPTS" -r "SYSLOGNG_OPTS = --no-caps" \ + -- /etc/default/syslog-ng +fi + +# Symlink configuration +ln -s -f /opt/docker/etc/syslog-ng/syslog-ng.conf /etc/syslog-ng/syslog-ng.conf + +go-replace --mode=lineinfile \ + -s "@version" -r "@version: ${SYSLOG_NG_VERSION}" \ + -- /etc/syslog-ng/syslog-ng.conf + +# Ensure /var/lib/syslog-ng exists +mkdir -p /var/lib/syslog-ng diff --git a/docker/base/ubuntu-16.04/conf/provision/variables-webdevops.yml b/docker/base/ubuntu-16.04/conf/provision/variables-webdevops.yml new file mode 100644 index 000000000..0b2a21a95 --- /dev/null +++ b/docker/base/ubuntu-16.04/conf/provision/variables-webdevops.yml @@ -0,0 +1,7 @@ +--- + +docker_image_info_family: "{{ lookup('pipe', 'docker-image-info family') }}" +docker_image_info_distribution: "{{ lookup('pipe', 'docker-image-info dist') }}" +docker_image_info_distribution_version: "{{ lookup('pipe', 'docker-image-info dist-version') }}" +docker_image_info_distribution_release: "{{ lookup('pipe', 'docker-image-info dist-release') }}" +docker_image_info_distribution_codename: "{{ lookup('pipe', 'docker-image-info dist-codename') }}" diff --git a/docker/base/ubuntu-16.04/conf/provision/variables.yml b/docker/base/ubuntu-16.04/conf/provision/variables.yml index ed97d539c..0b2a21a95 100644 --- a/docker/base/ubuntu-16.04/conf/provision/variables.yml +++ b/docker/base/ubuntu-16.04/conf/provision/variables.yml @@ -1 +1,7 @@ --- + +docker_image_info_family: "{{ lookup('pipe', 'docker-image-info family') }}" +docker_image_info_distribution: "{{ lookup('pipe', 'docker-image-info dist') }}" +docker_image_info_distribution_version: "{{ lookup('pipe', 'docker-image-info dist-version') }}" +docker_image_info_distribution_release: "{{ lookup('pipe', 'docker-image-info dist-release') }}" +docker_image_info_distribution_codename: "{{ lookup('pipe', 'docker-image-info dist-codename') }}" diff --git a/docker/base/ubuntu-16.10/Dockerfile b/docker/base/ubuntu-16.10/Dockerfile index 3ac259f01..8fc61d908 100644 --- a/docker/base/ubuntu-16.10/Dockerfile +++ b/docker/base/ubuntu-16.10/Dockerfile @@ -5,31 +5,47 @@ FROM webdevops/bootstrap:ubuntu-16.10 -MAINTAINER info@webdevops.io -LABEL vendor=WebDevOps.io -LABEL io.webdevops.layout=8 -LABEL io.webdevops.version=1.5.0 - -ENV DOCKER_CONF_HOME /opt/docker/ +ENV DOCKER_CONF_HOME=/opt/docker/ \ + LOG_STDOUT="" \ + LOG_STDERR="" COPY conf/ /opt/docker/ +# Install ansible +RUN /usr/local/bin/apt-install \ + python-minimal \ + python-setuptools \ + python-pip \ + python-paramiko \ + python-jinja2 \ + python-dev \ + libffi-dev \ + libssl-dev \ + build-essential \ + && pip install --upgrade pip \ + && hash -r \ + && pip install --no-cache-dir ansible \ + && chmod 750 /usr/local/bin/ansible* \ + # Cleanup + && apt-get purge -y -f --force-yes \ + python-dev \ + build-essential \ + libssl-dev \ + libffi-dev \ + && docker-image-cleanup + # Install services RUN chmod +x /opt/docker/bin/* \ && /usr/local/bin/apt-install \ supervisor \ - syslog-ng \ - syslog-ng-core \ - logrotate \ - cron \ wget \ curl \ net-tools \ gnupg \ && chmod +s /usr/local/bin/gosu \ && /opt/docker/bin/provision run --tag bootstrap --role webdevops-base \ - && /opt/docker/bin/bootstrap.sh - + && /opt/docker/bin/bootstrap.sh \ + && docker-image-cleanup ENTRYPOINT ["/opt/docker/bin/entrypoint.sh"] CMD ["supervisord"] diff --git a/docker/base/ubuntu-16.10/Dockerfile.jinja2 b/docker/base/ubuntu-16.10/Dockerfile.jinja2 index 4d48146b0..fcd217c3f 100644 --- a/docker/base/ubuntu-16.10/Dockerfile.jinja2 +++ b/docker/base/ubuntu-16.10/Dockerfile.jinja2 @@ -1,11 +1,11 @@ {{ docker.from("bootstrap", "ubuntu-16.10") }} -{{ docker.version() }} - -{{ environment.homePath() }} +{{ environment.base() }} {{ docker.copy('conf/', '/opt/docker/') }} +{{ ansible.ubuntu() }} + {{ base.ubuntu() }} {{ docker.entrypoint("/opt/docker/bin/entrypoint.sh") }} diff --git a/docker/base/ubuntu-16.10/conf/bin/bootstrap.sh b/docker/base/ubuntu-16.10/conf/bin/bootstrap.sh index 1d1a30f72..855c10782 100644 --- a/docker/base/ubuntu-16.10/conf/bin/bootstrap.sh +++ b/docker/base/ubuntu-16.10/conf/bin/bootstrap.sh @@ -17,10 +17,16 @@ rootCheck "$0" # Save the buildtime date +%s > /opt/docker/BUILDTIME +date +%s >/opt/docker/etc/.registry/image_info_buildtime # Make all scripts executable find /opt/docker/bin/ -type f -iname '*.sh' -print0 | xargs --no-run-if-empty -0 chmod +x +# Enable usr-bin executables +find /opt/docker/bin/usr-bin -type f | while read USR_BIN_FILE; do + chmod +x -- "$USR_BIN_FILE" + ln -n -f -- "$USR_BIN_FILE" "/usr/local/bin/$(basename "$USR_BIN_FILE")" +done case "$BOOTSTRAP_MODE" in ################################### @@ -44,6 +50,23 @@ case "$BOOTSTRAP_MODE" in echo "[ERROR] Bootstrap mode '$BOOTSTRAP_MODE' not defined" exit 1 ;; - esac + +###################### +# Check if entrypoint provisioning is available +###################### + +echo "Checking provision status..." +for PROVISION_TAG in onbuild build bootstrap entrypoint; do + ROLES=$(docker-provision list --tag "$PROVISION_TAG") + if [[ -n "$ROLES" ]]; then + PROVISION_ROLE_COUNT=$(echo "$ROLES" | wc -l) + echo " - found ${PROVISION_ROLE_COUNT} for provision tag ${PROVISION_TAG}, caching info for execution" + echo -n "$PROVISION_ROLE_COUNT" > "/opt/docker/etc/.registry/provision-availale.${PROVISION_TAG}" + else + echo " - no roles found for provision tag ${PROVISION_TAG}" + echo -n '' > "/opt/docker/etc/.registry/provision-availale.${PROVISION_TAG}" + fi +done + diff --git a/docker/base/ubuntu-16.10/conf/bin/config.sh b/docker/base/ubuntu-16.10/conf/bin/config.sh index 3155728e8..049756c26 100644 --- a/docker/base/ubuntu-16.10/conf/bin/config.sh +++ b/docker/base/ubuntu-16.10/conf/bin/config.sh @@ -15,44 +15,23 @@ function rootCheck() { } ### - # Create named pipe - # - # $1 -> name of file + # Create /docker.stdout and /docker.stderr # ## -function createNamedPipe() { - rm --force -- "$1" - mknod "$1" p -} - -### - # Escape value for sed usage - # - # $1 -> value - # STDOUT -> escaped value - # - ## -function sedEscape() { - echo "$(echo $* |sed -e 's/[]\/$*.^|[]/\\&/g')" -} +function createDockerStdoutStderr() { + # link stdout from docker + if [[ -z "$LOG_STDOUT" ]]; then + LOG_STDOUT="/proc/$$/fd/1" + fi -### - # Replace text inside a file - # - # $1 -> source value - # $2 -> target value - # $3 -> path to file - # - ## -function replaceTextInFile() { - SOURCE="$(sedEscape $1)" - REPLACE="$(sedEscape $2)" - TARGET="$3" + if [[ -z "$LOG_STDERR" ]]; then + LOG_STDERR="/proc/$$/fd/2" + fi - sed -i "s/${SOURCE}/${REPLACE}/" "${TARGET}" + ln -f -s "$LOG_STDOUT" /docker.stdout + ln -f -s "$LOG_STDERR" /docker.stderr + chmod 600 /docker.stdout /docker.stderr } - - ### # Include script directory text inside a file # @@ -104,7 +83,7 @@ function runEntrypoints() { . /opt/docker/bin/entrypoint.d/default.sh fi - exit + exit 1 } ### @@ -161,6 +140,12 @@ function runProvisionEntrypoint() { function runDockerProvision() { ANSIBLE_TAG="$1" - /opt/docker/bin/provision run --tag "$ANSIBLE_TAG" --use-registry + PROVISION_STATS_FILE="/opt/docker/etc/.registry/provision-stats.${ANSIBLE_TAG}" + + # run provision if stats file doesn't exists (unknown mode) + # or if stats file is not empty + if [[ ! -f "$PROVISION_STATS_FILE" ]] || [[ -s "$PROVISION_STATS_FILE" ]]; then + /opt/docker/bin/provision run --tag "${ANSIBLE_TAG}" --use-registry + fi } diff --git a/docker/base/ubuntu-16.10/conf/bin/control.sh b/docker/base/ubuntu-16.10/conf/bin/control.sh index a6697092d..22d189745 100644 --- a/docker/base/ubuntu-16.10/conf/bin/control.sh +++ b/docker/base/ubuntu-16.10/conf/bin/control.sh @@ -101,23 +101,13 @@ case "$CONTROL_COMMAND" in ## ------------------------------------------ "service.enable") - SERVICE_FILE="/opt/docker/etc/supervisor.d/$1.conf" - if [ -f "$SERVICE_FILE" ]; then - sed -i '/autostart = /c\autostart = true' -- "$SERVICE_FILE" - else - echo "[ERROR] Service '${1}' not found (tried ${SERVICE_FILE})" - exit 1 - fi + deprecationNotice " Please use >>docker-service-enable [service]<<" + docker-service-enable "$1" ;; "service.disable") - SERVICE_FILE="/opt/docker/etc/supervisor.d/$1.conf" - if [ -f "$SERVICE_FILE" ]; then - sed -i '/autostart = /c\autostart = false' -- "$SERVICE_FILE" - else - echo "[ERROR] Service '${1}' not found (tried ${SERVICE_FILE})" - exit 1 - fi + deprecationNotice " Please use >>docker-service-disable [service]<<" + docker-service-disable "$1" ;; ## ------------------------------------------ diff --git a/docker/base/ubuntu-16.10/conf/bin/entrypoint.d/cli.sh b/docker/base/ubuntu-16.10/conf/bin/entrypoint.d/cli.sh index 2ca68926c..fe212a8ea 100644 --- a/docker/base/ubuntu-16.10/conf/bin/entrypoint.d/cli.sh +++ b/docker/base/ubuntu-16.10/conf/bin/entrypoint.d/cli.sh @@ -8,7 +8,7 @@ if [ -n "${CLI_SCRIPT}" ]; then if [ -n "$APPLICATION_USER" ]; then # Run as EFFECTIVE_USER shift - exec sudo -H -E -u "${APPLICATION_USER}" ${CLI_SCRIPT} "$@" + exec gosu "${APPLICATION_USER}" ${CLI_SCRIPT} "$@" else # Run as root exec ${CLI_SCRIPT} "$@" diff --git a/docker/base/ubuntu-16.10/conf/bin/entrypoint.d/noop.sh b/docker/base/ubuntu-16.10/conf/bin/entrypoint.d/noop.sh index 967920837..092d55d8b 100644 --- a/docker/base/ubuntu-16.10/conf/bin/entrypoint.d/noop.sh +++ b/docker/base/ubuntu-16.10/conf/bin/entrypoint.d/noop.sh @@ -4,5 +4,4 @@ ## NOOP (no operation) ############################################# -tail -f /dev/null -exit +exec tail -f /dev/null diff --git a/docker/base/ubuntu-16.10/conf/bin/entrypoint.d/supervisord.sh b/docker/base/ubuntu-16.10/conf/bin/entrypoint.d/supervisord.sh index ead991551..f21489667 100644 --- a/docker/base/ubuntu-16.10/conf/bin/entrypoint.d/supervisord.sh +++ b/docker/base/ubuntu-16.10/conf/bin/entrypoint.d/supervisord.sh @@ -4,8 +4,6 @@ ## Supervisord (start daemons) ############################################# -rootCheck "supervisord" - ## Start services exec /opt/docker/bin/service.d/supervisor.sh diff --git a/docker/base/ubuntu-16.10/conf/bin/entrypoint.sh b/docker/base/ubuntu-16.10/conf/bin/entrypoint.sh index bbabcdddb..01f59660c 100644 --- a/docker/base/ubuntu-16.10/conf/bin/entrypoint.sh +++ b/docker/base/ubuntu-16.10/conf/bin/entrypoint.sh @@ -20,16 +20,13 @@ chmod -s /usr/local/bin/gosu trap 'echo sigterm ; exit' SIGTERM trap 'echo sigkill ; exit' SIGKILL -# link stdout from docker -ln -f -s "/proc/$$/fd/1" /docker.stdout -ln -f -s "/proc/$$/fd/2" /docker.stderr -chmod 600 /docker.stdout /docker.stderr - # sanitize input and set task TASK="$(echo $1| sed 's/[^-_a-zA-Z0-9]*//g')" source /opt/docker/bin/config.sh +createDockerStdoutStderr + if [[ "$UID" -eq 0 ]]; then # Only run provision if user is root diff --git a/docker/base/ubuntu-16.10/conf/bin/logwatch.sh b/docker/base/ubuntu-16.10/conf/bin/logwatch.sh deleted file mode 100644 index 1a5b486c7..000000000 --- a/docker/base/ubuntu-16.10/conf/bin/logwatch.sh +++ /dev/null @@ -1,14 +0,0 @@ -#!/usr/bin/env bash - -set -o pipefail # trace ERR through pipes -set -o errtrace # trace ERR through 'time command' and other functions -set -o nounset ## set -u : exit the script if you try to use an uninitialised variable -set -o errexit ## set -e : exit the script if any statement returns a non-true return value - -sleep 0.5 - -if [ -p "$2" ]; then - sed --unbuffered -e "s/^/\[$1\] /" -- "$2" -else - tail -n 0 -F -q "$2" | sed --unbuffered -e "s/^/\[$1\] /" -fi diff --git a/docker/base/ubuntu-16.10/conf/bin/provision b/docker/base/ubuntu-16.10/conf/bin/provision index f7b5ad0a8..d367c2812 100755 --- a/docker/base/ubuntu-16.10/conf/bin/provision +++ b/docker/base/ubuntu-16.10/conf/bin/provision @@ -19,6 +19,7 @@ PLAYBOOK = Template( - hosts: all vars_files: + - ./variables-webdevops.yml - ./variables.yml roles: - $roles @@ -188,7 +189,7 @@ def actionAdd(args): 'priority': args.priority } - saveJson(json); + saveJson(json) diff --git a/docker/base/ubuntu-16.10/conf/bin/provision.sh b/docker/base/ubuntu-16.10/conf/bin/provision.sh deleted file mode 100644 index 4079dd7f0..000000000 --- a/docker/base/ubuntu-16.10/conf/bin/provision.sh +++ /dev/null @@ -1,30 +0,0 @@ - #!/usr/bin/env bash - -# -# Example: -# provision.sh /opt/foobar/playbook.yml tag -# -# - -set -o pipefail # trace ERR through pipes -set -o errtrace # trace ERR through 'time command' and other functions -set -o nounset ## set -u : exit the script if you try to use an uninitialised variable -set -o errexit ## set -e : exit the script if any statement returns a non-true return value - -. config.sh - -deprecationNotice " Please use >>/opt/docker/bin/provision run --playbook playbook.yml --tag=bootstrap [args]<< for running provision" - - -if [ "$#" -lt 2 ]; then - echo "[ERROR] $0: Playbook or tag is missing" - exit 1 -fi - -ANSIBLE_PLAYBOOK="$1" -shift -ANSIBLE_TAG="$1" -shift -ANSIBLE_OPTS="$@" - -/opt/docker/bin/provision run --playbook "${ANSIBLE_PLAYBOOK}" --use-registry --tag "${ANSIBLE_TAG}" $ANSIBLE_OPTS diff --git a/docker/base-app/ubuntu-16.10/conf/bin/service.d/dnsmasq.d/10-init.sh b/docker/base/ubuntu-16.10/conf/bin/service.d/dnsmasq.d/10-init.sh similarity index 100% rename from docker/base-app/ubuntu-16.10/conf/bin/service.d/dnsmasq.d/10-init.sh rename to docker/base/ubuntu-16.10/conf/bin/service.d/dnsmasq.d/10-init.sh diff --git a/docker/base-app/ubuntu-16.10/conf/bin/service.d/dnsmasq.sh b/docker/base/ubuntu-16.10/conf/bin/service.d/dnsmasq.sh similarity index 100% rename from docker/base-app/ubuntu-16.10/conf/bin/service.d/dnsmasq.sh rename to docker/base/ubuntu-16.10/conf/bin/service.d/dnsmasq.sh diff --git a/docker/base/ubuntu-16.10/conf/bin/service.d/postfix.d/10-init.sh b/docker/base/ubuntu-16.10/conf/bin/service.d/postfix.d/10-init.sh new file mode 100644 index 000000000..cfd876955 --- /dev/null +++ b/docker/base/ubuntu-16.10/conf/bin/service.d/postfix.d/10-init.sh @@ -0,0 +1,27 @@ +# force new copy of hosts there (otherwise links could be outdated) +mkdir -p /var/spool/postfix/etc +cp -f /etc/hosts /var/spool/postfix/etc/hosts +cp -f /etc/resolv.conf /var/spool/postfix/etc/resolv.conf +cp -f /etc/services /var/spool/postfix/etc/services + +## MYHOSTNAME +# replace line +sed -i '/myhostname[ ]* =/c\' main.cf +echo "myhostname = $(hostname)" >> /etc/postfix/main.cf + +## REPLAYHOST +if [[ -n "${POSTFIX_RELAYHOST+x}" ]]; then + # replace line + sed -i '/relayhost[ ]* =/c\' main.cf + echo "relayhost = $POSTFIX_RELAYHOST" >> /etc/postfix/main.cf +fi + +## MYNETWORKS +if [[ -n "${POSTFIX_MYNETWORKS+x}" ]]; then + # replace line + sed -i '/mynetworks[ ]* =/c\' main.cf + echo "mynetworks = $POSTFIX_MYNETWORKS" >> /etc/postfix/main.cf +fi + +# generate aliases db +newaliases || : diff --git a/docker/base-app/ubuntu-16.10/conf/bin/service.d/postfix.sh b/docker/base/ubuntu-16.10/conf/bin/service.d/postfix.sh similarity index 100% rename from docker/base-app/ubuntu-16.10/conf/bin/service.d/postfix.sh rename to docker/base/ubuntu-16.10/conf/bin/service.d/postfix.sh diff --git a/docker/base/ubuntu-16.10/conf/bin/service.d/ssh.d/10-init.sh b/docker/base/ubuntu-16.10/conf/bin/service.d/ssh.d/10-init.sh new file mode 100644 index 000000000..f2b600312 --- /dev/null +++ b/docker/base/ubuntu-16.10/conf/bin/service.d/ssh.d/10-init.sh @@ -0,0 +1,7 @@ +# Init ssh privilege separation directory +mkdir -p /var/run/sshd +chown root:root /var/run/sshd +chmod 755 /var/run/sshd + +# generate host keys +ssh-keygen -A diff --git a/docker/base-app/ubuntu-16.10/conf/bin/service.d/ssh.sh b/docker/base/ubuntu-16.10/conf/bin/service.d/ssh.sh similarity index 100% rename from docker/base-app/ubuntu-16.10/conf/bin/service.d/ssh.sh rename to docker/base/ubuntu-16.10/conf/bin/service.d/ssh.sh diff --git a/docker/base/ubuntu-16.10/conf/bin/service.d/syslog-ng.d/10-init.sh b/docker/base/ubuntu-16.10/conf/bin/service.d/syslog-ng.d/10-init.sh index 22621d2ad..326207e52 100644 --- a/docker/base/ubuntu-16.10/conf/bin/service.d/syslog-ng.d/10-init.sh +++ b/docker/base/ubuntu-16.10/conf/bin/service.d/syslog-ng.d/10-init.sh @@ -6,5 +6,5 @@ if [ ! -S /var/lib/syslog-ng/syslog-ng.ctl ]; then rm -f /var/lib/syslog-ng/sysl if [[ ! -p /docker.stdout ]]; then # Switch to file (tty docker mode) - rpl --quiet 'pipe("/docker.stdout")' 'file("/docker.stdout")' -- /opt/docker/etc/syslog-ng/syslog-ng.conf > /dev/null + go-replace -s 'pipe("/docker.stdout")' -r 'file("/docker.stdout")' -- /opt/docker/etc/syslog-ng/syslog-ng.conf fi diff --git a/docker/base/ubuntu-16.10/conf/bin/usr-bin/docker-provision b/docker/base/ubuntu-16.10/conf/bin/usr-bin/docker-provision new file mode 100644 index 000000000..4ee715c64 --- /dev/null +++ b/docker/base/ubuntu-16.10/conf/bin/usr-bin/docker-provision @@ -0,0 +1,9 @@ +#!/usr/bin/env bash + +set -o pipefail # trace ERR through pipes +set -o errtrace # trace ERR through 'time command' and other functions +set -o nounset ## set -u : exit the script if you try to use an uninitialised variable +set -o errexit ## set -e : exit the script if any statement returns a non-true return value + +# wrapper +exec /opt/docker/bin/provision "$@" diff --git a/docker/base/ubuntu-16.10/conf/bin/usr-bin/docker-service-disable b/docker/base/ubuntu-16.10/conf/bin/usr-bin/docker-service-disable new file mode 100644 index 000000000..2b5b31bb4 --- /dev/null +++ b/docker/base/ubuntu-16.10/conf/bin/usr-bin/docker-service-disable @@ -0,0 +1,30 @@ +#!/usr/bin/env bash + +set -o pipefail # trace ERR through pipes +set -o errtrace # trace ERR through 'time command' and other functions +set -o nounset ## set -u : exit the script if you try to use an uninitialised variable +set -o errexit ## set -e : exit the script if any statement returns a non-true return value + +source /opt/docker/bin/config.sh + +rootCheck "$0" + +if [[ "$#" -eq 0 ]]; then + echo "Usage: $0 " + exit 1 +fi + +for SERVICE in "$@"; do + SERVICE_FILE="/opt/docker/etc/supervisor.d/${SERVICE}.conf" + + ## Disable service + if [[ -f "$SERVICE_FILE" ]]; then + go-replace --mode=lineinfile \ + -s 'autostart =' -r 'autostart = false' \ + -- "$SERVICE_FILE" + else + echo "[ERROR] Service '${SERVICE}' not found (tried ${SERVICE_FILE})" + exit 1 + fi +done + diff --git a/docker/base/ubuntu-16.10/conf/bin/usr-bin/docker-service-enable b/docker/base/ubuntu-16.10/conf/bin/usr-bin/docker-service-enable new file mode 100644 index 000000000..8d36a14a9 --- /dev/null +++ b/docker/base/ubuntu-16.10/conf/bin/usr-bin/docker-service-enable @@ -0,0 +1,41 @@ +#!/usr/bin/env bash + +set -o pipefail # trace ERR through pipes +set -o errtrace # trace ERR through 'time command' and other functions +set -o nounset ## set -u : exit the script if you try to use an uninitialised variable +set -o errexit ## set -e : exit the script if any statement returns a non-true return value + +source /opt/docker/bin/config.sh + +rootCheck "$0" + +if [[ "$#" -eq 0 ]]; then + echo "Usage: $0 " + exit 1 +fi + +for SERVICE in "$@"; do + SERVICE_FILE="/opt/docker/etc/supervisor.d/${SERVICE}.conf" + PROVISION_FILE="/opt/docker/provision/service.d/${SERVICE}.sh" + + # Run on demand installation/provisioning + if [[ -f "$PROVISION_FILE" ]]; then + echo "Running provisioning for ${SERVICE}, please wait..." + + ## execute scripts + . "$PROVISION_FILE" + + ## remove directory (one run time) + rm -f -- "$PROVISION_FILE" + fi + + ## Enable service + if [[ -f "$SERVICE_FILE" ]]; then + go-replace --mode=lineinfile \ + -s 'autostart =' -r 'autostart = true' \ + -- "$SERVICE_FILE" + else + echo "[ERROR] Service '${SERVICE}' not found (tried ${SERVICE_FILE})" + exit 1 + fi +done diff --git a/docker/base/ubuntu-16.10/conf/bin/usr-bin/service b/docker/base/ubuntu-16.10/conf/bin/usr-bin/service new file mode 100755 index 000000000..55ea12bf7 --- /dev/null +++ b/docker/base/ubuntu-16.10/conf/bin/usr-bin/service @@ -0,0 +1,86 @@ +#!/bin/bash + +set -o pipefail # trace ERR through pipes +set -o errtrace # trace ERR through 'time command' and other functions +set -o nounset ## set -u : exit the script if you try to use an uninitialised variable +set -o errexit ## set -e : exit the script if any statement returns a non-true return value + +# Root check +if [ "$(/usr/bin/whoami)" != "root" ]; then + echo "[ERROR] Must be run as root" + exit 1 +fi + +function serviceHelp() { + echo "Usage: $(basename "$0") " +} + +function getServicePid() { + local serviceName="$1" + local servicePid=$(supervisorctl pid "${serviceName}:${serviceName}d") + + if [[ -z "$servicePid" ]] || [[ "$servicePid" == "0" ]]; then + echo "not running" + exit 1 + fi + + echo $servicePid +} + +# Param check +if [ "$#" -lt 2 ]; then + echo "[ERROR] Missing parameters" + serviceHelp + exit 1 +fi + +############################# +# Param init +############################# + +SERVICENAME="$1" +ACTION="$2" + +############################# +# Service aliases +############################# +case "$SERVICENAME" in + apache2|httpd) + SERVICENAME="apache" + ;; +esac + +############################# +# Action runner +############################# +case "$ACTION" in + stop|start|restart|status) + exec supervisorctl "$ACTION" "${SERVICENAME}:${SERVICENAME}d" + ;; + + pid) + echo $(getServicePid "${SERVICENAME}") + ;; + + check) + FIRST_PID=$(getServicePid "${SERVICENAME}") + sleep 5 + SECOND_PID=$(getServicePid "${SERVICENAME}") + + if [[ "$FIRST_PID" == "$SECOND_PID" ]]; then + echo "ok" + exit 0 + else + echo "not running" + exit 1 + fi + ;; + + + *) + echo "[ERROR] Invalid action" + serviceHelp + exit 1 + ;; + +esac diff --git a/docker/base/ubuntu-16.10/conf/etc/supervisor.conf b/docker/base/ubuntu-16.10/conf/etc/supervisor.conf index 7c109515a..479e0db08 100644 --- a/docker/base/ubuntu-16.10/conf/etc/supervisor.conf +++ b/docker/base/ubuntu-16.10/conf/etc/supervisor.conf @@ -2,9 +2,16 @@ nodaemon=true [unix_http_server] -file = /var/run/supervisor.sock -# username = root -# password = {SHA}e982f17bcbe0f724063b708a4f76db211a999304 +file = /.supervisor.sock +chmod = 0700 +chown = root:root +username = root +password = {SHA}e982f17bcbe0f724063b708a4f76db211a999304 + +[supervisorctl] +serverurl = unix:///.supervisor.sock +username = root +password = docker [rpcinterface:supervisor] supervisor.rpcinterface_factory = supervisor.rpcinterface:make_main_rpcinterface diff --git a/docker/base/ubuntu-16.10/conf/etc/supervisor.d/dnsmasq.conf b/docker/base/ubuntu-16.10/conf/etc/supervisor.d/dnsmasq.conf new file mode 100644 index 000000000..9832ffca7 --- /dev/null +++ b/docker/base/ubuntu-16.10/conf/etc/supervisor.d/dnsmasq.conf @@ -0,0 +1,14 @@ +[group:dnsmasq] +programs=dnsmasqd +priority=15 + +[program:dnsmasqd] +command = /opt/docker/bin/service.d/dnsmasq.sh +process_name=%(program_name)s +startsecs = 0 +autostart = false +autorestart = true +stdout_logfile=/dev/stdout +stdout_logfile_maxbytes=0 +stderr_logfile=/dev/stderr +stderr_logfile_maxbytes=0 diff --git a/docker/base-app/ubuntu-16.10/conf/etc/supervisor.d/postfix.conf b/docker/base/ubuntu-16.10/conf/etc/supervisor.d/postfix.conf similarity index 100% rename from docker/base-app/ubuntu-16.10/conf/etc/supervisor.d/postfix.conf rename to docker/base/ubuntu-16.10/conf/etc/supervisor.d/postfix.conf diff --git a/docker/base-app/ubuntu-16.10/conf/etc/supervisor.d/ssh.conf b/docker/base/ubuntu-16.10/conf/etc/supervisor.d/ssh.conf similarity index 100% rename from docker/base-app/ubuntu-16.10/conf/etc/supervisor.d/ssh.conf rename to docker/base/ubuntu-16.10/conf/etc/supervisor.d/ssh.conf diff --git a/docker/base/ubuntu-16.10/conf/etc/supervisor.d/syslog-ng.conf b/docker/base/ubuntu-16.10/conf/etc/supervisor.d/syslog-ng.conf deleted file mode 100644 index 247fd1a25..000000000 --- a/docker/base/ubuntu-16.10/conf/etc/supervisor.d/syslog-ng.conf +++ /dev/null @@ -1,13 +0,0 @@ -[group:syslog] -programs=syslogd -priority=10 - -[program:syslogd] -command = /opt/docker/bin/service.d/syslog-ng.sh -process_name=%(program_name)s -autostart = true -autorestart = true -stdout_logfile=/dev/stdout -stdout_logfile_maxbytes=0 -stderr_logfile=/dev/stderr -stderr_logfile_maxbytes=0 diff --git a/docker/base/ubuntu-16.10/conf/etc/supervisor.d/syslog.conf b/docker/base/ubuntu-16.10/conf/etc/supervisor.d/syslog.conf new file mode 100644 index 000000000..20d1e238c --- /dev/null +++ b/docker/base/ubuntu-16.10/conf/etc/supervisor.d/syslog.conf @@ -0,0 +1,13 @@ +[group:syslog] +programs=syslogd +priority=10 + +[program:syslogd] +command = /opt/docker/bin/service.d/syslog-ng.sh +process_name=%(program_name)s +autostart = false +autorestart = true +stdout_logfile=/dev/stdout +stdout_logfile_maxbytes=0 +stderr_logfile=/dev/stderr +stderr_logfile_maxbytes=0 diff --git a/docker/base/ubuntu-16.10/conf/provision/roles/webdevops-base/tasks/bootstrap.yml b/docker/base/ubuntu-16.10/conf/provision/roles/webdevops-base/tasks/bootstrap.yml index 30be03c38..9f842336c 100644 --- a/docker/base/ubuntu-16.10/conf/provision/roles/webdevops-base/tasks/bootstrap.yml +++ b/docker/base/ubuntu-16.10/conf/provision/roles/webdevops-base/tasks/bootstrap.yml @@ -4,6 +4,5 @@ - include: bootstrap/misc.yml - include: bootstrap/root.yml - include: bootstrap/supervisor.yml -- include: bootstrap/syslog-ng.yml -- include: bootstrap/logrotate.yml - include: bootstrap/pam.yml +- include: bootstrap/entrypoint.yml diff --git a/docker/base/ubuntu-16.10/conf/provision/roles/webdevops-base/tasks/bootstrap/entrypoint.yml b/docker/base/ubuntu-16.10/conf/provision/roles/webdevops-base/tasks/bootstrap/entrypoint.yml new file mode 100644 index 000000000..d5d8809f4 --- /dev/null +++ b/docker/base/ubuntu-16.10/conf/provision/roles/webdevops-base/tasks/bootstrap/entrypoint.yml @@ -0,0 +1,8 @@ +--- + +- name: Create link for entrypoint + file: + src: '/opt/docker/bin/entrypoint.sh' + dest: '/entrypoint' + state: link + force: yes diff --git a/docker/base/ubuntu-16.10/conf/provision/roles/webdevops-base/tasks/bootstrap/logrotate.yml b/docker/base/ubuntu-16.10/conf/provision/roles/webdevops-base/tasks/bootstrap/logrotate.yml deleted file mode 100644 index d87926be2..000000000 --- a/docker/base/ubuntu-16.10/conf/provision/roles/webdevops-base/tasks/bootstrap/logrotate.yml +++ /dev/null @@ -1,33 +0,0 @@ ---- - -- name: Configure logrotate running user - lineinfile: - dest: /etc/logrotate.conf - regexp: '^su [-_a-zA-Z0-9]+ [-_a-zA-Z0-9]+' - line: 'su root adm' - -- name: Register logrotate configurations - file: - src: '{{ item }}' - dest: '/etc/logrotate.d/{{ item | basename }}' - state: link - force: yes - with_fileglob: - - /opt/docker/etc/logrotate.d/* - -- name: Remove system logrotates (not needed) - file: - path: '{{ item }}' - state: absent - with_items: - # Debian/Ubuntu - - /etc/cron.daily/logrotate - - /etc/cron.daily/apt-compat - - /etc/cron.daily/dpkg - - /etc/cron.daily/passwd - # RedHat - - /etc/cron.daily/0yum-daily.cron - - /etc/cron.daily/logrotate - - /etc/cron.hourly/0yum-hourly.cron - # Alpine - - /etc/periodic/daily/logrotate diff --git a/docker/base/ubuntu-16.10/conf/provision/roles/webdevops-base/tasks/bootstrap/supervisor.yml b/docker/base/ubuntu-16.10/conf/provision/roles/webdevops-base/tasks/bootstrap/supervisor.yml index bda0394b6..2ce07ac26 100644 --- a/docker/base/ubuntu-16.10/conf/provision/roles/webdevops-base/tasks/bootstrap/supervisor.yml +++ b/docker/base/ubuntu-16.10/conf/provision/roles/webdevops-base/tasks/bootstrap/supervisor.yml @@ -4,3 +4,10 @@ file: path: '/usr/sbin/service' state: absent + +- name: Create link for supervisor.conf + file: + src: '/opt/docker/etc/supervisor.conf' + dest: '/etc/supervisord.conf' + state: link + force: yes diff --git a/docker/base/ubuntu-16.10/conf/provision/roles/webdevops-base/tasks/bootstrap/syslog-ng.yml b/docker/base/ubuntu-16.10/conf/provision/roles/webdevops-base/tasks/bootstrap/syslog-ng.yml deleted file mode 100644 index 27c8f6a30..000000000 --- a/docker/base/ubuntu-16.10/conf/provision/roles/webdevops-base/tasks/bootstrap/syslog-ng.yml +++ /dev/null @@ -1,33 +0,0 @@ ---- - -- name: Get syslog-ng version - shell: "syslog-ng --version | grep -E -e '^syslog-ng[ ]+[0-9]+\\.[0-9]+' | head -n 1 | awk '{print $2}' | cut -f 1,2 -d ." - register: syslogng_version - -- name: Configure syslog-ng (default) - lineinfile: - dest: /etc/default/syslog-ng - regexp: '^[\s]*{{ item.key }}[\s]*=' - line: '{{ item.key }}="{{ item.value }}"' - create: yes - with_items: - - { key: 'SYSLOGNG_OPTS', value: '--no-caps' } - -- name: Enable syslog-ng config - file: - src: '/opt/docker/etc/syslog-ng/syslog-ng.conf' - dest: '/etc/syslog-ng/syslog-ng.conf' - state: link - force: yes - -- name: Set version of syslog-ng file - lineinfile: - dest: '/etc/syslog-ng/syslog-ng.conf' - regexp: '^@version:' - line: '@version: {{ syslogng_version.stdout }}' - -- name: Ensure /var/lib/syslog-ng exists - file: - path: '/var/lib/syslog-ng' - state: directory - recurse: yes diff --git a/docker/base/ubuntu-16.10/conf/provision/roles/webdevops-base/tasks/bootstrap/system.yml b/docker/base/ubuntu-16.10/conf/provision/roles/webdevops-base/tasks/bootstrap/system.yml index 8dfbf9665..0741d7cae 100644 --- a/docker/base/ubuntu-16.10/conf/provision/roles/webdevops-base/tasks/bootstrap/system.yml +++ b/docker/base/ubuntu-16.10/conf/provision/roles/webdevops-base/tasks/bootstrap/system.yml @@ -14,3 +14,20 @@ dest: '/entrypoint.cmd' state: link force: yes + +- name: Remove system logrotate and cronjobs (not needed) + file: + path: '{{ item }}' + state: absent + with_items: + # Debian/Ubuntu + - /etc/cron.daily/logrotate + - /etc/cron.daily/apt-compat + - /etc/cron.daily/dpkg + - /etc/cron.daily/passwd + # RedHat + - /etc/cron.daily/0yum-daily.cron + - /etc/cron.daily/logrotate + - /etc/cron.hourly/0yum-hourly.cron + # Alpine + - /etc/periodic/daily/logrotate diff --git a/docker/php/alpine-3/conf/etc/php/conf.d/.gitkeep b/docker/base/ubuntu-16.10/conf/provision/roles/webdevops-base/tasks/build/.gitkeep similarity index 100% rename from docker/php/alpine-3/conf/etc/php/conf.d/.gitkeep rename to docker/base/ubuntu-16.10/conf/provision/roles/webdevops-base/tasks/build/.gitkeep diff --git a/docker/base/ubuntu-16.10/conf/provision/roles/webdevops-base/tasks/build/logrotate.yml b/docker/base/ubuntu-16.10/conf/provision/roles/webdevops-base/tasks/build/logrotate.yml deleted file mode 100644 index 10f7e6644..000000000 --- a/docker/base/ubuntu-16.10/conf/provision/roles/webdevops-base/tasks/build/logrotate.yml +++ /dev/null @@ -1,10 +0,0 @@ ---- - -- name: Register logrotate configurations - file: - src: '{{ item }}' - dest: '/etc/logrotate.d/{{ item | basename }}' - state: link - force: yes - with_fileglob: - - /opt/docker/etc/logrotate.d/* diff --git a/docker/base/ubuntu-16.10/conf/provision/service.d/.gitkeep b/docker/base/ubuntu-16.10/conf/provision/service.d/.gitkeep new file mode 100644 index 000000000..e69de29bb diff --git a/docker/base/ubuntu-16.10/conf/provision/service.d/cron.sh b/docker/base/ubuntu-16.10/conf/provision/service.d/cron.sh new file mode 100644 index 000000000..bd8a54781 --- /dev/null +++ b/docker/base/ubuntu-16.10/conf/provision/service.d/cron.sh @@ -0,0 +1,13 @@ +#!/usr/bin/env bash + +IMAGE_FAMILY=$(docker-image-info family) + +case "$IMAGE_FAMILY" in + Debian|Ubuntu) + apt-install cron + ;; + + RedHat) + yum-install cronie + ;; +esac diff --git a/docker/base/ubuntu-16.10/conf/provision/service.d/dnsmasq.sh b/docker/base/ubuntu-16.10/conf/provision/service.d/dnsmasq.sh new file mode 100644 index 000000000..9e5c3228c --- /dev/null +++ b/docker/base/ubuntu-16.10/conf/provision/service.d/dnsmasq.sh @@ -0,0 +1,24 @@ +#!/usr/bin/env bash + +IMAGE_FAMILY=$(docker-image-info family) + +# Installation +case "$IMAGE_FAMILY" in + Debian|Ubuntu) + apt-install dnsmasq + ;; + + RedHat) + yum-install dnsmasq + ;; + + Alpine) + apk-install dnsmasq + ;; +esac + +# Configuration +go-replace --mode=line \ + -s '^[\s]*user[\s]*=' -r 'user = root' \ + -s '^[\s]*conf-dir[\s]*=' -r 'conf-dir = /etc/dnsmasq.d' \ + -- /etc/dnsmasq.conf diff --git a/docker/base/ubuntu-16.10/conf/provision/service.d/postfix.sh b/docker/base/ubuntu-16.10/conf/provision/service.d/postfix.sh new file mode 100644 index 000000000..ff1879345 --- /dev/null +++ b/docker/base/ubuntu-16.10/conf/provision/service.d/postfix.sh @@ -0,0 +1,28 @@ +#!/usr/bin/env bash + +IMAGE_FAMILY=$(docker-image-info family) + +# Installation +case "$IMAGE_FAMILY" in + Debian|Ubuntu) + apt-install postfix + ;; + + RedHat) + yum-install postfix + ;; + + Alpine) + apk-install postfix + ln -s -f /etc/postfix/aliases /etc/aliases + ;; +esac + +# Configuration +go-replace --mode=line \ + -s '^[\s]*mydestination[\s]*=' -r 'mydestination = ' \ + -s '^[\s]*message_size_limit[\s]*=' -r 'message_size_limit = 15240000' \ + -s '^[\s]*smtp_use_tls[\s]*=' -r 'smtp_use_tls = yes' \ + -s '^[\s]*smtp_tls_security_level[\s]*=' -r 'smtp_tls_security_level = may' \ + -s '^[\s]*myhostname[\s]*=' -r '# myhostname' \ + -- /etc/postfix/main.cf diff --git a/docker/base/ubuntu-16.10/conf/provision/service.d/ssh.sh b/docker/base/ubuntu-16.10/conf/provision/service.d/ssh.sh new file mode 100644 index 000000000..63d7a9f3a --- /dev/null +++ b/docker/base/ubuntu-16.10/conf/provision/service.d/ssh.sh @@ -0,0 +1,17 @@ +#!/usr/bin/env bash + +IMAGE_FAMILY=$(docker-image-info family) + +case "$IMAGE_FAMILY" in + Debian|Ubuntu) + apt-install openssh-server + ;; + + RedHat) + yum-install openssh-server + ;; + + Alpine) + apk-install openssh + ;; +esac diff --git a/docker/base/ubuntu-16.10/conf/provision/service.d/syslog.sh b/docker/base/ubuntu-16.10/conf/provision/service.d/syslog.sh new file mode 100644 index 000000000..7e8b8e0a9 --- /dev/null +++ b/docker/base/ubuntu-16.10/conf/provision/service.d/syslog.sh @@ -0,0 +1,41 @@ +#!/usr/bin/env bash + +IMAGE_FAMILY=$(docker-image-info family) + +# Installation +case "$IMAGE_FAMILY" in + Debian|Ubuntu) + apt-install syslog-ng syslog-ng-core + ;; + + RedHat) + yum-install syslog-ng + + # remove logrotate (not needed for docker) + rm -f "/etc/cron.daily/logrotate" + ;; + + Alpine) + apk-install syslog-ng + ;; +esac + +## Configuration +SYSLOG_NG_VERSION=$(syslog-ng --version | grep -E -e '^syslog-ng[ ]+[0-9]+\.[0-9]+' | head -n 1 | awk '{print $2}' | cut -f 1,2 -d .) + +# Disable caps inside container +if [[ -f /etc/default/syslog-ng ]]; then + go-replace --mode=lineinfile \ + -s "SYSLOGNG_OPTS" -r "SYSLOGNG_OPTS = --no-caps" \ + -- /etc/default/syslog-ng +fi + +# Symlink configuration +ln -s -f /opt/docker/etc/syslog-ng/syslog-ng.conf /etc/syslog-ng/syslog-ng.conf + +go-replace --mode=lineinfile \ + -s "@version" -r "@version: ${SYSLOG_NG_VERSION}" \ + -- /etc/syslog-ng/syslog-ng.conf + +# Ensure /var/lib/syslog-ng exists +mkdir -p /var/lib/syslog-ng diff --git a/docker/base/ubuntu-16.10/conf/provision/variables-webdevops.yml b/docker/base/ubuntu-16.10/conf/provision/variables-webdevops.yml new file mode 100644 index 000000000..0b2a21a95 --- /dev/null +++ b/docker/base/ubuntu-16.10/conf/provision/variables-webdevops.yml @@ -0,0 +1,7 @@ +--- + +docker_image_info_family: "{{ lookup('pipe', 'docker-image-info family') }}" +docker_image_info_distribution: "{{ lookup('pipe', 'docker-image-info dist') }}" +docker_image_info_distribution_version: "{{ lookup('pipe', 'docker-image-info dist-version') }}" +docker_image_info_distribution_release: "{{ lookup('pipe', 'docker-image-info dist-release') }}" +docker_image_info_distribution_codename: "{{ lookup('pipe', 'docker-image-info dist-codename') }}" diff --git a/docker/base/ubuntu-16.10/conf/provision/variables.yml b/docker/base/ubuntu-16.10/conf/provision/variables.yml index ed97d539c..0b2a21a95 100644 --- a/docker/base/ubuntu-16.10/conf/provision/variables.yml +++ b/docker/base/ubuntu-16.10/conf/provision/variables.yml @@ -1 +1,7 @@ --- + +docker_image_info_family: "{{ lookup('pipe', 'docker-image-info family') }}" +docker_image_info_distribution: "{{ lookup('pipe', 'docker-image-info dist') }}" +docker_image_info_distribution_version: "{{ lookup('pipe', 'docker-image-info dist-version') }}" +docker_image_info_distribution_release: "{{ lookup('pipe', 'docker-image-info dist-release') }}" +docker_image_info_distribution_codename: "{{ lookup('pipe', 'docker-image-info dist-codename') }}" diff --git a/docker/bootstrap/alpine-3 b/docker/bootstrap/alpine-3 new file mode 120000 index 000000000..0120374ca --- /dev/null +++ b/docker/bootstrap/alpine-3 @@ -0,0 +1 @@ +alpine \ No newline at end of file diff --git a/docker/bootstrap/alpine-3/Dockerfile b/docker/bootstrap/alpine-3/Dockerfile deleted file mode 100644 index 9ef3433c3..000000000 --- a/docker/bootstrap/alpine-3/Dockerfile +++ /dev/null @@ -1,67 +0,0 @@ -#+++++++++++++++++++++++++++++++++++++++ -# Dockerfile for webdevops/bootstrap:alpine-3 -# -- automatically generated -- -#+++++++++++++++++++++++++++++++++++++++ - -FROM alpine:3.5 - -MAINTAINER info@webdevops.io -LABEL vendor=WebDevOps.io -LABEL io.webdevops.layout=8 -LABEL io.webdevops.version=1.5.0 - -ENV TERM "xterm" -ENV LANG "en_US.UTF-8" -ENV LC_ALL "en_US.UTF-8" - -ADD baselayout.tar / - -# Init bootstrap (and install ansible) -RUN set -x \ - # Fix root terminal - && echo "export TERM=xterm" >> /root/.bashrc \ - # Add community - && echo http://dl-4.alpinelinux.org/alpine/v3.5/community/ >> /etc/apk/repositories \ - # System update - && /usr/local/bin/apk-upgrade \ - # Install base stuff - && /usr/local/bin/apk-install \ - bash \ - ca-certificates \ - # Install ansible - && /usr/local/bin/apk-install \ - python \ - python-dev \ - py-setuptools \ - py-crypto \ - py2-pip \ - py-cparser \ - py-cryptography \ - py-markupsafe \ - py-cffi \ - py-yaml \ - py-jinja2 \ - py-paramiko \ - && pip install --upgrade pip \ - && hash -r \ - && pip install ansible \ - && chmod 750 /usr/bin/ansible* \ - # Install gosu - && GOSU_VERSION=1.10 \ - && apk add --no-cache --virtual .gosu-deps \ - dpkg \ - gnupg \ - openssl \ - && dpkgArch="amd64" \ - && wget -O /usr/local/bin/gosu "https://github.com/tianon/gosu/releases/download/$GOSU_VERSION/gosu-$dpkgArch" \ - && wget -O /usr/local/bin/gosu.asc "https://github.com/tianon/gosu/releases/download/$GOSU_VERSION/gosu-$dpkgArch.asc" \ - && export GNUPGHOME="$(mktemp -d)" \ - && gpg --keyserver ha.pool.sks-keyservers.net --recv-keys B42F6819007F00F88E364FD4036A9C25BF357DD4 \ - && gpg --batch --verify /usr/local/bin/gosu.asc /usr/local/bin/gosu \ - && rm -r "$GNUPGHOME" /usr/local/bin/gosu.asc \ - && chmod +x /usr/local/bin/gosu \ - && gosu nobody true \ - && apk del .gosu-deps \ - # Cleanup - && apk del python-dev \ - && find /var/log/ -mindepth 1 -delete diff --git a/docker/bootstrap/alpine-3/baselayout.tar b/docker/bootstrap/alpine-3/baselayout.tar deleted file mode 100644 index 9fe660194..000000000 Binary files a/docker/bootstrap/alpine-3/baselayout.tar and /dev/null differ diff --git a/docker/bootstrap/alpine/Dockerfile b/docker/bootstrap/alpine/Dockerfile new file mode 100644 index 000000000..88f161803 --- /dev/null +++ b/docker/bootstrap/alpine/Dockerfile @@ -0,0 +1,52 @@ +#+++++++++++++++++++++++++++++++++++++++ +# Dockerfile for webdevops/bootstrap:alpine +# -- automatically generated -- +#+++++++++++++++++++++++++++++++++++++++ + +FROM alpine:3.5 + +LABEL maintainer=info@webdevops.io \ + vendor=WebDevOps.io \ + io.webdevops.layout=8 \ + io.webdevops.version=1.5.0 + +ENV TERM="xterm" \ + LANG="C.UTF-8" \ + LC_ALL="C.UTF-8" + +ADD baselayout.tar / + +# Init bootstrap +RUN set -x \ + # Add community + && echo http://dl-4.alpinelinux.org/alpine/v3.5/community/ >> /etc/apk/repositories \ + # System update + && /usr/local/bin/apk-upgrade \ + # Install base stuff + && /usr/local/bin/apk-install \ + bash \ + ca-certificates \ + openssl \ + && update-ca-certificates \ + && /usr/local/bin/generate-dockerimage-info \ + # Install gosu + && GOSU_VERSION=1.10 \ + && apk add --no-cache --virtual .gosu-deps \ + dpkg \ + gnupg \ + openssl \ + && dpkgArch="amd64" \ + && wget -O /usr/local/bin/gosu "https://github.com/tianon/gosu/releases/download/$GOSU_VERSION/gosu-$dpkgArch" \ + && wget -O /usr/local/bin/gosu.asc "https://github.com/tianon/gosu/releases/download/$GOSU_VERSION/gosu-$dpkgArch.asc" \ + && export GNUPGHOME="$(mktemp -d)" \ + && gpg --keyserver ha.pool.sks-keyservers.net --recv-keys B42F6819007F00F88E364FD4036A9C25BF357DD4 \ + && gpg --batch --verify /usr/local/bin/gosu.asc /usr/local/bin/gosu \ + && rm -r "$GNUPGHOME" /usr/local/bin/gosu.asc \ + && chmod +x /usr/local/bin/gosu \ + && gosu nobody true \ + && apk del .gosu-deps \ + ## Install go-replace + && GOREPLACE_VERSION=0.5.4 \ + && wget -O /usr/local/bin/go-replace https://github.com/webdevops/goreplace/releases/download/$GOREPLACE_VERSION/gr-64-linux \ + && chmod +x /usr/local/bin/go-replace \ + && docker-image-cleanup diff --git a/docker/bootstrap/alpine-3/Dockerfile.jinja2 b/docker/bootstrap/alpine/Dockerfile.jinja2 similarity index 100% rename from docker/bootstrap/alpine-3/Dockerfile.jinja2 rename to docker/bootstrap/alpine/Dockerfile.jinja2 diff --git a/docker/bootstrap/alpine/baselayout.tar b/docker/bootstrap/alpine/baselayout.tar new file mode 100644 index 000000000..dc5fbe08f Binary files /dev/null and b/docker/bootstrap/alpine/baselayout.tar differ diff --git a/docker/bootstrap/centos-7/Dockerfile b/docker/bootstrap/centos-7/Dockerfile index 61ae28f57..353501e59 100644 --- a/docker/bootstrap/centos-7/Dockerfile +++ b/docker/bootstrap/centos-7/Dockerfile @@ -5,41 +5,24 @@ FROM centos:7 -MAINTAINER info@webdevops.io -LABEL vendor=WebDevOps.io -LABEL io.webdevops.layout=8 -LABEL io.webdevops.version=1.5.0 +LABEL maintainer=info@webdevops.io \ + vendor=WebDevOps.io \ + io.webdevops.layout=8 \ + io.webdevops.version=1.5.0 -ENV TERM "xterm" -ENV LANG "en_US.UTF-8" -ENV LC_ALL "en_US.UTF-8" +ENV TERM="xterm" \ + LANG="en_US.utf8" \ + LC_ALL="en_US.utf8" ADD baselayout.tar / -# Init bootstrap (and install ansible) +# Init bootstrap RUN set -x \ - # Fix root terminal - && echo "export TERM=xterm" >> /root/.bashrc \ # System update && /usr/local/bin/yum-upgrade \ - # Install ansible && /usr/local/bin/yum-install \ epel-release \ - PyYAML \ - python-jinja2 \ - python-httplib2 \ - python-keyczar \ - python-paramiko \ - python-setuptools \ - python-setuptools-devel \ - libffi \ - python-devel \ - libffi-devel \ - && easy_install pip \ - && pip install --upgrade pip \ - && hash -r \ - && pip install ansible \ - && chmod 750 /usr/bin/ansible* \ + && /usr/local/bin/generate-dockerimage-info \ # Install gosu && GOSU_VERSION=1.10 \ && /usr/local/bin/yum-install gpg wget \ @@ -52,8 +35,9 @@ RUN set -x \ && rm -r "$GNUPGHOME" /usr/local/bin/gosu.asc \ && chmod +x /usr/local/bin/gosu \ && gosu nobody true \ + ## Install go-replace + && GOREPLACE_VERSION=0.5.4 \ + && wget -O /usr/local/bin/go-replace https://github.com/webdevops/goreplace/releases/download/$GOREPLACE_VERSION/gr-64-linux \ + && chmod +x /usr/local/bin/go-replace \ && yum erase -y wget \ - # Cleanup - && yum erase -y python-devel \ - && yum clean all \ - && find /var/log/ -mindepth 1 -delete + && docker-image-cleanup diff --git a/docker/bootstrap/centos-7/Dockerfile.jinja2 b/docker/bootstrap/centos-7/Dockerfile.jinja2 index d248f9571..e75d76b54 100644 --- a/docker/bootstrap/centos-7/Dockerfile.jinja2 +++ b/docker/bootstrap/centos-7/Dockerfile.jinja2 @@ -2,7 +2,7 @@ {{ docker.version() }} -{{ environment.general() }} +{{ environment.general(charset='en_US.utf8') }} {{ docker.add('baselayout.tar', '/') }} diff --git a/docker/bootstrap/centos-7/baselayout.tar b/docker/bootstrap/centos-7/baselayout.tar index 9fe660194..dc5fbe08f 100644 Binary files a/docker/bootstrap/centos-7/baselayout.tar and b/docker/bootstrap/centos-7/baselayout.tar differ diff --git a/docker/bootstrap/debian-7/Dockerfile b/docker/bootstrap/debian-7/Dockerfile index 1ff5c39be..f02be8fa4 100644 --- a/docker/bootstrap/debian-7/Dockerfile +++ b/docker/bootstrap/debian-7/Dockerfile @@ -5,50 +5,31 @@ FROM debian:7 -MAINTAINER info@webdevops.io -LABEL vendor=WebDevOps.io -LABEL io.webdevops.layout=8 -LABEL io.webdevops.version=1.5.0 +LABEL maintainer=info@webdevops.io \ + vendor=WebDevOps.io \ + io.webdevops.layout=8 \ + io.webdevops.version=1.5.0 -ENV TERM "xterm" -ENV LANG "en_US.UTF-8" -ENV LC_ALL "en_US.UTF-8" +ENV TERM="xterm" \ + LANG="C.UTF-8" \ + LC_ALL="C.UTF-8" ADD baselayout.tar / -# Init bootstrap (and install ansible) -RUN export DEBIAN_FRONTEND=noninteractive \ - && set -x \ - # Fix root terminal - && echo "export TERM=xterm" >> /root/.bashrc \ +# Init bootstrap +RUN set -x \ + && apt-update \ + && /usr/local/bin/generate-dockerimage-info \ # Enable non-free - && sed -ri 's/(deb.*\/debian wheezy main)/\1 contrib non-free /' -- /etc/apt/sources.list \ - # System updatei + && sed -ri "s/(deb.*\/debian $(docker-image-info dist-codename) main)/\1 contrib non-free /" -- /etc/apt/sources.list \ + && apt-update \ + # System update && /usr/local/bin/apt-upgrade \ # Base stuff && /usr/local/bin/apt-install \ - lsb-release \ + apt-transport-https \ ca-certificates \ locales \ - apt-transport-https \ - # Generate base locale - && echo "en_US.UTF-8 UTF-8" > /etc/locale.gen \ - && locale-gen \ - && /usr/local/bin/apt-install \ - # Install ansible - python-minimal \ - python-setuptools \ - python-pip \ - python-paramiko \ - python-jinja2 \ - python-dev \ - libffi-dev \ - libssl-dev \ - build-essential \ - && pip install --upgrade pip \ - && hash -r \ - && pip install ansible \ - && chmod 750 /usr/local/bin/ansible* \ # Install gosu && GOSU_VERSION=1.10 \ && /usr/local/bin/apt-install wget gnupg dirmngr \ @@ -61,13 +42,9 @@ RUN export DEBIAN_FRONTEND=noninteractive \ && rm -rf "$GNUPGHOME" /usr/local/bin/gosu.asc \ && chmod +x /usr/local/bin/gosu \ && gosu nobody true \ + ## Install go-replace + && GOREPLACE_VERSION=0.5.4 \ + && wget -O /usr/local/bin/go-replace https://github.com/webdevops/goreplace/releases/download/$GOREPLACE_VERSION/gr-64-linux \ + && chmod +x /usr/local/bin/go-replace \ && apt-get purge -y -f --force-yes wget dirmngr \ - # Cleanup - && apt-get purge -y -f --force-yes \ - python-dev \ - build-essential \ - libssl-dev \ - libffi-dev \ - && apt-get autoremove -y -f \ - && apt-get clean -y \ - && find /var/log/ -mindepth 1 -delete + && docker-image-cleanup diff --git a/docker/bootstrap/debian-7/baselayout.tar b/docker/bootstrap/debian-7/baselayout.tar index 9fe660194..dc5fbe08f 100644 Binary files a/docker/bootstrap/debian-7/baselayout.tar and b/docker/bootstrap/debian-7/baselayout.tar differ diff --git a/docker/bootstrap/debian-8/Dockerfile b/docker/bootstrap/debian-8/Dockerfile index 177a66737..cea111f90 100644 --- a/docker/bootstrap/debian-8/Dockerfile +++ b/docker/bootstrap/debian-8/Dockerfile @@ -5,50 +5,31 @@ FROM debian:8 -MAINTAINER info@webdevops.io -LABEL vendor=WebDevOps.io -LABEL io.webdevops.layout=8 -LABEL io.webdevops.version=1.5.0 +LABEL maintainer=info@webdevops.io \ + vendor=WebDevOps.io \ + io.webdevops.layout=8 \ + io.webdevops.version=1.5.0 -ENV TERM "xterm" -ENV LANG "en_US.UTF-8" -ENV LC_ALL "en_US.UTF-8" +ENV TERM="xterm" \ + LANG="C.UTF-8" \ + LC_ALL="C.UTF-8" ADD baselayout.tar / -# Init bootstrap (and install ansible) -RUN export DEBIAN_FRONTEND=noninteractive \ - && set -x \ - # Fix root terminal - && echo "export TERM=xterm" >> /root/.bashrc \ +# Init bootstrap +RUN set -x \ + && apt-update \ + && /usr/local/bin/generate-dockerimage-info \ # Enable non-free - && sed -ri 's/(deb.*\/debian jessie main)/\1 contrib non-free /' -- /etc/apt/sources.list \ - # System updatei + && sed -ri "s/(deb.*\/debian $(docker-image-info dist-codename) main)/\1 contrib non-free /" -- /etc/apt/sources.list \ + && apt-update \ + # System update && /usr/local/bin/apt-upgrade \ # Base stuff && /usr/local/bin/apt-install \ - lsb-release \ + apt-transport-https \ ca-certificates \ locales \ - apt-transport-https \ - # Generate base locale - && echo "en_US.UTF-8 UTF-8" > /etc/locale.gen \ - && locale-gen \ - && /usr/local/bin/apt-install \ - # Install ansible - python-minimal \ - python-setuptools \ - python-pip \ - python-paramiko \ - python-jinja2 \ - python-dev \ - libffi-dev \ - libssl-dev \ - build-essential \ - && pip install --upgrade pip \ - && hash -r \ - && pip install ansible \ - && chmod 750 /usr/local/bin/ansible* \ # Install gosu && GOSU_VERSION=1.10 \ && /usr/local/bin/apt-install wget gnupg dirmngr \ @@ -61,13 +42,9 @@ RUN export DEBIAN_FRONTEND=noninteractive \ && rm -rf "$GNUPGHOME" /usr/local/bin/gosu.asc \ && chmod +x /usr/local/bin/gosu \ && gosu nobody true \ + ## Install go-replace + && GOREPLACE_VERSION=0.5.4 \ + && wget -O /usr/local/bin/go-replace https://github.com/webdevops/goreplace/releases/download/$GOREPLACE_VERSION/gr-64-linux \ + && chmod +x /usr/local/bin/go-replace \ && apt-get purge -y -f --force-yes wget dirmngr \ - # Cleanup - && apt-get purge -y -f --force-yes \ - python-dev \ - build-essential \ - libssl-dev \ - libffi-dev \ - && apt-get autoremove -y -f \ - && apt-get clean -y \ - && find /var/log/ -mindepth 1 -delete + && docker-image-cleanup diff --git a/docker/bootstrap/debian-8/baselayout.tar b/docker/bootstrap/debian-8/baselayout.tar index 9fe660194..dc5fbe08f 100644 Binary files a/docker/bootstrap/debian-8/baselayout.tar and b/docker/bootstrap/debian-8/baselayout.tar differ diff --git a/docker/bootstrap/debian-9/Dockerfile b/docker/bootstrap/debian-9/Dockerfile index 2d315e158..a8d40bb46 100644 --- a/docker/bootstrap/debian-9/Dockerfile +++ b/docker/bootstrap/debian-9/Dockerfile @@ -5,50 +5,31 @@ FROM debian:stretch -MAINTAINER info@webdevops.io -LABEL vendor=WebDevOps.io -LABEL io.webdevops.layout=8 -LABEL io.webdevops.version=1.5.0 +LABEL maintainer=info@webdevops.io \ + vendor=WebDevOps.io \ + io.webdevops.layout=8 \ + io.webdevops.version=1.5.0 -ENV TERM "xterm" -ENV LANG "en_US.UTF-8" -ENV LC_ALL "en_US.UTF-8" +ENV TERM="xterm" \ + LANG="C.UTF-8" \ + LC_ALL="C.UTF-8" ADD baselayout.tar / -# Init bootstrap (and install ansible) -RUN export DEBIAN_FRONTEND=noninteractive \ - && set -x \ - # Fix root terminal - && echo "export TERM=xterm" >> /root/.bashrc \ +# Init bootstrap +RUN set -x \ + && apt-update \ + && /usr/local/bin/generate-dockerimage-info \ # Enable non-free - && sed -ri 's/(deb.*\/debian stretch main)/\1 contrib non-free /' -- /etc/apt/sources.list \ - # System updatei + && sed -ri "s/(deb.*\/debian $(docker-image-info dist-codename) main)/\1 contrib non-free /" -- /etc/apt/sources.list \ + && apt-update \ + # System update && /usr/local/bin/apt-upgrade \ # Base stuff && /usr/local/bin/apt-install \ - lsb-release \ + apt-transport-https \ ca-certificates \ locales \ - apt-transport-https \ - # Generate base locale - && echo "en_US.UTF-8 UTF-8" > /etc/locale.gen \ - && locale-gen \ - && /usr/local/bin/apt-install \ - # Install ansible - python-minimal \ - python-setuptools \ - python-pip \ - python-paramiko \ - python-jinja2 \ - python-dev \ - libffi-dev \ - libssl-dev \ - build-essential \ - && pip install --upgrade pip \ - && hash -r \ - && pip install ansible \ - && chmod 750 /usr/local/bin/ansible* \ # Install gosu && GOSU_VERSION=1.10 \ && /usr/local/bin/apt-install wget gnupg dirmngr \ @@ -61,13 +42,9 @@ RUN export DEBIAN_FRONTEND=noninteractive \ && rm -rf "$GNUPGHOME" /usr/local/bin/gosu.asc \ && chmod +x /usr/local/bin/gosu \ && gosu nobody true \ + ## Install go-replace + && GOREPLACE_VERSION=0.5.4 \ + && wget -O /usr/local/bin/go-replace https://github.com/webdevops/goreplace/releases/download/$GOREPLACE_VERSION/gr-64-linux \ + && chmod +x /usr/local/bin/go-replace \ && apt-get purge -y -f --force-yes wget dirmngr \ - # Cleanup - && apt-get purge -y -f --force-yes \ - python-dev \ - build-essential \ - libssl-dev \ - libffi-dev \ - && apt-get autoremove -y -f \ - && apt-get clean -y \ - && find /var/log/ -mindepth 1 -delete + && docker-image-cleanup diff --git a/docker/bootstrap/debian-9/baselayout.tar b/docker/bootstrap/debian-9/baselayout.tar index 9fe660194..dc5fbe08f 100644 Binary files a/docker/bootstrap/debian-9/baselayout.tar and b/docker/bootstrap/debian-9/baselayout.tar differ diff --git a/docker/bootstrap/ubuntu-12.04/Dockerfile b/docker/bootstrap/ubuntu-12.04/Dockerfile index 8491cd490..53658d63c 100644 --- a/docker/bootstrap/ubuntu-12.04/Dockerfile +++ b/docker/bootstrap/ubuntu-12.04/Dockerfile @@ -5,51 +5,34 @@ FROM ubuntu:12.04 -MAINTAINER info@webdevops.io -LABEL vendor=WebDevOps.io -LABEL io.webdevops.layout=8 -LABEL io.webdevops.version=1.5.0 +LABEL maintainer=info@webdevops.io \ + vendor=WebDevOps.io \ + io.webdevops.layout=8 \ + io.webdevops.version=1.5.0 -ENV TERM "xterm" -ENV LANG "en_US.UTF-8" -ENV LC_ALL "en_US.UTF-8" +ENV TERM="xterm" \ + LANG="C.UTF-8" \ + LC_ALL="C.UTF-8" ADD baselayout.tar / -# Init bootstrap (and install ansible) -RUN export DEBIAN_FRONTEND=noninteractive \ - && set -x \ +# Init bootstrap +RUN set -x \ # Add multiverse && echo "deb http://archive.ubuntu.com/ubuntu/ precise-security multiverse" >> /etc/apt/sources.list \ && echo "deb-src http://archive.ubuntu.com/ubuntu/ precise-security multiverse" >> /etc/apt/sources.list \ && echo "deb http://archive.ubuntu.com/ubuntu/ precise multiverse" >> /etc/apt/sources.list \ && echo "deb-src http://archive.ubuntu.com/ubuntu/ precise multiverse" >> /etc/apt/sources.list \ - # Fix root terminal - && echo "export TERM=xterm" >> /root/.bashrc \ - # Generate base locale - && locale-gen en_US.UTF-8 \ + && apt-update \ # System update && /usr/local/bin/apt-upgrade \ # Install base stuff && /usr/local/bin/apt-install \ + apt-transport-https \ python-software-properties \ - lsb-release \ ca-certificates \ - # Install ansible - python-minimal \ - python-setuptools \ - python-pip \ - python-paramiko \ - python-jinja2 \ - python-dev \ - libffi-dev \ - libssl-dev \ - build-essential \ apt-transport-https \ - && pip install --upgrade pip \ - && hash -r \ - && pip install ansible \ - && chmod 750 /usr/local/bin/ansible* \ + && /usr/local/bin/generate-dockerimage-info \ # Install gosu && GOSU_VERSION=1.10 \ && /usr/local/bin/apt-install wget gnupg \ @@ -62,13 +45,9 @@ RUN export DEBIAN_FRONTEND=noninteractive \ && rm -r "$GNUPGHOME" /usr/local/bin/gosu.asc \ && chmod +x /usr/local/bin/gosu \ && gosu nobody true \ + ## Install go-replace + && GOREPLACE_VERSION=0.5.4 \ + && wget -O /usr/local/bin/go-replace https://github.com/webdevops/goreplace/releases/download/$GOREPLACE_VERSION/gr-64-linux \ + && chmod +x /usr/local/bin/go-replace \ && apt-get purge -y -f --force-yes wget \ - # Cleanup - && apt-get purge -y -f --force-yes \ - python-dev \ - build-essential \ - libssl-dev \ - libffi-dev \ - && apt-get autoremove -y -f \ - && apt-get clean -y \ - && find /var/log/ -mindepth 1 -delete + && docker-image-cleanup diff --git a/docker/bootstrap/ubuntu-12.04/baselayout.tar b/docker/bootstrap/ubuntu-12.04/baselayout.tar index 9fe660194..dc5fbe08f 100644 Binary files a/docker/bootstrap/ubuntu-12.04/baselayout.tar and b/docker/bootstrap/ubuntu-12.04/baselayout.tar differ diff --git a/docker/bootstrap/ubuntu-14.04/Dockerfile b/docker/bootstrap/ubuntu-14.04/Dockerfile index 54f7edd07..c97143d20 100644 --- a/docker/bootstrap/ubuntu-14.04/Dockerfile +++ b/docker/bootstrap/ubuntu-14.04/Dockerfile @@ -5,49 +5,29 @@ FROM ubuntu:14.04 -MAINTAINER info@webdevops.io -LABEL vendor=WebDevOps.io -LABEL io.webdevops.layout=8 -LABEL io.webdevops.version=1.5.0 +LABEL maintainer=info@webdevops.io \ + vendor=WebDevOps.io \ + io.webdevops.layout=8 \ + io.webdevops.version=1.5.0 -ENV TERM "xterm" -ENV LANG "en_US.UTF-8" -ENV LC_ALL "en_US.UTF-8" +ENV TERM="xterm" \ + LANG="C.UTF-8" \ + LC_ALL="C.UTF-8" ADD baselayout.tar / -# Init bootstrap (and install ansible) -RUN export DEBIAN_FRONTEND=noninteractive \ - && set -x \ - # Fix root terminal - && echo "export TERM=xterm" >> /root/.bashrc \ - # Generate base locale - && locale-gen en_US.UTF-8 \ +# Init bootstrap +RUN set -x \ + && apt-update \ # System update && /usr/local/bin/apt-upgrade \ # Install base stuff && /usr/local/bin/apt-install \ - software-properties-common \ - lsb-release \ ca-certificates \ apt-transport-https \ && apt-add-repository multiverse \ - # Install ansible - && /usr/local/bin/apt-install \ - python-minimal \ - python-setuptools \ - python-pip \ - python-paramiko \ - python-jinja2 \ - python-cffi \ - python-dev \ - libffi-dev \ - libssl-dev \ - build-essential \ - && pip install --upgrade pip \ - && hash -r \ - && pip install ansible \ - && chmod 750 /usr/local/bin/ansible* \ + && apt-update \ + && /usr/local/bin/generate-dockerimage-info \ # Install gosu && GOSU_VERSION=1.10 \ && /usr/local/bin/apt-install wget gnupg \ @@ -60,13 +40,9 @@ RUN export DEBIAN_FRONTEND=noninteractive \ && rm -r "$GNUPGHOME" /usr/local/bin/gosu.asc \ && chmod +x /usr/local/bin/gosu \ && gosu nobody true \ + ## Install go-replace + && GOREPLACE_VERSION=0.5.4 \ + && wget -O /usr/local/bin/go-replace https://github.com/webdevops/goreplace/releases/download/$GOREPLACE_VERSION/gr-64-linux \ + && chmod +x /usr/local/bin/go-replace \ && apt-get purge -y -f --force-yes wget \ - # Cleanup - && apt-get purge -y -f --force-yes \ - python-dev \ - build-essential \ - libssl-dev \ - libffi-dev \ - && apt-get autoremove -y -f \ - && apt-get clean -y \ - && find /var/log/ -mindepth 1 -delete + && docker-image-cleanup diff --git a/docker/bootstrap/ubuntu-14.04/baselayout.tar b/docker/bootstrap/ubuntu-14.04/baselayout.tar index 9fe660194..dc5fbe08f 100644 Binary files a/docker/bootstrap/ubuntu-14.04/baselayout.tar and b/docker/bootstrap/ubuntu-14.04/baselayout.tar differ diff --git a/docker/bootstrap/ubuntu-15.04/Dockerfile b/docker/bootstrap/ubuntu-15.04/Dockerfile index 355bb5bcb..9ef86f61f 100644 --- a/docker/bootstrap/ubuntu-15.04/Dockerfile +++ b/docker/bootstrap/ubuntu-15.04/Dockerfile @@ -5,49 +5,29 @@ FROM ubuntu:15.04 -MAINTAINER info@webdevops.io -LABEL vendor=WebDevOps.io -LABEL io.webdevops.layout=8 -LABEL io.webdevops.version=1.5.0 +LABEL maintainer=info@webdevops.io \ + vendor=WebDevOps.io \ + io.webdevops.layout=8 \ + io.webdevops.version=1.5.0 -ENV TERM "xterm" -ENV LANG "en_US.UTF-8" -ENV LC_ALL "en_US.UTF-8" +ENV TERM="xterm" \ + LANG="C.UTF-8" \ + LC_ALL="C.UTF-8" ADD baselayout.tar / -# Init bootstrap (and install ansible) -RUN export DEBIAN_FRONTEND=noninteractive \ - && set -x \ - # Fix root terminal - && echo "export TERM=xterm" >> /root/.bashrc \ - # Generate base locale - && locale-gen en_US.UTF-8 \ +# Init bootstrap +RUN set -x \ + && apt-update \ # System update && /usr/local/bin/apt-upgrade \ # Install base stuff && /usr/local/bin/apt-install \ - software-properties-common \ - lsb-release \ ca-certificates \ apt-transport-https \ && apt-add-repository multiverse \ - # Install ansible - && /usr/local/bin/apt-install \ - python-minimal \ - python-setuptools \ - python-pip \ - python-paramiko \ - python-jinja2 \ - python-cffi \ - python-dev \ - libffi-dev \ - libssl-dev \ - build-essential \ - && pip install --upgrade pip \ - && hash -r \ - && pip install ansible \ - && chmod 750 /usr/local/bin/ansible* \ + && apt-update \ + && /usr/local/bin/generate-dockerimage-info \ # Install gosu && GOSU_VERSION=1.10 \ && /usr/local/bin/apt-install wget gnupg \ @@ -60,13 +40,9 @@ RUN export DEBIAN_FRONTEND=noninteractive \ && rm -r "$GNUPGHOME" /usr/local/bin/gosu.asc \ && chmod +x /usr/local/bin/gosu \ && gosu nobody true \ + ## Install go-replace + && GOREPLACE_VERSION=0.5.4 \ + && wget -O /usr/local/bin/go-replace https://github.com/webdevops/goreplace/releases/download/$GOREPLACE_VERSION/gr-64-linux \ + && chmod +x /usr/local/bin/go-replace \ && apt-get purge -y -f --force-yes wget \ - # Cleanup - && apt-get purge -y -f --force-yes \ - python-dev \ - build-essential \ - libssl-dev \ - libffi-dev \ - && apt-get autoremove -y -f \ - && apt-get clean -y \ - && find /var/log/ -mindepth 1 -delete + && docker-image-cleanup diff --git a/docker/bootstrap/ubuntu-15.04/baselayout.tar b/docker/bootstrap/ubuntu-15.04/baselayout.tar index 9fe660194..dc5fbe08f 100644 Binary files a/docker/bootstrap/ubuntu-15.04/baselayout.tar and b/docker/bootstrap/ubuntu-15.04/baselayout.tar differ diff --git a/docker/bootstrap/ubuntu-15.10/Dockerfile b/docker/bootstrap/ubuntu-15.10/Dockerfile index 5dead43df..815746055 100644 --- a/docker/bootstrap/ubuntu-15.10/Dockerfile +++ b/docker/bootstrap/ubuntu-15.10/Dockerfile @@ -5,49 +5,29 @@ FROM ubuntu:15.10 -MAINTAINER info@webdevops.io -LABEL vendor=WebDevOps.io -LABEL io.webdevops.layout=8 -LABEL io.webdevops.version=1.5.0 +LABEL maintainer=info@webdevops.io \ + vendor=WebDevOps.io \ + io.webdevops.layout=8 \ + io.webdevops.version=1.5.0 -ENV TERM "xterm" -ENV LANG "en_US.UTF-8" -ENV LC_ALL "en_US.UTF-8" +ENV TERM="xterm" \ + LANG="C.UTF-8" \ + LC_ALL="C.UTF-8" ADD baselayout.tar / -# Init bootstrap (and install ansible) -RUN export DEBIAN_FRONTEND=noninteractive \ - && set -x \ - # Fix root terminal - && echo "export TERM=xterm" >> /root/.bashrc \ - # Generate base locale - && locale-gen en_US.UTF-8 \ +# Init bootstrap +RUN set -x \ + && apt-update \ # System update && /usr/local/bin/apt-upgrade \ # Install base stuff && /usr/local/bin/apt-install \ - software-properties-common \ - lsb-release \ ca-certificates \ apt-transport-https \ && apt-add-repository multiverse \ - # Install ansible - && /usr/local/bin/apt-install \ - python-minimal \ - python-setuptools \ - python-pip \ - python-paramiko \ - python-jinja2 \ - python-cffi \ - python-dev \ - libffi-dev \ - libssl-dev \ - build-essential \ - && pip install --upgrade pip \ - && hash -r \ - && pip install ansible \ - && chmod 750 /usr/local/bin/ansible* \ + && apt-update \ + && /usr/local/bin/generate-dockerimage-info \ # Install gosu && GOSU_VERSION=1.10 \ && /usr/local/bin/apt-install wget gnupg \ @@ -60,13 +40,9 @@ RUN export DEBIAN_FRONTEND=noninteractive \ && rm -r "$GNUPGHOME" /usr/local/bin/gosu.asc \ && chmod +x /usr/local/bin/gosu \ && gosu nobody true \ + ## Install go-replace + && GOREPLACE_VERSION=0.5.4 \ + && wget -O /usr/local/bin/go-replace https://github.com/webdevops/goreplace/releases/download/$GOREPLACE_VERSION/gr-64-linux \ + && chmod +x /usr/local/bin/go-replace \ && apt-get purge -y -f --force-yes wget \ - # Cleanup - && apt-get purge -y -f --force-yes \ - python-dev \ - build-essential \ - libssl-dev \ - libffi-dev \ - && apt-get autoremove -y -f \ - && apt-get clean -y \ - && find /var/log/ -mindepth 1 -delete + && docker-image-cleanup diff --git a/docker/bootstrap/ubuntu-15.10/baselayout.tar b/docker/bootstrap/ubuntu-15.10/baselayout.tar index 9fe660194..dc5fbe08f 100644 Binary files a/docker/bootstrap/ubuntu-15.10/baselayout.tar and b/docker/bootstrap/ubuntu-15.10/baselayout.tar differ diff --git a/docker/bootstrap/ubuntu-16.04/Dockerfile b/docker/bootstrap/ubuntu-16.04/Dockerfile index e518088a8..ac3194605 100644 --- a/docker/bootstrap/ubuntu-16.04/Dockerfile +++ b/docker/bootstrap/ubuntu-16.04/Dockerfile @@ -5,49 +5,29 @@ FROM ubuntu:16.04 -MAINTAINER info@webdevops.io -LABEL vendor=WebDevOps.io -LABEL io.webdevops.layout=8 -LABEL io.webdevops.version=1.5.0 +LABEL maintainer=info@webdevops.io \ + vendor=WebDevOps.io \ + io.webdevops.layout=8 \ + io.webdevops.version=1.5.0 -ENV TERM "xterm" -ENV LANG "en_US.UTF-8" -ENV LC_ALL "en_US.UTF-8" +ENV TERM="xterm" \ + LANG="C.UTF-8" \ + LC_ALL="C.UTF-8" ADD baselayout.tar / -# Init bootstrap (and install ansible) -RUN export DEBIAN_FRONTEND=noninteractive \ - && set -x \ - # Fix root terminal - && echo "export TERM=xterm" >> /root/.bashrc \ - # Generate base locale - && locale-gen en_US.UTF-8 \ +# Init bootstrap +RUN set -x \ + && apt-update \ # System update && /usr/local/bin/apt-upgrade \ # Install base stuff && /usr/local/bin/apt-install \ - software-properties-common \ - lsb-release \ ca-certificates \ apt-transport-https \ && apt-add-repository multiverse \ - # Install ansible - && /usr/local/bin/apt-install \ - python-minimal \ - python-setuptools \ - python-pip \ - python-paramiko \ - python-jinja2 \ - python-cffi \ - python-dev \ - libffi-dev \ - libssl-dev \ - build-essential \ - && pip install --upgrade pip \ - && hash -r \ - && pip install ansible \ - && chmod 750 /usr/local/bin/ansible* \ + && apt-update \ + && /usr/local/bin/generate-dockerimage-info \ # Install gosu && GOSU_VERSION=1.10 \ && /usr/local/bin/apt-install wget gnupg \ @@ -60,13 +40,9 @@ RUN export DEBIAN_FRONTEND=noninteractive \ && rm -r "$GNUPGHOME" /usr/local/bin/gosu.asc \ && chmod +x /usr/local/bin/gosu \ && gosu nobody true \ + ## Install go-replace + && GOREPLACE_VERSION=0.5.4 \ + && wget -O /usr/local/bin/go-replace https://github.com/webdevops/goreplace/releases/download/$GOREPLACE_VERSION/gr-64-linux \ + && chmod +x /usr/local/bin/go-replace \ && apt-get purge -y -f --force-yes wget \ - # Cleanup - && apt-get purge -y -f --force-yes \ - python-dev \ - build-essential \ - libssl-dev \ - libffi-dev \ - && apt-get autoremove -y -f \ - && apt-get clean -y \ - && find /var/log/ -mindepth 1 -delete + && docker-image-cleanup diff --git a/docker/bootstrap/ubuntu-16.04/baselayout.tar b/docker/bootstrap/ubuntu-16.04/baselayout.tar index 9fe660194..dc5fbe08f 100644 Binary files a/docker/bootstrap/ubuntu-16.04/baselayout.tar and b/docker/bootstrap/ubuntu-16.04/baselayout.tar differ diff --git a/docker/bootstrap/ubuntu-16.10/Dockerfile b/docker/bootstrap/ubuntu-16.10/Dockerfile index 9685cbbd4..0707eff74 100644 --- a/docker/bootstrap/ubuntu-16.10/Dockerfile +++ b/docker/bootstrap/ubuntu-16.10/Dockerfile @@ -5,49 +5,29 @@ FROM ubuntu:16.10 -MAINTAINER info@webdevops.io -LABEL vendor=WebDevOps.io -LABEL io.webdevops.layout=8 -LABEL io.webdevops.version=1.5.0 +LABEL maintainer=info@webdevops.io \ + vendor=WebDevOps.io \ + io.webdevops.layout=8 \ + io.webdevops.version=1.5.0 -ENV TERM "xterm" -ENV LANG "en_US.UTF-8" -ENV LC_ALL "en_US.UTF-8" +ENV TERM="xterm" \ + LANG="C.UTF-8" \ + LC_ALL="C.UTF-8" ADD baselayout.tar / -# Init bootstrap (and install ansible) -RUN export DEBIAN_FRONTEND=noninteractive \ - && set -x \ - # Fix root terminal - && echo "export TERM=xterm" >> /root/.bashrc \ - # Generate base locale - && locale-gen en_US.UTF-8 \ +# Init bootstrap +RUN set -x \ + && apt-update \ # System update && /usr/local/bin/apt-upgrade \ # Install base stuff && /usr/local/bin/apt-install \ - software-properties-common \ - lsb-release \ ca-certificates \ apt-transport-https \ && apt-add-repository multiverse \ - # Install ansible - && /usr/local/bin/apt-install \ - python-minimal \ - python-setuptools \ - python-pip \ - python-paramiko \ - python-jinja2 \ - python-cffi \ - python-dev \ - libffi-dev \ - libssl-dev \ - build-essential \ - && pip install --upgrade pip \ - && hash -r \ - && pip install ansible \ - && chmod 750 /usr/local/bin/ansible* \ + && apt-update \ + && /usr/local/bin/generate-dockerimage-info \ # Install gosu && GOSU_VERSION=1.10 \ && /usr/local/bin/apt-install wget gnupg \ @@ -60,13 +40,9 @@ RUN export DEBIAN_FRONTEND=noninteractive \ && rm -r "$GNUPGHOME" /usr/local/bin/gosu.asc \ && chmod +x /usr/local/bin/gosu \ && gosu nobody true \ + ## Install go-replace + && GOREPLACE_VERSION=0.5.4 \ + && wget -O /usr/local/bin/go-replace https://github.com/webdevops/goreplace/releases/download/$GOREPLACE_VERSION/gr-64-linux \ + && chmod +x /usr/local/bin/go-replace \ && apt-get purge -y -f --force-yes wget \ - # Cleanup - && apt-get purge -y -f --force-yes \ - python-dev \ - build-essential \ - libssl-dev \ - libffi-dev \ - && apt-get autoremove -y -f \ - && apt-get clean -y \ - && find /var/log/ -mindepth 1 -delete + && docker-image-cleanup diff --git a/docker/bootstrap/ubuntu-16.10/baselayout.tar b/docker/bootstrap/ubuntu-16.10/baselayout.tar index 9fe660194..dc5fbe08f 100644 Binary files a/docker/bootstrap/ubuntu-16.10/baselayout.tar and b/docker/bootstrap/ubuntu-16.10/baselayout.tar differ diff --git a/docker/certbot/latest/Dockerfile b/docker/certbot/latest/Dockerfile index b163a57b3..912fa7ffa 100644 --- a/docker/certbot/latest/Dockerfile +++ b/docker/certbot/latest/Dockerfile @@ -3,12 +3,7 @@ # -- automatically generated -- #+++++++++++++++++++++++++++++++++++++++ -FROM webdevops/bootstrap:alpine-3 - -MAINTAINER info@webdevops.io -LABEL vendor=WebDevOps.io -LABEL io.webdevops.layout=8 -LABEL io.webdevops.version=1.5.0 +FROM webdevops/bootstrap:alpine VOLUME /etc/letsencrypt VOLUME /var/www @@ -21,4 +16,5 @@ RUN /usr/local/bin/apk-install \ certbot \ && pip install --upgrade pip \ && hash -r \ - && pip install pyRFC3339 configobj ConfigArgParse + && pip install pyRFC3339 configobj ConfigArgParse \ + && docker-image-cleanup diff --git a/docker/certbot/latest/Dockerfile.jinja2 b/docker/certbot/latest/Dockerfile.jinja2 index 91c145f29..59040cca3 100644 --- a/docker/certbot/latest/Dockerfile.jinja2 +++ b/docker/certbot/latest/Dockerfile.jinja2 @@ -1,6 +1,4 @@ -{{ docker.from("bootstrap","alpine-3") }} - -{{ docker.version() }} +{{ docker.from("bootstrap","alpine") }} {{ docker.volume('/etc/letsencrypt') }} {{ docker.volume('/var/www') }} diff --git a/docker/dockerfile-build-env/latest/Dockerfile b/docker/dockerfile-build-env/latest/Dockerfile new file mode 100644 index 000000000..24d421982 --- /dev/null +++ b/docker/dockerfile-build-env/latest/Dockerfile @@ -0,0 +1,47 @@ +#+++++++++++++++++++++++++++++++++++++++ +# Dockerfile for webdevops/dockerfile-build-env:latest +# -- automatically generated -- +#+++++++++++++++++++++++++++++++++++++++ + +FROM webdevops/bootstrap:ubuntu-16.04 + +RUN apt-install \ + build-essential \ + python \ + python-dev \ + python-setuptools \ + python-pip \ + ruby \ + ruby-dev \ + ruby-bundler \ + && pip install --upgrade pip \ + && pip install --upgrade setuptools \ + && pip install --upgrade \ + MarkupSafe \ + Jinja2 \ + graphviz \ + funcsigs \ + pbr \ + six \ + mock \ + psutil \ + pylev \ + py \ + appdirs \ + pyparsing \ + packaging \ + pytest \ + simplejson \ + backpack \ + cleo \ + pyyaml \ + yamlordereddictloader \ + testinfra \ + cloudpickle \ + pyinotify \ + configparser \ + doit==0.29.0 \ + termcolor \ + pytest-timeout \ + pytest-rerunfailures \ + && docker-image-cleanup diff --git a/docker/dockerfile-build-env/latest/Dockerfile.jinja2 b/docker/dockerfile-build-env/latest/Dockerfile.jinja2 new file mode 100644 index 000000000..2c3c22854 --- /dev/null +++ b/docker/dockerfile-build-env/latest/Dockerfile.jinja2 @@ -0,0 +1,42 @@ +{{ docker.from("bootstrap","ubuntu-16.04") }} + +RUN apt-install \ + build-essential \ + python \ + python-dev \ + python-setuptools \ + python-pip \ + ruby \ + ruby-dev \ + ruby-bundler \ + && pip install --upgrade pip \ + && pip install --upgrade setuptools \ + && pip install --upgrade \ + MarkupSafe \ + Jinja2 \ + graphviz \ + funcsigs \ + pbr \ + six \ + mock \ + psutil \ + pylev \ + py \ + appdirs \ + pyparsing \ + packaging \ + pytest \ + simplejson \ + backpack \ + cleo \ + pyyaml \ + yamlordereddictloader \ + testinfra \ + cloudpickle \ + pyinotify \ + configparser \ + doit==0.29.0 \ + termcolor \ + pytest-timeout \ + pytest-rerunfailures \ + {{ docker.cleanup() }} diff --git a/docker/hhvm-apache/ubuntu-14.04/Dockerfile b/docker/hhvm-apache/ubuntu-14.04/Dockerfile index 2d29e8db7..95830dfb6 100644 --- a/docker/hhvm-apache/ubuntu-14.04/Dockerfile +++ b/docker/hhvm-apache/ubuntu-14.04/Dockerfile @@ -5,15 +5,10 @@ FROM webdevops/hhvm:ubuntu-14.04 -MAINTAINER info@webdevops.io -LABEL vendor=WebDevOps.io -LABEL io.webdevops.layout=8 -LABEL io.webdevops.version=1.5.0 - -ENV WEB_DOCUMENT_ROOT /app -ENV WEB_DOCUMENT_INDEX index.php -ENV WEB_ALIAS_DOMAIN *.vm -ENV WEB_PHP_SOCKET 127.0.0.1:9000 +ENV WEB_DOCUMENT_ROOT=/app \ + WEB_DOCUMENT_INDEX=index.php \ + WEB_ALIAS_DOMAIN=*.vm +ENV WEB_PHP_SOCKET=127.0.0.1:9000 COPY conf/ /opt/docker/ @@ -30,7 +25,7 @@ RUN /usr/local/bin/apt-install \ && a2enmod actions fastcgi ssl rewrite headers expires \ && mkdir -p /var/lock/apache2 \ && /opt/docker/bin/provision run --tag bootstrap --role webdevops-apache --role webdevops-hhvm-apache \ - && /opt/docker/bin/bootstrap.sh - + && /opt/docker/bin/bootstrap.sh \ + && docker-image-cleanup EXPOSE 80 443 diff --git a/docker/hhvm-apache/ubuntu-14.04/Dockerfile.jinja2 b/docker/hhvm-apache/ubuntu-14.04/Dockerfile.jinja2 index f3e377099..7cc62d3dc 100644 --- a/docker/hhvm-apache/ubuntu-14.04/Dockerfile.jinja2 +++ b/docker/hhvm-apache/ubuntu-14.04/Dockerfile.jinja2 @@ -1,7 +1,5 @@ {{ docker.from("hhvm", "ubuntu-14.04") }} -{{ docker.version() }} - {{ environment.web() }} {{ environment.webPhp() }} diff --git a/docker/hhvm-apache/ubuntu-14.04/conf/bin/service.d/httpd.d/10-init.sh b/docker/hhvm-apache/ubuntu-14.04/conf/bin/service.d/httpd.d/10-init.sh index d3f1a0c9c..b9d57997e 100644 --- a/docker/hhvm-apache/ubuntu-14.04/conf/bin/service.d/httpd.d/10-init.sh +++ b/docker/hhvm-apache/ubuntu-14.04/conf/bin/service.d/httpd.d/10-init.sh @@ -5,15 +5,17 @@ if [[ ! -e "$WEB_DOCUMENT_ROOT" ]]; then fi # Replace markers -find /opt/docker/etc/httpd/ -iname '*.conf' -print0 | xargs -0 -r rpl --quiet "" "$WEB_DOCUMENT_INDEX" > /dev/null -find /opt/docker/etc/httpd/ -iname '*.conf' -print0 | xargs -0 -r rpl --quiet "" "$WEB_DOCUMENT_ROOT" > /dev/null -find /opt/docker/etc/httpd/ -iname '*.conf' -print0 | xargs -0 -r rpl --quiet "" "$WEB_ALIAS_DOMAIN" > /dev/null -find /opt/docker/etc/httpd/ -iname '*.conf' -print0 | xargs -0 -r rpl --quiet "" "$HOSTNAME" > /dev/null +go-replace \ + -s "" -r "$WEB_DOCUMENT_INDEX" \ + -s "" -r "$WEB_DOCUMENT_ROOT" \ + -s "" -r "$WEB_ALIAS_DOMAIN" \ + -s "" -r "$HOSTNAME" \ + -s "" -r "$WEB_PHP_SOCKET" \ + --path=/opt/docker/etc/httpd/ \ + --path-pattern='*.conf' \ + --ignore-empty -if [[ -n "${WEB_PHP_SOCKET+x}" ]]; then - ## WEB_PHP_SOCKET is set - find /opt/docker/etc/httpd/ -iname '*.conf' -print0 | xargs -0 -r rpl --quiet "" "$WEB_PHP_SOCKET" > /dev/null -else +if [[ -z "${WEB_PHP_SOCKET+x}" ]]; then ## WEB_PHP_SOCKET is not set, remove PHP files rm -f -- /opt/docker/etc/httpd/conf.d/10-php.conf fi diff --git a/docker/hhvm-apache/ubuntu-14.04/conf/etc/httpd/conf.d/10-log.conf b/docker/hhvm-apache/ubuntu-14.04/conf/etc/httpd/conf.d/10-log.conf index e4c4be4f2..ef0c73d38 100644 --- a/docker/hhvm-apache/ubuntu-14.04/conf/etc/httpd/conf.d/10-log.conf +++ b/docker/hhvm-apache/ubuntu-14.04/conf/etc/httpd/conf.d/10-log.conf @@ -1,4 +1,4 @@ LogFormat "[httpd:access] %V:%p %h %l %u %t \"%r\" %>s bytesIn:%I bytesOut:%O reqTime:%T" dockerlog LogLevel warn -CustomLog /proc/self/fd/1 dockerlog -ErrorLog /proc/self/fd/2 +CustomLog /docker.stdout dockerlog +ErrorLog /docker.stderr diff --git a/docker/hhvm-apache/ubuntu-14.04/conf/provision/roles/webdevops-apache/tasks/bootstrap.yml b/docker/hhvm-apache/ubuntu-14.04/conf/provision/roles/webdevops-apache/tasks/bootstrap.yml index 2be18b0e0..c285be286 100644 --- a/docker/hhvm-apache/ubuntu-14.04/conf/provision/roles/webdevops-apache/tasks/bootstrap.yml +++ b/docker/hhvm-apache/ubuntu-14.04/conf/provision/roles/webdevops-apache/tasks/bootstrap.yml @@ -84,7 +84,7 @@ with_items: - 'a2dismod mpm_event' - 'a2enmod mpm_event' - when: (ansible_distribution == 'Ubuntu' and ansible_lsb.major_release|int >= 14) or (ansible_distribution == 'Debian' and ansible_lsb.major_release|int >= 8) + when: (ansible_distribution == 'Ubuntu' and docker_image_info_distribution_version|int >= 14) or (ansible_distribution == 'Debian' and docker_image_info_distribution_version|int >= 8) - name: Manage modules [Alpine family] lineinfile: diff --git a/docker/hhvm-apache/ubuntu-16.04/Dockerfile b/docker/hhvm-apache/ubuntu-16.04/Dockerfile index c00235337..e7698806d 100644 --- a/docker/hhvm-apache/ubuntu-16.04/Dockerfile +++ b/docker/hhvm-apache/ubuntu-16.04/Dockerfile @@ -5,15 +5,10 @@ FROM webdevops/hhvm:ubuntu-16.04 -MAINTAINER info@webdevops.io -LABEL vendor=WebDevOps.io -LABEL io.webdevops.layout=8 -LABEL io.webdevops.version=1.5.0 - -ENV WEB_DOCUMENT_ROOT /app -ENV WEB_DOCUMENT_INDEX index.php -ENV WEB_ALIAS_DOMAIN *.vm -ENV WEB_PHP_SOCKET 127.0.0.1:9000 +ENV WEB_DOCUMENT_ROOT=/app \ + WEB_DOCUMENT_INDEX=index.php \ + WEB_ALIAS_DOMAIN=*.vm +ENV WEB_PHP_SOCKET=127.0.0.1:9000 COPY conf/ /opt/docker/ @@ -28,7 +23,7 @@ RUN /usr/local/bin/apt-install \ && ln -sf /opt/docker/etc/httpd/main.conf /etc/apache2/sites-enabled/10-docker.conf \ && a2enmod actions proxy proxy_fcgi ssl rewrite headers expires \ && /opt/docker/bin/provision run --tag bootstrap --role webdevops-apache --role webdevops-hhvm-apache \ - && /opt/docker/bin/bootstrap.sh - + && /opt/docker/bin/bootstrap.sh \ + && docker-image-cleanup EXPOSE 80 443 diff --git a/docker/hhvm-apache/ubuntu-16.04/Dockerfile.jinja2 b/docker/hhvm-apache/ubuntu-16.04/Dockerfile.jinja2 index 11dc1b0db..48b4cf5ed 100644 --- a/docker/hhvm-apache/ubuntu-16.04/Dockerfile.jinja2 +++ b/docker/hhvm-apache/ubuntu-16.04/Dockerfile.jinja2 @@ -1,7 +1,5 @@ {{ docker.from("hhvm", "ubuntu-16.04") }} -{{ docker.version() }} - {{ environment.web() }} {{ environment.webPhp() }} diff --git a/docker/hhvm-apache/ubuntu-16.04/conf/bin/service.d/httpd.d/10-init.sh b/docker/hhvm-apache/ubuntu-16.04/conf/bin/service.d/httpd.d/10-init.sh index d3f1a0c9c..b9d57997e 100644 --- a/docker/hhvm-apache/ubuntu-16.04/conf/bin/service.d/httpd.d/10-init.sh +++ b/docker/hhvm-apache/ubuntu-16.04/conf/bin/service.d/httpd.d/10-init.sh @@ -5,15 +5,17 @@ if [[ ! -e "$WEB_DOCUMENT_ROOT" ]]; then fi # Replace markers -find /opt/docker/etc/httpd/ -iname '*.conf' -print0 | xargs -0 -r rpl --quiet "" "$WEB_DOCUMENT_INDEX" > /dev/null -find /opt/docker/etc/httpd/ -iname '*.conf' -print0 | xargs -0 -r rpl --quiet "" "$WEB_DOCUMENT_ROOT" > /dev/null -find /opt/docker/etc/httpd/ -iname '*.conf' -print0 | xargs -0 -r rpl --quiet "" "$WEB_ALIAS_DOMAIN" > /dev/null -find /opt/docker/etc/httpd/ -iname '*.conf' -print0 | xargs -0 -r rpl --quiet "" "$HOSTNAME" > /dev/null +go-replace \ + -s "" -r "$WEB_DOCUMENT_INDEX" \ + -s "" -r "$WEB_DOCUMENT_ROOT" \ + -s "" -r "$WEB_ALIAS_DOMAIN" \ + -s "" -r "$HOSTNAME" \ + -s "" -r "$WEB_PHP_SOCKET" \ + --path=/opt/docker/etc/httpd/ \ + --path-pattern='*.conf' \ + --ignore-empty -if [[ -n "${WEB_PHP_SOCKET+x}" ]]; then - ## WEB_PHP_SOCKET is set - find /opt/docker/etc/httpd/ -iname '*.conf' -print0 | xargs -0 -r rpl --quiet "" "$WEB_PHP_SOCKET" > /dev/null -else +if [[ -z "${WEB_PHP_SOCKET+x}" ]]; then ## WEB_PHP_SOCKET is not set, remove PHP files rm -f -- /opt/docker/etc/httpd/conf.d/10-php.conf fi diff --git a/docker/hhvm-apache/ubuntu-16.04/conf/etc/httpd/conf.d/10-log.conf b/docker/hhvm-apache/ubuntu-16.04/conf/etc/httpd/conf.d/10-log.conf index e4c4be4f2..ef0c73d38 100644 --- a/docker/hhvm-apache/ubuntu-16.04/conf/etc/httpd/conf.d/10-log.conf +++ b/docker/hhvm-apache/ubuntu-16.04/conf/etc/httpd/conf.d/10-log.conf @@ -1,4 +1,4 @@ LogFormat "[httpd:access] %V:%p %h %l %u %t \"%r\" %>s bytesIn:%I bytesOut:%O reqTime:%T" dockerlog LogLevel warn -CustomLog /proc/self/fd/1 dockerlog -ErrorLog /proc/self/fd/2 +CustomLog /docker.stdout dockerlog +ErrorLog /docker.stderr diff --git a/docker/hhvm-apache/ubuntu-16.04/conf/provision/roles/webdevops-apache/tasks/bootstrap.yml b/docker/hhvm-apache/ubuntu-16.04/conf/provision/roles/webdevops-apache/tasks/bootstrap.yml index 2be18b0e0..c285be286 100644 --- a/docker/hhvm-apache/ubuntu-16.04/conf/provision/roles/webdevops-apache/tasks/bootstrap.yml +++ b/docker/hhvm-apache/ubuntu-16.04/conf/provision/roles/webdevops-apache/tasks/bootstrap.yml @@ -84,7 +84,7 @@ with_items: - 'a2dismod mpm_event' - 'a2enmod mpm_event' - when: (ansible_distribution == 'Ubuntu' and ansible_lsb.major_release|int >= 14) or (ansible_distribution == 'Debian' and ansible_lsb.major_release|int >= 8) + when: (ansible_distribution == 'Ubuntu' and docker_image_info_distribution_version|int >= 14) or (ansible_distribution == 'Debian' and docker_image_info_distribution_version|int >= 8) - name: Manage modules [Alpine family] lineinfile: diff --git a/docker/hhvm-nginx/ubuntu-14.04/Dockerfile b/docker/hhvm-nginx/ubuntu-14.04/Dockerfile index e552cd6f2..776e7f54a 100644 --- a/docker/hhvm-nginx/ubuntu-14.04/Dockerfile +++ b/docker/hhvm-nginx/ubuntu-14.04/Dockerfile @@ -5,15 +5,10 @@ FROM webdevops/hhvm:ubuntu-14.04 -MAINTAINER info@webdevops.io -LABEL vendor=WebDevOps.io -LABEL io.webdevops.layout=8 -LABEL io.webdevops.version=1.5.0 - -ENV WEB_DOCUMENT_ROOT /app -ENV WEB_DOCUMENT_INDEX index.php -ENV WEB_ALIAS_DOMAIN *.vm -ENV WEB_PHP_SOCKET 127.0.0.1:9000 +ENV WEB_DOCUMENT_ROOT=/app \ + WEB_DOCUMENT_INDEX=index.php \ + WEB_ALIAS_DOMAIN=*.vm +ENV WEB_PHP_SOCKET=127.0.0.1:9000 COPY conf/ /opt/docker/ @@ -21,7 +16,7 @@ COPY conf/ /opt/docker/ RUN /usr/local/bin/apt-install \ nginx \ && /opt/docker/bin/provision run --tag bootstrap --role webdevops-nginx --role webdevops-hhvm-nginx \ - && /opt/docker/bin/bootstrap.sh - + && /opt/docker/bin/bootstrap.sh \ + && docker-image-cleanup EXPOSE 80 443 diff --git a/docker/hhvm-nginx/ubuntu-14.04/Dockerfile.jinja2 b/docker/hhvm-nginx/ubuntu-14.04/Dockerfile.jinja2 index a3525392d..606c83926 100644 --- a/docker/hhvm-nginx/ubuntu-14.04/Dockerfile.jinja2 +++ b/docker/hhvm-nginx/ubuntu-14.04/Dockerfile.jinja2 @@ -1,7 +1,5 @@ {{ docker.from("hhvm", "ubuntu-14.04") }} -{{ docker.version() }} - {{ environment.web() }} {{ environment.webPhp() }} diff --git a/docker/hhvm-nginx/ubuntu-14.04/conf/bin/service.d/nginx.d/10-init.sh b/docker/hhvm-nginx/ubuntu-14.04/conf/bin/service.d/nginx.d/10-init.sh index 75a84a4eb..27b9776cc 100644 --- a/docker/hhvm-nginx/ubuntu-14.04/conf/bin/service.d/nginx.d/10-init.sh +++ b/docker/hhvm-nginx/ubuntu-14.04/conf/bin/service.d/nginx.d/10-init.sh @@ -8,15 +8,17 @@ fi ln -f -s /var/lib/nginx/logs /var/log/nginx # Replace markers -find /opt/docker/etc/nginx/ -iname '*.conf' -print0 | xargs -0 -r rpl --quiet "" "$WEB_DOCUMENT_INDEX" > /dev/null -find /opt/docker/etc/nginx/ -iname '*.conf' -print0 | xargs -0 -r rpl --quiet "" "$WEB_DOCUMENT_ROOT" > /dev/null -find /opt/docker/etc/nginx/ -iname '*.conf' -print0 | xargs -0 -r rpl --quiet "" "$WEB_ALIAS_DOMAIN" > /dev/null -find /opt/docker/etc/nginx/ -iname '*.conf' -print0 | xargs -0 -r rpl --quiet "" "$HOSTNAME" > /dev/null +go-replace \ + -s "" -r "$WEB_DOCUMENT_INDEX" \ + -s "" -r "$WEB_DOCUMENT_ROOT" \ + -s "" -r "$WEB_ALIAS_DOMAIN" \ + -s "" -r "$HOSTNAME" \ + -s "" -r "$WEB_PHP_SOCKET" \ + --path=/opt/docker/etc/nginx/ \ + --path-pattern='*.conf' \ + --ignore-empty -if [[ -n "${WEB_PHP_SOCKET+x}" ]]; then - ## WEB_PHP_SOCKET is set - find /opt/docker/etc/nginx/ -iname '*.conf' -print0 | xargs -0 -r rpl --quiet "" "$WEB_PHP_SOCKET" > /dev/null -else +if [[ -z "${WEB_PHP_SOCKET+x}" ]]; then ## WEB_PHP_SOCKET is not set, remove PHP files rm -f -- /opt/docker/etc/nginx/conf.d/10-php.conf rm -f -- /opt/docker/etc/nginx/vhost.common.d/10-php.conf diff --git a/docker/hhvm-nginx/ubuntu-14.04/conf/etc/nginx/vhost.common.d/10-general.conf b/docker/hhvm-nginx/ubuntu-14.04/conf/etc/nginx/vhost.common.d/10-general.conf new file mode 100644 index 000000000..d3fd0aa5e --- /dev/null +++ b/docker/hhvm-nginx/ubuntu-14.04/conf/etc/nginx/vhost.common.d/10-general.conf @@ -0,0 +1 @@ +client_max_body_size 50m; diff --git a/docker/hhvm-nginx/ubuntu-14.04/conf/etc/nginx/vhost.common.d/10-log.conf b/docker/hhvm-nginx/ubuntu-14.04/conf/etc/nginx/vhost.common.d/10-log.conf new file mode 100644 index 000000000..9646c6826 --- /dev/null +++ b/docker/hhvm-nginx/ubuntu-14.04/conf/etc/nginx/vhost.common.d/10-log.conf @@ -0,0 +1,2 @@ +access_log /docker.stdout; +error_log /docker.stderr warn; diff --git a/docker/hhvm-nginx/ubuntu-14.04/conf/etc/nginx/vhost.conf b/docker/hhvm-nginx/ubuntu-14.04/conf/etc/nginx/vhost.conf index d07e27094..8225f314a 100644 --- a/docker/hhvm-nginx/ubuntu-14.04/conf/etc/nginx/vhost.conf +++ b/docker/hhvm-nginx/ubuntu-14.04/conf/etc/nginx/vhost.conf @@ -1,17 +1,11 @@ server { - listen 80 default_server; - listen 8000 default_server; + listen 80 default_server; server_name _ docker; - access_log /docker.stdout; - error_log /docker.stdout info; - root ""; index ; - client_max_body_size 50m; - include /opt/docker/etc/nginx/vhost.common.d/*.conf; } @@ -20,19 +14,13 @@ server { ############## server { - listen 443 default_server; - listen 8443 default_server; + listen 443 default_server; server_name _ docker; - access_log /docker.stdout; - error_log /docker.stdout info; - root ""; index ; - client_max_body_size 50m; - include /opt/docker/etc/nginx/vhost.common.d/*.conf; include /opt/docker/etc/nginx/vhost.ssl.conf; } diff --git a/docker/hhvm-nginx/ubuntu-16.04/Dockerfile b/docker/hhvm-nginx/ubuntu-16.04/Dockerfile index 7e6b49afe..d2a962541 100644 --- a/docker/hhvm-nginx/ubuntu-16.04/Dockerfile +++ b/docker/hhvm-nginx/ubuntu-16.04/Dockerfile @@ -5,15 +5,10 @@ FROM webdevops/hhvm:ubuntu-16.04 -MAINTAINER info@webdevops.io -LABEL vendor=WebDevOps.io -LABEL io.webdevops.layout=8 -LABEL io.webdevops.version=1.5.0 - -ENV WEB_DOCUMENT_ROOT /app -ENV WEB_DOCUMENT_INDEX index.php -ENV WEB_ALIAS_DOMAIN *.vm -ENV WEB_PHP_SOCKET 127.0.0.1:9000 +ENV WEB_DOCUMENT_ROOT=/app \ + WEB_DOCUMENT_INDEX=index.php \ + WEB_ALIAS_DOMAIN=*.vm +ENV WEB_PHP_SOCKET=127.0.0.1:9000 COPY conf/ /opt/docker/ @@ -21,7 +16,7 @@ COPY conf/ /opt/docker/ RUN /usr/local/bin/apt-install \ nginx \ && /opt/docker/bin/provision run --tag bootstrap --role webdevops-nginx --role webdevops-hhvm-nginx \ - && /opt/docker/bin/bootstrap.sh - + && /opt/docker/bin/bootstrap.sh \ + && docker-image-cleanup EXPOSE 80 443 diff --git a/docker/hhvm-nginx/ubuntu-16.04/Dockerfile.jinja2 b/docker/hhvm-nginx/ubuntu-16.04/Dockerfile.jinja2 index 0d3295069..01ea0f3e6 100644 --- a/docker/hhvm-nginx/ubuntu-16.04/Dockerfile.jinja2 +++ b/docker/hhvm-nginx/ubuntu-16.04/Dockerfile.jinja2 @@ -1,7 +1,5 @@ {{ docker.from("hhvm", "ubuntu-16.04") }} -{{ docker.version() }} - {{ environment.web() }} {{ environment.webPhp() }} diff --git a/docker/hhvm-nginx/ubuntu-16.04/conf/bin/service.d/nginx.d/10-init.sh b/docker/hhvm-nginx/ubuntu-16.04/conf/bin/service.d/nginx.d/10-init.sh index 75a84a4eb..27b9776cc 100644 --- a/docker/hhvm-nginx/ubuntu-16.04/conf/bin/service.d/nginx.d/10-init.sh +++ b/docker/hhvm-nginx/ubuntu-16.04/conf/bin/service.d/nginx.d/10-init.sh @@ -8,15 +8,17 @@ fi ln -f -s /var/lib/nginx/logs /var/log/nginx # Replace markers -find /opt/docker/etc/nginx/ -iname '*.conf' -print0 | xargs -0 -r rpl --quiet "" "$WEB_DOCUMENT_INDEX" > /dev/null -find /opt/docker/etc/nginx/ -iname '*.conf' -print0 | xargs -0 -r rpl --quiet "" "$WEB_DOCUMENT_ROOT" > /dev/null -find /opt/docker/etc/nginx/ -iname '*.conf' -print0 | xargs -0 -r rpl --quiet "" "$WEB_ALIAS_DOMAIN" > /dev/null -find /opt/docker/etc/nginx/ -iname '*.conf' -print0 | xargs -0 -r rpl --quiet "" "$HOSTNAME" > /dev/null +go-replace \ + -s "" -r "$WEB_DOCUMENT_INDEX" \ + -s "" -r "$WEB_DOCUMENT_ROOT" \ + -s "" -r "$WEB_ALIAS_DOMAIN" \ + -s "" -r "$HOSTNAME" \ + -s "" -r "$WEB_PHP_SOCKET" \ + --path=/opt/docker/etc/nginx/ \ + --path-pattern='*.conf' \ + --ignore-empty -if [[ -n "${WEB_PHP_SOCKET+x}" ]]; then - ## WEB_PHP_SOCKET is set - find /opt/docker/etc/nginx/ -iname '*.conf' -print0 | xargs -0 -r rpl --quiet "" "$WEB_PHP_SOCKET" > /dev/null -else +if [[ -z "${WEB_PHP_SOCKET+x}" ]]; then ## WEB_PHP_SOCKET is not set, remove PHP files rm -f -- /opt/docker/etc/nginx/conf.d/10-php.conf rm -f -- /opt/docker/etc/nginx/vhost.common.d/10-php.conf diff --git a/docker/hhvm-nginx/ubuntu-16.04/conf/etc/nginx/vhost.common.d/10-general.conf b/docker/hhvm-nginx/ubuntu-16.04/conf/etc/nginx/vhost.common.d/10-general.conf new file mode 100644 index 000000000..d3fd0aa5e --- /dev/null +++ b/docker/hhvm-nginx/ubuntu-16.04/conf/etc/nginx/vhost.common.d/10-general.conf @@ -0,0 +1 @@ +client_max_body_size 50m; diff --git a/docker/hhvm-nginx/ubuntu-16.04/conf/etc/nginx/vhost.common.d/10-log.conf b/docker/hhvm-nginx/ubuntu-16.04/conf/etc/nginx/vhost.common.d/10-log.conf new file mode 100644 index 000000000..9646c6826 --- /dev/null +++ b/docker/hhvm-nginx/ubuntu-16.04/conf/etc/nginx/vhost.common.d/10-log.conf @@ -0,0 +1,2 @@ +access_log /docker.stdout; +error_log /docker.stderr warn; diff --git a/docker/hhvm-nginx/ubuntu-16.04/conf/etc/nginx/vhost.conf b/docker/hhvm-nginx/ubuntu-16.04/conf/etc/nginx/vhost.conf index d07e27094..8225f314a 100644 --- a/docker/hhvm-nginx/ubuntu-16.04/conf/etc/nginx/vhost.conf +++ b/docker/hhvm-nginx/ubuntu-16.04/conf/etc/nginx/vhost.conf @@ -1,17 +1,11 @@ server { - listen 80 default_server; - listen 8000 default_server; + listen 80 default_server; server_name _ docker; - access_log /docker.stdout; - error_log /docker.stdout info; - root ""; index ; - client_max_body_size 50m; - include /opt/docker/etc/nginx/vhost.common.d/*.conf; } @@ -20,19 +14,13 @@ server { ############## server { - listen 443 default_server; - listen 8443 default_server; + listen 443 default_server; server_name _ docker; - access_log /docker.stdout; - error_log /docker.stdout info; - root ""; index ; - client_max_body_size 50m; - include /opt/docker/etc/nginx/vhost.common.d/*.conf; include /opt/docker/etc/nginx/vhost.ssl.conf; } diff --git a/docker/hhvm/ubuntu-14.04/Dockerfile b/docker/hhvm/ubuntu-14.04/Dockerfile index 05d77cc54..49f68ffcb 100644 --- a/docker/hhvm/ubuntu-14.04/Dockerfile +++ b/docker/hhvm/ubuntu-14.04/Dockerfile @@ -5,21 +5,16 @@ FROM webdevops/base-app:ubuntu-14.04 -MAINTAINER info@webdevops.io -LABEL vendor=WebDevOps.io -LABEL io.webdevops.layout=8 -LABEL io.webdevops.version=1.5.0 - -ENV WEB_DOCUMENT_ROOT /app -ENV WEB_DOCUMENT_INDEX index.php -ENV WEB_ALIAS_DOMAIN *.vm +ENV WEB_DOCUMENT_ROOT=/app \ + WEB_DOCUMENT_INDEX=index.php \ + WEB_ALIAS_DOMAIN=*.vm COPY conf/ /opt/docker/ # Install hhvm environment RUN export DEBIAN_FRONTEND=noninteractive && set -x \ && apt-key adv --recv-keys --keyserver hkp://keyserver.ubuntu.com:80 0x5a16e7281be7a449 \ - && add-apt-repository "deb http://dl.hhvm.com/ubuntu $(lsb_release -sc) main" \ + && echo "deb http://dl.hhvm.com/ubuntu $(docker-image-info dist-codename) main" >> /etc/apt/sources.list \ && /usr/local/bin/apt-install \ hhvm \ imagemagick \ @@ -28,8 +23,8 @@ RUN export DEBIAN_FRONTEND=noninteractive && set -x \ && /usr/bin/update-alternatives --install /usr/bin/php php /usr/bin/hhvm 60 \ && curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin/ --filename=composer \ && /opt/docker/bin/provision run --tag bootstrap --role webdevops-hhvm \ - && /opt/docker/bin/bootstrap.sh - + && /opt/docker/bin/bootstrap.sh \ + && docker-image-cleanup EXPOSE 9000 diff --git a/docker/hhvm/ubuntu-14.04/Dockerfile.jinja2 b/docker/hhvm/ubuntu-14.04/Dockerfile.jinja2 index 2467b22d6..d77b946f6 100644 --- a/docker/hhvm/ubuntu-14.04/Dockerfile.jinja2 +++ b/docker/hhvm/ubuntu-14.04/Dockerfile.jinja2 @@ -1,7 +1,5 @@ {{ docker.from("base-app", "ubuntu-14.04") }} -{{ docker.version() }} - {{ environment.web() }} {{ docker.copy('conf/', '/opt/docker/') }} diff --git a/docker/hhvm/ubuntu-16.04/Dockerfile b/docker/hhvm/ubuntu-16.04/Dockerfile index 924bd367f..d755bba4f 100644 --- a/docker/hhvm/ubuntu-16.04/Dockerfile +++ b/docker/hhvm/ubuntu-16.04/Dockerfile @@ -5,14 +5,9 @@ FROM webdevops/base-app:ubuntu-16.04 -MAINTAINER info@webdevops.io -LABEL vendor=WebDevOps.io -LABEL io.webdevops.layout=8 -LABEL io.webdevops.version=1.5.0 - -ENV WEB_DOCUMENT_ROOT /app -ENV WEB_DOCUMENT_INDEX index.php -ENV WEB_ALIAS_DOMAIN *.vm +ENV WEB_DOCUMENT_ROOT=/app \ + WEB_DOCUMENT_INDEX=index.php \ + WEB_ALIAS_DOMAIN=*.vm COPY conf/ /opt/docker/ @@ -25,8 +20,8 @@ RUN /usr/local/bin/apt-install \ && /usr/bin/update-alternatives --install /usr/bin/php php /usr/bin/hhvm 60 \ && curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin/ --filename=composer \ && /opt/docker/bin/provision run --tag bootstrap --role webdevops-hhvm \ - && /opt/docker/bin/bootstrap.sh - + && /opt/docker/bin/bootstrap.sh \ + && docker-image-cleanup EXPOSE 9000 diff --git a/docker/hhvm/ubuntu-16.04/Dockerfile.jinja2 b/docker/hhvm/ubuntu-16.04/Dockerfile.jinja2 index f2c47cf88..20db1da68 100644 --- a/docker/hhvm/ubuntu-16.04/Dockerfile.jinja2 +++ b/docker/hhvm/ubuntu-16.04/Dockerfile.jinja2 @@ -1,7 +1,5 @@ {{ docker.from("base-app", "ubuntu-16.04") }} -{{ docker.version() }} - {{ environment.web() }} {{ docker.copy('conf/', '/opt/docker/') }} diff --git a/docker/liquibase/latest/Dockerfile b/docker/liquibase/latest/Dockerfile index 11b1b0b1d..5f27f1828 100644 --- a/docker/liquibase/latest/Dockerfile +++ b/docker/liquibase/latest/Dockerfile @@ -5,20 +5,20 @@ FROM java:latest -MAINTAINER info@webdevops.io -LABEL vendor=WebDevOps.io -LABEL io.webdevops.layout=8 -LABEL io.webdevops.version=1.5.0 - -ENV LIQUIBASE_VERSION "3.5.3" -ENV LIQUIBASE_DRIVER "com.mysql.jdbc.Driver" -ENV LIQUIBASE_CLASSPATH "/usr/share/java/mysql.jar" -ENV LIQUIBASE_URL "" -ENV LIQUIBASE_USERNAME "" -ENV LIQUIBASE_PASSWORD "" -ENV LIQUIBASE_CHANGELOG "liquibase.xml" -ENV LIQUIBASE_CONTEXTS "" -ENV LIQUIBASE_OPTS "" +LABEL maintainer=info@webdevops.io \ + vendor=WebDevOps.io \ + io.webdevops.layout=8 \ + io.webdevops.version=1.5.0 + +ENV LIQUIBASE_VERSION="3.5.3" \ + LIQUIBASE_DRIVER="com.mysql.jdbc.Driver" \ + LIQUIBASE_CLASSPATH="/usr/share/java/mysql.jar" \ + LIQUIBASE_URL="" \ + LIQUIBASE_USERNAME="" \ + LIQUIBASE_PASSWORD="" \ + LIQUIBASE_CHANGELOG="liquibase.xml" \ + LIQUIBASE_CONTEXTS="" \ + LIQUIBASE_OPTS="" COPY conf/ /opt/docker/ diff --git a/docker/liquibase/mysql/Dockerfile b/docker/liquibase/mysql/Dockerfile index 6943d3b2c..540ffd5c7 100644 --- a/docker/liquibase/mysql/Dockerfile +++ b/docker/liquibase/mysql/Dockerfile @@ -5,20 +5,20 @@ FROM java:latest -MAINTAINER info@webdevops.io -LABEL vendor=WebDevOps.io -LABEL io.webdevops.layout=8 -LABEL io.webdevops.version=1.5.0 - -ENV LIQUIBASE_VERSION "3.5.3" -ENV LIQUIBASE_DRIVER "com.mysql.jdbc.Driver" -ENV LIQUIBASE_CLASSPATH "/usr/share/java/mysql.jar" -ENV LIQUIBASE_URL "" -ENV LIQUIBASE_USERNAME "" -ENV LIQUIBASE_PASSWORD "" -ENV LIQUIBASE_CHANGELOG "liquibase.xml" -ENV LIQUIBASE_CONTEXTS "" -ENV LIQUIBASE_OPTS "" +LABEL maintainer=info@webdevops.io \ + vendor=WebDevOps.io \ + io.webdevops.layout=8 \ + io.webdevops.version=1.5.0 + +ENV LIQUIBASE_VERSION="3.5.3" \ + LIQUIBASE_DRIVER="com.mysql.jdbc.Driver" \ + LIQUIBASE_CLASSPATH="/usr/share/java/mysql.jar" \ + LIQUIBASE_URL="" \ + LIQUIBASE_USERNAME="" \ + LIQUIBASE_PASSWORD="" \ + LIQUIBASE_CHANGELOG="liquibase.xml" \ + LIQUIBASE_CONTEXTS="" \ + LIQUIBASE_OPTS="" COPY conf/ /opt/docker/ diff --git a/docker/liquibase/postgres/Dockerfile b/docker/liquibase/postgres/Dockerfile index aab855098..9c4ad6971 100644 --- a/docker/liquibase/postgres/Dockerfile +++ b/docker/liquibase/postgres/Dockerfile @@ -5,20 +5,20 @@ FROM java:latest -MAINTAINER info@webdevops.io -LABEL vendor=WebDevOps.io -LABEL io.webdevops.layout=8 -LABEL io.webdevops.version=1.5.0 - -ENV LIQUIBASE_VERSION "3.5.3" -ENV LIQUIBASE_DRIVER "org.postgresql.Driver" -ENV LIQUIBASE_CLASSPATH "/usr/share/java/postgresql.jar" -ENV LIQUIBASE_URL "" -ENV LIQUIBASE_USERNAME "" -ENV LIQUIBASE_PASSWORD "" -ENV LIQUIBASE_CHANGELOG "liquibase.xml" -ENV LIQUIBASE_CONTEXTS "" -ENV LIQUIBASE_OPTS "" +LABEL maintainer=info@webdevops.io \ + vendor=WebDevOps.io \ + io.webdevops.layout=8 \ + io.webdevops.version=1.5.0 + +ENV LIQUIBASE_VERSION="3.5.3" \ + LIQUIBASE_DRIVER="org.postgresql.Driver" \ + LIQUIBASE_CLASSPATH="/usr/share/java/postgresql.jar" \ + LIQUIBASE_URL="" \ + LIQUIBASE_USERNAME="" \ + LIQUIBASE_PASSWORD="" \ + LIQUIBASE_CHANGELOG="liquibase.xml" \ + LIQUIBASE_CONTEXTS="" \ + LIQUIBASE_OPTS="" COPY conf/ /opt/docker/ diff --git a/docker/liquidsoap/latest/Dockerfile b/docker/liquidsoap/latest/Dockerfile new file mode 100644 index 000000000..5293bf019 --- /dev/null +++ b/docker/liquidsoap/latest/Dockerfile @@ -0,0 +1,44 @@ +#+++++++++++++++++++++++++++++++++++++++ +# Dockerfile for webdevops/liquidsoap:latest +# -- automatically generated -- +#+++++++++++++++++++++++++++++++++++++++ + +FROM webdevops/base:latest + +# Install services +RUN /usr/local/bin/apt-install \ + liquidsoap \ + liquidsoap-plugin-all \ + mplayer \ + gstreamer0.10-plugins-base \ + gstreamer0.10-plugins-good \ + && docker-image-cleanup + +ENV LIQUIDSOAP_USER "liquidsoap" +ENV LIQUIDSOAP_TELNET "1" + +ENV LIQUIDSOAP_SCRIPT "/opt/docker/etc/liquidsoap/default.liq" +ENV LIQUIDSOAP_TEMPLATE "/opt/docker/etc/liquidsoap/default.liq" + +ENV LIQUIDSOAP_STREAM_INPUT "http://icecast:8000/live" + +ENV LIQUIDSOAP_PLAYLIST_DEFAULT "audio_to_stereo(single('/opt/docker/etc/liquidsoap/default.mp3'))" + +ENV LIQUIDSOAP_PLAYLIST_DAY "playlist('/opt/docker/etc/liquidsoap/playlist-day.pls')" +ENV LIQUIDSOAP_PLAYLIST_DAY_TIMERANGE "4h-2h" + +ENV LIQUIDSOAP_PLAYLIST_NIGHT "playlist('/opt/docker/etc/liquidsoap/playlist-night.pls')" +ENV LIQUIDSOAP_PLAYLIST_NIGHT_TIMERANGE "2h-14h" + +ENV LIQUIDSOAP_OUTPUT "output.icecast(%mp3(bitrate=128),host='localhost',port=8000,password='secretpassword',mount='liquidsoap-128',name=META_name,genre=META_genre,url=META_url,description=META_desc,ALL_input)" + +ENV LIQUIDSOAP_META_NAME "Liquidsoap Docker" +ENV LIQUIDSOAP_META_GENRE "" +ENV LIQUIDSOAP_META_URL "" +ENV LIQUIDSOAP_META_DESCRIPTION "" + +COPY conf/ /opt/docker/ + +CMD ["liquidsoap"] + +EXPOSE 1234 diff --git a/docker/liquidsoap/latest/Dockerfile.jinja2 b/docker/liquidsoap/latest/Dockerfile.jinja2 new file mode 100644 index 000000000..536adb84c --- /dev/null +++ b/docker/liquidsoap/latest/Dockerfile.jinja2 @@ -0,0 +1,39 @@ +{{ docker.from("base","latest") }} + +# Install services +RUN /usr/local/bin/apt-install \ + liquidsoap \ + liquidsoap-plugin-all \ + mplayer \ + gstreamer0.10-plugins-base \ + gstreamer0.10-plugins-good \ + {{ docker.cleanup() }} + +ENV LIQUIDSOAP_USER "liquidsoap" +ENV LIQUIDSOAP_TELNET "1" + +ENV LIQUIDSOAP_SCRIPT "/opt/docker/etc/liquidsoap/default.liq" +ENV LIQUIDSOAP_TEMPLATE "/opt/docker/etc/liquidsoap/default.liq" + +ENV LIQUIDSOAP_STREAM_INPUT "http://icecast:8000/live" + +ENV LIQUIDSOAP_PLAYLIST_DEFAULT "audio_to_stereo(single('/opt/docker/etc/liquidsoap/default.mp3'))" + +ENV LIQUIDSOAP_PLAYLIST_DAY "playlist('/opt/docker/etc/liquidsoap/playlist-day.pls')" +ENV LIQUIDSOAP_PLAYLIST_DAY_TIMERANGE "4h-2h" + +ENV LIQUIDSOAP_PLAYLIST_NIGHT "playlist('/opt/docker/etc/liquidsoap/playlist-night.pls')" +ENV LIQUIDSOAP_PLAYLIST_NIGHT_TIMERANGE "2h-14h" + +ENV LIQUIDSOAP_OUTPUT "output.icecast(%mp3(bitrate=128),host='localhost',port=8000,password='secretpassword',mount='liquidsoap-128',name=META_name,genre=META_genre,url=META_url,description=META_desc,ALL_input)" + +ENV LIQUIDSOAP_META_NAME "Liquidsoap Docker" +ENV LIQUIDSOAP_META_GENRE "" +ENV LIQUIDSOAP_META_URL "" +ENV LIQUIDSOAP_META_DESCRIPTION "" + +{{ docker.copy('conf/', '/opt/docker/') }} + +{{ docker.cmd("liquidsoap") }} + +{{ docker.expose('1234') }} diff --git a/docker/liquidsoap/latest/conf/bin/entrypoint.d/liquidsoap.sh b/docker/liquidsoap/latest/conf/bin/entrypoint.d/liquidsoap.sh new file mode 100644 index 000000000..1fd1ea972 --- /dev/null +++ b/docker/liquidsoap/latest/conf/bin/entrypoint.d/liquidsoap.sh @@ -0,0 +1,11 @@ +#!/usr/bin/env bash + +############################################# +## Configure and run liquidsoap +############################################# + +if [[ -n "$LIQUIDSOAP_TEMPLATE" ]]; then + go-replace --mode=template -- "$LIQUIDSOAP_TEMPLATE" +fi + +exec gosu "$LIQUIDSOAP_USER" liquidsoap "$LIQUIDSOAP_SCRIPT" diff --git a/docker/liquidsoap/latest/conf/etc/liquidsoap/default.liq b/docker/liquidsoap/latest/conf/etc/liquidsoap/default.liq new file mode 100644 index 000000000..c848c1e4d --- /dev/null +++ b/docker/liquidsoap/latest/conf/etc/liquidsoap/default.liq @@ -0,0 +1,88 @@ +#!/usr/bin/liquidsoap + +# Lines starting with # are comments, they are ignored. + +# Log path +set("log.file.path","/dev/null") + +# Print log messages to the console, +# can also be done by passing the -v option to liquidsoap. +set("log.stdout", true) + +# Use the telnet server for requests +{{if .Env.LIQUIDSOAP_TELNET}} +set("server.telnet", true) +{{else}} +set("server.telnet", false) +{{end}} + +################## +# Settings +################## + +DJ_stream = "{{.Env.LIQUIDSOAP_STREAM_INPUT}}" + +PLAYLIST_default = {{.Env.LIQUIDSOAP_PLAYLIST_DEFAULT}} +PLAYLIST_day = {{.Env.LIQUIDSOAP_PLAYLIST_DAY}} +PLAYLIST_night = {{.Env.LIQUIDSOAP_PLAYLIST_NIGHT}} + +META_name = "{{.Env.LIQUIDSOAP_META_NAME}}" +META_genre = "{{.Env.LIQUIDSOAP_META_GENRE}}" +META_url = "{{.Env.LIQUIDSOAP_META_URL}}" +META_desc = "{{.Env.LIQUIDSOAP_META_DESCRIPTION}}" + +## fetch dj stream +DJ_input = input.http(DJ_stream) + +## fadeout dj +#DJ_input = fade.out(merge_tracks(DJ_input)) + +# Play user requests if there are any, +# otherwise one of our playlists, +# and the default file if anything goes wrong. +PLAYLIST_input = fallback([ + switch([({ {{.Env.LIQUIDSOAP_PLAYLIST_DAY_TIMERANGE}} }, PLAYLIST_day), + ({ {{.Env.LIQUIDSOAP_PLAYLIST_NIGHT_TIMERANGE}} }, PLAYLIST_night)]), + PLAYLIST_default +]) + +## add fade +PLAYLIST_input = smart_crossfade(fade_out=0.5, fade_in=0.5, PLAYLIST_input) + +## set title +PLAYLIST_input = rewrite_metadata( + [ + ("title", "$(title)"), + ("comment", "{{.Env.LIQUIDSOAP_META_URL}}") + ], + PLAYLIST_input +) + +# Add the ability to relay live shows +ALL_input = fallback(track_sensitive=false, [DJ_input, PLAYLIST_input]) + +################# +# Output +################# + +{{.Env.LIQUIDSOAP_OUTPUT}} +{{.Env.LIQUIDSOAP_OUTPUT_1}} +{{.Env.LIQUIDSOAP_OUTPUT_2}} +{{.Env.LIQUIDSOAP_OUTPUT_3}} +{{.Env.LIQUIDSOAP_OUTPUT_4}} +{{.Env.LIQUIDSOAP_OUTPUT_5}} +{{.Env.LIQUIDSOAP_OUTPUT_6}} +{{.Env.LIQUIDSOAP_OUTPUT_7}} +{{.Env.LIQUIDSOAP_OUTPUT_8}} +{{.Env.LIQUIDSOAP_OUTPUT_9}} +{{.Env.LIQUIDSOAP_OUTPUT_10}} +{{.Env.LIQUIDSOAP_OUTPUT_11}} +{{.Env.LIQUIDSOAP_OUTPUT_12}} +{{.Env.LIQUIDSOAP_OUTPUT_13}} +{{.Env.LIQUIDSOAP_OUTPUT_14}} +{{.Env.LIQUIDSOAP_OUTPUT_15}} +{{.Env.LIQUIDSOAP_OUTPUT_16}} +{{.Env.LIQUIDSOAP_OUTPUT_17}} +{{.Env.LIQUIDSOAP_OUTPUT_18}} +{{.Env.LIQUIDSOAP_OUTPUT_19}} +{{.Env.LIQUIDSOAP_OUTPUT_20}} diff --git a/docker/liquidsoap/latest/conf/etc/liquidsoap/default.mp3 b/docker/liquidsoap/latest/conf/etc/liquidsoap/default.mp3 new file mode 100644 index 000000000..c8a0bf931 Binary files /dev/null and b/docker/liquidsoap/latest/conf/etc/liquidsoap/default.mp3 differ diff --git a/docker/liquidsoap/latest/conf/etc/liquidsoap/playlist-day.pls b/docker/liquidsoap/latest/conf/etc/liquidsoap/playlist-day.pls new file mode 100644 index 000000000..fcd718794 --- /dev/null +++ b/docker/liquidsoap/latest/conf/etc/liquidsoap/playlist-day.pls @@ -0,0 +1 @@ +#EXTM3U diff --git a/docker/liquidsoap/latest/conf/etc/liquidsoap/playlist-night.pls b/docker/liquidsoap/latest/conf/etc/liquidsoap/playlist-night.pls new file mode 100644 index 000000000..fcd718794 --- /dev/null +++ b/docker/liquidsoap/latest/conf/etc/liquidsoap/playlist-night.pls @@ -0,0 +1 @@ +#EXTM3U diff --git a/docker/mail-sandbox/latest/Dockerfile b/docker/mail-sandbox/latest/Dockerfile index cff102307..51c61f04b 100644 --- a/docker/mail-sandbox/latest/Dockerfile +++ b/docker/mail-sandbox/latest/Dockerfile @@ -5,13 +5,8 @@ FROM webdevops/php-nginx:latest -MAINTAINER info@webdevops.io -LABEL vendor=WebDevOps.io -LABEL io.webdevops.layout=8 -LABEL io.webdevops.version=1.5.0 - -ENV MAILBOX_USERNAME "dev" -ENV MAILBOX_PASSWORD "dev" +ENV MAILBOX_USERNAME="dev" \ + MAILBOX_PASSWORD="dev" COPY conf/ /opt/docker/ @@ -23,8 +18,8 @@ RUN /usr/local/bin/apt-install \ && /opt/docker/bin/control.sh service.enable dovecot \ && /opt/docker/bin/provision add --tag entrypoint webdevops-mail-sandbox \ && /opt/docker/bin/provision run --tag bootstrap --role webdevops-mail-sandbox \ - && /opt/docker/bin/bootstrap.sh - + && /opt/docker/bin/bootstrap.sh \ + && docker-image-cleanup # Install Roundcube + plugins RUN cd /app \ @@ -35,6 +30,7 @@ RUN cd /app \ && ls -l \ && rm -rf .git installer \ && ln -s /opt/docker/etc/roundcube/plugins/webdevops_autologin/ plugins/webdevops_autologin \ - && ln -s /opt/docker/etc/roundcube/config.php config/config.inc.php + && ln -s /opt/docker/etc/roundcube/config.php config/config.inc.php \ + && docker-image-cleanup EXPOSE 25 465 587 143 993 diff --git a/docker/mail-sandbox/latest/Dockerfile.jinja2 b/docker/mail-sandbox/latest/Dockerfile.jinja2 index 16809eb41..2ebceccb2 100644 --- a/docker/mail-sandbox/latest/Dockerfile.jinja2 +++ b/docker/mail-sandbox/latest/Dockerfile.jinja2 @@ -1,7 +1,5 @@ {{ docker.from("php-nginx") }} -{{ docker.version() }} - {{ environment.mailbox() }} {{ docker.copy('conf/', '/opt/docker/') }} diff --git a/docker/nginx-dev/alpine-3 b/docker/nginx-dev/alpine-3 new file mode 120000 index 000000000..0120374ca --- /dev/null +++ b/docker/nginx-dev/alpine-3 @@ -0,0 +1 @@ +alpine \ No newline at end of file diff --git a/docker/nginx-dev/alpine-3/Dockerfile b/docker/nginx-dev/alpine-3/Dockerfile deleted file mode 100644 index f82567674..000000000 --- a/docker/nginx-dev/alpine-3/Dockerfile +++ /dev/null @@ -1,25 +0,0 @@ -#+++++++++++++++++++++++++++++++++++++++ -# Dockerfile for webdevops/nginx-dev:alpine-3 -# -- automatically generated -- -#+++++++++++++++++++++++++++++++++++++++ - -FROM webdevops/nginx:alpine-3 - -MAINTAINER info@webdevops.io -LABEL vendor=WebDevOps.io -LABEL io.webdevops.layout=8 -LABEL io.webdevops.version=1.5.0 - -ENV WEB_DOCUMENT_ROOT /app -ENV WEB_DOCUMENT_INDEX index.php -ENV WEB_ALIAS_DOMAIN *.vm - -COPY conf/ /opt/docker/ - -# Install apache -RUN echo \ - && /opt/docker/bin/provision run --tag bootstrap --role webdevops-nginx-dev \ - && /opt/docker/bin/bootstrap.sh - - -EXPOSE 80 443 diff --git a/docker/nginx-dev/alpine-3/Dockerfile.jinja2 b/docker/nginx-dev/alpine-3/Dockerfile.jinja2 deleted file mode 100644 index 344d02a74..000000000 --- a/docker/nginx-dev/alpine-3/Dockerfile.jinja2 +++ /dev/null @@ -1,11 +0,0 @@ -{{ docker.from("nginx", "alpine-3") }} - -{{ docker.version() }} - -{{ environment.web() }} - -{{ docker.copy('conf/', '/opt/docker/') }} - -{{ nginxdev.general() }} - -{{ docker.expose('80 443') }} diff --git a/docker/nginx-dev/alpine-3/conf/bin/service.d/nginx.d/12-development.sh b/docker/nginx-dev/alpine-3/conf/bin/service.d/nginx.d/12-development.sh deleted file mode 100644 index fa4b601a9..000000000 --- a/docker/nginx-dev/alpine-3/conf/bin/service.d/nginx.d/12-development.sh +++ /dev/null @@ -1 +0,0 @@ -find /opt/docker/etc/nginx/ -iname '*.conf' -print0 | xargs -0 -r rpl --quiet "" "$WEB_NO_CACHE_PATTERN" > /dev/null diff --git a/docker/nginx-dev/alpine/Dockerfile b/docker/nginx-dev/alpine/Dockerfile new file mode 100644 index 000000000..41ff22fb1 --- /dev/null +++ b/docker/nginx-dev/alpine/Dockerfile @@ -0,0 +1,20 @@ +#+++++++++++++++++++++++++++++++++++++++ +# Dockerfile for webdevops/nginx-dev:alpine +# -- automatically generated -- +#+++++++++++++++++++++++++++++++++++++++ + +FROM webdevops/nginx:alpine + +ENV WEB_DOCUMENT_ROOT=/app \ + WEB_DOCUMENT_INDEX=index.php \ + WEB_ALIAS_DOMAIN=*.vm + +COPY conf/ /opt/docker/ + +# Install apache +RUN echo \ + && /opt/docker/bin/provision run --tag bootstrap --role webdevops-nginx-dev \ + && /opt/docker/bin/bootstrap.sh \ + && docker-image-cleanup + +EXPOSE 80 443 diff --git a/docker/nginx-dev/alpine/Dockerfile.jinja2 b/docker/nginx-dev/alpine/Dockerfile.jinja2 new file mode 100644 index 000000000..587679251 --- /dev/null +++ b/docker/nginx-dev/alpine/Dockerfile.jinja2 @@ -0,0 +1,9 @@ +{{ docker.from("nginx", "alpine") }} + +{{ environment.web() }} + +{{ docker.copy('conf/', '/opt/docker/') }} + +{{ nginxdev.general() }} + +{{ docker.expose('80 443') }} diff --git a/docker/nginx-dev/alpine/conf/bin/service.d/nginx.d/12-development.sh b/docker/nginx-dev/alpine/conf/bin/service.d/nginx.d/12-development.sh new file mode 100644 index 000000000..f4695f059 --- /dev/null +++ b/docker/nginx-dev/alpine/conf/bin/service.d/nginx.d/12-development.sh @@ -0,0 +1,7 @@ +go-replace \ + -s "" \ + -r "$WEB_NO_CACHE_PATTERN" \ + --path=/opt/docker/etc/nginx/ \ + --path-pattern='*.conf' \ + --ignore-empty + diff --git a/docker/nginx-dev/alpine-3/conf/etc/nginx/conf.d/02-dev.conf b/docker/nginx-dev/alpine/conf/etc/nginx/conf.d/02-dev.conf similarity index 100% rename from docker/nginx-dev/alpine-3/conf/etc/nginx/conf.d/02-dev.conf rename to docker/nginx-dev/alpine/conf/etc/nginx/conf.d/02-dev.conf diff --git a/docker/nginx-dev/alpine/conf/etc/nginx/vhost.common.d/.gitkeep b/docker/nginx-dev/alpine/conf/etc/nginx/vhost.common.d/.gitkeep new file mode 100644 index 000000000..e69de29bb diff --git a/docker/nginx-dev/alpine-3/conf/etc/nginx/vhost.common.d/02-dev.conf b/docker/nginx-dev/alpine/conf/etc/nginx/vhost.common.d/02-dev.conf similarity index 100% rename from docker/nginx-dev/alpine-3/conf/etc/nginx/vhost.common.d/02-dev.conf rename to docker/nginx-dev/alpine/conf/etc/nginx/vhost.common.d/02-dev.conf diff --git a/docker/nginx-dev/alpine/conf/etc/nginx/vhost.common.d/10-log.conf b/docker/nginx-dev/alpine/conf/etc/nginx/vhost.common.d/10-log.conf new file mode 100644 index 000000000..a2cd929e7 --- /dev/null +++ b/docker/nginx-dev/alpine/conf/etc/nginx/vhost.common.d/10-log.conf @@ -0,0 +1,2 @@ +access_log /docker.stdout; +error_log /docker.stderr info; diff --git a/docker/nginx-dev/alpine-3/conf/provision/roles/webdevops-nginx-dev/defaults/main.yml b/docker/nginx-dev/alpine/conf/provision/roles/webdevops-nginx-dev/defaults/main.yml similarity index 100% rename from docker/nginx-dev/alpine-3/conf/provision/roles/webdevops-nginx-dev/defaults/main.yml rename to docker/nginx-dev/alpine/conf/provision/roles/webdevops-nginx-dev/defaults/main.yml diff --git a/docker/nginx-dev/alpine-3/conf/provision/roles/webdevops-nginx-dev/tasks/bootstrap.yml b/docker/nginx-dev/alpine/conf/provision/roles/webdevops-nginx-dev/tasks/bootstrap.yml similarity index 100% rename from docker/nginx-dev/alpine-3/conf/provision/roles/webdevops-nginx-dev/tasks/bootstrap.yml rename to docker/nginx-dev/alpine/conf/provision/roles/webdevops-nginx-dev/tasks/bootstrap.yml diff --git a/docker/nginx-dev/alpine-3/conf/provision/roles/webdevops-nginx-dev/tasks/bootstrap/nginx.yml b/docker/nginx-dev/alpine/conf/provision/roles/webdevops-nginx-dev/tasks/bootstrap/nginx.yml similarity index 100% rename from docker/nginx-dev/alpine-3/conf/provision/roles/webdevops-nginx-dev/tasks/bootstrap/nginx.yml rename to docker/nginx-dev/alpine/conf/provision/roles/webdevops-nginx-dev/tasks/bootstrap/nginx.yml diff --git a/docker/nginx-dev/alpine-3/conf/provision/roles/webdevops-nginx-dev/tasks/main.yml b/docker/nginx-dev/alpine/conf/provision/roles/webdevops-nginx-dev/tasks/main.yml similarity index 100% rename from docker/nginx-dev/alpine-3/conf/provision/roles/webdevops-nginx-dev/tasks/main.yml rename to docker/nginx-dev/alpine/conf/provision/roles/webdevops-nginx-dev/tasks/main.yml diff --git a/docker/nginx-dev/centos-7/Dockerfile b/docker/nginx-dev/centos-7/Dockerfile index eb22a35e8..39e9578cc 100644 --- a/docker/nginx-dev/centos-7/Dockerfile +++ b/docker/nginx-dev/centos-7/Dockerfile @@ -5,21 +5,16 @@ FROM webdevops/nginx:centos-7 -MAINTAINER info@webdevops.io -LABEL vendor=WebDevOps.io -LABEL io.webdevops.layout=8 -LABEL io.webdevops.version=1.5.0 - -ENV WEB_DOCUMENT_ROOT /app -ENV WEB_DOCUMENT_INDEX index.php -ENV WEB_ALIAS_DOMAIN *.vm +ENV WEB_DOCUMENT_ROOT=/app \ + WEB_DOCUMENT_INDEX=index.php \ + WEB_ALIAS_DOMAIN=*.vm COPY conf/ /opt/docker/ # Install apache RUN echo \ && /opt/docker/bin/provision run --tag bootstrap --role webdevops-nginx-dev \ - && /opt/docker/bin/bootstrap.sh - + && /opt/docker/bin/bootstrap.sh \ + && docker-image-cleanup EXPOSE 80 443 diff --git a/docker/nginx-dev/centos-7/Dockerfile.jinja2 b/docker/nginx-dev/centos-7/Dockerfile.jinja2 index 8cb9dab6c..ae74cb605 100644 --- a/docker/nginx-dev/centos-7/Dockerfile.jinja2 +++ b/docker/nginx-dev/centos-7/Dockerfile.jinja2 @@ -1,7 +1,5 @@ {{ docker.from("nginx", "centos-7") }} -{{ docker.version() }} - {{ environment.web() }} {{ docker.copy('conf/', '/opt/docker/') }} diff --git a/docker/nginx-dev/centos-7/conf/bin/service.d/nginx.d/12-development.sh b/docker/nginx-dev/centos-7/conf/bin/service.d/nginx.d/12-development.sh index fa4b601a9..f4695f059 100644 --- a/docker/nginx-dev/centos-7/conf/bin/service.d/nginx.d/12-development.sh +++ b/docker/nginx-dev/centos-7/conf/bin/service.d/nginx.d/12-development.sh @@ -1 +1,7 @@ -find /opt/docker/etc/nginx/ -iname '*.conf' -print0 | xargs -0 -r rpl --quiet "" "$WEB_NO_CACHE_PATTERN" > /dev/null +go-replace \ + -s "" \ + -r "$WEB_NO_CACHE_PATTERN" \ + --path=/opt/docker/etc/nginx/ \ + --path-pattern='*.conf' \ + --ignore-empty + diff --git a/docker/nginx-dev/centos-7/conf/etc/nginx/vhost.common.d/10-log.conf b/docker/nginx-dev/centos-7/conf/etc/nginx/vhost.common.d/10-log.conf new file mode 100644 index 000000000..a2cd929e7 --- /dev/null +++ b/docker/nginx-dev/centos-7/conf/etc/nginx/vhost.common.d/10-log.conf @@ -0,0 +1,2 @@ +access_log /docker.stdout; +error_log /docker.stderr info; diff --git a/docker/nginx-dev/debian-7/Dockerfile b/docker/nginx-dev/debian-7/Dockerfile index bc11cf563..06c1bb79e 100644 --- a/docker/nginx-dev/debian-7/Dockerfile +++ b/docker/nginx-dev/debian-7/Dockerfile @@ -5,21 +5,16 @@ FROM webdevops/nginx:debian-7 -MAINTAINER info@webdevops.io -LABEL vendor=WebDevOps.io -LABEL io.webdevops.layout=8 -LABEL io.webdevops.version=1.5.0 - -ENV WEB_DOCUMENT_ROOT /app -ENV WEB_DOCUMENT_INDEX index.php -ENV WEB_ALIAS_DOMAIN *.vm +ENV WEB_DOCUMENT_ROOT=/app \ + WEB_DOCUMENT_INDEX=index.php \ + WEB_ALIAS_DOMAIN=*.vm COPY conf/ /opt/docker/ # Install apache RUN echo \ && /opt/docker/bin/provision run --tag bootstrap --role webdevops-nginx-dev \ - && /opt/docker/bin/bootstrap.sh - + && /opt/docker/bin/bootstrap.sh \ + && docker-image-cleanup EXPOSE 80 443 diff --git a/docker/nginx-dev/debian-7/Dockerfile.jinja2 b/docker/nginx-dev/debian-7/Dockerfile.jinja2 index 9709b08fb..57defa803 100644 --- a/docker/nginx-dev/debian-7/Dockerfile.jinja2 +++ b/docker/nginx-dev/debian-7/Dockerfile.jinja2 @@ -1,7 +1,5 @@ {{ docker.from("nginx", "debian-7") }} -{{ docker.version() }} - {{ environment.web() }} {{ docker.copy('conf/', '/opt/docker/') }} diff --git a/docker/nginx-dev/debian-7/conf/bin/service.d/nginx.d/12-development.sh b/docker/nginx-dev/debian-7/conf/bin/service.d/nginx.d/12-development.sh index fa4b601a9..f4695f059 100644 --- a/docker/nginx-dev/debian-7/conf/bin/service.d/nginx.d/12-development.sh +++ b/docker/nginx-dev/debian-7/conf/bin/service.d/nginx.d/12-development.sh @@ -1 +1,7 @@ -find /opt/docker/etc/nginx/ -iname '*.conf' -print0 | xargs -0 -r rpl --quiet "" "$WEB_NO_CACHE_PATTERN" > /dev/null +go-replace \ + -s "" \ + -r "$WEB_NO_CACHE_PATTERN" \ + --path=/opt/docker/etc/nginx/ \ + --path-pattern='*.conf' \ + --ignore-empty + diff --git a/docker/nginx-dev/debian-7/conf/etc/nginx/vhost.common.d/10-log.conf b/docker/nginx-dev/debian-7/conf/etc/nginx/vhost.common.d/10-log.conf new file mode 100644 index 000000000..a2cd929e7 --- /dev/null +++ b/docker/nginx-dev/debian-7/conf/etc/nginx/vhost.common.d/10-log.conf @@ -0,0 +1,2 @@ +access_log /docker.stdout; +error_log /docker.stderr info; diff --git a/docker/nginx-dev/debian-8/Dockerfile b/docker/nginx-dev/debian-8/Dockerfile index 9688f8538..3d9d515d1 100644 --- a/docker/nginx-dev/debian-8/Dockerfile +++ b/docker/nginx-dev/debian-8/Dockerfile @@ -5,21 +5,16 @@ FROM webdevops/nginx:debian-8 -MAINTAINER info@webdevops.io -LABEL vendor=WebDevOps.io -LABEL io.webdevops.layout=8 -LABEL io.webdevops.version=1.5.0 - -ENV WEB_DOCUMENT_ROOT /app -ENV WEB_DOCUMENT_INDEX index.php -ENV WEB_ALIAS_DOMAIN *.vm +ENV WEB_DOCUMENT_ROOT=/app \ + WEB_DOCUMENT_INDEX=index.php \ + WEB_ALIAS_DOMAIN=*.vm COPY conf/ /opt/docker/ # Install apache RUN echo \ && /opt/docker/bin/provision run --tag bootstrap --role webdevops-nginx-dev \ - && /opt/docker/bin/bootstrap.sh - + && /opt/docker/bin/bootstrap.sh \ + && docker-image-cleanup EXPOSE 80 443 diff --git a/docker/nginx-dev/debian-8/Dockerfile.jinja2 b/docker/nginx-dev/debian-8/Dockerfile.jinja2 index 363713e03..e0c62cbc8 100644 --- a/docker/nginx-dev/debian-8/Dockerfile.jinja2 +++ b/docker/nginx-dev/debian-8/Dockerfile.jinja2 @@ -1,7 +1,5 @@ {{ docker.from("nginx", "debian-8") }} -{{ docker.version() }} - {{ environment.web() }} {{ docker.copy('conf/', '/opt/docker/') }} diff --git a/docker/nginx-dev/debian-8/conf/bin/service.d/nginx.d/12-development.sh b/docker/nginx-dev/debian-8/conf/bin/service.d/nginx.d/12-development.sh index fa4b601a9..f4695f059 100644 --- a/docker/nginx-dev/debian-8/conf/bin/service.d/nginx.d/12-development.sh +++ b/docker/nginx-dev/debian-8/conf/bin/service.d/nginx.d/12-development.sh @@ -1 +1,7 @@ -find /opt/docker/etc/nginx/ -iname '*.conf' -print0 | xargs -0 -r rpl --quiet "" "$WEB_NO_CACHE_PATTERN" > /dev/null +go-replace \ + -s "" \ + -r "$WEB_NO_CACHE_PATTERN" \ + --path=/opt/docker/etc/nginx/ \ + --path-pattern='*.conf' \ + --ignore-empty + diff --git a/docker/nginx-dev/debian-8/conf/etc/nginx/vhost.common.d/10-log.conf b/docker/nginx-dev/debian-8/conf/etc/nginx/vhost.common.d/10-log.conf new file mode 100644 index 000000000..a2cd929e7 --- /dev/null +++ b/docker/nginx-dev/debian-8/conf/etc/nginx/vhost.common.d/10-log.conf @@ -0,0 +1,2 @@ +access_log /docker.stdout; +error_log /docker.stderr info; diff --git a/docker/nginx-dev/debian-9/Dockerfile b/docker/nginx-dev/debian-9/Dockerfile index 495e4dec3..7f9707c14 100644 --- a/docker/nginx-dev/debian-9/Dockerfile +++ b/docker/nginx-dev/debian-9/Dockerfile @@ -5,21 +5,16 @@ FROM webdevops/nginx:debian-9 -MAINTAINER info@webdevops.io -LABEL vendor=WebDevOps.io -LABEL io.webdevops.layout=8 -LABEL io.webdevops.version=1.5.0 - -ENV WEB_DOCUMENT_ROOT /app -ENV WEB_DOCUMENT_INDEX index.php -ENV WEB_ALIAS_DOMAIN *.vm +ENV WEB_DOCUMENT_ROOT=/app \ + WEB_DOCUMENT_INDEX=index.php \ + WEB_ALIAS_DOMAIN=*.vm COPY conf/ /opt/docker/ # Install apache RUN echo \ && /opt/docker/bin/provision run --tag bootstrap --role webdevops-nginx-dev \ - && /opt/docker/bin/bootstrap.sh - + && /opt/docker/bin/bootstrap.sh \ + && docker-image-cleanup EXPOSE 80 443 diff --git a/docker/nginx-dev/debian-9/Dockerfile.jinja2 b/docker/nginx-dev/debian-9/Dockerfile.jinja2 index 144cd8143..949be425f 100644 --- a/docker/nginx-dev/debian-9/Dockerfile.jinja2 +++ b/docker/nginx-dev/debian-9/Dockerfile.jinja2 @@ -1,7 +1,5 @@ {{ docker.from("nginx", "debian-9") }} -{{ docker.version() }} - {{ environment.web() }} {{ docker.copy('conf/', '/opt/docker/') }} diff --git a/docker/nginx-dev/debian-9/conf/bin/service.d/nginx.d/12-development.sh b/docker/nginx-dev/debian-9/conf/bin/service.d/nginx.d/12-development.sh index fa4b601a9..f4695f059 100644 --- a/docker/nginx-dev/debian-9/conf/bin/service.d/nginx.d/12-development.sh +++ b/docker/nginx-dev/debian-9/conf/bin/service.d/nginx.d/12-development.sh @@ -1 +1,7 @@ -find /opt/docker/etc/nginx/ -iname '*.conf' -print0 | xargs -0 -r rpl --quiet "" "$WEB_NO_CACHE_PATTERN" > /dev/null +go-replace \ + -s "" \ + -r "$WEB_NO_CACHE_PATTERN" \ + --path=/opt/docker/etc/nginx/ \ + --path-pattern='*.conf' \ + --ignore-empty + diff --git a/docker/nginx-dev/debian-9/conf/etc/nginx/vhost.common.d/10-log.conf b/docker/nginx-dev/debian-9/conf/etc/nginx/vhost.common.d/10-log.conf new file mode 100644 index 000000000..a2cd929e7 --- /dev/null +++ b/docker/nginx-dev/debian-9/conf/etc/nginx/vhost.common.d/10-log.conf @@ -0,0 +1,2 @@ +access_log /docker.stdout; +error_log /docker.stderr info; diff --git a/docker/nginx-dev/ubuntu-12.04/Dockerfile b/docker/nginx-dev/ubuntu-12.04/Dockerfile index 09867db38..5c5d9642f 100644 --- a/docker/nginx-dev/ubuntu-12.04/Dockerfile +++ b/docker/nginx-dev/ubuntu-12.04/Dockerfile @@ -5,21 +5,16 @@ FROM webdevops/nginx:ubuntu-12.04 -MAINTAINER info@webdevops.io -LABEL vendor=WebDevOps.io -LABEL io.webdevops.layout=8 -LABEL io.webdevops.version=1.5.0 - -ENV WEB_DOCUMENT_ROOT /app -ENV WEB_DOCUMENT_INDEX index.php -ENV WEB_ALIAS_DOMAIN *.vm +ENV WEB_DOCUMENT_ROOT=/app \ + WEB_DOCUMENT_INDEX=index.php \ + WEB_ALIAS_DOMAIN=*.vm COPY conf/ /opt/docker/ # Install apache RUN echo \ && /opt/docker/bin/provision run --tag bootstrap --role webdevops-nginx-dev \ - && /opt/docker/bin/bootstrap.sh - + && /opt/docker/bin/bootstrap.sh \ + && docker-image-cleanup EXPOSE 80 443 diff --git a/docker/nginx-dev/ubuntu-12.04/Dockerfile.jinja2 b/docker/nginx-dev/ubuntu-12.04/Dockerfile.jinja2 index 33f2d2bb2..e1f358869 100644 --- a/docker/nginx-dev/ubuntu-12.04/Dockerfile.jinja2 +++ b/docker/nginx-dev/ubuntu-12.04/Dockerfile.jinja2 @@ -1,7 +1,5 @@ {{ docker.from("nginx", "ubuntu-12.04") }} -{{ docker.version() }} - {{ environment.web() }} {{ docker.copy('conf/', '/opt/docker/') }} diff --git a/docker/nginx-dev/ubuntu-12.04/conf/bin/service.d/nginx.d/12-development.sh b/docker/nginx-dev/ubuntu-12.04/conf/bin/service.d/nginx.d/12-development.sh index fa4b601a9..f4695f059 100644 --- a/docker/nginx-dev/ubuntu-12.04/conf/bin/service.d/nginx.d/12-development.sh +++ b/docker/nginx-dev/ubuntu-12.04/conf/bin/service.d/nginx.d/12-development.sh @@ -1 +1,7 @@ -find /opt/docker/etc/nginx/ -iname '*.conf' -print0 | xargs -0 -r rpl --quiet "" "$WEB_NO_CACHE_PATTERN" > /dev/null +go-replace \ + -s "" \ + -r "$WEB_NO_CACHE_PATTERN" \ + --path=/opt/docker/etc/nginx/ \ + --path-pattern='*.conf' \ + --ignore-empty + diff --git a/docker/nginx-dev/ubuntu-12.04/conf/etc/nginx/vhost.common.d/10-log.conf b/docker/nginx-dev/ubuntu-12.04/conf/etc/nginx/vhost.common.d/10-log.conf new file mode 100644 index 000000000..a2cd929e7 --- /dev/null +++ b/docker/nginx-dev/ubuntu-12.04/conf/etc/nginx/vhost.common.d/10-log.conf @@ -0,0 +1,2 @@ +access_log /docker.stdout; +error_log /docker.stderr info; diff --git a/docker/nginx-dev/ubuntu-14.04/Dockerfile b/docker/nginx-dev/ubuntu-14.04/Dockerfile index 47523ef4e..10fd4f261 100644 --- a/docker/nginx-dev/ubuntu-14.04/Dockerfile +++ b/docker/nginx-dev/ubuntu-14.04/Dockerfile @@ -5,21 +5,16 @@ FROM webdevops/nginx:ubuntu-14.04 -MAINTAINER info@webdevops.io -LABEL vendor=WebDevOps.io -LABEL io.webdevops.layout=8 -LABEL io.webdevops.version=1.5.0 - -ENV WEB_DOCUMENT_ROOT /app -ENV WEB_DOCUMENT_INDEX index.php -ENV WEB_ALIAS_DOMAIN *.vm +ENV WEB_DOCUMENT_ROOT=/app \ + WEB_DOCUMENT_INDEX=index.php \ + WEB_ALIAS_DOMAIN=*.vm COPY conf/ /opt/docker/ # Install apache RUN echo \ && /opt/docker/bin/provision run --tag bootstrap --role webdevops-nginx-dev \ - && /opt/docker/bin/bootstrap.sh - + && /opt/docker/bin/bootstrap.sh \ + && docker-image-cleanup EXPOSE 80 443 diff --git a/docker/nginx-dev/ubuntu-14.04/Dockerfile.jinja2 b/docker/nginx-dev/ubuntu-14.04/Dockerfile.jinja2 index fa47fee73..2501067e7 100644 --- a/docker/nginx-dev/ubuntu-14.04/Dockerfile.jinja2 +++ b/docker/nginx-dev/ubuntu-14.04/Dockerfile.jinja2 @@ -1,7 +1,5 @@ {{ docker.from("nginx", "ubuntu-14.04") }} -{{ docker.version() }} - {{ environment.web() }} {{ docker.copy('conf/', '/opt/docker/') }} diff --git a/docker/nginx-dev/ubuntu-14.04/conf/bin/service.d/nginx.d/12-development.sh b/docker/nginx-dev/ubuntu-14.04/conf/bin/service.d/nginx.d/12-development.sh index fa4b601a9..f4695f059 100644 --- a/docker/nginx-dev/ubuntu-14.04/conf/bin/service.d/nginx.d/12-development.sh +++ b/docker/nginx-dev/ubuntu-14.04/conf/bin/service.d/nginx.d/12-development.sh @@ -1 +1,7 @@ -find /opt/docker/etc/nginx/ -iname '*.conf' -print0 | xargs -0 -r rpl --quiet "" "$WEB_NO_CACHE_PATTERN" > /dev/null +go-replace \ + -s "" \ + -r "$WEB_NO_CACHE_PATTERN" \ + --path=/opt/docker/etc/nginx/ \ + --path-pattern='*.conf' \ + --ignore-empty + diff --git a/docker/nginx-dev/ubuntu-14.04/conf/etc/nginx/vhost.common.d/10-log.conf b/docker/nginx-dev/ubuntu-14.04/conf/etc/nginx/vhost.common.d/10-log.conf new file mode 100644 index 000000000..a2cd929e7 --- /dev/null +++ b/docker/nginx-dev/ubuntu-14.04/conf/etc/nginx/vhost.common.d/10-log.conf @@ -0,0 +1,2 @@ +access_log /docker.stdout; +error_log /docker.stderr info; diff --git a/docker/nginx-dev/ubuntu-15.04/Dockerfile b/docker/nginx-dev/ubuntu-15.04/Dockerfile index 00e18b89d..c2ff87c60 100644 --- a/docker/nginx-dev/ubuntu-15.04/Dockerfile +++ b/docker/nginx-dev/ubuntu-15.04/Dockerfile @@ -5,21 +5,16 @@ FROM webdevops/nginx:ubuntu-15.04 -MAINTAINER info@webdevops.io -LABEL vendor=WebDevOps.io -LABEL io.webdevops.layout=8 -LABEL io.webdevops.version=1.5.0 - -ENV WEB_DOCUMENT_ROOT /app -ENV WEB_DOCUMENT_INDEX index.php -ENV WEB_ALIAS_DOMAIN *.vm +ENV WEB_DOCUMENT_ROOT=/app \ + WEB_DOCUMENT_INDEX=index.php \ + WEB_ALIAS_DOMAIN=*.vm COPY conf/ /opt/docker/ # Install apache RUN echo \ && /opt/docker/bin/provision run --tag bootstrap --role webdevops-nginx-dev \ - && /opt/docker/bin/bootstrap.sh - + && /opt/docker/bin/bootstrap.sh \ + && docker-image-cleanup EXPOSE 80 443 diff --git a/docker/nginx-dev/ubuntu-15.04/Dockerfile.jinja2 b/docker/nginx-dev/ubuntu-15.04/Dockerfile.jinja2 index a787e39b1..ec6a93d0c 100644 --- a/docker/nginx-dev/ubuntu-15.04/Dockerfile.jinja2 +++ b/docker/nginx-dev/ubuntu-15.04/Dockerfile.jinja2 @@ -1,7 +1,5 @@ {{ docker.from("nginx", "ubuntu-15.04") }} -{{ docker.version() }} - {{ environment.web() }} {{ docker.copy('conf/', '/opt/docker/') }} diff --git a/docker/nginx-dev/ubuntu-15.04/conf/bin/service.d/nginx.d/12-development.sh b/docker/nginx-dev/ubuntu-15.04/conf/bin/service.d/nginx.d/12-development.sh index fa4b601a9..f4695f059 100644 --- a/docker/nginx-dev/ubuntu-15.04/conf/bin/service.d/nginx.d/12-development.sh +++ b/docker/nginx-dev/ubuntu-15.04/conf/bin/service.d/nginx.d/12-development.sh @@ -1 +1,7 @@ -find /opt/docker/etc/nginx/ -iname '*.conf' -print0 | xargs -0 -r rpl --quiet "" "$WEB_NO_CACHE_PATTERN" > /dev/null +go-replace \ + -s "" \ + -r "$WEB_NO_CACHE_PATTERN" \ + --path=/opt/docker/etc/nginx/ \ + --path-pattern='*.conf' \ + --ignore-empty + diff --git a/docker/nginx-dev/ubuntu-15.04/conf/etc/nginx/vhost.common.d/10-log.conf b/docker/nginx-dev/ubuntu-15.04/conf/etc/nginx/vhost.common.d/10-log.conf new file mode 100644 index 000000000..a2cd929e7 --- /dev/null +++ b/docker/nginx-dev/ubuntu-15.04/conf/etc/nginx/vhost.common.d/10-log.conf @@ -0,0 +1,2 @@ +access_log /docker.stdout; +error_log /docker.stderr info; diff --git a/docker/nginx-dev/ubuntu-15.10/Dockerfile b/docker/nginx-dev/ubuntu-15.10/Dockerfile index 45aae883c..1783b1be2 100644 --- a/docker/nginx-dev/ubuntu-15.10/Dockerfile +++ b/docker/nginx-dev/ubuntu-15.10/Dockerfile @@ -5,21 +5,16 @@ FROM webdevops/nginx:ubuntu-15.10 -MAINTAINER info@webdevops.io -LABEL vendor=WebDevOps.io -LABEL io.webdevops.layout=8 -LABEL io.webdevops.version=1.5.0 - -ENV WEB_DOCUMENT_ROOT /app -ENV WEB_DOCUMENT_INDEX index.php -ENV WEB_ALIAS_DOMAIN *.vm +ENV WEB_DOCUMENT_ROOT=/app \ + WEB_DOCUMENT_INDEX=index.php \ + WEB_ALIAS_DOMAIN=*.vm COPY conf/ /opt/docker/ # Install apache RUN echo \ && /opt/docker/bin/provision run --tag bootstrap --role webdevops-nginx-dev \ - && /opt/docker/bin/bootstrap.sh - + && /opt/docker/bin/bootstrap.sh \ + && docker-image-cleanup EXPOSE 80 443 diff --git a/docker/nginx-dev/ubuntu-15.10/Dockerfile.jinja2 b/docker/nginx-dev/ubuntu-15.10/Dockerfile.jinja2 index 8a1395919..16129e677 100644 --- a/docker/nginx-dev/ubuntu-15.10/Dockerfile.jinja2 +++ b/docker/nginx-dev/ubuntu-15.10/Dockerfile.jinja2 @@ -1,7 +1,5 @@ {{ docker.from("nginx", "ubuntu-15.10") }} -{{ docker.version() }} - {{ environment.web() }} {{ docker.copy('conf/', '/opt/docker/') }} diff --git a/docker/nginx-dev/ubuntu-15.10/conf/bin/service.d/nginx.d/12-development.sh b/docker/nginx-dev/ubuntu-15.10/conf/bin/service.d/nginx.d/12-development.sh index fa4b601a9..f4695f059 100644 --- a/docker/nginx-dev/ubuntu-15.10/conf/bin/service.d/nginx.d/12-development.sh +++ b/docker/nginx-dev/ubuntu-15.10/conf/bin/service.d/nginx.d/12-development.sh @@ -1 +1,7 @@ -find /opt/docker/etc/nginx/ -iname '*.conf' -print0 | xargs -0 -r rpl --quiet "" "$WEB_NO_CACHE_PATTERN" > /dev/null +go-replace \ + -s "" \ + -r "$WEB_NO_CACHE_PATTERN" \ + --path=/opt/docker/etc/nginx/ \ + --path-pattern='*.conf' \ + --ignore-empty + diff --git a/docker/nginx-dev/ubuntu-15.10/conf/etc/nginx/vhost.common.d/10-log.conf b/docker/nginx-dev/ubuntu-15.10/conf/etc/nginx/vhost.common.d/10-log.conf new file mode 100644 index 000000000..a2cd929e7 --- /dev/null +++ b/docker/nginx-dev/ubuntu-15.10/conf/etc/nginx/vhost.common.d/10-log.conf @@ -0,0 +1,2 @@ +access_log /docker.stdout; +error_log /docker.stderr info; diff --git a/docker/nginx-dev/ubuntu-16.04/Dockerfile b/docker/nginx-dev/ubuntu-16.04/Dockerfile index 1f5151cb4..52aa24a19 100644 --- a/docker/nginx-dev/ubuntu-16.04/Dockerfile +++ b/docker/nginx-dev/ubuntu-16.04/Dockerfile @@ -5,21 +5,16 @@ FROM webdevops/nginx:ubuntu-16.04 -MAINTAINER info@webdevops.io -LABEL vendor=WebDevOps.io -LABEL io.webdevops.layout=8 -LABEL io.webdevops.version=1.5.0 - -ENV WEB_DOCUMENT_ROOT /app -ENV WEB_DOCUMENT_INDEX index.php -ENV WEB_ALIAS_DOMAIN *.vm +ENV WEB_DOCUMENT_ROOT=/app \ + WEB_DOCUMENT_INDEX=index.php \ + WEB_ALIAS_DOMAIN=*.vm COPY conf/ /opt/docker/ # Install apache RUN echo \ && /opt/docker/bin/provision run --tag bootstrap --role webdevops-nginx-dev \ - && /opt/docker/bin/bootstrap.sh - + && /opt/docker/bin/bootstrap.sh \ + && docker-image-cleanup EXPOSE 80 443 diff --git a/docker/nginx-dev/ubuntu-16.04/Dockerfile.jinja2 b/docker/nginx-dev/ubuntu-16.04/Dockerfile.jinja2 index e667c951d..5692d818d 100644 --- a/docker/nginx-dev/ubuntu-16.04/Dockerfile.jinja2 +++ b/docker/nginx-dev/ubuntu-16.04/Dockerfile.jinja2 @@ -1,7 +1,5 @@ {{ docker.from("nginx", "ubuntu-16.04") }} -{{ docker.version() }} - {{ environment.web() }} {{ docker.copy('conf/', '/opt/docker/') }} diff --git a/docker/nginx-dev/ubuntu-16.04/conf/bin/service.d/nginx.d/12-development.sh b/docker/nginx-dev/ubuntu-16.04/conf/bin/service.d/nginx.d/12-development.sh index fa4b601a9..f4695f059 100644 --- a/docker/nginx-dev/ubuntu-16.04/conf/bin/service.d/nginx.d/12-development.sh +++ b/docker/nginx-dev/ubuntu-16.04/conf/bin/service.d/nginx.d/12-development.sh @@ -1 +1,7 @@ -find /opt/docker/etc/nginx/ -iname '*.conf' -print0 | xargs -0 -r rpl --quiet "" "$WEB_NO_CACHE_PATTERN" > /dev/null +go-replace \ + -s "" \ + -r "$WEB_NO_CACHE_PATTERN" \ + --path=/opt/docker/etc/nginx/ \ + --path-pattern='*.conf' \ + --ignore-empty + diff --git a/docker/nginx-dev/ubuntu-16.04/conf/etc/nginx/vhost.common.d/10-log.conf b/docker/nginx-dev/ubuntu-16.04/conf/etc/nginx/vhost.common.d/10-log.conf new file mode 100644 index 000000000..a2cd929e7 --- /dev/null +++ b/docker/nginx-dev/ubuntu-16.04/conf/etc/nginx/vhost.common.d/10-log.conf @@ -0,0 +1,2 @@ +access_log /docker.stdout; +error_log /docker.stderr info; diff --git a/docker/nginx-dev/ubuntu-16.10/Dockerfile b/docker/nginx-dev/ubuntu-16.10/Dockerfile index 0ecd1a20f..effd29520 100644 --- a/docker/nginx-dev/ubuntu-16.10/Dockerfile +++ b/docker/nginx-dev/ubuntu-16.10/Dockerfile @@ -5,21 +5,16 @@ FROM webdevops/nginx:ubuntu-16.10 -MAINTAINER info@webdevops.io -LABEL vendor=WebDevOps.io -LABEL io.webdevops.layout=8 -LABEL io.webdevops.version=1.5.0 - -ENV WEB_DOCUMENT_ROOT /app -ENV WEB_DOCUMENT_INDEX index.php -ENV WEB_ALIAS_DOMAIN *.vm +ENV WEB_DOCUMENT_ROOT=/app \ + WEB_DOCUMENT_INDEX=index.php \ + WEB_ALIAS_DOMAIN=*.vm COPY conf/ /opt/docker/ # Install apache RUN echo \ && /opt/docker/bin/provision run --tag bootstrap --role webdevops-nginx-dev \ - && /opt/docker/bin/bootstrap.sh - + && /opt/docker/bin/bootstrap.sh \ + && docker-image-cleanup EXPOSE 80 443 diff --git a/docker/nginx-dev/ubuntu-16.10/Dockerfile.jinja2 b/docker/nginx-dev/ubuntu-16.10/Dockerfile.jinja2 index d2a520752..e950663f4 100644 --- a/docker/nginx-dev/ubuntu-16.10/Dockerfile.jinja2 +++ b/docker/nginx-dev/ubuntu-16.10/Dockerfile.jinja2 @@ -1,7 +1,5 @@ {{ docker.from("nginx", "ubuntu-16.10") }} -{{ docker.version() }} - {{ environment.web() }} {{ docker.copy('conf/', '/opt/docker/') }} diff --git a/docker/nginx-dev/ubuntu-16.10/conf/bin/service.d/nginx.d/12-development.sh b/docker/nginx-dev/ubuntu-16.10/conf/bin/service.d/nginx.d/12-development.sh index fa4b601a9..f4695f059 100644 --- a/docker/nginx-dev/ubuntu-16.10/conf/bin/service.d/nginx.d/12-development.sh +++ b/docker/nginx-dev/ubuntu-16.10/conf/bin/service.d/nginx.d/12-development.sh @@ -1 +1,7 @@ -find /opt/docker/etc/nginx/ -iname '*.conf' -print0 | xargs -0 -r rpl --quiet "" "$WEB_NO_CACHE_PATTERN" > /dev/null +go-replace \ + -s "" \ + -r "$WEB_NO_CACHE_PATTERN" \ + --path=/opt/docker/etc/nginx/ \ + --path-pattern='*.conf' \ + --ignore-empty + diff --git a/docker/nginx-dev/ubuntu-16.10/conf/etc/nginx/vhost.common.d/10-log.conf b/docker/nginx-dev/ubuntu-16.10/conf/etc/nginx/vhost.common.d/10-log.conf new file mode 100644 index 000000000..a2cd929e7 --- /dev/null +++ b/docker/nginx-dev/ubuntu-16.10/conf/etc/nginx/vhost.common.d/10-log.conf @@ -0,0 +1,2 @@ +access_log /docker.stdout; +error_log /docker.stderr info; diff --git a/docker/nginx/alpine-3 b/docker/nginx/alpine-3 new file mode 120000 index 000000000..0120374ca --- /dev/null +++ b/docker/nginx/alpine-3 @@ -0,0 +1 @@ +alpine \ No newline at end of file diff --git a/docker/nginx/alpine-3/Dockerfile b/docker/nginx/alpine-3/Dockerfile deleted file mode 100644 index 1040faa2f..000000000 --- a/docker/nginx/alpine-3/Dockerfile +++ /dev/null @@ -1,26 +0,0 @@ -#+++++++++++++++++++++++++++++++++++++++ -# Dockerfile for webdevops/nginx:alpine-3 -# -- automatically generated -- -#+++++++++++++++++++++++++++++++++++++++ - -FROM webdevops/base:alpine-3 - -MAINTAINER info@webdevops.io -LABEL vendor=WebDevOps.io -LABEL io.webdevops.layout=8 -LABEL io.webdevops.version=1.5.0 - -ENV WEB_DOCUMENT_ROOT /app -ENV WEB_DOCUMENT_INDEX index.php -ENV WEB_ALIAS_DOMAIN *.vm - -COPY conf/ /opt/docker/ - -# Install nginx -RUN /usr/local/bin/apk-install \ - nginx \ - && /opt/docker/bin/provision run --tag bootstrap --role webdevops-nginx \ - && /opt/docker/bin/bootstrap.sh - - -EXPOSE 80 443 diff --git a/docker/nginx/alpine-3/Dockerfile.jinja2 b/docker/nginx/alpine-3/Dockerfile.jinja2 deleted file mode 100644 index 0be9b5e64..000000000 --- a/docker/nginx/alpine-3/Dockerfile.jinja2 +++ /dev/null @@ -1,11 +0,0 @@ -{{ docker.from("base", "alpine-3") }} - -{{ docker.version() }} - -{{ environment.web() }} - -{{ docker.copy('conf/', '/opt/docker/') }} - -{{ nginx.alpine() }} - -{{ docker.expose('80 443') }} diff --git a/docker/nginx/alpine-3/conf/bin/service.d/nginx.d/10-init.sh b/docker/nginx/alpine-3/conf/bin/service.d/nginx.d/10-init.sh deleted file mode 100644 index 75a84a4eb..000000000 --- a/docker/nginx/alpine-3/conf/bin/service.d/nginx.d/10-init.sh +++ /dev/null @@ -1,23 +0,0 @@ -if [[ ! -e "$WEB_DOCUMENT_ROOT" ]]; then - echo "" - echo "[WARNING] WEB_DOCUMENT_ROOT does not exists with path \"$WEB_DOCUMENT_ROOT\"!" - echo "" -fi - -# Prevent startup of nginx (ubuntu 16.04 needs it) -ln -f -s /var/lib/nginx/logs /var/log/nginx - -# Replace markers -find /opt/docker/etc/nginx/ -iname '*.conf' -print0 | xargs -0 -r rpl --quiet "" "$WEB_DOCUMENT_INDEX" > /dev/null -find /opt/docker/etc/nginx/ -iname '*.conf' -print0 | xargs -0 -r rpl --quiet "" "$WEB_DOCUMENT_ROOT" > /dev/null -find /opt/docker/etc/nginx/ -iname '*.conf' -print0 | xargs -0 -r rpl --quiet "" "$WEB_ALIAS_DOMAIN" > /dev/null -find /opt/docker/etc/nginx/ -iname '*.conf' -print0 | xargs -0 -r rpl --quiet "" "$HOSTNAME" > /dev/null - -if [[ -n "${WEB_PHP_SOCKET+x}" ]]; then - ## WEB_PHP_SOCKET is set - find /opt/docker/etc/nginx/ -iname '*.conf' -print0 | xargs -0 -r rpl --quiet "" "$WEB_PHP_SOCKET" > /dev/null -else - ## WEB_PHP_SOCKET is not set, remove PHP files - rm -f -- /opt/docker/etc/nginx/conf.d/10-php.conf - rm -f -- /opt/docker/etc/nginx/vhost.common.d/10-php.conf -fi diff --git a/docker/nginx/alpine-3/conf/etc/nginx/vhost.conf b/docker/nginx/alpine-3/conf/etc/nginx/vhost.conf deleted file mode 100644 index d07e27094..000000000 --- a/docker/nginx/alpine-3/conf/etc/nginx/vhost.conf +++ /dev/null @@ -1,38 +0,0 @@ -server { - listen 80 default_server; - listen 8000 default_server; - - server_name _ docker; - - access_log /docker.stdout; - error_log /docker.stdout info; - - root ""; - index ; - - client_max_body_size 50m; - - include /opt/docker/etc/nginx/vhost.common.d/*.conf; -} - -############## -# SSL -############## - -server { - listen 443 default_server; - listen 8443 default_server; - - server_name _ docker; - - access_log /docker.stdout; - error_log /docker.stdout info; - - root ""; - index ; - - client_max_body_size 50m; - - include /opt/docker/etc/nginx/vhost.common.d/*.conf; - include /opt/docker/etc/nginx/vhost.ssl.conf; -} diff --git a/docker/nginx/alpine/Dockerfile b/docker/nginx/alpine/Dockerfile new file mode 100644 index 000000000..ef989626e --- /dev/null +++ b/docker/nginx/alpine/Dockerfile @@ -0,0 +1,21 @@ +#+++++++++++++++++++++++++++++++++++++++ +# Dockerfile for webdevops/nginx:alpine +# -- automatically generated -- +#+++++++++++++++++++++++++++++++++++++++ + +FROM webdevops/base:alpine + +ENV WEB_DOCUMENT_ROOT=/app \ + WEB_DOCUMENT_INDEX=index.php \ + WEB_ALIAS_DOMAIN=*.vm + +COPY conf/ /opt/docker/ + +# Install nginx +RUN /usr/local/bin/apk-install \ + nginx \ + && /opt/docker/bin/provision run --tag bootstrap --role webdevops-nginx \ + && /opt/docker/bin/bootstrap.sh \ + && docker-image-cleanup + +EXPOSE 80 443 diff --git a/docker/nginx/alpine/Dockerfile.jinja2 b/docker/nginx/alpine/Dockerfile.jinja2 new file mode 100644 index 000000000..d0d65ed82 --- /dev/null +++ b/docker/nginx/alpine/Dockerfile.jinja2 @@ -0,0 +1,9 @@ +{{ docker.from("base", "alpine") }} + +{{ environment.web() }} + +{{ docker.copy('conf/', '/opt/docker/') }} + +{{ nginx.alpine() }} + +{{ docker.expose('80 443') }} diff --git a/docker/nginx/alpine/conf/bin/service.d/nginx.d/10-init.sh b/docker/nginx/alpine/conf/bin/service.d/nginx.d/10-init.sh new file mode 100644 index 000000000..27b9776cc --- /dev/null +++ b/docker/nginx/alpine/conf/bin/service.d/nginx.d/10-init.sh @@ -0,0 +1,25 @@ +if [[ ! -e "$WEB_DOCUMENT_ROOT" ]]; then + echo "" + echo "[WARNING] WEB_DOCUMENT_ROOT does not exists with path \"$WEB_DOCUMENT_ROOT\"!" + echo "" +fi + +# Prevent startup of nginx (ubuntu 16.04 needs it) +ln -f -s /var/lib/nginx/logs /var/log/nginx + +# Replace markers +go-replace \ + -s "" -r "$WEB_DOCUMENT_INDEX" \ + -s "" -r "$WEB_DOCUMENT_ROOT" \ + -s "" -r "$WEB_ALIAS_DOMAIN" \ + -s "" -r "$HOSTNAME" \ + -s "" -r "$WEB_PHP_SOCKET" \ + --path=/opt/docker/etc/nginx/ \ + --path-pattern='*.conf' \ + --ignore-empty + +if [[ -z "${WEB_PHP_SOCKET+x}" ]]; then + ## WEB_PHP_SOCKET is not set, remove PHP files + rm -f -- /opt/docker/etc/nginx/conf.d/10-php.conf + rm -f -- /opt/docker/etc/nginx/vhost.common.d/10-php.conf +fi diff --git a/docker/nginx/alpine-3/conf/bin/service.d/nginx.sh b/docker/nginx/alpine/conf/bin/service.d/nginx.sh similarity index 100% rename from docker/nginx/alpine-3/conf/bin/service.d/nginx.sh rename to docker/nginx/alpine/conf/bin/service.d/nginx.sh diff --git a/docker/nginx/alpine/conf/etc/nginx/conf.d/.gitkeep b/docker/nginx/alpine/conf/etc/nginx/conf.d/.gitkeep new file mode 100644 index 000000000..e69de29bb diff --git a/docker/nginx/alpine-3/conf/etc/nginx/conf.d/10-php.conf b/docker/nginx/alpine/conf/etc/nginx/conf.d/10-php.conf similarity index 100% rename from docker/nginx/alpine-3/conf/etc/nginx/conf.d/10-php.conf rename to docker/nginx/alpine/conf/etc/nginx/conf.d/10-php.conf diff --git a/docker/nginx/alpine-3/conf/etc/nginx/global.conf b/docker/nginx/alpine/conf/etc/nginx/global.conf similarity index 100% rename from docker/nginx/alpine-3/conf/etc/nginx/global.conf rename to docker/nginx/alpine/conf/etc/nginx/global.conf diff --git a/docker/nginx/alpine-3/conf/etc/nginx/main.conf b/docker/nginx/alpine/conf/etc/nginx/main.conf similarity index 100% rename from docker/nginx/alpine-3/conf/etc/nginx/main.conf rename to docker/nginx/alpine/conf/etc/nginx/main.conf diff --git a/docker/nginx/alpine-3/conf/etc/nginx/nginx.conf b/docker/nginx/alpine/conf/etc/nginx/nginx.conf similarity index 100% rename from docker/nginx/alpine-3/conf/etc/nginx/nginx.conf rename to docker/nginx/alpine/conf/etc/nginx/nginx.conf diff --git a/docker/nginx/alpine-3/conf/etc/nginx/php.conf b/docker/nginx/alpine/conf/etc/nginx/php.conf similarity index 100% rename from docker/nginx/alpine-3/conf/etc/nginx/php.conf rename to docker/nginx/alpine/conf/etc/nginx/php.conf diff --git a/docker/nginx/alpine-3/conf/etc/nginx/ssl/server.crt b/docker/nginx/alpine/conf/etc/nginx/ssl/server.crt similarity index 100% rename from docker/nginx/alpine-3/conf/etc/nginx/ssl/server.crt rename to docker/nginx/alpine/conf/etc/nginx/ssl/server.crt diff --git a/docker/nginx/alpine-3/conf/etc/nginx/ssl/server.csr b/docker/nginx/alpine/conf/etc/nginx/ssl/server.csr similarity index 100% rename from docker/nginx/alpine-3/conf/etc/nginx/ssl/server.csr rename to docker/nginx/alpine/conf/etc/nginx/ssl/server.csr diff --git a/docker/nginx/alpine-3/conf/etc/nginx/ssl/server.key b/docker/nginx/alpine/conf/etc/nginx/ssl/server.key similarity index 100% rename from docker/nginx/alpine-3/conf/etc/nginx/ssl/server.key rename to docker/nginx/alpine/conf/etc/nginx/ssl/server.key diff --git a/docker/nginx/alpine-3/conf/etc/nginx/vhost.common.conf b/docker/nginx/alpine/conf/etc/nginx/vhost.common.conf similarity index 100% rename from docker/nginx/alpine-3/conf/etc/nginx/vhost.common.conf rename to docker/nginx/alpine/conf/etc/nginx/vhost.common.conf diff --git a/docker/nginx/alpine/conf/etc/nginx/vhost.common.d/.gitkeep b/docker/nginx/alpine/conf/etc/nginx/vhost.common.d/.gitkeep new file mode 100644 index 000000000..e69de29bb diff --git a/docker/nginx/alpine/conf/etc/nginx/vhost.common.d/10-general.conf b/docker/nginx/alpine/conf/etc/nginx/vhost.common.d/10-general.conf new file mode 100644 index 000000000..d3fd0aa5e --- /dev/null +++ b/docker/nginx/alpine/conf/etc/nginx/vhost.common.d/10-general.conf @@ -0,0 +1 @@ +client_max_body_size 50m; diff --git a/docker/nginx/alpine-3/conf/etc/nginx/vhost.common.d/10-location-root.conf b/docker/nginx/alpine/conf/etc/nginx/vhost.common.d/10-location-root.conf similarity index 100% rename from docker/nginx/alpine-3/conf/etc/nginx/vhost.common.d/10-location-root.conf rename to docker/nginx/alpine/conf/etc/nginx/vhost.common.d/10-location-root.conf diff --git a/docker/nginx/alpine/conf/etc/nginx/vhost.common.d/10-log.conf b/docker/nginx/alpine/conf/etc/nginx/vhost.common.d/10-log.conf new file mode 100644 index 000000000..9646c6826 --- /dev/null +++ b/docker/nginx/alpine/conf/etc/nginx/vhost.common.d/10-log.conf @@ -0,0 +1,2 @@ +access_log /docker.stdout; +error_log /docker.stderr warn; diff --git a/docker/nginx/alpine-3/conf/etc/nginx/vhost.common.d/10-php.conf b/docker/nginx/alpine/conf/etc/nginx/vhost.common.d/10-php.conf similarity index 100% rename from docker/nginx/alpine-3/conf/etc/nginx/vhost.common.d/10-php.conf rename to docker/nginx/alpine/conf/etc/nginx/vhost.common.d/10-php.conf diff --git a/docker/nginx/alpine/conf/etc/nginx/vhost.conf b/docker/nginx/alpine/conf/etc/nginx/vhost.conf new file mode 100644 index 000000000..8225f314a --- /dev/null +++ b/docker/nginx/alpine/conf/etc/nginx/vhost.conf @@ -0,0 +1,26 @@ +server { + listen 80 default_server; + + server_name _ docker; + + root ""; + index ; + + include /opt/docker/etc/nginx/vhost.common.d/*.conf; +} + +############## +# SSL +############## + +server { + listen 443 default_server; + + server_name _ docker; + + root ""; + index ; + + include /opt/docker/etc/nginx/vhost.common.d/*.conf; + include /opt/docker/etc/nginx/vhost.ssl.conf; +} diff --git a/docker/nginx/alpine-3/conf/etc/nginx/vhost.ssl.conf b/docker/nginx/alpine/conf/etc/nginx/vhost.ssl.conf similarity index 100% rename from docker/nginx/alpine-3/conf/etc/nginx/vhost.ssl.conf rename to docker/nginx/alpine/conf/etc/nginx/vhost.ssl.conf diff --git a/docker/nginx/alpine-3/conf/etc/supervisor.d/nginx.conf b/docker/nginx/alpine/conf/etc/supervisor.d/nginx.conf similarity index 100% rename from docker/nginx/alpine-3/conf/etc/supervisor.d/nginx.conf rename to docker/nginx/alpine/conf/etc/supervisor.d/nginx.conf diff --git a/docker/nginx/alpine-3/conf/provision/roles/webdevops-nginx/defaults/main.yml b/docker/nginx/alpine/conf/provision/roles/webdevops-nginx/defaults/main.yml similarity index 100% rename from docker/nginx/alpine-3/conf/provision/roles/webdevops-nginx/defaults/main.yml rename to docker/nginx/alpine/conf/provision/roles/webdevops-nginx/defaults/main.yml diff --git a/docker/nginx/alpine-3/conf/provision/roles/webdevops-nginx/tasks/bootstrap.yml b/docker/nginx/alpine/conf/provision/roles/webdevops-nginx/tasks/bootstrap.yml similarity index 100% rename from docker/nginx/alpine-3/conf/provision/roles/webdevops-nginx/tasks/bootstrap.yml rename to docker/nginx/alpine/conf/provision/roles/webdevops-nginx/tasks/bootstrap.yml diff --git a/docker/nginx/alpine-3/conf/provision/roles/webdevops-nginx/tasks/main.yml b/docker/nginx/alpine/conf/provision/roles/webdevops-nginx/tasks/main.yml similarity index 100% rename from docker/nginx/alpine-3/conf/provision/roles/webdevops-nginx/tasks/main.yml rename to docker/nginx/alpine/conf/provision/roles/webdevops-nginx/tasks/main.yml diff --git a/docker/nginx/centos-7/Dockerfile b/docker/nginx/centos-7/Dockerfile index be7e92ab5..d7ea36389 100644 --- a/docker/nginx/centos-7/Dockerfile +++ b/docker/nginx/centos-7/Dockerfile @@ -5,14 +5,9 @@ FROM webdevops/base:centos-7 -MAINTAINER info@webdevops.io -LABEL vendor=WebDevOps.io -LABEL io.webdevops.layout=8 -LABEL io.webdevops.version=1.5.0 - -ENV WEB_DOCUMENT_ROOT /app -ENV WEB_DOCUMENT_INDEX index.php -ENV WEB_ALIAS_DOMAIN *.vm +ENV WEB_DOCUMENT_ROOT=/app \ + WEB_DOCUMENT_INDEX=index.php \ + WEB_ALIAS_DOMAIN=*.vm COPY conf/ /opt/docker/ @@ -20,7 +15,7 @@ COPY conf/ /opt/docker/ RUN /usr/local/bin/yum-install \ nginx \ && /opt/docker/bin/provision run --tag bootstrap --role webdevops-nginx \ - && /opt/docker/bin/bootstrap.sh - + && /opt/docker/bin/bootstrap.sh \ + && docker-image-cleanup EXPOSE 80 443 diff --git a/docker/nginx/centos-7/Dockerfile.jinja2 b/docker/nginx/centos-7/Dockerfile.jinja2 index 6401fcd50..b1d4ad234 100644 --- a/docker/nginx/centos-7/Dockerfile.jinja2 +++ b/docker/nginx/centos-7/Dockerfile.jinja2 @@ -1,7 +1,5 @@ {{ docker.from("base", "centos-7") }} -{{ docker.version() }} - {{ environment.web() }} {{ docker.copy('conf/', '/opt/docker/') }} diff --git a/docker/nginx/centos-7/conf/bin/service.d/nginx.d/10-init.sh b/docker/nginx/centos-7/conf/bin/service.d/nginx.d/10-init.sh index 75a84a4eb..27b9776cc 100644 --- a/docker/nginx/centos-7/conf/bin/service.d/nginx.d/10-init.sh +++ b/docker/nginx/centos-7/conf/bin/service.d/nginx.d/10-init.sh @@ -8,15 +8,17 @@ fi ln -f -s /var/lib/nginx/logs /var/log/nginx # Replace markers -find /opt/docker/etc/nginx/ -iname '*.conf' -print0 | xargs -0 -r rpl --quiet "" "$WEB_DOCUMENT_INDEX" > /dev/null -find /opt/docker/etc/nginx/ -iname '*.conf' -print0 | xargs -0 -r rpl --quiet "" "$WEB_DOCUMENT_ROOT" > /dev/null -find /opt/docker/etc/nginx/ -iname '*.conf' -print0 | xargs -0 -r rpl --quiet "" "$WEB_ALIAS_DOMAIN" > /dev/null -find /opt/docker/etc/nginx/ -iname '*.conf' -print0 | xargs -0 -r rpl --quiet "" "$HOSTNAME" > /dev/null +go-replace \ + -s "" -r "$WEB_DOCUMENT_INDEX" \ + -s "" -r "$WEB_DOCUMENT_ROOT" \ + -s "" -r "$WEB_ALIAS_DOMAIN" \ + -s "" -r "$HOSTNAME" \ + -s "" -r "$WEB_PHP_SOCKET" \ + --path=/opt/docker/etc/nginx/ \ + --path-pattern='*.conf' \ + --ignore-empty -if [[ -n "${WEB_PHP_SOCKET+x}" ]]; then - ## WEB_PHP_SOCKET is set - find /opt/docker/etc/nginx/ -iname '*.conf' -print0 | xargs -0 -r rpl --quiet "" "$WEB_PHP_SOCKET" > /dev/null -else +if [[ -z "${WEB_PHP_SOCKET+x}" ]]; then ## WEB_PHP_SOCKET is not set, remove PHP files rm -f -- /opt/docker/etc/nginx/conf.d/10-php.conf rm -f -- /opt/docker/etc/nginx/vhost.common.d/10-php.conf diff --git a/docker/nginx/centos-7/conf/etc/nginx/vhost.common.d/10-general.conf b/docker/nginx/centos-7/conf/etc/nginx/vhost.common.d/10-general.conf new file mode 100644 index 000000000..d3fd0aa5e --- /dev/null +++ b/docker/nginx/centos-7/conf/etc/nginx/vhost.common.d/10-general.conf @@ -0,0 +1 @@ +client_max_body_size 50m; diff --git a/docker/nginx/centos-7/conf/etc/nginx/vhost.common.d/10-log.conf b/docker/nginx/centos-7/conf/etc/nginx/vhost.common.d/10-log.conf new file mode 100644 index 000000000..9646c6826 --- /dev/null +++ b/docker/nginx/centos-7/conf/etc/nginx/vhost.common.d/10-log.conf @@ -0,0 +1,2 @@ +access_log /docker.stdout; +error_log /docker.stderr warn; diff --git a/docker/nginx/centos-7/conf/etc/nginx/vhost.conf b/docker/nginx/centos-7/conf/etc/nginx/vhost.conf index d07e27094..8225f314a 100644 --- a/docker/nginx/centos-7/conf/etc/nginx/vhost.conf +++ b/docker/nginx/centos-7/conf/etc/nginx/vhost.conf @@ -1,17 +1,11 @@ server { - listen 80 default_server; - listen 8000 default_server; + listen 80 default_server; server_name _ docker; - access_log /docker.stdout; - error_log /docker.stdout info; - root ""; index ; - client_max_body_size 50m; - include /opt/docker/etc/nginx/vhost.common.d/*.conf; } @@ -20,19 +14,13 @@ server { ############## server { - listen 443 default_server; - listen 8443 default_server; + listen 443 default_server; server_name _ docker; - access_log /docker.stdout; - error_log /docker.stdout info; - root ""; index ; - client_max_body_size 50m; - include /opt/docker/etc/nginx/vhost.common.d/*.conf; include /opt/docker/etc/nginx/vhost.ssl.conf; } diff --git a/docker/nginx/debian-7/Dockerfile b/docker/nginx/debian-7/Dockerfile index 7e26d64c2..0b5f9b368 100644 --- a/docker/nginx/debian-7/Dockerfile +++ b/docker/nginx/debian-7/Dockerfile @@ -5,14 +5,9 @@ FROM webdevops/base:debian-7 -MAINTAINER info@webdevops.io -LABEL vendor=WebDevOps.io -LABEL io.webdevops.layout=8 -LABEL io.webdevops.version=1.5.0 - -ENV WEB_DOCUMENT_ROOT /app -ENV WEB_DOCUMENT_INDEX index.php -ENV WEB_ALIAS_DOMAIN *.vm +ENV WEB_DOCUMENT_ROOT=/app \ + WEB_DOCUMENT_INDEX=index.php \ + WEB_ALIAS_DOMAIN=*.vm COPY conf/ /opt/docker/ @@ -20,7 +15,7 @@ COPY conf/ /opt/docker/ RUN /usr/local/bin/apt-install \ nginx \ && /opt/docker/bin/provision run --tag bootstrap --role webdevops-nginx \ - && /opt/docker/bin/bootstrap.sh - + && /opt/docker/bin/bootstrap.sh \ + && docker-image-cleanup EXPOSE 80 443 diff --git a/docker/nginx/debian-7/Dockerfile.jinja2 b/docker/nginx/debian-7/Dockerfile.jinja2 index f7bc02c78..ceabe21dc 100644 --- a/docker/nginx/debian-7/Dockerfile.jinja2 +++ b/docker/nginx/debian-7/Dockerfile.jinja2 @@ -1,7 +1,5 @@ {{ docker.from("base", "debian-7") }} -{{ docker.version() }} - {{ environment.web() }} {{ docker.copy('conf/', '/opt/docker/') }} diff --git a/docker/nginx/debian-7/conf/bin/service.d/nginx.d/10-init.sh b/docker/nginx/debian-7/conf/bin/service.d/nginx.d/10-init.sh index 75a84a4eb..27b9776cc 100644 --- a/docker/nginx/debian-7/conf/bin/service.d/nginx.d/10-init.sh +++ b/docker/nginx/debian-7/conf/bin/service.d/nginx.d/10-init.sh @@ -8,15 +8,17 @@ fi ln -f -s /var/lib/nginx/logs /var/log/nginx # Replace markers -find /opt/docker/etc/nginx/ -iname '*.conf' -print0 | xargs -0 -r rpl --quiet "" "$WEB_DOCUMENT_INDEX" > /dev/null -find /opt/docker/etc/nginx/ -iname '*.conf' -print0 | xargs -0 -r rpl --quiet "" "$WEB_DOCUMENT_ROOT" > /dev/null -find /opt/docker/etc/nginx/ -iname '*.conf' -print0 | xargs -0 -r rpl --quiet "" "$WEB_ALIAS_DOMAIN" > /dev/null -find /opt/docker/etc/nginx/ -iname '*.conf' -print0 | xargs -0 -r rpl --quiet "" "$HOSTNAME" > /dev/null +go-replace \ + -s "" -r "$WEB_DOCUMENT_INDEX" \ + -s "" -r "$WEB_DOCUMENT_ROOT" \ + -s "" -r "$WEB_ALIAS_DOMAIN" \ + -s "" -r "$HOSTNAME" \ + -s "" -r "$WEB_PHP_SOCKET" \ + --path=/opt/docker/etc/nginx/ \ + --path-pattern='*.conf' \ + --ignore-empty -if [[ -n "${WEB_PHP_SOCKET+x}" ]]; then - ## WEB_PHP_SOCKET is set - find /opt/docker/etc/nginx/ -iname '*.conf' -print0 | xargs -0 -r rpl --quiet "" "$WEB_PHP_SOCKET" > /dev/null -else +if [[ -z "${WEB_PHP_SOCKET+x}" ]]; then ## WEB_PHP_SOCKET is not set, remove PHP files rm -f -- /opt/docker/etc/nginx/conf.d/10-php.conf rm -f -- /opt/docker/etc/nginx/vhost.common.d/10-php.conf diff --git a/docker/nginx/debian-7/conf/etc/nginx/vhost.common.d/10-general.conf b/docker/nginx/debian-7/conf/etc/nginx/vhost.common.d/10-general.conf new file mode 100644 index 000000000..d3fd0aa5e --- /dev/null +++ b/docker/nginx/debian-7/conf/etc/nginx/vhost.common.d/10-general.conf @@ -0,0 +1 @@ +client_max_body_size 50m; diff --git a/docker/nginx/debian-7/conf/etc/nginx/vhost.common.d/10-log.conf b/docker/nginx/debian-7/conf/etc/nginx/vhost.common.d/10-log.conf new file mode 100644 index 000000000..9646c6826 --- /dev/null +++ b/docker/nginx/debian-7/conf/etc/nginx/vhost.common.d/10-log.conf @@ -0,0 +1,2 @@ +access_log /docker.stdout; +error_log /docker.stderr warn; diff --git a/docker/nginx/debian-7/conf/etc/nginx/vhost.conf b/docker/nginx/debian-7/conf/etc/nginx/vhost.conf index d07e27094..8225f314a 100644 --- a/docker/nginx/debian-7/conf/etc/nginx/vhost.conf +++ b/docker/nginx/debian-7/conf/etc/nginx/vhost.conf @@ -1,17 +1,11 @@ server { - listen 80 default_server; - listen 8000 default_server; + listen 80 default_server; server_name _ docker; - access_log /docker.stdout; - error_log /docker.stdout info; - root ""; index ; - client_max_body_size 50m; - include /opt/docker/etc/nginx/vhost.common.d/*.conf; } @@ -20,19 +14,13 @@ server { ############## server { - listen 443 default_server; - listen 8443 default_server; + listen 443 default_server; server_name _ docker; - access_log /docker.stdout; - error_log /docker.stdout info; - root ""; index ; - client_max_body_size 50m; - include /opt/docker/etc/nginx/vhost.common.d/*.conf; include /opt/docker/etc/nginx/vhost.ssl.conf; } diff --git a/docker/nginx/debian-8/Dockerfile b/docker/nginx/debian-8/Dockerfile index 4cbf5ab38..cfa899058 100644 --- a/docker/nginx/debian-8/Dockerfile +++ b/docker/nginx/debian-8/Dockerfile @@ -5,14 +5,9 @@ FROM webdevops/base:debian-8 -MAINTAINER info@webdevops.io -LABEL vendor=WebDevOps.io -LABEL io.webdevops.layout=8 -LABEL io.webdevops.version=1.5.0 - -ENV WEB_DOCUMENT_ROOT /app -ENV WEB_DOCUMENT_INDEX index.php -ENV WEB_ALIAS_DOMAIN *.vm +ENV WEB_DOCUMENT_ROOT=/app \ + WEB_DOCUMENT_INDEX=index.php \ + WEB_ALIAS_DOMAIN=*.vm COPY conf/ /opt/docker/ @@ -20,7 +15,7 @@ COPY conf/ /opt/docker/ RUN /usr/local/bin/apt-install \ nginx \ && /opt/docker/bin/provision run --tag bootstrap --role webdevops-nginx \ - && /opt/docker/bin/bootstrap.sh - + && /opt/docker/bin/bootstrap.sh \ + && docker-image-cleanup EXPOSE 80 443 diff --git a/docker/nginx/debian-8/Dockerfile.jinja2 b/docker/nginx/debian-8/Dockerfile.jinja2 index 75fae8911..90470a38f 100644 --- a/docker/nginx/debian-8/Dockerfile.jinja2 +++ b/docker/nginx/debian-8/Dockerfile.jinja2 @@ -1,7 +1,5 @@ {{ docker.from("base", "debian-8") }} -{{ docker.version() }} - {{ environment.web() }} {{ docker.copy('conf/', '/opt/docker/') }} diff --git a/docker/nginx/debian-8/conf/bin/service.d/nginx.d/10-init.sh b/docker/nginx/debian-8/conf/bin/service.d/nginx.d/10-init.sh index 75a84a4eb..27b9776cc 100644 --- a/docker/nginx/debian-8/conf/bin/service.d/nginx.d/10-init.sh +++ b/docker/nginx/debian-8/conf/bin/service.d/nginx.d/10-init.sh @@ -8,15 +8,17 @@ fi ln -f -s /var/lib/nginx/logs /var/log/nginx # Replace markers -find /opt/docker/etc/nginx/ -iname '*.conf' -print0 | xargs -0 -r rpl --quiet "" "$WEB_DOCUMENT_INDEX" > /dev/null -find /opt/docker/etc/nginx/ -iname '*.conf' -print0 | xargs -0 -r rpl --quiet "" "$WEB_DOCUMENT_ROOT" > /dev/null -find /opt/docker/etc/nginx/ -iname '*.conf' -print0 | xargs -0 -r rpl --quiet "" "$WEB_ALIAS_DOMAIN" > /dev/null -find /opt/docker/etc/nginx/ -iname '*.conf' -print0 | xargs -0 -r rpl --quiet "" "$HOSTNAME" > /dev/null +go-replace \ + -s "" -r "$WEB_DOCUMENT_INDEX" \ + -s "" -r "$WEB_DOCUMENT_ROOT" \ + -s "" -r "$WEB_ALIAS_DOMAIN" \ + -s "" -r "$HOSTNAME" \ + -s "" -r "$WEB_PHP_SOCKET" \ + --path=/opt/docker/etc/nginx/ \ + --path-pattern='*.conf' \ + --ignore-empty -if [[ -n "${WEB_PHP_SOCKET+x}" ]]; then - ## WEB_PHP_SOCKET is set - find /opt/docker/etc/nginx/ -iname '*.conf' -print0 | xargs -0 -r rpl --quiet "" "$WEB_PHP_SOCKET" > /dev/null -else +if [[ -z "${WEB_PHP_SOCKET+x}" ]]; then ## WEB_PHP_SOCKET is not set, remove PHP files rm -f -- /opt/docker/etc/nginx/conf.d/10-php.conf rm -f -- /opt/docker/etc/nginx/vhost.common.d/10-php.conf diff --git a/docker/nginx/debian-8/conf/etc/nginx/vhost.common.d/10-general.conf b/docker/nginx/debian-8/conf/etc/nginx/vhost.common.d/10-general.conf new file mode 100644 index 000000000..d3fd0aa5e --- /dev/null +++ b/docker/nginx/debian-8/conf/etc/nginx/vhost.common.d/10-general.conf @@ -0,0 +1 @@ +client_max_body_size 50m; diff --git a/docker/nginx/debian-8/conf/etc/nginx/vhost.common.d/10-log.conf b/docker/nginx/debian-8/conf/etc/nginx/vhost.common.d/10-log.conf new file mode 100644 index 000000000..9646c6826 --- /dev/null +++ b/docker/nginx/debian-8/conf/etc/nginx/vhost.common.d/10-log.conf @@ -0,0 +1,2 @@ +access_log /docker.stdout; +error_log /docker.stderr warn; diff --git a/docker/nginx/debian-8/conf/etc/nginx/vhost.conf b/docker/nginx/debian-8/conf/etc/nginx/vhost.conf index d07e27094..8225f314a 100644 --- a/docker/nginx/debian-8/conf/etc/nginx/vhost.conf +++ b/docker/nginx/debian-8/conf/etc/nginx/vhost.conf @@ -1,17 +1,11 @@ server { - listen 80 default_server; - listen 8000 default_server; + listen 80 default_server; server_name _ docker; - access_log /docker.stdout; - error_log /docker.stdout info; - root ""; index ; - client_max_body_size 50m; - include /opt/docker/etc/nginx/vhost.common.d/*.conf; } @@ -20,19 +14,13 @@ server { ############## server { - listen 443 default_server; - listen 8443 default_server; + listen 443 default_server; server_name _ docker; - access_log /docker.stdout; - error_log /docker.stdout info; - root ""; index ; - client_max_body_size 50m; - include /opt/docker/etc/nginx/vhost.common.d/*.conf; include /opt/docker/etc/nginx/vhost.ssl.conf; } diff --git a/docker/nginx/debian-9/Dockerfile b/docker/nginx/debian-9/Dockerfile index 9f3ffde21..802424c03 100644 --- a/docker/nginx/debian-9/Dockerfile +++ b/docker/nginx/debian-9/Dockerfile @@ -5,14 +5,9 @@ FROM webdevops/base:debian-9 -MAINTAINER info@webdevops.io -LABEL vendor=WebDevOps.io -LABEL io.webdevops.layout=8 -LABEL io.webdevops.version=1.5.0 - -ENV WEB_DOCUMENT_ROOT /app -ENV WEB_DOCUMENT_INDEX index.php -ENV WEB_ALIAS_DOMAIN *.vm +ENV WEB_DOCUMENT_ROOT=/app \ + WEB_DOCUMENT_INDEX=index.php \ + WEB_ALIAS_DOMAIN=*.vm COPY conf/ /opt/docker/ @@ -20,7 +15,7 @@ COPY conf/ /opt/docker/ RUN /usr/local/bin/apt-install \ nginx \ && /opt/docker/bin/provision run --tag bootstrap --role webdevops-nginx \ - && /opt/docker/bin/bootstrap.sh - + && /opt/docker/bin/bootstrap.sh \ + && docker-image-cleanup EXPOSE 80 443 diff --git a/docker/nginx/debian-9/Dockerfile.jinja2 b/docker/nginx/debian-9/Dockerfile.jinja2 index 69e46a1d3..98d797329 100644 --- a/docker/nginx/debian-9/Dockerfile.jinja2 +++ b/docker/nginx/debian-9/Dockerfile.jinja2 @@ -1,7 +1,5 @@ {{ docker.from("base", "debian-9") }} -{{ docker.version() }} - {{ environment.web() }} {{ docker.copy('conf/', '/opt/docker/') }} diff --git a/docker/nginx/debian-9/conf/bin/service.d/nginx.d/10-init.sh b/docker/nginx/debian-9/conf/bin/service.d/nginx.d/10-init.sh index 75a84a4eb..27b9776cc 100644 --- a/docker/nginx/debian-9/conf/bin/service.d/nginx.d/10-init.sh +++ b/docker/nginx/debian-9/conf/bin/service.d/nginx.d/10-init.sh @@ -8,15 +8,17 @@ fi ln -f -s /var/lib/nginx/logs /var/log/nginx # Replace markers -find /opt/docker/etc/nginx/ -iname '*.conf' -print0 | xargs -0 -r rpl --quiet "" "$WEB_DOCUMENT_INDEX" > /dev/null -find /opt/docker/etc/nginx/ -iname '*.conf' -print0 | xargs -0 -r rpl --quiet "" "$WEB_DOCUMENT_ROOT" > /dev/null -find /opt/docker/etc/nginx/ -iname '*.conf' -print0 | xargs -0 -r rpl --quiet "" "$WEB_ALIAS_DOMAIN" > /dev/null -find /opt/docker/etc/nginx/ -iname '*.conf' -print0 | xargs -0 -r rpl --quiet "" "$HOSTNAME" > /dev/null +go-replace \ + -s "" -r "$WEB_DOCUMENT_INDEX" \ + -s "" -r "$WEB_DOCUMENT_ROOT" \ + -s "" -r "$WEB_ALIAS_DOMAIN" \ + -s "" -r "$HOSTNAME" \ + -s "" -r "$WEB_PHP_SOCKET" \ + --path=/opt/docker/etc/nginx/ \ + --path-pattern='*.conf' \ + --ignore-empty -if [[ -n "${WEB_PHP_SOCKET+x}" ]]; then - ## WEB_PHP_SOCKET is set - find /opt/docker/etc/nginx/ -iname '*.conf' -print0 | xargs -0 -r rpl --quiet "" "$WEB_PHP_SOCKET" > /dev/null -else +if [[ -z "${WEB_PHP_SOCKET+x}" ]]; then ## WEB_PHP_SOCKET is not set, remove PHP files rm -f -- /opt/docker/etc/nginx/conf.d/10-php.conf rm -f -- /opt/docker/etc/nginx/vhost.common.d/10-php.conf diff --git a/docker/nginx/debian-9/conf/etc/nginx/vhost.common.d/10-general.conf b/docker/nginx/debian-9/conf/etc/nginx/vhost.common.d/10-general.conf new file mode 100644 index 000000000..d3fd0aa5e --- /dev/null +++ b/docker/nginx/debian-9/conf/etc/nginx/vhost.common.d/10-general.conf @@ -0,0 +1 @@ +client_max_body_size 50m; diff --git a/docker/nginx/debian-9/conf/etc/nginx/vhost.common.d/10-log.conf b/docker/nginx/debian-9/conf/etc/nginx/vhost.common.d/10-log.conf new file mode 100644 index 000000000..9646c6826 --- /dev/null +++ b/docker/nginx/debian-9/conf/etc/nginx/vhost.common.d/10-log.conf @@ -0,0 +1,2 @@ +access_log /docker.stdout; +error_log /docker.stderr warn; diff --git a/docker/nginx/debian-9/conf/etc/nginx/vhost.conf b/docker/nginx/debian-9/conf/etc/nginx/vhost.conf index d07e27094..8225f314a 100644 --- a/docker/nginx/debian-9/conf/etc/nginx/vhost.conf +++ b/docker/nginx/debian-9/conf/etc/nginx/vhost.conf @@ -1,17 +1,11 @@ server { - listen 80 default_server; - listen 8000 default_server; + listen 80 default_server; server_name _ docker; - access_log /docker.stdout; - error_log /docker.stdout info; - root ""; index ; - client_max_body_size 50m; - include /opt/docker/etc/nginx/vhost.common.d/*.conf; } @@ -20,19 +14,13 @@ server { ############## server { - listen 443 default_server; - listen 8443 default_server; + listen 443 default_server; server_name _ docker; - access_log /docker.stdout; - error_log /docker.stdout info; - root ""; index ; - client_max_body_size 50m; - include /opt/docker/etc/nginx/vhost.common.d/*.conf; include /opt/docker/etc/nginx/vhost.ssl.conf; } diff --git a/docker/nginx/ubuntu-12.04/Dockerfile b/docker/nginx/ubuntu-12.04/Dockerfile index 9aad4af44..5a0ea993a 100644 --- a/docker/nginx/ubuntu-12.04/Dockerfile +++ b/docker/nginx/ubuntu-12.04/Dockerfile @@ -5,14 +5,9 @@ FROM webdevops/base:ubuntu-12.04 -MAINTAINER info@webdevops.io -LABEL vendor=WebDevOps.io -LABEL io.webdevops.layout=8 -LABEL io.webdevops.version=1.5.0 - -ENV WEB_DOCUMENT_ROOT /app -ENV WEB_DOCUMENT_INDEX index.php -ENV WEB_ALIAS_DOMAIN *.vm +ENV WEB_DOCUMENT_ROOT=/app \ + WEB_DOCUMENT_INDEX=index.php \ + WEB_ALIAS_DOMAIN=*.vm COPY conf/ /opt/docker/ @@ -20,7 +15,7 @@ COPY conf/ /opt/docker/ RUN /usr/local/bin/apt-install \ nginx \ && /opt/docker/bin/provision run --tag bootstrap --role webdevops-nginx \ - && /opt/docker/bin/bootstrap.sh - + && /opt/docker/bin/bootstrap.sh \ + && docker-image-cleanup EXPOSE 80 443 diff --git a/docker/nginx/ubuntu-12.04/Dockerfile.jinja2 b/docker/nginx/ubuntu-12.04/Dockerfile.jinja2 index 275cb76f9..b87279b56 100644 --- a/docker/nginx/ubuntu-12.04/Dockerfile.jinja2 +++ b/docker/nginx/ubuntu-12.04/Dockerfile.jinja2 @@ -1,7 +1,5 @@ {{ docker.from("base", "ubuntu-12.04") }} -{{ docker.version() }} - {{ environment.web() }} {{ docker.copy('conf/', '/opt/docker/') }} diff --git a/docker/nginx/ubuntu-12.04/conf/bin/service.d/nginx.d/10-init.sh b/docker/nginx/ubuntu-12.04/conf/bin/service.d/nginx.d/10-init.sh index 75a84a4eb..27b9776cc 100644 --- a/docker/nginx/ubuntu-12.04/conf/bin/service.d/nginx.d/10-init.sh +++ b/docker/nginx/ubuntu-12.04/conf/bin/service.d/nginx.d/10-init.sh @@ -8,15 +8,17 @@ fi ln -f -s /var/lib/nginx/logs /var/log/nginx # Replace markers -find /opt/docker/etc/nginx/ -iname '*.conf' -print0 | xargs -0 -r rpl --quiet "" "$WEB_DOCUMENT_INDEX" > /dev/null -find /opt/docker/etc/nginx/ -iname '*.conf' -print0 | xargs -0 -r rpl --quiet "" "$WEB_DOCUMENT_ROOT" > /dev/null -find /opt/docker/etc/nginx/ -iname '*.conf' -print0 | xargs -0 -r rpl --quiet "" "$WEB_ALIAS_DOMAIN" > /dev/null -find /opt/docker/etc/nginx/ -iname '*.conf' -print0 | xargs -0 -r rpl --quiet "" "$HOSTNAME" > /dev/null +go-replace \ + -s "" -r "$WEB_DOCUMENT_INDEX" \ + -s "" -r "$WEB_DOCUMENT_ROOT" \ + -s "" -r "$WEB_ALIAS_DOMAIN" \ + -s "" -r "$HOSTNAME" \ + -s "" -r "$WEB_PHP_SOCKET" \ + --path=/opt/docker/etc/nginx/ \ + --path-pattern='*.conf' \ + --ignore-empty -if [[ -n "${WEB_PHP_SOCKET+x}" ]]; then - ## WEB_PHP_SOCKET is set - find /opt/docker/etc/nginx/ -iname '*.conf' -print0 | xargs -0 -r rpl --quiet "" "$WEB_PHP_SOCKET" > /dev/null -else +if [[ -z "${WEB_PHP_SOCKET+x}" ]]; then ## WEB_PHP_SOCKET is not set, remove PHP files rm -f -- /opt/docker/etc/nginx/conf.d/10-php.conf rm -f -- /opt/docker/etc/nginx/vhost.common.d/10-php.conf diff --git a/docker/nginx/ubuntu-12.04/conf/etc/nginx/vhost.common.d/10-general.conf b/docker/nginx/ubuntu-12.04/conf/etc/nginx/vhost.common.d/10-general.conf new file mode 100644 index 000000000..d3fd0aa5e --- /dev/null +++ b/docker/nginx/ubuntu-12.04/conf/etc/nginx/vhost.common.d/10-general.conf @@ -0,0 +1 @@ +client_max_body_size 50m; diff --git a/docker/nginx/ubuntu-12.04/conf/etc/nginx/vhost.common.d/10-log.conf b/docker/nginx/ubuntu-12.04/conf/etc/nginx/vhost.common.d/10-log.conf new file mode 100644 index 000000000..9646c6826 --- /dev/null +++ b/docker/nginx/ubuntu-12.04/conf/etc/nginx/vhost.common.d/10-log.conf @@ -0,0 +1,2 @@ +access_log /docker.stdout; +error_log /docker.stderr warn; diff --git a/docker/nginx/ubuntu-12.04/conf/etc/nginx/vhost.conf b/docker/nginx/ubuntu-12.04/conf/etc/nginx/vhost.conf index d07e27094..8225f314a 100644 --- a/docker/nginx/ubuntu-12.04/conf/etc/nginx/vhost.conf +++ b/docker/nginx/ubuntu-12.04/conf/etc/nginx/vhost.conf @@ -1,17 +1,11 @@ server { - listen 80 default_server; - listen 8000 default_server; + listen 80 default_server; server_name _ docker; - access_log /docker.stdout; - error_log /docker.stdout info; - root ""; index ; - client_max_body_size 50m; - include /opt/docker/etc/nginx/vhost.common.d/*.conf; } @@ -20,19 +14,13 @@ server { ############## server { - listen 443 default_server; - listen 8443 default_server; + listen 443 default_server; server_name _ docker; - access_log /docker.stdout; - error_log /docker.stdout info; - root ""; index ; - client_max_body_size 50m; - include /opt/docker/etc/nginx/vhost.common.d/*.conf; include /opt/docker/etc/nginx/vhost.ssl.conf; } diff --git a/docker/nginx/ubuntu-14.04/Dockerfile b/docker/nginx/ubuntu-14.04/Dockerfile index 29d85d0ec..9515f45b8 100644 --- a/docker/nginx/ubuntu-14.04/Dockerfile +++ b/docker/nginx/ubuntu-14.04/Dockerfile @@ -5,14 +5,9 @@ FROM webdevops/base:ubuntu-14.04 -MAINTAINER info@webdevops.io -LABEL vendor=WebDevOps.io -LABEL io.webdevops.layout=8 -LABEL io.webdevops.version=1.5.0 - -ENV WEB_DOCUMENT_ROOT /app -ENV WEB_DOCUMENT_INDEX index.php -ENV WEB_ALIAS_DOMAIN *.vm +ENV WEB_DOCUMENT_ROOT=/app \ + WEB_DOCUMENT_INDEX=index.php \ + WEB_ALIAS_DOMAIN=*.vm COPY conf/ /opt/docker/ @@ -20,7 +15,7 @@ COPY conf/ /opt/docker/ RUN /usr/local/bin/apt-install \ nginx \ && /opt/docker/bin/provision run --tag bootstrap --role webdevops-nginx \ - && /opt/docker/bin/bootstrap.sh - + && /opt/docker/bin/bootstrap.sh \ + && docker-image-cleanup EXPOSE 80 443 diff --git a/docker/nginx/ubuntu-14.04/Dockerfile.jinja2 b/docker/nginx/ubuntu-14.04/Dockerfile.jinja2 index 3ef996efd..08404c0a5 100644 --- a/docker/nginx/ubuntu-14.04/Dockerfile.jinja2 +++ b/docker/nginx/ubuntu-14.04/Dockerfile.jinja2 @@ -1,7 +1,5 @@ {{ docker.from("base", "ubuntu-14.04") }} -{{ docker.version() }} - {{ environment.web() }} {{ docker.copy('conf/', '/opt/docker/') }} diff --git a/docker/nginx/ubuntu-14.04/conf/bin/service.d/nginx.d/10-init.sh b/docker/nginx/ubuntu-14.04/conf/bin/service.d/nginx.d/10-init.sh index 75a84a4eb..27b9776cc 100644 --- a/docker/nginx/ubuntu-14.04/conf/bin/service.d/nginx.d/10-init.sh +++ b/docker/nginx/ubuntu-14.04/conf/bin/service.d/nginx.d/10-init.sh @@ -8,15 +8,17 @@ fi ln -f -s /var/lib/nginx/logs /var/log/nginx # Replace markers -find /opt/docker/etc/nginx/ -iname '*.conf' -print0 | xargs -0 -r rpl --quiet "" "$WEB_DOCUMENT_INDEX" > /dev/null -find /opt/docker/etc/nginx/ -iname '*.conf' -print0 | xargs -0 -r rpl --quiet "" "$WEB_DOCUMENT_ROOT" > /dev/null -find /opt/docker/etc/nginx/ -iname '*.conf' -print0 | xargs -0 -r rpl --quiet "" "$WEB_ALIAS_DOMAIN" > /dev/null -find /opt/docker/etc/nginx/ -iname '*.conf' -print0 | xargs -0 -r rpl --quiet "" "$HOSTNAME" > /dev/null +go-replace \ + -s "" -r "$WEB_DOCUMENT_INDEX" \ + -s "" -r "$WEB_DOCUMENT_ROOT" \ + -s "" -r "$WEB_ALIAS_DOMAIN" \ + -s "" -r "$HOSTNAME" \ + -s "" -r "$WEB_PHP_SOCKET" \ + --path=/opt/docker/etc/nginx/ \ + --path-pattern='*.conf' \ + --ignore-empty -if [[ -n "${WEB_PHP_SOCKET+x}" ]]; then - ## WEB_PHP_SOCKET is set - find /opt/docker/etc/nginx/ -iname '*.conf' -print0 | xargs -0 -r rpl --quiet "" "$WEB_PHP_SOCKET" > /dev/null -else +if [[ -z "${WEB_PHP_SOCKET+x}" ]]; then ## WEB_PHP_SOCKET is not set, remove PHP files rm -f -- /opt/docker/etc/nginx/conf.d/10-php.conf rm -f -- /opt/docker/etc/nginx/vhost.common.d/10-php.conf diff --git a/docker/nginx/ubuntu-14.04/conf/etc/nginx/vhost.common.d/10-general.conf b/docker/nginx/ubuntu-14.04/conf/etc/nginx/vhost.common.d/10-general.conf new file mode 100644 index 000000000..d3fd0aa5e --- /dev/null +++ b/docker/nginx/ubuntu-14.04/conf/etc/nginx/vhost.common.d/10-general.conf @@ -0,0 +1 @@ +client_max_body_size 50m; diff --git a/docker/nginx/ubuntu-14.04/conf/etc/nginx/vhost.common.d/10-log.conf b/docker/nginx/ubuntu-14.04/conf/etc/nginx/vhost.common.d/10-log.conf new file mode 100644 index 000000000..9646c6826 --- /dev/null +++ b/docker/nginx/ubuntu-14.04/conf/etc/nginx/vhost.common.d/10-log.conf @@ -0,0 +1,2 @@ +access_log /docker.stdout; +error_log /docker.stderr warn; diff --git a/docker/nginx/ubuntu-14.04/conf/etc/nginx/vhost.conf b/docker/nginx/ubuntu-14.04/conf/etc/nginx/vhost.conf index d07e27094..8225f314a 100644 --- a/docker/nginx/ubuntu-14.04/conf/etc/nginx/vhost.conf +++ b/docker/nginx/ubuntu-14.04/conf/etc/nginx/vhost.conf @@ -1,17 +1,11 @@ server { - listen 80 default_server; - listen 8000 default_server; + listen 80 default_server; server_name _ docker; - access_log /docker.stdout; - error_log /docker.stdout info; - root ""; index ; - client_max_body_size 50m; - include /opt/docker/etc/nginx/vhost.common.d/*.conf; } @@ -20,19 +14,13 @@ server { ############## server { - listen 443 default_server; - listen 8443 default_server; + listen 443 default_server; server_name _ docker; - access_log /docker.stdout; - error_log /docker.stdout info; - root ""; index ; - client_max_body_size 50m; - include /opt/docker/etc/nginx/vhost.common.d/*.conf; include /opt/docker/etc/nginx/vhost.ssl.conf; } diff --git a/docker/nginx/ubuntu-15.04/Dockerfile b/docker/nginx/ubuntu-15.04/Dockerfile index 791a4b134..88e3e8615 100644 --- a/docker/nginx/ubuntu-15.04/Dockerfile +++ b/docker/nginx/ubuntu-15.04/Dockerfile @@ -5,14 +5,9 @@ FROM webdevops/base:ubuntu-15.04 -MAINTAINER info@webdevops.io -LABEL vendor=WebDevOps.io -LABEL io.webdevops.layout=8 -LABEL io.webdevops.version=1.5.0 - -ENV WEB_DOCUMENT_ROOT /app -ENV WEB_DOCUMENT_INDEX index.php -ENV WEB_ALIAS_DOMAIN *.vm +ENV WEB_DOCUMENT_ROOT=/app \ + WEB_DOCUMENT_INDEX=index.php \ + WEB_ALIAS_DOMAIN=*.vm COPY conf/ /opt/docker/ @@ -20,7 +15,7 @@ COPY conf/ /opt/docker/ RUN /usr/local/bin/apt-install \ nginx \ && /opt/docker/bin/provision run --tag bootstrap --role webdevops-nginx \ - && /opt/docker/bin/bootstrap.sh - + && /opt/docker/bin/bootstrap.sh \ + && docker-image-cleanup EXPOSE 80 443 diff --git a/docker/nginx/ubuntu-15.04/Dockerfile.jinja2 b/docker/nginx/ubuntu-15.04/Dockerfile.jinja2 index 03f670fa2..b912380bb 100644 --- a/docker/nginx/ubuntu-15.04/Dockerfile.jinja2 +++ b/docker/nginx/ubuntu-15.04/Dockerfile.jinja2 @@ -1,7 +1,5 @@ {{ docker.from("base", "ubuntu-15.04") }} -{{ docker.version() }} - {{ environment.web() }} {{ docker.copy('conf/', '/opt/docker/') }} diff --git a/docker/nginx/ubuntu-15.04/conf/bin/service.d/nginx.d/10-init.sh b/docker/nginx/ubuntu-15.04/conf/bin/service.d/nginx.d/10-init.sh index 75a84a4eb..27b9776cc 100644 --- a/docker/nginx/ubuntu-15.04/conf/bin/service.d/nginx.d/10-init.sh +++ b/docker/nginx/ubuntu-15.04/conf/bin/service.d/nginx.d/10-init.sh @@ -8,15 +8,17 @@ fi ln -f -s /var/lib/nginx/logs /var/log/nginx # Replace markers -find /opt/docker/etc/nginx/ -iname '*.conf' -print0 | xargs -0 -r rpl --quiet "" "$WEB_DOCUMENT_INDEX" > /dev/null -find /opt/docker/etc/nginx/ -iname '*.conf' -print0 | xargs -0 -r rpl --quiet "" "$WEB_DOCUMENT_ROOT" > /dev/null -find /opt/docker/etc/nginx/ -iname '*.conf' -print0 | xargs -0 -r rpl --quiet "" "$WEB_ALIAS_DOMAIN" > /dev/null -find /opt/docker/etc/nginx/ -iname '*.conf' -print0 | xargs -0 -r rpl --quiet "" "$HOSTNAME" > /dev/null +go-replace \ + -s "" -r "$WEB_DOCUMENT_INDEX" \ + -s "" -r "$WEB_DOCUMENT_ROOT" \ + -s "" -r "$WEB_ALIAS_DOMAIN" \ + -s "" -r "$HOSTNAME" \ + -s "" -r "$WEB_PHP_SOCKET" \ + --path=/opt/docker/etc/nginx/ \ + --path-pattern='*.conf' \ + --ignore-empty -if [[ -n "${WEB_PHP_SOCKET+x}" ]]; then - ## WEB_PHP_SOCKET is set - find /opt/docker/etc/nginx/ -iname '*.conf' -print0 | xargs -0 -r rpl --quiet "" "$WEB_PHP_SOCKET" > /dev/null -else +if [[ -z "${WEB_PHP_SOCKET+x}" ]]; then ## WEB_PHP_SOCKET is not set, remove PHP files rm -f -- /opt/docker/etc/nginx/conf.d/10-php.conf rm -f -- /opt/docker/etc/nginx/vhost.common.d/10-php.conf diff --git a/docker/nginx/ubuntu-15.04/conf/etc/nginx/vhost.common.d/10-general.conf b/docker/nginx/ubuntu-15.04/conf/etc/nginx/vhost.common.d/10-general.conf new file mode 100644 index 000000000..d3fd0aa5e --- /dev/null +++ b/docker/nginx/ubuntu-15.04/conf/etc/nginx/vhost.common.d/10-general.conf @@ -0,0 +1 @@ +client_max_body_size 50m; diff --git a/docker/nginx/ubuntu-15.04/conf/etc/nginx/vhost.common.d/10-log.conf b/docker/nginx/ubuntu-15.04/conf/etc/nginx/vhost.common.d/10-log.conf new file mode 100644 index 000000000..9646c6826 --- /dev/null +++ b/docker/nginx/ubuntu-15.04/conf/etc/nginx/vhost.common.d/10-log.conf @@ -0,0 +1,2 @@ +access_log /docker.stdout; +error_log /docker.stderr warn; diff --git a/docker/nginx/ubuntu-15.04/conf/etc/nginx/vhost.conf b/docker/nginx/ubuntu-15.04/conf/etc/nginx/vhost.conf index d07e27094..8225f314a 100644 --- a/docker/nginx/ubuntu-15.04/conf/etc/nginx/vhost.conf +++ b/docker/nginx/ubuntu-15.04/conf/etc/nginx/vhost.conf @@ -1,17 +1,11 @@ server { - listen 80 default_server; - listen 8000 default_server; + listen 80 default_server; server_name _ docker; - access_log /docker.stdout; - error_log /docker.stdout info; - root ""; index ; - client_max_body_size 50m; - include /opt/docker/etc/nginx/vhost.common.d/*.conf; } @@ -20,19 +14,13 @@ server { ############## server { - listen 443 default_server; - listen 8443 default_server; + listen 443 default_server; server_name _ docker; - access_log /docker.stdout; - error_log /docker.stdout info; - root ""; index ; - client_max_body_size 50m; - include /opt/docker/etc/nginx/vhost.common.d/*.conf; include /opt/docker/etc/nginx/vhost.ssl.conf; } diff --git a/docker/nginx/ubuntu-15.10/Dockerfile b/docker/nginx/ubuntu-15.10/Dockerfile index 732ce20d3..4ca4bb0d1 100644 --- a/docker/nginx/ubuntu-15.10/Dockerfile +++ b/docker/nginx/ubuntu-15.10/Dockerfile @@ -5,14 +5,9 @@ FROM webdevops/base:ubuntu-15.10 -MAINTAINER info@webdevops.io -LABEL vendor=WebDevOps.io -LABEL io.webdevops.layout=8 -LABEL io.webdevops.version=1.5.0 - -ENV WEB_DOCUMENT_ROOT /app -ENV WEB_DOCUMENT_INDEX index.php -ENV WEB_ALIAS_DOMAIN *.vm +ENV WEB_DOCUMENT_ROOT=/app \ + WEB_DOCUMENT_INDEX=index.php \ + WEB_ALIAS_DOMAIN=*.vm COPY conf/ /opt/docker/ @@ -20,7 +15,7 @@ COPY conf/ /opt/docker/ RUN /usr/local/bin/apt-install \ nginx \ && /opt/docker/bin/provision run --tag bootstrap --role webdevops-nginx \ - && /opt/docker/bin/bootstrap.sh - + && /opt/docker/bin/bootstrap.sh \ + && docker-image-cleanup EXPOSE 80 443 diff --git a/docker/nginx/ubuntu-15.10/Dockerfile.jinja2 b/docker/nginx/ubuntu-15.10/Dockerfile.jinja2 index 8c433be7d..afcd182c1 100644 --- a/docker/nginx/ubuntu-15.10/Dockerfile.jinja2 +++ b/docker/nginx/ubuntu-15.10/Dockerfile.jinja2 @@ -1,7 +1,5 @@ {{ docker.from("base", "ubuntu-15.10") }} -{{ docker.version() }} - {{ environment.web() }} {{ docker.copy('conf/', '/opt/docker/') }} diff --git a/docker/nginx/ubuntu-15.10/conf/bin/service.d/nginx.d/10-init.sh b/docker/nginx/ubuntu-15.10/conf/bin/service.d/nginx.d/10-init.sh index 75a84a4eb..27b9776cc 100644 --- a/docker/nginx/ubuntu-15.10/conf/bin/service.d/nginx.d/10-init.sh +++ b/docker/nginx/ubuntu-15.10/conf/bin/service.d/nginx.d/10-init.sh @@ -8,15 +8,17 @@ fi ln -f -s /var/lib/nginx/logs /var/log/nginx # Replace markers -find /opt/docker/etc/nginx/ -iname '*.conf' -print0 | xargs -0 -r rpl --quiet "" "$WEB_DOCUMENT_INDEX" > /dev/null -find /opt/docker/etc/nginx/ -iname '*.conf' -print0 | xargs -0 -r rpl --quiet "" "$WEB_DOCUMENT_ROOT" > /dev/null -find /opt/docker/etc/nginx/ -iname '*.conf' -print0 | xargs -0 -r rpl --quiet "" "$WEB_ALIAS_DOMAIN" > /dev/null -find /opt/docker/etc/nginx/ -iname '*.conf' -print0 | xargs -0 -r rpl --quiet "" "$HOSTNAME" > /dev/null +go-replace \ + -s "" -r "$WEB_DOCUMENT_INDEX" \ + -s "" -r "$WEB_DOCUMENT_ROOT" \ + -s "" -r "$WEB_ALIAS_DOMAIN" \ + -s "" -r "$HOSTNAME" \ + -s "" -r "$WEB_PHP_SOCKET" \ + --path=/opt/docker/etc/nginx/ \ + --path-pattern='*.conf' \ + --ignore-empty -if [[ -n "${WEB_PHP_SOCKET+x}" ]]; then - ## WEB_PHP_SOCKET is set - find /opt/docker/etc/nginx/ -iname '*.conf' -print0 | xargs -0 -r rpl --quiet "" "$WEB_PHP_SOCKET" > /dev/null -else +if [[ -z "${WEB_PHP_SOCKET+x}" ]]; then ## WEB_PHP_SOCKET is not set, remove PHP files rm -f -- /opt/docker/etc/nginx/conf.d/10-php.conf rm -f -- /opt/docker/etc/nginx/vhost.common.d/10-php.conf diff --git a/docker/nginx/ubuntu-15.10/conf/etc/nginx/vhost.common.d/10-general.conf b/docker/nginx/ubuntu-15.10/conf/etc/nginx/vhost.common.d/10-general.conf new file mode 100644 index 000000000..d3fd0aa5e --- /dev/null +++ b/docker/nginx/ubuntu-15.10/conf/etc/nginx/vhost.common.d/10-general.conf @@ -0,0 +1 @@ +client_max_body_size 50m; diff --git a/docker/nginx/ubuntu-15.10/conf/etc/nginx/vhost.common.d/10-log.conf b/docker/nginx/ubuntu-15.10/conf/etc/nginx/vhost.common.d/10-log.conf new file mode 100644 index 000000000..9646c6826 --- /dev/null +++ b/docker/nginx/ubuntu-15.10/conf/etc/nginx/vhost.common.d/10-log.conf @@ -0,0 +1,2 @@ +access_log /docker.stdout; +error_log /docker.stderr warn; diff --git a/docker/nginx/ubuntu-15.10/conf/etc/nginx/vhost.conf b/docker/nginx/ubuntu-15.10/conf/etc/nginx/vhost.conf index d07e27094..8225f314a 100644 --- a/docker/nginx/ubuntu-15.10/conf/etc/nginx/vhost.conf +++ b/docker/nginx/ubuntu-15.10/conf/etc/nginx/vhost.conf @@ -1,17 +1,11 @@ server { - listen 80 default_server; - listen 8000 default_server; + listen 80 default_server; server_name _ docker; - access_log /docker.stdout; - error_log /docker.stdout info; - root ""; index ; - client_max_body_size 50m; - include /opt/docker/etc/nginx/vhost.common.d/*.conf; } @@ -20,19 +14,13 @@ server { ############## server { - listen 443 default_server; - listen 8443 default_server; + listen 443 default_server; server_name _ docker; - access_log /docker.stdout; - error_log /docker.stdout info; - root ""; index ; - client_max_body_size 50m; - include /opt/docker/etc/nginx/vhost.common.d/*.conf; include /opt/docker/etc/nginx/vhost.ssl.conf; } diff --git a/docker/nginx/ubuntu-16.04/Dockerfile b/docker/nginx/ubuntu-16.04/Dockerfile index 7295a41b9..9b1cc784c 100644 --- a/docker/nginx/ubuntu-16.04/Dockerfile +++ b/docker/nginx/ubuntu-16.04/Dockerfile @@ -5,14 +5,9 @@ FROM webdevops/base:ubuntu-16.04 -MAINTAINER info@webdevops.io -LABEL vendor=WebDevOps.io -LABEL io.webdevops.layout=8 -LABEL io.webdevops.version=1.5.0 - -ENV WEB_DOCUMENT_ROOT /app -ENV WEB_DOCUMENT_INDEX index.php -ENV WEB_ALIAS_DOMAIN *.vm +ENV WEB_DOCUMENT_ROOT=/app \ + WEB_DOCUMENT_INDEX=index.php \ + WEB_ALIAS_DOMAIN=*.vm COPY conf/ /opt/docker/ @@ -20,7 +15,7 @@ COPY conf/ /opt/docker/ RUN /usr/local/bin/apt-install \ nginx \ && /opt/docker/bin/provision run --tag bootstrap --role webdevops-nginx \ - && /opt/docker/bin/bootstrap.sh - + && /opt/docker/bin/bootstrap.sh \ + && docker-image-cleanup EXPOSE 80 443 diff --git a/docker/nginx/ubuntu-16.04/Dockerfile.jinja2 b/docker/nginx/ubuntu-16.04/Dockerfile.jinja2 index 9dfe66136..a479b11c2 100644 --- a/docker/nginx/ubuntu-16.04/Dockerfile.jinja2 +++ b/docker/nginx/ubuntu-16.04/Dockerfile.jinja2 @@ -1,7 +1,5 @@ {{ docker.from("base", "ubuntu-16.04") }} -{{ docker.version() }} - {{ environment.web() }} {{ docker.copy('conf/', '/opt/docker/') }} diff --git a/docker/nginx/ubuntu-16.04/conf/bin/service.d/nginx.d/10-init.sh b/docker/nginx/ubuntu-16.04/conf/bin/service.d/nginx.d/10-init.sh index 75a84a4eb..27b9776cc 100644 --- a/docker/nginx/ubuntu-16.04/conf/bin/service.d/nginx.d/10-init.sh +++ b/docker/nginx/ubuntu-16.04/conf/bin/service.d/nginx.d/10-init.sh @@ -8,15 +8,17 @@ fi ln -f -s /var/lib/nginx/logs /var/log/nginx # Replace markers -find /opt/docker/etc/nginx/ -iname '*.conf' -print0 | xargs -0 -r rpl --quiet "" "$WEB_DOCUMENT_INDEX" > /dev/null -find /opt/docker/etc/nginx/ -iname '*.conf' -print0 | xargs -0 -r rpl --quiet "" "$WEB_DOCUMENT_ROOT" > /dev/null -find /opt/docker/etc/nginx/ -iname '*.conf' -print0 | xargs -0 -r rpl --quiet "" "$WEB_ALIAS_DOMAIN" > /dev/null -find /opt/docker/etc/nginx/ -iname '*.conf' -print0 | xargs -0 -r rpl --quiet "" "$HOSTNAME" > /dev/null +go-replace \ + -s "" -r "$WEB_DOCUMENT_INDEX" \ + -s "" -r "$WEB_DOCUMENT_ROOT" \ + -s "" -r "$WEB_ALIAS_DOMAIN" \ + -s "" -r "$HOSTNAME" \ + -s "" -r "$WEB_PHP_SOCKET" \ + --path=/opt/docker/etc/nginx/ \ + --path-pattern='*.conf' \ + --ignore-empty -if [[ -n "${WEB_PHP_SOCKET+x}" ]]; then - ## WEB_PHP_SOCKET is set - find /opt/docker/etc/nginx/ -iname '*.conf' -print0 | xargs -0 -r rpl --quiet "" "$WEB_PHP_SOCKET" > /dev/null -else +if [[ -z "${WEB_PHP_SOCKET+x}" ]]; then ## WEB_PHP_SOCKET is not set, remove PHP files rm -f -- /opt/docker/etc/nginx/conf.d/10-php.conf rm -f -- /opt/docker/etc/nginx/vhost.common.d/10-php.conf diff --git a/docker/nginx/ubuntu-16.04/conf/etc/nginx/vhost.common.d/10-general.conf b/docker/nginx/ubuntu-16.04/conf/etc/nginx/vhost.common.d/10-general.conf new file mode 100644 index 000000000..d3fd0aa5e --- /dev/null +++ b/docker/nginx/ubuntu-16.04/conf/etc/nginx/vhost.common.d/10-general.conf @@ -0,0 +1 @@ +client_max_body_size 50m; diff --git a/docker/nginx/ubuntu-16.04/conf/etc/nginx/vhost.common.d/10-log.conf b/docker/nginx/ubuntu-16.04/conf/etc/nginx/vhost.common.d/10-log.conf new file mode 100644 index 000000000..9646c6826 --- /dev/null +++ b/docker/nginx/ubuntu-16.04/conf/etc/nginx/vhost.common.d/10-log.conf @@ -0,0 +1,2 @@ +access_log /docker.stdout; +error_log /docker.stderr warn; diff --git a/docker/nginx/ubuntu-16.04/conf/etc/nginx/vhost.conf b/docker/nginx/ubuntu-16.04/conf/etc/nginx/vhost.conf index d07e27094..8225f314a 100644 --- a/docker/nginx/ubuntu-16.04/conf/etc/nginx/vhost.conf +++ b/docker/nginx/ubuntu-16.04/conf/etc/nginx/vhost.conf @@ -1,17 +1,11 @@ server { - listen 80 default_server; - listen 8000 default_server; + listen 80 default_server; server_name _ docker; - access_log /docker.stdout; - error_log /docker.stdout info; - root ""; index ; - client_max_body_size 50m; - include /opt/docker/etc/nginx/vhost.common.d/*.conf; } @@ -20,19 +14,13 @@ server { ############## server { - listen 443 default_server; - listen 8443 default_server; + listen 443 default_server; server_name _ docker; - access_log /docker.stdout; - error_log /docker.stdout info; - root ""; index ; - client_max_body_size 50m; - include /opt/docker/etc/nginx/vhost.common.d/*.conf; include /opt/docker/etc/nginx/vhost.ssl.conf; } diff --git a/docker/nginx/ubuntu-16.10/Dockerfile b/docker/nginx/ubuntu-16.10/Dockerfile index ad78b5abe..11e773c2b 100644 --- a/docker/nginx/ubuntu-16.10/Dockerfile +++ b/docker/nginx/ubuntu-16.10/Dockerfile @@ -5,14 +5,9 @@ FROM webdevops/base:ubuntu-16.10 -MAINTAINER info@webdevops.io -LABEL vendor=WebDevOps.io -LABEL io.webdevops.layout=8 -LABEL io.webdevops.version=1.5.0 - -ENV WEB_DOCUMENT_ROOT /app -ENV WEB_DOCUMENT_INDEX index.php -ENV WEB_ALIAS_DOMAIN *.vm +ENV WEB_DOCUMENT_ROOT=/app \ + WEB_DOCUMENT_INDEX=index.php \ + WEB_ALIAS_DOMAIN=*.vm COPY conf/ /opt/docker/ @@ -20,7 +15,7 @@ COPY conf/ /opt/docker/ RUN /usr/local/bin/apt-install \ nginx \ && /opt/docker/bin/provision run --tag bootstrap --role webdevops-nginx \ - && /opt/docker/bin/bootstrap.sh - + && /opt/docker/bin/bootstrap.sh \ + && docker-image-cleanup EXPOSE 80 443 diff --git a/docker/nginx/ubuntu-16.10/Dockerfile.jinja2 b/docker/nginx/ubuntu-16.10/Dockerfile.jinja2 index 8496b2290..2f16f063e 100644 --- a/docker/nginx/ubuntu-16.10/Dockerfile.jinja2 +++ b/docker/nginx/ubuntu-16.10/Dockerfile.jinja2 @@ -1,7 +1,5 @@ {{ docker.from("base", "ubuntu-16.10") }} -{{ docker.version() }} - {{ environment.web() }} {{ docker.copy('conf/', '/opt/docker/') }} diff --git a/docker/nginx/ubuntu-16.10/conf/bin/service.d/nginx.d/10-init.sh b/docker/nginx/ubuntu-16.10/conf/bin/service.d/nginx.d/10-init.sh index 75a84a4eb..27b9776cc 100644 --- a/docker/nginx/ubuntu-16.10/conf/bin/service.d/nginx.d/10-init.sh +++ b/docker/nginx/ubuntu-16.10/conf/bin/service.d/nginx.d/10-init.sh @@ -8,15 +8,17 @@ fi ln -f -s /var/lib/nginx/logs /var/log/nginx # Replace markers -find /opt/docker/etc/nginx/ -iname '*.conf' -print0 | xargs -0 -r rpl --quiet "" "$WEB_DOCUMENT_INDEX" > /dev/null -find /opt/docker/etc/nginx/ -iname '*.conf' -print0 | xargs -0 -r rpl --quiet "" "$WEB_DOCUMENT_ROOT" > /dev/null -find /opt/docker/etc/nginx/ -iname '*.conf' -print0 | xargs -0 -r rpl --quiet "" "$WEB_ALIAS_DOMAIN" > /dev/null -find /opt/docker/etc/nginx/ -iname '*.conf' -print0 | xargs -0 -r rpl --quiet "" "$HOSTNAME" > /dev/null +go-replace \ + -s "" -r "$WEB_DOCUMENT_INDEX" \ + -s "" -r "$WEB_DOCUMENT_ROOT" \ + -s "" -r "$WEB_ALIAS_DOMAIN" \ + -s "" -r "$HOSTNAME" \ + -s "" -r "$WEB_PHP_SOCKET" \ + --path=/opt/docker/etc/nginx/ \ + --path-pattern='*.conf' \ + --ignore-empty -if [[ -n "${WEB_PHP_SOCKET+x}" ]]; then - ## WEB_PHP_SOCKET is set - find /opt/docker/etc/nginx/ -iname '*.conf' -print0 | xargs -0 -r rpl --quiet "" "$WEB_PHP_SOCKET" > /dev/null -else +if [[ -z "${WEB_PHP_SOCKET+x}" ]]; then ## WEB_PHP_SOCKET is not set, remove PHP files rm -f -- /opt/docker/etc/nginx/conf.d/10-php.conf rm -f -- /opt/docker/etc/nginx/vhost.common.d/10-php.conf diff --git a/docker/nginx/ubuntu-16.10/conf/etc/nginx/vhost.common.d/10-general.conf b/docker/nginx/ubuntu-16.10/conf/etc/nginx/vhost.common.d/10-general.conf new file mode 100644 index 000000000..d3fd0aa5e --- /dev/null +++ b/docker/nginx/ubuntu-16.10/conf/etc/nginx/vhost.common.d/10-general.conf @@ -0,0 +1 @@ +client_max_body_size 50m; diff --git a/docker/nginx/ubuntu-16.10/conf/etc/nginx/vhost.common.d/10-log.conf b/docker/nginx/ubuntu-16.10/conf/etc/nginx/vhost.common.d/10-log.conf new file mode 100644 index 000000000..9646c6826 --- /dev/null +++ b/docker/nginx/ubuntu-16.10/conf/etc/nginx/vhost.common.d/10-log.conf @@ -0,0 +1,2 @@ +access_log /docker.stdout; +error_log /docker.stderr warn; diff --git a/docker/nginx/ubuntu-16.10/conf/etc/nginx/vhost.conf b/docker/nginx/ubuntu-16.10/conf/etc/nginx/vhost.conf index d07e27094..8225f314a 100644 --- a/docker/nginx/ubuntu-16.10/conf/etc/nginx/vhost.conf +++ b/docker/nginx/ubuntu-16.10/conf/etc/nginx/vhost.conf @@ -1,17 +1,11 @@ server { - listen 80 default_server; - listen 8000 default_server; + listen 80 default_server; server_name _ docker; - access_log /docker.stdout; - error_log /docker.stdout info; - root ""; index ; - client_max_body_size 50m; - include /opt/docker/etc/nginx/vhost.common.d/*.conf; } @@ -20,19 +14,13 @@ server { ############## server { - listen 443 default_server; - listen 8443 default_server; + listen 443 default_server; server_name _ docker; - access_log /docker.stdout; - error_log /docker.stdout info; - root ""; index ; - client_max_body_size 50m; - include /opt/docker/etc/nginx/vhost.common.d/*.conf; include /opt/docker/etc/nginx/vhost.ssl.conf; } diff --git a/docker/php-apache-dev/5.6/Dockerfile b/docker/php-apache-dev/5.6/Dockerfile new file mode 100644 index 000000000..453876d7e --- /dev/null +++ b/docker/php-apache-dev/5.6/Dockerfile @@ -0,0 +1,30 @@ +#+++++++++++++++++++++++++++++++++++++++ +# Dockerfile for webdevops/php-apache-dev:5.6 +# -- automatically generated -- +#+++++++++++++++++++++++++++++++++++++++ + +FROM webdevops/php-dev:5.6 + +ENV WEB_DOCUMENT_ROOT=/app \ + WEB_DOCUMENT_INDEX=index.php \ + WEB_ALIAS_DOMAIN=*.vm +ENV WEB_PHP_SOCKET=127.0.0.1:9000 +ENV WEB_NO_CACHE_PATTERN="\.(css|js|gif|png|jpg|svg|json|xml)$" + +COPY conf/ /opt/docker/ + +# Install apache +RUN /usr/local/bin/apt-install \ + apache2 \ + apache2-mpm-worker \ + && sed -ri ' \ + s!^(\s*CustomLog)\s+\S+!\1 /proc/self/fd/1!g; \ + s!^(\s*ErrorLog)\s+\S+!\1 /proc/self/fd/2!g; \ + ' /etc/apache2/apache2.conf \ + && rm -f /etc/apache2/sites-enabled/* \ + && a2enmod actions proxy proxy_fcgi ssl rewrite headers expires \ + && /opt/docker/bin/provision run --tag bootstrap --role webdevops-apache --role webdevops-php-apache --role webdevops-apache-dev --role webdevops-php-dev \ + && /opt/docker/bin/bootstrap.sh \ + && docker-image-cleanup + +EXPOSE 80 443 diff --git a/docker/php-apache-dev/5.6/Dockerfile.jinja2 b/docker/php-apache-dev/5.6/Dockerfile.jinja2 new file mode 100644 index 000000000..238ad3a06 --- /dev/null +++ b/docker/php-apache-dev/5.6/Dockerfile.jinja2 @@ -0,0 +1,11 @@ +{{ docker.from("php-dev", "5.6") }} + +{{ environment.web() }} +{{ environment.webPhp() }} +{{ environment.webDevelopment() }} + +{{ docker.copy('conf/', '/opt/docker/') }} + +{{ apache.debian8('php-apache apache-dev php-dev') }} + +{{ docker.expose('80 443') }} diff --git a/docker/php-apache-dev/alpine-3-php7/conf/bin/service.d/blackfire-agent.d/10-init.sh b/docker/php-apache-dev/5.6/conf/bin/service.d/blackfire-agent.d/10-init.sh similarity index 100% rename from docker/php-apache-dev/alpine-3-php7/conf/bin/service.d/blackfire-agent.d/10-init.sh rename to docker/php-apache-dev/5.6/conf/bin/service.d/blackfire-agent.d/10-init.sh diff --git a/docker/php-apache-dev/alpine-3-php7/conf/bin/service.d/blackfire-agent.sh b/docker/php-apache-dev/5.6/conf/bin/service.d/blackfire-agent.sh similarity index 100% rename from docker/php-apache-dev/alpine-3-php7/conf/bin/service.d/blackfire-agent.sh rename to docker/php-apache-dev/5.6/conf/bin/service.d/blackfire-agent.sh diff --git a/docker/php-apache-dev/5.6/conf/bin/service.d/httpd.d/10-init.sh b/docker/php-apache-dev/5.6/conf/bin/service.d/httpd.d/10-init.sh new file mode 100644 index 000000000..b9d57997e --- /dev/null +++ b/docker/php-apache-dev/5.6/conf/bin/service.d/httpd.d/10-init.sh @@ -0,0 +1,21 @@ +if [[ ! -e "$WEB_DOCUMENT_ROOT" ]]; then + echo "" + echo "[WARNING] WEB_DOCUMENT_ROOT does not exists with path \"$WEB_DOCUMENT_ROOT\"!" + echo "" +fi + +# Replace markers +go-replace \ + -s "" -r "$WEB_DOCUMENT_INDEX" \ + -s "" -r "$WEB_DOCUMENT_ROOT" \ + -s "" -r "$WEB_ALIAS_DOMAIN" \ + -s "" -r "$HOSTNAME" \ + -s "" -r "$WEB_PHP_SOCKET" \ + --path=/opt/docker/etc/httpd/ \ + --path-pattern='*.conf' \ + --ignore-empty + +if [[ -z "${WEB_PHP_SOCKET+x}" ]]; then + ## WEB_PHP_SOCKET is not set, remove PHP files + rm -f -- /opt/docker/etc/httpd/conf.d/10-php.conf +fi diff --git a/docker/php-apache-dev/5.6/conf/bin/service.d/httpd.d/12-development.sh b/docker/php-apache-dev/5.6/conf/bin/service.d/httpd.d/12-development.sh new file mode 100644 index 000000000..a9d2c6e92 --- /dev/null +++ b/docker/php-apache-dev/5.6/conf/bin/service.d/httpd.d/12-development.sh @@ -0,0 +1,5 @@ +go-replace \ + -s "" -r "$WEB_NO_CACHE_PATTERN" \ + --path=/opt/docker/etc/httpd/ \ + --path-pattern='*.conf' \ + --ignore-empty diff --git a/docker/php-apache-dev/5.6/conf/bin/service.d/httpd.sh b/docker/php-apache-dev/5.6/conf/bin/service.d/httpd.sh new file mode 100644 index 000000000..03eec305a --- /dev/null +++ b/docker/php-apache-dev/5.6/conf/bin/service.d/httpd.sh @@ -0,0 +1,12 @@ +#!/usr/bin/env bash +set -e + +source /opt/docker/bin/config.sh + +includeScriptDir "/opt/docker/bin/service.d/httpd.d/" + +# Apache gets grumpy about PID files pre-existing +rm -f /var/run/apache2/apache2*.pid + +source /etc/apache2/envvars +exec apache2 -DFOREGROUND -DAPACHE_LOCK_DIR diff --git a/docker/php-apache-dev/5.6/conf/etc/httpd/conf.d/.gitkeep b/docker/php-apache-dev/5.6/conf/etc/httpd/conf.d/.gitkeep new file mode 100644 index 000000000..e69de29bb diff --git a/docker/php-apache-dev/alpine-3-php7/conf/etc/httpd/conf.d/02-dev.conf b/docker/php-apache-dev/5.6/conf/etc/httpd/conf.d/02-dev.conf similarity index 100% rename from docker/php-apache-dev/alpine-3-php7/conf/etc/httpd/conf.d/02-dev.conf rename to docker/php-apache-dev/5.6/conf/etc/httpd/conf.d/02-dev.conf diff --git a/docker/php-apache-dev/alpine-3-php7/conf/etc/httpd/conf.d/10-error-document.conf b/docker/php-apache-dev/5.6/conf/etc/httpd/conf.d/10-error-document.conf similarity index 100% rename from docker/php-apache-dev/alpine-3-php7/conf/etc/httpd/conf.d/10-error-document.conf rename to docker/php-apache-dev/5.6/conf/etc/httpd/conf.d/10-error-document.conf diff --git a/docker/php-apache-dev/5.6/conf/etc/httpd/conf.d/10-log.conf b/docker/php-apache-dev/5.6/conf/etc/httpd/conf.d/10-log.conf new file mode 100644 index 000000000..ef0c73d38 --- /dev/null +++ b/docker/php-apache-dev/5.6/conf/etc/httpd/conf.d/10-log.conf @@ -0,0 +1,4 @@ +LogFormat "[httpd:access] %V:%p %h %l %u %t \"%r\" %>s bytesIn:%I bytesOut:%O reqTime:%T" dockerlog +LogLevel warn +CustomLog /docker.stdout dockerlog +ErrorLog /docker.stderr diff --git a/docker/php-apache-dev/alpine-3-php7/conf/etc/httpd/conf.d/10-php.conf b/docker/php-apache-dev/5.6/conf/etc/httpd/conf.d/10-php.conf similarity index 100% rename from docker/php-apache-dev/alpine-3-php7/conf/etc/httpd/conf.d/10-php.conf rename to docker/php-apache-dev/5.6/conf/etc/httpd/conf.d/10-php.conf diff --git a/docker/php-apache-dev/alpine-3-php7/conf/etc/httpd/conf.d/10-server.conf b/docker/php-apache-dev/5.6/conf/etc/httpd/conf.d/10-server.conf similarity index 100% rename from docker/php-apache-dev/alpine-3-php7/conf/etc/httpd/conf.d/10-server.conf rename to docker/php-apache-dev/5.6/conf/etc/httpd/conf.d/10-server.conf diff --git a/docker/php-apache-dev/alpine-3-php7/conf/etc/httpd/global.conf b/docker/php-apache-dev/5.6/conf/etc/httpd/global.conf similarity index 100% rename from docker/php-apache-dev/alpine-3-php7/conf/etc/httpd/global.conf rename to docker/php-apache-dev/5.6/conf/etc/httpd/global.conf diff --git a/docker/php-apache-dev/alpine-3-php7/conf/etc/httpd/main.conf b/docker/php-apache-dev/5.6/conf/etc/httpd/main.conf similarity index 100% rename from docker/php-apache-dev/alpine-3-php7/conf/etc/httpd/main.conf rename to docker/php-apache-dev/5.6/conf/etc/httpd/main.conf diff --git a/docker/php-apache-dev/alpine-3-php7/conf/etc/httpd/php.conf b/docker/php-apache-dev/5.6/conf/etc/httpd/php.conf similarity index 100% rename from docker/php-apache-dev/alpine-3-php7/conf/etc/httpd/php.conf rename to docker/php-apache-dev/5.6/conf/etc/httpd/php.conf diff --git a/docker/php-apache-dev/alpine-3-php7/conf/etc/httpd/ssl/server.crt b/docker/php-apache-dev/5.6/conf/etc/httpd/ssl/server.crt similarity index 100% rename from docker/php-apache-dev/alpine-3-php7/conf/etc/httpd/ssl/server.crt rename to docker/php-apache-dev/5.6/conf/etc/httpd/ssl/server.crt diff --git a/docker/php-apache-dev/alpine-3-php7/conf/etc/httpd/ssl/server.csr b/docker/php-apache-dev/5.6/conf/etc/httpd/ssl/server.csr similarity index 100% rename from docker/php-apache-dev/alpine-3-php7/conf/etc/httpd/ssl/server.csr rename to docker/php-apache-dev/5.6/conf/etc/httpd/ssl/server.csr diff --git a/docker/php-apache-dev/alpine-3-php7/conf/etc/httpd/ssl/server.key b/docker/php-apache-dev/5.6/conf/etc/httpd/ssl/server.key similarity index 100% rename from docker/php-apache-dev/alpine-3-php7/conf/etc/httpd/ssl/server.key rename to docker/php-apache-dev/5.6/conf/etc/httpd/ssl/server.key diff --git a/docker/php-apache-dev/alpine-3-php7/conf/etc/httpd/vhost.common.conf b/docker/php-apache-dev/5.6/conf/etc/httpd/vhost.common.conf similarity index 100% rename from docker/php-apache-dev/alpine-3-php7/conf/etc/httpd/vhost.common.conf rename to docker/php-apache-dev/5.6/conf/etc/httpd/vhost.common.conf diff --git a/docker/php-apache-dev/5.6/conf/etc/httpd/vhost.common.d/.gitkeep b/docker/php-apache-dev/5.6/conf/etc/httpd/vhost.common.d/.gitkeep new file mode 100644 index 000000000..e69de29bb diff --git a/docker/php-apache-dev/alpine-3-php7/conf/etc/httpd/vhost.common.d/01-boilerplate.conf b/docker/php-apache-dev/5.6/conf/etc/httpd/vhost.common.d/01-boilerplate.conf similarity index 100% rename from docker/php-apache-dev/alpine-3-php7/conf/etc/httpd/vhost.common.d/01-boilerplate.conf rename to docker/php-apache-dev/5.6/conf/etc/httpd/vhost.common.d/01-boilerplate.conf diff --git a/docker/php-apache-dev/alpine-3-php7/conf/etc/httpd/vhost.common.d/02-dev.conf b/docker/php-apache-dev/5.6/conf/etc/httpd/vhost.common.d/02-dev.conf similarity index 100% rename from docker/php-apache-dev/alpine-3-php7/conf/etc/httpd/vhost.common.d/02-dev.conf rename to docker/php-apache-dev/5.6/conf/etc/httpd/vhost.common.d/02-dev.conf diff --git a/docker/php-apache-dev/alpine-3-php7/conf/etc/httpd/vhost.conf b/docker/php-apache-dev/5.6/conf/etc/httpd/vhost.conf similarity index 100% rename from docker/php-apache-dev/alpine-3-php7/conf/etc/httpd/vhost.conf rename to docker/php-apache-dev/5.6/conf/etc/httpd/vhost.conf diff --git a/docker/php-apache-dev/alpine-3-php7/conf/etc/httpd/vhost.ssl.conf b/docker/php-apache-dev/5.6/conf/etc/httpd/vhost.ssl.conf similarity index 100% rename from docker/php-apache-dev/alpine-3-php7/conf/etc/httpd/vhost.ssl.conf rename to docker/php-apache-dev/5.6/conf/etc/httpd/vhost.ssl.conf diff --git a/docker/php-apache-dev/alpine-3-php7/conf/etc/supervisor.d/apache.conf b/docker/php-apache-dev/5.6/conf/etc/supervisor.d/apache.conf similarity index 100% rename from docker/php-apache-dev/alpine-3-php7/conf/etc/supervisor.d/apache.conf rename to docker/php-apache-dev/5.6/conf/etc/supervisor.d/apache.conf diff --git a/docker/php-apache-dev/alpine-3-php7/conf/etc/supervisor.d/blackfire-agent.conf b/docker/php-apache-dev/5.6/conf/etc/supervisor.d/blackfire-agent.conf similarity index 100% rename from docker/php-apache-dev/alpine-3-php7/conf/etc/supervisor.d/blackfire-agent.conf rename to docker/php-apache-dev/5.6/conf/etc/supervisor.d/blackfire-agent.conf diff --git a/docker/php-apache-dev/5.6/conf/provision/entrypoint.d/10-php-debugger.sh b/docker/php-apache-dev/5.6/conf/provision/entrypoint.d/10-php-debugger.sh new file mode 100644 index 000000000..b5985a9ef --- /dev/null +++ b/docker/php-apache-dev/5.6/conf/provision/entrypoint.d/10-php-debugger.sh @@ -0,0 +1,96 @@ +#!/usr/bin/env bash + +################################################# +# Debugger switch +################################################# + +PHP_CONF_PATHS=" +/etc/php5/conf.d +/etc/php7/conf.d +/etc/php.d +/etc/php5/mods-available +/etc/php5/cli/conf.d +/etc/php5/cli/conf.d +/etc/php5/fpm/conf.d +/etc/php5/fpm/conf.d +/etc/php/7.0/mods-available +/etc/php/7.0/cli/conf.d +/etc/php/7.0/fpm/conf.d +/usr/local/etc/php/conf.d/" + +function phpModuleRemove() { + if [ "$#" -ne 1 ]; then + echo "You must specify the name of the PHP module which you want to disable" + exit 1 + fi + + echo " - Removing PHP module ${1}" + for CONF_PATH in $PHP_CONF_PATHS; do + rm -f "${CONF_PATH}"/*"${1}".ini + done +} + + +if [[ -n "${PHP_DEBUGGER+x}" ]]; then + case "$PHP_DEBUGGER" in + xdebug) + echo "PHP-Debugger: Xdebug enabled" + phpModuleRemove "blackfire" + ;; + + blackfire) + echo "PHP-Debugger: Blackfire enabled" + phpModuleRemove "xdebug" + docker-service-enable blackfire-agent + ;; + + none) + echo "PHP-Debugger: none" + phpModuleRemove "blackfire" + phpModuleRemove "xdebug" + ;; + esac + +else + + echo "PHP-Debugger: not specified - default is xdebug" + phpModuleRemove "blackfire" + +fi + +################################################# +# PHP debugger environment variables +################################################# + +function phpEnvironmentVariable() { + PHP_INI_KEY="$1" + PHP_ENV_NAME="$2" + + if [[ -n "${!PHP_ENV_NAME+x}" ]]; then + PHP_ENV_VALUE="${!PHP_ENV_NAME}" + echo "${PHP_INI_KEY}=\"${PHP_ENV_VALUE}\"" >> /opt/docker/etc/php/php.ini + fi +} + +################### +# XDEBUG +################### + +# remote debugger +phpEnvironmentVariable "xdebug.remote_connect_back" "XDEBUG_REMOTE_CONNECT_BACK" +phpEnvironmentVariable "xdebug.remote_autostart" "XDEBUG_REMOTE_AUTOSTART" +phpEnvironmentVariable "xdebug.remote_host" "XDEBUG_REMOTE_HOST" +phpEnvironmentVariable "xdebug.remote_port" "XDEBUG_REMOTE_PORT" + +# profiler +phpEnvironmentVariable "xdebug.profiler_enable" "XDEBUG_PROFILER_ENABLE" +phpEnvironmentVariable "xdebug.profiler_enable_trigger" "XDEBUG_PROFILER_ENABLE_TRIGGER" +phpEnvironmentVariable "xdebug.profiler_enable_trigger_value" "XDEBUG_PROFILER_ENABLE_TRIGGER_VALUE" +phpEnvironmentVariable "xdebug.profiler_output_dir" "XDEBUG_PROFILER_OUTPUT_DIR" +phpEnvironmentVariable "xdebug.profiler_output_name" "XDEBUG_PROFILER_OUTPUT_NAME" + +################### +# BLACKFIRE +################### +phpEnvironmentVariable "blackfire.server_id" "BLACKFIRE_SERVER_ID" +phpEnvironmentVariable "blackfire.server_token" "BLACKFIRE_SERVER_TOKEN" diff --git a/docker/php-apache-dev/alpine-3-php7/conf/provision/roles/webdevops-apache-dev/defaults/main.yml b/docker/php-apache-dev/5.6/conf/provision/roles/webdevops-apache-dev/defaults/main.yml similarity index 100% rename from docker/php-apache-dev/alpine-3-php7/conf/provision/roles/webdevops-apache-dev/defaults/main.yml rename to docker/php-apache-dev/5.6/conf/provision/roles/webdevops-apache-dev/defaults/main.yml diff --git a/docker/php-apache-dev/alpine-3-php7/conf/provision/roles/webdevops-apache-dev/tasks/bootstrap.yml b/docker/php-apache-dev/5.6/conf/provision/roles/webdevops-apache-dev/tasks/bootstrap.yml similarity index 100% rename from docker/php-apache-dev/alpine-3-php7/conf/provision/roles/webdevops-apache-dev/tasks/bootstrap.yml rename to docker/php-apache-dev/5.6/conf/provision/roles/webdevops-apache-dev/tasks/bootstrap.yml diff --git a/docker/php-apache-dev/alpine-3-php7/conf/provision/roles/webdevops-apache-dev/tasks/main.yml b/docker/php-apache-dev/5.6/conf/provision/roles/webdevops-apache-dev/tasks/main.yml similarity index 100% rename from docker/php-apache-dev/alpine-3-php7/conf/provision/roles/webdevops-apache-dev/tasks/main.yml rename to docker/php-apache-dev/5.6/conf/provision/roles/webdevops-apache-dev/tasks/main.yml diff --git a/docker/php-apache-dev/alpine-3-php7/conf/provision/roles/webdevops-apache/defaults/main.yml b/docker/php-apache-dev/5.6/conf/provision/roles/webdevops-apache/defaults/main.yml similarity index 100% rename from docker/php-apache-dev/alpine-3-php7/conf/provision/roles/webdevops-apache/defaults/main.yml rename to docker/php-apache-dev/5.6/conf/provision/roles/webdevops-apache/defaults/main.yml diff --git a/docker/php-apache-dev/5.6/conf/provision/roles/webdevops-apache/tasks/bootstrap.yml b/docker/php-apache-dev/5.6/conf/provision/roles/webdevops-apache/tasks/bootstrap.yml new file mode 100644 index 000000000..c285be286 --- /dev/null +++ b/docker/php-apache-dev/5.6/conf/provision/roles/webdevops-apache/tasks/bootstrap.yml @@ -0,0 +1,156 @@ +--- + +- name: Set apache vhost file [RedHat family] + set_fact: + apache_main_path: /etc/httpd/ + apache_docker_vhost: /etc/httpd/conf.d/zzz-docker.conf + when: ansible_os_family == 'RedHat' + +- name: Set apache vhost file [Debian family] + set_fact: + apache_main_path: /etc/apache2/ + apache_docker_vhost: /etc/apache2/sites-enabled/10-docker.conf + when: ansible_os_family == 'Debian' + +- name: Set apache vhost file [Alpine family] + set_fact: + apache_main_path: /etc/apache2/ + apache_docker_vhost: /etc/apache2/conf.d/zzz-docker.conf + when: ansible_os_family == 'Alpine' + +- name: Enable apache main config + file: + src: '/opt/docker/etc/httpd/main.conf' + dest: '{{ apache_docker_vhost }}' + state: link + force: yes + +- name: Ensure document root is available + file: + path: "{{ DOCUMENT_ROOT }}" + state: directory + recurse: yes + +- name: Ensure /var/run/apache2 exists + file: + path: '/var/run/apache2' + state: directory + recurse: yes + +- name: Ensure /run/apache2 exists + file: + path: '/run/apache2' + state: directory + recurse: yes + when: ansible_os_family == 'Alpine' + +- name: Find apache2 files + shell: "find '{{ apache_main_path }}' -type f -iname '*.conf' -o -iname 'default*' -o -iname '*log'" + register: apache2_conf_files + +- name: Change CustomLog to Docker stdout + replace: + dest: '{{ item }}' + regexp: '^[\s]*CustomLog ([^\s]+)(.*)' + replace: 'CustomLog /docker.stdout \2' + with_items: "{{ apache2_conf_files.stdout_lines }}" + +- name: Change CustomLog to Docker stdout + replace: + dest: '{{ item }}' + regexp: '^[\s]*ErrorLog ([^\s]+)(.*)' + replace: 'ErrorLog /docker.stdout \2' + with_items: "{{ apache2_conf_files.stdout_lines }}" + +- name: Change TransferLog to Docker stdout + replace: + dest: '{{ item }}' + regexp: '^[\s]*TransferLog ([^\s]+)(.*)' + replace: 'TransferLog /docker.stdout \2' + with_items: "{{ apache2_conf_files.stdout_lines }}" + +- name: Switch MPM to worker [RedHat family] + lineinfile: + dest: '/etc/httpd/conf.modules.d/00-mpm.conf' + regexp: '^[\s#]*{{ item.line }}' + line: '{{ item.prefix }}{{ item.line }}' + with_items: + - { line: 'LoadModule mpm_prefork_module modules/mod_mpm_prefork.so', prefix: "#" } + - { line: 'LoadModule mpm_event_module modules/mod_mpm_event.so', prefix: "" } + when: ansible_os_family == 'RedHat' + +- name: Switch MPM to event for Apache 2.4 and higher [Ubuntu family] + command: "{{ item }}" + with_items: + - 'a2dismod mpm_event' + - 'a2enmod mpm_event' + when: (ansible_distribution == 'Ubuntu' and docker_image_info_distribution_version|int >= 14) or (ansible_distribution == 'Debian' and docker_image_info_distribution_version|int >= 8) + +- name: Manage modules [Alpine family] + lineinfile: + dest: '/etc/apache2/httpd.conf' + regexp: '^[\s#]*{{ item.line }}' + line: '{{ item.prefix }}{{ item.line }}' + with_items: + - { line: 'LoadModule mpm_prefork_module modules/mod_mpm_prefork.so', prefix: "#" } + - { line: 'LoadModule mpm_event_module modules/mod_mpm_event.so', prefix: "" } + - { line: 'LoadModule deflate_module modules/mod_deflate.so', prefix: "" } + - { line: 'LoadModule rewrite_module modules/mod_rewrite.so', prefix: "" } + - { line: 'LoadModule logio_module modules/mod_logio.so', prefix: "" } + - { line: 'LoadModule slotmem_shm_module modules/mod_slotmem_shm.so', prefix: "" } + - { line: 'LoadModule actions_module modules/mod_actions.so', prefix: "" } + - { line: 'LoadModule expires_module modules/mod_expires.so', prefix: "" } + when: ansible_os_family == 'Alpine' + +- name: Fix ssl support [Alpine family] + lineinfile: + dest: '/etc/apache2/conf.d/ssl.conf' + regexp: '{{ item.regexp }}' + line: '{{ item.line }}' + with_items: + - { regexp: 'LoadModule ssl_module', line: 'LoadModule ssl_module /usr/lib/apache2/mod_ssl.so' } + - { regexp: 'LoadModule socache_shmcb_module', line: 'LoadModule socache_shmcb_module /usr/lib/apache2/mod_socache_shmcb.so' } + when: ansible_os_family == 'Alpine' + +- name: Remove default vhost from ssl configuration [Alpine family] + command: sed -i -e '1h;2,$H;$!d;g' -e 's//#-> removed vhost/g' /etc/apache2/conf.d/ssl.conf + when: ansible_os_family == 'Alpine' + +- name: Disable proxy [Alpine family] + lineinfile: + dest: '/etc/apache2/conf.d/proxy.conf' + regexp: '^[\s#]*{{ item.line }}' + line: '{{ item.prefix }}{{ item.line }}' + with_items: + - { line: 'LoadModule proxy_ajp_module modules/mod_proxy_ajp.so', prefix: "#" } + - { line: 'LoadModule proxy_connect_module modules/mod_proxy_connect.so', prefix: "#" } + - { line: 'LoadModule proxy_balancer_module modules/mod_proxy_balancer.so', prefix: "#" } + - { line: 'LoadModule proxy_express_module modules/mod_proxy_express.so', prefix: "#" } + - { line: 'LoadModule proxy_fcgi_module modules/mod_proxy_fcgi.so', prefix: "" } + - { line: 'LoadModule proxy_fdpass_module modules/mod_proxy_fdpass.so', prefix: "#" } + - { line: 'LoadModule proxy_ftp_module modules/mod_proxy_ftp.so', prefix: "#" } + - { line: 'LoadModule proxy_http_module modules/mod_proxy_http.so', prefix: "#" } + - { line: 'LoadModule proxy_scgi_module modules/mod_proxy_scgi.so', prefix: "#" } + when: ansible_os_family == 'Alpine' + +- name: Fix rights of ssl files + file: + path: "{{ item.path }}" + state: "{{ item.state }}" + mode: "{{ item.mode }}" + owner: "root" + group: "root" + with_items: + - { path: '/opt/docker/etc/httpd/ssl', state: 'directory', mode: '0750' } + - { path: '/opt/docker/etc/httpd/ssl/server.crt', state: 'file', mode: '0640' } + - { path: '/opt/docker/etc/httpd/ssl/server.csr', state: 'file', mode: '0640' } + - { path: '/opt/docker/etc/httpd/ssl/server.key', state: 'file', mode: '0640' } + +- name: Maintain lock directory [Debian family] + file: + path: "/var/lock/apache2" + state: "directory" + mode: "0750" + owner: "www-data" + group: "www-data" + when: ansible_os_family == 'Debian' diff --git a/docker/php-apache-dev/alpine-3-php7/conf/provision/roles/webdevops-apache/tasks/main.yml b/docker/php-apache-dev/5.6/conf/provision/roles/webdevops-apache/tasks/main.yml similarity index 100% rename from docker/php-apache-dev/alpine-3-php7/conf/provision/roles/webdevops-apache/tasks/main.yml rename to docker/php-apache-dev/5.6/conf/provision/roles/webdevops-apache/tasks/main.yml diff --git a/docker/php-apache-dev/alpine-3-php7/conf/provision/roles/webdevops-php-apache/defaults/main.yml b/docker/php-apache-dev/5.6/conf/provision/roles/webdevops-php-apache/defaults/main.yml similarity index 100% rename from docker/php-apache-dev/alpine-3-php7/conf/provision/roles/webdevops-php-apache/defaults/main.yml rename to docker/php-apache-dev/5.6/conf/provision/roles/webdevops-php-apache/defaults/main.yml diff --git a/docker/php-apache-dev/alpine-3-php7/conf/provision/roles/webdevops-php-apache/tasks/bootstrap.yml b/docker/php-apache-dev/5.6/conf/provision/roles/webdevops-php-apache/tasks/bootstrap.yml similarity index 100% rename from docker/php-apache-dev/alpine-3-php7/conf/provision/roles/webdevops-php-apache/tasks/bootstrap.yml rename to docker/php-apache-dev/5.6/conf/provision/roles/webdevops-php-apache/tasks/bootstrap.yml diff --git a/docker/php-apache-dev/alpine-3-php7/conf/provision/roles/webdevops-php-apache/tasks/entrypoint.yml b/docker/php-apache-dev/5.6/conf/provision/roles/webdevops-php-apache/tasks/entrypoint.yml similarity index 100% rename from docker/php-apache-dev/alpine-3-php7/conf/provision/roles/webdevops-php-apache/tasks/entrypoint.yml rename to docker/php-apache-dev/5.6/conf/provision/roles/webdevops-php-apache/tasks/entrypoint.yml diff --git a/docker/php-apache-dev/alpine-3-php7/conf/provision/roles/webdevops-php-apache/tasks/main.yml b/docker/php-apache-dev/5.6/conf/provision/roles/webdevops-php-apache/tasks/main.yml similarity index 100% rename from docker/php-apache-dev/alpine-3-php7/conf/provision/roles/webdevops-php-apache/tasks/main.yml rename to docker/php-apache-dev/5.6/conf/provision/roles/webdevops-php-apache/tasks/main.yml diff --git a/docker/php-apache-dev/alpine-3-php7/conf/provision/roles/webdevops-php-dev/defaults/main.yml b/docker/php-apache-dev/5.6/conf/provision/roles/webdevops-php-dev/defaults/main.yml similarity index 100% rename from docker/php-apache-dev/alpine-3-php7/conf/provision/roles/webdevops-php-dev/defaults/main.yml rename to docker/php-apache-dev/5.6/conf/provision/roles/webdevops-php-dev/defaults/main.yml diff --git a/docker/php-apache-dev/5.6/conf/provision/roles/webdevops-php-dev/tasks/bootstrap.yml b/docker/php-apache-dev/5.6/conf/provision/roles/webdevops-php-dev/tasks/bootstrap.yml new file mode 100644 index 000000000..ff02b05fc --- /dev/null +++ b/docker/php-apache-dev/5.6/conf/provision/roles/webdevops-php-dev/tasks/bootstrap.yml @@ -0,0 +1,7 @@ +--- + +- include: bootstrap/php-fpm.yml +- include: bootstrap/php-module.yml +- include: bootstrap/php-module.opcache.yml +- include: bootstrap/php-module.xdebug.yml +- include: bootstrap/php-module.blackfire.yml diff --git a/docker/php-apache-dev/alpine-3-php7/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/php-fpm.yml b/docker/php-apache-dev/5.6/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/php-fpm.yml similarity index 100% rename from docker/php-apache-dev/alpine-3-php7/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/php-fpm.yml rename to docker/php-apache-dev/5.6/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/php-fpm.yml diff --git a/docker/php-apache-dev/5.6/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/php-module.blackfire.yml b/docker/php-apache-dev/5.6/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/php-module.blackfire.yml new file mode 100644 index 000000000..faf05f8de --- /dev/null +++ b/docker/php-apache-dev/5.6/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/php-module.blackfire.yml @@ -0,0 +1,10 @@ +--- + +- name: Remove superfluous blackfire configuration file + file: + path: '{{ item }}' + state: absent + with_items: + - /etc/php5/cli/conf.d/zz-blackfire.ini + - /etc/php5/fpm/conf.d/zz-blackfire.ini + when: ansible_distribution == 'Debian' and docker_image_info_distribution_version|int >= 7 diff --git a/docker/php-apache-dev/alpine-3-php7/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/php-module.opcache.yml b/docker/php-apache-dev/5.6/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/php-module.opcache.yml similarity index 100% rename from docker/php-apache-dev/alpine-3-php7/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/php-module.opcache.yml rename to docker/php-apache-dev/5.6/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/php-module.opcache.yml diff --git a/docker/php-apache-dev/alpine-3-php7/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/php-module.xdebug.yml b/docker/php-apache-dev/5.6/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/php-module.xdebug.yml similarity index 100% rename from docker/php-apache-dev/alpine-3-php7/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/php-module.xdebug.yml rename to docker/php-apache-dev/5.6/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/php-module.xdebug.yml diff --git a/docker/php-apache-dev/alpine-3-php7/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/php-module.yml b/docker/php-apache-dev/5.6/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/php-module.yml similarity index 100% rename from docker/php-apache-dev/alpine-3-php7/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/php-module.yml rename to docker/php-apache-dev/5.6/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/php-module.yml diff --git a/docker/php-apache-dev/alpine-3-php7/conf/provision/roles/webdevops-php-dev/tasks/main.yml b/docker/php-apache-dev/5.6/conf/provision/roles/webdevops-php-dev/tasks/main.yml similarity index 100% rename from docker/php-apache-dev/alpine-3-php7/conf/provision/roles/webdevops-php-dev/tasks/main.yml rename to docker/php-apache-dev/5.6/conf/provision/roles/webdevops-php-dev/tasks/main.yml diff --git a/docker/php-apache-dev/7.0/Dockerfile b/docker/php-apache-dev/7.0/Dockerfile new file mode 100644 index 000000000..1820cbc4f --- /dev/null +++ b/docker/php-apache-dev/7.0/Dockerfile @@ -0,0 +1,30 @@ +#+++++++++++++++++++++++++++++++++++++++ +# Dockerfile for webdevops/php-apache-dev:7.0 +# -- automatically generated -- +#+++++++++++++++++++++++++++++++++++++++ + +FROM webdevops/php-dev:7.0 + +ENV WEB_DOCUMENT_ROOT=/app \ + WEB_DOCUMENT_INDEX=index.php \ + WEB_ALIAS_DOMAIN=*.vm +ENV WEB_PHP_SOCKET=127.0.0.1:9000 +ENV WEB_NO_CACHE_PATTERN="\.(css|js|gif|png|jpg|svg|json|xml)$" + +COPY conf/ /opt/docker/ + +# Install apache +RUN /usr/local/bin/apt-install \ + apache2 \ + apache2-mpm-worker \ + && sed -ri ' \ + s!^(\s*CustomLog)\s+\S+!\1 /proc/self/fd/1!g; \ + s!^(\s*ErrorLog)\s+\S+!\1 /proc/self/fd/2!g; \ + ' /etc/apache2/apache2.conf \ + && rm -f /etc/apache2/sites-enabled/* \ + && a2enmod actions proxy proxy_fcgi ssl rewrite headers expires \ + && /opt/docker/bin/provision run --tag bootstrap --role webdevops-apache --role webdevops-php-apache --role webdevops-apache-dev --role webdevops-php-dev \ + && /opt/docker/bin/bootstrap.sh \ + && docker-image-cleanup + +EXPOSE 80 443 diff --git a/docker/php-apache-dev/7.0/Dockerfile.jinja2 b/docker/php-apache-dev/7.0/Dockerfile.jinja2 new file mode 100644 index 000000000..03f7a444e --- /dev/null +++ b/docker/php-apache-dev/7.0/Dockerfile.jinja2 @@ -0,0 +1,11 @@ +{{ docker.from("php-dev", "7.0") }} + +{{ environment.web() }} +{{ environment.webPhp() }} +{{ environment.webDevelopment() }} + +{{ docker.copy('conf/', '/opt/docker/') }} + +{{ apache.debian8('php-apache apache-dev php-dev') }} + +{{ docker.expose('80 443') }} diff --git a/docker/php-apache-dev/alpine-3/conf/bin/service.d/blackfire-agent.d/10-init.sh b/docker/php-apache-dev/7.0/conf/bin/service.d/blackfire-agent.d/10-init.sh similarity index 100% rename from docker/php-apache-dev/alpine-3/conf/bin/service.d/blackfire-agent.d/10-init.sh rename to docker/php-apache-dev/7.0/conf/bin/service.d/blackfire-agent.d/10-init.sh diff --git a/docker/php-apache-dev/alpine-3/conf/bin/service.d/blackfire-agent.sh b/docker/php-apache-dev/7.0/conf/bin/service.d/blackfire-agent.sh similarity index 100% rename from docker/php-apache-dev/alpine-3/conf/bin/service.d/blackfire-agent.sh rename to docker/php-apache-dev/7.0/conf/bin/service.d/blackfire-agent.sh diff --git a/docker/php-apache-dev/7.0/conf/bin/service.d/httpd.d/10-init.sh b/docker/php-apache-dev/7.0/conf/bin/service.d/httpd.d/10-init.sh new file mode 100644 index 000000000..b9d57997e --- /dev/null +++ b/docker/php-apache-dev/7.0/conf/bin/service.d/httpd.d/10-init.sh @@ -0,0 +1,21 @@ +if [[ ! -e "$WEB_DOCUMENT_ROOT" ]]; then + echo "" + echo "[WARNING] WEB_DOCUMENT_ROOT does not exists with path \"$WEB_DOCUMENT_ROOT\"!" + echo "" +fi + +# Replace markers +go-replace \ + -s "" -r "$WEB_DOCUMENT_INDEX" \ + -s "" -r "$WEB_DOCUMENT_ROOT" \ + -s "" -r "$WEB_ALIAS_DOMAIN" \ + -s "" -r "$HOSTNAME" \ + -s "" -r "$WEB_PHP_SOCKET" \ + --path=/opt/docker/etc/httpd/ \ + --path-pattern='*.conf' \ + --ignore-empty + +if [[ -z "${WEB_PHP_SOCKET+x}" ]]; then + ## WEB_PHP_SOCKET is not set, remove PHP files + rm -f -- /opt/docker/etc/httpd/conf.d/10-php.conf +fi diff --git a/docker/php-apache-dev/7.0/conf/bin/service.d/httpd.d/12-development.sh b/docker/php-apache-dev/7.0/conf/bin/service.d/httpd.d/12-development.sh new file mode 100644 index 000000000..a9d2c6e92 --- /dev/null +++ b/docker/php-apache-dev/7.0/conf/bin/service.d/httpd.d/12-development.sh @@ -0,0 +1,5 @@ +go-replace \ + -s "" -r "$WEB_NO_CACHE_PATTERN" \ + --path=/opt/docker/etc/httpd/ \ + --path-pattern='*.conf' \ + --ignore-empty diff --git a/docker/php-apache-dev/7.0/conf/bin/service.d/httpd.sh b/docker/php-apache-dev/7.0/conf/bin/service.d/httpd.sh new file mode 100644 index 000000000..03eec305a --- /dev/null +++ b/docker/php-apache-dev/7.0/conf/bin/service.d/httpd.sh @@ -0,0 +1,12 @@ +#!/usr/bin/env bash +set -e + +source /opt/docker/bin/config.sh + +includeScriptDir "/opt/docker/bin/service.d/httpd.d/" + +# Apache gets grumpy about PID files pre-existing +rm -f /var/run/apache2/apache2*.pid + +source /etc/apache2/envvars +exec apache2 -DFOREGROUND -DAPACHE_LOCK_DIR diff --git a/docker/php-apache-dev/7.0/conf/etc/httpd/conf.d/.gitkeep b/docker/php-apache-dev/7.0/conf/etc/httpd/conf.d/.gitkeep new file mode 100644 index 000000000..e69de29bb diff --git a/docker/php-apache-dev/alpine-3/conf/etc/httpd/conf.d/02-dev.conf b/docker/php-apache-dev/7.0/conf/etc/httpd/conf.d/02-dev.conf similarity index 100% rename from docker/php-apache-dev/alpine-3/conf/etc/httpd/conf.d/02-dev.conf rename to docker/php-apache-dev/7.0/conf/etc/httpd/conf.d/02-dev.conf diff --git a/docker/php-apache-dev/alpine-3/conf/etc/httpd/conf.d/10-error-document.conf b/docker/php-apache-dev/7.0/conf/etc/httpd/conf.d/10-error-document.conf similarity index 100% rename from docker/php-apache-dev/alpine-3/conf/etc/httpd/conf.d/10-error-document.conf rename to docker/php-apache-dev/7.0/conf/etc/httpd/conf.d/10-error-document.conf diff --git a/docker/php-apache-dev/7.0/conf/etc/httpd/conf.d/10-log.conf b/docker/php-apache-dev/7.0/conf/etc/httpd/conf.d/10-log.conf new file mode 100644 index 000000000..ef0c73d38 --- /dev/null +++ b/docker/php-apache-dev/7.0/conf/etc/httpd/conf.d/10-log.conf @@ -0,0 +1,4 @@ +LogFormat "[httpd:access] %V:%p %h %l %u %t \"%r\" %>s bytesIn:%I bytesOut:%O reqTime:%T" dockerlog +LogLevel warn +CustomLog /docker.stdout dockerlog +ErrorLog /docker.stderr diff --git a/docker/php-apache-dev/alpine-3/conf/etc/httpd/conf.d/10-php.conf b/docker/php-apache-dev/7.0/conf/etc/httpd/conf.d/10-php.conf similarity index 100% rename from docker/php-apache-dev/alpine-3/conf/etc/httpd/conf.d/10-php.conf rename to docker/php-apache-dev/7.0/conf/etc/httpd/conf.d/10-php.conf diff --git a/docker/php-apache-dev/alpine-3/conf/etc/httpd/conf.d/10-server.conf b/docker/php-apache-dev/7.0/conf/etc/httpd/conf.d/10-server.conf similarity index 100% rename from docker/php-apache-dev/alpine-3/conf/etc/httpd/conf.d/10-server.conf rename to docker/php-apache-dev/7.0/conf/etc/httpd/conf.d/10-server.conf diff --git a/docker/php-apache-dev/alpine-3/conf/etc/httpd/global.conf b/docker/php-apache-dev/7.0/conf/etc/httpd/global.conf similarity index 100% rename from docker/php-apache-dev/alpine-3/conf/etc/httpd/global.conf rename to docker/php-apache-dev/7.0/conf/etc/httpd/global.conf diff --git a/docker/php-apache-dev/alpine-3/conf/etc/httpd/main.conf b/docker/php-apache-dev/7.0/conf/etc/httpd/main.conf similarity index 100% rename from docker/php-apache-dev/alpine-3/conf/etc/httpd/main.conf rename to docker/php-apache-dev/7.0/conf/etc/httpd/main.conf diff --git a/docker/php-apache-dev/alpine-3/conf/etc/httpd/php.conf b/docker/php-apache-dev/7.0/conf/etc/httpd/php.conf similarity index 100% rename from docker/php-apache-dev/alpine-3/conf/etc/httpd/php.conf rename to docker/php-apache-dev/7.0/conf/etc/httpd/php.conf diff --git a/docker/php-apache-dev/alpine-3/conf/etc/httpd/ssl/server.crt b/docker/php-apache-dev/7.0/conf/etc/httpd/ssl/server.crt similarity index 100% rename from docker/php-apache-dev/alpine-3/conf/etc/httpd/ssl/server.crt rename to docker/php-apache-dev/7.0/conf/etc/httpd/ssl/server.crt diff --git a/docker/php-apache-dev/alpine-3/conf/etc/httpd/ssl/server.csr b/docker/php-apache-dev/7.0/conf/etc/httpd/ssl/server.csr similarity index 100% rename from docker/php-apache-dev/alpine-3/conf/etc/httpd/ssl/server.csr rename to docker/php-apache-dev/7.0/conf/etc/httpd/ssl/server.csr diff --git a/docker/php-apache-dev/alpine-3/conf/etc/httpd/ssl/server.key b/docker/php-apache-dev/7.0/conf/etc/httpd/ssl/server.key similarity index 100% rename from docker/php-apache-dev/alpine-3/conf/etc/httpd/ssl/server.key rename to docker/php-apache-dev/7.0/conf/etc/httpd/ssl/server.key diff --git a/docker/php-apache-dev/alpine-3/conf/etc/httpd/vhost.common.conf b/docker/php-apache-dev/7.0/conf/etc/httpd/vhost.common.conf similarity index 100% rename from docker/php-apache-dev/alpine-3/conf/etc/httpd/vhost.common.conf rename to docker/php-apache-dev/7.0/conf/etc/httpd/vhost.common.conf diff --git a/docker/php-apache-dev/7.0/conf/etc/httpd/vhost.common.d/.gitkeep b/docker/php-apache-dev/7.0/conf/etc/httpd/vhost.common.d/.gitkeep new file mode 100644 index 000000000..e69de29bb diff --git a/docker/php-apache-dev/alpine-3/conf/etc/httpd/vhost.common.d/01-boilerplate.conf b/docker/php-apache-dev/7.0/conf/etc/httpd/vhost.common.d/01-boilerplate.conf similarity index 100% rename from docker/php-apache-dev/alpine-3/conf/etc/httpd/vhost.common.d/01-boilerplate.conf rename to docker/php-apache-dev/7.0/conf/etc/httpd/vhost.common.d/01-boilerplate.conf diff --git a/docker/php-apache-dev/alpine-3/conf/etc/httpd/vhost.common.d/02-dev.conf b/docker/php-apache-dev/7.0/conf/etc/httpd/vhost.common.d/02-dev.conf similarity index 100% rename from docker/php-apache-dev/alpine-3/conf/etc/httpd/vhost.common.d/02-dev.conf rename to docker/php-apache-dev/7.0/conf/etc/httpd/vhost.common.d/02-dev.conf diff --git a/docker/php-apache-dev/alpine-3/conf/etc/httpd/vhost.conf b/docker/php-apache-dev/7.0/conf/etc/httpd/vhost.conf similarity index 100% rename from docker/php-apache-dev/alpine-3/conf/etc/httpd/vhost.conf rename to docker/php-apache-dev/7.0/conf/etc/httpd/vhost.conf diff --git a/docker/php-apache-dev/alpine-3/conf/etc/httpd/vhost.ssl.conf b/docker/php-apache-dev/7.0/conf/etc/httpd/vhost.ssl.conf similarity index 100% rename from docker/php-apache-dev/alpine-3/conf/etc/httpd/vhost.ssl.conf rename to docker/php-apache-dev/7.0/conf/etc/httpd/vhost.ssl.conf diff --git a/docker/php-apache-dev/alpine-3/conf/etc/supervisor.d/apache.conf b/docker/php-apache-dev/7.0/conf/etc/supervisor.d/apache.conf similarity index 100% rename from docker/php-apache-dev/alpine-3/conf/etc/supervisor.d/apache.conf rename to docker/php-apache-dev/7.0/conf/etc/supervisor.d/apache.conf diff --git a/docker/php-apache-dev/alpine-3/conf/etc/supervisor.d/blackfire-agent.conf b/docker/php-apache-dev/7.0/conf/etc/supervisor.d/blackfire-agent.conf similarity index 100% rename from docker/php-apache-dev/alpine-3/conf/etc/supervisor.d/blackfire-agent.conf rename to docker/php-apache-dev/7.0/conf/etc/supervisor.d/blackfire-agent.conf diff --git a/docker/php-apache-dev/7.0/conf/provision/entrypoint.d/10-php-debugger.sh b/docker/php-apache-dev/7.0/conf/provision/entrypoint.d/10-php-debugger.sh new file mode 100644 index 000000000..b5985a9ef --- /dev/null +++ b/docker/php-apache-dev/7.0/conf/provision/entrypoint.d/10-php-debugger.sh @@ -0,0 +1,96 @@ +#!/usr/bin/env bash + +################################################# +# Debugger switch +################################################# + +PHP_CONF_PATHS=" +/etc/php5/conf.d +/etc/php7/conf.d +/etc/php.d +/etc/php5/mods-available +/etc/php5/cli/conf.d +/etc/php5/cli/conf.d +/etc/php5/fpm/conf.d +/etc/php5/fpm/conf.d +/etc/php/7.0/mods-available +/etc/php/7.0/cli/conf.d +/etc/php/7.0/fpm/conf.d +/usr/local/etc/php/conf.d/" + +function phpModuleRemove() { + if [ "$#" -ne 1 ]; then + echo "You must specify the name of the PHP module which you want to disable" + exit 1 + fi + + echo " - Removing PHP module ${1}" + for CONF_PATH in $PHP_CONF_PATHS; do + rm -f "${CONF_PATH}"/*"${1}".ini + done +} + + +if [[ -n "${PHP_DEBUGGER+x}" ]]; then + case "$PHP_DEBUGGER" in + xdebug) + echo "PHP-Debugger: Xdebug enabled" + phpModuleRemove "blackfire" + ;; + + blackfire) + echo "PHP-Debugger: Blackfire enabled" + phpModuleRemove "xdebug" + docker-service-enable blackfire-agent + ;; + + none) + echo "PHP-Debugger: none" + phpModuleRemove "blackfire" + phpModuleRemove "xdebug" + ;; + esac + +else + + echo "PHP-Debugger: not specified - default is xdebug" + phpModuleRemove "blackfire" + +fi + +################################################# +# PHP debugger environment variables +################################################# + +function phpEnvironmentVariable() { + PHP_INI_KEY="$1" + PHP_ENV_NAME="$2" + + if [[ -n "${!PHP_ENV_NAME+x}" ]]; then + PHP_ENV_VALUE="${!PHP_ENV_NAME}" + echo "${PHP_INI_KEY}=\"${PHP_ENV_VALUE}\"" >> /opt/docker/etc/php/php.ini + fi +} + +################### +# XDEBUG +################### + +# remote debugger +phpEnvironmentVariable "xdebug.remote_connect_back" "XDEBUG_REMOTE_CONNECT_BACK" +phpEnvironmentVariable "xdebug.remote_autostart" "XDEBUG_REMOTE_AUTOSTART" +phpEnvironmentVariable "xdebug.remote_host" "XDEBUG_REMOTE_HOST" +phpEnvironmentVariable "xdebug.remote_port" "XDEBUG_REMOTE_PORT" + +# profiler +phpEnvironmentVariable "xdebug.profiler_enable" "XDEBUG_PROFILER_ENABLE" +phpEnvironmentVariable "xdebug.profiler_enable_trigger" "XDEBUG_PROFILER_ENABLE_TRIGGER" +phpEnvironmentVariable "xdebug.profiler_enable_trigger_value" "XDEBUG_PROFILER_ENABLE_TRIGGER_VALUE" +phpEnvironmentVariable "xdebug.profiler_output_dir" "XDEBUG_PROFILER_OUTPUT_DIR" +phpEnvironmentVariable "xdebug.profiler_output_name" "XDEBUG_PROFILER_OUTPUT_NAME" + +################### +# BLACKFIRE +################### +phpEnvironmentVariable "blackfire.server_id" "BLACKFIRE_SERVER_ID" +phpEnvironmentVariable "blackfire.server_token" "BLACKFIRE_SERVER_TOKEN" diff --git a/docker/php-apache-dev/alpine-3/conf/provision/roles/webdevops-apache-dev/defaults/main.yml b/docker/php-apache-dev/7.0/conf/provision/roles/webdevops-apache-dev/defaults/main.yml similarity index 100% rename from docker/php-apache-dev/alpine-3/conf/provision/roles/webdevops-apache-dev/defaults/main.yml rename to docker/php-apache-dev/7.0/conf/provision/roles/webdevops-apache-dev/defaults/main.yml diff --git a/docker/php-apache-dev/alpine-3/conf/provision/roles/webdevops-apache-dev/tasks/bootstrap.yml b/docker/php-apache-dev/7.0/conf/provision/roles/webdevops-apache-dev/tasks/bootstrap.yml similarity index 100% rename from docker/php-apache-dev/alpine-3/conf/provision/roles/webdevops-apache-dev/tasks/bootstrap.yml rename to docker/php-apache-dev/7.0/conf/provision/roles/webdevops-apache-dev/tasks/bootstrap.yml diff --git a/docker/php-apache-dev/alpine-3/conf/provision/roles/webdevops-apache-dev/tasks/main.yml b/docker/php-apache-dev/7.0/conf/provision/roles/webdevops-apache-dev/tasks/main.yml similarity index 100% rename from docker/php-apache-dev/alpine-3/conf/provision/roles/webdevops-apache-dev/tasks/main.yml rename to docker/php-apache-dev/7.0/conf/provision/roles/webdevops-apache-dev/tasks/main.yml diff --git a/docker/php-apache-dev/alpine-3/conf/provision/roles/webdevops-apache/defaults/main.yml b/docker/php-apache-dev/7.0/conf/provision/roles/webdevops-apache/defaults/main.yml similarity index 100% rename from docker/php-apache-dev/alpine-3/conf/provision/roles/webdevops-apache/defaults/main.yml rename to docker/php-apache-dev/7.0/conf/provision/roles/webdevops-apache/defaults/main.yml diff --git a/docker/php-apache-dev/7.0/conf/provision/roles/webdevops-apache/tasks/bootstrap.yml b/docker/php-apache-dev/7.0/conf/provision/roles/webdevops-apache/tasks/bootstrap.yml new file mode 100644 index 000000000..c285be286 --- /dev/null +++ b/docker/php-apache-dev/7.0/conf/provision/roles/webdevops-apache/tasks/bootstrap.yml @@ -0,0 +1,156 @@ +--- + +- name: Set apache vhost file [RedHat family] + set_fact: + apache_main_path: /etc/httpd/ + apache_docker_vhost: /etc/httpd/conf.d/zzz-docker.conf + when: ansible_os_family == 'RedHat' + +- name: Set apache vhost file [Debian family] + set_fact: + apache_main_path: /etc/apache2/ + apache_docker_vhost: /etc/apache2/sites-enabled/10-docker.conf + when: ansible_os_family == 'Debian' + +- name: Set apache vhost file [Alpine family] + set_fact: + apache_main_path: /etc/apache2/ + apache_docker_vhost: /etc/apache2/conf.d/zzz-docker.conf + when: ansible_os_family == 'Alpine' + +- name: Enable apache main config + file: + src: '/opt/docker/etc/httpd/main.conf' + dest: '{{ apache_docker_vhost }}' + state: link + force: yes + +- name: Ensure document root is available + file: + path: "{{ DOCUMENT_ROOT }}" + state: directory + recurse: yes + +- name: Ensure /var/run/apache2 exists + file: + path: '/var/run/apache2' + state: directory + recurse: yes + +- name: Ensure /run/apache2 exists + file: + path: '/run/apache2' + state: directory + recurse: yes + when: ansible_os_family == 'Alpine' + +- name: Find apache2 files + shell: "find '{{ apache_main_path }}' -type f -iname '*.conf' -o -iname 'default*' -o -iname '*log'" + register: apache2_conf_files + +- name: Change CustomLog to Docker stdout + replace: + dest: '{{ item }}' + regexp: '^[\s]*CustomLog ([^\s]+)(.*)' + replace: 'CustomLog /docker.stdout \2' + with_items: "{{ apache2_conf_files.stdout_lines }}" + +- name: Change CustomLog to Docker stdout + replace: + dest: '{{ item }}' + regexp: '^[\s]*ErrorLog ([^\s]+)(.*)' + replace: 'ErrorLog /docker.stdout \2' + with_items: "{{ apache2_conf_files.stdout_lines }}" + +- name: Change TransferLog to Docker stdout + replace: + dest: '{{ item }}' + regexp: '^[\s]*TransferLog ([^\s]+)(.*)' + replace: 'TransferLog /docker.stdout \2' + with_items: "{{ apache2_conf_files.stdout_lines }}" + +- name: Switch MPM to worker [RedHat family] + lineinfile: + dest: '/etc/httpd/conf.modules.d/00-mpm.conf' + regexp: '^[\s#]*{{ item.line }}' + line: '{{ item.prefix }}{{ item.line }}' + with_items: + - { line: 'LoadModule mpm_prefork_module modules/mod_mpm_prefork.so', prefix: "#" } + - { line: 'LoadModule mpm_event_module modules/mod_mpm_event.so', prefix: "" } + when: ansible_os_family == 'RedHat' + +- name: Switch MPM to event for Apache 2.4 and higher [Ubuntu family] + command: "{{ item }}" + with_items: + - 'a2dismod mpm_event' + - 'a2enmod mpm_event' + when: (ansible_distribution == 'Ubuntu' and docker_image_info_distribution_version|int >= 14) or (ansible_distribution == 'Debian' and docker_image_info_distribution_version|int >= 8) + +- name: Manage modules [Alpine family] + lineinfile: + dest: '/etc/apache2/httpd.conf' + regexp: '^[\s#]*{{ item.line }}' + line: '{{ item.prefix }}{{ item.line }}' + with_items: + - { line: 'LoadModule mpm_prefork_module modules/mod_mpm_prefork.so', prefix: "#" } + - { line: 'LoadModule mpm_event_module modules/mod_mpm_event.so', prefix: "" } + - { line: 'LoadModule deflate_module modules/mod_deflate.so', prefix: "" } + - { line: 'LoadModule rewrite_module modules/mod_rewrite.so', prefix: "" } + - { line: 'LoadModule logio_module modules/mod_logio.so', prefix: "" } + - { line: 'LoadModule slotmem_shm_module modules/mod_slotmem_shm.so', prefix: "" } + - { line: 'LoadModule actions_module modules/mod_actions.so', prefix: "" } + - { line: 'LoadModule expires_module modules/mod_expires.so', prefix: "" } + when: ansible_os_family == 'Alpine' + +- name: Fix ssl support [Alpine family] + lineinfile: + dest: '/etc/apache2/conf.d/ssl.conf' + regexp: '{{ item.regexp }}' + line: '{{ item.line }}' + with_items: + - { regexp: 'LoadModule ssl_module', line: 'LoadModule ssl_module /usr/lib/apache2/mod_ssl.so' } + - { regexp: 'LoadModule socache_shmcb_module', line: 'LoadModule socache_shmcb_module /usr/lib/apache2/mod_socache_shmcb.so' } + when: ansible_os_family == 'Alpine' + +- name: Remove default vhost from ssl configuration [Alpine family] + command: sed -i -e '1h;2,$H;$!d;g' -e 's//#-> removed vhost/g' /etc/apache2/conf.d/ssl.conf + when: ansible_os_family == 'Alpine' + +- name: Disable proxy [Alpine family] + lineinfile: + dest: '/etc/apache2/conf.d/proxy.conf' + regexp: '^[\s#]*{{ item.line }}' + line: '{{ item.prefix }}{{ item.line }}' + with_items: + - { line: 'LoadModule proxy_ajp_module modules/mod_proxy_ajp.so', prefix: "#" } + - { line: 'LoadModule proxy_connect_module modules/mod_proxy_connect.so', prefix: "#" } + - { line: 'LoadModule proxy_balancer_module modules/mod_proxy_balancer.so', prefix: "#" } + - { line: 'LoadModule proxy_express_module modules/mod_proxy_express.so', prefix: "#" } + - { line: 'LoadModule proxy_fcgi_module modules/mod_proxy_fcgi.so', prefix: "" } + - { line: 'LoadModule proxy_fdpass_module modules/mod_proxy_fdpass.so', prefix: "#" } + - { line: 'LoadModule proxy_ftp_module modules/mod_proxy_ftp.so', prefix: "#" } + - { line: 'LoadModule proxy_http_module modules/mod_proxy_http.so', prefix: "#" } + - { line: 'LoadModule proxy_scgi_module modules/mod_proxy_scgi.so', prefix: "#" } + when: ansible_os_family == 'Alpine' + +- name: Fix rights of ssl files + file: + path: "{{ item.path }}" + state: "{{ item.state }}" + mode: "{{ item.mode }}" + owner: "root" + group: "root" + with_items: + - { path: '/opt/docker/etc/httpd/ssl', state: 'directory', mode: '0750' } + - { path: '/opt/docker/etc/httpd/ssl/server.crt', state: 'file', mode: '0640' } + - { path: '/opt/docker/etc/httpd/ssl/server.csr', state: 'file', mode: '0640' } + - { path: '/opt/docker/etc/httpd/ssl/server.key', state: 'file', mode: '0640' } + +- name: Maintain lock directory [Debian family] + file: + path: "/var/lock/apache2" + state: "directory" + mode: "0750" + owner: "www-data" + group: "www-data" + when: ansible_os_family == 'Debian' diff --git a/docker/php-apache-dev/alpine-3/conf/provision/roles/webdevops-apache/tasks/main.yml b/docker/php-apache-dev/7.0/conf/provision/roles/webdevops-apache/tasks/main.yml similarity index 100% rename from docker/php-apache-dev/alpine-3/conf/provision/roles/webdevops-apache/tasks/main.yml rename to docker/php-apache-dev/7.0/conf/provision/roles/webdevops-apache/tasks/main.yml diff --git a/docker/php-apache-dev/alpine-3/conf/provision/roles/webdevops-php-apache/defaults/main.yml b/docker/php-apache-dev/7.0/conf/provision/roles/webdevops-php-apache/defaults/main.yml similarity index 100% rename from docker/php-apache-dev/alpine-3/conf/provision/roles/webdevops-php-apache/defaults/main.yml rename to docker/php-apache-dev/7.0/conf/provision/roles/webdevops-php-apache/defaults/main.yml diff --git a/docker/php-apache-dev/alpine-3/conf/provision/roles/webdevops-php-apache/tasks/bootstrap.yml b/docker/php-apache-dev/7.0/conf/provision/roles/webdevops-php-apache/tasks/bootstrap.yml similarity index 100% rename from docker/php-apache-dev/alpine-3/conf/provision/roles/webdevops-php-apache/tasks/bootstrap.yml rename to docker/php-apache-dev/7.0/conf/provision/roles/webdevops-php-apache/tasks/bootstrap.yml diff --git a/docker/php-apache-dev/alpine-3/conf/provision/roles/webdevops-php-apache/tasks/entrypoint.yml b/docker/php-apache-dev/7.0/conf/provision/roles/webdevops-php-apache/tasks/entrypoint.yml similarity index 100% rename from docker/php-apache-dev/alpine-3/conf/provision/roles/webdevops-php-apache/tasks/entrypoint.yml rename to docker/php-apache-dev/7.0/conf/provision/roles/webdevops-php-apache/tasks/entrypoint.yml diff --git a/docker/php-apache-dev/alpine-3/conf/provision/roles/webdevops-php-apache/tasks/main.yml b/docker/php-apache-dev/7.0/conf/provision/roles/webdevops-php-apache/tasks/main.yml similarity index 100% rename from docker/php-apache-dev/alpine-3/conf/provision/roles/webdevops-php-apache/tasks/main.yml rename to docker/php-apache-dev/7.0/conf/provision/roles/webdevops-php-apache/tasks/main.yml diff --git a/docker/php-apache-dev/alpine-3/conf/provision/roles/webdevops-php-dev/defaults/main.yml b/docker/php-apache-dev/7.0/conf/provision/roles/webdevops-php-dev/defaults/main.yml similarity index 100% rename from docker/php-apache-dev/alpine-3/conf/provision/roles/webdevops-php-dev/defaults/main.yml rename to docker/php-apache-dev/7.0/conf/provision/roles/webdevops-php-dev/defaults/main.yml diff --git a/docker/php-apache-dev/7.0/conf/provision/roles/webdevops-php-dev/tasks/bootstrap.yml b/docker/php-apache-dev/7.0/conf/provision/roles/webdevops-php-dev/tasks/bootstrap.yml new file mode 100644 index 000000000..ff02b05fc --- /dev/null +++ b/docker/php-apache-dev/7.0/conf/provision/roles/webdevops-php-dev/tasks/bootstrap.yml @@ -0,0 +1,7 @@ +--- + +- include: bootstrap/php-fpm.yml +- include: bootstrap/php-module.yml +- include: bootstrap/php-module.opcache.yml +- include: bootstrap/php-module.xdebug.yml +- include: bootstrap/php-module.blackfire.yml diff --git a/docker/php-apache-dev/alpine-3/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/php-fpm.yml b/docker/php-apache-dev/7.0/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/php-fpm.yml similarity index 100% rename from docker/php-apache-dev/alpine-3/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/php-fpm.yml rename to docker/php-apache-dev/7.0/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/php-fpm.yml diff --git a/docker/php-apache-dev/7.0/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/php-module.blackfire.yml b/docker/php-apache-dev/7.0/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/php-module.blackfire.yml new file mode 100644 index 000000000..faf05f8de --- /dev/null +++ b/docker/php-apache-dev/7.0/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/php-module.blackfire.yml @@ -0,0 +1,10 @@ +--- + +- name: Remove superfluous blackfire configuration file + file: + path: '{{ item }}' + state: absent + with_items: + - /etc/php5/cli/conf.d/zz-blackfire.ini + - /etc/php5/fpm/conf.d/zz-blackfire.ini + when: ansible_distribution == 'Debian' and docker_image_info_distribution_version|int >= 7 diff --git a/docker/php-apache-dev/alpine-3/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/php-module.opcache.yml b/docker/php-apache-dev/7.0/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/php-module.opcache.yml similarity index 100% rename from docker/php-apache-dev/alpine-3/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/php-module.opcache.yml rename to docker/php-apache-dev/7.0/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/php-module.opcache.yml diff --git a/docker/php-apache-dev/alpine-3/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/php-module.xdebug.yml b/docker/php-apache-dev/7.0/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/php-module.xdebug.yml similarity index 100% rename from docker/php-apache-dev/alpine-3/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/php-module.xdebug.yml rename to docker/php-apache-dev/7.0/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/php-module.xdebug.yml diff --git a/docker/php-apache-dev/alpine-3/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/php-module.yml b/docker/php-apache-dev/7.0/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/php-module.yml similarity index 100% rename from docker/php-apache-dev/alpine-3/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/php-module.yml rename to docker/php-apache-dev/7.0/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/php-module.yml diff --git a/docker/php-apache-dev/alpine-3/conf/provision/roles/webdevops-php-dev/tasks/main.yml b/docker/php-apache-dev/7.0/conf/provision/roles/webdevops-php-dev/tasks/main.yml similarity index 100% rename from docker/php-apache-dev/alpine-3/conf/provision/roles/webdevops-php-dev/tasks/main.yml rename to docker/php-apache-dev/7.0/conf/provision/roles/webdevops-php-dev/tasks/main.yml diff --git a/docker/php-apache-dev/7.1/Dockerfile b/docker/php-apache-dev/7.1/Dockerfile new file mode 100644 index 000000000..35c77e557 --- /dev/null +++ b/docker/php-apache-dev/7.1/Dockerfile @@ -0,0 +1,30 @@ +#+++++++++++++++++++++++++++++++++++++++ +# Dockerfile for webdevops/php-apache-dev:7.1 +# -- automatically generated -- +#+++++++++++++++++++++++++++++++++++++++ + +FROM webdevops/php-dev:7.1 + +ENV WEB_DOCUMENT_ROOT=/app \ + WEB_DOCUMENT_INDEX=index.php \ + WEB_ALIAS_DOMAIN=*.vm +ENV WEB_PHP_SOCKET=127.0.0.1:9000 +ENV WEB_NO_CACHE_PATTERN="\.(css|js|gif|png|jpg|svg|json|xml)$" + +COPY conf/ /opt/docker/ + +# Install apache +RUN /usr/local/bin/apt-install \ + apache2 \ + apache2-mpm-worker \ + && sed -ri ' \ + s!^(\s*CustomLog)\s+\S+!\1 /proc/self/fd/1!g; \ + s!^(\s*ErrorLog)\s+\S+!\1 /proc/self/fd/2!g; \ + ' /etc/apache2/apache2.conf \ + && rm -f /etc/apache2/sites-enabled/* \ + && a2enmod actions proxy proxy_fcgi ssl rewrite headers expires \ + && /opt/docker/bin/provision run --tag bootstrap --role webdevops-apache --role webdevops-php-apache --role webdevops-apache-dev --role webdevops-php-dev \ + && /opt/docker/bin/bootstrap.sh \ + && docker-image-cleanup + +EXPOSE 80 443 diff --git a/docker/php-apache-dev/7.1/Dockerfile.jinja2 b/docker/php-apache-dev/7.1/Dockerfile.jinja2 new file mode 100644 index 000000000..e294d24d9 --- /dev/null +++ b/docker/php-apache-dev/7.1/Dockerfile.jinja2 @@ -0,0 +1,11 @@ +{{ docker.from("php-dev", "7.1") }} + +{{ environment.web() }} +{{ environment.webPhp() }} +{{ environment.webDevelopment() }} + +{{ docker.copy('conf/', '/opt/docker/') }} + +{{ apache.debian8('php-apache apache-dev php-dev') }} + +{{ docker.expose('80 443') }} diff --git a/docker/php-dev/alpine-3-php7/conf/bin/service.d/blackfire-agent.d/10-init.sh b/docker/php-apache-dev/7.1/conf/bin/service.d/blackfire-agent.d/10-init.sh similarity index 100% rename from docker/php-dev/alpine-3-php7/conf/bin/service.d/blackfire-agent.d/10-init.sh rename to docker/php-apache-dev/7.1/conf/bin/service.d/blackfire-agent.d/10-init.sh diff --git a/docker/php-dev/alpine-3-php7/conf/bin/service.d/blackfire-agent.sh b/docker/php-apache-dev/7.1/conf/bin/service.d/blackfire-agent.sh similarity index 100% rename from docker/php-dev/alpine-3-php7/conf/bin/service.d/blackfire-agent.sh rename to docker/php-apache-dev/7.1/conf/bin/service.d/blackfire-agent.sh diff --git a/docker/php-apache-dev/7.1/conf/bin/service.d/httpd.d/10-init.sh b/docker/php-apache-dev/7.1/conf/bin/service.d/httpd.d/10-init.sh new file mode 100644 index 000000000..b9d57997e --- /dev/null +++ b/docker/php-apache-dev/7.1/conf/bin/service.d/httpd.d/10-init.sh @@ -0,0 +1,21 @@ +if [[ ! -e "$WEB_DOCUMENT_ROOT" ]]; then + echo "" + echo "[WARNING] WEB_DOCUMENT_ROOT does not exists with path \"$WEB_DOCUMENT_ROOT\"!" + echo "" +fi + +# Replace markers +go-replace \ + -s "" -r "$WEB_DOCUMENT_INDEX" \ + -s "" -r "$WEB_DOCUMENT_ROOT" \ + -s "" -r "$WEB_ALIAS_DOMAIN" \ + -s "" -r "$HOSTNAME" \ + -s "" -r "$WEB_PHP_SOCKET" \ + --path=/opt/docker/etc/httpd/ \ + --path-pattern='*.conf' \ + --ignore-empty + +if [[ -z "${WEB_PHP_SOCKET+x}" ]]; then + ## WEB_PHP_SOCKET is not set, remove PHP files + rm -f -- /opt/docker/etc/httpd/conf.d/10-php.conf +fi diff --git a/docker/php-apache-dev/7.1/conf/bin/service.d/httpd.d/12-development.sh b/docker/php-apache-dev/7.1/conf/bin/service.d/httpd.d/12-development.sh new file mode 100644 index 000000000..a9d2c6e92 --- /dev/null +++ b/docker/php-apache-dev/7.1/conf/bin/service.d/httpd.d/12-development.sh @@ -0,0 +1,5 @@ +go-replace \ + -s "" -r "$WEB_NO_CACHE_PATTERN" \ + --path=/opt/docker/etc/httpd/ \ + --path-pattern='*.conf' \ + --ignore-empty diff --git a/docker/php-apache-dev/7.1/conf/bin/service.d/httpd.sh b/docker/php-apache-dev/7.1/conf/bin/service.d/httpd.sh new file mode 100644 index 000000000..03eec305a --- /dev/null +++ b/docker/php-apache-dev/7.1/conf/bin/service.d/httpd.sh @@ -0,0 +1,12 @@ +#!/usr/bin/env bash +set -e + +source /opt/docker/bin/config.sh + +includeScriptDir "/opt/docker/bin/service.d/httpd.d/" + +# Apache gets grumpy about PID files pre-existing +rm -f /var/run/apache2/apache2*.pid + +source /etc/apache2/envvars +exec apache2 -DFOREGROUND -DAPACHE_LOCK_DIR diff --git a/docker/php-apache-dev/7.1/conf/etc/httpd/conf.d/.gitkeep b/docker/php-apache-dev/7.1/conf/etc/httpd/conf.d/.gitkeep new file mode 100644 index 000000000..e69de29bb diff --git a/docker/php-apache-dev/7.1/conf/etc/httpd/conf.d/02-dev.conf b/docker/php-apache-dev/7.1/conf/etc/httpd/conf.d/02-dev.conf new file mode 100644 index 000000000..75e5f4396 --- /dev/null +++ b/docker/php-apache-dev/7.1/conf/etc/httpd/conf.d/02-dev.conf @@ -0,0 +1,8 @@ +# EnableSendfile: Control whether the sendfile kernel support is +# used to deliver files (assuming that the OS supports it). +# The default is on; turn this off if you serve from NFS-mounted +# filesystems. Please see +# http://httpd.apache.org/docs/2.2/mod/core.html#enablesendfile +EnableSendfile off + +LogLevel info diff --git a/docker/php-apache/alpine-3-php7/conf/etc/httpd/conf.d/10-error-document.conf b/docker/php-apache-dev/7.1/conf/etc/httpd/conf.d/10-error-document.conf similarity index 100% rename from docker/php-apache/alpine-3-php7/conf/etc/httpd/conf.d/10-error-document.conf rename to docker/php-apache-dev/7.1/conf/etc/httpd/conf.d/10-error-document.conf diff --git a/docker/php-apache-dev/7.1/conf/etc/httpd/conf.d/10-log.conf b/docker/php-apache-dev/7.1/conf/etc/httpd/conf.d/10-log.conf new file mode 100644 index 000000000..ef0c73d38 --- /dev/null +++ b/docker/php-apache-dev/7.1/conf/etc/httpd/conf.d/10-log.conf @@ -0,0 +1,4 @@ +LogFormat "[httpd:access] %V:%p %h %l %u %t \"%r\" %>s bytesIn:%I bytesOut:%O reqTime:%T" dockerlog +LogLevel warn +CustomLog /docker.stdout dockerlog +ErrorLog /docker.stderr diff --git a/docker/php-apache/alpine-3-php7/conf/etc/httpd/conf.d/10-php.conf b/docker/php-apache-dev/7.1/conf/etc/httpd/conf.d/10-php.conf similarity index 100% rename from docker/php-apache/alpine-3-php7/conf/etc/httpd/conf.d/10-php.conf rename to docker/php-apache-dev/7.1/conf/etc/httpd/conf.d/10-php.conf diff --git a/docker/php-apache/alpine-3-php7/conf/etc/httpd/conf.d/10-server.conf b/docker/php-apache-dev/7.1/conf/etc/httpd/conf.d/10-server.conf similarity index 100% rename from docker/php-apache/alpine-3-php7/conf/etc/httpd/conf.d/10-server.conf rename to docker/php-apache-dev/7.1/conf/etc/httpd/conf.d/10-server.conf diff --git a/docker/php-apache/alpine-3-php7/conf/etc/httpd/global.conf b/docker/php-apache-dev/7.1/conf/etc/httpd/global.conf similarity index 100% rename from docker/php-apache/alpine-3-php7/conf/etc/httpd/global.conf rename to docker/php-apache-dev/7.1/conf/etc/httpd/global.conf diff --git a/docker/php-apache/alpine-3-php7/conf/etc/httpd/main.conf b/docker/php-apache-dev/7.1/conf/etc/httpd/main.conf similarity index 100% rename from docker/php-apache/alpine-3-php7/conf/etc/httpd/main.conf rename to docker/php-apache-dev/7.1/conf/etc/httpd/main.conf diff --git a/docker/php-apache/alpine-3-php7/conf/etc/httpd/php.conf b/docker/php-apache-dev/7.1/conf/etc/httpd/php.conf similarity index 100% rename from docker/php-apache/alpine-3-php7/conf/etc/httpd/php.conf rename to docker/php-apache-dev/7.1/conf/etc/httpd/php.conf diff --git a/docker/php-apache/alpine-3-php7/conf/etc/httpd/ssl/server.crt b/docker/php-apache-dev/7.1/conf/etc/httpd/ssl/server.crt similarity index 100% rename from docker/php-apache/alpine-3-php7/conf/etc/httpd/ssl/server.crt rename to docker/php-apache-dev/7.1/conf/etc/httpd/ssl/server.crt diff --git a/docker/php-apache/alpine-3-php7/conf/etc/httpd/ssl/server.csr b/docker/php-apache-dev/7.1/conf/etc/httpd/ssl/server.csr similarity index 100% rename from docker/php-apache/alpine-3-php7/conf/etc/httpd/ssl/server.csr rename to docker/php-apache-dev/7.1/conf/etc/httpd/ssl/server.csr diff --git a/docker/php-apache/alpine-3-php7/conf/etc/httpd/ssl/server.key b/docker/php-apache-dev/7.1/conf/etc/httpd/ssl/server.key similarity index 100% rename from docker/php-apache/alpine-3-php7/conf/etc/httpd/ssl/server.key rename to docker/php-apache-dev/7.1/conf/etc/httpd/ssl/server.key diff --git a/docker/php-apache/alpine-3-php7/conf/etc/httpd/vhost.common.conf b/docker/php-apache-dev/7.1/conf/etc/httpd/vhost.common.conf similarity index 100% rename from docker/php-apache/alpine-3-php7/conf/etc/httpd/vhost.common.conf rename to docker/php-apache-dev/7.1/conf/etc/httpd/vhost.common.conf diff --git a/docker/php-apache-dev/7.1/conf/etc/httpd/vhost.common.d/.gitkeep b/docker/php-apache-dev/7.1/conf/etc/httpd/vhost.common.d/.gitkeep new file mode 100644 index 000000000..e69de29bb diff --git a/docker/php-apache/alpine-3-php7/conf/etc/httpd/vhost.common.d/01-boilerplate.conf b/docker/php-apache-dev/7.1/conf/etc/httpd/vhost.common.d/01-boilerplate.conf similarity index 100% rename from docker/php-apache/alpine-3-php7/conf/etc/httpd/vhost.common.d/01-boilerplate.conf rename to docker/php-apache-dev/7.1/conf/etc/httpd/vhost.common.d/01-boilerplate.conf diff --git a/docker/php-apache-dev/7.1/conf/etc/httpd/vhost.common.d/02-dev.conf b/docker/php-apache-dev/7.1/conf/etc/httpd/vhost.common.d/02-dev.conf new file mode 100644 index 000000000..54918ec2b --- /dev/null +++ b/docker/php-apache-dev/7.1/conf/etc/httpd/vhost.common.d/02-dev.conf @@ -0,0 +1,10 @@ +"> + FileETag None + + + Header unset ETag + Header set Cache-Control "max-age=0, no-cache, no-store, must-revalidate" + Header set Pragma "no-cache" + Header set Expires "Wed, 11 Jan 1984 05:00:00 GMT" + + diff --git a/docker/php-apache/alpine-3-php7/conf/etc/httpd/vhost.conf b/docker/php-apache-dev/7.1/conf/etc/httpd/vhost.conf similarity index 100% rename from docker/php-apache/alpine-3-php7/conf/etc/httpd/vhost.conf rename to docker/php-apache-dev/7.1/conf/etc/httpd/vhost.conf diff --git a/docker/php-apache/alpine-3-php7/conf/etc/httpd/vhost.ssl.conf b/docker/php-apache-dev/7.1/conf/etc/httpd/vhost.ssl.conf similarity index 100% rename from docker/php-apache/alpine-3-php7/conf/etc/httpd/vhost.ssl.conf rename to docker/php-apache-dev/7.1/conf/etc/httpd/vhost.ssl.conf diff --git a/docker/php-apache/alpine-3-php7/conf/etc/supervisor.d/apache.conf b/docker/php-apache-dev/7.1/conf/etc/supervisor.d/apache.conf similarity index 100% rename from docker/php-apache/alpine-3-php7/conf/etc/supervisor.d/apache.conf rename to docker/php-apache-dev/7.1/conf/etc/supervisor.d/apache.conf diff --git a/docker/php-dev/alpine-3-php7/conf/etc/supervisor.d/blackfire-agent.conf b/docker/php-apache-dev/7.1/conf/etc/supervisor.d/blackfire-agent.conf similarity index 100% rename from docker/php-dev/alpine-3-php7/conf/etc/supervisor.d/blackfire-agent.conf rename to docker/php-apache-dev/7.1/conf/etc/supervisor.d/blackfire-agent.conf diff --git a/docker/php-apache-dev/7.1/conf/provision/entrypoint.d/10-php-debugger.sh b/docker/php-apache-dev/7.1/conf/provision/entrypoint.d/10-php-debugger.sh new file mode 100644 index 000000000..b5985a9ef --- /dev/null +++ b/docker/php-apache-dev/7.1/conf/provision/entrypoint.d/10-php-debugger.sh @@ -0,0 +1,96 @@ +#!/usr/bin/env bash + +################################################# +# Debugger switch +################################################# + +PHP_CONF_PATHS=" +/etc/php5/conf.d +/etc/php7/conf.d +/etc/php.d +/etc/php5/mods-available +/etc/php5/cli/conf.d +/etc/php5/cli/conf.d +/etc/php5/fpm/conf.d +/etc/php5/fpm/conf.d +/etc/php/7.0/mods-available +/etc/php/7.0/cli/conf.d +/etc/php/7.0/fpm/conf.d +/usr/local/etc/php/conf.d/" + +function phpModuleRemove() { + if [ "$#" -ne 1 ]; then + echo "You must specify the name of the PHP module which you want to disable" + exit 1 + fi + + echo " - Removing PHP module ${1}" + for CONF_PATH in $PHP_CONF_PATHS; do + rm -f "${CONF_PATH}"/*"${1}".ini + done +} + + +if [[ -n "${PHP_DEBUGGER+x}" ]]; then + case "$PHP_DEBUGGER" in + xdebug) + echo "PHP-Debugger: Xdebug enabled" + phpModuleRemove "blackfire" + ;; + + blackfire) + echo "PHP-Debugger: Blackfire enabled" + phpModuleRemove "xdebug" + docker-service-enable blackfire-agent + ;; + + none) + echo "PHP-Debugger: none" + phpModuleRemove "blackfire" + phpModuleRemove "xdebug" + ;; + esac + +else + + echo "PHP-Debugger: not specified - default is xdebug" + phpModuleRemove "blackfire" + +fi + +################################################# +# PHP debugger environment variables +################################################# + +function phpEnvironmentVariable() { + PHP_INI_KEY="$1" + PHP_ENV_NAME="$2" + + if [[ -n "${!PHP_ENV_NAME+x}" ]]; then + PHP_ENV_VALUE="${!PHP_ENV_NAME}" + echo "${PHP_INI_KEY}=\"${PHP_ENV_VALUE}\"" >> /opt/docker/etc/php/php.ini + fi +} + +################### +# XDEBUG +################### + +# remote debugger +phpEnvironmentVariable "xdebug.remote_connect_back" "XDEBUG_REMOTE_CONNECT_BACK" +phpEnvironmentVariable "xdebug.remote_autostart" "XDEBUG_REMOTE_AUTOSTART" +phpEnvironmentVariable "xdebug.remote_host" "XDEBUG_REMOTE_HOST" +phpEnvironmentVariable "xdebug.remote_port" "XDEBUG_REMOTE_PORT" + +# profiler +phpEnvironmentVariable "xdebug.profiler_enable" "XDEBUG_PROFILER_ENABLE" +phpEnvironmentVariable "xdebug.profiler_enable_trigger" "XDEBUG_PROFILER_ENABLE_TRIGGER" +phpEnvironmentVariable "xdebug.profiler_enable_trigger_value" "XDEBUG_PROFILER_ENABLE_TRIGGER_VALUE" +phpEnvironmentVariable "xdebug.profiler_output_dir" "XDEBUG_PROFILER_OUTPUT_DIR" +phpEnvironmentVariable "xdebug.profiler_output_name" "XDEBUG_PROFILER_OUTPUT_NAME" + +################### +# BLACKFIRE +################### +phpEnvironmentVariable "blackfire.server_id" "BLACKFIRE_SERVER_ID" +phpEnvironmentVariable "blackfire.server_token" "BLACKFIRE_SERVER_TOKEN" diff --git a/docker/php-dev/alpine-3-php7/conf/provision/roles/webdevops-php-dev/defaults/main.yml b/docker/php-apache-dev/7.1/conf/provision/roles/webdevops-apache-dev/defaults/main.yml similarity index 100% rename from docker/php-dev/alpine-3-php7/conf/provision/roles/webdevops-php-dev/defaults/main.yml rename to docker/php-apache-dev/7.1/conf/provision/roles/webdevops-apache-dev/defaults/main.yml diff --git a/docker/php-apache/alpine-3-php7/conf/provision/roles/webdevops-php-apache/tasks/entrypoint.yml b/docker/php-apache-dev/7.1/conf/provision/roles/webdevops-apache-dev/tasks/bootstrap.yml similarity index 100% rename from docker/php-apache/alpine-3-php7/conf/provision/roles/webdevops-php-apache/tasks/entrypoint.yml rename to docker/php-apache-dev/7.1/conf/provision/roles/webdevops-apache-dev/tasks/bootstrap.yml diff --git a/docker/php-apache/alpine-3-php7/conf/provision/roles/webdevops-apache/tasks/main.yml b/docker/php-apache-dev/7.1/conf/provision/roles/webdevops-apache-dev/tasks/main.yml similarity index 100% rename from docker/php-apache/alpine-3-php7/conf/provision/roles/webdevops-apache/tasks/main.yml rename to docker/php-apache-dev/7.1/conf/provision/roles/webdevops-apache-dev/tasks/main.yml diff --git a/docker/php-apache/alpine-3-php7/conf/provision/roles/webdevops-apache/defaults/main.yml b/docker/php-apache-dev/7.1/conf/provision/roles/webdevops-apache/defaults/main.yml similarity index 100% rename from docker/php-apache/alpine-3-php7/conf/provision/roles/webdevops-apache/defaults/main.yml rename to docker/php-apache-dev/7.1/conf/provision/roles/webdevops-apache/defaults/main.yml diff --git a/docker/php-apache-dev/7.1/conf/provision/roles/webdevops-apache/tasks/bootstrap.yml b/docker/php-apache-dev/7.1/conf/provision/roles/webdevops-apache/tasks/bootstrap.yml new file mode 100644 index 000000000..c285be286 --- /dev/null +++ b/docker/php-apache-dev/7.1/conf/provision/roles/webdevops-apache/tasks/bootstrap.yml @@ -0,0 +1,156 @@ +--- + +- name: Set apache vhost file [RedHat family] + set_fact: + apache_main_path: /etc/httpd/ + apache_docker_vhost: /etc/httpd/conf.d/zzz-docker.conf + when: ansible_os_family == 'RedHat' + +- name: Set apache vhost file [Debian family] + set_fact: + apache_main_path: /etc/apache2/ + apache_docker_vhost: /etc/apache2/sites-enabled/10-docker.conf + when: ansible_os_family == 'Debian' + +- name: Set apache vhost file [Alpine family] + set_fact: + apache_main_path: /etc/apache2/ + apache_docker_vhost: /etc/apache2/conf.d/zzz-docker.conf + when: ansible_os_family == 'Alpine' + +- name: Enable apache main config + file: + src: '/opt/docker/etc/httpd/main.conf' + dest: '{{ apache_docker_vhost }}' + state: link + force: yes + +- name: Ensure document root is available + file: + path: "{{ DOCUMENT_ROOT }}" + state: directory + recurse: yes + +- name: Ensure /var/run/apache2 exists + file: + path: '/var/run/apache2' + state: directory + recurse: yes + +- name: Ensure /run/apache2 exists + file: + path: '/run/apache2' + state: directory + recurse: yes + when: ansible_os_family == 'Alpine' + +- name: Find apache2 files + shell: "find '{{ apache_main_path }}' -type f -iname '*.conf' -o -iname 'default*' -o -iname '*log'" + register: apache2_conf_files + +- name: Change CustomLog to Docker stdout + replace: + dest: '{{ item }}' + regexp: '^[\s]*CustomLog ([^\s]+)(.*)' + replace: 'CustomLog /docker.stdout \2' + with_items: "{{ apache2_conf_files.stdout_lines }}" + +- name: Change CustomLog to Docker stdout + replace: + dest: '{{ item }}' + regexp: '^[\s]*ErrorLog ([^\s]+)(.*)' + replace: 'ErrorLog /docker.stdout \2' + with_items: "{{ apache2_conf_files.stdout_lines }}" + +- name: Change TransferLog to Docker stdout + replace: + dest: '{{ item }}' + regexp: '^[\s]*TransferLog ([^\s]+)(.*)' + replace: 'TransferLog /docker.stdout \2' + with_items: "{{ apache2_conf_files.stdout_lines }}" + +- name: Switch MPM to worker [RedHat family] + lineinfile: + dest: '/etc/httpd/conf.modules.d/00-mpm.conf' + regexp: '^[\s#]*{{ item.line }}' + line: '{{ item.prefix }}{{ item.line }}' + with_items: + - { line: 'LoadModule mpm_prefork_module modules/mod_mpm_prefork.so', prefix: "#" } + - { line: 'LoadModule mpm_event_module modules/mod_mpm_event.so', prefix: "" } + when: ansible_os_family == 'RedHat' + +- name: Switch MPM to event for Apache 2.4 and higher [Ubuntu family] + command: "{{ item }}" + with_items: + - 'a2dismod mpm_event' + - 'a2enmod mpm_event' + when: (ansible_distribution == 'Ubuntu' and docker_image_info_distribution_version|int >= 14) or (ansible_distribution == 'Debian' and docker_image_info_distribution_version|int >= 8) + +- name: Manage modules [Alpine family] + lineinfile: + dest: '/etc/apache2/httpd.conf' + regexp: '^[\s#]*{{ item.line }}' + line: '{{ item.prefix }}{{ item.line }}' + with_items: + - { line: 'LoadModule mpm_prefork_module modules/mod_mpm_prefork.so', prefix: "#" } + - { line: 'LoadModule mpm_event_module modules/mod_mpm_event.so', prefix: "" } + - { line: 'LoadModule deflate_module modules/mod_deflate.so', prefix: "" } + - { line: 'LoadModule rewrite_module modules/mod_rewrite.so', prefix: "" } + - { line: 'LoadModule logio_module modules/mod_logio.so', prefix: "" } + - { line: 'LoadModule slotmem_shm_module modules/mod_slotmem_shm.so', prefix: "" } + - { line: 'LoadModule actions_module modules/mod_actions.so', prefix: "" } + - { line: 'LoadModule expires_module modules/mod_expires.so', prefix: "" } + when: ansible_os_family == 'Alpine' + +- name: Fix ssl support [Alpine family] + lineinfile: + dest: '/etc/apache2/conf.d/ssl.conf' + regexp: '{{ item.regexp }}' + line: '{{ item.line }}' + with_items: + - { regexp: 'LoadModule ssl_module', line: 'LoadModule ssl_module /usr/lib/apache2/mod_ssl.so' } + - { regexp: 'LoadModule socache_shmcb_module', line: 'LoadModule socache_shmcb_module /usr/lib/apache2/mod_socache_shmcb.so' } + when: ansible_os_family == 'Alpine' + +- name: Remove default vhost from ssl configuration [Alpine family] + command: sed -i -e '1h;2,$H;$!d;g' -e 's//#-> removed vhost/g' /etc/apache2/conf.d/ssl.conf + when: ansible_os_family == 'Alpine' + +- name: Disable proxy [Alpine family] + lineinfile: + dest: '/etc/apache2/conf.d/proxy.conf' + regexp: '^[\s#]*{{ item.line }}' + line: '{{ item.prefix }}{{ item.line }}' + with_items: + - { line: 'LoadModule proxy_ajp_module modules/mod_proxy_ajp.so', prefix: "#" } + - { line: 'LoadModule proxy_connect_module modules/mod_proxy_connect.so', prefix: "#" } + - { line: 'LoadModule proxy_balancer_module modules/mod_proxy_balancer.so', prefix: "#" } + - { line: 'LoadModule proxy_express_module modules/mod_proxy_express.so', prefix: "#" } + - { line: 'LoadModule proxy_fcgi_module modules/mod_proxy_fcgi.so', prefix: "" } + - { line: 'LoadModule proxy_fdpass_module modules/mod_proxy_fdpass.so', prefix: "#" } + - { line: 'LoadModule proxy_ftp_module modules/mod_proxy_ftp.so', prefix: "#" } + - { line: 'LoadModule proxy_http_module modules/mod_proxy_http.so', prefix: "#" } + - { line: 'LoadModule proxy_scgi_module modules/mod_proxy_scgi.so', prefix: "#" } + when: ansible_os_family == 'Alpine' + +- name: Fix rights of ssl files + file: + path: "{{ item.path }}" + state: "{{ item.state }}" + mode: "{{ item.mode }}" + owner: "root" + group: "root" + with_items: + - { path: '/opt/docker/etc/httpd/ssl', state: 'directory', mode: '0750' } + - { path: '/opt/docker/etc/httpd/ssl/server.crt', state: 'file', mode: '0640' } + - { path: '/opt/docker/etc/httpd/ssl/server.csr', state: 'file', mode: '0640' } + - { path: '/opt/docker/etc/httpd/ssl/server.key', state: 'file', mode: '0640' } + +- name: Maintain lock directory [Debian family] + file: + path: "/var/lock/apache2" + state: "directory" + mode: "0750" + owner: "www-data" + group: "www-data" + when: ansible_os_family == 'Debian' diff --git a/docker/php-apache/alpine-3/conf/provision/roles/webdevops-apache/tasks/main.yml b/docker/php-apache-dev/7.1/conf/provision/roles/webdevops-apache/tasks/main.yml similarity index 100% rename from docker/php-apache/alpine-3/conf/provision/roles/webdevops-apache/tasks/main.yml rename to docker/php-apache-dev/7.1/conf/provision/roles/webdevops-apache/tasks/main.yml diff --git a/docker/php-apache/alpine-3-php7/conf/provision/roles/webdevops-php-apache/defaults/main.yml b/docker/php-apache-dev/7.1/conf/provision/roles/webdevops-php-apache/defaults/main.yml similarity index 100% rename from docker/php-apache/alpine-3-php7/conf/provision/roles/webdevops-php-apache/defaults/main.yml rename to docker/php-apache-dev/7.1/conf/provision/roles/webdevops-php-apache/defaults/main.yml diff --git a/docker/php-apache/alpine-3-php7/conf/provision/roles/webdevops-php-apache/tasks/bootstrap.yml b/docker/php-apache-dev/7.1/conf/provision/roles/webdevops-php-apache/tasks/bootstrap.yml similarity index 100% rename from docker/php-apache/alpine-3-php7/conf/provision/roles/webdevops-php-apache/tasks/bootstrap.yml rename to docker/php-apache-dev/7.1/conf/provision/roles/webdevops-php-apache/tasks/bootstrap.yml diff --git a/docker/php-apache/alpine-3/conf/provision/roles/webdevops-php-apache/tasks/entrypoint.yml b/docker/php-apache-dev/7.1/conf/provision/roles/webdevops-php-apache/tasks/entrypoint.yml similarity index 100% rename from docker/php-apache/alpine-3/conf/provision/roles/webdevops-php-apache/tasks/entrypoint.yml rename to docker/php-apache-dev/7.1/conf/provision/roles/webdevops-php-apache/tasks/entrypoint.yml diff --git a/docker/php-apache/alpine-3-php7/conf/provision/roles/webdevops-php-apache/tasks/main.yml b/docker/php-apache-dev/7.1/conf/provision/roles/webdevops-php-apache/tasks/main.yml similarity index 100% rename from docker/php-apache/alpine-3-php7/conf/provision/roles/webdevops-php-apache/tasks/main.yml rename to docker/php-apache-dev/7.1/conf/provision/roles/webdevops-php-apache/tasks/main.yml diff --git a/docker/php-dev/alpine-3/conf/provision/roles/webdevops-php-dev/defaults/main.yml b/docker/php-apache-dev/7.1/conf/provision/roles/webdevops-php-dev/defaults/main.yml similarity index 100% rename from docker/php-dev/alpine-3/conf/provision/roles/webdevops-php-dev/defaults/main.yml rename to docker/php-apache-dev/7.1/conf/provision/roles/webdevops-php-dev/defaults/main.yml diff --git a/docker/php-apache-dev/7.1/conf/provision/roles/webdevops-php-dev/tasks/bootstrap.yml b/docker/php-apache-dev/7.1/conf/provision/roles/webdevops-php-dev/tasks/bootstrap.yml new file mode 100644 index 000000000..ff02b05fc --- /dev/null +++ b/docker/php-apache-dev/7.1/conf/provision/roles/webdevops-php-dev/tasks/bootstrap.yml @@ -0,0 +1,7 @@ +--- + +- include: bootstrap/php-fpm.yml +- include: bootstrap/php-module.yml +- include: bootstrap/php-module.opcache.yml +- include: bootstrap/php-module.xdebug.yml +- include: bootstrap/php-module.blackfire.yml diff --git a/docker/php-dev/alpine-3-php7/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/php-fpm.yml b/docker/php-apache-dev/7.1/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/php-fpm.yml similarity index 100% rename from docker/php-dev/alpine-3-php7/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/php-fpm.yml rename to docker/php-apache-dev/7.1/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/php-fpm.yml diff --git a/docker/php-apache-dev/7.1/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/php-module.blackfire.yml b/docker/php-apache-dev/7.1/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/php-module.blackfire.yml new file mode 100644 index 000000000..faf05f8de --- /dev/null +++ b/docker/php-apache-dev/7.1/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/php-module.blackfire.yml @@ -0,0 +1,10 @@ +--- + +- name: Remove superfluous blackfire configuration file + file: + path: '{{ item }}' + state: absent + with_items: + - /etc/php5/cli/conf.d/zz-blackfire.ini + - /etc/php5/fpm/conf.d/zz-blackfire.ini + when: ansible_distribution == 'Debian' and docker_image_info_distribution_version|int >= 7 diff --git a/docker/php-dev/alpine-3-php7/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/php-module.opcache.yml b/docker/php-apache-dev/7.1/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/php-module.opcache.yml similarity index 100% rename from docker/php-dev/alpine-3-php7/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/php-module.opcache.yml rename to docker/php-apache-dev/7.1/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/php-module.opcache.yml diff --git a/docker/php-dev/alpine-3-php7/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/php-module.xdebug.yml b/docker/php-apache-dev/7.1/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/php-module.xdebug.yml similarity index 100% rename from docker/php-dev/alpine-3-php7/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/php-module.xdebug.yml rename to docker/php-apache-dev/7.1/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/php-module.xdebug.yml diff --git a/docker/php-dev/alpine-3-php7/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/php-module.yml b/docker/php-apache-dev/7.1/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/php-module.yml similarity index 100% rename from docker/php-dev/alpine-3-php7/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/php-module.yml rename to docker/php-apache-dev/7.1/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/php-module.yml diff --git a/docker/php-dev/alpine-3-php7/conf/provision/roles/webdevops-dev/tasks/main.yml b/docker/php-apache-dev/7.1/conf/provision/roles/webdevops-php-dev/tasks/main.yml similarity index 100% rename from docker/php-dev/alpine-3-php7/conf/provision/roles/webdevops-dev/tasks/main.yml rename to docker/php-apache-dev/7.1/conf/provision/roles/webdevops-php-dev/tasks/main.yml diff --git a/docker/php-apache-dev/alpine b/docker/php-apache-dev/alpine new file mode 120000 index 000000000..a5e678cb6 --- /dev/null +++ b/docker/php-apache-dev/alpine @@ -0,0 +1 @@ +alpine-php7 \ No newline at end of file diff --git a/docker/php-apache-dev/alpine-3 b/docker/php-apache-dev/alpine-3 new file mode 120000 index 000000000..a84cfe247 --- /dev/null +++ b/docker/php-apache-dev/alpine-3 @@ -0,0 +1 @@ +alpine-php5 \ No newline at end of file diff --git a/docker/php-apache-dev/alpine-3-php7 b/docker/php-apache-dev/alpine-3-php7 new file mode 120000 index 000000000..a5e678cb6 --- /dev/null +++ b/docker/php-apache-dev/alpine-3-php7 @@ -0,0 +1 @@ +alpine-php7 \ No newline at end of file diff --git a/docker/php-apache-dev/alpine-3-php7/Dockerfile b/docker/php-apache-dev/alpine-3-php7/Dockerfile deleted file mode 100644 index 6402fdb1b..000000000 --- a/docker/php-apache-dev/alpine-3-php7/Dockerfile +++ /dev/null @@ -1,35 +0,0 @@ -#+++++++++++++++++++++++++++++++++++++++ -# Dockerfile for webdevops/php-apache-dev:alpine-3-php7 -# -- automatically generated -- -#+++++++++++++++++++++++++++++++++++++++ - -FROM webdevops/php-dev:alpine-3-php7 - -MAINTAINER info@webdevops.io -LABEL vendor=WebDevOps.io -LABEL io.webdevops.layout=8 -LABEL io.webdevops.version=1.5.0 - -ENV WEB_DOCUMENT_ROOT /app -ENV WEB_DOCUMENT_INDEX index.php -ENV WEB_ALIAS_DOMAIN *.vm -ENV WEB_PHP_SOCKET 127.0.0.1:9000 -ENV WEB_NO_CACHE_PATTERN "\.(css|js|gif|png|jpg|svg|json|xml)$" - -COPY conf/ /opt/docker/ - -# Install apache -RUN /usr/local/bin/apk-install \ - apache2 \ - apache2-utils \ - apache2-proxy \ - apache2-ssl \ - && sed -ri ' \ - s!^(\s*CustomLog)\s+\S+!\1 /proc/self/fd/1!g; \ - s!^(\s*ErrorLog)\s+\S+!\1 /proc/self/fd/2!g; \ - ' /etc/apache2/httpd.conf \ - && /opt/docker/bin/provision run --tag bootstrap --role webdevops-apache --role webdevops-php-apache --role webdevops-apache-dev --role webdevops-php-dev \ - && /opt/docker/bin/bootstrap.sh - - -EXPOSE 80 443 diff --git a/docker/php-apache-dev/alpine-3-php7/Dockerfile.jinja2 b/docker/php-apache-dev/alpine-3-php7/Dockerfile.jinja2 deleted file mode 100644 index d4a2d1f33..000000000 --- a/docker/php-apache-dev/alpine-3-php7/Dockerfile.jinja2 +++ /dev/null @@ -1,13 +0,0 @@ -{{ docker.from("php-dev", "alpine-3-php7") }} - -{{ docker.version() }} - -{{ environment.web() }} -{{ environment.webPhp() }} -{{ environment.webDevelopment() }} - -{{ docker.copy('conf/', '/opt/docker/') }} - -{{ apache.alpine('php-apache apache-dev php-dev') }} - -{{ docker.expose('80 443') }} diff --git a/docker/php-apache-dev/alpine-3-php7/conf/bin/service.d/httpd.d/10-init.sh b/docker/php-apache-dev/alpine-3-php7/conf/bin/service.d/httpd.d/10-init.sh deleted file mode 100644 index d3f1a0c9c..000000000 --- a/docker/php-apache-dev/alpine-3-php7/conf/bin/service.d/httpd.d/10-init.sh +++ /dev/null @@ -1,19 +0,0 @@ -if [[ ! -e "$WEB_DOCUMENT_ROOT" ]]; then - echo "" - echo "[WARNING] WEB_DOCUMENT_ROOT does not exists with path \"$WEB_DOCUMENT_ROOT\"!" - echo "" -fi - -# Replace markers -find /opt/docker/etc/httpd/ -iname '*.conf' -print0 | xargs -0 -r rpl --quiet "" "$WEB_DOCUMENT_INDEX" > /dev/null -find /opt/docker/etc/httpd/ -iname '*.conf' -print0 | xargs -0 -r rpl --quiet "" "$WEB_DOCUMENT_ROOT" > /dev/null -find /opt/docker/etc/httpd/ -iname '*.conf' -print0 | xargs -0 -r rpl --quiet "" "$WEB_ALIAS_DOMAIN" > /dev/null -find /opt/docker/etc/httpd/ -iname '*.conf' -print0 | xargs -0 -r rpl --quiet "" "$HOSTNAME" > /dev/null - -if [[ -n "${WEB_PHP_SOCKET+x}" ]]; then - ## WEB_PHP_SOCKET is set - find /opt/docker/etc/httpd/ -iname '*.conf' -print0 | xargs -0 -r rpl --quiet "" "$WEB_PHP_SOCKET" > /dev/null -else - ## WEB_PHP_SOCKET is not set, remove PHP files - rm -f -- /opt/docker/etc/httpd/conf.d/10-php.conf -fi diff --git a/docker/php-apache-dev/alpine-3-php7/conf/bin/service.d/httpd.d/12-development.sh b/docker/php-apache-dev/alpine-3-php7/conf/bin/service.d/httpd.d/12-development.sh deleted file mode 100644 index 299f67e2f..000000000 --- a/docker/php-apache-dev/alpine-3-php7/conf/bin/service.d/httpd.d/12-development.sh +++ /dev/null @@ -1 +0,0 @@ -find /opt/docker/etc/httpd/ -iname '*.conf' -print0 | xargs -0 -r rpl --quiet "" "$WEB_NO_CACHE_PATTERN" > /dev/null diff --git a/docker/php-apache-dev/alpine-3-php7/conf/etc/httpd/conf.d/10-log.conf b/docker/php-apache-dev/alpine-3-php7/conf/etc/httpd/conf.d/10-log.conf deleted file mode 100644 index e4c4be4f2..000000000 --- a/docker/php-apache-dev/alpine-3-php7/conf/etc/httpd/conf.d/10-log.conf +++ /dev/null @@ -1,4 +0,0 @@ -LogFormat "[httpd:access] %V:%p %h %l %u %t \"%r\" %>s bytesIn:%I bytesOut:%O reqTime:%T" dockerlog -LogLevel warn -CustomLog /proc/self/fd/1 dockerlog -ErrorLog /proc/self/fd/2 diff --git a/docker/php-apache-dev/alpine-3-php7/conf/provision/entrypoint.d/10-php-debugger.sh b/docker/php-apache-dev/alpine-3-php7/conf/provision/entrypoint.d/10-php-debugger.sh deleted file mode 100644 index 7156e28aa..000000000 --- a/docker/php-apache-dev/alpine-3-php7/conf/provision/entrypoint.d/10-php-debugger.sh +++ /dev/null @@ -1,95 +0,0 @@ -#!/usr/bin/env bash - -################################################# -# Debugger switch -################################################# - -PHP_CONF_PATHS=" -/etc/php5/conf.d -/etc/php7/conf.d -/etc/php.d -/etc/php5/mods-available -/etc/php5/cli/conf.d -/etc/php5/cli/conf.d -/etc/php5/fpm/conf.d -/etc/php5/fpm/conf.d -/etc/php/7.0/mods-available -/etc/php/7.0/cli/conf.d -/etc/php/7.0/fpm/conf.d" - -function phpModuleRemove() { - if [ "$#" -ne 1 ]; then - echo "You must specify the name of the PHP module which you want to disable" - exit 1 - fi - - echo " - Removing PHP module ${1}" - for CONF_PATH in $PHP_CONF_PATHS; do - rm -f "${CONF_PATH}"/*"${1}".ini - done -} - - -if [[ -n "${PHP_DEBUGGER+x}" ]]; then - case "$PHP_DEBUGGER" in - xdebug) - echo "PHP-Debugger: Xdebug enabled" - phpModuleRemove "blackfire" - ;; - - blackfire) - echo "PHP-Debugger: Blackfire enabled" - phpModuleRemove "xdebug" - /opt/docker/bin/control.sh service.enable blackfire-agent - ;; - - none) - echo "PHP-Debugger: none" - phpModuleRemove "blackfire" - phpModuleRemove "xdebug" - ;; - esac - -else - - echo "PHP-Debugger: not specified - default is xdebug" - phpModuleRemove "blackfire" - -fi - -################################################# -# PHP debugger environment variables -################################################# - -function phpEnvironmentVariable() { - PHP_INI_KEY="$1" - PHP_ENV_NAME="$2" - - if [[ -n "${!PHP_ENV_NAME+x}" ]]; then - PHP_ENV_VALUE="${!PHP_ENV_NAME}" - echo "${PHP_INI_KEY}=\"${PHP_ENV_VALUE}\"" >> /opt/docker/etc/php/php.ini - fi -} - -################### -# XDEBUG -################### - -# remote debugger -phpEnvironmentVariable "xdebug.remote_connect_back" "XDEBUG_REMOTE_CONNECT_BACK" -phpEnvironmentVariable "xdebug.remote_autostart" "XDEBUG_REMOTE_AUTOSTART" -phpEnvironmentVariable "xdebug.remote_host" "XDEBUG_REMOTE_HOST" -phpEnvironmentVariable "xdebug.remote_port" "XDEBUG_REMOTE_PORT" - -# profiler -phpEnvironmentVariable "xdebug.profiler_enable" "XDEBUG_PROFILER_ENABLE" -phpEnvironmentVariable "xdebug.profiler_enable_trigger" "XDEBUG_PROFILER_ENABLE_TRIGGER" -phpEnvironmentVariable "xdebug.profiler_enable_trigger_value" "XDEBUG_PROFILER_ENABLE_TRIGGER_VALUE" -phpEnvironmentVariable "xdebug.profiler_output_dir" "XDEBUG_PROFILER_OUTPUT_DIR" -phpEnvironmentVariable "xdebug.profiler_output_name" "XDEBUG_PROFILER_OUTPUT_NAME" - -################### -# BLACKFIRE -################### -phpEnvironmentVariable "blackfire.server_id" "BLACKFIRE_SERVER_ID" -phpEnvironmentVariable "blackfire.server_token" "BLACKFIRE_SERVER_TOKEN" diff --git a/docker/php-apache-dev/alpine-3-php7/conf/provision/roles/webdevops-apache/tasks/bootstrap.yml b/docker/php-apache-dev/alpine-3-php7/conf/provision/roles/webdevops-apache/tasks/bootstrap.yml deleted file mode 100644 index 2be18b0e0..000000000 --- a/docker/php-apache-dev/alpine-3-php7/conf/provision/roles/webdevops-apache/tasks/bootstrap.yml +++ /dev/null @@ -1,156 +0,0 @@ ---- - -- name: Set apache vhost file [RedHat family] - set_fact: - apache_main_path: /etc/httpd/ - apache_docker_vhost: /etc/httpd/conf.d/zzz-docker.conf - when: ansible_os_family == 'RedHat' - -- name: Set apache vhost file [Debian family] - set_fact: - apache_main_path: /etc/apache2/ - apache_docker_vhost: /etc/apache2/sites-enabled/10-docker.conf - when: ansible_os_family == 'Debian' - -- name: Set apache vhost file [Alpine family] - set_fact: - apache_main_path: /etc/apache2/ - apache_docker_vhost: /etc/apache2/conf.d/zzz-docker.conf - when: ansible_os_family == 'Alpine' - -- name: Enable apache main config - file: - src: '/opt/docker/etc/httpd/main.conf' - dest: '{{ apache_docker_vhost }}' - state: link - force: yes - -- name: Ensure document root is available - file: - path: "{{ DOCUMENT_ROOT }}" - state: directory - recurse: yes - -- name: Ensure /var/run/apache2 exists - file: - path: '/var/run/apache2' - state: directory - recurse: yes - -- name: Ensure /run/apache2 exists - file: - path: '/run/apache2' - state: directory - recurse: yes - when: ansible_os_family == 'Alpine' - -- name: Find apache2 files - shell: "find '{{ apache_main_path }}' -type f -iname '*.conf' -o -iname 'default*' -o -iname '*log'" - register: apache2_conf_files - -- name: Change CustomLog to Docker stdout - replace: - dest: '{{ item }}' - regexp: '^[\s]*CustomLog ([^\s]+)(.*)' - replace: 'CustomLog /docker.stdout \2' - with_items: "{{ apache2_conf_files.stdout_lines }}" - -- name: Change CustomLog to Docker stdout - replace: - dest: '{{ item }}' - regexp: '^[\s]*ErrorLog ([^\s]+)(.*)' - replace: 'ErrorLog /docker.stdout \2' - with_items: "{{ apache2_conf_files.stdout_lines }}" - -- name: Change TransferLog to Docker stdout - replace: - dest: '{{ item }}' - regexp: '^[\s]*TransferLog ([^\s]+)(.*)' - replace: 'TransferLog /docker.stdout \2' - with_items: "{{ apache2_conf_files.stdout_lines }}" - -- name: Switch MPM to worker [RedHat family] - lineinfile: - dest: '/etc/httpd/conf.modules.d/00-mpm.conf' - regexp: '^[\s#]*{{ item.line }}' - line: '{{ item.prefix }}{{ item.line }}' - with_items: - - { line: 'LoadModule mpm_prefork_module modules/mod_mpm_prefork.so', prefix: "#" } - - { line: 'LoadModule mpm_event_module modules/mod_mpm_event.so', prefix: "" } - when: ansible_os_family == 'RedHat' - -- name: Switch MPM to event for Apache 2.4 and higher [Ubuntu family] - command: "{{ item }}" - with_items: - - 'a2dismod mpm_event' - - 'a2enmod mpm_event' - when: (ansible_distribution == 'Ubuntu' and ansible_lsb.major_release|int >= 14) or (ansible_distribution == 'Debian' and ansible_lsb.major_release|int >= 8) - -- name: Manage modules [Alpine family] - lineinfile: - dest: '/etc/apache2/httpd.conf' - regexp: '^[\s#]*{{ item.line }}' - line: '{{ item.prefix }}{{ item.line }}' - with_items: - - { line: 'LoadModule mpm_prefork_module modules/mod_mpm_prefork.so', prefix: "#" } - - { line: 'LoadModule mpm_event_module modules/mod_mpm_event.so', prefix: "" } - - { line: 'LoadModule deflate_module modules/mod_deflate.so', prefix: "" } - - { line: 'LoadModule rewrite_module modules/mod_rewrite.so', prefix: "" } - - { line: 'LoadModule logio_module modules/mod_logio.so', prefix: "" } - - { line: 'LoadModule slotmem_shm_module modules/mod_slotmem_shm.so', prefix: "" } - - { line: 'LoadModule actions_module modules/mod_actions.so', prefix: "" } - - { line: 'LoadModule expires_module modules/mod_expires.so', prefix: "" } - when: ansible_os_family == 'Alpine' - -- name: Fix ssl support [Alpine family] - lineinfile: - dest: '/etc/apache2/conf.d/ssl.conf' - regexp: '{{ item.regexp }}' - line: '{{ item.line }}' - with_items: - - { regexp: 'LoadModule ssl_module', line: 'LoadModule ssl_module /usr/lib/apache2/mod_ssl.so' } - - { regexp: 'LoadModule socache_shmcb_module', line: 'LoadModule socache_shmcb_module /usr/lib/apache2/mod_socache_shmcb.so' } - when: ansible_os_family == 'Alpine' - -- name: Remove default vhost from ssl configuration [Alpine family] - command: sed -i -e '1h;2,$H;$!d;g' -e 's//#-> removed vhost/g' /etc/apache2/conf.d/ssl.conf - when: ansible_os_family == 'Alpine' - -- name: Disable proxy [Alpine family] - lineinfile: - dest: '/etc/apache2/conf.d/proxy.conf' - regexp: '^[\s#]*{{ item.line }}' - line: '{{ item.prefix }}{{ item.line }}' - with_items: - - { line: 'LoadModule proxy_ajp_module modules/mod_proxy_ajp.so', prefix: "#" } - - { line: 'LoadModule proxy_connect_module modules/mod_proxy_connect.so', prefix: "#" } - - { line: 'LoadModule proxy_balancer_module modules/mod_proxy_balancer.so', prefix: "#" } - - { line: 'LoadModule proxy_express_module modules/mod_proxy_express.so', prefix: "#" } - - { line: 'LoadModule proxy_fcgi_module modules/mod_proxy_fcgi.so', prefix: "" } - - { line: 'LoadModule proxy_fdpass_module modules/mod_proxy_fdpass.so', prefix: "#" } - - { line: 'LoadModule proxy_ftp_module modules/mod_proxy_ftp.so', prefix: "#" } - - { line: 'LoadModule proxy_http_module modules/mod_proxy_http.so', prefix: "#" } - - { line: 'LoadModule proxy_scgi_module modules/mod_proxy_scgi.so', prefix: "#" } - when: ansible_os_family == 'Alpine' - -- name: Fix rights of ssl files - file: - path: "{{ item.path }}" - state: "{{ item.state }}" - mode: "{{ item.mode }}" - owner: "root" - group: "root" - with_items: - - { path: '/opt/docker/etc/httpd/ssl', state: 'directory', mode: '0750' } - - { path: '/opt/docker/etc/httpd/ssl/server.crt', state: 'file', mode: '0640' } - - { path: '/opt/docker/etc/httpd/ssl/server.csr', state: 'file', mode: '0640' } - - { path: '/opt/docker/etc/httpd/ssl/server.key', state: 'file', mode: '0640' } - -- name: Maintain lock directory [Debian family] - file: - path: "/var/lock/apache2" - state: "directory" - mode: "0750" - owner: "www-data" - group: "www-data" - when: ansible_os_family == 'Debian' diff --git a/docker/php-apache-dev/alpine-3-php7/conf/provision/roles/webdevops-php-dev/tasks/bootstrap.yml b/docker/php-apache-dev/alpine-3-php7/conf/provision/roles/webdevops-php-dev/tasks/bootstrap.yml deleted file mode 100644 index 2c5d76e3d..000000000 --- a/docker/php-apache-dev/alpine-3-php7/conf/provision/roles/webdevops-php-dev/tasks/bootstrap.yml +++ /dev/null @@ -1,8 +0,0 @@ ---- - -- include: bootstrap/tools.yml -- include: bootstrap/php-fpm.yml -- include: bootstrap/php-module.yml -- include: bootstrap/php-module.opcache.yml -- include: bootstrap/php-module.xdebug.yml -- include: bootstrap/php-module.blackfire.yml diff --git a/docker/php-apache-dev/alpine-3-php7/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/php-module.blackfire.yml b/docker/php-apache-dev/alpine-3-php7/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/php-module.blackfire.yml deleted file mode 100644 index 1a3db9bac..000000000 --- a/docker/php-apache-dev/alpine-3-php7/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/php-module.blackfire.yml +++ /dev/null @@ -1,10 +0,0 @@ ---- - -- name: Remove superfluous blackfire configuration file - file: - path: '{{ item }}' - state: absent - with_items: - - /etc/php5/cli/conf.d/zz-blackfire.ini - - /etc/php5/fpm/conf.d/zz-blackfire.ini - when: ansible_distribution == 'Debian' and ansible_lsb.major_release|int >= 7 diff --git a/docker/php-apache-dev/alpine-3-php7/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/tools.yml b/docker/php-apache-dev/alpine-3-php7/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/tools.yml deleted file mode 100644 index c49cb0e34..000000000 --- a/docker/php-apache-dev/alpine-3-php7/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/tools.yml +++ /dev/null @@ -1,23 +0,0 @@ ---- - -- name: Downloading Tools - shell: curl -o "{{ item.dest }}" "{{ item.url }}" && chmod 755 "{{ item.dest }}" - with_items: - - { url: "https://phar.phpunit.de/phploc.phar", dest: /usr/local/bin/phploc } - - { url: "https://phar.phpunit.de/phpunit.phar", dest: /usr/local/bin/phpunit } - - { url: "http://static.pdepend.org/php/latest/pdepend.phar", dest: /usr/local/bin/pdepend } - - { url: "http://static.phpmd.org/php/latest/phpmd.phar", dest: /usr/local/bin/phpmd } - - { url: "https://squizlabs.github.io/PHP_CodeSniffer/phpcs.phar", dest: /usr/local/bin/phpcs } - - { url: "https://squizlabs.github.io/PHP_CodeSniffer/phpcbf.phar", dest: /usr/local/bin/phpcbf } - - { url: "https://phar.phpunit.de/phpcpd.phar", dest: /usr/local/bin/phpcpd } - - { url: "https://phar.phpunit.de/phpdcd.phar", dest: /usr/local/bin/phpdcd } - - { url: "https://github.com/Halleck45/PhpMetrics/raw/master/build/phpmetrics.phar", dest: /usr/local/bin/phpmetrics } - - { url: "http://get.sensiolabs.org/php-cs-fixer.phar", dest: /usr/local/bin/php-cs-fixer } - - { url: "https://github.com/sensiolabs-de/deprecation-detector/releases/download/0.1.0-alpha4/deprecation-detector.phar", dest: /usr/local/bin/deprecation-detector } - - { url: "https://github.com/sensiolabs-de/deprecation-detector/releases/download/0.1.0-alpha4/deprecation-detector.phar", dest: /usr/local/bin/deprecation-detector } - -- name: Install Tools via composer - raw: COMPOSER_HOME="/usr/local/composer" COMPOSER_BIN_DIR="/usr/local/bin" composer global require "{{ item.package }}" "{{ item.version }}" - with_items: - - { package: "sstalle/php7cc" , version: "*" } - - { package: "phpspec/phpspec" , version: "~2.0" } diff --git a/docker/php-apache-dev/alpine-3/Dockerfile b/docker/php-apache-dev/alpine-3/Dockerfile deleted file mode 100644 index 2dc02048a..000000000 --- a/docker/php-apache-dev/alpine-3/Dockerfile +++ /dev/null @@ -1,35 +0,0 @@ -#+++++++++++++++++++++++++++++++++++++++ -# Dockerfile for webdevops/php-apache-dev:alpine-3 -# -- automatically generated -- -#+++++++++++++++++++++++++++++++++++++++ - -FROM webdevops/php-dev:alpine-3 - -MAINTAINER info@webdevops.io -LABEL vendor=WebDevOps.io -LABEL io.webdevops.layout=8 -LABEL io.webdevops.version=1.5.0 - -ENV WEB_DOCUMENT_ROOT /app -ENV WEB_DOCUMENT_INDEX index.php -ENV WEB_ALIAS_DOMAIN *.vm -ENV WEB_PHP_SOCKET 127.0.0.1:9000 -ENV WEB_NO_CACHE_PATTERN "\.(css|js|gif|png|jpg|svg|json|xml)$" - -COPY conf/ /opt/docker/ - -# Install apache -RUN /usr/local/bin/apk-install \ - apache2 \ - apache2-utils \ - apache2-proxy \ - apache2-ssl \ - && sed -ri ' \ - s!^(\s*CustomLog)\s+\S+!\1 /proc/self/fd/1!g; \ - s!^(\s*ErrorLog)\s+\S+!\1 /proc/self/fd/2!g; \ - ' /etc/apache2/httpd.conf \ - && /opt/docker/bin/provision run --tag bootstrap --role webdevops-apache --role webdevops-php-apache --role webdevops-apache-dev --role webdevops-php-dev \ - && /opt/docker/bin/bootstrap.sh - - -EXPOSE 80 443 diff --git a/docker/php-apache-dev/alpine-3/Dockerfile.jinja2 b/docker/php-apache-dev/alpine-3/Dockerfile.jinja2 deleted file mode 100644 index 515caa477..000000000 --- a/docker/php-apache-dev/alpine-3/Dockerfile.jinja2 +++ /dev/null @@ -1,13 +0,0 @@ -{{ docker.from("php-dev", "alpine-3") }} - -{{ docker.version() }} - -{{ environment.web() }} -{{ environment.webPhp() }} -{{ environment.webDevelopment() }} - -{{ docker.copy('conf/', '/opt/docker/') }} - -{{ apache.alpine('php-apache apache-dev php-dev') }} - -{{ docker.expose('80 443') }} diff --git a/docker/php-apache-dev/alpine-3/conf/bin/service.d/httpd.d/10-init.sh b/docker/php-apache-dev/alpine-3/conf/bin/service.d/httpd.d/10-init.sh deleted file mode 100644 index d3f1a0c9c..000000000 --- a/docker/php-apache-dev/alpine-3/conf/bin/service.d/httpd.d/10-init.sh +++ /dev/null @@ -1,19 +0,0 @@ -if [[ ! -e "$WEB_DOCUMENT_ROOT" ]]; then - echo "" - echo "[WARNING] WEB_DOCUMENT_ROOT does not exists with path \"$WEB_DOCUMENT_ROOT\"!" - echo "" -fi - -# Replace markers -find /opt/docker/etc/httpd/ -iname '*.conf' -print0 | xargs -0 -r rpl --quiet "" "$WEB_DOCUMENT_INDEX" > /dev/null -find /opt/docker/etc/httpd/ -iname '*.conf' -print0 | xargs -0 -r rpl --quiet "" "$WEB_DOCUMENT_ROOT" > /dev/null -find /opt/docker/etc/httpd/ -iname '*.conf' -print0 | xargs -0 -r rpl --quiet "" "$WEB_ALIAS_DOMAIN" > /dev/null -find /opt/docker/etc/httpd/ -iname '*.conf' -print0 | xargs -0 -r rpl --quiet "" "$HOSTNAME" > /dev/null - -if [[ -n "${WEB_PHP_SOCKET+x}" ]]; then - ## WEB_PHP_SOCKET is set - find /opt/docker/etc/httpd/ -iname '*.conf' -print0 | xargs -0 -r rpl --quiet "" "$WEB_PHP_SOCKET" > /dev/null -else - ## WEB_PHP_SOCKET is not set, remove PHP files - rm -f -- /opt/docker/etc/httpd/conf.d/10-php.conf -fi diff --git a/docker/php-apache-dev/alpine-3/conf/bin/service.d/httpd.d/12-development.sh b/docker/php-apache-dev/alpine-3/conf/bin/service.d/httpd.d/12-development.sh deleted file mode 100644 index 299f67e2f..000000000 --- a/docker/php-apache-dev/alpine-3/conf/bin/service.d/httpd.d/12-development.sh +++ /dev/null @@ -1 +0,0 @@ -find /opt/docker/etc/httpd/ -iname '*.conf' -print0 | xargs -0 -r rpl --quiet "" "$WEB_NO_CACHE_PATTERN" > /dev/null diff --git a/docker/php-apache-dev/alpine-3/conf/etc/httpd/conf.d/10-log.conf b/docker/php-apache-dev/alpine-3/conf/etc/httpd/conf.d/10-log.conf deleted file mode 100644 index e4c4be4f2..000000000 --- a/docker/php-apache-dev/alpine-3/conf/etc/httpd/conf.d/10-log.conf +++ /dev/null @@ -1,4 +0,0 @@ -LogFormat "[httpd:access] %V:%p %h %l %u %t \"%r\" %>s bytesIn:%I bytesOut:%O reqTime:%T" dockerlog -LogLevel warn -CustomLog /proc/self/fd/1 dockerlog -ErrorLog /proc/self/fd/2 diff --git a/docker/php-apache-dev/alpine-3/conf/provision/entrypoint.d/10-php-debugger.sh b/docker/php-apache-dev/alpine-3/conf/provision/entrypoint.d/10-php-debugger.sh deleted file mode 100644 index 7156e28aa..000000000 --- a/docker/php-apache-dev/alpine-3/conf/provision/entrypoint.d/10-php-debugger.sh +++ /dev/null @@ -1,95 +0,0 @@ -#!/usr/bin/env bash - -################################################# -# Debugger switch -################################################# - -PHP_CONF_PATHS=" -/etc/php5/conf.d -/etc/php7/conf.d -/etc/php.d -/etc/php5/mods-available -/etc/php5/cli/conf.d -/etc/php5/cli/conf.d -/etc/php5/fpm/conf.d -/etc/php5/fpm/conf.d -/etc/php/7.0/mods-available -/etc/php/7.0/cli/conf.d -/etc/php/7.0/fpm/conf.d" - -function phpModuleRemove() { - if [ "$#" -ne 1 ]; then - echo "You must specify the name of the PHP module which you want to disable" - exit 1 - fi - - echo " - Removing PHP module ${1}" - for CONF_PATH in $PHP_CONF_PATHS; do - rm -f "${CONF_PATH}"/*"${1}".ini - done -} - - -if [[ -n "${PHP_DEBUGGER+x}" ]]; then - case "$PHP_DEBUGGER" in - xdebug) - echo "PHP-Debugger: Xdebug enabled" - phpModuleRemove "blackfire" - ;; - - blackfire) - echo "PHP-Debugger: Blackfire enabled" - phpModuleRemove "xdebug" - /opt/docker/bin/control.sh service.enable blackfire-agent - ;; - - none) - echo "PHP-Debugger: none" - phpModuleRemove "blackfire" - phpModuleRemove "xdebug" - ;; - esac - -else - - echo "PHP-Debugger: not specified - default is xdebug" - phpModuleRemove "blackfire" - -fi - -################################################# -# PHP debugger environment variables -################################################# - -function phpEnvironmentVariable() { - PHP_INI_KEY="$1" - PHP_ENV_NAME="$2" - - if [[ -n "${!PHP_ENV_NAME+x}" ]]; then - PHP_ENV_VALUE="${!PHP_ENV_NAME}" - echo "${PHP_INI_KEY}=\"${PHP_ENV_VALUE}\"" >> /opt/docker/etc/php/php.ini - fi -} - -################### -# XDEBUG -################### - -# remote debugger -phpEnvironmentVariable "xdebug.remote_connect_back" "XDEBUG_REMOTE_CONNECT_BACK" -phpEnvironmentVariable "xdebug.remote_autostart" "XDEBUG_REMOTE_AUTOSTART" -phpEnvironmentVariable "xdebug.remote_host" "XDEBUG_REMOTE_HOST" -phpEnvironmentVariable "xdebug.remote_port" "XDEBUG_REMOTE_PORT" - -# profiler -phpEnvironmentVariable "xdebug.profiler_enable" "XDEBUG_PROFILER_ENABLE" -phpEnvironmentVariable "xdebug.profiler_enable_trigger" "XDEBUG_PROFILER_ENABLE_TRIGGER" -phpEnvironmentVariable "xdebug.profiler_enable_trigger_value" "XDEBUG_PROFILER_ENABLE_TRIGGER_VALUE" -phpEnvironmentVariable "xdebug.profiler_output_dir" "XDEBUG_PROFILER_OUTPUT_DIR" -phpEnvironmentVariable "xdebug.profiler_output_name" "XDEBUG_PROFILER_OUTPUT_NAME" - -################### -# BLACKFIRE -################### -phpEnvironmentVariable "blackfire.server_id" "BLACKFIRE_SERVER_ID" -phpEnvironmentVariable "blackfire.server_token" "BLACKFIRE_SERVER_TOKEN" diff --git a/docker/php-apache-dev/alpine-3/conf/provision/roles/webdevops-apache/tasks/bootstrap.yml b/docker/php-apache-dev/alpine-3/conf/provision/roles/webdevops-apache/tasks/bootstrap.yml deleted file mode 100644 index 2be18b0e0..000000000 --- a/docker/php-apache-dev/alpine-3/conf/provision/roles/webdevops-apache/tasks/bootstrap.yml +++ /dev/null @@ -1,156 +0,0 @@ ---- - -- name: Set apache vhost file [RedHat family] - set_fact: - apache_main_path: /etc/httpd/ - apache_docker_vhost: /etc/httpd/conf.d/zzz-docker.conf - when: ansible_os_family == 'RedHat' - -- name: Set apache vhost file [Debian family] - set_fact: - apache_main_path: /etc/apache2/ - apache_docker_vhost: /etc/apache2/sites-enabled/10-docker.conf - when: ansible_os_family == 'Debian' - -- name: Set apache vhost file [Alpine family] - set_fact: - apache_main_path: /etc/apache2/ - apache_docker_vhost: /etc/apache2/conf.d/zzz-docker.conf - when: ansible_os_family == 'Alpine' - -- name: Enable apache main config - file: - src: '/opt/docker/etc/httpd/main.conf' - dest: '{{ apache_docker_vhost }}' - state: link - force: yes - -- name: Ensure document root is available - file: - path: "{{ DOCUMENT_ROOT }}" - state: directory - recurse: yes - -- name: Ensure /var/run/apache2 exists - file: - path: '/var/run/apache2' - state: directory - recurse: yes - -- name: Ensure /run/apache2 exists - file: - path: '/run/apache2' - state: directory - recurse: yes - when: ansible_os_family == 'Alpine' - -- name: Find apache2 files - shell: "find '{{ apache_main_path }}' -type f -iname '*.conf' -o -iname 'default*' -o -iname '*log'" - register: apache2_conf_files - -- name: Change CustomLog to Docker stdout - replace: - dest: '{{ item }}' - regexp: '^[\s]*CustomLog ([^\s]+)(.*)' - replace: 'CustomLog /docker.stdout \2' - with_items: "{{ apache2_conf_files.stdout_lines }}" - -- name: Change CustomLog to Docker stdout - replace: - dest: '{{ item }}' - regexp: '^[\s]*ErrorLog ([^\s]+)(.*)' - replace: 'ErrorLog /docker.stdout \2' - with_items: "{{ apache2_conf_files.stdout_lines }}" - -- name: Change TransferLog to Docker stdout - replace: - dest: '{{ item }}' - regexp: '^[\s]*TransferLog ([^\s]+)(.*)' - replace: 'TransferLog /docker.stdout \2' - with_items: "{{ apache2_conf_files.stdout_lines }}" - -- name: Switch MPM to worker [RedHat family] - lineinfile: - dest: '/etc/httpd/conf.modules.d/00-mpm.conf' - regexp: '^[\s#]*{{ item.line }}' - line: '{{ item.prefix }}{{ item.line }}' - with_items: - - { line: 'LoadModule mpm_prefork_module modules/mod_mpm_prefork.so', prefix: "#" } - - { line: 'LoadModule mpm_event_module modules/mod_mpm_event.so', prefix: "" } - when: ansible_os_family == 'RedHat' - -- name: Switch MPM to event for Apache 2.4 and higher [Ubuntu family] - command: "{{ item }}" - with_items: - - 'a2dismod mpm_event' - - 'a2enmod mpm_event' - when: (ansible_distribution == 'Ubuntu' and ansible_lsb.major_release|int >= 14) or (ansible_distribution == 'Debian' and ansible_lsb.major_release|int >= 8) - -- name: Manage modules [Alpine family] - lineinfile: - dest: '/etc/apache2/httpd.conf' - regexp: '^[\s#]*{{ item.line }}' - line: '{{ item.prefix }}{{ item.line }}' - with_items: - - { line: 'LoadModule mpm_prefork_module modules/mod_mpm_prefork.so', prefix: "#" } - - { line: 'LoadModule mpm_event_module modules/mod_mpm_event.so', prefix: "" } - - { line: 'LoadModule deflate_module modules/mod_deflate.so', prefix: "" } - - { line: 'LoadModule rewrite_module modules/mod_rewrite.so', prefix: "" } - - { line: 'LoadModule logio_module modules/mod_logio.so', prefix: "" } - - { line: 'LoadModule slotmem_shm_module modules/mod_slotmem_shm.so', prefix: "" } - - { line: 'LoadModule actions_module modules/mod_actions.so', prefix: "" } - - { line: 'LoadModule expires_module modules/mod_expires.so', prefix: "" } - when: ansible_os_family == 'Alpine' - -- name: Fix ssl support [Alpine family] - lineinfile: - dest: '/etc/apache2/conf.d/ssl.conf' - regexp: '{{ item.regexp }}' - line: '{{ item.line }}' - with_items: - - { regexp: 'LoadModule ssl_module', line: 'LoadModule ssl_module /usr/lib/apache2/mod_ssl.so' } - - { regexp: 'LoadModule socache_shmcb_module', line: 'LoadModule socache_shmcb_module /usr/lib/apache2/mod_socache_shmcb.so' } - when: ansible_os_family == 'Alpine' - -- name: Remove default vhost from ssl configuration [Alpine family] - command: sed -i -e '1h;2,$H;$!d;g' -e 's//#-> removed vhost/g' /etc/apache2/conf.d/ssl.conf - when: ansible_os_family == 'Alpine' - -- name: Disable proxy [Alpine family] - lineinfile: - dest: '/etc/apache2/conf.d/proxy.conf' - regexp: '^[\s#]*{{ item.line }}' - line: '{{ item.prefix }}{{ item.line }}' - with_items: - - { line: 'LoadModule proxy_ajp_module modules/mod_proxy_ajp.so', prefix: "#" } - - { line: 'LoadModule proxy_connect_module modules/mod_proxy_connect.so', prefix: "#" } - - { line: 'LoadModule proxy_balancer_module modules/mod_proxy_balancer.so', prefix: "#" } - - { line: 'LoadModule proxy_express_module modules/mod_proxy_express.so', prefix: "#" } - - { line: 'LoadModule proxy_fcgi_module modules/mod_proxy_fcgi.so', prefix: "" } - - { line: 'LoadModule proxy_fdpass_module modules/mod_proxy_fdpass.so', prefix: "#" } - - { line: 'LoadModule proxy_ftp_module modules/mod_proxy_ftp.so', prefix: "#" } - - { line: 'LoadModule proxy_http_module modules/mod_proxy_http.so', prefix: "#" } - - { line: 'LoadModule proxy_scgi_module modules/mod_proxy_scgi.so', prefix: "#" } - when: ansible_os_family == 'Alpine' - -- name: Fix rights of ssl files - file: - path: "{{ item.path }}" - state: "{{ item.state }}" - mode: "{{ item.mode }}" - owner: "root" - group: "root" - with_items: - - { path: '/opt/docker/etc/httpd/ssl', state: 'directory', mode: '0750' } - - { path: '/opt/docker/etc/httpd/ssl/server.crt', state: 'file', mode: '0640' } - - { path: '/opt/docker/etc/httpd/ssl/server.csr', state: 'file', mode: '0640' } - - { path: '/opt/docker/etc/httpd/ssl/server.key', state: 'file', mode: '0640' } - -- name: Maintain lock directory [Debian family] - file: - path: "/var/lock/apache2" - state: "directory" - mode: "0750" - owner: "www-data" - group: "www-data" - when: ansible_os_family == 'Debian' diff --git a/docker/php-apache-dev/alpine-3/conf/provision/roles/webdevops-php-dev/tasks/bootstrap.yml b/docker/php-apache-dev/alpine-3/conf/provision/roles/webdevops-php-dev/tasks/bootstrap.yml deleted file mode 100644 index 2c5d76e3d..000000000 --- a/docker/php-apache-dev/alpine-3/conf/provision/roles/webdevops-php-dev/tasks/bootstrap.yml +++ /dev/null @@ -1,8 +0,0 @@ ---- - -- include: bootstrap/tools.yml -- include: bootstrap/php-fpm.yml -- include: bootstrap/php-module.yml -- include: bootstrap/php-module.opcache.yml -- include: bootstrap/php-module.xdebug.yml -- include: bootstrap/php-module.blackfire.yml diff --git a/docker/php-apache-dev/alpine-3/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/php-module.blackfire.yml b/docker/php-apache-dev/alpine-3/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/php-module.blackfire.yml deleted file mode 100644 index 1a3db9bac..000000000 --- a/docker/php-apache-dev/alpine-3/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/php-module.blackfire.yml +++ /dev/null @@ -1,10 +0,0 @@ ---- - -- name: Remove superfluous blackfire configuration file - file: - path: '{{ item }}' - state: absent - with_items: - - /etc/php5/cli/conf.d/zz-blackfire.ini - - /etc/php5/fpm/conf.d/zz-blackfire.ini - when: ansible_distribution == 'Debian' and ansible_lsb.major_release|int >= 7 diff --git a/docker/php-apache-dev/alpine-3/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/tools.yml b/docker/php-apache-dev/alpine-3/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/tools.yml deleted file mode 100644 index c49cb0e34..000000000 --- a/docker/php-apache-dev/alpine-3/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/tools.yml +++ /dev/null @@ -1,23 +0,0 @@ ---- - -- name: Downloading Tools - shell: curl -o "{{ item.dest }}" "{{ item.url }}" && chmod 755 "{{ item.dest }}" - with_items: - - { url: "https://phar.phpunit.de/phploc.phar", dest: /usr/local/bin/phploc } - - { url: "https://phar.phpunit.de/phpunit.phar", dest: /usr/local/bin/phpunit } - - { url: "http://static.pdepend.org/php/latest/pdepend.phar", dest: /usr/local/bin/pdepend } - - { url: "http://static.phpmd.org/php/latest/phpmd.phar", dest: /usr/local/bin/phpmd } - - { url: "https://squizlabs.github.io/PHP_CodeSniffer/phpcs.phar", dest: /usr/local/bin/phpcs } - - { url: "https://squizlabs.github.io/PHP_CodeSniffer/phpcbf.phar", dest: /usr/local/bin/phpcbf } - - { url: "https://phar.phpunit.de/phpcpd.phar", dest: /usr/local/bin/phpcpd } - - { url: "https://phar.phpunit.de/phpdcd.phar", dest: /usr/local/bin/phpdcd } - - { url: "https://github.com/Halleck45/PhpMetrics/raw/master/build/phpmetrics.phar", dest: /usr/local/bin/phpmetrics } - - { url: "http://get.sensiolabs.org/php-cs-fixer.phar", dest: /usr/local/bin/php-cs-fixer } - - { url: "https://github.com/sensiolabs-de/deprecation-detector/releases/download/0.1.0-alpha4/deprecation-detector.phar", dest: /usr/local/bin/deprecation-detector } - - { url: "https://github.com/sensiolabs-de/deprecation-detector/releases/download/0.1.0-alpha4/deprecation-detector.phar", dest: /usr/local/bin/deprecation-detector } - -- name: Install Tools via composer - raw: COMPOSER_HOME="/usr/local/composer" COMPOSER_BIN_DIR="/usr/local/bin" composer global require "{{ item.package }}" "{{ item.version }}" - with_items: - - { package: "sstalle/php7cc" , version: "*" } - - { package: "phpspec/phpspec" , version: "~2.0" } diff --git a/docker/php-apache-dev/alpine-php5/Dockerfile b/docker/php-apache-dev/alpine-php5/Dockerfile new file mode 100644 index 000000000..6c27a1db3 --- /dev/null +++ b/docker/php-apache-dev/alpine-php5/Dockerfile @@ -0,0 +1,30 @@ +#+++++++++++++++++++++++++++++++++++++++ +# Dockerfile for webdevops/php-apache-dev:alpine-php5 +# -- automatically generated -- +#+++++++++++++++++++++++++++++++++++++++ + +FROM webdevops/php-dev:alpine-php5 + +ENV WEB_DOCUMENT_ROOT=/app \ + WEB_DOCUMENT_INDEX=index.php \ + WEB_ALIAS_DOMAIN=*.vm +ENV WEB_PHP_SOCKET=127.0.0.1:9000 +ENV WEB_NO_CACHE_PATTERN="\.(css|js|gif|png|jpg|svg|json|xml)$" + +COPY conf/ /opt/docker/ + +# Install apache +RUN /usr/local/bin/apk-install \ + apache2 \ + apache2-utils \ + apache2-proxy \ + apache2-ssl \ + && sed -ri ' \ + s!^(\s*CustomLog)\s+\S+!\1 /proc/self/fd/1!g; \ + s!^(\s*ErrorLog)\s+\S+!\1 /proc/self/fd/2!g; \ + ' /etc/apache2/httpd.conf \ + && /opt/docker/bin/provision run --tag bootstrap --role webdevops-apache --role webdevops-php-apache --role webdevops-apache-dev --role webdevops-php-dev \ + && /opt/docker/bin/bootstrap.sh \ + && docker-image-cleanup + +EXPOSE 80 443 diff --git a/docker/php-apache-dev/alpine-php5/Dockerfile.jinja2 b/docker/php-apache-dev/alpine-php5/Dockerfile.jinja2 new file mode 100644 index 000000000..f18d03f22 --- /dev/null +++ b/docker/php-apache-dev/alpine-php5/Dockerfile.jinja2 @@ -0,0 +1,11 @@ +{{ docker.from("php-dev", "alpine-php5") }} + +{{ environment.web() }} +{{ environment.webPhp() }} +{{ environment.webDevelopment() }} + +{{ docker.copy('conf/', '/opt/docker/') }} + +{{ apache.alpine('php-apache apache-dev php-dev') }} + +{{ docker.expose('80 443') }} diff --git a/docker/php-dev/alpine-3/conf/bin/service.d/blackfire-agent.d/10-init.sh b/docker/php-apache-dev/alpine-php5/conf/bin/service.d/blackfire-agent.d/10-init.sh similarity index 100% rename from docker/php-dev/alpine-3/conf/bin/service.d/blackfire-agent.d/10-init.sh rename to docker/php-apache-dev/alpine-php5/conf/bin/service.d/blackfire-agent.d/10-init.sh diff --git a/docker/php-dev/alpine-3/conf/bin/service.d/blackfire-agent.sh b/docker/php-apache-dev/alpine-php5/conf/bin/service.d/blackfire-agent.sh similarity index 100% rename from docker/php-dev/alpine-3/conf/bin/service.d/blackfire-agent.sh rename to docker/php-apache-dev/alpine-php5/conf/bin/service.d/blackfire-agent.sh diff --git a/docker/php-apache-dev/alpine-php5/conf/bin/service.d/httpd.d/10-init.sh b/docker/php-apache-dev/alpine-php5/conf/bin/service.d/httpd.d/10-init.sh new file mode 100644 index 000000000..b9d57997e --- /dev/null +++ b/docker/php-apache-dev/alpine-php5/conf/bin/service.d/httpd.d/10-init.sh @@ -0,0 +1,21 @@ +if [[ ! -e "$WEB_DOCUMENT_ROOT" ]]; then + echo "" + echo "[WARNING] WEB_DOCUMENT_ROOT does not exists with path \"$WEB_DOCUMENT_ROOT\"!" + echo "" +fi + +# Replace markers +go-replace \ + -s "" -r "$WEB_DOCUMENT_INDEX" \ + -s "" -r "$WEB_DOCUMENT_ROOT" \ + -s "" -r "$WEB_ALIAS_DOMAIN" \ + -s "" -r "$HOSTNAME" \ + -s "" -r "$WEB_PHP_SOCKET" \ + --path=/opt/docker/etc/httpd/ \ + --path-pattern='*.conf' \ + --ignore-empty + +if [[ -z "${WEB_PHP_SOCKET+x}" ]]; then + ## WEB_PHP_SOCKET is not set, remove PHP files + rm -f -- /opt/docker/etc/httpd/conf.d/10-php.conf +fi diff --git a/docker/php-apache-dev/alpine-php5/conf/bin/service.d/httpd.d/12-development.sh b/docker/php-apache-dev/alpine-php5/conf/bin/service.d/httpd.d/12-development.sh new file mode 100644 index 000000000..a9d2c6e92 --- /dev/null +++ b/docker/php-apache-dev/alpine-php5/conf/bin/service.d/httpd.d/12-development.sh @@ -0,0 +1,5 @@ +go-replace \ + -s "" -r "$WEB_NO_CACHE_PATTERN" \ + --path=/opt/docker/etc/httpd/ \ + --path-pattern='*.conf' \ + --ignore-empty diff --git a/docker/php-apache-dev/alpine-3-php7/conf/bin/service.d/httpd.sh b/docker/php-apache-dev/alpine-php5/conf/bin/service.d/httpd.sh similarity index 100% rename from docker/php-apache-dev/alpine-3-php7/conf/bin/service.d/httpd.sh rename to docker/php-apache-dev/alpine-php5/conf/bin/service.d/httpd.sh diff --git a/docker/php-apache-dev/alpine-php5/conf/etc/httpd/conf.d/.gitkeep b/docker/php-apache-dev/alpine-php5/conf/etc/httpd/conf.d/.gitkeep new file mode 100644 index 000000000..e69de29bb diff --git a/docker/php-apache-dev/alpine-php5/conf/etc/httpd/conf.d/02-dev.conf b/docker/php-apache-dev/alpine-php5/conf/etc/httpd/conf.d/02-dev.conf new file mode 100644 index 000000000..75e5f4396 --- /dev/null +++ b/docker/php-apache-dev/alpine-php5/conf/etc/httpd/conf.d/02-dev.conf @@ -0,0 +1,8 @@ +# EnableSendfile: Control whether the sendfile kernel support is +# used to deliver files (assuming that the OS supports it). +# The default is on; turn this off if you serve from NFS-mounted +# filesystems. Please see +# http://httpd.apache.org/docs/2.2/mod/core.html#enablesendfile +EnableSendfile off + +LogLevel info diff --git a/docker/php-apache/alpine-3/conf/etc/httpd/conf.d/10-error-document.conf b/docker/php-apache-dev/alpine-php5/conf/etc/httpd/conf.d/10-error-document.conf similarity index 100% rename from docker/php-apache/alpine-3/conf/etc/httpd/conf.d/10-error-document.conf rename to docker/php-apache-dev/alpine-php5/conf/etc/httpd/conf.d/10-error-document.conf diff --git a/docker/php-apache-dev/alpine-php5/conf/etc/httpd/conf.d/10-log.conf b/docker/php-apache-dev/alpine-php5/conf/etc/httpd/conf.d/10-log.conf new file mode 100644 index 000000000..ef0c73d38 --- /dev/null +++ b/docker/php-apache-dev/alpine-php5/conf/etc/httpd/conf.d/10-log.conf @@ -0,0 +1,4 @@ +LogFormat "[httpd:access] %V:%p %h %l %u %t \"%r\" %>s bytesIn:%I bytesOut:%O reqTime:%T" dockerlog +LogLevel warn +CustomLog /docker.stdout dockerlog +ErrorLog /docker.stderr diff --git a/docker/php-apache/alpine-3/conf/etc/httpd/conf.d/10-php.conf b/docker/php-apache-dev/alpine-php5/conf/etc/httpd/conf.d/10-php.conf similarity index 100% rename from docker/php-apache/alpine-3/conf/etc/httpd/conf.d/10-php.conf rename to docker/php-apache-dev/alpine-php5/conf/etc/httpd/conf.d/10-php.conf diff --git a/docker/php-apache/alpine-3/conf/etc/httpd/conf.d/10-server.conf b/docker/php-apache-dev/alpine-php5/conf/etc/httpd/conf.d/10-server.conf similarity index 100% rename from docker/php-apache/alpine-3/conf/etc/httpd/conf.d/10-server.conf rename to docker/php-apache-dev/alpine-php5/conf/etc/httpd/conf.d/10-server.conf diff --git a/docker/php-apache/alpine-3/conf/etc/httpd/global.conf b/docker/php-apache-dev/alpine-php5/conf/etc/httpd/global.conf similarity index 100% rename from docker/php-apache/alpine-3/conf/etc/httpd/global.conf rename to docker/php-apache-dev/alpine-php5/conf/etc/httpd/global.conf diff --git a/docker/php-apache/alpine-3/conf/etc/httpd/main.conf b/docker/php-apache-dev/alpine-php5/conf/etc/httpd/main.conf similarity index 100% rename from docker/php-apache/alpine-3/conf/etc/httpd/main.conf rename to docker/php-apache-dev/alpine-php5/conf/etc/httpd/main.conf diff --git a/docker/php-apache/alpine-3/conf/etc/httpd/php.conf b/docker/php-apache-dev/alpine-php5/conf/etc/httpd/php.conf similarity index 100% rename from docker/php-apache/alpine-3/conf/etc/httpd/php.conf rename to docker/php-apache-dev/alpine-php5/conf/etc/httpd/php.conf diff --git a/docker/php-apache/alpine-3/conf/etc/httpd/ssl/server.crt b/docker/php-apache-dev/alpine-php5/conf/etc/httpd/ssl/server.crt similarity index 100% rename from docker/php-apache/alpine-3/conf/etc/httpd/ssl/server.crt rename to docker/php-apache-dev/alpine-php5/conf/etc/httpd/ssl/server.crt diff --git a/docker/php-apache/alpine-3/conf/etc/httpd/ssl/server.csr b/docker/php-apache-dev/alpine-php5/conf/etc/httpd/ssl/server.csr similarity index 100% rename from docker/php-apache/alpine-3/conf/etc/httpd/ssl/server.csr rename to docker/php-apache-dev/alpine-php5/conf/etc/httpd/ssl/server.csr diff --git a/docker/php-apache/alpine-3/conf/etc/httpd/ssl/server.key b/docker/php-apache-dev/alpine-php5/conf/etc/httpd/ssl/server.key similarity index 100% rename from docker/php-apache/alpine-3/conf/etc/httpd/ssl/server.key rename to docker/php-apache-dev/alpine-php5/conf/etc/httpd/ssl/server.key diff --git a/docker/php-apache/alpine-3/conf/etc/httpd/vhost.common.conf b/docker/php-apache-dev/alpine-php5/conf/etc/httpd/vhost.common.conf similarity index 100% rename from docker/php-apache/alpine-3/conf/etc/httpd/vhost.common.conf rename to docker/php-apache-dev/alpine-php5/conf/etc/httpd/vhost.common.conf diff --git a/docker/php-apache-dev/alpine-php5/conf/etc/httpd/vhost.common.d/.gitkeep b/docker/php-apache-dev/alpine-php5/conf/etc/httpd/vhost.common.d/.gitkeep new file mode 100644 index 000000000..e69de29bb diff --git a/docker/php-apache/alpine-3/conf/etc/httpd/vhost.common.d/01-boilerplate.conf b/docker/php-apache-dev/alpine-php5/conf/etc/httpd/vhost.common.d/01-boilerplate.conf similarity index 100% rename from docker/php-apache/alpine-3/conf/etc/httpd/vhost.common.d/01-boilerplate.conf rename to docker/php-apache-dev/alpine-php5/conf/etc/httpd/vhost.common.d/01-boilerplate.conf diff --git a/docker/php-apache-dev/alpine-php5/conf/etc/httpd/vhost.common.d/02-dev.conf b/docker/php-apache-dev/alpine-php5/conf/etc/httpd/vhost.common.d/02-dev.conf new file mode 100644 index 000000000..54918ec2b --- /dev/null +++ b/docker/php-apache-dev/alpine-php5/conf/etc/httpd/vhost.common.d/02-dev.conf @@ -0,0 +1,10 @@ +"> + FileETag None + + + Header unset ETag + Header set Cache-Control "max-age=0, no-cache, no-store, must-revalidate" + Header set Pragma "no-cache" + Header set Expires "Wed, 11 Jan 1984 05:00:00 GMT" + + diff --git a/docker/php-apache/alpine-3/conf/etc/httpd/vhost.conf b/docker/php-apache-dev/alpine-php5/conf/etc/httpd/vhost.conf similarity index 100% rename from docker/php-apache/alpine-3/conf/etc/httpd/vhost.conf rename to docker/php-apache-dev/alpine-php5/conf/etc/httpd/vhost.conf diff --git a/docker/php-apache/alpine-3/conf/etc/httpd/vhost.ssl.conf b/docker/php-apache-dev/alpine-php5/conf/etc/httpd/vhost.ssl.conf similarity index 100% rename from docker/php-apache/alpine-3/conf/etc/httpd/vhost.ssl.conf rename to docker/php-apache-dev/alpine-php5/conf/etc/httpd/vhost.ssl.conf diff --git a/docker/php-apache/alpine-3/conf/etc/supervisor.d/apache.conf b/docker/php-apache-dev/alpine-php5/conf/etc/supervisor.d/apache.conf similarity index 100% rename from docker/php-apache/alpine-3/conf/etc/supervisor.d/apache.conf rename to docker/php-apache-dev/alpine-php5/conf/etc/supervisor.d/apache.conf diff --git a/docker/php-dev/alpine-3/conf/etc/supervisor.d/blackfire-agent.conf b/docker/php-apache-dev/alpine-php5/conf/etc/supervisor.d/blackfire-agent.conf similarity index 100% rename from docker/php-dev/alpine-3/conf/etc/supervisor.d/blackfire-agent.conf rename to docker/php-apache-dev/alpine-php5/conf/etc/supervisor.d/blackfire-agent.conf diff --git a/docker/php-apache-dev/alpine-php5/conf/provision/entrypoint.d/10-php-debugger.sh b/docker/php-apache-dev/alpine-php5/conf/provision/entrypoint.d/10-php-debugger.sh new file mode 100644 index 000000000..b5985a9ef --- /dev/null +++ b/docker/php-apache-dev/alpine-php5/conf/provision/entrypoint.d/10-php-debugger.sh @@ -0,0 +1,96 @@ +#!/usr/bin/env bash + +################################################# +# Debugger switch +################################################# + +PHP_CONF_PATHS=" +/etc/php5/conf.d +/etc/php7/conf.d +/etc/php.d +/etc/php5/mods-available +/etc/php5/cli/conf.d +/etc/php5/cli/conf.d +/etc/php5/fpm/conf.d +/etc/php5/fpm/conf.d +/etc/php/7.0/mods-available +/etc/php/7.0/cli/conf.d +/etc/php/7.0/fpm/conf.d +/usr/local/etc/php/conf.d/" + +function phpModuleRemove() { + if [ "$#" -ne 1 ]; then + echo "You must specify the name of the PHP module which you want to disable" + exit 1 + fi + + echo " - Removing PHP module ${1}" + for CONF_PATH in $PHP_CONF_PATHS; do + rm -f "${CONF_PATH}"/*"${1}".ini + done +} + + +if [[ -n "${PHP_DEBUGGER+x}" ]]; then + case "$PHP_DEBUGGER" in + xdebug) + echo "PHP-Debugger: Xdebug enabled" + phpModuleRemove "blackfire" + ;; + + blackfire) + echo "PHP-Debugger: Blackfire enabled" + phpModuleRemove "xdebug" + docker-service-enable blackfire-agent + ;; + + none) + echo "PHP-Debugger: none" + phpModuleRemove "blackfire" + phpModuleRemove "xdebug" + ;; + esac + +else + + echo "PHP-Debugger: not specified - default is xdebug" + phpModuleRemove "blackfire" + +fi + +################################################# +# PHP debugger environment variables +################################################# + +function phpEnvironmentVariable() { + PHP_INI_KEY="$1" + PHP_ENV_NAME="$2" + + if [[ -n "${!PHP_ENV_NAME+x}" ]]; then + PHP_ENV_VALUE="${!PHP_ENV_NAME}" + echo "${PHP_INI_KEY}=\"${PHP_ENV_VALUE}\"" >> /opt/docker/etc/php/php.ini + fi +} + +################### +# XDEBUG +################### + +# remote debugger +phpEnvironmentVariable "xdebug.remote_connect_back" "XDEBUG_REMOTE_CONNECT_BACK" +phpEnvironmentVariable "xdebug.remote_autostart" "XDEBUG_REMOTE_AUTOSTART" +phpEnvironmentVariable "xdebug.remote_host" "XDEBUG_REMOTE_HOST" +phpEnvironmentVariable "xdebug.remote_port" "XDEBUG_REMOTE_PORT" + +# profiler +phpEnvironmentVariable "xdebug.profiler_enable" "XDEBUG_PROFILER_ENABLE" +phpEnvironmentVariable "xdebug.profiler_enable_trigger" "XDEBUG_PROFILER_ENABLE_TRIGGER" +phpEnvironmentVariable "xdebug.profiler_enable_trigger_value" "XDEBUG_PROFILER_ENABLE_TRIGGER_VALUE" +phpEnvironmentVariable "xdebug.profiler_output_dir" "XDEBUG_PROFILER_OUTPUT_DIR" +phpEnvironmentVariable "xdebug.profiler_output_name" "XDEBUG_PROFILER_OUTPUT_NAME" + +################### +# BLACKFIRE +################### +phpEnvironmentVariable "blackfire.server_id" "BLACKFIRE_SERVER_ID" +phpEnvironmentVariable "blackfire.server_token" "BLACKFIRE_SERVER_TOKEN" diff --git a/docker/php-dev/debian-7-php7/conf/provision/roles/webdevops-php-dev/defaults/main.yml b/docker/php-apache-dev/alpine-php5/conf/provision/roles/webdevops-apache-dev/defaults/main.yml similarity index 100% rename from docker/php-dev/debian-7-php7/conf/provision/roles/webdevops-php-dev/defaults/main.yml rename to docker/php-apache-dev/alpine-php5/conf/provision/roles/webdevops-apache-dev/defaults/main.yml diff --git a/docker/php-nginx-dev/alpine-3-php7/conf/provision/roles/webdevops-php-nginx/tasks/entrypoint.yml b/docker/php-apache-dev/alpine-php5/conf/provision/roles/webdevops-apache-dev/tasks/bootstrap.yml similarity index 100% rename from docker/php-nginx-dev/alpine-3-php7/conf/provision/roles/webdevops-php-nginx/tasks/entrypoint.yml rename to docker/php-apache-dev/alpine-php5/conf/provision/roles/webdevops-apache-dev/tasks/bootstrap.yml diff --git a/docker/php-dev/alpine-3-php7/conf/provision/roles/webdevops-php-dev/tasks/main.yml b/docker/php-apache-dev/alpine-php5/conf/provision/roles/webdevops-apache-dev/tasks/main.yml similarity index 100% rename from docker/php-dev/alpine-3-php7/conf/provision/roles/webdevops-php-dev/tasks/main.yml rename to docker/php-apache-dev/alpine-php5/conf/provision/roles/webdevops-apache-dev/tasks/main.yml diff --git a/docker/php-apache/alpine-3/conf/provision/roles/webdevops-apache/defaults/main.yml b/docker/php-apache-dev/alpine-php5/conf/provision/roles/webdevops-apache/defaults/main.yml similarity index 100% rename from docker/php-apache/alpine-3/conf/provision/roles/webdevops-apache/defaults/main.yml rename to docker/php-apache-dev/alpine-php5/conf/provision/roles/webdevops-apache/defaults/main.yml diff --git a/docker/php-apache-dev/alpine-php5/conf/provision/roles/webdevops-apache/tasks/bootstrap.yml b/docker/php-apache-dev/alpine-php5/conf/provision/roles/webdevops-apache/tasks/bootstrap.yml new file mode 100644 index 000000000..c285be286 --- /dev/null +++ b/docker/php-apache-dev/alpine-php5/conf/provision/roles/webdevops-apache/tasks/bootstrap.yml @@ -0,0 +1,156 @@ +--- + +- name: Set apache vhost file [RedHat family] + set_fact: + apache_main_path: /etc/httpd/ + apache_docker_vhost: /etc/httpd/conf.d/zzz-docker.conf + when: ansible_os_family == 'RedHat' + +- name: Set apache vhost file [Debian family] + set_fact: + apache_main_path: /etc/apache2/ + apache_docker_vhost: /etc/apache2/sites-enabled/10-docker.conf + when: ansible_os_family == 'Debian' + +- name: Set apache vhost file [Alpine family] + set_fact: + apache_main_path: /etc/apache2/ + apache_docker_vhost: /etc/apache2/conf.d/zzz-docker.conf + when: ansible_os_family == 'Alpine' + +- name: Enable apache main config + file: + src: '/opt/docker/etc/httpd/main.conf' + dest: '{{ apache_docker_vhost }}' + state: link + force: yes + +- name: Ensure document root is available + file: + path: "{{ DOCUMENT_ROOT }}" + state: directory + recurse: yes + +- name: Ensure /var/run/apache2 exists + file: + path: '/var/run/apache2' + state: directory + recurse: yes + +- name: Ensure /run/apache2 exists + file: + path: '/run/apache2' + state: directory + recurse: yes + when: ansible_os_family == 'Alpine' + +- name: Find apache2 files + shell: "find '{{ apache_main_path }}' -type f -iname '*.conf' -o -iname 'default*' -o -iname '*log'" + register: apache2_conf_files + +- name: Change CustomLog to Docker stdout + replace: + dest: '{{ item }}' + regexp: '^[\s]*CustomLog ([^\s]+)(.*)' + replace: 'CustomLog /docker.stdout \2' + with_items: "{{ apache2_conf_files.stdout_lines }}" + +- name: Change CustomLog to Docker stdout + replace: + dest: '{{ item }}' + regexp: '^[\s]*ErrorLog ([^\s]+)(.*)' + replace: 'ErrorLog /docker.stdout \2' + with_items: "{{ apache2_conf_files.stdout_lines }}" + +- name: Change TransferLog to Docker stdout + replace: + dest: '{{ item }}' + regexp: '^[\s]*TransferLog ([^\s]+)(.*)' + replace: 'TransferLog /docker.stdout \2' + with_items: "{{ apache2_conf_files.stdout_lines }}" + +- name: Switch MPM to worker [RedHat family] + lineinfile: + dest: '/etc/httpd/conf.modules.d/00-mpm.conf' + regexp: '^[\s#]*{{ item.line }}' + line: '{{ item.prefix }}{{ item.line }}' + with_items: + - { line: 'LoadModule mpm_prefork_module modules/mod_mpm_prefork.so', prefix: "#" } + - { line: 'LoadModule mpm_event_module modules/mod_mpm_event.so', prefix: "" } + when: ansible_os_family == 'RedHat' + +- name: Switch MPM to event for Apache 2.4 and higher [Ubuntu family] + command: "{{ item }}" + with_items: + - 'a2dismod mpm_event' + - 'a2enmod mpm_event' + when: (ansible_distribution == 'Ubuntu' and docker_image_info_distribution_version|int >= 14) or (ansible_distribution == 'Debian' and docker_image_info_distribution_version|int >= 8) + +- name: Manage modules [Alpine family] + lineinfile: + dest: '/etc/apache2/httpd.conf' + regexp: '^[\s#]*{{ item.line }}' + line: '{{ item.prefix }}{{ item.line }}' + with_items: + - { line: 'LoadModule mpm_prefork_module modules/mod_mpm_prefork.so', prefix: "#" } + - { line: 'LoadModule mpm_event_module modules/mod_mpm_event.so', prefix: "" } + - { line: 'LoadModule deflate_module modules/mod_deflate.so', prefix: "" } + - { line: 'LoadModule rewrite_module modules/mod_rewrite.so', prefix: "" } + - { line: 'LoadModule logio_module modules/mod_logio.so', prefix: "" } + - { line: 'LoadModule slotmem_shm_module modules/mod_slotmem_shm.so', prefix: "" } + - { line: 'LoadModule actions_module modules/mod_actions.so', prefix: "" } + - { line: 'LoadModule expires_module modules/mod_expires.so', prefix: "" } + when: ansible_os_family == 'Alpine' + +- name: Fix ssl support [Alpine family] + lineinfile: + dest: '/etc/apache2/conf.d/ssl.conf' + regexp: '{{ item.regexp }}' + line: '{{ item.line }}' + with_items: + - { regexp: 'LoadModule ssl_module', line: 'LoadModule ssl_module /usr/lib/apache2/mod_ssl.so' } + - { regexp: 'LoadModule socache_shmcb_module', line: 'LoadModule socache_shmcb_module /usr/lib/apache2/mod_socache_shmcb.so' } + when: ansible_os_family == 'Alpine' + +- name: Remove default vhost from ssl configuration [Alpine family] + command: sed -i -e '1h;2,$H;$!d;g' -e 's//#-> removed vhost/g' /etc/apache2/conf.d/ssl.conf + when: ansible_os_family == 'Alpine' + +- name: Disable proxy [Alpine family] + lineinfile: + dest: '/etc/apache2/conf.d/proxy.conf' + regexp: '^[\s#]*{{ item.line }}' + line: '{{ item.prefix }}{{ item.line }}' + with_items: + - { line: 'LoadModule proxy_ajp_module modules/mod_proxy_ajp.so', prefix: "#" } + - { line: 'LoadModule proxy_connect_module modules/mod_proxy_connect.so', prefix: "#" } + - { line: 'LoadModule proxy_balancer_module modules/mod_proxy_balancer.so', prefix: "#" } + - { line: 'LoadModule proxy_express_module modules/mod_proxy_express.so', prefix: "#" } + - { line: 'LoadModule proxy_fcgi_module modules/mod_proxy_fcgi.so', prefix: "" } + - { line: 'LoadModule proxy_fdpass_module modules/mod_proxy_fdpass.so', prefix: "#" } + - { line: 'LoadModule proxy_ftp_module modules/mod_proxy_ftp.so', prefix: "#" } + - { line: 'LoadModule proxy_http_module modules/mod_proxy_http.so', prefix: "#" } + - { line: 'LoadModule proxy_scgi_module modules/mod_proxy_scgi.so', prefix: "#" } + when: ansible_os_family == 'Alpine' + +- name: Fix rights of ssl files + file: + path: "{{ item.path }}" + state: "{{ item.state }}" + mode: "{{ item.mode }}" + owner: "root" + group: "root" + with_items: + - { path: '/opt/docker/etc/httpd/ssl', state: 'directory', mode: '0750' } + - { path: '/opt/docker/etc/httpd/ssl/server.crt', state: 'file', mode: '0640' } + - { path: '/opt/docker/etc/httpd/ssl/server.csr', state: 'file', mode: '0640' } + - { path: '/opt/docker/etc/httpd/ssl/server.key', state: 'file', mode: '0640' } + +- name: Maintain lock directory [Debian family] + file: + path: "/var/lock/apache2" + state: "directory" + mode: "0750" + owner: "www-data" + group: "www-data" + when: ansible_os_family == 'Debian' diff --git a/docker/php-dev/alpine-3/conf/provision/roles/webdevops-dev/tasks/main.yml b/docker/php-apache-dev/alpine-php5/conf/provision/roles/webdevops-apache/tasks/main.yml similarity index 100% rename from docker/php-dev/alpine-3/conf/provision/roles/webdevops-dev/tasks/main.yml rename to docker/php-apache-dev/alpine-php5/conf/provision/roles/webdevops-apache/tasks/main.yml diff --git a/docker/php-apache/alpine-3/conf/provision/roles/webdevops-php-apache/defaults/main.yml b/docker/php-apache-dev/alpine-php5/conf/provision/roles/webdevops-php-apache/defaults/main.yml similarity index 100% rename from docker/php-apache/alpine-3/conf/provision/roles/webdevops-php-apache/defaults/main.yml rename to docker/php-apache-dev/alpine-php5/conf/provision/roles/webdevops-php-apache/defaults/main.yml diff --git a/docker/php-apache/alpine-3/conf/provision/roles/webdevops-php-apache/tasks/bootstrap.yml b/docker/php-apache-dev/alpine-php5/conf/provision/roles/webdevops-php-apache/tasks/bootstrap.yml similarity index 100% rename from docker/php-apache/alpine-3/conf/provision/roles/webdevops-php-apache/tasks/bootstrap.yml rename to docker/php-apache-dev/alpine-php5/conf/provision/roles/webdevops-php-apache/tasks/bootstrap.yml diff --git a/docker/php-nginx-dev/alpine-3/conf/provision/roles/webdevops-php-nginx/tasks/entrypoint.yml b/docker/php-apache-dev/alpine-php5/conf/provision/roles/webdevops-php-apache/tasks/entrypoint.yml similarity index 100% rename from docker/php-nginx-dev/alpine-3/conf/provision/roles/webdevops-php-nginx/tasks/entrypoint.yml rename to docker/php-apache-dev/alpine-php5/conf/provision/roles/webdevops-php-apache/tasks/entrypoint.yml diff --git a/docker/php-apache/alpine-3/conf/provision/roles/webdevops-php-apache/tasks/main.yml b/docker/php-apache-dev/alpine-php5/conf/provision/roles/webdevops-php-apache/tasks/main.yml similarity index 100% rename from docker/php-apache/alpine-3/conf/provision/roles/webdevops-php-apache/tasks/main.yml rename to docker/php-apache-dev/alpine-php5/conf/provision/roles/webdevops-php-apache/tasks/main.yml diff --git a/docker/php-nginx-dev/alpine-3-php7/conf/provision/roles/webdevops-nginx-dev/defaults/main.yml b/docker/php-apache-dev/alpine-php5/conf/provision/roles/webdevops-php-dev/defaults/main.yml similarity index 100% rename from docker/php-nginx-dev/alpine-3-php7/conf/provision/roles/webdevops-nginx-dev/defaults/main.yml rename to docker/php-apache-dev/alpine-php5/conf/provision/roles/webdevops-php-dev/defaults/main.yml diff --git a/docker/php-apache-dev/alpine-php5/conf/provision/roles/webdevops-php-dev/tasks/bootstrap.yml b/docker/php-apache-dev/alpine-php5/conf/provision/roles/webdevops-php-dev/tasks/bootstrap.yml new file mode 100644 index 000000000..ff02b05fc --- /dev/null +++ b/docker/php-apache-dev/alpine-php5/conf/provision/roles/webdevops-php-dev/tasks/bootstrap.yml @@ -0,0 +1,7 @@ +--- + +- include: bootstrap/php-fpm.yml +- include: bootstrap/php-module.yml +- include: bootstrap/php-module.opcache.yml +- include: bootstrap/php-module.xdebug.yml +- include: bootstrap/php-module.blackfire.yml diff --git a/docker/php-dev/alpine-3/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/php-fpm.yml b/docker/php-apache-dev/alpine-php5/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/php-fpm.yml similarity index 100% rename from docker/php-dev/alpine-3/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/php-fpm.yml rename to docker/php-apache-dev/alpine-php5/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/php-fpm.yml diff --git a/docker/php-apache-dev/alpine-php5/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/php-module.blackfire.yml b/docker/php-apache-dev/alpine-php5/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/php-module.blackfire.yml new file mode 100644 index 000000000..faf05f8de --- /dev/null +++ b/docker/php-apache-dev/alpine-php5/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/php-module.blackfire.yml @@ -0,0 +1,10 @@ +--- + +- name: Remove superfluous blackfire configuration file + file: + path: '{{ item }}' + state: absent + with_items: + - /etc/php5/cli/conf.d/zz-blackfire.ini + - /etc/php5/fpm/conf.d/zz-blackfire.ini + when: ansible_distribution == 'Debian' and docker_image_info_distribution_version|int >= 7 diff --git a/docker/php-dev/alpine-3/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/php-module.opcache.yml b/docker/php-apache-dev/alpine-php5/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/php-module.opcache.yml similarity index 100% rename from docker/php-dev/alpine-3/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/php-module.opcache.yml rename to docker/php-apache-dev/alpine-php5/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/php-module.opcache.yml diff --git a/docker/php-dev/alpine-3/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/php-module.xdebug.yml b/docker/php-apache-dev/alpine-php5/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/php-module.xdebug.yml similarity index 100% rename from docker/php-dev/alpine-3/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/php-module.xdebug.yml rename to docker/php-apache-dev/alpine-php5/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/php-module.xdebug.yml diff --git a/docker/php-dev/alpine-3/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/php-module.yml b/docker/php-apache-dev/alpine-php5/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/php-module.yml similarity index 100% rename from docker/php-dev/alpine-3/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/php-module.yml rename to docker/php-apache-dev/alpine-php5/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/php-module.yml diff --git a/docker/php-dev/alpine-3/conf/provision/roles/webdevops-php-dev/tasks/main.yml b/docker/php-apache-dev/alpine-php5/conf/provision/roles/webdevops-php-dev/tasks/main.yml similarity index 100% rename from docker/php-dev/alpine-3/conf/provision/roles/webdevops-php-dev/tasks/main.yml rename to docker/php-apache-dev/alpine-php5/conf/provision/roles/webdevops-php-dev/tasks/main.yml diff --git a/docker/php-apache-dev/alpine-php7/Dockerfile b/docker/php-apache-dev/alpine-php7/Dockerfile new file mode 100644 index 000000000..fb25a1d2a --- /dev/null +++ b/docker/php-apache-dev/alpine-php7/Dockerfile @@ -0,0 +1,30 @@ +#+++++++++++++++++++++++++++++++++++++++ +# Dockerfile for webdevops/php-apache-dev:alpine-php7 +# -- automatically generated -- +#+++++++++++++++++++++++++++++++++++++++ + +FROM webdevops/php-dev:alpine-php7 + +ENV WEB_DOCUMENT_ROOT=/app \ + WEB_DOCUMENT_INDEX=index.php \ + WEB_ALIAS_DOMAIN=*.vm +ENV WEB_PHP_SOCKET=127.0.0.1:9000 +ENV WEB_NO_CACHE_PATTERN="\.(css|js|gif|png|jpg|svg|json|xml)$" + +COPY conf/ /opt/docker/ + +# Install apache +RUN /usr/local/bin/apk-install \ + apache2 \ + apache2-utils \ + apache2-proxy \ + apache2-ssl \ + && sed -ri ' \ + s!^(\s*CustomLog)\s+\S+!\1 /proc/self/fd/1!g; \ + s!^(\s*ErrorLog)\s+\S+!\1 /proc/self/fd/2!g; \ + ' /etc/apache2/httpd.conf \ + && /opt/docker/bin/provision run --tag bootstrap --role webdevops-apache --role webdevops-php-apache --role webdevops-apache-dev --role webdevops-php-dev \ + && /opt/docker/bin/bootstrap.sh \ + && docker-image-cleanup + +EXPOSE 80 443 diff --git a/docker/php-apache-dev/alpine-php7/Dockerfile.jinja2 b/docker/php-apache-dev/alpine-php7/Dockerfile.jinja2 new file mode 100644 index 000000000..de5e8acbc --- /dev/null +++ b/docker/php-apache-dev/alpine-php7/Dockerfile.jinja2 @@ -0,0 +1,11 @@ +{{ docker.from("php-dev", "alpine-php7") }} + +{{ environment.web() }} +{{ environment.webPhp() }} +{{ environment.webDevelopment() }} + +{{ docker.copy('conf/', '/opt/docker/') }} + +{{ apache.alpine('php-apache apache-dev php-dev') }} + +{{ docker.expose('80 443') }} diff --git a/docker/php-nginx-dev/alpine-3-php7/conf/bin/service.d/blackfire-agent.d/10-init.sh b/docker/php-apache-dev/alpine-php7/conf/bin/service.d/blackfire-agent.d/10-init.sh similarity index 100% rename from docker/php-nginx-dev/alpine-3-php7/conf/bin/service.d/blackfire-agent.d/10-init.sh rename to docker/php-apache-dev/alpine-php7/conf/bin/service.d/blackfire-agent.d/10-init.sh diff --git a/docker/php-nginx-dev/alpine-3-php7/conf/bin/service.d/blackfire-agent.sh b/docker/php-apache-dev/alpine-php7/conf/bin/service.d/blackfire-agent.sh similarity index 100% rename from docker/php-nginx-dev/alpine-3-php7/conf/bin/service.d/blackfire-agent.sh rename to docker/php-apache-dev/alpine-php7/conf/bin/service.d/blackfire-agent.sh diff --git a/docker/php-apache-dev/alpine-php7/conf/bin/service.d/httpd.d/10-init.sh b/docker/php-apache-dev/alpine-php7/conf/bin/service.d/httpd.d/10-init.sh new file mode 100644 index 000000000..b9d57997e --- /dev/null +++ b/docker/php-apache-dev/alpine-php7/conf/bin/service.d/httpd.d/10-init.sh @@ -0,0 +1,21 @@ +if [[ ! -e "$WEB_DOCUMENT_ROOT" ]]; then + echo "" + echo "[WARNING] WEB_DOCUMENT_ROOT does not exists with path \"$WEB_DOCUMENT_ROOT\"!" + echo "" +fi + +# Replace markers +go-replace \ + -s "" -r "$WEB_DOCUMENT_INDEX" \ + -s "" -r "$WEB_DOCUMENT_ROOT" \ + -s "" -r "$WEB_ALIAS_DOMAIN" \ + -s "" -r "$HOSTNAME" \ + -s "" -r "$WEB_PHP_SOCKET" \ + --path=/opt/docker/etc/httpd/ \ + --path-pattern='*.conf' \ + --ignore-empty + +if [[ -z "${WEB_PHP_SOCKET+x}" ]]; then + ## WEB_PHP_SOCKET is not set, remove PHP files + rm -f -- /opt/docker/etc/httpd/conf.d/10-php.conf +fi diff --git a/docker/php-apache-dev/alpine-php7/conf/bin/service.d/httpd.d/12-development.sh b/docker/php-apache-dev/alpine-php7/conf/bin/service.d/httpd.d/12-development.sh new file mode 100644 index 000000000..a9d2c6e92 --- /dev/null +++ b/docker/php-apache-dev/alpine-php7/conf/bin/service.d/httpd.d/12-development.sh @@ -0,0 +1,5 @@ +go-replace \ + -s "" -r "$WEB_NO_CACHE_PATTERN" \ + --path=/opt/docker/etc/httpd/ \ + --path-pattern='*.conf' \ + --ignore-empty diff --git a/docker/php-apache-dev/alpine-3/conf/bin/service.d/httpd.sh b/docker/php-apache-dev/alpine-php7/conf/bin/service.d/httpd.sh similarity index 100% rename from docker/php-apache-dev/alpine-3/conf/bin/service.d/httpd.sh rename to docker/php-apache-dev/alpine-php7/conf/bin/service.d/httpd.sh diff --git a/docker/php-apache-dev/alpine-php7/conf/etc/httpd/conf.d/.gitkeep b/docker/php-apache-dev/alpine-php7/conf/etc/httpd/conf.d/.gitkeep new file mode 100644 index 000000000..e69de29bb diff --git a/docker/php-apache-dev/alpine-php7/conf/etc/httpd/conf.d/02-dev.conf b/docker/php-apache-dev/alpine-php7/conf/etc/httpd/conf.d/02-dev.conf new file mode 100644 index 000000000..75e5f4396 --- /dev/null +++ b/docker/php-apache-dev/alpine-php7/conf/etc/httpd/conf.d/02-dev.conf @@ -0,0 +1,8 @@ +# EnableSendfile: Control whether the sendfile kernel support is +# used to deliver files (assuming that the OS supports it). +# The default is on; turn this off if you serve from NFS-mounted +# filesystems. Please see +# http://httpd.apache.org/docs/2.2/mod/core.html#enablesendfile +EnableSendfile off + +LogLevel info diff --git a/docker/php-apache-dev/alpine-php7/conf/etc/httpd/conf.d/10-error-document.conf b/docker/php-apache-dev/alpine-php7/conf/etc/httpd/conf.d/10-error-document.conf new file mode 100644 index 000000000..ebabf87e4 --- /dev/null +++ b/docker/php-apache-dev/alpine-php7/conf/etc/httpd/conf.d/10-error-document.conf @@ -0,0 +1,15 @@ +####################################### +# Faster error documents +####################################### + + ErrorDocument 400 "400 Bad Request" + ErrorDocument 401 "401 Unauthorized" + ErrorDocument 403 "403 Forbidden" + ErrorDocument 404 "404 Not Found" + ErrorDocument 405 "405 Method Not Allowed" + + ErrorDocument 500 "500 Internal Server Error" + ErrorDocument 501 "501 Not Implemented" + ErrorDocument 502 "502 Bad Gateway" + ErrorDocument 503 "503 Service Unavailable" + diff --git a/docker/php-apache-dev/alpine-php7/conf/etc/httpd/conf.d/10-log.conf b/docker/php-apache-dev/alpine-php7/conf/etc/httpd/conf.d/10-log.conf new file mode 100644 index 000000000..ef0c73d38 --- /dev/null +++ b/docker/php-apache-dev/alpine-php7/conf/etc/httpd/conf.d/10-log.conf @@ -0,0 +1,4 @@ +LogFormat "[httpd:access] %V:%p %h %l %u %t \"%r\" %>s bytesIn:%I bytesOut:%O reqTime:%T" dockerlog +LogLevel warn +CustomLog /docker.stdout dockerlog +ErrorLog /docker.stderr diff --git a/docker/php-apache-dev/alpine-php7/conf/etc/httpd/conf.d/10-php.conf b/docker/php-apache-dev/alpine-php7/conf/etc/httpd/conf.d/10-php.conf new file mode 100644 index 000000000..4368d12ef --- /dev/null +++ b/docker/php-apache-dev/alpine-php7/conf/etc/httpd/conf.d/10-php.conf @@ -0,0 +1,37 @@ +############################# +# mod_proxy_fcgi +# official solution +# apache 2.4 and later +############################# + + + > + ProxySet connectiontimeout=5 timeout=600 + + + + SetHandler "proxy:fcgi://" + + + +############################# +# mod_fastcgi +# apaache 2.2 and 2.4 +############################# + + + AddHandler php-fcgi .php + Action php-fcgi /php-fcgi + Alias /php-fcgi /usr/lib/cgi-bin/php-fcgi + FastCgiExternalServer /usr/lib/cgi-bin/php-fcgi -host "" -pass-header Authorization -idle-timeout 600 + + + + Allow from all + + = 2.4> + Require all granted + + + + diff --git a/docker/php-apache-dev/alpine-php7/conf/etc/httpd/conf.d/10-server.conf b/docker/php-apache-dev/alpine-php7/conf/etc/httpd/conf.d/10-server.conf new file mode 100644 index 000000000..d3a5defbd --- /dev/null +++ b/docker/php-apache-dev/alpine-php7/conf/etc/httpd/conf.d/10-server.conf @@ -0,0 +1,18 @@ +# Settings +TimeOut 1000 +ServerName "" + +DirectoryIndex +DocumentRoot "" + +"> + Options Indexes FollowSymLinks + AllowOverride All + + + Allow from all + + = 2.4> + Require all granted + + diff --git a/docker/php-nginx-dev/alpine-3-php7/conf/etc/nginx/global.conf b/docker/php-apache-dev/alpine-php7/conf/etc/httpd/global.conf similarity index 100% rename from docker/php-nginx-dev/alpine-3-php7/conf/etc/nginx/global.conf rename to docker/php-apache-dev/alpine-php7/conf/etc/httpd/global.conf diff --git a/docker/php-apache-dev/alpine-php7/conf/etc/httpd/main.conf b/docker/php-apache-dev/alpine-php7/conf/etc/httpd/main.conf new file mode 100644 index 000000000..12251c222 --- /dev/null +++ b/docker/php-apache-dev/alpine-php7/conf/etc/httpd/main.conf @@ -0,0 +1,12 @@ +Include /opt/docker/etc/httpd/global.conf +Include /opt/docker/etc/httpd/php.conf + + + Include /opt/docker/etc/httpd/conf.d/*.conf + += 2.4> + IncludeOptional /opt/docker/etc/httpd/conf.d/*.conf + +Include /opt/docker/etc/httpd/vhost.conf + + diff --git a/docker/php-nginx-dev/alpine-3-php7/conf/etc/nginx/php.conf b/docker/php-apache-dev/alpine-php7/conf/etc/httpd/php.conf similarity index 100% rename from docker/php-nginx-dev/alpine-3-php7/conf/etc/nginx/php.conf rename to docker/php-apache-dev/alpine-php7/conf/etc/httpd/php.conf diff --git a/docker/php-nginx-dev/alpine-3-php7/conf/etc/nginx/ssl/server.crt b/docker/php-apache-dev/alpine-php7/conf/etc/httpd/ssl/server.crt similarity index 100% rename from docker/php-nginx-dev/alpine-3-php7/conf/etc/nginx/ssl/server.crt rename to docker/php-apache-dev/alpine-php7/conf/etc/httpd/ssl/server.crt diff --git a/docker/php-nginx-dev/alpine-3-php7/conf/etc/nginx/ssl/server.csr b/docker/php-apache-dev/alpine-php7/conf/etc/httpd/ssl/server.csr similarity index 100% rename from docker/php-nginx-dev/alpine-3-php7/conf/etc/nginx/ssl/server.csr rename to docker/php-apache-dev/alpine-php7/conf/etc/httpd/ssl/server.csr diff --git a/docker/php-nginx-dev/alpine-3-php7/conf/etc/nginx/ssl/server.key b/docker/php-apache-dev/alpine-php7/conf/etc/httpd/ssl/server.key similarity index 100% rename from docker/php-nginx-dev/alpine-3-php7/conf/etc/nginx/ssl/server.key rename to docker/php-apache-dev/alpine-php7/conf/etc/httpd/ssl/server.key diff --git a/docker/php-apache-dev/alpine-php7/conf/etc/httpd/vhost.common.conf b/docker/php-apache-dev/alpine-php7/conf/etc/httpd/vhost.common.conf new file mode 100644 index 000000000..384696b4e --- /dev/null +++ b/docker/php-apache-dev/alpine-php7/conf/etc/httpd/vhost.common.conf @@ -0,0 +1,7 @@ +# compatibility for PHP and TYPO3 Docker Boilerplate + + Include /opt/docker/etc/httpd/vhost.common.d/*.conf + + = 2.4> + IncludeOptional /opt/docker/etc/httpd/vhost.common.d/*.conf + diff --git a/docker/php-apache-dev/alpine-php7/conf/etc/httpd/vhost.common.d/.gitkeep b/docker/php-apache-dev/alpine-php7/conf/etc/httpd/vhost.common.d/.gitkeep new file mode 100644 index 000000000..e69de29bb diff --git a/docker/php-nginx-dev/alpine-3-php7/conf/etc/nginx/conf.d/02-dev.conf b/docker/php-apache-dev/alpine-php7/conf/etc/httpd/vhost.common.d/01-boilerplate.conf similarity index 100% rename from docker/php-nginx-dev/alpine-3-php7/conf/etc/nginx/conf.d/02-dev.conf rename to docker/php-apache-dev/alpine-php7/conf/etc/httpd/vhost.common.d/01-boilerplate.conf diff --git a/docker/php-apache-dev/alpine-php7/conf/etc/httpd/vhost.common.d/02-dev.conf b/docker/php-apache-dev/alpine-php7/conf/etc/httpd/vhost.common.d/02-dev.conf new file mode 100644 index 000000000..54918ec2b --- /dev/null +++ b/docker/php-apache-dev/alpine-php7/conf/etc/httpd/vhost.common.d/02-dev.conf @@ -0,0 +1,10 @@ +"> + FileETag None + + + Header unset ETag + Header set Cache-Control "max-age=0, no-cache, no-store, must-revalidate" + Header set Pragma "no-cache" + Header set Expires "Wed, 11 Jan 1984 05:00:00 GMT" + + diff --git a/docker/php-apache-dev/alpine-php7/conf/etc/httpd/vhost.conf b/docker/php-apache-dev/alpine-php7/conf/etc/httpd/vhost.conf new file mode 100644 index 000000000..c04a94318 --- /dev/null +++ b/docker/php-apache-dev/alpine-php7/conf/etc/httpd/vhost.conf @@ -0,0 +1,36 @@ +####################################### +# Vhost +####################################### + + + ServerName docker.vm + ServerAlias + DocumentRoot "" + + UseCanonicalName Off + + + Include /opt/docker/etc/httpd/vhost.common.d/*.conf + + = 2.4> + IncludeOptional /opt/docker/etc/httpd/vhost.common.d/*.conf + + + + + + ServerName docker.vm + ServerAlias + DocumentRoot "" + + UseCanonicalName Off + + + Include /opt/docker/etc/httpd/vhost.common.d/*.conf + + = 2.4> + IncludeOptional /opt/docker/etc/httpd/vhost.common.d/*.conf + + + Include /opt/docker/etc/httpd/vhost.ssl.conf + diff --git a/docker/php-apache-dev/alpine-php7/conf/etc/httpd/vhost.ssl.conf b/docker/php-apache-dev/alpine-php7/conf/etc/httpd/vhost.ssl.conf new file mode 100644 index 000000000..cf5fbc604 --- /dev/null +++ b/docker/php-apache-dev/alpine-php7/conf/etc/httpd/vhost.ssl.conf @@ -0,0 +1,26 @@ + ############ + # SSL + ############ + + SSLEngine on + SSLCertificateFile /opt/docker/etc/httpd/ssl/server.crt + SSLCertificateKeyFile /opt/docker/etc/httpd/ssl/server.key + + + SSLOptions +StdEnvVars + + + SSLOptions +StdEnvVars + + + BrowserMatch "MSIE [2-6]" \ + nokeepalive ssl-unclean-shutdown \ + downgrade-1.0 force-response-1.0 + # MSIE 7 and newer should be able to use keepalive + # This regexp is ok with 17-9! + BrowserMatch "MSIE [17-9]" ssl-unclean-shutdown + + ## SSL Hardening + SSLProtocol All -SSLv2 -SSLv3 + SSLHonorCipherOrder on + SSLCipherSuite 'EDH+CAMELLIA:EDH+aRSA:EECDH+aRSA+AESGCM:EECDH+aRSA+SHA384:EECDH+aRSA+SHA256:EECDH:+CAMELLIA256:+AES256:+CAMELLIA128:+AES128:+SSLv3:!aNULL:!eNULL:!LOW:!3DES:!MD5:!EXP:!PSK:!DSS:!RC4:!SEED:!ECDSA:CAMELLIA256-SHA:AES256-SHA:CAMELLIA128-SHA:AES128-SHA' diff --git a/docker/php-apache-dev/alpine-php7/conf/etc/supervisor.d/apache.conf b/docker/php-apache-dev/alpine-php7/conf/etc/supervisor.d/apache.conf new file mode 100644 index 000000000..12a6f86f7 --- /dev/null +++ b/docker/php-apache-dev/alpine-php7/conf/etc/supervisor.d/apache.conf @@ -0,0 +1,14 @@ +[group:apache] +programs=apached +priority=20 + +[program:apached] +command = /opt/docker/bin/service.d/httpd.sh +process_name=%(program_name)s +startsecs = 0 +autostart = true +autorestart = true +stdout_logfile=/dev/stdout +stdout_logfile_maxbytes=0 +stderr_logfile=/dev/stderr +stderr_logfile_maxbytes=0 diff --git a/docker/php-nginx-dev/alpine-3-php7/conf/etc/supervisor.d/blackfire-agent.conf b/docker/php-apache-dev/alpine-php7/conf/etc/supervisor.d/blackfire-agent.conf similarity index 100% rename from docker/php-nginx-dev/alpine-3-php7/conf/etc/supervisor.d/blackfire-agent.conf rename to docker/php-apache-dev/alpine-php7/conf/etc/supervisor.d/blackfire-agent.conf diff --git a/docker/php-apache-dev/alpine-php7/conf/provision/entrypoint.d/10-php-debugger.sh b/docker/php-apache-dev/alpine-php7/conf/provision/entrypoint.d/10-php-debugger.sh new file mode 100644 index 000000000..b5985a9ef --- /dev/null +++ b/docker/php-apache-dev/alpine-php7/conf/provision/entrypoint.d/10-php-debugger.sh @@ -0,0 +1,96 @@ +#!/usr/bin/env bash + +################################################# +# Debugger switch +################################################# + +PHP_CONF_PATHS=" +/etc/php5/conf.d +/etc/php7/conf.d +/etc/php.d +/etc/php5/mods-available +/etc/php5/cli/conf.d +/etc/php5/cli/conf.d +/etc/php5/fpm/conf.d +/etc/php5/fpm/conf.d +/etc/php/7.0/mods-available +/etc/php/7.0/cli/conf.d +/etc/php/7.0/fpm/conf.d +/usr/local/etc/php/conf.d/" + +function phpModuleRemove() { + if [ "$#" -ne 1 ]; then + echo "You must specify the name of the PHP module which you want to disable" + exit 1 + fi + + echo " - Removing PHP module ${1}" + for CONF_PATH in $PHP_CONF_PATHS; do + rm -f "${CONF_PATH}"/*"${1}".ini + done +} + + +if [[ -n "${PHP_DEBUGGER+x}" ]]; then + case "$PHP_DEBUGGER" in + xdebug) + echo "PHP-Debugger: Xdebug enabled" + phpModuleRemove "blackfire" + ;; + + blackfire) + echo "PHP-Debugger: Blackfire enabled" + phpModuleRemove "xdebug" + docker-service-enable blackfire-agent + ;; + + none) + echo "PHP-Debugger: none" + phpModuleRemove "blackfire" + phpModuleRemove "xdebug" + ;; + esac + +else + + echo "PHP-Debugger: not specified - default is xdebug" + phpModuleRemove "blackfire" + +fi + +################################################# +# PHP debugger environment variables +################################################# + +function phpEnvironmentVariable() { + PHP_INI_KEY="$1" + PHP_ENV_NAME="$2" + + if [[ -n "${!PHP_ENV_NAME+x}" ]]; then + PHP_ENV_VALUE="${!PHP_ENV_NAME}" + echo "${PHP_INI_KEY}=\"${PHP_ENV_VALUE}\"" >> /opt/docker/etc/php/php.ini + fi +} + +################### +# XDEBUG +################### + +# remote debugger +phpEnvironmentVariable "xdebug.remote_connect_back" "XDEBUG_REMOTE_CONNECT_BACK" +phpEnvironmentVariable "xdebug.remote_autostart" "XDEBUG_REMOTE_AUTOSTART" +phpEnvironmentVariable "xdebug.remote_host" "XDEBUG_REMOTE_HOST" +phpEnvironmentVariable "xdebug.remote_port" "XDEBUG_REMOTE_PORT" + +# profiler +phpEnvironmentVariable "xdebug.profiler_enable" "XDEBUG_PROFILER_ENABLE" +phpEnvironmentVariable "xdebug.profiler_enable_trigger" "XDEBUG_PROFILER_ENABLE_TRIGGER" +phpEnvironmentVariable "xdebug.profiler_enable_trigger_value" "XDEBUG_PROFILER_ENABLE_TRIGGER_VALUE" +phpEnvironmentVariable "xdebug.profiler_output_dir" "XDEBUG_PROFILER_OUTPUT_DIR" +phpEnvironmentVariable "xdebug.profiler_output_name" "XDEBUG_PROFILER_OUTPUT_NAME" + +################### +# BLACKFIRE +################### +phpEnvironmentVariable "blackfire.server_id" "BLACKFIRE_SERVER_ID" +phpEnvironmentVariable "blackfire.server_token" "BLACKFIRE_SERVER_TOKEN" diff --git a/docker/php-nginx-dev/alpine-3-php7/conf/provision/roles/webdevops-php-dev/defaults/main.yml b/docker/php-apache-dev/alpine-php7/conf/provision/roles/webdevops-apache-dev/defaults/main.yml similarity index 100% rename from docker/php-nginx-dev/alpine-3-php7/conf/provision/roles/webdevops-php-dev/defaults/main.yml rename to docker/php-apache-dev/alpine-php7/conf/provision/roles/webdevops-apache-dev/defaults/main.yml diff --git a/docker/php-nginx/alpine-3-php7/conf/provision/roles/webdevops-php-nginx/tasks/entrypoint.yml b/docker/php-apache-dev/alpine-php7/conf/provision/roles/webdevops-apache-dev/tasks/bootstrap.yml similarity index 100% rename from docker/php-nginx/alpine-3-php7/conf/provision/roles/webdevops-php-nginx/tasks/entrypoint.yml rename to docker/php-apache-dev/alpine-php7/conf/provision/roles/webdevops-apache-dev/tasks/bootstrap.yml diff --git a/docker/php-dev/debian-7-php7/conf/provision/roles/webdevops-php-dev/tasks/main.yml b/docker/php-apache-dev/alpine-php7/conf/provision/roles/webdevops-apache-dev/tasks/main.yml similarity index 100% rename from docker/php-dev/debian-7-php7/conf/provision/roles/webdevops-php-dev/tasks/main.yml rename to docker/php-apache-dev/alpine-php7/conf/provision/roles/webdevops-apache-dev/tasks/main.yml diff --git a/docker/php-nginx-dev/alpine-3-php7/conf/provision/roles/webdevops-nginx/defaults/main.yml b/docker/php-apache-dev/alpine-php7/conf/provision/roles/webdevops-apache/defaults/main.yml similarity index 100% rename from docker/php-nginx-dev/alpine-3-php7/conf/provision/roles/webdevops-nginx/defaults/main.yml rename to docker/php-apache-dev/alpine-php7/conf/provision/roles/webdevops-apache/defaults/main.yml diff --git a/docker/php-apache-dev/alpine-php7/conf/provision/roles/webdevops-apache/tasks/bootstrap.yml b/docker/php-apache-dev/alpine-php7/conf/provision/roles/webdevops-apache/tasks/bootstrap.yml new file mode 100644 index 000000000..c285be286 --- /dev/null +++ b/docker/php-apache-dev/alpine-php7/conf/provision/roles/webdevops-apache/tasks/bootstrap.yml @@ -0,0 +1,156 @@ +--- + +- name: Set apache vhost file [RedHat family] + set_fact: + apache_main_path: /etc/httpd/ + apache_docker_vhost: /etc/httpd/conf.d/zzz-docker.conf + when: ansible_os_family == 'RedHat' + +- name: Set apache vhost file [Debian family] + set_fact: + apache_main_path: /etc/apache2/ + apache_docker_vhost: /etc/apache2/sites-enabled/10-docker.conf + when: ansible_os_family == 'Debian' + +- name: Set apache vhost file [Alpine family] + set_fact: + apache_main_path: /etc/apache2/ + apache_docker_vhost: /etc/apache2/conf.d/zzz-docker.conf + when: ansible_os_family == 'Alpine' + +- name: Enable apache main config + file: + src: '/opt/docker/etc/httpd/main.conf' + dest: '{{ apache_docker_vhost }}' + state: link + force: yes + +- name: Ensure document root is available + file: + path: "{{ DOCUMENT_ROOT }}" + state: directory + recurse: yes + +- name: Ensure /var/run/apache2 exists + file: + path: '/var/run/apache2' + state: directory + recurse: yes + +- name: Ensure /run/apache2 exists + file: + path: '/run/apache2' + state: directory + recurse: yes + when: ansible_os_family == 'Alpine' + +- name: Find apache2 files + shell: "find '{{ apache_main_path }}' -type f -iname '*.conf' -o -iname 'default*' -o -iname '*log'" + register: apache2_conf_files + +- name: Change CustomLog to Docker stdout + replace: + dest: '{{ item }}' + regexp: '^[\s]*CustomLog ([^\s]+)(.*)' + replace: 'CustomLog /docker.stdout \2' + with_items: "{{ apache2_conf_files.stdout_lines }}" + +- name: Change CustomLog to Docker stdout + replace: + dest: '{{ item }}' + regexp: '^[\s]*ErrorLog ([^\s]+)(.*)' + replace: 'ErrorLog /docker.stdout \2' + with_items: "{{ apache2_conf_files.stdout_lines }}" + +- name: Change TransferLog to Docker stdout + replace: + dest: '{{ item }}' + regexp: '^[\s]*TransferLog ([^\s]+)(.*)' + replace: 'TransferLog /docker.stdout \2' + with_items: "{{ apache2_conf_files.stdout_lines }}" + +- name: Switch MPM to worker [RedHat family] + lineinfile: + dest: '/etc/httpd/conf.modules.d/00-mpm.conf' + regexp: '^[\s#]*{{ item.line }}' + line: '{{ item.prefix }}{{ item.line }}' + with_items: + - { line: 'LoadModule mpm_prefork_module modules/mod_mpm_prefork.so', prefix: "#" } + - { line: 'LoadModule mpm_event_module modules/mod_mpm_event.so', prefix: "" } + when: ansible_os_family == 'RedHat' + +- name: Switch MPM to event for Apache 2.4 and higher [Ubuntu family] + command: "{{ item }}" + with_items: + - 'a2dismod mpm_event' + - 'a2enmod mpm_event' + when: (ansible_distribution == 'Ubuntu' and docker_image_info_distribution_version|int >= 14) or (ansible_distribution == 'Debian' and docker_image_info_distribution_version|int >= 8) + +- name: Manage modules [Alpine family] + lineinfile: + dest: '/etc/apache2/httpd.conf' + regexp: '^[\s#]*{{ item.line }}' + line: '{{ item.prefix }}{{ item.line }}' + with_items: + - { line: 'LoadModule mpm_prefork_module modules/mod_mpm_prefork.so', prefix: "#" } + - { line: 'LoadModule mpm_event_module modules/mod_mpm_event.so', prefix: "" } + - { line: 'LoadModule deflate_module modules/mod_deflate.so', prefix: "" } + - { line: 'LoadModule rewrite_module modules/mod_rewrite.so', prefix: "" } + - { line: 'LoadModule logio_module modules/mod_logio.so', prefix: "" } + - { line: 'LoadModule slotmem_shm_module modules/mod_slotmem_shm.so', prefix: "" } + - { line: 'LoadModule actions_module modules/mod_actions.so', prefix: "" } + - { line: 'LoadModule expires_module modules/mod_expires.so', prefix: "" } + when: ansible_os_family == 'Alpine' + +- name: Fix ssl support [Alpine family] + lineinfile: + dest: '/etc/apache2/conf.d/ssl.conf' + regexp: '{{ item.regexp }}' + line: '{{ item.line }}' + with_items: + - { regexp: 'LoadModule ssl_module', line: 'LoadModule ssl_module /usr/lib/apache2/mod_ssl.so' } + - { regexp: 'LoadModule socache_shmcb_module', line: 'LoadModule socache_shmcb_module /usr/lib/apache2/mod_socache_shmcb.so' } + when: ansible_os_family == 'Alpine' + +- name: Remove default vhost from ssl configuration [Alpine family] + command: sed -i -e '1h;2,$H;$!d;g' -e 's//#-> removed vhost/g' /etc/apache2/conf.d/ssl.conf + when: ansible_os_family == 'Alpine' + +- name: Disable proxy [Alpine family] + lineinfile: + dest: '/etc/apache2/conf.d/proxy.conf' + regexp: '^[\s#]*{{ item.line }}' + line: '{{ item.prefix }}{{ item.line }}' + with_items: + - { line: 'LoadModule proxy_ajp_module modules/mod_proxy_ajp.so', prefix: "#" } + - { line: 'LoadModule proxy_connect_module modules/mod_proxy_connect.so', prefix: "#" } + - { line: 'LoadModule proxy_balancer_module modules/mod_proxy_balancer.so', prefix: "#" } + - { line: 'LoadModule proxy_express_module modules/mod_proxy_express.so', prefix: "#" } + - { line: 'LoadModule proxy_fcgi_module modules/mod_proxy_fcgi.so', prefix: "" } + - { line: 'LoadModule proxy_fdpass_module modules/mod_proxy_fdpass.so', prefix: "#" } + - { line: 'LoadModule proxy_ftp_module modules/mod_proxy_ftp.so', prefix: "#" } + - { line: 'LoadModule proxy_http_module modules/mod_proxy_http.so', prefix: "#" } + - { line: 'LoadModule proxy_scgi_module modules/mod_proxy_scgi.so', prefix: "#" } + when: ansible_os_family == 'Alpine' + +- name: Fix rights of ssl files + file: + path: "{{ item.path }}" + state: "{{ item.state }}" + mode: "{{ item.mode }}" + owner: "root" + group: "root" + with_items: + - { path: '/opt/docker/etc/httpd/ssl', state: 'directory', mode: '0750' } + - { path: '/opt/docker/etc/httpd/ssl/server.crt', state: 'file', mode: '0640' } + - { path: '/opt/docker/etc/httpd/ssl/server.csr', state: 'file', mode: '0640' } + - { path: '/opt/docker/etc/httpd/ssl/server.key', state: 'file', mode: '0640' } + +- name: Maintain lock directory [Debian family] + file: + path: "/var/lock/apache2" + state: "directory" + mode: "0750" + owner: "www-data" + group: "www-data" + when: ansible_os_family == 'Debian' diff --git a/docker/php-nginx-dev/alpine-3-php7/conf/provision/roles/webdevops-nginx-dev/tasks/main.yml b/docker/php-apache-dev/alpine-php7/conf/provision/roles/webdevops-apache/tasks/main.yml similarity index 100% rename from docker/php-nginx-dev/alpine-3-php7/conf/provision/roles/webdevops-nginx-dev/tasks/main.yml rename to docker/php-apache-dev/alpine-php7/conf/provision/roles/webdevops-apache/tasks/main.yml diff --git a/docker/php-nginx-dev/alpine-3-php7/conf/provision/roles/webdevops-php-nginx/defaults/main.yml b/docker/php-apache-dev/alpine-php7/conf/provision/roles/webdevops-php-apache/defaults/main.yml similarity index 100% rename from docker/php-nginx-dev/alpine-3-php7/conf/provision/roles/webdevops-php-nginx/defaults/main.yml rename to docker/php-apache-dev/alpine-php7/conf/provision/roles/webdevops-php-apache/defaults/main.yml diff --git a/docker/php-apache-dev/alpine-php7/conf/provision/roles/webdevops-php-apache/tasks/bootstrap.yml b/docker/php-apache-dev/alpine-php7/conf/provision/roles/webdevops-php-apache/tasks/bootstrap.yml new file mode 100644 index 000000000..ad5fb2121 --- /dev/null +++ b/docker/php-apache-dev/alpine-php7/conf/provision/roles/webdevops-php-apache/tasks/bootstrap.yml @@ -0,0 +1,8 @@ +--- +- name: Restrict php-fpm to local connection + lineinfile: + dest: '/opt/docker/etc/php/fpm/pool.d/application.conf' + regexp: '^[\s;]*{{ item.key }}[\s]*=' + line: '{{ item.key }} = {{ item.value }}' + with_items: + - { key: 'listen', value: "127.0.0.1:9000" } diff --git a/docker/php-nginx/alpine-3/conf/provision/roles/webdevops-php-nginx/tasks/entrypoint.yml b/docker/php-apache-dev/alpine-php7/conf/provision/roles/webdevops-php-apache/tasks/entrypoint.yml similarity index 100% rename from docker/php-nginx/alpine-3/conf/provision/roles/webdevops-php-nginx/tasks/entrypoint.yml rename to docker/php-apache-dev/alpine-php7/conf/provision/roles/webdevops-php-apache/tasks/entrypoint.yml diff --git a/docker/php-nginx-dev/alpine-3-php7/conf/provision/roles/webdevops-php-nginx/tasks/main.yml b/docker/php-apache-dev/alpine-php7/conf/provision/roles/webdevops-php-apache/tasks/main.yml similarity index 100% rename from docker/php-nginx-dev/alpine-3-php7/conf/provision/roles/webdevops-php-nginx/tasks/main.yml rename to docker/php-apache-dev/alpine-php7/conf/provision/roles/webdevops-php-apache/tasks/main.yml diff --git a/docker/php-nginx-dev/alpine-3/conf/provision/roles/webdevops-nginx-dev/defaults/main.yml b/docker/php-apache-dev/alpine-php7/conf/provision/roles/webdevops-php-dev/defaults/main.yml similarity index 100% rename from docker/php-nginx-dev/alpine-3/conf/provision/roles/webdevops-nginx-dev/defaults/main.yml rename to docker/php-apache-dev/alpine-php7/conf/provision/roles/webdevops-php-dev/defaults/main.yml diff --git a/docker/php-apache-dev/alpine-php7/conf/provision/roles/webdevops-php-dev/tasks/bootstrap.yml b/docker/php-apache-dev/alpine-php7/conf/provision/roles/webdevops-php-dev/tasks/bootstrap.yml new file mode 100644 index 000000000..ff02b05fc --- /dev/null +++ b/docker/php-apache-dev/alpine-php7/conf/provision/roles/webdevops-php-dev/tasks/bootstrap.yml @@ -0,0 +1,7 @@ +--- + +- include: bootstrap/php-fpm.yml +- include: bootstrap/php-module.yml +- include: bootstrap/php-module.opcache.yml +- include: bootstrap/php-module.xdebug.yml +- include: bootstrap/php-module.blackfire.yml diff --git a/docker/php-nginx-dev/alpine-3-php7/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/php-fpm.yml b/docker/php-apache-dev/alpine-php7/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/php-fpm.yml similarity index 100% rename from docker/php-nginx-dev/alpine-3-php7/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/php-fpm.yml rename to docker/php-apache-dev/alpine-php7/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/php-fpm.yml diff --git a/docker/php-apache-dev/alpine-php7/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/php-module.blackfire.yml b/docker/php-apache-dev/alpine-php7/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/php-module.blackfire.yml new file mode 100644 index 000000000..faf05f8de --- /dev/null +++ b/docker/php-apache-dev/alpine-php7/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/php-module.blackfire.yml @@ -0,0 +1,10 @@ +--- + +- name: Remove superfluous blackfire configuration file + file: + path: '{{ item }}' + state: absent + with_items: + - /etc/php5/cli/conf.d/zz-blackfire.ini + - /etc/php5/fpm/conf.d/zz-blackfire.ini + when: ansible_distribution == 'Debian' and docker_image_info_distribution_version|int >= 7 diff --git a/docker/php-nginx-dev/alpine-3-php7/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/php-module.opcache.yml b/docker/php-apache-dev/alpine-php7/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/php-module.opcache.yml similarity index 100% rename from docker/php-nginx-dev/alpine-3-php7/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/php-module.opcache.yml rename to docker/php-apache-dev/alpine-php7/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/php-module.opcache.yml diff --git a/docker/php-nginx-dev/alpine-3-php7/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/php-module.xdebug.yml b/docker/php-apache-dev/alpine-php7/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/php-module.xdebug.yml similarity index 100% rename from docker/php-nginx-dev/alpine-3-php7/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/php-module.xdebug.yml rename to docker/php-apache-dev/alpine-php7/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/php-module.xdebug.yml diff --git a/docker/php-nginx-dev/alpine-3-php7/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/php-module.yml b/docker/php-apache-dev/alpine-php7/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/php-module.yml similarity index 100% rename from docker/php-nginx-dev/alpine-3-php7/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/php-module.yml rename to docker/php-apache-dev/alpine-php7/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/php-module.yml diff --git a/docker/php-nginx-dev/alpine-3-php7/conf/provision/roles/webdevops-nginx/tasks/main.yml b/docker/php-apache-dev/alpine-php7/conf/provision/roles/webdevops-php-dev/tasks/main.yml similarity index 100% rename from docker/php-nginx-dev/alpine-3-php7/conf/provision/roles/webdevops-nginx/tasks/main.yml rename to docker/php-apache-dev/alpine-php7/conf/provision/roles/webdevops-php-dev/tasks/main.yml diff --git a/docker/php-apache-dev/centos-7-php56/Dockerfile b/docker/php-apache-dev/centos-7-php56/Dockerfile index 55ed16b85..e7cef5948 100644 --- a/docker/php-apache-dev/centos-7-php56/Dockerfile +++ b/docker/php-apache-dev/centos-7-php56/Dockerfile @@ -5,16 +5,11 @@ FROM webdevops/php-dev:centos-7-php56 -MAINTAINER info@webdevops.io -LABEL vendor=WebDevOps.io -LABEL io.webdevops.layout=8 -LABEL io.webdevops.version=1.5.0 - -ENV WEB_DOCUMENT_ROOT /app -ENV WEB_DOCUMENT_INDEX index.php -ENV WEB_ALIAS_DOMAIN *.vm -ENV WEB_PHP_SOCKET 127.0.0.1:9000 -ENV WEB_NO_CACHE_PATTERN "\.(css|js|gif|png|jpg|svg|json|xml)$" +ENV WEB_DOCUMENT_ROOT=/app \ + WEB_DOCUMENT_INDEX=index.php \ + WEB_ALIAS_DOMAIN=*.vm +ENV WEB_PHP_SOCKET=127.0.0.1:9000 +ENV WEB_NO_CACHE_PATTERN="\.(css|js|gif|png|jpg|svg|json|xml)$" COPY conf/ /opt/docker/ @@ -27,7 +22,7 @@ RUN /usr/local/bin/yum-install \ s!^(\s*ErrorLog)\s+\S+!\1 /proc/self/fd/2!g; \ ' /etc/httpd/conf/httpd.conf /etc/httpd/conf.d/ssl.conf \ && /opt/docker/bin/provision run --tag bootstrap --role webdevops-apache --role webdevops-php-apache --role webdevops-apache-dev --role webdevops-php-dev \ - && /opt/docker/bin/bootstrap.sh - + && /opt/docker/bin/bootstrap.sh \ + && docker-image-cleanup EXPOSE 80 443 diff --git a/docker/php-apache-dev/centos-7-php56/Dockerfile.jinja2 b/docker/php-apache-dev/centos-7-php56/Dockerfile.jinja2 index 9884776c6..a7d213f46 100644 --- a/docker/php-apache-dev/centos-7-php56/Dockerfile.jinja2 +++ b/docker/php-apache-dev/centos-7-php56/Dockerfile.jinja2 @@ -1,7 +1,5 @@ {{ docker.from("php-dev", "centos-7-php56") }} -{{ docker.version() }} - {{ environment.web() }} {{ environment.webPhp() }} {{ environment.webDevelopment() }} diff --git a/docker/php-apache-dev/centos-7-php56/conf/bin/service.d/httpd.d/10-init.sh b/docker/php-apache-dev/centos-7-php56/conf/bin/service.d/httpd.d/10-init.sh index d3f1a0c9c..b9d57997e 100644 --- a/docker/php-apache-dev/centos-7-php56/conf/bin/service.d/httpd.d/10-init.sh +++ b/docker/php-apache-dev/centos-7-php56/conf/bin/service.d/httpd.d/10-init.sh @@ -5,15 +5,17 @@ if [[ ! -e "$WEB_DOCUMENT_ROOT" ]]; then fi # Replace markers -find /opt/docker/etc/httpd/ -iname '*.conf' -print0 | xargs -0 -r rpl --quiet "" "$WEB_DOCUMENT_INDEX" > /dev/null -find /opt/docker/etc/httpd/ -iname '*.conf' -print0 | xargs -0 -r rpl --quiet "" "$WEB_DOCUMENT_ROOT" > /dev/null -find /opt/docker/etc/httpd/ -iname '*.conf' -print0 | xargs -0 -r rpl --quiet "" "$WEB_ALIAS_DOMAIN" > /dev/null -find /opt/docker/etc/httpd/ -iname '*.conf' -print0 | xargs -0 -r rpl --quiet "" "$HOSTNAME" > /dev/null +go-replace \ + -s "" -r "$WEB_DOCUMENT_INDEX" \ + -s "" -r "$WEB_DOCUMENT_ROOT" \ + -s "" -r "$WEB_ALIAS_DOMAIN" \ + -s "" -r "$HOSTNAME" \ + -s "" -r "$WEB_PHP_SOCKET" \ + --path=/opt/docker/etc/httpd/ \ + --path-pattern='*.conf' \ + --ignore-empty -if [[ -n "${WEB_PHP_SOCKET+x}" ]]; then - ## WEB_PHP_SOCKET is set - find /opt/docker/etc/httpd/ -iname '*.conf' -print0 | xargs -0 -r rpl --quiet "" "$WEB_PHP_SOCKET" > /dev/null -else +if [[ -z "${WEB_PHP_SOCKET+x}" ]]; then ## WEB_PHP_SOCKET is not set, remove PHP files rm -f -- /opt/docker/etc/httpd/conf.d/10-php.conf fi diff --git a/docker/php-apache-dev/centos-7-php56/conf/bin/service.d/httpd.d/12-development.sh b/docker/php-apache-dev/centos-7-php56/conf/bin/service.d/httpd.d/12-development.sh index 299f67e2f..a9d2c6e92 100644 --- a/docker/php-apache-dev/centos-7-php56/conf/bin/service.d/httpd.d/12-development.sh +++ b/docker/php-apache-dev/centos-7-php56/conf/bin/service.d/httpd.d/12-development.sh @@ -1 +1,5 @@ -find /opt/docker/etc/httpd/ -iname '*.conf' -print0 | xargs -0 -r rpl --quiet "" "$WEB_NO_CACHE_PATTERN" > /dev/null +go-replace \ + -s "" -r "$WEB_NO_CACHE_PATTERN" \ + --path=/opt/docker/etc/httpd/ \ + --path-pattern='*.conf' \ + --ignore-empty diff --git a/docker/php-apache-dev/centos-7-php56/conf/etc/httpd/conf.d/10-log.conf b/docker/php-apache-dev/centos-7-php56/conf/etc/httpd/conf.d/10-log.conf index e4c4be4f2..ef0c73d38 100644 --- a/docker/php-apache-dev/centos-7-php56/conf/etc/httpd/conf.d/10-log.conf +++ b/docker/php-apache-dev/centos-7-php56/conf/etc/httpd/conf.d/10-log.conf @@ -1,4 +1,4 @@ LogFormat "[httpd:access] %V:%p %h %l %u %t \"%r\" %>s bytesIn:%I bytesOut:%O reqTime:%T" dockerlog LogLevel warn -CustomLog /proc/self/fd/1 dockerlog -ErrorLog /proc/self/fd/2 +CustomLog /docker.stdout dockerlog +ErrorLog /docker.stderr diff --git a/docker/php-apache-dev/centos-7-php56/conf/provision/entrypoint.d/10-php-debugger.sh b/docker/php-apache-dev/centos-7-php56/conf/provision/entrypoint.d/10-php-debugger.sh index 7156e28aa..b5985a9ef 100644 --- a/docker/php-apache-dev/centos-7-php56/conf/provision/entrypoint.d/10-php-debugger.sh +++ b/docker/php-apache-dev/centos-7-php56/conf/provision/entrypoint.d/10-php-debugger.sh @@ -15,7 +15,8 @@ PHP_CONF_PATHS=" /etc/php5/fpm/conf.d /etc/php/7.0/mods-available /etc/php/7.0/cli/conf.d -/etc/php/7.0/fpm/conf.d" +/etc/php/7.0/fpm/conf.d +/usr/local/etc/php/conf.d/" function phpModuleRemove() { if [ "$#" -ne 1 ]; then @@ -40,7 +41,7 @@ if [[ -n "${PHP_DEBUGGER+x}" ]]; then blackfire) echo "PHP-Debugger: Blackfire enabled" phpModuleRemove "xdebug" - /opt/docker/bin/control.sh service.enable blackfire-agent + docker-service-enable blackfire-agent ;; none) diff --git a/docker/php-apache-dev/centos-7-php56/conf/provision/roles/webdevops-apache/tasks/bootstrap.yml b/docker/php-apache-dev/centos-7-php56/conf/provision/roles/webdevops-apache/tasks/bootstrap.yml index 2be18b0e0..c285be286 100644 --- a/docker/php-apache-dev/centos-7-php56/conf/provision/roles/webdevops-apache/tasks/bootstrap.yml +++ b/docker/php-apache-dev/centos-7-php56/conf/provision/roles/webdevops-apache/tasks/bootstrap.yml @@ -84,7 +84,7 @@ with_items: - 'a2dismod mpm_event' - 'a2enmod mpm_event' - when: (ansible_distribution == 'Ubuntu' and ansible_lsb.major_release|int >= 14) or (ansible_distribution == 'Debian' and ansible_lsb.major_release|int >= 8) + when: (ansible_distribution == 'Ubuntu' and docker_image_info_distribution_version|int >= 14) or (ansible_distribution == 'Debian' and docker_image_info_distribution_version|int >= 8) - name: Manage modules [Alpine family] lineinfile: diff --git a/docker/php-apache-dev/centos-7-php56/conf/provision/roles/webdevops-php-dev/tasks/bootstrap.yml b/docker/php-apache-dev/centos-7-php56/conf/provision/roles/webdevops-php-dev/tasks/bootstrap.yml index 2c5d76e3d..ff02b05fc 100644 --- a/docker/php-apache-dev/centos-7-php56/conf/provision/roles/webdevops-php-dev/tasks/bootstrap.yml +++ b/docker/php-apache-dev/centos-7-php56/conf/provision/roles/webdevops-php-dev/tasks/bootstrap.yml @@ -1,6 +1,5 @@ --- -- include: bootstrap/tools.yml - include: bootstrap/php-fpm.yml - include: bootstrap/php-module.yml - include: bootstrap/php-module.opcache.yml diff --git a/docker/php-apache-dev/centos-7-php56/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/php-module.blackfire.yml b/docker/php-apache-dev/centos-7-php56/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/php-module.blackfire.yml index 1a3db9bac..faf05f8de 100644 --- a/docker/php-apache-dev/centos-7-php56/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/php-module.blackfire.yml +++ b/docker/php-apache-dev/centos-7-php56/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/php-module.blackfire.yml @@ -7,4 +7,4 @@ with_items: - /etc/php5/cli/conf.d/zz-blackfire.ini - /etc/php5/fpm/conf.d/zz-blackfire.ini - when: ansible_distribution == 'Debian' and ansible_lsb.major_release|int >= 7 + when: ansible_distribution == 'Debian' and docker_image_info_distribution_version|int >= 7 diff --git a/docker/php-apache-dev/centos-7-php56/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/tools.yml b/docker/php-apache-dev/centos-7-php56/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/tools.yml deleted file mode 100644 index c49cb0e34..000000000 --- a/docker/php-apache-dev/centos-7-php56/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/tools.yml +++ /dev/null @@ -1,23 +0,0 @@ ---- - -- name: Downloading Tools - shell: curl -o "{{ item.dest }}" "{{ item.url }}" && chmod 755 "{{ item.dest }}" - with_items: - - { url: "https://phar.phpunit.de/phploc.phar", dest: /usr/local/bin/phploc } - - { url: "https://phar.phpunit.de/phpunit.phar", dest: /usr/local/bin/phpunit } - - { url: "http://static.pdepend.org/php/latest/pdepend.phar", dest: /usr/local/bin/pdepend } - - { url: "http://static.phpmd.org/php/latest/phpmd.phar", dest: /usr/local/bin/phpmd } - - { url: "https://squizlabs.github.io/PHP_CodeSniffer/phpcs.phar", dest: /usr/local/bin/phpcs } - - { url: "https://squizlabs.github.io/PHP_CodeSniffer/phpcbf.phar", dest: /usr/local/bin/phpcbf } - - { url: "https://phar.phpunit.de/phpcpd.phar", dest: /usr/local/bin/phpcpd } - - { url: "https://phar.phpunit.de/phpdcd.phar", dest: /usr/local/bin/phpdcd } - - { url: "https://github.com/Halleck45/PhpMetrics/raw/master/build/phpmetrics.phar", dest: /usr/local/bin/phpmetrics } - - { url: "http://get.sensiolabs.org/php-cs-fixer.phar", dest: /usr/local/bin/php-cs-fixer } - - { url: "https://github.com/sensiolabs-de/deprecation-detector/releases/download/0.1.0-alpha4/deprecation-detector.phar", dest: /usr/local/bin/deprecation-detector } - - { url: "https://github.com/sensiolabs-de/deprecation-detector/releases/download/0.1.0-alpha4/deprecation-detector.phar", dest: /usr/local/bin/deprecation-detector } - -- name: Install Tools via composer - raw: COMPOSER_HOME="/usr/local/composer" COMPOSER_BIN_DIR="/usr/local/bin" composer global require "{{ item.package }}" "{{ item.version }}" - with_items: - - { package: "sstalle/php7cc" , version: "*" } - - { package: "phpspec/phpspec" , version: "~2.0" } diff --git a/docker/php-apache-dev/centos-7-php7/Dockerfile b/docker/php-apache-dev/centos-7-php7/Dockerfile index 74293f318..6f50a8280 100644 --- a/docker/php-apache-dev/centos-7-php7/Dockerfile +++ b/docker/php-apache-dev/centos-7-php7/Dockerfile @@ -5,16 +5,11 @@ FROM webdevops/php-dev:centos-7-php7 -MAINTAINER info@webdevops.io -LABEL vendor=WebDevOps.io -LABEL io.webdevops.layout=8 -LABEL io.webdevops.version=1.5.0 - -ENV WEB_DOCUMENT_ROOT /app -ENV WEB_DOCUMENT_INDEX index.php -ENV WEB_ALIAS_DOMAIN *.vm -ENV WEB_PHP_SOCKET 127.0.0.1:9000 -ENV WEB_NO_CACHE_PATTERN "\.(css|js|gif|png|jpg|svg|json|xml)$" +ENV WEB_DOCUMENT_ROOT=/app \ + WEB_DOCUMENT_INDEX=index.php \ + WEB_ALIAS_DOMAIN=*.vm +ENV WEB_PHP_SOCKET=127.0.0.1:9000 +ENV WEB_NO_CACHE_PATTERN="\.(css|js|gif|png|jpg|svg|json|xml)$" COPY conf/ /opt/docker/ @@ -27,7 +22,7 @@ RUN /usr/local/bin/yum-install \ s!^(\s*ErrorLog)\s+\S+!\1 /proc/self/fd/2!g; \ ' /etc/httpd/conf/httpd.conf /etc/httpd/conf.d/ssl.conf \ && /opt/docker/bin/provision run --tag bootstrap --role webdevops-apache --role webdevops-php-apache --role webdevops-apache-dev --role webdevops-php-dev \ - && /opt/docker/bin/bootstrap.sh - + && /opt/docker/bin/bootstrap.sh \ + && docker-image-cleanup EXPOSE 80 443 diff --git a/docker/php-apache-dev/centos-7-php7/Dockerfile.jinja2 b/docker/php-apache-dev/centos-7-php7/Dockerfile.jinja2 index 06799f985..284ce6b2c 100644 --- a/docker/php-apache-dev/centos-7-php7/Dockerfile.jinja2 +++ b/docker/php-apache-dev/centos-7-php7/Dockerfile.jinja2 @@ -1,7 +1,5 @@ {{ docker.from("php-dev", "centos-7-php7") }} -{{ docker.version() }} - {{ environment.web() }} {{ environment.webPhp() }} {{ environment.webDevelopment() }} diff --git a/docker/php-apache-dev/centos-7-php7/conf/bin/service.d/httpd.d/10-init.sh b/docker/php-apache-dev/centos-7-php7/conf/bin/service.d/httpd.d/10-init.sh index d3f1a0c9c..b9d57997e 100644 --- a/docker/php-apache-dev/centos-7-php7/conf/bin/service.d/httpd.d/10-init.sh +++ b/docker/php-apache-dev/centos-7-php7/conf/bin/service.d/httpd.d/10-init.sh @@ -5,15 +5,17 @@ if [[ ! -e "$WEB_DOCUMENT_ROOT" ]]; then fi # Replace markers -find /opt/docker/etc/httpd/ -iname '*.conf' -print0 | xargs -0 -r rpl --quiet "" "$WEB_DOCUMENT_INDEX" > /dev/null -find /opt/docker/etc/httpd/ -iname '*.conf' -print0 | xargs -0 -r rpl --quiet "" "$WEB_DOCUMENT_ROOT" > /dev/null -find /opt/docker/etc/httpd/ -iname '*.conf' -print0 | xargs -0 -r rpl --quiet "" "$WEB_ALIAS_DOMAIN" > /dev/null -find /opt/docker/etc/httpd/ -iname '*.conf' -print0 | xargs -0 -r rpl --quiet "" "$HOSTNAME" > /dev/null +go-replace \ + -s "" -r "$WEB_DOCUMENT_INDEX" \ + -s "" -r "$WEB_DOCUMENT_ROOT" \ + -s "" -r "$WEB_ALIAS_DOMAIN" \ + -s "" -r "$HOSTNAME" \ + -s "" -r "$WEB_PHP_SOCKET" \ + --path=/opt/docker/etc/httpd/ \ + --path-pattern='*.conf' \ + --ignore-empty -if [[ -n "${WEB_PHP_SOCKET+x}" ]]; then - ## WEB_PHP_SOCKET is set - find /opt/docker/etc/httpd/ -iname '*.conf' -print0 | xargs -0 -r rpl --quiet "" "$WEB_PHP_SOCKET" > /dev/null -else +if [[ -z "${WEB_PHP_SOCKET+x}" ]]; then ## WEB_PHP_SOCKET is not set, remove PHP files rm -f -- /opt/docker/etc/httpd/conf.d/10-php.conf fi diff --git a/docker/php-apache-dev/centos-7-php7/conf/bin/service.d/httpd.d/12-development.sh b/docker/php-apache-dev/centos-7-php7/conf/bin/service.d/httpd.d/12-development.sh index 299f67e2f..a9d2c6e92 100644 --- a/docker/php-apache-dev/centos-7-php7/conf/bin/service.d/httpd.d/12-development.sh +++ b/docker/php-apache-dev/centos-7-php7/conf/bin/service.d/httpd.d/12-development.sh @@ -1 +1,5 @@ -find /opt/docker/etc/httpd/ -iname '*.conf' -print0 | xargs -0 -r rpl --quiet "" "$WEB_NO_CACHE_PATTERN" > /dev/null +go-replace \ + -s "" -r "$WEB_NO_CACHE_PATTERN" \ + --path=/opt/docker/etc/httpd/ \ + --path-pattern='*.conf' \ + --ignore-empty diff --git a/docker/php-apache-dev/centos-7-php7/conf/etc/httpd/conf.d/10-log.conf b/docker/php-apache-dev/centos-7-php7/conf/etc/httpd/conf.d/10-log.conf index e4c4be4f2..ef0c73d38 100644 --- a/docker/php-apache-dev/centos-7-php7/conf/etc/httpd/conf.d/10-log.conf +++ b/docker/php-apache-dev/centos-7-php7/conf/etc/httpd/conf.d/10-log.conf @@ -1,4 +1,4 @@ LogFormat "[httpd:access] %V:%p %h %l %u %t \"%r\" %>s bytesIn:%I bytesOut:%O reqTime:%T" dockerlog LogLevel warn -CustomLog /proc/self/fd/1 dockerlog -ErrorLog /proc/self/fd/2 +CustomLog /docker.stdout dockerlog +ErrorLog /docker.stderr diff --git a/docker/php-apache-dev/centos-7-php7/conf/provision/entrypoint.d/10-php-debugger.sh b/docker/php-apache-dev/centos-7-php7/conf/provision/entrypoint.d/10-php-debugger.sh index 7156e28aa..b5985a9ef 100644 --- a/docker/php-apache-dev/centos-7-php7/conf/provision/entrypoint.d/10-php-debugger.sh +++ b/docker/php-apache-dev/centos-7-php7/conf/provision/entrypoint.d/10-php-debugger.sh @@ -15,7 +15,8 @@ PHP_CONF_PATHS=" /etc/php5/fpm/conf.d /etc/php/7.0/mods-available /etc/php/7.0/cli/conf.d -/etc/php/7.0/fpm/conf.d" +/etc/php/7.0/fpm/conf.d +/usr/local/etc/php/conf.d/" function phpModuleRemove() { if [ "$#" -ne 1 ]; then @@ -40,7 +41,7 @@ if [[ -n "${PHP_DEBUGGER+x}" ]]; then blackfire) echo "PHP-Debugger: Blackfire enabled" phpModuleRemove "xdebug" - /opt/docker/bin/control.sh service.enable blackfire-agent + docker-service-enable blackfire-agent ;; none) diff --git a/docker/php-apache-dev/centos-7-php7/conf/provision/roles/webdevops-apache/tasks/bootstrap.yml b/docker/php-apache-dev/centos-7-php7/conf/provision/roles/webdevops-apache/tasks/bootstrap.yml index 2be18b0e0..c285be286 100644 --- a/docker/php-apache-dev/centos-7-php7/conf/provision/roles/webdevops-apache/tasks/bootstrap.yml +++ b/docker/php-apache-dev/centos-7-php7/conf/provision/roles/webdevops-apache/tasks/bootstrap.yml @@ -84,7 +84,7 @@ with_items: - 'a2dismod mpm_event' - 'a2enmod mpm_event' - when: (ansible_distribution == 'Ubuntu' and ansible_lsb.major_release|int >= 14) or (ansible_distribution == 'Debian' and ansible_lsb.major_release|int >= 8) + when: (ansible_distribution == 'Ubuntu' and docker_image_info_distribution_version|int >= 14) or (ansible_distribution == 'Debian' and docker_image_info_distribution_version|int >= 8) - name: Manage modules [Alpine family] lineinfile: diff --git a/docker/php-apache-dev/centos-7-php7/conf/provision/roles/webdevops-php-dev/tasks/bootstrap.yml b/docker/php-apache-dev/centos-7-php7/conf/provision/roles/webdevops-php-dev/tasks/bootstrap.yml index 2c5d76e3d..ff02b05fc 100644 --- a/docker/php-apache-dev/centos-7-php7/conf/provision/roles/webdevops-php-dev/tasks/bootstrap.yml +++ b/docker/php-apache-dev/centos-7-php7/conf/provision/roles/webdevops-php-dev/tasks/bootstrap.yml @@ -1,6 +1,5 @@ --- -- include: bootstrap/tools.yml - include: bootstrap/php-fpm.yml - include: bootstrap/php-module.yml - include: bootstrap/php-module.opcache.yml diff --git a/docker/php-apache-dev/centos-7-php7/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/php-module.blackfire.yml b/docker/php-apache-dev/centos-7-php7/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/php-module.blackfire.yml index 1a3db9bac..faf05f8de 100644 --- a/docker/php-apache-dev/centos-7-php7/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/php-module.blackfire.yml +++ b/docker/php-apache-dev/centos-7-php7/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/php-module.blackfire.yml @@ -7,4 +7,4 @@ with_items: - /etc/php5/cli/conf.d/zz-blackfire.ini - /etc/php5/fpm/conf.d/zz-blackfire.ini - when: ansible_distribution == 'Debian' and ansible_lsb.major_release|int >= 7 + when: ansible_distribution == 'Debian' and docker_image_info_distribution_version|int >= 7 diff --git a/docker/php-apache-dev/centos-7-php7/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/tools.yml b/docker/php-apache-dev/centos-7-php7/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/tools.yml deleted file mode 100644 index c49cb0e34..000000000 --- a/docker/php-apache-dev/centos-7-php7/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/tools.yml +++ /dev/null @@ -1,23 +0,0 @@ ---- - -- name: Downloading Tools - shell: curl -o "{{ item.dest }}" "{{ item.url }}" && chmod 755 "{{ item.dest }}" - with_items: - - { url: "https://phar.phpunit.de/phploc.phar", dest: /usr/local/bin/phploc } - - { url: "https://phar.phpunit.de/phpunit.phar", dest: /usr/local/bin/phpunit } - - { url: "http://static.pdepend.org/php/latest/pdepend.phar", dest: /usr/local/bin/pdepend } - - { url: "http://static.phpmd.org/php/latest/phpmd.phar", dest: /usr/local/bin/phpmd } - - { url: "https://squizlabs.github.io/PHP_CodeSniffer/phpcs.phar", dest: /usr/local/bin/phpcs } - - { url: "https://squizlabs.github.io/PHP_CodeSniffer/phpcbf.phar", dest: /usr/local/bin/phpcbf } - - { url: "https://phar.phpunit.de/phpcpd.phar", dest: /usr/local/bin/phpcpd } - - { url: "https://phar.phpunit.de/phpdcd.phar", dest: /usr/local/bin/phpdcd } - - { url: "https://github.com/Halleck45/PhpMetrics/raw/master/build/phpmetrics.phar", dest: /usr/local/bin/phpmetrics } - - { url: "http://get.sensiolabs.org/php-cs-fixer.phar", dest: /usr/local/bin/php-cs-fixer } - - { url: "https://github.com/sensiolabs-de/deprecation-detector/releases/download/0.1.0-alpha4/deprecation-detector.phar", dest: /usr/local/bin/deprecation-detector } - - { url: "https://github.com/sensiolabs-de/deprecation-detector/releases/download/0.1.0-alpha4/deprecation-detector.phar", dest: /usr/local/bin/deprecation-detector } - -- name: Install Tools via composer - raw: COMPOSER_HOME="/usr/local/composer" COMPOSER_BIN_DIR="/usr/local/bin" composer global require "{{ item.package }}" "{{ item.version }}" - with_items: - - { package: "sstalle/php7cc" , version: "*" } - - { package: "phpspec/phpspec" , version: "~2.0" } diff --git a/docker/php-apache-dev/centos-7/Dockerfile b/docker/php-apache-dev/centos-7/Dockerfile index 924a5eb8e..643fe49df 100644 --- a/docker/php-apache-dev/centos-7/Dockerfile +++ b/docker/php-apache-dev/centos-7/Dockerfile @@ -5,16 +5,11 @@ FROM webdevops/php-dev:centos-7 -MAINTAINER info@webdevops.io -LABEL vendor=WebDevOps.io -LABEL io.webdevops.layout=8 -LABEL io.webdevops.version=1.5.0 - -ENV WEB_DOCUMENT_ROOT /app -ENV WEB_DOCUMENT_INDEX index.php -ENV WEB_ALIAS_DOMAIN *.vm -ENV WEB_PHP_SOCKET 127.0.0.1:9000 -ENV WEB_NO_CACHE_PATTERN "\.(css|js|gif|png|jpg|svg|json|xml)$" +ENV WEB_DOCUMENT_ROOT=/app \ + WEB_DOCUMENT_INDEX=index.php \ + WEB_ALIAS_DOMAIN=*.vm +ENV WEB_PHP_SOCKET=127.0.0.1:9000 +ENV WEB_NO_CACHE_PATTERN="\.(css|js|gif|png|jpg|svg|json|xml)$" COPY conf/ /opt/docker/ @@ -27,7 +22,7 @@ RUN /usr/local/bin/yum-install \ s!^(\s*ErrorLog)\s+\S+!\1 /proc/self/fd/2!g; \ ' /etc/httpd/conf/httpd.conf /etc/httpd/conf.d/ssl.conf \ && /opt/docker/bin/provision run --tag bootstrap --role webdevops-apache --role webdevops-php-apache --role webdevops-apache-dev --role webdevops-php-dev \ - && /opt/docker/bin/bootstrap.sh - + && /opt/docker/bin/bootstrap.sh \ + && docker-image-cleanup EXPOSE 80 443 diff --git a/docker/php-apache-dev/centos-7/Dockerfile.jinja2 b/docker/php-apache-dev/centos-7/Dockerfile.jinja2 index e3596a41d..b3962dba8 100644 --- a/docker/php-apache-dev/centos-7/Dockerfile.jinja2 +++ b/docker/php-apache-dev/centos-7/Dockerfile.jinja2 @@ -1,7 +1,5 @@ {{ docker.from("php-dev", "centos-7") }} -{{ docker.version() }} - {{ environment.web() }} {{ environment.webPhp() }} {{ environment.webDevelopment() }} diff --git a/docker/php-apache-dev/centos-7/conf/bin/service.d/httpd.d/10-init.sh b/docker/php-apache-dev/centos-7/conf/bin/service.d/httpd.d/10-init.sh index d3f1a0c9c..b9d57997e 100644 --- a/docker/php-apache-dev/centos-7/conf/bin/service.d/httpd.d/10-init.sh +++ b/docker/php-apache-dev/centos-7/conf/bin/service.d/httpd.d/10-init.sh @@ -5,15 +5,17 @@ if [[ ! -e "$WEB_DOCUMENT_ROOT" ]]; then fi # Replace markers -find /opt/docker/etc/httpd/ -iname '*.conf' -print0 | xargs -0 -r rpl --quiet "" "$WEB_DOCUMENT_INDEX" > /dev/null -find /opt/docker/etc/httpd/ -iname '*.conf' -print0 | xargs -0 -r rpl --quiet "" "$WEB_DOCUMENT_ROOT" > /dev/null -find /opt/docker/etc/httpd/ -iname '*.conf' -print0 | xargs -0 -r rpl --quiet "" "$WEB_ALIAS_DOMAIN" > /dev/null -find /opt/docker/etc/httpd/ -iname '*.conf' -print0 | xargs -0 -r rpl --quiet "" "$HOSTNAME" > /dev/null +go-replace \ + -s "" -r "$WEB_DOCUMENT_INDEX" \ + -s "" -r "$WEB_DOCUMENT_ROOT" \ + -s "" -r "$WEB_ALIAS_DOMAIN" \ + -s "" -r "$HOSTNAME" \ + -s "" -r "$WEB_PHP_SOCKET" \ + --path=/opt/docker/etc/httpd/ \ + --path-pattern='*.conf' \ + --ignore-empty -if [[ -n "${WEB_PHP_SOCKET+x}" ]]; then - ## WEB_PHP_SOCKET is set - find /opt/docker/etc/httpd/ -iname '*.conf' -print0 | xargs -0 -r rpl --quiet "" "$WEB_PHP_SOCKET" > /dev/null -else +if [[ -z "${WEB_PHP_SOCKET+x}" ]]; then ## WEB_PHP_SOCKET is not set, remove PHP files rm -f -- /opt/docker/etc/httpd/conf.d/10-php.conf fi diff --git a/docker/php-apache-dev/centos-7/conf/bin/service.d/httpd.d/12-development.sh b/docker/php-apache-dev/centos-7/conf/bin/service.d/httpd.d/12-development.sh index 299f67e2f..a9d2c6e92 100644 --- a/docker/php-apache-dev/centos-7/conf/bin/service.d/httpd.d/12-development.sh +++ b/docker/php-apache-dev/centos-7/conf/bin/service.d/httpd.d/12-development.sh @@ -1 +1,5 @@ -find /opt/docker/etc/httpd/ -iname '*.conf' -print0 | xargs -0 -r rpl --quiet "" "$WEB_NO_CACHE_PATTERN" > /dev/null +go-replace \ + -s "" -r "$WEB_NO_CACHE_PATTERN" \ + --path=/opt/docker/etc/httpd/ \ + --path-pattern='*.conf' \ + --ignore-empty diff --git a/docker/php-apache-dev/centos-7/conf/etc/httpd/conf.d/10-log.conf b/docker/php-apache-dev/centos-7/conf/etc/httpd/conf.d/10-log.conf index e4c4be4f2..ef0c73d38 100644 --- a/docker/php-apache-dev/centos-7/conf/etc/httpd/conf.d/10-log.conf +++ b/docker/php-apache-dev/centos-7/conf/etc/httpd/conf.d/10-log.conf @@ -1,4 +1,4 @@ LogFormat "[httpd:access] %V:%p %h %l %u %t \"%r\" %>s bytesIn:%I bytesOut:%O reqTime:%T" dockerlog LogLevel warn -CustomLog /proc/self/fd/1 dockerlog -ErrorLog /proc/self/fd/2 +CustomLog /docker.stdout dockerlog +ErrorLog /docker.stderr diff --git a/docker/php-apache-dev/centos-7/conf/provision/entrypoint.d/10-php-debugger.sh b/docker/php-apache-dev/centos-7/conf/provision/entrypoint.d/10-php-debugger.sh index 7156e28aa..b5985a9ef 100644 --- a/docker/php-apache-dev/centos-7/conf/provision/entrypoint.d/10-php-debugger.sh +++ b/docker/php-apache-dev/centos-7/conf/provision/entrypoint.d/10-php-debugger.sh @@ -15,7 +15,8 @@ PHP_CONF_PATHS=" /etc/php5/fpm/conf.d /etc/php/7.0/mods-available /etc/php/7.0/cli/conf.d -/etc/php/7.0/fpm/conf.d" +/etc/php/7.0/fpm/conf.d +/usr/local/etc/php/conf.d/" function phpModuleRemove() { if [ "$#" -ne 1 ]; then @@ -40,7 +41,7 @@ if [[ -n "${PHP_DEBUGGER+x}" ]]; then blackfire) echo "PHP-Debugger: Blackfire enabled" phpModuleRemove "xdebug" - /opt/docker/bin/control.sh service.enable blackfire-agent + docker-service-enable blackfire-agent ;; none) diff --git a/docker/php-apache-dev/centos-7/conf/provision/roles/webdevops-apache/tasks/bootstrap.yml b/docker/php-apache-dev/centos-7/conf/provision/roles/webdevops-apache/tasks/bootstrap.yml index 2be18b0e0..c285be286 100644 --- a/docker/php-apache-dev/centos-7/conf/provision/roles/webdevops-apache/tasks/bootstrap.yml +++ b/docker/php-apache-dev/centos-7/conf/provision/roles/webdevops-apache/tasks/bootstrap.yml @@ -84,7 +84,7 @@ with_items: - 'a2dismod mpm_event' - 'a2enmod mpm_event' - when: (ansible_distribution == 'Ubuntu' and ansible_lsb.major_release|int >= 14) or (ansible_distribution == 'Debian' and ansible_lsb.major_release|int >= 8) + when: (ansible_distribution == 'Ubuntu' and docker_image_info_distribution_version|int >= 14) or (ansible_distribution == 'Debian' and docker_image_info_distribution_version|int >= 8) - name: Manage modules [Alpine family] lineinfile: diff --git a/docker/php-apache-dev/centos-7/conf/provision/roles/webdevops-php-dev/tasks/bootstrap.yml b/docker/php-apache-dev/centos-7/conf/provision/roles/webdevops-php-dev/tasks/bootstrap.yml index 2c5d76e3d..ff02b05fc 100644 --- a/docker/php-apache-dev/centos-7/conf/provision/roles/webdevops-php-dev/tasks/bootstrap.yml +++ b/docker/php-apache-dev/centos-7/conf/provision/roles/webdevops-php-dev/tasks/bootstrap.yml @@ -1,6 +1,5 @@ --- -- include: bootstrap/tools.yml - include: bootstrap/php-fpm.yml - include: bootstrap/php-module.yml - include: bootstrap/php-module.opcache.yml diff --git a/docker/php-apache-dev/centos-7/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/php-module.blackfire.yml b/docker/php-apache-dev/centos-7/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/php-module.blackfire.yml index 1a3db9bac..faf05f8de 100644 --- a/docker/php-apache-dev/centos-7/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/php-module.blackfire.yml +++ b/docker/php-apache-dev/centos-7/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/php-module.blackfire.yml @@ -7,4 +7,4 @@ with_items: - /etc/php5/cli/conf.d/zz-blackfire.ini - /etc/php5/fpm/conf.d/zz-blackfire.ini - when: ansible_distribution == 'Debian' and ansible_lsb.major_release|int >= 7 + when: ansible_distribution == 'Debian' and docker_image_info_distribution_version|int >= 7 diff --git a/docker/php-apache-dev/centos-7/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/tools.yml b/docker/php-apache-dev/centos-7/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/tools.yml deleted file mode 100644 index c49cb0e34..000000000 --- a/docker/php-apache-dev/centos-7/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/tools.yml +++ /dev/null @@ -1,23 +0,0 @@ ---- - -- name: Downloading Tools - shell: curl -o "{{ item.dest }}" "{{ item.url }}" && chmod 755 "{{ item.dest }}" - with_items: - - { url: "https://phar.phpunit.de/phploc.phar", dest: /usr/local/bin/phploc } - - { url: "https://phar.phpunit.de/phpunit.phar", dest: /usr/local/bin/phpunit } - - { url: "http://static.pdepend.org/php/latest/pdepend.phar", dest: /usr/local/bin/pdepend } - - { url: "http://static.phpmd.org/php/latest/phpmd.phar", dest: /usr/local/bin/phpmd } - - { url: "https://squizlabs.github.io/PHP_CodeSniffer/phpcs.phar", dest: /usr/local/bin/phpcs } - - { url: "https://squizlabs.github.io/PHP_CodeSniffer/phpcbf.phar", dest: /usr/local/bin/phpcbf } - - { url: "https://phar.phpunit.de/phpcpd.phar", dest: /usr/local/bin/phpcpd } - - { url: "https://phar.phpunit.de/phpdcd.phar", dest: /usr/local/bin/phpdcd } - - { url: "https://github.com/Halleck45/PhpMetrics/raw/master/build/phpmetrics.phar", dest: /usr/local/bin/phpmetrics } - - { url: "http://get.sensiolabs.org/php-cs-fixer.phar", dest: /usr/local/bin/php-cs-fixer } - - { url: "https://github.com/sensiolabs-de/deprecation-detector/releases/download/0.1.0-alpha4/deprecation-detector.phar", dest: /usr/local/bin/deprecation-detector } - - { url: "https://github.com/sensiolabs-de/deprecation-detector/releases/download/0.1.0-alpha4/deprecation-detector.phar", dest: /usr/local/bin/deprecation-detector } - -- name: Install Tools via composer - raw: COMPOSER_HOME="/usr/local/composer" COMPOSER_BIN_DIR="/usr/local/bin" composer global require "{{ item.package }}" "{{ item.version }}" - with_items: - - { package: "sstalle/php7cc" , version: "*" } - - { package: "phpspec/phpspec" , version: "~2.0" } diff --git a/docker/php-apache-dev/debian-7/Dockerfile b/docker/php-apache-dev/debian-7/Dockerfile index bea517d44..cbddbeed1 100644 --- a/docker/php-apache-dev/debian-7/Dockerfile +++ b/docker/php-apache-dev/debian-7/Dockerfile @@ -5,16 +5,11 @@ FROM webdevops/php-dev:debian-7 -MAINTAINER info@webdevops.io -LABEL vendor=WebDevOps.io -LABEL io.webdevops.layout=8 -LABEL io.webdevops.version=1.5.0 - -ENV WEB_DOCUMENT_ROOT /app -ENV WEB_DOCUMENT_INDEX index.php -ENV WEB_ALIAS_DOMAIN *.vm -ENV WEB_PHP_SOCKET 127.0.0.1:9000 -ENV WEB_NO_CACHE_PATTERN "\.(css|js|gif|png|jpg|svg|json|xml)$" +ENV WEB_DOCUMENT_ROOT=/app \ + WEB_DOCUMENT_INDEX=index.php \ + WEB_ALIAS_DOMAIN=*.vm +ENV WEB_PHP_SOCKET=127.0.0.1:9000 +ENV WEB_NO_CACHE_PATTERN="\.(css|js|gif|png|jpg|svg|json|xml)$" COPY conf/ /opt/docker/ @@ -30,7 +25,7 @@ RUN /usr/local/bin/apt-install \ && rm -f /etc/apache2/sites-enabled/* \ && a2enmod actions fastcgi ssl rewrite headers expires \ && /opt/docker/bin/provision run --tag bootstrap --role webdevops-apache --role webdevops-php-apache --role webdevops-apache-dev --role webdevops-php-dev \ - && /opt/docker/bin/bootstrap.sh - + && /opt/docker/bin/bootstrap.sh \ + && docker-image-cleanup EXPOSE 80 443 diff --git a/docker/php-apache-dev/debian-7/Dockerfile.jinja2 b/docker/php-apache-dev/debian-7/Dockerfile.jinja2 index db7238d46..61d44dc04 100644 --- a/docker/php-apache-dev/debian-7/Dockerfile.jinja2 +++ b/docker/php-apache-dev/debian-7/Dockerfile.jinja2 @@ -1,7 +1,5 @@ {{ docker.from("php-dev", "debian-7") }} -{{ docker.version() }} - {{ environment.web() }} {{ environment.webPhp() }} {{ environment.webDevelopment() }} diff --git a/docker/php-apache-dev/debian-7/conf/bin/service.d/httpd.d/10-init.sh b/docker/php-apache-dev/debian-7/conf/bin/service.d/httpd.d/10-init.sh index d3f1a0c9c..b9d57997e 100644 --- a/docker/php-apache-dev/debian-7/conf/bin/service.d/httpd.d/10-init.sh +++ b/docker/php-apache-dev/debian-7/conf/bin/service.d/httpd.d/10-init.sh @@ -5,15 +5,17 @@ if [[ ! -e "$WEB_DOCUMENT_ROOT" ]]; then fi # Replace markers -find /opt/docker/etc/httpd/ -iname '*.conf' -print0 | xargs -0 -r rpl --quiet "" "$WEB_DOCUMENT_INDEX" > /dev/null -find /opt/docker/etc/httpd/ -iname '*.conf' -print0 | xargs -0 -r rpl --quiet "" "$WEB_DOCUMENT_ROOT" > /dev/null -find /opt/docker/etc/httpd/ -iname '*.conf' -print0 | xargs -0 -r rpl --quiet "" "$WEB_ALIAS_DOMAIN" > /dev/null -find /opt/docker/etc/httpd/ -iname '*.conf' -print0 | xargs -0 -r rpl --quiet "" "$HOSTNAME" > /dev/null +go-replace \ + -s "" -r "$WEB_DOCUMENT_INDEX" \ + -s "" -r "$WEB_DOCUMENT_ROOT" \ + -s "" -r "$WEB_ALIAS_DOMAIN" \ + -s "" -r "$HOSTNAME" \ + -s "" -r "$WEB_PHP_SOCKET" \ + --path=/opt/docker/etc/httpd/ \ + --path-pattern='*.conf' \ + --ignore-empty -if [[ -n "${WEB_PHP_SOCKET+x}" ]]; then - ## WEB_PHP_SOCKET is set - find /opt/docker/etc/httpd/ -iname '*.conf' -print0 | xargs -0 -r rpl --quiet "" "$WEB_PHP_SOCKET" > /dev/null -else +if [[ -z "${WEB_PHP_SOCKET+x}" ]]; then ## WEB_PHP_SOCKET is not set, remove PHP files rm -f -- /opt/docker/etc/httpd/conf.d/10-php.conf fi diff --git a/docker/php-apache-dev/debian-7/conf/bin/service.d/httpd.d/12-development.sh b/docker/php-apache-dev/debian-7/conf/bin/service.d/httpd.d/12-development.sh index 299f67e2f..a9d2c6e92 100644 --- a/docker/php-apache-dev/debian-7/conf/bin/service.d/httpd.d/12-development.sh +++ b/docker/php-apache-dev/debian-7/conf/bin/service.d/httpd.d/12-development.sh @@ -1 +1,5 @@ -find /opt/docker/etc/httpd/ -iname '*.conf' -print0 | xargs -0 -r rpl --quiet "" "$WEB_NO_CACHE_PATTERN" > /dev/null +go-replace \ + -s "" -r "$WEB_NO_CACHE_PATTERN" \ + --path=/opt/docker/etc/httpd/ \ + --path-pattern='*.conf' \ + --ignore-empty diff --git a/docker/php-apache-dev/debian-7/conf/etc/httpd/conf.d/10-log.conf b/docker/php-apache-dev/debian-7/conf/etc/httpd/conf.d/10-log.conf index e4c4be4f2..ef0c73d38 100644 --- a/docker/php-apache-dev/debian-7/conf/etc/httpd/conf.d/10-log.conf +++ b/docker/php-apache-dev/debian-7/conf/etc/httpd/conf.d/10-log.conf @@ -1,4 +1,4 @@ LogFormat "[httpd:access] %V:%p %h %l %u %t \"%r\" %>s bytesIn:%I bytesOut:%O reqTime:%T" dockerlog LogLevel warn -CustomLog /proc/self/fd/1 dockerlog -ErrorLog /proc/self/fd/2 +CustomLog /docker.stdout dockerlog +ErrorLog /docker.stderr diff --git a/docker/php-apache-dev/debian-7/conf/provision/entrypoint.d/10-php-debugger.sh b/docker/php-apache-dev/debian-7/conf/provision/entrypoint.d/10-php-debugger.sh index 7156e28aa..b5985a9ef 100644 --- a/docker/php-apache-dev/debian-7/conf/provision/entrypoint.d/10-php-debugger.sh +++ b/docker/php-apache-dev/debian-7/conf/provision/entrypoint.d/10-php-debugger.sh @@ -15,7 +15,8 @@ PHP_CONF_PATHS=" /etc/php5/fpm/conf.d /etc/php/7.0/mods-available /etc/php/7.0/cli/conf.d -/etc/php/7.0/fpm/conf.d" +/etc/php/7.0/fpm/conf.d +/usr/local/etc/php/conf.d/" function phpModuleRemove() { if [ "$#" -ne 1 ]; then @@ -40,7 +41,7 @@ if [[ -n "${PHP_DEBUGGER+x}" ]]; then blackfire) echo "PHP-Debugger: Blackfire enabled" phpModuleRemove "xdebug" - /opt/docker/bin/control.sh service.enable blackfire-agent + docker-service-enable blackfire-agent ;; none) diff --git a/docker/php-apache-dev/debian-7/conf/provision/roles/webdevops-apache/tasks/bootstrap.yml b/docker/php-apache-dev/debian-7/conf/provision/roles/webdevops-apache/tasks/bootstrap.yml index 2be18b0e0..c285be286 100644 --- a/docker/php-apache-dev/debian-7/conf/provision/roles/webdevops-apache/tasks/bootstrap.yml +++ b/docker/php-apache-dev/debian-7/conf/provision/roles/webdevops-apache/tasks/bootstrap.yml @@ -84,7 +84,7 @@ with_items: - 'a2dismod mpm_event' - 'a2enmod mpm_event' - when: (ansible_distribution == 'Ubuntu' and ansible_lsb.major_release|int >= 14) or (ansible_distribution == 'Debian' and ansible_lsb.major_release|int >= 8) + when: (ansible_distribution == 'Ubuntu' and docker_image_info_distribution_version|int >= 14) or (ansible_distribution == 'Debian' and docker_image_info_distribution_version|int >= 8) - name: Manage modules [Alpine family] lineinfile: diff --git a/docker/php-apache-dev/debian-7/conf/provision/roles/webdevops-php-dev/tasks/bootstrap.yml b/docker/php-apache-dev/debian-7/conf/provision/roles/webdevops-php-dev/tasks/bootstrap.yml index 2c5d76e3d..ff02b05fc 100644 --- a/docker/php-apache-dev/debian-7/conf/provision/roles/webdevops-php-dev/tasks/bootstrap.yml +++ b/docker/php-apache-dev/debian-7/conf/provision/roles/webdevops-php-dev/tasks/bootstrap.yml @@ -1,6 +1,5 @@ --- -- include: bootstrap/tools.yml - include: bootstrap/php-fpm.yml - include: bootstrap/php-module.yml - include: bootstrap/php-module.opcache.yml diff --git a/docker/php-apache-dev/debian-7/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/php-module.blackfire.yml b/docker/php-apache-dev/debian-7/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/php-module.blackfire.yml index 1a3db9bac..faf05f8de 100644 --- a/docker/php-apache-dev/debian-7/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/php-module.blackfire.yml +++ b/docker/php-apache-dev/debian-7/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/php-module.blackfire.yml @@ -7,4 +7,4 @@ with_items: - /etc/php5/cli/conf.d/zz-blackfire.ini - /etc/php5/fpm/conf.d/zz-blackfire.ini - when: ansible_distribution == 'Debian' and ansible_lsb.major_release|int >= 7 + when: ansible_distribution == 'Debian' and docker_image_info_distribution_version|int >= 7 diff --git a/docker/php-apache-dev/debian-7/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/tools.yml b/docker/php-apache-dev/debian-7/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/tools.yml deleted file mode 100644 index c49cb0e34..000000000 --- a/docker/php-apache-dev/debian-7/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/tools.yml +++ /dev/null @@ -1,23 +0,0 @@ ---- - -- name: Downloading Tools - shell: curl -o "{{ item.dest }}" "{{ item.url }}" && chmod 755 "{{ item.dest }}" - with_items: - - { url: "https://phar.phpunit.de/phploc.phar", dest: /usr/local/bin/phploc } - - { url: "https://phar.phpunit.de/phpunit.phar", dest: /usr/local/bin/phpunit } - - { url: "http://static.pdepend.org/php/latest/pdepend.phar", dest: /usr/local/bin/pdepend } - - { url: "http://static.phpmd.org/php/latest/phpmd.phar", dest: /usr/local/bin/phpmd } - - { url: "https://squizlabs.github.io/PHP_CodeSniffer/phpcs.phar", dest: /usr/local/bin/phpcs } - - { url: "https://squizlabs.github.io/PHP_CodeSniffer/phpcbf.phar", dest: /usr/local/bin/phpcbf } - - { url: "https://phar.phpunit.de/phpcpd.phar", dest: /usr/local/bin/phpcpd } - - { url: "https://phar.phpunit.de/phpdcd.phar", dest: /usr/local/bin/phpdcd } - - { url: "https://github.com/Halleck45/PhpMetrics/raw/master/build/phpmetrics.phar", dest: /usr/local/bin/phpmetrics } - - { url: "http://get.sensiolabs.org/php-cs-fixer.phar", dest: /usr/local/bin/php-cs-fixer } - - { url: "https://github.com/sensiolabs-de/deprecation-detector/releases/download/0.1.0-alpha4/deprecation-detector.phar", dest: /usr/local/bin/deprecation-detector } - - { url: "https://github.com/sensiolabs-de/deprecation-detector/releases/download/0.1.0-alpha4/deprecation-detector.phar", dest: /usr/local/bin/deprecation-detector } - -- name: Install Tools via composer - raw: COMPOSER_HOME="/usr/local/composer" COMPOSER_BIN_DIR="/usr/local/bin" composer global require "{{ item.package }}" "{{ item.version }}" - with_items: - - { package: "sstalle/php7cc" , version: "*" } - - { package: "phpspec/phpspec" , version: "~2.0" } diff --git a/docker/php-apache-dev/debian-8-php7/Dockerfile b/docker/php-apache-dev/debian-8-php7/Dockerfile index d0b64dc51..d478479f7 100644 --- a/docker/php-apache-dev/debian-8-php7/Dockerfile +++ b/docker/php-apache-dev/debian-8-php7/Dockerfile @@ -5,16 +5,11 @@ FROM webdevops/php-dev:debian-8-php7 -MAINTAINER info@webdevops.io -LABEL vendor=WebDevOps.io -LABEL io.webdevops.layout=8 -LABEL io.webdevops.version=1.5.0 - -ENV WEB_DOCUMENT_ROOT /app -ENV WEB_DOCUMENT_INDEX index.php -ENV WEB_ALIAS_DOMAIN *.vm -ENV WEB_PHP_SOCKET 127.0.0.1:9000 -ENV WEB_NO_CACHE_PATTERN "\.(css|js|gif|png|jpg|svg|json|xml)$" +ENV WEB_DOCUMENT_ROOT=/app \ + WEB_DOCUMENT_INDEX=index.php \ + WEB_ALIAS_DOMAIN=*.vm +ENV WEB_PHP_SOCKET=127.0.0.1:9000 +ENV WEB_NO_CACHE_PATTERN="\.(css|js|gif|png|jpg|svg|json|xml)$" COPY conf/ /opt/docker/ @@ -29,7 +24,7 @@ RUN /usr/local/bin/apt-install \ && rm -f /etc/apache2/sites-enabled/* \ && a2enmod actions proxy proxy_fcgi ssl rewrite headers expires \ && /opt/docker/bin/provision run --tag bootstrap --role webdevops-apache --role webdevops-php-apache --role webdevops-apache-dev --role webdevops-php-dev \ - && /opt/docker/bin/bootstrap.sh - + && /opt/docker/bin/bootstrap.sh \ + && docker-image-cleanup EXPOSE 80 443 diff --git a/docker/php-apache-dev/debian-8-php7/Dockerfile.jinja2 b/docker/php-apache-dev/debian-8-php7/Dockerfile.jinja2 index fc2b2a2ae..061dcb383 100644 --- a/docker/php-apache-dev/debian-8-php7/Dockerfile.jinja2 +++ b/docker/php-apache-dev/debian-8-php7/Dockerfile.jinja2 @@ -1,7 +1,5 @@ {{ docker.from("php-dev", "debian-8-php7") }} -{{ docker.version() }} - {{ environment.web() }} {{ environment.webPhp() }} {{ environment.webDevelopment() }} diff --git a/docker/php-apache-dev/debian-8-php7/conf/bin/service.d/httpd.d/10-init.sh b/docker/php-apache-dev/debian-8-php7/conf/bin/service.d/httpd.d/10-init.sh index d3f1a0c9c..b9d57997e 100644 --- a/docker/php-apache-dev/debian-8-php7/conf/bin/service.d/httpd.d/10-init.sh +++ b/docker/php-apache-dev/debian-8-php7/conf/bin/service.d/httpd.d/10-init.sh @@ -5,15 +5,17 @@ if [[ ! -e "$WEB_DOCUMENT_ROOT" ]]; then fi # Replace markers -find /opt/docker/etc/httpd/ -iname '*.conf' -print0 | xargs -0 -r rpl --quiet "" "$WEB_DOCUMENT_INDEX" > /dev/null -find /opt/docker/etc/httpd/ -iname '*.conf' -print0 | xargs -0 -r rpl --quiet "" "$WEB_DOCUMENT_ROOT" > /dev/null -find /opt/docker/etc/httpd/ -iname '*.conf' -print0 | xargs -0 -r rpl --quiet "" "$WEB_ALIAS_DOMAIN" > /dev/null -find /opt/docker/etc/httpd/ -iname '*.conf' -print0 | xargs -0 -r rpl --quiet "" "$HOSTNAME" > /dev/null +go-replace \ + -s "" -r "$WEB_DOCUMENT_INDEX" \ + -s "" -r "$WEB_DOCUMENT_ROOT" \ + -s "" -r "$WEB_ALIAS_DOMAIN" \ + -s "" -r "$HOSTNAME" \ + -s "" -r "$WEB_PHP_SOCKET" \ + --path=/opt/docker/etc/httpd/ \ + --path-pattern='*.conf' \ + --ignore-empty -if [[ -n "${WEB_PHP_SOCKET+x}" ]]; then - ## WEB_PHP_SOCKET is set - find /opt/docker/etc/httpd/ -iname '*.conf' -print0 | xargs -0 -r rpl --quiet "" "$WEB_PHP_SOCKET" > /dev/null -else +if [[ -z "${WEB_PHP_SOCKET+x}" ]]; then ## WEB_PHP_SOCKET is not set, remove PHP files rm -f -- /opt/docker/etc/httpd/conf.d/10-php.conf fi diff --git a/docker/php-apache-dev/debian-8-php7/conf/bin/service.d/httpd.d/12-development.sh b/docker/php-apache-dev/debian-8-php7/conf/bin/service.d/httpd.d/12-development.sh index 299f67e2f..a9d2c6e92 100644 --- a/docker/php-apache-dev/debian-8-php7/conf/bin/service.d/httpd.d/12-development.sh +++ b/docker/php-apache-dev/debian-8-php7/conf/bin/service.d/httpd.d/12-development.sh @@ -1 +1,5 @@ -find /opt/docker/etc/httpd/ -iname '*.conf' -print0 | xargs -0 -r rpl --quiet "" "$WEB_NO_CACHE_PATTERN" > /dev/null +go-replace \ + -s "" -r "$WEB_NO_CACHE_PATTERN" \ + --path=/opt/docker/etc/httpd/ \ + --path-pattern='*.conf' \ + --ignore-empty diff --git a/docker/php-apache-dev/debian-8-php7/conf/etc/httpd/conf.d/10-log.conf b/docker/php-apache-dev/debian-8-php7/conf/etc/httpd/conf.d/10-log.conf index e4c4be4f2..ef0c73d38 100644 --- a/docker/php-apache-dev/debian-8-php7/conf/etc/httpd/conf.d/10-log.conf +++ b/docker/php-apache-dev/debian-8-php7/conf/etc/httpd/conf.d/10-log.conf @@ -1,4 +1,4 @@ LogFormat "[httpd:access] %V:%p %h %l %u %t \"%r\" %>s bytesIn:%I bytesOut:%O reqTime:%T" dockerlog LogLevel warn -CustomLog /proc/self/fd/1 dockerlog -ErrorLog /proc/self/fd/2 +CustomLog /docker.stdout dockerlog +ErrorLog /docker.stderr diff --git a/docker/php-apache-dev/debian-8-php7/conf/provision/entrypoint.d/10-php-debugger.sh b/docker/php-apache-dev/debian-8-php7/conf/provision/entrypoint.d/10-php-debugger.sh index 7156e28aa..b5985a9ef 100644 --- a/docker/php-apache-dev/debian-8-php7/conf/provision/entrypoint.d/10-php-debugger.sh +++ b/docker/php-apache-dev/debian-8-php7/conf/provision/entrypoint.d/10-php-debugger.sh @@ -15,7 +15,8 @@ PHP_CONF_PATHS=" /etc/php5/fpm/conf.d /etc/php/7.0/mods-available /etc/php/7.0/cli/conf.d -/etc/php/7.0/fpm/conf.d" +/etc/php/7.0/fpm/conf.d +/usr/local/etc/php/conf.d/" function phpModuleRemove() { if [ "$#" -ne 1 ]; then @@ -40,7 +41,7 @@ if [[ -n "${PHP_DEBUGGER+x}" ]]; then blackfire) echo "PHP-Debugger: Blackfire enabled" phpModuleRemove "xdebug" - /opt/docker/bin/control.sh service.enable blackfire-agent + docker-service-enable blackfire-agent ;; none) diff --git a/docker/php-apache-dev/debian-8-php7/conf/provision/roles/webdevops-apache/tasks/bootstrap.yml b/docker/php-apache-dev/debian-8-php7/conf/provision/roles/webdevops-apache/tasks/bootstrap.yml index 2be18b0e0..c285be286 100644 --- a/docker/php-apache-dev/debian-8-php7/conf/provision/roles/webdevops-apache/tasks/bootstrap.yml +++ b/docker/php-apache-dev/debian-8-php7/conf/provision/roles/webdevops-apache/tasks/bootstrap.yml @@ -84,7 +84,7 @@ with_items: - 'a2dismod mpm_event' - 'a2enmod mpm_event' - when: (ansible_distribution == 'Ubuntu' and ansible_lsb.major_release|int >= 14) or (ansible_distribution == 'Debian' and ansible_lsb.major_release|int >= 8) + when: (ansible_distribution == 'Ubuntu' and docker_image_info_distribution_version|int >= 14) or (ansible_distribution == 'Debian' and docker_image_info_distribution_version|int >= 8) - name: Manage modules [Alpine family] lineinfile: diff --git a/docker/php-apache-dev/debian-8-php7/conf/provision/roles/webdevops-php-dev/tasks/bootstrap.yml b/docker/php-apache-dev/debian-8-php7/conf/provision/roles/webdevops-php-dev/tasks/bootstrap.yml index 2c5d76e3d..ff02b05fc 100644 --- a/docker/php-apache-dev/debian-8-php7/conf/provision/roles/webdevops-php-dev/tasks/bootstrap.yml +++ b/docker/php-apache-dev/debian-8-php7/conf/provision/roles/webdevops-php-dev/tasks/bootstrap.yml @@ -1,6 +1,5 @@ --- -- include: bootstrap/tools.yml - include: bootstrap/php-fpm.yml - include: bootstrap/php-module.yml - include: bootstrap/php-module.opcache.yml diff --git a/docker/php-apache-dev/debian-8-php7/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/php-module.blackfire.yml b/docker/php-apache-dev/debian-8-php7/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/php-module.blackfire.yml index 1a3db9bac..faf05f8de 100644 --- a/docker/php-apache-dev/debian-8-php7/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/php-module.blackfire.yml +++ b/docker/php-apache-dev/debian-8-php7/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/php-module.blackfire.yml @@ -7,4 +7,4 @@ with_items: - /etc/php5/cli/conf.d/zz-blackfire.ini - /etc/php5/fpm/conf.d/zz-blackfire.ini - when: ansible_distribution == 'Debian' and ansible_lsb.major_release|int >= 7 + when: ansible_distribution == 'Debian' and docker_image_info_distribution_version|int >= 7 diff --git a/docker/php-apache-dev/debian-8-php7/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/tools.yml b/docker/php-apache-dev/debian-8-php7/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/tools.yml deleted file mode 100644 index c49cb0e34..000000000 --- a/docker/php-apache-dev/debian-8-php7/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/tools.yml +++ /dev/null @@ -1,23 +0,0 @@ ---- - -- name: Downloading Tools - shell: curl -o "{{ item.dest }}" "{{ item.url }}" && chmod 755 "{{ item.dest }}" - with_items: - - { url: "https://phar.phpunit.de/phploc.phar", dest: /usr/local/bin/phploc } - - { url: "https://phar.phpunit.de/phpunit.phar", dest: /usr/local/bin/phpunit } - - { url: "http://static.pdepend.org/php/latest/pdepend.phar", dest: /usr/local/bin/pdepend } - - { url: "http://static.phpmd.org/php/latest/phpmd.phar", dest: /usr/local/bin/phpmd } - - { url: "https://squizlabs.github.io/PHP_CodeSniffer/phpcs.phar", dest: /usr/local/bin/phpcs } - - { url: "https://squizlabs.github.io/PHP_CodeSniffer/phpcbf.phar", dest: /usr/local/bin/phpcbf } - - { url: "https://phar.phpunit.de/phpcpd.phar", dest: /usr/local/bin/phpcpd } - - { url: "https://phar.phpunit.de/phpdcd.phar", dest: /usr/local/bin/phpdcd } - - { url: "https://github.com/Halleck45/PhpMetrics/raw/master/build/phpmetrics.phar", dest: /usr/local/bin/phpmetrics } - - { url: "http://get.sensiolabs.org/php-cs-fixer.phar", dest: /usr/local/bin/php-cs-fixer } - - { url: "https://github.com/sensiolabs-de/deprecation-detector/releases/download/0.1.0-alpha4/deprecation-detector.phar", dest: /usr/local/bin/deprecation-detector } - - { url: "https://github.com/sensiolabs-de/deprecation-detector/releases/download/0.1.0-alpha4/deprecation-detector.phar", dest: /usr/local/bin/deprecation-detector } - -- name: Install Tools via composer - raw: COMPOSER_HOME="/usr/local/composer" COMPOSER_BIN_DIR="/usr/local/bin" composer global require "{{ item.package }}" "{{ item.version }}" - with_items: - - { package: "sstalle/php7cc" , version: "*" } - - { package: "phpspec/phpspec" , version: "~2.0" } diff --git a/docker/php-apache-dev/debian-8/Dockerfile b/docker/php-apache-dev/debian-8/Dockerfile index f868ae6fc..ca840eebf 100644 --- a/docker/php-apache-dev/debian-8/Dockerfile +++ b/docker/php-apache-dev/debian-8/Dockerfile @@ -5,16 +5,11 @@ FROM webdevops/php-dev:debian-8 -MAINTAINER info@webdevops.io -LABEL vendor=WebDevOps.io -LABEL io.webdevops.layout=8 -LABEL io.webdevops.version=1.5.0 - -ENV WEB_DOCUMENT_ROOT /app -ENV WEB_DOCUMENT_INDEX index.php -ENV WEB_ALIAS_DOMAIN *.vm -ENV WEB_PHP_SOCKET 127.0.0.1:9000 -ENV WEB_NO_CACHE_PATTERN "\.(css|js|gif|png|jpg|svg|json|xml)$" +ENV WEB_DOCUMENT_ROOT=/app \ + WEB_DOCUMENT_INDEX=index.php \ + WEB_ALIAS_DOMAIN=*.vm +ENV WEB_PHP_SOCKET=127.0.0.1:9000 +ENV WEB_NO_CACHE_PATTERN="\.(css|js|gif|png|jpg|svg|json|xml)$" COPY conf/ /opt/docker/ @@ -29,7 +24,7 @@ RUN /usr/local/bin/apt-install \ && rm -f /etc/apache2/sites-enabled/* \ && a2enmod actions proxy proxy_fcgi ssl rewrite headers expires \ && /opt/docker/bin/provision run --tag bootstrap --role webdevops-apache --role webdevops-php-apache --role webdevops-apache-dev --role webdevops-php-dev \ - && /opt/docker/bin/bootstrap.sh - + && /opt/docker/bin/bootstrap.sh \ + && docker-image-cleanup EXPOSE 80 443 diff --git a/docker/php-apache-dev/debian-8/Dockerfile.jinja2 b/docker/php-apache-dev/debian-8/Dockerfile.jinja2 index bc690b346..1d792e13b 100644 --- a/docker/php-apache-dev/debian-8/Dockerfile.jinja2 +++ b/docker/php-apache-dev/debian-8/Dockerfile.jinja2 @@ -1,7 +1,5 @@ {{ docker.from("php-dev", "debian-8") }} -{{ docker.version() }} - {{ environment.web() }} {{ environment.webPhp() }} {{ environment.webDevelopment() }} diff --git a/docker/php-apache-dev/debian-8/conf/bin/service.d/httpd.d/10-init.sh b/docker/php-apache-dev/debian-8/conf/bin/service.d/httpd.d/10-init.sh index d3f1a0c9c..b9d57997e 100644 --- a/docker/php-apache-dev/debian-8/conf/bin/service.d/httpd.d/10-init.sh +++ b/docker/php-apache-dev/debian-8/conf/bin/service.d/httpd.d/10-init.sh @@ -5,15 +5,17 @@ if [[ ! -e "$WEB_DOCUMENT_ROOT" ]]; then fi # Replace markers -find /opt/docker/etc/httpd/ -iname '*.conf' -print0 | xargs -0 -r rpl --quiet "" "$WEB_DOCUMENT_INDEX" > /dev/null -find /opt/docker/etc/httpd/ -iname '*.conf' -print0 | xargs -0 -r rpl --quiet "" "$WEB_DOCUMENT_ROOT" > /dev/null -find /opt/docker/etc/httpd/ -iname '*.conf' -print0 | xargs -0 -r rpl --quiet "" "$WEB_ALIAS_DOMAIN" > /dev/null -find /opt/docker/etc/httpd/ -iname '*.conf' -print0 | xargs -0 -r rpl --quiet "" "$HOSTNAME" > /dev/null +go-replace \ + -s "" -r "$WEB_DOCUMENT_INDEX" \ + -s "" -r "$WEB_DOCUMENT_ROOT" \ + -s "" -r "$WEB_ALIAS_DOMAIN" \ + -s "" -r "$HOSTNAME" \ + -s "" -r "$WEB_PHP_SOCKET" \ + --path=/opt/docker/etc/httpd/ \ + --path-pattern='*.conf' \ + --ignore-empty -if [[ -n "${WEB_PHP_SOCKET+x}" ]]; then - ## WEB_PHP_SOCKET is set - find /opt/docker/etc/httpd/ -iname '*.conf' -print0 | xargs -0 -r rpl --quiet "" "$WEB_PHP_SOCKET" > /dev/null -else +if [[ -z "${WEB_PHP_SOCKET+x}" ]]; then ## WEB_PHP_SOCKET is not set, remove PHP files rm -f -- /opt/docker/etc/httpd/conf.d/10-php.conf fi diff --git a/docker/php-apache-dev/debian-8/conf/bin/service.d/httpd.d/12-development.sh b/docker/php-apache-dev/debian-8/conf/bin/service.d/httpd.d/12-development.sh index 299f67e2f..a9d2c6e92 100644 --- a/docker/php-apache-dev/debian-8/conf/bin/service.d/httpd.d/12-development.sh +++ b/docker/php-apache-dev/debian-8/conf/bin/service.d/httpd.d/12-development.sh @@ -1 +1,5 @@ -find /opt/docker/etc/httpd/ -iname '*.conf' -print0 | xargs -0 -r rpl --quiet "" "$WEB_NO_CACHE_PATTERN" > /dev/null +go-replace \ + -s "" -r "$WEB_NO_CACHE_PATTERN" \ + --path=/opt/docker/etc/httpd/ \ + --path-pattern='*.conf' \ + --ignore-empty diff --git a/docker/php-apache-dev/debian-8/conf/etc/httpd/conf.d/10-log.conf b/docker/php-apache-dev/debian-8/conf/etc/httpd/conf.d/10-log.conf index e4c4be4f2..ef0c73d38 100644 --- a/docker/php-apache-dev/debian-8/conf/etc/httpd/conf.d/10-log.conf +++ b/docker/php-apache-dev/debian-8/conf/etc/httpd/conf.d/10-log.conf @@ -1,4 +1,4 @@ LogFormat "[httpd:access] %V:%p %h %l %u %t \"%r\" %>s bytesIn:%I bytesOut:%O reqTime:%T" dockerlog LogLevel warn -CustomLog /proc/self/fd/1 dockerlog -ErrorLog /proc/self/fd/2 +CustomLog /docker.stdout dockerlog +ErrorLog /docker.stderr diff --git a/docker/php-apache-dev/debian-8/conf/provision/entrypoint.d/10-php-debugger.sh b/docker/php-apache-dev/debian-8/conf/provision/entrypoint.d/10-php-debugger.sh index 7156e28aa..b5985a9ef 100644 --- a/docker/php-apache-dev/debian-8/conf/provision/entrypoint.d/10-php-debugger.sh +++ b/docker/php-apache-dev/debian-8/conf/provision/entrypoint.d/10-php-debugger.sh @@ -15,7 +15,8 @@ PHP_CONF_PATHS=" /etc/php5/fpm/conf.d /etc/php/7.0/mods-available /etc/php/7.0/cli/conf.d -/etc/php/7.0/fpm/conf.d" +/etc/php/7.0/fpm/conf.d +/usr/local/etc/php/conf.d/" function phpModuleRemove() { if [ "$#" -ne 1 ]; then @@ -40,7 +41,7 @@ if [[ -n "${PHP_DEBUGGER+x}" ]]; then blackfire) echo "PHP-Debugger: Blackfire enabled" phpModuleRemove "xdebug" - /opt/docker/bin/control.sh service.enable blackfire-agent + docker-service-enable blackfire-agent ;; none) diff --git a/docker/php-apache-dev/debian-8/conf/provision/roles/webdevops-apache/tasks/bootstrap.yml b/docker/php-apache-dev/debian-8/conf/provision/roles/webdevops-apache/tasks/bootstrap.yml index 2be18b0e0..c285be286 100644 --- a/docker/php-apache-dev/debian-8/conf/provision/roles/webdevops-apache/tasks/bootstrap.yml +++ b/docker/php-apache-dev/debian-8/conf/provision/roles/webdevops-apache/tasks/bootstrap.yml @@ -84,7 +84,7 @@ with_items: - 'a2dismod mpm_event' - 'a2enmod mpm_event' - when: (ansible_distribution == 'Ubuntu' and ansible_lsb.major_release|int >= 14) or (ansible_distribution == 'Debian' and ansible_lsb.major_release|int >= 8) + when: (ansible_distribution == 'Ubuntu' and docker_image_info_distribution_version|int >= 14) or (ansible_distribution == 'Debian' and docker_image_info_distribution_version|int >= 8) - name: Manage modules [Alpine family] lineinfile: diff --git a/docker/php-apache-dev/debian-8/conf/provision/roles/webdevops-php-dev/tasks/bootstrap.yml b/docker/php-apache-dev/debian-8/conf/provision/roles/webdevops-php-dev/tasks/bootstrap.yml index 2c5d76e3d..ff02b05fc 100644 --- a/docker/php-apache-dev/debian-8/conf/provision/roles/webdevops-php-dev/tasks/bootstrap.yml +++ b/docker/php-apache-dev/debian-8/conf/provision/roles/webdevops-php-dev/tasks/bootstrap.yml @@ -1,6 +1,5 @@ --- -- include: bootstrap/tools.yml - include: bootstrap/php-fpm.yml - include: bootstrap/php-module.yml - include: bootstrap/php-module.opcache.yml diff --git a/docker/php-apache-dev/debian-8/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/php-module.blackfire.yml b/docker/php-apache-dev/debian-8/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/php-module.blackfire.yml index 1a3db9bac..faf05f8de 100644 --- a/docker/php-apache-dev/debian-8/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/php-module.blackfire.yml +++ b/docker/php-apache-dev/debian-8/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/php-module.blackfire.yml @@ -7,4 +7,4 @@ with_items: - /etc/php5/cli/conf.d/zz-blackfire.ini - /etc/php5/fpm/conf.d/zz-blackfire.ini - when: ansible_distribution == 'Debian' and ansible_lsb.major_release|int >= 7 + when: ansible_distribution == 'Debian' and docker_image_info_distribution_version|int >= 7 diff --git a/docker/php-apache-dev/debian-8/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/tools.yml b/docker/php-apache-dev/debian-8/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/tools.yml deleted file mode 100644 index c49cb0e34..000000000 --- a/docker/php-apache-dev/debian-8/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/tools.yml +++ /dev/null @@ -1,23 +0,0 @@ ---- - -- name: Downloading Tools - shell: curl -o "{{ item.dest }}" "{{ item.url }}" && chmod 755 "{{ item.dest }}" - with_items: - - { url: "https://phar.phpunit.de/phploc.phar", dest: /usr/local/bin/phploc } - - { url: "https://phar.phpunit.de/phpunit.phar", dest: /usr/local/bin/phpunit } - - { url: "http://static.pdepend.org/php/latest/pdepend.phar", dest: /usr/local/bin/pdepend } - - { url: "http://static.phpmd.org/php/latest/phpmd.phar", dest: /usr/local/bin/phpmd } - - { url: "https://squizlabs.github.io/PHP_CodeSniffer/phpcs.phar", dest: /usr/local/bin/phpcs } - - { url: "https://squizlabs.github.io/PHP_CodeSniffer/phpcbf.phar", dest: /usr/local/bin/phpcbf } - - { url: "https://phar.phpunit.de/phpcpd.phar", dest: /usr/local/bin/phpcpd } - - { url: "https://phar.phpunit.de/phpdcd.phar", dest: /usr/local/bin/phpdcd } - - { url: "https://github.com/Halleck45/PhpMetrics/raw/master/build/phpmetrics.phar", dest: /usr/local/bin/phpmetrics } - - { url: "http://get.sensiolabs.org/php-cs-fixer.phar", dest: /usr/local/bin/php-cs-fixer } - - { url: "https://github.com/sensiolabs-de/deprecation-detector/releases/download/0.1.0-alpha4/deprecation-detector.phar", dest: /usr/local/bin/deprecation-detector } - - { url: "https://github.com/sensiolabs-de/deprecation-detector/releases/download/0.1.0-alpha4/deprecation-detector.phar", dest: /usr/local/bin/deprecation-detector } - -- name: Install Tools via composer - raw: COMPOSER_HOME="/usr/local/composer" COMPOSER_BIN_DIR="/usr/local/bin" composer global require "{{ item.package }}" "{{ item.version }}" - with_items: - - { package: "sstalle/php7cc" , version: "*" } - - { package: "phpspec/phpspec" , version: "~2.0" } diff --git a/docker/php-apache-dev/debian-9/Dockerfile b/docker/php-apache-dev/debian-9/Dockerfile index 75424fa23..91a1576e5 100644 --- a/docker/php-apache-dev/debian-9/Dockerfile +++ b/docker/php-apache-dev/debian-9/Dockerfile @@ -5,16 +5,11 @@ FROM webdevops/php-dev:debian-9 -MAINTAINER info@webdevops.io -LABEL vendor=WebDevOps.io -LABEL io.webdevops.layout=8 -LABEL io.webdevops.version=1.5.0 - -ENV WEB_DOCUMENT_ROOT /app -ENV WEB_DOCUMENT_INDEX index.php -ENV WEB_ALIAS_DOMAIN *.vm -ENV WEB_PHP_SOCKET 127.0.0.1:9000 -ENV WEB_NO_CACHE_PATTERN "\.(css|js|gif|png|jpg|svg|json|xml)$" +ENV WEB_DOCUMENT_ROOT=/app \ + WEB_DOCUMENT_INDEX=index.php \ + WEB_ALIAS_DOMAIN=*.vm +ENV WEB_PHP_SOCKET=127.0.0.1:9000 +ENV WEB_NO_CACHE_PATTERN="\.(css|js|gif|png|jpg|svg|json|xml)$" COPY conf/ /opt/docker/ @@ -28,7 +23,7 @@ RUN /usr/local/bin/apt-install \ && rm -f /etc/apache2/sites-enabled/* \ && a2enmod actions proxy proxy_fcgi ssl rewrite headers expires \ && /opt/docker/bin/provision run --tag bootstrap --role webdevops-apache --role webdevops-php-apache --role webdevops-apache-dev --role webdevops-php-dev \ - && /opt/docker/bin/bootstrap.sh - + && /opt/docker/bin/bootstrap.sh \ + && docker-image-cleanup EXPOSE 80 443 diff --git a/docker/php-apache-dev/debian-9/Dockerfile.jinja2 b/docker/php-apache-dev/debian-9/Dockerfile.jinja2 index 44a199691..5db157050 100644 --- a/docker/php-apache-dev/debian-9/Dockerfile.jinja2 +++ b/docker/php-apache-dev/debian-9/Dockerfile.jinja2 @@ -1,7 +1,5 @@ {{ docker.from("php-dev", "debian-9") }} -{{ docker.version() }} - {{ environment.web() }} {{ environment.webPhp() }} {{ environment.webDevelopment() }} diff --git a/docker/php-apache-dev/debian-9/conf/bin/service.d/httpd.d/10-init.sh b/docker/php-apache-dev/debian-9/conf/bin/service.d/httpd.d/10-init.sh index d3f1a0c9c..b9d57997e 100644 --- a/docker/php-apache-dev/debian-9/conf/bin/service.d/httpd.d/10-init.sh +++ b/docker/php-apache-dev/debian-9/conf/bin/service.d/httpd.d/10-init.sh @@ -5,15 +5,17 @@ if [[ ! -e "$WEB_DOCUMENT_ROOT" ]]; then fi # Replace markers -find /opt/docker/etc/httpd/ -iname '*.conf' -print0 | xargs -0 -r rpl --quiet "" "$WEB_DOCUMENT_INDEX" > /dev/null -find /opt/docker/etc/httpd/ -iname '*.conf' -print0 | xargs -0 -r rpl --quiet "" "$WEB_DOCUMENT_ROOT" > /dev/null -find /opt/docker/etc/httpd/ -iname '*.conf' -print0 | xargs -0 -r rpl --quiet "" "$WEB_ALIAS_DOMAIN" > /dev/null -find /opt/docker/etc/httpd/ -iname '*.conf' -print0 | xargs -0 -r rpl --quiet "" "$HOSTNAME" > /dev/null +go-replace \ + -s "" -r "$WEB_DOCUMENT_INDEX" \ + -s "" -r "$WEB_DOCUMENT_ROOT" \ + -s "" -r "$WEB_ALIAS_DOMAIN" \ + -s "" -r "$HOSTNAME" \ + -s "" -r "$WEB_PHP_SOCKET" \ + --path=/opt/docker/etc/httpd/ \ + --path-pattern='*.conf' \ + --ignore-empty -if [[ -n "${WEB_PHP_SOCKET+x}" ]]; then - ## WEB_PHP_SOCKET is set - find /opt/docker/etc/httpd/ -iname '*.conf' -print0 | xargs -0 -r rpl --quiet "" "$WEB_PHP_SOCKET" > /dev/null -else +if [[ -z "${WEB_PHP_SOCKET+x}" ]]; then ## WEB_PHP_SOCKET is not set, remove PHP files rm -f -- /opt/docker/etc/httpd/conf.d/10-php.conf fi diff --git a/docker/php-apache-dev/debian-9/conf/bin/service.d/httpd.d/12-development.sh b/docker/php-apache-dev/debian-9/conf/bin/service.d/httpd.d/12-development.sh index 299f67e2f..a9d2c6e92 100644 --- a/docker/php-apache-dev/debian-9/conf/bin/service.d/httpd.d/12-development.sh +++ b/docker/php-apache-dev/debian-9/conf/bin/service.d/httpd.d/12-development.sh @@ -1 +1,5 @@ -find /opt/docker/etc/httpd/ -iname '*.conf' -print0 | xargs -0 -r rpl --quiet "" "$WEB_NO_CACHE_PATTERN" > /dev/null +go-replace \ + -s "" -r "$WEB_NO_CACHE_PATTERN" \ + --path=/opt/docker/etc/httpd/ \ + --path-pattern='*.conf' \ + --ignore-empty diff --git a/docker/php-apache-dev/debian-9/conf/etc/httpd/conf.d/10-log.conf b/docker/php-apache-dev/debian-9/conf/etc/httpd/conf.d/10-log.conf index e4c4be4f2..ef0c73d38 100644 --- a/docker/php-apache-dev/debian-9/conf/etc/httpd/conf.d/10-log.conf +++ b/docker/php-apache-dev/debian-9/conf/etc/httpd/conf.d/10-log.conf @@ -1,4 +1,4 @@ LogFormat "[httpd:access] %V:%p %h %l %u %t \"%r\" %>s bytesIn:%I bytesOut:%O reqTime:%T" dockerlog LogLevel warn -CustomLog /proc/self/fd/1 dockerlog -ErrorLog /proc/self/fd/2 +CustomLog /docker.stdout dockerlog +ErrorLog /docker.stderr diff --git a/docker/php-apache-dev/debian-9/conf/provision/entrypoint.d/10-php-debugger.sh b/docker/php-apache-dev/debian-9/conf/provision/entrypoint.d/10-php-debugger.sh index 7156e28aa..b5985a9ef 100644 --- a/docker/php-apache-dev/debian-9/conf/provision/entrypoint.d/10-php-debugger.sh +++ b/docker/php-apache-dev/debian-9/conf/provision/entrypoint.d/10-php-debugger.sh @@ -15,7 +15,8 @@ PHP_CONF_PATHS=" /etc/php5/fpm/conf.d /etc/php/7.0/mods-available /etc/php/7.0/cli/conf.d -/etc/php/7.0/fpm/conf.d" +/etc/php/7.0/fpm/conf.d +/usr/local/etc/php/conf.d/" function phpModuleRemove() { if [ "$#" -ne 1 ]; then @@ -40,7 +41,7 @@ if [[ -n "${PHP_DEBUGGER+x}" ]]; then blackfire) echo "PHP-Debugger: Blackfire enabled" phpModuleRemove "xdebug" - /opt/docker/bin/control.sh service.enable blackfire-agent + docker-service-enable blackfire-agent ;; none) diff --git a/docker/php-apache-dev/debian-9/conf/provision/roles/webdevops-apache/tasks/bootstrap.yml b/docker/php-apache-dev/debian-9/conf/provision/roles/webdevops-apache/tasks/bootstrap.yml index 2be18b0e0..c285be286 100644 --- a/docker/php-apache-dev/debian-9/conf/provision/roles/webdevops-apache/tasks/bootstrap.yml +++ b/docker/php-apache-dev/debian-9/conf/provision/roles/webdevops-apache/tasks/bootstrap.yml @@ -84,7 +84,7 @@ with_items: - 'a2dismod mpm_event' - 'a2enmod mpm_event' - when: (ansible_distribution == 'Ubuntu' and ansible_lsb.major_release|int >= 14) or (ansible_distribution == 'Debian' and ansible_lsb.major_release|int >= 8) + when: (ansible_distribution == 'Ubuntu' and docker_image_info_distribution_version|int >= 14) or (ansible_distribution == 'Debian' and docker_image_info_distribution_version|int >= 8) - name: Manage modules [Alpine family] lineinfile: diff --git a/docker/php-apache-dev/debian-9/conf/provision/roles/webdevops-php-dev/tasks/bootstrap.yml b/docker/php-apache-dev/debian-9/conf/provision/roles/webdevops-php-dev/tasks/bootstrap.yml index 2c5d76e3d..ff02b05fc 100644 --- a/docker/php-apache-dev/debian-9/conf/provision/roles/webdevops-php-dev/tasks/bootstrap.yml +++ b/docker/php-apache-dev/debian-9/conf/provision/roles/webdevops-php-dev/tasks/bootstrap.yml @@ -1,6 +1,5 @@ --- -- include: bootstrap/tools.yml - include: bootstrap/php-fpm.yml - include: bootstrap/php-module.yml - include: bootstrap/php-module.opcache.yml diff --git a/docker/php-apache-dev/debian-9/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/php-module.blackfire.yml b/docker/php-apache-dev/debian-9/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/php-module.blackfire.yml index 1a3db9bac..faf05f8de 100644 --- a/docker/php-apache-dev/debian-9/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/php-module.blackfire.yml +++ b/docker/php-apache-dev/debian-9/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/php-module.blackfire.yml @@ -7,4 +7,4 @@ with_items: - /etc/php5/cli/conf.d/zz-blackfire.ini - /etc/php5/fpm/conf.d/zz-blackfire.ini - when: ansible_distribution == 'Debian' and ansible_lsb.major_release|int >= 7 + when: ansible_distribution == 'Debian' and docker_image_info_distribution_version|int >= 7 diff --git a/docker/php-apache-dev/debian-9/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/tools.yml b/docker/php-apache-dev/debian-9/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/tools.yml deleted file mode 100644 index c49cb0e34..000000000 --- a/docker/php-apache-dev/debian-9/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/tools.yml +++ /dev/null @@ -1,23 +0,0 @@ ---- - -- name: Downloading Tools - shell: curl -o "{{ item.dest }}" "{{ item.url }}" && chmod 755 "{{ item.dest }}" - with_items: - - { url: "https://phar.phpunit.de/phploc.phar", dest: /usr/local/bin/phploc } - - { url: "https://phar.phpunit.de/phpunit.phar", dest: /usr/local/bin/phpunit } - - { url: "http://static.pdepend.org/php/latest/pdepend.phar", dest: /usr/local/bin/pdepend } - - { url: "http://static.phpmd.org/php/latest/phpmd.phar", dest: /usr/local/bin/phpmd } - - { url: "https://squizlabs.github.io/PHP_CodeSniffer/phpcs.phar", dest: /usr/local/bin/phpcs } - - { url: "https://squizlabs.github.io/PHP_CodeSniffer/phpcbf.phar", dest: /usr/local/bin/phpcbf } - - { url: "https://phar.phpunit.de/phpcpd.phar", dest: /usr/local/bin/phpcpd } - - { url: "https://phar.phpunit.de/phpdcd.phar", dest: /usr/local/bin/phpdcd } - - { url: "https://github.com/Halleck45/PhpMetrics/raw/master/build/phpmetrics.phar", dest: /usr/local/bin/phpmetrics } - - { url: "http://get.sensiolabs.org/php-cs-fixer.phar", dest: /usr/local/bin/php-cs-fixer } - - { url: "https://github.com/sensiolabs-de/deprecation-detector/releases/download/0.1.0-alpha4/deprecation-detector.phar", dest: /usr/local/bin/deprecation-detector } - - { url: "https://github.com/sensiolabs-de/deprecation-detector/releases/download/0.1.0-alpha4/deprecation-detector.phar", dest: /usr/local/bin/deprecation-detector } - -- name: Install Tools via composer - raw: COMPOSER_HOME="/usr/local/composer" COMPOSER_BIN_DIR="/usr/local/bin" composer global require "{{ item.package }}" "{{ item.version }}" - with_items: - - { package: "sstalle/php7cc" , version: "*" } - - { package: "phpspec/phpspec" , version: "~2.0" } diff --git a/docker/php-apache-dev/ubuntu-12.04/Dockerfile b/docker/php-apache-dev/ubuntu-12.04/Dockerfile index 2aa66f626..86b76734f 100644 --- a/docker/php-apache-dev/ubuntu-12.04/Dockerfile +++ b/docker/php-apache-dev/ubuntu-12.04/Dockerfile @@ -5,16 +5,11 @@ FROM webdevops/php-dev:ubuntu-12.04 -MAINTAINER info@webdevops.io -LABEL vendor=WebDevOps.io -LABEL io.webdevops.layout=8 -LABEL io.webdevops.version=1.5.0 - -ENV WEB_DOCUMENT_ROOT /app -ENV WEB_DOCUMENT_INDEX index.php -ENV WEB_ALIAS_DOMAIN *.vm -ENV WEB_PHP_SOCKET 127.0.0.1:9000 -ENV WEB_NO_CACHE_PATTERN "\.(css|js|gif|png|jpg|svg|json|xml)$" +ENV WEB_DOCUMENT_ROOT=/app \ + WEB_DOCUMENT_INDEX=index.php \ + WEB_ALIAS_DOMAIN=*.vm +ENV WEB_PHP_SOCKET=127.0.0.1:9000 +ENV WEB_NO_CACHE_PATTERN="\.(css|js|gif|png|jpg|svg|json|xml)$" COPY conf/ /opt/docker/ @@ -31,7 +26,7 @@ RUN /usr/local/bin/apt-install \ && a2enmod actions fastcgi ssl rewrite headers version expires \ && mkdir -p /var/lock/apache2 \ && /opt/docker/bin/provision run --tag bootstrap --role webdevops-apache --role webdevops-php-apache --role webdevops-apache-dev --role webdevops-php-dev \ - && /opt/docker/bin/bootstrap.sh - + && /opt/docker/bin/bootstrap.sh \ + && docker-image-cleanup EXPOSE 80 443 diff --git a/docker/php-apache-dev/ubuntu-12.04/Dockerfile.jinja2 b/docker/php-apache-dev/ubuntu-12.04/Dockerfile.jinja2 index 526b62d9c..69c4f599f 100644 --- a/docker/php-apache-dev/ubuntu-12.04/Dockerfile.jinja2 +++ b/docker/php-apache-dev/ubuntu-12.04/Dockerfile.jinja2 @@ -1,7 +1,5 @@ {{ docker.from("php-dev", "ubuntu-12.04") }} -{{ docker.version() }} - {{ environment.web() }} {{ environment.webPhp() }} {{ environment.webDevelopment() }} diff --git a/docker/php-apache-dev/ubuntu-12.04/conf/bin/service.d/httpd.d/10-init.sh b/docker/php-apache-dev/ubuntu-12.04/conf/bin/service.d/httpd.d/10-init.sh index d3f1a0c9c..b9d57997e 100644 --- a/docker/php-apache-dev/ubuntu-12.04/conf/bin/service.d/httpd.d/10-init.sh +++ b/docker/php-apache-dev/ubuntu-12.04/conf/bin/service.d/httpd.d/10-init.sh @@ -5,15 +5,17 @@ if [[ ! -e "$WEB_DOCUMENT_ROOT" ]]; then fi # Replace markers -find /opt/docker/etc/httpd/ -iname '*.conf' -print0 | xargs -0 -r rpl --quiet "" "$WEB_DOCUMENT_INDEX" > /dev/null -find /opt/docker/etc/httpd/ -iname '*.conf' -print0 | xargs -0 -r rpl --quiet "" "$WEB_DOCUMENT_ROOT" > /dev/null -find /opt/docker/etc/httpd/ -iname '*.conf' -print0 | xargs -0 -r rpl --quiet "" "$WEB_ALIAS_DOMAIN" > /dev/null -find /opt/docker/etc/httpd/ -iname '*.conf' -print0 | xargs -0 -r rpl --quiet "" "$HOSTNAME" > /dev/null +go-replace \ + -s "" -r "$WEB_DOCUMENT_INDEX" \ + -s "" -r "$WEB_DOCUMENT_ROOT" \ + -s "" -r "$WEB_ALIAS_DOMAIN" \ + -s "" -r "$HOSTNAME" \ + -s "" -r "$WEB_PHP_SOCKET" \ + --path=/opt/docker/etc/httpd/ \ + --path-pattern='*.conf' \ + --ignore-empty -if [[ -n "${WEB_PHP_SOCKET+x}" ]]; then - ## WEB_PHP_SOCKET is set - find /opt/docker/etc/httpd/ -iname '*.conf' -print0 | xargs -0 -r rpl --quiet "" "$WEB_PHP_SOCKET" > /dev/null -else +if [[ -z "${WEB_PHP_SOCKET+x}" ]]; then ## WEB_PHP_SOCKET is not set, remove PHP files rm -f -- /opt/docker/etc/httpd/conf.d/10-php.conf fi diff --git a/docker/php-apache-dev/ubuntu-12.04/conf/bin/service.d/httpd.d/12-development.sh b/docker/php-apache-dev/ubuntu-12.04/conf/bin/service.d/httpd.d/12-development.sh index 299f67e2f..a9d2c6e92 100644 --- a/docker/php-apache-dev/ubuntu-12.04/conf/bin/service.d/httpd.d/12-development.sh +++ b/docker/php-apache-dev/ubuntu-12.04/conf/bin/service.d/httpd.d/12-development.sh @@ -1 +1,5 @@ -find /opt/docker/etc/httpd/ -iname '*.conf' -print0 | xargs -0 -r rpl --quiet "" "$WEB_NO_CACHE_PATTERN" > /dev/null +go-replace \ + -s "" -r "$WEB_NO_CACHE_PATTERN" \ + --path=/opt/docker/etc/httpd/ \ + --path-pattern='*.conf' \ + --ignore-empty diff --git a/docker/php-apache-dev/ubuntu-12.04/conf/etc/httpd/conf.d/10-log.conf b/docker/php-apache-dev/ubuntu-12.04/conf/etc/httpd/conf.d/10-log.conf index e4c4be4f2..ef0c73d38 100644 --- a/docker/php-apache-dev/ubuntu-12.04/conf/etc/httpd/conf.d/10-log.conf +++ b/docker/php-apache-dev/ubuntu-12.04/conf/etc/httpd/conf.d/10-log.conf @@ -1,4 +1,4 @@ LogFormat "[httpd:access] %V:%p %h %l %u %t \"%r\" %>s bytesIn:%I bytesOut:%O reqTime:%T" dockerlog LogLevel warn -CustomLog /proc/self/fd/1 dockerlog -ErrorLog /proc/self/fd/2 +CustomLog /docker.stdout dockerlog +ErrorLog /docker.stderr diff --git a/docker/php-apache-dev/ubuntu-12.04/conf/provision/entrypoint.d/10-php-debugger.sh b/docker/php-apache-dev/ubuntu-12.04/conf/provision/entrypoint.d/10-php-debugger.sh index 7156e28aa..b5985a9ef 100644 --- a/docker/php-apache-dev/ubuntu-12.04/conf/provision/entrypoint.d/10-php-debugger.sh +++ b/docker/php-apache-dev/ubuntu-12.04/conf/provision/entrypoint.d/10-php-debugger.sh @@ -15,7 +15,8 @@ PHP_CONF_PATHS=" /etc/php5/fpm/conf.d /etc/php/7.0/mods-available /etc/php/7.0/cli/conf.d -/etc/php/7.0/fpm/conf.d" +/etc/php/7.0/fpm/conf.d +/usr/local/etc/php/conf.d/" function phpModuleRemove() { if [ "$#" -ne 1 ]; then @@ -40,7 +41,7 @@ if [[ -n "${PHP_DEBUGGER+x}" ]]; then blackfire) echo "PHP-Debugger: Blackfire enabled" phpModuleRemove "xdebug" - /opt/docker/bin/control.sh service.enable blackfire-agent + docker-service-enable blackfire-agent ;; none) diff --git a/docker/php-apache-dev/ubuntu-12.04/conf/provision/roles/webdevops-apache/tasks/bootstrap.yml b/docker/php-apache-dev/ubuntu-12.04/conf/provision/roles/webdevops-apache/tasks/bootstrap.yml index 2be18b0e0..c285be286 100644 --- a/docker/php-apache-dev/ubuntu-12.04/conf/provision/roles/webdevops-apache/tasks/bootstrap.yml +++ b/docker/php-apache-dev/ubuntu-12.04/conf/provision/roles/webdevops-apache/tasks/bootstrap.yml @@ -84,7 +84,7 @@ with_items: - 'a2dismod mpm_event' - 'a2enmod mpm_event' - when: (ansible_distribution == 'Ubuntu' and ansible_lsb.major_release|int >= 14) or (ansible_distribution == 'Debian' and ansible_lsb.major_release|int >= 8) + when: (ansible_distribution == 'Ubuntu' and docker_image_info_distribution_version|int >= 14) or (ansible_distribution == 'Debian' and docker_image_info_distribution_version|int >= 8) - name: Manage modules [Alpine family] lineinfile: diff --git a/docker/php-apache-dev/ubuntu-12.04/conf/provision/roles/webdevops-php-dev/tasks/bootstrap.yml b/docker/php-apache-dev/ubuntu-12.04/conf/provision/roles/webdevops-php-dev/tasks/bootstrap.yml index 2c5d76e3d..ff02b05fc 100644 --- a/docker/php-apache-dev/ubuntu-12.04/conf/provision/roles/webdevops-php-dev/tasks/bootstrap.yml +++ b/docker/php-apache-dev/ubuntu-12.04/conf/provision/roles/webdevops-php-dev/tasks/bootstrap.yml @@ -1,6 +1,5 @@ --- -- include: bootstrap/tools.yml - include: bootstrap/php-fpm.yml - include: bootstrap/php-module.yml - include: bootstrap/php-module.opcache.yml diff --git a/docker/php-apache-dev/ubuntu-12.04/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/php-module.blackfire.yml b/docker/php-apache-dev/ubuntu-12.04/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/php-module.blackfire.yml index 1a3db9bac..faf05f8de 100644 --- a/docker/php-apache-dev/ubuntu-12.04/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/php-module.blackfire.yml +++ b/docker/php-apache-dev/ubuntu-12.04/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/php-module.blackfire.yml @@ -7,4 +7,4 @@ with_items: - /etc/php5/cli/conf.d/zz-blackfire.ini - /etc/php5/fpm/conf.d/zz-blackfire.ini - when: ansible_distribution == 'Debian' and ansible_lsb.major_release|int >= 7 + when: ansible_distribution == 'Debian' and docker_image_info_distribution_version|int >= 7 diff --git a/docker/php-apache-dev/ubuntu-12.04/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/tools.yml b/docker/php-apache-dev/ubuntu-12.04/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/tools.yml deleted file mode 100644 index c49cb0e34..000000000 --- a/docker/php-apache-dev/ubuntu-12.04/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/tools.yml +++ /dev/null @@ -1,23 +0,0 @@ ---- - -- name: Downloading Tools - shell: curl -o "{{ item.dest }}" "{{ item.url }}" && chmod 755 "{{ item.dest }}" - with_items: - - { url: "https://phar.phpunit.de/phploc.phar", dest: /usr/local/bin/phploc } - - { url: "https://phar.phpunit.de/phpunit.phar", dest: /usr/local/bin/phpunit } - - { url: "http://static.pdepend.org/php/latest/pdepend.phar", dest: /usr/local/bin/pdepend } - - { url: "http://static.phpmd.org/php/latest/phpmd.phar", dest: /usr/local/bin/phpmd } - - { url: "https://squizlabs.github.io/PHP_CodeSniffer/phpcs.phar", dest: /usr/local/bin/phpcs } - - { url: "https://squizlabs.github.io/PHP_CodeSniffer/phpcbf.phar", dest: /usr/local/bin/phpcbf } - - { url: "https://phar.phpunit.de/phpcpd.phar", dest: /usr/local/bin/phpcpd } - - { url: "https://phar.phpunit.de/phpdcd.phar", dest: /usr/local/bin/phpdcd } - - { url: "https://github.com/Halleck45/PhpMetrics/raw/master/build/phpmetrics.phar", dest: /usr/local/bin/phpmetrics } - - { url: "http://get.sensiolabs.org/php-cs-fixer.phar", dest: /usr/local/bin/php-cs-fixer } - - { url: "https://github.com/sensiolabs-de/deprecation-detector/releases/download/0.1.0-alpha4/deprecation-detector.phar", dest: /usr/local/bin/deprecation-detector } - - { url: "https://github.com/sensiolabs-de/deprecation-detector/releases/download/0.1.0-alpha4/deprecation-detector.phar", dest: /usr/local/bin/deprecation-detector } - -- name: Install Tools via composer - raw: COMPOSER_HOME="/usr/local/composer" COMPOSER_BIN_DIR="/usr/local/bin" composer global require "{{ item.package }}" "{{ item.version }}" - with_items: - - { package: "sstalle/php7cc" , version: "*" } - - { package: "phpspec/phpspec" , version: "~2.0" } diff --git a/docker/php-apache-dev/ubuntu-14.04/Dockerfile b/docker/php-apache-dev/ubuntu-14.04/Dockerfile index 3c8485a59..17f78ba49 100644 --- a/docker/php-apache-dev/ubuntu-14.04/Dockerfile +++ b/docker/php-apache-dev/ubuntu-14.04/Dockerfile @@ -5,16 +5,11 @@ FROM webdevops/php-dev:ubuntu-14.04 -MAINTAINER info@webdevops.io -LABEL vendor=WebDevOps.io -LABEL io.webdevops.layout=8 -LABEL io.webdevops.version=1.5.0 - -ENV WEB_DOCUMENT_ROOT /app -ENV WEB_DOCUMENT_INDEX index.php -ENV WEB_ALIAS_DOMAIN *.vm -ENV WEB_PHP_SOCKET 127.0.0.1:9000 -ENV WEB_NO_CACHE_PATTERN "\.(css|js|gif|png|jpg|svg|json|xml)$" +ENV WEB_DOCUMENT_ROOT=/app \ + WEB_DOCUMENT_INDEX=index.php \ + WEB_ALIAS_DOMAIN=*.vm +ENV WEB_PHP_SOCKET=127.0.0.1:9000 +ENV WEB_NO_CACHE_PATTERN="\.(css|js|gif|png|jpg|svg|json|xml)$" COPY conf/ /opt/docker/ @@ -31,7 +26,7 @@ RUN /usr/local/bin/apt-install \ && a2enmod actions fastcgi ssl rewrite headers expires \ && mkdir -p /var/lock/apache2 \ && /opt/docker/bin/provision run --tag bootstrap --role webdevops-apache --role webdevops-php-apache --role webdevops-apache-dev --role webdevops-php-dev \ - && /opt/docker/bin/bootstrap.sh - + && /opt/docker/bin/bootstrap.sh \ + && docker-image-cleanup EXPOSE 80 443 diff --git a/docker/php-apache-dev/ubuntu-14.04/Dockerfile.jinja2 b/docker/php-apache-dev/ubuntu-14.04/Dockerfile.jinja2 index 58dc1e66e..8106f83ab 100644 --- a/docker/php-apache-dev/ubuntu-14.04/Dockerfile.jinja2 +++ b/docker/php-apache-dev/ubuntu-14.04/Dockerfile.jinja2 @@ -1,7 +1,5 @@ {{ docker.from("php-dev", "ubuntu-14.04") }} -{{ docker.version() }} - {{ environment.web() }} {{ environment.webPhp() }} {{ environment.webDevelopment() }} diff --git a/docker/php-apache-dev/ubuntu-14.04/conf/bin/service.d/httpd.d/10-init.sh b/docker/php-apache-dev/ubuntu-14.04/conf/bin/service.d/httpd.d/10-init.sh index d3f1a0c9c..b9d57997e 100644 --- a/docker/php-apache-dev/ubuntu-14.04/conf/bin/service.d/httpd.d/10-init.sh +++ b/docker/php-apache-dev/ubuntu-14.04/conf/bin/service.d/httpd.d/10-init.sh @@ -5,15 +5,17 @@ if [[ ! -e "$WEB_DOCUMENT_ROOT" ]]; then fi # Replace markers -find /opt/docker/etc/httpd/ -iname '*.conf' -print0 | xargs -0 -r rpl --quiet "" "$WEB_DOCUMENT_INDEX" > /dev/null -find /opt/docker/etc/httpd/ -iname '*.conf' -print0 | xargs -0 -r rpl --quiet "" "$WEB_DOCUMENT_ROOT" > /dev/null -find /opt/docker/etc/httpd/ -iname '*.conf' -print0 | xargs -0 -r rpl --quiet "" "$WEB_ALIAS_DOMAIN" > /dev/null -find /opt/docker/etc/httpd/ -iname '*.conf' -print0 | xargs -0 -r rpl --quiet "" "$HOSTNAME" > /dev/null +go-replace \ + -s "" -r "$WEB_DOCUMENT_INDEX" \ + -s "" -r "$WEB_DOCUMENT_ROOT" \ + -s "" -r "$WEB_ALIAS_DOMAIN" \ + -s "" -r "$HOSTNAME" \ + -s "" -r "$WEB_PHP_SOCKET" \ + --path=/opt/docker/etc/httpd/ \ + --path-pattern='*.conf' \ + --ignore-empty -if [[ -n "${WEB_PHP_SOCKET+x}" ]]; then - ## WEB_PHP_SOCKET is set - find /opt/docker/etc/httpd/ -iname '*.conf' -print0 | xargs -0 -r rpl --quiet "" "$WEB_PHP_SOCKET" > /dev/null -else +if [[ -z "${WEB_PHP_SOCKET+x}" ]]; then ## WEB_PHP_SOCKET is not set, remove PHP files rm -f -- /opt/docker/etc/httpd/conf.d/10-php.conf fi diff --git a/docker/php-apache-dev/ubuntu-14.04/conf/bin/service.d/httpd.d/12-development.sh b/docker/php-apache-dev/ubuntu-14.04/conf/bin/service.d/httpd.d/12-development.sh index 299f67e2f..a9d2c6e92 100644 --- a/docker/php-apache-dev/ubuntu-14.04/conf/bin/service.d/httpd.d/12-development.sh +++ b/docker/php-apache-dev/ubuntu-14.04/conf/bin/service.d/httpd.d/12-development.sh @@ -1 +1,5 @@ -find /opt/docker/etc/httpd/ -iname '*.conf' -print0 | xargs -0 -r rpl --quiet "" "$WEB_NO_CACHE_PATTERN" > /dev/null +go-replace \ + -s "" -r "$WEB_NO_CACHE_PATTERN" \ + --path=/opt/docker/etc/httpd/ \ + --path-pattern='*.conf' \ + --ignore-empty diff --git a/docker/php-apache-dev/ubuntu-14.04/conf/etc/httpd/conf.d/10-log.conf b/docker/php-apache-dev/ubuntu-14.04/conf/etc/httpd/conf.d/10-log.conf index e4c4be4f2..ef0c73d38 100644 --- a/docker/php-apache-dev/ubuntu-14.04/conf/etc/httpd/conf.d/10-log.conf +++ b/docker/php-apache-dev/ubuntu-14.04/conf/etc/httpd/conf.d/10-log.conf @@ -1,4 +1,4 @@ LogFormat "[httpd:access] %V:%p %h %l %u %t \"%r\" %>s bytesIn:%I bytesOut:%O reqTime:%T" dockerlog LogLevel warn -CustomLog /proc/self/fd/1 dockerlog -ErrorLog /proc/self/fd/2 +CustomLog /docker.stdout dockerlog +ErrorLog /docker.stderr diff --git a/docker/php-apache-dev/ubuntu-14.04/conf/provision/entrypoint.d/10-php-debugger.sh b/docker/php-apache-dev/ubuntu-14.04/conf/provision/entrypoint.d/10-php-debugger.sh index 7156e28aa..b5985a9ef 100644 --- a/docker/php-apache-dev/ubuntu-14.04/conf/provision/entrypoint.d/10-php-debugger.sh +++ b/docker/php-apache-dev/ubuntu-14.04/conf/provision/entrypoint.d/10-php-debugger.sh @@ -15,7 +15,8 @@ PHP_CONF_PATHS=" /etc/php5/fpm/conf.d /etc/php/7.0/mods-available /etc/php/7.0/cli/conf.d -/etc/php/7.0/fpm/conf.d" +/etc/php/7.0/fpm/conf.d +/usr/local/etc/php/conf.d/" function phpModuleRemove() { if [ "$#" -ne 1 ]; then @@ -40,7 +41,7 @@ if [[ -n "${PHP_DEBUGGER+x}" ]]; then blackfire) echo "PHP-Debugger: Blackfire enabled" phpModuleRemove "xdebug" - /opt/docker/bin/control.sh service.enable blackfire-agent + docker-service-enable blackfire-agent ;; none) diff --git a/docker/php-apache-dev/ubuntu-14.04/conf/provision/roles/webdevops-apache/tasks/bootstrap.yml b/docker/php-apache-dev/ubuntu-14.04/conf/provision/roles/webdevops-apache/tasks/bootstrap.yml index 2be18b0e0..c285be286 100644 --- a/docker/php-apache-dev/ubuntu-14.04/conf/provision/roles/webdevops-apache/tasks/bootstrap.yml +++ b/docker/php-apache-dev/ubuntu-14.04/conf/provision/roles/webdevops-apache/tasks/bootstrap.yml @@ -84,7 +84,7 @@ with_items: - 'a2dismod mpm_event' - 'a2enmod mpm_event' - when: (ansible_distribution == 'Ubuntu' and ansible_lsb.major_release|int >= 14) or (ansible_distribution == 'Debian' and ansible_lsb.major_release|int >= 8) + when: (ansible_distribution == 'Ubuntu' and docker_image_info_distribution_version|int >= 14) or (ansible_distribution == 'Debian' and docker_image_info_distribution_version|int >= 8) - name: Manage modules [Alpine family] lineinfile: diff --git a/docker/php-apache-dev/ubuntu-14.04/conf/provision/roles/webdevops-php-dev/tasks/bootstrap.yml b/docker/php-apache-dev/ubuntu-14.04/conf/provision/roles/webdevops-php-dev/tasks/bootstrap.yml index 2c5d76e3d..ff02b05fc 100644 --- a/docker/php-apache-dev/ubuntu-14.04/conf/provision/roles/webdevops-php-dev/tasks/bootstrap.yml +++ b/docker/php-apache-dev/ubuntu-14.04/conf/provision/roles/webdevops-php-dev/tasks/bootstrap.yml @@ -1,6 +1,5 @@ --- -- include: bootstrap/tools.yml - include: bootstrap/php-fpm.yml - include: bootstrap/php-module.yml - include: bootstrap/php-module.opcache.yml diff --git a/docker/php-apache-dev/ubuntu-14.04/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/php-module.blackfire.yml b/docker/php-apache-dev/ubuntu-14.04/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/php-module.blackfire.yml index 1a3db9bac..faf05f8de 100644 --- a/docker/php-apache-dev/ubuntu-14.04/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/php-module.blackfire.yml +++ b/docker/php-apache-dev/ubuntu-14.04/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/php-module.blackfire.yml @@ -7,4 +7,4 @@ with_items: - /etc/php5/cli/conf.d/zz-blackfire.ini - /etc/php5/fpm/conf.d/zz-blackfire.ini - when: ansible_distribution == 'Debian' and ansible_lsb.major_release|int >= 7 + when: ansible_distribution == 'Debian' and docker_image_info_distribution_version|int >= 7 diff --git a/docker/php-apache-dev/ubuntu-14.04/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/tools.yml b/docker/php-apache-dev/ubuntu-14.04/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/tools.yml deleted file mode 100644 index c49cb0e34..000000000 --- a/docker/php-apache-dev/ubuntu-14.04/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/tools.yml +++ /dev/null @@ -1,23 +0,0 @@ ---- - -- name: Downloading Tools - shell: curl -o "{{ item.dest }}" "{{ item.url }}" && chmod 755 "{{ item.dest }}" - with_items: - - { url: "https://phar.phpunit.de/phploc.phar", dest: /usr/local/bin/phploc } - - { url: "https://phar.phpunit.de/phpunit.phar", dest: /usr/local/bin/phpunit } - - { url: "http://static.pdepend.org/php/latest/pdepend.phar", dest: /usr/local/bin/pdepend } - - { url: "http://static.phpmd.org/php/latest/phpmd.phar", dest: /usr/local/bin/phpmd } - - { url: "https://squizlabs.github.io/PHP_CodeSniffer/phpcs.phar", dest: /usr/local/bin/phpcs } - - { url: "https://squizlabs.github.io/PHP_CodeSniffer/phpcbf.phar", dest: /usr/local/bin/phpcbf } - - { url: "https://phar.phpunit.de/phpcpd.phar", dest: /usr/local/bin/phpcpd } - - { url: "https://phar.phpunit.de/phpdcd.phar", dest: /usr/local/bin/phpdcd } - - { url: "https://github.com/Halleck45/PhpMetrics/raw/master/build/phpmetrics.phar", dest: /usr/local/bin/phpmetrics } - - { url: "http://get.sensiolabs.org/php-cs-fixer.phar", dest: /usr/local/bin/php-cs-fixer } - - { url: "https://github.com/sensiolabs-de/deprecation-detector/releases/download/0.1.0-alpha4/deprecation-detector.phar", dest: /usr/local/bin/deprecation-detector } - - { url: "https://github.com/sensiolabs-de/deprecation-detector/releases/download/0.1.0-alpha4/deprecation-detector.phar", dest: /usr/local/bin/deprecation-detector } - -- name: Install Tools via composer - raw: COMPOSER_HOME="/usr/local/composer" COMPOSER_BIN_DIR="/usr/local/bin" composer global require "{{ item.package }}" "{{ item.version }}" - with_items: - - { package: "sstalle/php7cc" , version: "*" } - - { package: "phpspec/phpspec" , version: "~2.0" } diff --git a/docker/php-apache-dev/ubuntu-15.04/Dockerfile b/docker/php-apache-dev/ubuntu-15.04/Dockerfile index c61432ba9..0cb2b1143 100644 --- a/docker/php-apache-dev/ubuntu-15.04/Dockerfile +++ b/docker/php-apache-dev/ubuntu-15.04/Dockerfile @@ -5,16 +5,11 @@ FROM webdevops/php-dev:ubuntu-15.04 -MAINTAINER info@webdevops.io -LABEL vendor=WebDevOps.io -LABEL io.webdevops.layout=8 -LABEL io.webdevops.version=1.5.0 - -ENV WEB_DOCUMENT_ROOT /app -ENV WEB_DOCUMENT_INDEX index.php -ENV WEB_ALIAS_DOMAIN *.vm -ENV WEB_PHP_SOCKET 127.0.0.1:9000 -ENV WEB_NO_CACHE_PATTERN "\.(css|js|gif|png|jpg|svg|json|xml)$" +ENV WEB_DOCUMENT_ROOT=/app \ + WEB_DOCUMENT_INDEX=index.php \ + WEB_ALIAS_DOMAIN=*.vm +ENV WEB_PHP_SOCKET=127.0.0.1:9000 +ENV WEB_NO_CACHE_PATTERN="\.(css|js|gif|png|jpg|svg|json|xml)$" COPY conf/ /opt/docker/ @@ -29,7 +24,7 @@ RUN /usr/local/bin/apt-install \ && ln -sf /opt/docker/etc/httpd/main.conf /etc/apache2/sites-enabled/10-docker.conf \ && a2enmod actions proxy proxy_fcgi ssl rewrite headers expires \ && /opt/docker/bin/provision run --tag bootstrap --role webdevops-apache --role webdevops-php-apache --role webdevops-apache-dev --role webdevops-php-dev \ - && /opt/docker/bin/bootstrap.sh - + && /opt/docker/bin/bootstrap.sh \ + && docker-image-cleanup EXPOSE 80 443 diff --git a/docker/php-apache-dev/ubuntu-15.04/Dockerfile.jinja2 b/docker/php-apache-dev/ubuntu-15.04/Dockerfile.jinja2 index e7356b43d..b0d9e6299 100644 --- a/docker/php-apache-dev/ubuntu-15.04/Dockerfile.jinja2 +++ b/docker/php-apache-dev/ubuntu-15.04/Dockerfile.jinja2 @@ -1,7 +1,5 @@ {{ docker.from("php-dev", "ubuntu-15.04") }} -{{ docker.version() }} - {{ environment.web() }} {{ environment.webPhp() }} {{ environment.webDevelopment() }} diff --git a/docker/php-apache-dev/ubuntu-15.04/conf/bin/service.d/httpd.d/10-init.sh b/docker/php-apache-dev/ubuntu-15.04/conf/bin/service.d/httpd.d/10-init.sh index d3f1a0c9c..b9d57997e 100644 --- a/docker/php-apache-dev/ubuntu-15.04/conf/bin/service.d/httpd.d/10-init.sh +++ b/docker/php-apache-dev/ubuntu-15.04/conf/bin/service.d/httpd.d/10-init.sh @@ -5,15 +5,17 @@ if [[ ! -e "$WEB_DOCUMENT_ROOT" ]]; then fi # Replace markers -find /opt/docker/etc/httpd/ -iname '*.conf' -print0 | xargs -0 -r rpl --quiet "" "$WEB_DOCUMENT_INDEX" > /dev/null -find /opt/docker/etc/httpd/ -iname '*.conf' -print0 | xargs -0 -r rpl --quiet "" "$WEB_DOCUMENT_ROOT" > /dev/null -find /opt/docker/etc/httpd/ -iname '*.conf' -print0 | xargs -0 -r rpl --quiet "" "$WEB_ALIAS_DOMAIN" > /dev/null -find /opt/docker/etc/httpd/ -iname '*.conf' -print0 | xargs -0 -r rpl --quiet "" "$HOSTNAME" > /dev/null +go-replace \ + -s "" -r "$WEB_DOCUMENT_INDEX" \ + -s "" -r "$WEB_DOCUMENT_ROOT" \ + -s "" -r "$WEB_ALIAS_DOMAIN" \ + -s "" -r "$HOSTNAME" \ + -s "" -r "$WEB_PHP_SOCKET" \ + --path=/opt/docker/etc/httpd/ \ + --path-pattern='*.conf' \ + --ignore-empty -if [[ -n "${WEB_PHP_SOCKET+x}" ]]; then - ## WEB_PHP_SOCKET is set - find /opt/docker/etc/httpd/ -iname '*.conf' -print0 | xargs -0 -r rpl --quiet "" "$WEB_PHP_SOCKET" > /dev/null -else +if [[ -z "${WEB_PHP_SOCKET+x}" ]]; then ## WEB_PHP_SOCKET is not set, remove PHP files rm -f -- /opt/docker/etc/httpd/conf.d/10-php.conf fi diff --git a/docker/php-apache-dev/ubuntu-15.04/conf/bin/service.d/httpd.d/12-development.sh b/docker/php-apache-dev/ubuntu-15.04/conf/bin/service.d/httpd.d/12-development.sh index 299f67e2f..a9d2c6e92 100644 --- a/docker/php-apache-dev/ubuntu-15.04/conf/bin/service.d/httpd.d/12-development.sh +++ b/docker/php-apache-dev/ubuntu-15.04/conf/bin/service.d/httpd.d/12-development.sh @@ -1 +1,5 @@ -find /opt/docker/etc/httpd/ -iname '*.conf' -print0 | xargs -0 -r rpl --quiet "" "$WEB_NO_CACHE_PATTERN" > /dev/null +go-replace \ + -s "" -r "$WEB_NO_CACHE_PATTERN" \ + --path=/opt/docker/etc/httpd/ \ + --path-pattern='*.conf' \ + --ignore-empty diff --git a/docker/php-apache-dev/ubuntu-15.04/conf/etc/httpd/conf.d/10-log.conf b/docker/php-apache-dev/ubuntu-15.04/conf/etc/httpd/conf.d/10-log.conf index e4c4be4f2..ef0c73d38 100644 --- a/docker/php-apache-dev/ubuntu-15.04/conf/etc/httpd/conf.d/10-log.conf +++ b/docker/php-apache-dev/ubuntu-15.04/conf/etc/httpd/conf.d/10-log.conf @@ -1,4 +1,4 @@ LogFormat "[httpd:access] %V:%p %h %l %u %t \"%r\" %>s bytesIn:%I bytesOut:%O reqTime:%T" dockerlog LogLevel warn -CustomLog /proc/self/fd/1 dockerlog -ErrorLog /proc/self/fd/2 +CustomLog /docker.stdout dockerlog +ErrorLog /docker.stderr diff --git a/docker/php-apache-dev/ubuntu-15.04/conf/provision/entrypoint.d/10-php-debugger.sh b/docker/php-apache-dev/ubuntu-15.04/conf/provision/entrypoint.d/10-php-debugger.sh index 7156e28aa..b5985a9ef 100644 --- a/docker/php-apache-dev/ubuntu-15.04/conf/provision/entrypoint.d/10-php-debugger.sh +++ b/docker/php-apache-dev/ubuntu-15.04/conf/provision/entrypoint.d/10-php-debugger.sh @@ -15,7 +15,8 @@ PHP_CONF_PATHS=" /etc/php5/fpm/conf.d /etc/php/7.0/mods-available /etc/php/7.0/cli/conf.d -/etc/php/7.0/fpm/conf.d" +/etc/php/7.0/fpm/conf.d +/usr/local/etc/php/conf.d/" function phpModuleRemove() { if [ "$#" -ne 1 ]; then @@ -40,7 +41,7 @@ if [[ -n "${PHP_DEBUGGER+x}" ]]; then blackfire) echo "PHP-Debugger: Blackfire enabled" phpModuleRemove "xdebug" - /opt/docker/bin/control.sh service.enable blackfire-agent + docker-service-enable blackfire-agent ;; none) diff --git a/docker/php-apache-dev/ubuntu-15.04/conf/provision/roles/webdevops-apache/tasks/bootstrap.yml b/docker/php-apache-dev/ubuntu-15.04/conf/provision/roles/webdevops-apache/tasks/bootstrap.yml index 2be18b0e0..c285be286 100644 --- a/docker/php-apache-dev/ubuntu-15.04/conf/provision/roles/webdevops-apache/tasks/bootstrap.yml +++ b/docker/php-apache-dev/ubuntu-15.04/conf/provision/roles/webdevops-apache/tasks/bootstrap.yml @@ -84,7 +84,7 @@ with_items: - 'a2dismod mpm_event' - 'a2enmod mpm_event' - when: (ansible_distribution == 'Ubuntu' and ansible_lsb.major_release|int >= 14) or (ansible_distribution == 'Debian' and ansible_lsb.major_release|int >= 8) + when: (ansible_distribution == 'Ubuntu' and docker_image_info_distribution_version|int >= 14) or (ansible_distribution == 'Debian' and docker_image_info_distribution_version|int >= 8) - name: Manage modules [Alpine family] lineinfile: diff --git a/docker/php-apache-dev/ubuntu-15.04/conf/provision/roles/webdevops-php-dev/tasks/bootstrap.yml b/docker/php-apache-dev/ubuntu-15.04/conf/provision/roles/webdevops-php-dev/tasks/bootstrap.yml index 2c5d76e3d..ff02b05fc 100644 --- a/docker/php-apache-dev/ubuntu-15.04/conf/provision/roles/webdevops-php-dev/tasks/bootstrap.yml +++ b/docker/php-apache-dev/ubuntu-15.04/conf/provision/roles/webdevops-php-dev/tasks/bootstrap.yml @@ -1,6 +1,5 @@ --- -- include: bootstrap/tools.yml - include: bootstrap/php-fpm.yml - include: bootstrap/php-module.yml - include: bootstrap/php-module.opcache.yml diff --git a/docker/php-apache-dev/ubuntu-15.04/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/php-module.blackfire.yml b/docker/php-apache-dev/ubuntu-15.04/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/php-module.blackfire.yml index 1a3db9bac..faf05f8de 100644 --- a/docker/php-apache-dev/ubuntu-15.04/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/php-module.blackfire.yml +++ b/docker/php-apache-dev/ubuntu-15.04/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/php-module.blackfire.yml @@ -7,4 +7,4 @@ with_items: - /etc/php5/cli/conf.d/zz-blackfire.ini - /etc/php5/fpm/conf.d/zz-blackfire.ini - when: ansible_distribution == 'Debian' and ansible_lsb.major_release|int >= 7 + when: ansible_distribution == 'Debian' and docker_image_info_distribution_version|int >= 7 diff --git a/docker/php-apache-dev/ubuntu-15.04/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/tools.yml b/docker/php-apache-dev/ubuntu-15.04/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/tools.yml deleted file mode 100644 index c49cb0e34..000000000 --- a/docker/php-apache-dev/ubuntu-15.04/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/tools.yml +++ /dev/null @@ -1,23 +0,0 @@ ---- - -- name: Downloading Tools - shell: curl -o "{{ item.dest }}" "{{ item.url }}" && chmod 755 "{{ item.dest }}" - with_items: - - { url: "https://phar.phpunit.de/phploc.phar", dest: /usr/local/bin/phploc } - - { url: "https://phar.phpunit.de/phpunit.phar", dest: /usr/local/bin/phpunit } - - { url: "http://static.pdepend.org/php/latest/pdepend.phar", dest: /usr/local/bin/pdepend } - - { url: "http://static.phpmd.org/php/latest/phpmd.phar", dest: /usr/local/bin/phpmd } - - { url: "https://squizlabs.github.io/PHP_CodeSniffer/phpcs.phar", dest: /usr/local/bin/phpcs } - - { url: "https://squizlabs.github.io/PHP_CodeSniffer/phpcbf.phar", dest: /usr/local/bin/phpcbf } - - { url: "https://phar.phpunit.de/phpcpd.phar", dest: /usr/local/bin/phpcpd } - - { url: "https://phar.phpunit.de/phpdcd.phar", dest: /usr/local/bin/phpdcd } - - { url: "https://github.com/Halleck45/PhpMetrics/raw/master/build/phpmetrics.phar", dest: /usr/local/bin/phpmetrics } - - { url: "http://get.sensiolabs.org/php-cs-fixer.phar", dest: /usr/local/bin/php-cs-fixer } - - { url: "https://github.com/sensiolabs-de/deprecation-detector/releases/download/0.1.0-alpha4/deprecation-detector.phar", dest: /usr/local/bin/deprecation-detector } - - { url: "https://github.com/sensiolabs-de/deprecation-detector/releases/download/0.1.0-alpha4/deprecation-detector.phar", dest: /usr/local/bin/deprecation-detector } - -- name: Install Tools via composer - raw: COMPOSER_HOME="/usr/local/composer" COMPOSER_BIN_DIR="/usr/local/bin" composer global require "{{ item.package }}" "{{ item.version }}" - with_items: - - { package: "sstalle/php7cc" , version: "*" } - - { package: "phpspec/phpspec" , version: "~2.0" } diff --git a/docker/php-apache-dev/ubuntu-15.10/Dockerfile b/docker/php-apache-dev/ubuntu-15.10/Dockerfile index f6f57b629..78402f298 100644 --- a/docker/php-apache-dev/ubuntu-15.10/Dockerfile +++ b/docker/php-apache-dev/ubuntu-15.10/Dockerfile @@ -5,16 +5,11 @@ FROM webdevops/php-dev:ubuntu-15.10 -MAINTAINER info@webdevops.io -LABEL vendor=WebDevOps.io -LABEL io.webdevops.layout=8 -LABEL io.webdevops.version=1.5.0 - -ENV WEB_DOCUMENT_ROOT /app -ENV WEB_DOCUMENT_INDEX index.php -ENV WEB_ALIAS_DOMAIN *.vm -ENV WEB_PHP_SOCKET 127.0.0.1:9000 -ENV WEB_NO_CACHE_PATTERN "\.(css|js|gif|png|jpg|svg|json|xml)$" +ENV WEB_DOCUMENT_ROOT=/app \ + WEB_DOCUMENT_INDEX=index.php \ + WEB_ALIAS_DOMAIN=*.vm +ENV WEB_PHP_SOCKET=127.0.0.1:9000 +ENV WEB_NO_CACHE_PATTERN="\.(css|js|gif|png|jpg|svg|json|xml)$" COPY conf/ /opt/docker/ @@ -29,7 +24,7 @@ RUN /usr/local/bin/apt-install \ && ln -sf /opt/docker/etc/httpd/main.conf /etc/apache2/sites-enabled/10-docker.conf \ && a2enmod actions proxy proxy_fcgi ssl rewrite headers expires \ && /opt/docker/bin/provision run --tag bootstrap --role webdevops-apache --role webdevops-php-apache --role webdevops-apache-dev --role webdevops-php-dev \ - && /opt/docker/bin/bootstrap.sh - + && /opt/docker/bin/bootstrap.sh \ + && docker-image-cleanup EXPOSE 80 443 diff --git a/docker/php-apache-dev/ubuntu-15.10/Dockerfile.jinja2 b/docker/php-apache-dev/ubuntu-15.10/Dockerfile.jinja2 index 6737813a9..746fdf556 100644 --- a/docker/php-apache-dev/ubuntu-15.10/Dockerfile.jinja2 +++ b/docker/php-apache-dev/ubuntu-15.10/Dockerfile.jinja2 @@ -1,7 +1,5 @@ {{ docker.from("php-dev", "ubuntu-15.10") }} -{{ docker.version() }} - {{ environment.web() }} {{ environment.webPhp() }} {{ environment.webDevelopment() }} diff --git a/docker/php-apache-dev/ubuntu-15.10/conf/bin/service.d/httpd.d/10-init.sh b/docker/php-apache-dev/ubuntu-15.10/conf/bin/service.d/httpd.d/10-init.sh index d3f1a0c9c..b9d57997e 100644 --- a/docker/php-apache-dev/ubuntu-15.10/conf/bin/service.d/httpd.d/10-init.sh +++ b/docker/php-apache-dev/ubuntu-15.10/conf/bin/service.d/httpd.d/10-init.sh @@ -5,15 +5,17 @@ if [[ ! -e "$WEB_DOCUMENT_ROOT" ]]; then fi # Replace markers -find /opt/docker/etc/httpd/ -iname '*.conf' -print0 | xargs -0 -r rpl --quiet "" "$WEB_DOCUMENT_INDEX" > /dev/null -find /opt/docker/etc/httpd/ -iname '*.conf' -print0 | xargs -0 -r rpl --quiet "" "$WEB_DOCUMENT_ROOT" > /dev/null -find /opt/docker/etc/httpd/ -iname '*.conf' -print0 | xargs -0 -r rpl --quiet "" "$WEB_ALIAS_DOMAIN" > /dev/null -find /opt/docker/etc/httpd/ -iname '*.conf' -print0 | xargs -0 -r rpl --quiet "" "$HOSTNAME" > /dev/null +go-replace \ + -s "" -r "$WEB_DOCUMENT_INDEX" \ + -s "" -r "$WEB_DOCUMENT_ROOT" \ + -s "" -r "$WEB_ALIAS_DOMAIN" \ + -s "" -r "$HOSTNAME" \ + -s "" -r "$WEB_PHP_SOCKET" \ + --path=/opt/docker/etc/httpd/ \ + --path-pattern='*.conf' \ + --ignore-empty -if [[ -n "${WEB_PHP_SOCKET+x}" ]]; then - ## WEB_PHP_SOCKET is set - find /opt/docker/etc/httpd/ -iname '*.conf' -print0 | xargs -0 -r rpl --quiet "" "$WEB_PHP_SOCKET" > /dev/null -else +if [[ -z "${WEB_PHP_SOCKET+x}" ]]; then ## WEB_PHP_SOCKET is not set, remove PHP files rm -f -- /opt/docker/etc/httpd/conf.d/10-php.conf fi diff --git a/docker/php-apache-dev/ubuntu-15.10/conf/bin/service.d/httpd.d/12-development.sh b/docker/php-apache-dev/ubuntu-15.10/conf/bin/service.d/httpd.d/12-development.sh index 299f67e2f..a9d2c6e92 100644 --- a/docker/php-apache-dev/ubuntu-15.10/conf/bin/service.d/httpd.d/12-development.sh +++ b/docker/php-apache-dev/ubuntu-15.10/conf/bin/service.d/httpd.d/12-development.sh @@ -1 +1,5 @@ -find /opt/docker/etc/httpd/ -iname '*.conf' -print0 | xargs -0 -r rpl --quiet "" "$WEB_NO_CACHE_PATTERN" > /dev/null +go-replace \ + -s "" -r "$WEB_NO_CACHE_PATTERN" \ + --path=/opt/docker/etc/httpd/ \ + --path-pattern='*.conf' \ + --ignore-empty diff --git a/docker/php-apache-dev/ubuntu-15.10/conf/etc/httpd/conf.d/10-log.conf b/docker/php-apache-dev/ubuntu-15.10/conf/etc/httpd/conf.d/10-log.conf index e4c4be4f2..ef0c73d38 100644 --- a/docker/php-apache-dev/ubuntu-15.10/conf/etc/httpd/conf.d/10-log.conf +++ b/docker/php-apache-dev/ubuntu-15.10/conf/etc/httpd/conf.d/10-log.conf @@ -1,4 +1,4 @@ LogFormat "[httpd:access] %V:%p %h %l %u %t \"%r\" %>s bytesIn:%I bytesOut:%O reqTime:%T" dockerlog LogLevel warn -CustomLog /proc/self/fd/1 dockerlog -ErrorLog /proc/self/fd/2 +CustomLog /docker.stdout dockerlog +ErrorLog /docker.stderr diff --git a/docker/php-apache-dev/ubuntu-15.10/conf/provision/entrypoint.d/10-php-debugger.sh b/docker/php-apache-dev/ubuntu-15.10/conf/provision/entrypoint.d/10-php-debugger.sh index 7156e28aa..b5985a9ef 100644 --- a/docker/php-apache-dev/ubuntu-15.10/conf/provision/entrypoint.d/10-php-debugger.sh +++ b/docker/php-apache-dev/ubuntu-15.10/conf/provision/entrypoint.d/10-php-debugger.sh @@ -15,7 +15,8 @@ PHP_CONF_PATHS=" /etc/php5/fpm/conf.d /etc/php/7.0/mods-available /etc/php/7.0/cli/conf.d -/etc/php/7.0/fpm/conf.d" +/etc/php/7.0/fpm/conf.d +/usr/local/etc/php/conf.d/" function phpModuleRemove() { if [ "$#" -ne 1 ]; then @@ -40,7 +41,7 @@ if [[ -n "${PHP_DEBUGGER+x}" ]]; then blackfire) echo "PHP-Debugger: Blackfire enabled" phpModuleRemove "xdebug" - /opt/docker/bin/control.sh service.enable blackfire-agent + docker-service-enable blackfire-agent ;; none) diff --git a/docker/php-apache-dev/ubuntu-15.10/conf/provision/roles/webdevops-apache/tasks/bootstrap.yml b/docker/php-apache-dev/ubuntu-15.10/conf/provision/roles/webdevops-apache/tasks/bootstrap.yml index 2be18b0e0..c285be286 100644 --- a/docker/php-apache-dev/ubuntu-15.10/conf/provision/roles/webdevops-apache/tasks/bootstrap.yml +++ b/docker/php-apache-dev/ubuntu-15.10/conf/provision/roles/webdevops-apache/tasks/bootstrap.yml @@ -84,7 +84,7 @@ with_items: - 'a2dismod mpm_event' - 'a2enmod mpm_event' - when: (ansible_distribution == 'Ubuntu' and ansible_lsb.major_release|int >= 14) or (ansible_distribution == 'Debian' and ansible_lsb.major_release|int >= 8) + when: (ansible_distribution == 'Ubuntu' and docker_image_info_distribution_version|int >= 14) or (ansible_distribution == 'Debian' and docker_image_info_distribution_version|int >= 8) - name: Manage modules [Alpine family] lineinfile: diff --git a/docker/php-apache-dev/ubuntu-15.10/conf/provision/roles/webdevops-php-dev/tasks/bootstrap.yml b/docker/php-apache-dev/ubuntu-15.10/conf/provision/roles/webdevops-php-dev/tasks/bootstrap.yml index 2c5d76e3d..ff02b05fc 100644 --- a/docker/php-apache-dev/ubuntu-15.10/conf/provision/roles/webdevops-php-dev/tasks/bootstrap.yml +++ b/docker/php-apache-dev/ubuntu-15.10/conf/provision/roles/webdevops-php-dev/tasks/bootstrap.yml @@ -1,6 +1,5 @@ --- -- include: bootstrap/tools.yml - include: bootstrap/php-fpm.yml - include: bootstrap/php-module.yml - include: bootstrap/php-module.opcache.yml diff --git a/docker/php-apache-dev/ubuntu-15.10/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/php-module.blackfire.yml b/docker/php-apache-dev/ubuntu-15.10/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/php-module.blackfire.yml index 1a3db9bac..faf05f8de 100644 --- a/docker/php-apache-dev/ubuntu-15.10/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/php-module.blackfire.yml +++ b/docker/php-apache-dev/ubuntu-15.10/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/php-module.blackfire.yml @@ -7,4 +7,4 @@ with_items: - /etc/php5/cli/conf.d/zz-blackfire.ini - /etc/php5/fpm/conf.d/zz-blackfire.ini - when: ansible_distribution == 'Debian' and ansible_lsb.major_release|int >= 7 + when: ansible_distribution == 'Debian' and docker_image_info_distribution_version|int >= 7 diff --git a/docker/php-apache-dev/ubuntu-15.10/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/tools.yml b/docker/php-apache-dev/ubuntu-15.10/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/tools.yml deleted file mode 100644 index c49cb0e34..000000000 --- a/docker/php-apache-dev/ubuntu-15.10/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/tools.yml +++ /dev/null @@ -1,23 +0,0 @@ ---- - -- name: Downloading Tools - shell: curl -o "{{ item.dest }}" "{{ item.url }}" && chmod 755 "{{ item.dest }}" - with_items: - - { url: "https://phar.phpunit.de/phploc.phar", dest: /usr/local/bin/phploc } - - { url: "https://phar.phpunit.de/phpunit.phar", dest: /usr/local/bin/phpunit } - - { url: "http://static.pdepend.org/php/latest/pdepend.phar", dest: /usr/local/bin/pdepend } - - { url: "http://static.phpmd.org/php/latest/phpmd.phar", dest: /usr/local/bin/phpmd } - - { url: "https://squizlabs.github.io/PHP_CodeSniffer/phpcs.phar", dest: /usr/local/bin/phpcs } - - { url: "https://squizlabs.github.io/PHP_CodeSniffer/phpcbf.phar", dest: /usr/local/bin/phpcbf } - - { url: "https://phar.phpunit.de/phpcpd.phar", dest: /usr/local/bin/phpcpd } - - { url: "https://phar.phpunit.de/phpdcd.phar", dest: /usr/local/bin/phpdcd } - - { url: "https://github.com/Halleck45/PhpMetrics/raw/master/build/phpmetrics.phar", dest: /usr/local/bin/phpmetrics } - - { url: "http://get.sensiolabs.org/php-cs-fixer.phar", dest: /usr/local/bin/php-cs-fixer } - - { url: "https://github.com/sensiolabs-de/deprecation-detector/releases/download/0.1.0-alpha4/deprecation-detector.phar", dest: /usr/local/bin/deprecation-detector } - - { url: "https://github.com/sensiolabs-de/deprecation-detector/releases/download/0.1.0-alpha4/deprecation-detector.phar", dest: /usr/local/bin/deprecation-detector } - -- name: Install Tools via composer - raw: COMPOSER_HOME="/usr/local/composer" COMPOSER_BIN_DIR="/usr/local/bin" composer global require "{{ item.package }}" "{{ item.version }}" - with_items: - - { package: "sstalle/php7cc" , version: "*" } - - { package: "phpspec/phpspec" , version: "~2.0" } diff --git a/docker/php-apache-dev/ubuntu-16.04/Dockerfile b/docker/php-apache-dev/ubuntu-16.04/Dockerfile index fdd141b42..f98737eb8 100644 --- a/docker/php-apache-dev/ubuntu-16.04/Dockerfile +++ b/docker/php-apache-dev/ubuntu-16.04/Dockerfile @@ -5,16 +5,11 @@ FROM webdevops/php-dev:ubuntu-16.04 -MAINTAINER info@webdevops.io -LABEL vendor=WebDevOps.io -LABEL io.webdevops.layout=8 -LABEL io.webdevops.version=1.5.0 - -ENV WEB_DOCUMENT_ROOT /app -ENV WEB_DOCUMENT_INDEX index.php -ENV WEB_ALIAS_DOMAIN *.vm -ENV WEB_PHP_SOCKET 127.0.0.1:9000 -ENV WEB_NO_CACHE_PATTERN "\.(css|js|gif|png|jpg|svg|json|xml)$" +ENV WEB_DOCUMENT_ROOT=/app \ + WEB_DOCUMENT_INDEX=index.php \ + WEB_ALIAS_DOMAIN=*.vm +ENV WEB_PHP_SOCKET=127.0.0.1:9000 +ENV WEB_NO_CACHE_PATTERN="\.(css|js|gif|png|jpg|svg|json|xml)$" COPY conf/ /opt/docker/ @@ -29,7 +24,7 @@ RUN /usr/local/bin/apt-install \ && ln -sf /opt/docker/etc/httpd/main.conf /etc/apache2/sites-enabled/10-docker.conf \ && a2enmod actions proxy proxy_fcgi ssl rewrite headers expires \ && /opt/docker/bin/provision run --tag bootstrap --role webdevops-apache --role webdevops-php-apache --role webdevops-apache-dev --role webdevops-php-dev \ - && /opt/docker/bin/bootstrap.sh - + && /opt/docker/bin/bootstrap.sh \ + && docker-image-cleanup EXPOSE 80 443 diff --git a/docker/php-apache-dev/ubuntu-16.04/Dockerfile.jinja2 b/docker/php-apache-dev/ubuntu-16.04/Dockerfile.jinja2 index df24f9644..faf593552 100644 --- a/docker/php-apache-dev/ubuntu-16.04/Dockerfile.jinja2 +++ b/docker/php-apache-dev/ubuntu-16.04/Dockerfile.jinja2 @@ -1,7 +1,5 @@ {{ docker.from("php-dev", "ubuntu-16.04") }} -{{ docker.version() }} - {{ environment.web() }} {{ environment.webPhp() }} {{ environment.webDevelopment() }} diff --git a/docker/php-apache-dev/ubuntu-16.04/conf/bin/service.d/httpd.d/10-init.sh b/docker/php-apache-dev/ubuntu-16.04/conf/bin/service.d/httpd.d/10-init.sh index d3f1a0c9c..b9d57997e 100644 --- a/docker/php-apache-dev/ubuntu-16.04/conf/bin/service.d/httpd.d/10-init.sh +++ b/docker/php-apache-dev/ubuntu-16.04/conf/bin/service.d/httpd.d/10-init.sh @@ -5,15 +5,17 @@ if [[ ! -e "$WEB_DOCUMENT_ROOT" ]]; then fi # Replace markers -find /opt/docker/etc/httpd/ -iname '*.conf' -print0 | xargs -0 -r rpl --quiet "" "$WEB_DOCUMENT_INDEX" > /dev/null -find /opt/docker/etc/httpd/ -iname '*.conf' -print0 | xargs -0 -r rpl --quiet "" "$WEB_DOCUMENT_ROOT" > /dev/null -find /opt/docker/etc/httpd/ -iname '*.conf' -print0 | xargs -0 -r rpl --quiet "" "$WEB_ALIAS_DOMAIN" > /dev/null -find /opt/docker/etc/httpd/ -iname '*.conf' -print0 | xargs -0 -r rpl --quiet "" "$HOSTNAME" > /dev/null +go-replace \ + -s "" -r "$WEB_DOCUMENT_INDEX" \ + -s "" -r "$WEB_DOCUMENT_ROOT" \ + -s "" -r "$WEB_ALIAS_DOMAIN" \ + -s "" -r "$HOSTNAME" \ + -s "" -r "$WEB_PHP_SOCKET" \ + --path=/opt/docker/etc/httpd/ \ + --path-pattern='*.conf' \ + --ignore-empty -if [[ -n "${WEB_PHP_SOCKET+x}" ]]; then - ## WEB_PHP_SOCKET is set - find /opt/docker/etc/httpd/ -iname '*.conf' -print0 | xargs -0 -r rpl --quiet "" "$WEB_PHP_SOCKET" > /dev/null -else +if [[ -z "${WEB_PHP_SOCKET+x}" ]]; then ## WEB_PHP_SOCKET is not set, remove PHP files rm -f -- /opt/docker/etc/httpd/conf.d/10-php.conf fi diff --git a/docker/php-apache-dev/ubuntu-16.04/conf/bin/service.d/httpd.d/12-development.sh b/docker/php-apache-dev/ubuntu-16.04/conf/bin/service.d/httpd.d/12-development.sh index 299f67e2f..a9d2c6e92 100644 --- a/docker/php-apache-dev/ubuntu-16.04/conf/bin/service.d/httpd.d/12-development.sh +++ b/docker/php-apache-dev/ubuntu-16.04/conf/bin/service.d/httpd.d/12-development.sh @@ -1 +1,5 @@ -find /opt/docker/etc/httpd/ -iname '*.conf' -print0 | xargs -0 -r rpl --quiet "" "$WEB_NO_CACHE_PATTERN" > /dev/null +go-replace \ + -s "" -r "$WEB_NO_CACHE_PATTERN" \ + --path=/opt/docker/etc/httpd/ \ + --path-pattern='*.conf' \ + --ignore-empty diff --git a/docker/php-apache-dev/ubuntu-16.04/conf/etc/httpd/conf.d/10-log.conf b/docker/php-apache-dev/ubuntu-16.04/conf/etc/httpd/conf.d/10-log.conf index e4c4be4f2..ef0c73d38 100644 --- a/docker/php-apache-dev/ubuntu-16.04/conf/etc/httpd/conf.d/10-log.conf +++ b/docker/php-apache-dev/ubuntu-16.04/conf/etc/httpd/conf.d/10-log.conf @@ -1,4 +1,4 @@ LogFormat "[httpd:access] %V:%p %h %l %u %t \"%r\" %>s bytesIn:%I bytesOut:%O reqTime:%T" dockerlog LogLevel warn -CustomLog /proc/self/fd/1 dockerlog -ErrorLog /proc/self/fd/2 +CustomLog /docker.stdout dockerlog +ErrorLog /docker.stderr diff --git a/docker/php-apache-dev/ubuntu-16.04/conf/provision/entrypoint.d/10-php-debugger.sh b/docker/php-apache-dev/ubuntu-16.04/conf/provision/entrypoint.d/10-php-debugger.sh index 7156e28aa..b5985a9ef 100644 --- a/docker/php-apache-dev/ubuntu-16.04/conf/provision/entrypoint.d/10-php-debugger.sh +++ b/docker/php-apache-dev/ubuntu-16.04/conf/provision/entrypoint.d/10-php-debugger.sh @@ -15,7 +15,8 @@ PHP_CONF_PATHS=" /etc/php5/fpm/conf.d /etc/php/7.0/mods-available /etc/php/7.0/cli/conf.d -/etc/php/7.0/fpm/conf.d" +/etc/php/7.0/fpm/conf.d +/usr/local/etc/php/conf.d/" function phpModuleRemove() { if [ "$#" -ne 1 ]; then @@ -40,7 +41,7 @@ if [[ -n "${PHP_DEBUGGER+x}" ]]; then blackfire) echo "PHP-Debugger: Blackfire enabled" phpModuleRemove "xdebug" - /opt/docker/bin/control.sh service.enable blackfire-agent + docker-service-enable blackfire-agent ;; none) diff --git a/docker/php-apache-dev/ubuntu-16.04/conf/provision/roles/webdevops-apache/tasks/bootstrap.yml b/docker/php-apache-dev/ubuntu-16.04/conf/provision/roles/webdevops-apache/tasks/bootstrap.yml index 2be18b0e0..c285be286 100644 --- a/docker/php-apache-dev/ubuntu-16.04/conf/provision/roles/webdevops-apache/tasks/bootstrap.yml +++ b/docker/php-apache-dev/ubuntu-16.04/conf/provision/roles/webdevops-apache/tasks/bootstrap.yml @@ -84,7 +84,7 @@ with_items: - 'a2dismod mpm_event' - 'a2enmod mpm_event' - when: (ansible_distribution == 'Ubuntu' and ansible_lsb.major_release|int >= 14) or (ansible_distribution == 'Debian' and ansible_lsb.major_release|int >= 8) + when: (ansible_distribution == 'Ubuntu' and docker_image_info_distribution_version|int >= 14) or (ansible_distribution == 'Debian' and docker_image_info_distribution_version|int >= 8) - name: Manage modules [Alpine family] lineinfile: diff --git a/docker/php-apache-dev/ubuntu-16.04/conf/provision/roles/webdevops-php-dev/tasks/bootstrap.yml b/docker/php-apache-dev/ubuntu-16.04/conf/provision/roles/webdevops-php-dev/tasks/bootstrap.yml index 2c5d76e3d..ff02b05fc 100644 --- a/docker/php-apache-dev/ubuntu-16.04/conf/provision/roles/webdevops-php-dev/tasks/bootstrap.yml +++ b/docker/php-apache-dev/ubuntu-16.04/conf/provision/roles/webdevops-php-dev/tasks/bootstrap.yml @@ -1,6 +1,5 @@ --- -- include: bootstrap/tools.yml - include: bootstrap/php-fpm.yml - include: bootstrap/php-module.yml - include: bootstrap/php-module.opcache.yml diff --git a/docker/php-apache-dev/ubuntu-16.04/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/php-module.blackfire.yml b/docker/php-apache-dev/ubuntu-16.04/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/php-module.blackfire.yml index 1a3db9bac..faf05f8de 100644 --- a/docker/php-apache-dev/ubuntu-16.04/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/php-module.blackfire.yml +++ b/docker/php-apache-dev/ubuntu-16.04/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/php-module.blackfire.yml @@ -7,4 +7,4 @@ with_items: - /etc/php5/cli/conf.d/zz-blackfire.ini - /etc/php5/fpm/conf.d/zz-blackfire.ini - when: ansible_distribution == 'Debian' and ansible_lsb.major_release|int >= 7 + when: ansible_distribution == 'Debian' and docker_image_info_distribution_version|int >= 7 diff --git a/docker/php-apache-dev/ubuntu-16.04/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/tools.yml b/docker/php-apache-dev/ubuntu-16.04/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/tools.yml deleted file mode 100644 index c49cb0e34..000000000 --- a/docker/php-apache-dev/ubuntu-16.04/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/tools.yml +++ /dev/null @@ -1,23 +0,0 @@ ---- - -- name: Downloading Tools - shell: curl -o "{{ item.dest }}" "{{ item.url }}" && chmod 755 "{{ item.dest }}" - with_items: - - { url: "https://phar.phpunit.de/phploc.phar", dest: /usr/local/bin/phploc } - - { url: "https://phar.phpunit.de/phpunit.phar", dest: /usr/local/bin/phpunit } - - { url: "http://static.pdepend.org/php/latest/pdepend.phar", dest: /usr/local/bin/pdepend } - - { url: "http://static.phpmd.org/php/latest/phpmd.phar", dest: /usr/local/bin/phpmd } - - { url: "https://squizlabs.github.io/PHP_CodeSniffer/phpcs.phar", dest: /usr/local/bin/phpcs } - - { url: "https://squizlabs.github.io/PHP_CodeSniffer/phpcbf.phar", dest: /usr/local/bin/phpcbf } - - { url: "https://phar.phpunit.de/phpcpd.phar", dest: /usr/local/bin/phpcpd } - - { url: "https://phar.phpunit.de/phpdcd.phar", dest: /usr/local/bin/phpdcd } - - { url: "https://github.com/Halleck45/PhpMetrics/raw/master/build/phpmetrics.phar", dest: /usr/local/bin/phpmetrics } - - { url: "http://get.sensiolabs.org/php-cs-fixer.phar", dest: /usr/local/bin/php-cs-fixer } - - { url: "https://github.com/sensiolabs-de/deprecation-detector/releases/download/0.1.0-alpha4/deprecation-detector.phar", dest: /usr/local/bin/deprecation-detector } - - { url: "https://github.com/sensiolabs-de/deprecation-detector/releases/download/0.1.0-alpha4/deprecation-detector.phar", dest: /usr/local/bin/deprecation-detector } - -- name: Install Tools via composer - raw: COMPOSER_HOME="/usr/local/composer" COMPOSER_BIN_DIR="/usr/local/bin" composer global require "{{ item.package }}" "{{ item.version }}" - with_items: - - { package: "sstalle/php7cc" , version: "*" } - - { package: "phpspec/phpspec" , version: "~2.0" } diff --git a/docker/php-apache-dev/ubuntu-16.10/Dockerfile b/docker/php-apache-dev/ubuntu-16.10/Dockerfile index 40c437508..27e65e220 100644 --- a/docker/php-apache-dev/ubuntu-16.10/Dockerfile +++ b/docker/php-apache-dev/ubuntu-16.10/Dockerfile @@ -5,16 +5,11 @@ FROM webdevops/php-dev:ubuntu-16.10 -MAINTAINER info@webdevops.io -LABEL vendor=WebDevOps.io -LABEL io.webdevops.layout=8 -LABEL io.webdevops.version=1.5.0 - -ENV WEB_DOCUMENT_ROOT /app -ENV WEB_DOCUMENT_INDEX index.php -ENV WEB_ALIAS_DOMAIN *.vm -ENV WEB_PHP_SOCKET 127.0.0.1:9000 -ENV WEB_NO_CACHE_PATTERN "\.(css|js|gif|png|jpg|svg|json|xml)$" +ENV WEB_DOCUMENT_ROOT=/app \ + WEB_DOCUMENT_INDEX=index.php \ + WEB_ALIAS_DOMAIN=*.vm +ENV WEB_PHP_SOCKET=127.0.0.1:9000 +ENV WEB_NO_CACHE_PATTERN="\.(css|js|gif|png|jpg|svg|json|xml)$" COPY conf/ /opt/docker/ @@ -29,7 +24,7 @@ RUN /usr/local/bin/apt-install \ && ln -sf /opt/docker/etc/httpd/main.conf /etc/apache2/sites-enabled/10-docker.conf \ && a2enmod actions proxy proxy_fcgi ssl rewrite headers expires \ && /opt/docker/bin/provision run --tag bootstrap --role webdevops-apache --role webdevops-php-apache --role webdevops-apache-dev --role webdevops-php-dev \ - && /opt/docker/bin/bootstrap.sh - + && /opt/docker/bin/bootstrap.sh \ + && docker-image-cleanup EXPOSE 80 443 diff --git a/docker/php-apache-dev/ubuntu-16.10/Dockerfile.jinja2 b/docker/php-apache-dev/ubuntu-16.10/Dockerfile.jinja2 index 88d0d4331..652708df4 100644 --- a/docker/php-apache-dev/ubuntu-16.10/Dockerfile.jinja2 +++ b/docker/php-apache-dev/ubuntu-16.10/Dockerfile.jinja2 @@ -1,7 +1,5 @@ {{ docker.from("php-dev", "ubuntu-16.10") }} -{{ docker.version() }} - {{ environment.web() }} {{ environment.webPhp() }} {{ environment.webDevelopment() }} diff --git a/docker/php-apache-dev/ubuntu-16.10/conf/bin/service.d/httpd.d/10-init.sh b/docker/php-apache-dev/ubuntu-16.10/conf/bin/service.d/httpd.d/10-init.sh index d3f1a0c9c..b9d57997e 100644 --- a/docker/php-apache-dev/ubuntu-16.10/conf/bin/service.d/httpd.d/10-init.sh +++ b/docker/php-apache-dev/ubuntu-16.10/conf/bin/service.d/httpd.d/10-init.sh @@ -5,15 +5,17 @@ if [[ ! -e "$WEB_DOCUMENT_ROOT" ]]; then fi # Replace markers -find /opt/docker/etc/httpd/ -iname '*.conf' -print0 | xargs -0 -r rpl --quiet "" "$WEB_DOCUMENT_INDEX" > /dev/null -find /opt/docker/etc/httpd/ -iname '*.conf' -print0 | xargs -0 -r rpl --quiet "" "$WEB_DOCUMENT_ROOT" > /dev/null -find /opt/docker/etc/httpd/ -iname '*.conf' -print0 | xargs -0 -r rpl --quiet "" "$WEB_ALIAS_DOMAIN" > /dev/null -find /opt/docker/etc/httpd/ -iname '*.conf' -print0 | xargs -0 -r rpl --quiet "" "$HOSTNAME" > /dev/null +go-replace \ + -s "" -r "$WEB_DOCUMENT_INDEX" \ + -s "" -r "$WEB_DOCUMENT_ROOT" \ + -s "" -r "$WEB_ALIAS_DOMAIN" \ + -s "" -r "$HOSTNAME" \ + -s "" -r "$WEB_PHP_SOCKET" \ + --path=/opt/docker/etc/httpd/ \ + --path-pattern='*.conf' \ + --ignore-empty -if [[ -n "${WEB_PHP_SOCKET+x}" ]]; then - ## WEB_PHP_SOCKET is set - find /opt/docker/etc/httpd/ -iname '*.conf' -print0 | xargs -0 -r rpl --quiet "" "$WEB_PHP_SOCKET" > /dev/null -else +if [[ -z "${WEB_PHP_SOCKET+x}" ]]; then ## WEB_PHP_SOCKET is not set, remove PHP files rm -f -- /opt/docker/etc/httpd/conf.d/10-php.conf fi diff --git a/docker/php-apache-dev/ubuntu-16.10/conf/bin/service.d/httpd.d/12-development.sh b/docker/php-apache-dev/ubuntu-16.10/conf/bin/service.d/httpd.d/12-development.sh index 299f67e2f..a9d2c6e92 100644 --- a/docker/php-apache-dev/ubuntu-16.10/conf/bin/service.d/httpd.d/12-development.sh +++ b/docker/php-apache-dev/ubuntu-16.10/conf/bin/service.d/httpd.d/12-development.sh @@ -1 +1,5 @@ -find /opt/docker/etc/httpd/ -iname '*.conf' -print0 | xargs -0 -r rpl --quiet "" "$WEB_NO_CACHE_PATTERN" > /dev/null +go-replace \ + -s "" -r "$WEB_NO_CACHE_PATTERN" \ + --path=/opt/docker/etc/httpd/ \ + --path-pattern='*.conf' \ + --ignore-empty diff --git a/docker/php-apache-dev/ubuntu-16.10/conf/etc/httpd/conf.d/10-log.conf b/docker/php-apache-dev/ubuntu-16.10/conf/etc/httpd/conf.d/10-log.conf index e4c4be4f2..ef0c73d38 100644 --- a/docker/php-apache-dev/ubuntu-16.10/conf/etc/httpd/conf.d/10-log.conf +++ b/docker/php-apache-dev/ubuntu-16.10/conf/etc/httpd/conf.d/10-log.conf @@ -1,4 +1,4 @@ LogFormat "[httpd:access] %V:%p %h %l %u %t \"%r\" %>s bytesIn:%I bytesOut:%O reqTime:%T" dockerlog LogLevel warn -CustomLog /proc/self/fd/1 dockerlog -ErrorLog /proc/self/fd/2 +CustomLog /docker.stdout dockerlog +ErrorLog /docker.stderr diff --git a/docker/php-apache-dev/ubuntu-16.10/conf/provision/entrypoint.d/10-php-debugger.sh b/docker/php-apache-dev/ubuntu-16.10/conf/provision/entrypoint.d/10-php-debugger.sh index 7156e28aa..b5985a9ef 100644 --- a/docker/php-apache-dev/ubuntu-16.10/conf/provision/entrypoint.d/10-php-debugger.sh +++ b/docker/php-apache-dev/ubuntu-16.10/conf/provision/entrypoint.d/10-php-debugger.sh @@ -15,7 +15,8 @@ PHP_CONF_PATHS=" /etc/php5/fpm/conf.d /etc/php/7.0/mods-available /etc/php/7.0/cli/conf.d -/etc/php/7.0/fpm/conf.d" +/etc/php/7.0/fpm/conf.d +/usr/local/etc/php/conf.d/" function phpModuleRemove() { if [ "$#" -ne 1 ]; then @@ -40,7 +41,7 @@ if [[ -n "${PHP_DEBUGGER+x}" ]]; then blackfire) echo "PHP-Debugger: Blackfire enabled" phpModuleRemove "xdebug" - /opt/docker/bin/control.sh service.enable blackfire-agent + docker-service-enable blackfire-agent ;; none) diff --git a/docker/php-apache-dev/ubuntu-16.10/conf/provision/roles/webdevops-apache/tasks/bootstrap.yml b/docker/php-apache-dev/ubuntu-16.10/conf/provision/roles/webdevops-apache/tasks/bootstrap.yml index 2be18b0e0..c285be286 100644 --- a/docker/php-apache-dev/ubuntu-16.10/conf/provision/roles/webdevops-apache/tasks/bootstrap.yml +++ b/docker/php-apache-dev/ubuntu-16.10/conf/provision/roles/webdevops-apache/tasks/bootstrap.yml @@ -84,7 +84,7 @@ with_items: - 'a2dismod mpm_event' - 'a2enmod mpm_event' - when: (ansible_distribution == 'Ubuntu' and ansible_lsb.major_release|int >= 14) or (ansible_distribution == 'Debian' and ansible_lsb.major_release|int >= 8) + when: (ansible_distribution == 'Ubuntu' and docker_image_info_distribution_version|int >= 14) or (ansible_distribution == 'Debian' and docker_image_info_distribution_version|int >= 8) - name: Manage modules [Alpine family] lineinfile: diff --git a/docker/php-apache-dev/ubuntu-16.10/conf/provision/roles/webdevops-php-dev/tasks/bootstrap.yml b/docker/php-apache-dev/ubuntu-16.10/conf/provision/roles/webdevops-php-dev/tasks/bootstrap.yml index 2c5d76e3d..ff02b05fc 100644 --- a/docker/php-apache-dev/ubuntu-16.10/conf/provision/roles/webdevops-php-dev/tasks/bootstrap.yml +++ b/docker/php-apache-dev/ubuntu-16.10/conf/provision/roles/webdevops-php-dev/tasks/bootstrap.yml @@ -1,6 +1,5 @@ --- -- include: bootstrap/tools.yml - include: bootstrap/php-fpm.yml - include: bootstrap/php-module.yml - include: bootstrap/php-module.opcache.yml diff --git a/docker/php-apache-dev/ubuntu-16.10/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/php-module.blackfire.yml b/docker/php-apache-dev/ubuntu-16.10/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/php-module.blackfire.yml index 1a3db9bac..faf05f8de 100644 --- a/docker/php-apache-dev/ubuntu-16.10/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/php-module.blackfire.yml +++ b/docker/php-apache-dev/ubuntu-16.10/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/php-module.blackfire.yml @@ -7,4 +7,4 @@ with_items: - /etc/php5/cli/conf.d/zz-blackfire.ini - /etc/php5/fpm/conf.d/zz-blackfire.ini - when: ansible_distribution == 'Debian' and ansible_lsb.major_release|int >= 7 + when: ansible_distribution == 'Debian' and docker_image_info_distribution_version|int >= 7 diff --git a/docker/php-apache-dev/ubuntu-16.10/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/tools.yml b/docker/php-apache-dev/ubuntu-16.10/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/tools.yml deleted file mode 100644 index c49cb0e34..000000000 --- a/docker/php-apache-dev/ubuntu-16.10/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/tools.yml +++ /dev/null @@ -1,23 +0,0 @@ ---- - -- name: Downloading Tools - shell: curl -o "{{ item.dest }}" "{{ item.url }}" && chmod 755 "{{ item.dest }}" - with_items: - - { url: "https://phar.phpunit.de/phploc.phar", dest: /usr/local/bin/phploc } - - { url: "https://phar.phpunit.de/phpunit.phar", dest: /usr/local/bin/phpunit } - - { url: "http://static.pdepend.org/php/latest/pdepend.phar", dest: /usr/local/bin/pdepend } - - { url: "http://static.phpmd.org/php/latest/phpmd.phar", dest: /usr/local/bin/phpmd } - - { url: "https://squizlabs.github.io/PHP_CodeSniffer/phpcs.phar", dest: /usr/local/bin/phpcs } - - { url: "https://squizlabs.github.io/PHP_CodeSniffer/phpcbf.phar", dest: /usr/local/bin/phpcbf } - - { url: "https://phar.phpunit.de/phpcpd.phar", dest: /usr/local/bin/phpcpd } - - { url: "https://phar.phpunit.de/phpdcd.phar", dest: /usr/local/bin/phpdcd } - - { url: "https://github.com/Halleck45/PhpMetrics/raw/master/build/phpmetrics.phar", dest: /usr/local/bin/phpmetrics } - - { url: "http://get.sensiolabs.org/php-cs-fixer.phar", dest: /usr/local/bin/php-cs-fixer } - - { url: "https://github.com/sensiolabs-de/deprecation-detector/releases/download/0.1.0-alpha4/deprecation-detector.phar", dest: /usr/local/bin/deprecation-detector } - - { url: "https://github.com/sensiolabs-de/deprecation-detector/releases/download/0.1.0-alpha4/deprecation-detector.phar", dest: /usr/local/bin/deprecation-detector } - -- name: Install Tools via composer - raw: COMPOSER_HOME="/usr/local/composer" COMPOSER_BIN_DIR="/usr/local/bin" composer global require "{{ item.package }}" "{{ item.version }}" - with_items: - - { package: "sstalle/php7cc" , version: "*" } - - { package: "phpspec/phpspec" , version: "~2.0" } diff --git a/docker/php-apache/5.6/Dockerfile b/docker/php-apache/5.6/Dockerfile new file mode 100644 index 000000000..2e5dcff58 --- /dev/null +++ b/docker/php-apache/5.6/Dockerfile @@ -0,0 +1,29 @@ +#+++++++++++++++++++++++++++++++++++++++ +# Dockerfile for webdevops/php-apache:5.6 +# -- automatically generated -- +#+++++++++++++++++++++++++++++++++++++++ + +FROM webdevops/php:5.6 + +ENV WEB_DOCUMENT_ROOT=/app \ + WEB_DOCUMENT_INDEX=index.php \ + WEB_ALIAS_DOMAIN=*.vm +ENV WEB_PHP_SOCKET=127.0.0.1:9000 + +COPY conf/ /opt/docker/ + +# Install apache +RUN /usr/local/bin/apt-install \ + apache2 \ + apache2-mpm-worker \ + && sed -ri ' \ + s!^(\s*CustomLog)\s+\S+!\1 /proc/self/fd/1!g; \ + s!^(\s*ErrorLog)\s+\S+!\1 /proc/self/fd/2!g; \ + ' /etc/apache2/apache2.conf \ + && rm -f /etc/apache2/sites-enabled/* \ + && a2enmod actions proxy proxy_fcgi ssl rewrite headers expires \ + && /opt/docker/bin/provision run --tag bootstrap --role webdevops-apache --role webdevops-php-apache \ + && /opt/docker/bin/bootstrap.sh \ + && docker-image-cleanup + +EXPOSE 80 443 diff --git a/docker/php-apache/5.6/Dockerfile.jinja2 b/docker/php-apache/5.6/Dockerfile.jinja2 new file mode 100644 index 000000000..6d352967e --- /dev/null +++ b/docker/php-apache/5.6/Dockerfile.jinja2 @@ -0,0 +1,10 @@ +{{ docker.from("php", "5.6") }} + +{{ environment.web() }} +{{ environment.webPhp() }} + +{{ docker.copy('conf/', '/opt/docker/') }} + +{{ apache.debian8('php-apache') }} + +{{ docker.expose('80 443') }} diff --git a/docker/php-apache/5.6/conf/bin/service.d/httpd.d/10-init.sh b/docker/php-apache/5.6/conf/bin/service.d/httpd.d/10-init.sh new file mode 100644 index 000000000..b9d57997e --- /dev/null +++ b/docker/php-apache/5.6/conf/bin/service.d/httpd.d/10-init.sh @@ -0,0 +1,21 @@ +if [[ ! -e "$WEB_DOCUMENT_ROOT" ]]; then + echo "" + echo "[WARNING] WEB_DOCUMENT_ROOT does not exists with path \"$WEB_DOCUMENT_ROOT\"!" + echo "" +fi + +# Replace markers +go-replace \ + -s "" -r "$WEB_DOCUMENT_INDEX" \ + -s "" -r "$WEB_DOCUMENT_ROOT" \ + -s "" -r "$WEB_ALIAS_DOMAIN" \ + -s "" -r "$HOSTNAME" \ + -s "" -r "$WEB_PHP_SOCKET" \ + --path=/opt/docker/etc/httpd/ \ + --path-pattern='*.conf' \ + --ignore-empty + +if [[ -z "${WEB_PHP_SOCKET+x}" ]]; then + ## WEB_PHP_SOCKET is not set, remove PHP files + rm -f -- /opt/docker/etc/httpd/conf.d/10-php.conf +fi diff --git a/docker/php-apache/5.6/conf/bin/service.d/httpd.sh b/docker/php-apache/5.6/conf/bin/service.d/httpd.sh new file mode 100644 index 000000000..03eec305a --- /dev/null +++ b/docker/php-apache/5.6/conf/bin/service.d/httpd.sh @@ -0,0 +1,12 @@ +#!/usr/bin/env bash +set -e + +source /opt/docker/bin/config.sh + +includeScriptDir "/opt/docker/bin/service.d/httpd.d/" + +# Apache gets grumpy about PID files pre-existing +rm -f /var/run/apache2/apache2*.pid + +source /etc/apache2/envvars +exec apache2 -DFOREGROUND -DAPACHE_LOCK_DIR diff --git a/docker/php-apache/5.6/conf/etc/httpd/conf.d/.gitkeep b/docker/php-apache/5.6/conf/etc/httpd/conf.d/.gitkeep new file mode 100644 index 000000000..e69de29bb diff --git a/docker/php-apache/5.6/conf/etc/httpd/conf.d/10-error-document.conf b/docker/php-apache/5.6/conf/etc/httpd/conf.d/10-error-document.conf new file mode 100644 index 000000000..ebabf87e4 --- /dev/null +++ b/docker/php-apache/5.6/conf/etc/httpd/conf.d/10-error-document.conf @@ -0,0 +1,15 @@ +####################################### +# Faster error documents +####################################### + + ErrorDocument 400 "400 Bad Request" + ErrorDocument 401 "401 Unauthorized" + ErrorDocument 403 "403 Forbidden" + ErrorDocument 404 "404 Not Found" + ErrorDocument 405 "405 Method Not Allowed" + + ErrorDocument 500 "500 Internal Server Error" + ErrorDocument 501 "501 Not Implemented" + ErrorDocument 502 "502 Bad Gateway" + ErrorDocument 503 "503 Service Unavailable" + diff --git a/docker/php-apache/5.6/conf/etc/httpd/conf.d/10-log.conf b/docker/php-apache/5.6/conf/etc/httpd/conf.d/10-log.conf new file mode 100644 index 000000000..ef0c73d38 --- /dev/null +++ b/docker/php-apache/5.6/conf/etc/httpd/conf.d/10-log.conf @@ -0,0 +1,4 @@ +LogFormat "[httpd:access] %V:%p %h %l %u %t \"%r\" %>s bytesIn:%I bytesOut:%O reqTime:%T" dockerlog +LogLevel warn +CustomLog /docker.stdout dockerlog +ErrorLog /docker.stderr diff --git a/docker/php-apache/5.6/conf/etc/httpd/conf.d/10-php.conf b/docker/php-apache/5.6/conf/etc/httpd/conf.d/10-php.conf new file mode 100644 index 000000000..4368d12ef --- /dev/null +++ b/docker/php-apache/5.6/conf/etc/httpd/conf.d/10-php.conf @@ -0,0 +1,37 @@ +############################# +# mod_proxy_fcgi +# official solution +# apache 2.4 and later +############################# + + + > + ProxySet connectiontimeout=5 timeout=600 + + + + SetHandler "proxy:fcgi://" + + + +############################# +# mod_fastcgi +# apaache 2.2 and 2.4 +############################# + + + AddHandler php-fcgi .php + Action php-fcgi /php-fcgi + Alias /php-fcgi /usr/lib/cgi-bin/php-fcgi + FastCgiExternalServer /usr/lib/cgi-bin/php-fcgi -host "" -pass-header Authorization -idle-timeout 600 + + + + Allow from all + + = 2.4> + Require all granted + + + + diff --git a/docker/php-apache/5.6/conf/etc/httpd/conf.d/10-server.conf b/docker/php-apache/5.6/conf/etc/httpd/conf.d/10-server.conf new file mode 100644 index 000000000..d3a5defbd --- /dev/null +++ b/docker/php-apache/5.6/conf/etc/httpd/conf.d/10-server.conf @@ -0,0 +1,18 @@ +# Settings +TimeOut 1000 +ServerName "" + +DirectoryIndex +DocumentRoot "" + +"> + Options Indexes FollowSymLinks + AllowOverride All + + + Allow from all + + = 2.4> + Require all granted + + diff --git a/docker/php-nginx-dev/alpine-3/conf/etc/nginx/global.conf b/docker/php-apache/5.6/conf/etc/httpd/global.conf similarity index 100% rename from docker/php-nginx-dev/alpine-3/conf/etc/nginx/global.conf rename to docker/php-apache/5.6/conf/etc/httpd/global.conf diff --git a/docker/php-apache/5.6/conf/etc/httpd/main.conf b/docker/php-apache/5.6/conf/etc/httpd/main.conf new file mode 100644 index 000000000..12251c222 --- /dev/null +++ b/docker/php-apache/5.6/conf/etc/httpd/main.conf @@ -0,0 +1,12 @@ +Include /opt/docker/etc/httpd/global.conf +Include /opt/docker/etc/httpd/php.conf + + + Include /opt/docker/etc/httpd/conf.d/*.conf + += 2.4> + IncludeOptional /opt/docker/etc/httpd/conf.d/*.conf + +Include /opt/docker/etc/httpd/vhost.conf + + diff --git a/docker/php-nginx-dev/alpine-3/conf/etc/nginx/php.conf b/docker/php-apache/5.6/conf/etc/httpd/php.conf similarity index 100% rename from docker/php-nginx-dev/alpine-3/conf/etc/nginx/php.conf rename to docker/php-apache/5.6/conf/etc/httpd/php.conf diff --git a/docker/php-nginx-dev/alpine-3/conf/etc/nginx/ssl/server.crt b/docker/php-apache/5.6/conf/etc/httpd/ssl/server.crt similarity index 100% rename from docker/php-nginx-dev/alpine-3/conf/etc/nginx/ssl/server.crt rename to docker/php-apache/5.6/conf/etc/httpd/ssl/server.crt diff --git a/docker/php-nginx-dev/alpine-3/conf/etc/nginx/ssl/server.csr b/docker/php-apache/5.6/conf/etc/httpd/ssl/server.csr similarity index 100% rename from docker/php-nginx-dev/alpine-3/conf/etc/nginx/ssl/server.csr rename to docker/php-apache/5.6/conf/etc/httpd/ssl/server.csr diff --git a/docker/php-nginx-dev/alpine-3/conf/etc/nginx/ssl/server.key b/docker/php-apache/5.6/conf/etc/httpd/ssl/server.key similarity index 100% rename from docker/php-nginx-dev/alpine-3/conf/etc/nginx/ssl/server.key rename to docker/php-apache/5.6/conf/etc/httpd/ssl/server.key diff --git a/docker/php-apache/5.6/conf/etc/httpd/vhost.common.conf b/docker/php-apache/5.6/conf/etc/httpd/vhost.common.conf new file mode 100644 index 000000000..384696b4e --- /dev/null +++ b/docker/php-apache/5.6/conf/etc/httpd/vhost.common.conf @@ -0,0 +1,7 @@ +# compatibility for PHP and TYPO3 Docker Boilerplate + + Include /opt/docker/etc/httpd/vhost.common.d/*.conf + + = 2.4> + IncludeOptional /opt/docker/etc/httpd/vhost.common.d/*.conf + diff --git a/docker/php-apache/5.6/conf/etc/httpd/vhost.common.d/.gitkeep b/docker/php-apache/5.6/conf/etc/httpd/vhost.common.d/.gitkeep new file mode 100644 index 000000000..e69de29bb diff --git a/docker/php-nginx-dev/alpine-3/conf/bin/service.d/blackfire-agent.d/10-init.sh b/docker/php-apache/5.6/conf/etc/httpd/vhost.common.d/01-boilerplate.conf similarity index 100% rename from docker/php-nginx-dev/alpine-3/conf/bin/service.d/blackfire-agent.d/10-init.sh rename to docker/php-apache/5.6/conf/etc/httpd/vhost.common.d/01-boilerplate.conf diff --git a/docker/php-apache/5.6/conf/etc/httpd/vhost.conf b/docker/php-apache/5.6/conf/etc/httpd/vhost.conf new file mode 100644 index 000000000..c04a94318 --- /dev/null +++ b/docker/php-apache/5.6/conf/etc/httpd/vhost.conf @@ -0,0 +1,36 @@ +####################################### +# Vhost +####################################### + + + ServerName docker.vm + ServerAlias + DocumentRoot "" + + UseCanonicalName Off + + + Include /opt/docker/etc/httpd/vhost.common.d/*.conf + + = 2.4> + IncludeOptional /opt/docker/etc/httpd/vhost.common.d/*.conf + + + + + + ServerName docker.vm + ServerAlias + DocumentRoot "" + + UseCanonicalName Off + + + Include /opt/docker/etc/httpd/vhost.common.d/*.conf + + = 2.4> + IncludeOptional /opt/docker/etc/httpd/vhost.common.d/*.conf + + + Include /opt/docker/etc/httpd/vhost.ssl.conf + diff --git a/docker/php-apache/5.6/conf/etc/httpd/vhost.ssl.conf b/docker/php-apache/5.6/conf/etc/httpd/vhost.ssl.conf new file mode 100644 index 000000000..cf5fbc604 --- /dev/null +++ b/docker/php-apache/5.6/conf/etc/httpd/vhost.ssl.conf @@ -0,0 +1,26 @@ + ############ + # SSL + ############ + + SSLEngine on + SSLCertificateFile /opt/docker/etc/httpd/ssl/server.crt + SSLCertificateKeyFile /opt/docker/etc/httpd/ssl/server.key + + + SSLOptions +StdEnvVars + + + SSLOptions +StdEnvVars + + + BrowserMatch "MSIE [2-6]" \ + nokeepalive ssl-unclean-shutdown \ + downgrade-1.0 force-response-1.0 + # MSIE 7 and newer should be able to use keepalive + # This regexp is ok with 17-9! + BrowserMatch "MSIE [17-9]" ssl-unclean-shutdown + + ## SSL Hardening + SSLProtocol All -SSLv2 -SSLv3 + SSLHonorCipherOrder on + SSLCipherSuite 'EDH+CAMELLIA:EDH+aRSA:EECDH+aRSA+AESGCM:EECDH+aRSA+SHA384:EECDH+aRSA+SHA256:EECDH:+CAMELLIA256:+AES256:+CAMELLIA128:+AES128:+SSLv3:!aNULL:!eNULL:!LOW:!3DES:!MD5:!EXP:!PSK:!DSS:!RC4:!SEED:!ECDSA:CAMELLIA256-SHA:AES256-SHA:CAMELLIA128-SHA:AES128-SHA' diff --git a/docker/php-apache/5.6/conf/etc/supervisor.d/apache.conf b/docker/php-apache/5.6/conf/etc/supervisor.d/apache.conf new file mode 100644 index 000000000..12a6f86f7 --- /dev/null +++ b/docker/php-apache/5.6/conf/etc/supervisor.d/apache.conf @@ -0,0 +1,14 @@ +[group:apache] +programs=apached +priority=20 + +[program:apached] +command = /opt/docker/bin/service.d/httpd.sh +process_name=%(program_name)s +startsecs = 0 +autostart = true +autorestart = true +stdout_logfile=/dev/stdout +stdout_logfile_maxbytes=0 +stderr_logfile=/dev/stderr +stderr_logfile_maxbytes=0 diff --git a/docker/php-nginx-dev/alpine-3/conf/provision/roles/webdevops-nginx/defaults/main.yml b/docker/php-apache/5.6/conf/provision/roles/webdevops-apache/defaults/main.yml similarity index 100% rename from docker/php-nginx-dev/alpine-3/conf/provision/roles/webdevops-nginx/defaults/main.yml rename to docker/php-apache/5.6/conf/provision/roles/webdevops-apache/defaults/main.yml diff --git a/docker/php-apache/5.6/conf/provision/roles/webdevops-apache/tasks/bootstrap.yml b/docker/php-apache/5.6/conf/provision/roles/webdevops-apache/tasks/bootstrap.yml new file mode 100644 index 000000000..c285be286 --- /dev/null +++ b/docker/php-apache/5.6/conf/provision/roles/webdevops-apache/tasks/bootstrap.yml @@ -0,0 +1,156 @@ +--- + +- name: Set apache vhost file [RedHat family] + set_fact: + apache_main_path: /etc/httpd/ + apache_docker_vhost: /etc/httpd/conf.d/zzz-docker.conf + when: ansible_os_family == 'RedHat' + +- name: Set apache vhost file [Debian family] + set_fact: + apache_main_path: /etc/apache2/ + apache_docker_vhost: /etc/apache2/sites-enabled/10-docker.conf + when: ansible_os_family == 'Debian' + +- name: Set apache vhost file [Alpine family] + set_fact: + apache_main_path: /etc/apache2/ + apache_docker_vhost: /etc/apache2/conf.d/zzz-docker.conf + when: ansible_os_family == 'Alpine' + +- name: Enable apache main config + file: + src: '/opt/docker/etc/httpd/main.conf' + dest: '{{ apache_docker_vhost }}' + state: link + force: yes + +- name: Ensure document root is available + file: + path: "{{ DOCUMENT_ROOT }}" + state: directory + recurse: yes + +- name: Ensure /var/run/apache2 exists + file: + path: '/var/run/apache2' + state: directory + recurse: yes + +- name: Ensure /run/apache2 exists + file: + path: '/run/apache2' + state: directory + recurse: yes + when: ansible_os_family == 'Alpine' + +- name: Find apache2 files + shell: "find '{{ apache_main_path }}' -type f -iname '*.conf' -o -iname 'default*' -o -iname '*log'" + register: apache2_conf_files + +- name: Change CustomLog to Docker stdout + replace: + dest: '{{ item }}' + regexp: '^[\s]*CustomLog ([^\s]+)(.*)' + replace: 'CustomLog /docker.stdout \2' + with_items: "{{ apache2_conf_files.stdout_lines }}" + +- name: Change CustomLog to Docker stdout + replace: + dest: '{{ item }}' + regexp: '^[\s]*ErrorLog ([^\s]+)(.*)' + replace: 'ErrorLog /docker.stdout \2' + with_items: "{{ apache2_conf_files.stdout_lines }}" + +- name: Change TransferLog to Docker stdout + replace: + dest: '{{ item }}' + regexp: '^[\s]*TransferLog ([^\s]+)(.*)' + replace: 'TransferLog /docker.stdout \2' + with_items: "{{ apache2_conf_files.stdout_lines }}" + +- name: Switch MPM to worker [RedHat family] + lineinfile: + dest: '/etc/httpd/conf.modules.d/00-mpm.conf' + regexp: '^[\s#]*{{ item.line }}' + line: '{{ item.prefix }}{{ item.line }}' + with_items: + - { line: 'LoadModule mpm_prefork_module modules/mod_mpm_prefork.so', prefix: "#" } + - { line: 'LoadModule mpm_event_module modules/mod_mpm_event.so', prefix: "" } + when: ansible_os_family == 'RedHat' + +- name: Switch MPM to event for Apache 2.4 and higher [Ubuntu family] + command: "{{ item }}" + with_items: + - 'a2dismod mpm_event' + - 'a2enmod mpm_event' + when: (ansible_distribution == 'Ubuntu' and docker_image_info_distribution_version|int >= 14) or (ansible_distribution == 'Debian' and docker_image_info_distribution_version|int >= 8) + +- name: Manage modules [Alpine family] + lineinfile: + dest: '/etc/apache2/httpd.conf' + regexp: '^[\s#]*{{ item.line }}' + line: '{{ item.prefix }}{{ item.line }}' + with_items: + - { line: 'LoadModule mpm_prefork_module modules/mod_mpm_prefork.so', prefix: "#" } + - { line: 'LoadModule mpm_event_module modules/mod_mpm_event.so', prefix: "" } + - { line: 'LoadModule deflate_module modules/mod_deflate.so', prefix: "" } + - { line: 'LoadModule rewrite_module modules/mod_rewrite.so', prefix: "" } + - { line: 'LoadModule logio_module modules/mod_logio.so', prefix: "" } + - { line: 'LoadModule slotmem_shm_module modules/mod_slotmem_shm.so', prefix: "" } + - { line: 'LoadModule actions_module modules/mod_actions.so', prefix: "" } + - { line: 'LoadModule expires_module modules/mod_expires.so', prefix: "" } + when: ansible_os_family == 'Alpine' + +- name: Fix ssl support [Alpine family] + lineinfile: + dest: '/etc/apache2/conf.d/ssl.conf' + regexp: '{{ item.regexp }}' + line: '{{ item.line }}' + with_items: + - { regexp: 'LoadModule ssl_module', line: 'LoadModule ssl_module /usr/lib/apache2/mod_ssl.so' } + - { regexp: 'LoadModule socache_shmcb_module', line: 'LoadModule socache_shmcb_module /usr/lib/apache2/mod_socache_shmcb.so' } + when: ansible_os_family == 'Alpine' + +- name: Remove default vhost from ssl configuration [Alpine family] + command: sed -i -e '1h;2,$H;$!d;g' -e 's//#-> removed vhost/g' /etc/apache2/conf.d/ssl.conf + when: ansible_os_family == 'Alpine' + +- name: Disable proxy [Alpine family] + lineinfile: + dest: '/etc/apache2/conf.d/proxy.conf' + regexp: '^[\s#]*{{ item.line }}' + line: '{{ item.prefix }}{{ item.line }}' + with_items: + - { line: 'LoadModule proxy_ajp_module modules/mod_proxy_ajp.so', prefix: "#" } + - { line: 'LoadModule proxy_connect_module modules/mod_proxy_connect.so', prefix: "#" } + - { line: 'LoadModule proxy_balancer_module modules/mod_proxy_balancer.so', prefix: "#" } + - { line: 'LoadModule proxy_express_module modules/mod_proxy_express.so', prefix: "#" } + - { line: 'LoadModule proxy_fcgi_module modules/mod_proxy_fcgi.so', prefix: "" } + - { line: 'LoadModule proxy_fdpass_module modules/mod_proxy_fdpass.so', prefix: "#" } + - { line: 'LoadModule proxy_ftp_module modules/mod_proxy_ftp.so', prefix: "#" } + - { line: 'LoadModule proxy_http_module modules/mod_proxy_http.so', prefix: "#" } + - { line: 'LoadModule proxy_scgi_module modules/mod_proxy_scgi.so', prefix: "#" } + when: ansible_os_family == 'Alpine' + +- name: Fix rights of ssl files + file: + path: "{{ item.path }}" + state: "{{ item.state }}" + mode: "{{ item.mode }}" + owner: "root" + group: "root" + with_items: + - { path: '/opt/docker/etc/httpd/ssl', state: 'directory', mode: '0750' } + - { path: '/opt/docker/etc/httpd/ssl/server.crt', state: 'file', mode: '0640' } + - { path: '/opt/docker/etc/httpd/ssl/server.csr', state: 'file', mode: '0640' } + - { path: '/opt/docker/etc/httpd/ssl/server.key', state: 'file', mode: '0640' } + +- name: Maintain lock directory [Debian family] + file: + path: "/var/lock/apache2" + state: "directory" + mode: "0750" + owner: "www-data" + group: "www-data" + when: ansible_os_family == 'Debian' diff --git a/docker/php-nginx-dev/alpine-3-php7/conf/provision/roles/webdevops-php-dev/tasks/main.yml b/docker/php-apache/5.6/conf/provision/roles/webdevops-apache/tasks/main.yml similarity index 100% rename from docker/php-nginx-dev/alpine-3-php7/conf/provision/roles/webdevops-php-dev/tasks/main.yml rename to docker/php-apache/5.6/conf/provision/roles/webdevops-apache/tasks/main.yml diff --git a/docker/php-nginx-dev/alpine-3/conf/provision/roles/webdevops-php-nginx/defaults/main.yml b/docker/php-apache/5.6/conf/provision/roles/webdevops-php-apache/defaults/main.yml similarity index 100% rename from docker/php-nginx-dev/alpine-3/conf/provision/roles/webdevops-php-nginx/defaults/main.yml rename to docker/php-apache/5.6/conf/provision/roles/webdevops-php-apache/defaults/main.yml diff --git a/docker/php-apache/5.6/conf/provision/roles/webdevops-php-apache/tasks/bootstrap.yml b/docker/php-apache/5.6/conf/provision/roles/webdevops-php-apache/tasks/bootstrap.yml new file mode 100644 index 000000000..ad5fb2121 --- /dev/null +++ b/docker/php-apache/5.6/conf/provision/roles/webdevops-php-apache/tasks/bootstrap.yml @@ -0,0 +1,8 @@ +--- +- name: Restrict php-fpm to local connection + lineinfile: + dest: '/opt/docker/etc/php/fpm/pool.d/application.conf' + regexp: '^[\s;]*{{ item.key }}[\s]*=' + line: '{{ item.key }} = {{ item.value }}' + with_items: + - { key: 'listen', value: "127.0.0.1:9000" } diff --git a/docker/php-apache/5.6/conf/provision/roles/webdevops-php-apache/tasks/entrypoint.yml b/docker/php-apache/5.6/conf/provision/roles/webdevops-php-apache/tasks/entrypoint.yml new file mode 100644 index 000000000..cd21505a4 --- /dev/null +++ b/docker/php-apache/5.6/conf/provision/roles/webdevops-php-apache/tasks/entrypoint.yml @@ -0,0 +1,2 @@ +--- + diff --git a/docker/php-nginx-dev/alpine-3/conf/provision/roles/webdevops-php-nginx/tasks/main.yml b/docker/php-apache/5.6/conf/provision/roles/webdevops-php-apache/tasks/main.yml similarity index 100% rename from docker/php-nginx-dev/alpine-3/conf/provision/roles/webdevops-php-nginx/tasks/main.yml rename to docker/php-apache/5.6/conf/provision/roles/webdevops-php-apache/tasks/main.yml diff --git a/docker/php-apache/7.0/Dockerfile b/docker/php-apache/7.0/Dockerfile new file mode 100644 index 000000000..a39c8bd81 --- /dev/null +++ b/docker/php-apache/7.0/Dockerfile @@ -0,0 +1,29 @@ +#+++++++++++++++++++++++++++++++++++++++ +# Dockerfile for webdevops/php-apache:7.0 +# -- automatically generated -- +#+++++++++++++++++++++++++++++++++++++++ + +FROM webdevops/php:7.0 + +ENV WEB_DOCUMENT_ROOT=/app \ + WEB_DOCUMENT_INDEX=index.php \ + WEB_ALIAS_DOMAIN=*.vm +ENV WEB_PHP_SOCKET=127.0.0.1:9000 + +COPY conf/ /opt/docker/ + +# Install apache +RUN /usr/local/bin/apt-install \ + apache2 \ + apache2-mpm-worker \ + && sed -ri ' \ + s!^(\s*CustomLog)\s+\S+!\1 /proc/self/fd/1!g; \ + s!^(\s*ErrorLog)\s+\S+!\1 /proc/self/fd/2!g; \ + ' /etc/apache2/apache2.conf \ + && rm -f /etc/apache2/sites-enabled/* \ + && a2enmod actions proxy proxy_fcgi ssl rewrite headers expires \ + && /opt/docker/bin/provision run --tag bootstrap --role webdevops-apache --role webdevops-php-apache \ + && /opt/docker/bin/bootstrap.sh \ + && docker-image-cleanup + +EXPOSE 80 443 diff --git a/docker/php-apache/7.0/Dockerfile.jinja2 b/docker/php-apache/7.0/Dockerfile.jinja2 new file mode 100644 index 000000000..1b758cde3 --- /dev/null +++ b/docker/php-apache/7.0/Dockerfile.jinja2 @@ -0,0 +1,10 @@ +{{ docker.from("php", "7.0") }} + +{{ environment.web() }} +{{ environment.webPhp() }} + +{{ docker.copy('conf/', '/opt/docker/') }} + +{{ apache.debian8('php-apache') }} + +{{ docker.expose('80 443') }} diff --git a/docker/php-apache/7.0/conf/bin/service.d/httpd.d/10-init.sh b/docker/php-apache/7.0/conf/bin/service.d/httpd.d/10-init.sh new file mode 100644 index 000000000..b9d57997e --- /dev/null +++ b/docker/php-apache/7.0/conf/bin/service.d/httpd.d/10-init.sh @@ -0,0 +1,21 @@ +if [[ ! -e "$WEB_DOCUMENT_ROOT" ]]; then + echo "" + echo "[WARNING] WEB_DOCUMENT_ROOT does not exists with path \"$WEB_DOCUMENT_ROOT\"!" + echo "" +fi + +# Replace markers +go-replace \ + -s "" -r "$WEB_DOCUMENT_INDEX" \ + -s "" -r "$WEB_DOCUMENT_ROOT" \ + -s "" -r "$WEB_ALIAS_DOMAIN" \ + -s "" -r "$HOSTNAME" \ + -s "" -r "$WEB_PHP_SOCKET" \ + --path=/opt/docker/etc/httpd/ \ + --path-pattern='*.conf' \ + --ignore-empty + +if [[ -z "${WEB_PHP_SOCKET+x}" ]]; then + ## WEB_PHP_SOCKET is not set, remove PHP files + rm -f -- /opt/docker/etc/httpd/conf.d/10-php.conf +fi diff --git a/docker/php-apache/7.0/conf/bin/service.d/httpd.sh b/docker/php-apache/7.0/conf/bin/service.d/httpd.sh new file mode 100644 index 000000000..03eec305a --- /dev/null +++ b/docker/php-apache/7.0/conf/bin/service.d/httpd.sh @@ -0,0 +1,12 @@ +#!/usr/bin/env bash +set -e + +source /opt/docker/bin/config.sh + +includeScriptDir "/opt/docker/bin/service.d/httpd.d/" + +# Apache gets grumpy about PID files pre-existing +rm -f /var/run/apache2/apache2*.pid + +source /etc/apache2/envvars +exec apache2 -DFOREGROUND -DAPACHE_LOCK_DIR diff --git a/docker/php-apache/7.0/conf/etc/httpd/conf.d/.gitkeep b/docker/php-apache/7.0/conf/etc/httpd/conf.d/.gitkeep new file mode 100644 index 000000000..e69de29bb diff --git a/docker/php-apache/7.0/conf/etc/httpd/conf.d/10-error-document.conf b/docker/php-apache/7.0/conf/etc/httpd/conf.d/10-error-document.conf new file mode 100644 index 000000000..ebabf87e4 --- /dev/null +++ b/docker/php-apache/7.0/conf/etc/httpd/conf.d/10-error-document.conf @@ -0,0 +1,15 @@ +####################################### +# Faster error documents +####################################### + + ErrorDocument 400 "400 Bad Request" + ErrorDocument 401 "401 Unauthorized" + ErrorDocument 403 "403 Forbidden" + ErrorDocument 404 "404 Not Found" + ErrorDocument 405 "405 Method Not Allowed" + + ErrorDocument 500 "500 Internal Server Error" + ErrorDocument 501 "501 Not Implemented" + ErrorDocument 502 "502 Bad Gateway" + ErrorDocument 503 "503 Service Unavailable" + diff --git a/docker/php-apache/7.0/conf/etc/httpd/conf.d/10-log.conf b/docker/php-apache/7.0/conf/etc/httpd/conf.d/10-log.conf new file mode 100644 index 000000000..ef0c73d38 --- /dev/null +++ b/docker/php-apache/7.0/conf/etc/httpd/conf.d/10-log.conf @@ -0,0 +1,4 @@ +LogFormat "[httpd:access] %V:%p %h %l %u %t \"%r\" %>s bytesIn:%I bytesOut:%O reqTime:%T" dockerlog +LogLevel warn +CustomLog /docker.stdout dockerlog +ErrorLog /docker.stderr diff --git a/docker/php-apache/7.0/conf/etc/httpd/conf.d/10-php.conf b/docker/php-apache/7.0/conf/etc/httpd/conf.d/10-php.conf new file mode 100644 index 000000000..4368d12ef --- /dev/null +++ b/docker/php-apache/7.0/conf/etc/httpd/conf.d/10-php.conf @@ -0,0 +1,37 @@ +############################# +# mod_proxy_fcgi +# official solution +# apache 2.4 and later +############################# + + + > + ProxySet connectiontimeout=5 timeout=600 + + + + SetHandler "proxy:fcgi://" + + + +############################# +# mod_fastcgi +# apaache 2.2 and 2.4 +############################# + + + AddHandler php-fcgi .php + Action php-fcgi /php-fcgi + Alias /php-fcgi /usr/lib/cgi-bin/php-fcgi + FastCgiExternalServer /usr/lib/cgi-bin/php-fcgi -host "" -pass-header Authorization -idle-timeout 600 + + + + Allow from all + + = 2.4> + Require all granted + + + + diff --git a/docker/php-apache/7.0/conf/etc/httpd/conf.d/10-server.conf b/docker/php-apache/7.0/conf/etc/httpd/conf.d/10-server.conf new file mode 100644 index 000000000..d3a5defbd --- /dev/null +++ b/docker/php-apache/7.0/conf/etc/httpd/conf.d/10-server.conf @@ -0,0 +1,18 @@ +# Settings +TimeOut 1000 +ServerName "" + +DirectoryIndex +DocumentRoot "" + +"> + Options Indexes FollowSymLinks + AllowOverride All + + + Allow from all + + = 2.4> + Require all granted + + diff --git a/docker/php-nginx/alpine-3-php7/conf/etc/nginx/global.conf b/docker/php-apache/7.0/conf/etc/httpd/global.conf similarity index 100% rename from docker/php-nginx/alpine-3-php7/conf/etc/nginx/global.conf rename to docker/php-apache/7.0/conf/etc/httpd/global.conf diff --git a/docker/php-apache/7.0/conf/etc/httpd/main.conf b/docker/php-apache/7.0/conf/etc/httpd/main.conf new file mode 100644 index 000000000..12251c222 --- /dev/null +++ b/docker/php-apache/7.0/conf/etc/httpd/main.conf @@ -0,0 +1,12 @@ +Include /opt/docker/etc/httpd/global.conf +Include /opt/docker/etc/httpd/php.conf + + + Include /opt/docker/etc/httpd/conf.d/*.conf + += 2.4> + IncludeOptional /opt/docker/etc/httpd/conf.d/*.conf + +Include /opt/docker/etc/httpd/vhost.conf + + diff --git a/docker/php-nginx/alpine-3-php7/conf/etc/nginx/php.conf b/docker/php-apache/7.0/conf/etc/httpd/php.conf similarity index 100% rename from docker/php-nginx/alpine-3-php7/conf/etc/nginx/php.conf rename to docker/php-apache/7.0/conf/etc/httpd/php.conf diff --git a/docker/php-nginx/alpine-3-php7/conf/etc/nginx/ssl/server.crt b/docker/php-apache/7.0/conf/etc/httpd/ssl/server.crt similarity index 100% rename from docker/php-nginx/alpine-3-php7/conf/etc/nginx/ssl/server.crt rename to docker/php-apache/7.0/conf/etc/httpd/ssl/server.crt diff --git a/docker/php-nginx/alpine-3-php7/conf/etc/nginx/ssl/server.csr b/docker/php-apache/7.0/conf/etc/httpd/ssl/server.csr similarity index 100% rename from docker/php-nginx/alpine-3-php7/conf/etc/nginx/ssl/server.csr rename to docker/php-apache/7.0/conf/etc/httpd/ssl/server.csr diff --git a/docker/php-nginx/alpine-3-php7/conf/etc/nginx/ssl/server.key b/docker/php-apache/7.0/conf/etc/httpd/ssl/server.key similarity index 100% rename from docker/php-nginx/alpine-3-php7/conf/etc/nginx/ssl/server.key rename to docker/php-apache/7.0/conf/etc/httpd/ssl/server.key diff --git a/docker/php-apache/7.0/conf/etc/httpd/vhost.common.conf b/docker/php-apache/7.0/conf/etc/httpd/vhost.common.conf new file mode 100644 index 000000000..384696b4e --- /dev/null +++ b/docker/php-apache/7.0/conf/etc/httpd/vhost.common.conf @@ -0,0 +1,7 @@ +# compatibility for PHP and TYPO3 Docker Boilerplate + + Include /opt/docker/etc/httpd/vhost.common.d/*.conf + + = 2.4> + IncludeOptional /opt/docker/etc/httpd/vhost.common.d/*.conf + diff --git a/docker/php-apache/7.0/conf/etc/httpd/vhost.common.d/.gitkeep b/docker/php-apache/7.0/conf/etc/httpd/vhost.common.d/.gitkeep new file mode 100644 index 000000000..e69de29bb diff --git a/docker/php-nginx-dev/alpine-3/conf/etc/nginx/conf.d/02-dev.conf b/docker/php-apache/7.0/conf/etc/httpd/vhost.common.d/01-boilerplate.conf similarity index 100% rename from docker/php-nginx-dev/alpine-3/conf/etc/nginx/conf.d/02-dev.conf rename to docker/php-apache/7.0/conf/etc/httpd/vhost.common.d/01-boilerplate.conf diff --git a/docker/php-apache/7.0/conf/etc/httpd/vhost.conf b/docker/php-apache/7.0/conf/etc/httpd/vhost.conf new file mode 100644 index 000000000..c04a94318 --- /dev/null +++ b/docker/php-apache/7.0/conf/etc/httpd/vhost.conf @@ -0,0 +1,36 @@ +####################################### +# Vhost +####################################### + + + ServerName docker.vm + ServerAlias + DocumentRoot "" + + UseCanonicalName Off + + + Include /opt/docker/etc/httpd/vhost.common.d/*.conf + + = 2.4> + IncludeOptional /opt/docker/etc/httpd/vhost.common.d/*.conf + + + + + + ServerName docker.vm + ServerAlias + DocumentRoot "" + + UseCanonicalName Off + + + Include /opt/docker/etc/httpd/vhost.common.d/*.conf + + = 2.4> + IncludeOptional /opt/docker/etc/httpd/vhost.common.d/*.conf + + + Include /opt/docker/etc/httpd/vhost.ssl.conf + diff --git a/docker/php-apache/7.0/conf/etc/httpd/vhost.ssl.conf b/docker/php-apache/7.0/conf/etc/httpd/vhost.ssl.conf new file mode 100644 index 000000000..cf5fbc604 --- /dev/null +++ b/docker/php-apache/7.0/conf/etc/httpd/vhost.ssl.conf @@ -0,0 +1,26 @@ + ############ + # SSL + ############ + + SSLEngine on + SSLCertificateFile /opt/docker/etc/httpd/ssl/server.crt + SSLCertificateKeyFile /opt/docker/etc/httpd/ssl/server.key + + + SSLOptions +StdEnvVars + + + SSLOptions +StdEnvVars + + + BrowserMatch "MSIE [2-6]" \ + nokeepalive ssl-unclean-shutdown \ + downgrade-1.0 force-response-1.0 + # MSIE 7 and newer should be able to use keepalive + # This regexp is ok with 17-9! + BrowserMatch "MSIE [17-9]" ssl-unclean-shutdown + + ## SSL Hardening + SSLProtocol All -SSLv2 -SSLv3 + SSLHonorCipherOrder on + SSLCipherSuite 'EDH+CAMELLIA:EDH+aRSA:EECDH+aRSA+AESGCM:EECDH+aRSA+SHA384:EECDH+aRSA+SHA256:EECDH:+CAMELLIA256:+AES256:+CAMELLIA128:+AES128:+SSLv3:!aNULL:!eNULL:!LOW:!3DES:!MD5:!EXP:!PSK:!DSS:!RC4:!SEED:!ECDSA:CAMELLIA256-SHA:AES256-SHA:CAMELLIA128-SHA:AES128-SHA' diff --git a/docker/php-apache/7.0/conf/etc/supervisor.d/apache.conf b/docker/php-apache/7.0/conf/etc/supervisor.d/apache.conf new file mode 100644 index 000000000..12a6f86f7 --- /dev/null +++ b/docker/php-apache/7.0/conf/etc/supervisor.d/apache.conf @@ -0,0 +1,14 @@ +[group:apache] +programs=apached +priority=20 + +[program:apached] +command = /opt/docker/bin/service.d/httpd.sh +process_name=%(program_name)s +startsecs = 0 +autostart = true +autorestart = true +stdout_logfile=/dev/stdout +stdout_logfile_maxbytes=0 +stderr_logfile=/dev/stderr +stderr_logfile_maxbytes=0 diff --git a/docker/php-nginx/alpine-3-php7/conf/provision/roles/webdevops-nginx/defaults/main.yml b/docker/php-apache/7.0/conf/provision/roles/webdevops-apache/defaults/main.yml similarity index 100% rename from docker/php-nginx/alpine-3-php7/conf/provision/roles/webdevops-nginx/defaults/main.yml rename to docker/php-apache/7.0/conf/provision/roles/webdevops-apache/defaults/main.yml diff --git a/docker/php-apache/7.0/conf/provision/roles/webdevops-apache/tasks/bootstrap.yml b/docker/php-apache/7.0/conf/provision/roles/webdevops-apache/tasks/bootstrap.yml new file mode 100644 index 000000000..c285be286 --- /dev/null +++ b/docker/php-apache/7.0/conf/provision/roles/webdevops-apache/tasks/bootstrap.yml @@ -0,0 +1,156 @@ +--- + +- name: Set apache vhost file [RedHat family] + set_fact: + apache_main_path: /etc/httpd/ + apache_docker_vhost: /etc/httpd/conf.d/zzz-docker.conf + when: ansible_os_family == 'RedHat' + +- name: Set apache vhost file [Debian family] + set_fact: + apache_main_path: /etc/apache2/ + apache_docker_vhost: /etc/apache2/sites-enabled/10-docker.conf + when: ansible_os_family == 'Debian' + +- name: Set apache vhost file [Alpine family] + set_fact: + apache_main_path: /etc/apache2/ + apache_docker_vhost: /etc/apache2/conf.d/zzz-docker.conf + when: ansible_os_family == 'Alpine' + +- name: Enable apache main config + file: + src: '/opt/docker/etc/httpd/main.conf' + dest: '{{ apache_docker_vhost }}' + state: link + force: yes + +- name: Ensure document root is available + file: + path: "{{ DOCUMENT_ROOT }}" + state: directory + recurse: yes + +- name: Ensure /var/run/apache2 exists + file: + path: '/var/run/apache2' + state: directory + recurse: yes + +- name: Ensure /run/apache2 exists + file: + path: '/run/apache2' + state: directory + recurse: yes + when: ansible_os_family == 'Alpine' + +- name: Find apache2 files + shell: "find '{{ apache_main_path }}' -type f -iname '*.conf' -o -iname 'default*' -o -iname '*log'" + register: apache2_conf_files + +- name: Change CustomLog to Docker stdout + replace: + dest: '{{ item }}' + regexp: '^[\s]*CustomLog ([^\s]+)(.*)' + replace: 'CustomLog /docker.stdout \2' + with_items: "{{ apache2_conf_files.stdout_lines }}" + +- name: Change CustomLog to Docker stdout + replace: + dest: '{{ item }}' + regexp: '^[\s]*ErrorLog ([^\s]+)(.*)' + replace: 'ErrorLog /docker.stdout \2' + with_items: "{{ apache2_conf_files.stdout_lines }}" + +- name: Change TransferLog to Docker stdout + replace: + dest: '{{ item }}' + regexp: '^[\s]*TransferLog ([^\s]+)(.*)' + replace: 'TransferLog /docker.stdout \2' + with_items: "{{ apache2_conf_files.stdout_lines }}" + +- name: Switch MPM to worker [RedHat family] + lineinfile: + dest: '/etc/httpd/conf.modules.d/00-mpm.conf' + regexp: '^[\s#]*{{ item.line }}' + line: '{{ item.prefix }}{{ item.line }}' + with_items: + - { line: 'LoadModule mpm_prefork_module modules/mod_mpm_prefork.so', prefix: "#" } + - { line: 'LoadModule mpm_event_module modules/mod_mpm_event.so', prefix: "" } + when: ansible_os_family == 'RedHat' + +- name: Switch MPM to event for Apache 2.4 and higher [Ubuntu family] + command: "{{ item }}" + with_items: + - 'a2dismod mpm_event' + - 'a2enmod mpm_event' + when: (ansible_distribution == 'Ubuntu' and docker_image_info_distribution_version|int >= 14) or (ansible_distribution == 'Debian' and docker_image_info_distribution_version|int >= 8) + +- name: Manage modules [Alpine family] + lineinfile: + dest: '/etc/apache2/httpd.conf' + regexp: '^[\s#]*{{ item.line }}' + line: '{{ item.prefix }}{{ item.line }}' + with_items: + - { line: 'LoadModule mpm_prefork_module modules/mod_mpm_prefork.so', prefix: "#" } + - { line: 'LoadModule mpm_event_module modules/mod_mpm_event.so', prefix: "" } + - { line: 'LoadModule deflate_module modules/mod_deflate.so', prefix: "" } + - { line: 'LoadModule rewrite_module modules/mod_rewrite.so', prefix: "" } + - { line: 'LoadModule logio_module modules/mod_logio.so', prefix: "" } + - { line: 'LoadModule slotmem_shm_module modules/mod_slotmem_shm.so', prefix: "" } + - { line: 'LoadModule actions_module modules/mod_actions.so', prefix: "" } + - { line: 'LoadModule expires_module modules/mod_expires.so', prefix: "" } + when: ansible_os_family == 'Alpine' + +- name: Fix ssl support [Alpine family] + lineinfile: + dest: '/etc/apache2/conf.d/ssl.conf' + regexp: '{{ item.regexp }}' + line: '{{ item.line }}' + with_items: + - { regexp: 'LoadModule ssl_module', line: 'LoadModule ssl_module /usr/lib/apache2/mod_ssl.so' } + - { regexp: 'LoadModule socache_shmcb_module', line: 'LoadModule socache_shmcb_module /usr/lib/apache2/mod_socache_shmcb.so' } + when: ansible_os_family == 'Alpine' + +- name: Remove default vhost from ssl configuration [Alpine family] + command: sed -i -e '1h;2,$H;$!d;g' -e 's//#-> removed vhost/g' /etc/apache2/conf.d/ssl.conf + when: ansible_os_family == 'Alpine' + +- name: Disable proxy [Alpine family] + lineinfile: + dest: '/etc/apache2/conf.d/proxy.conf' + regexp: '^[\s#]*{{ item.line }}' + line: '{{ item.prefix }}{{ item.line }}' + with_items: + - { line: 'LoadModule proxy_ajp_module modules/mod_proxy_ajp.so', prefix: "#" } + - { line: 'LoadModule proxy_connect_module modules/mod_proxy_connect.so', prefix: "#" } + - { line: 'LoadModule proxy_balancer_module modules/mod_proxy_balancer.so', prefix: "#" } + - { line: 'LoadModule proxy_express_module modules/mod_proxy_express.so', prefix: "#" } + - { line: 'LoadModule proxy_fcgi_module modules/mod_proxy_fcgi.so', prefix: "" } + - { line: 'LoadModule proxy_fdpass_module modules/mod_proxy_fdpass.so', prefix: "#" } + - { line: 'LoadModule proxy_ftp_module modules/mod_proxy_ftp.so', prefix: "#" } + - { line: 'LoadModule proxy_http_module modules/mod_proxy_http.so', prefix: "#" } + - { line: 'LoadModule proxy_scgi_module modules/mod_proxy_scgi.so', prefix: "#" } + when: ansible_os_family == 'Alpine' + +- name: Fix rights of ssl files + file: + path: "{{ item.path }}" + state: "{{ item.state }}" + mode: "{{ item.mode }}" + owner: "root" + group: "root" + with_items: + - { path: '/opt/docker/etc/httpd/ssl', state: 'directory', mode: '0750' } + - { path: '/opt/docker/etc/httpd/ssl/server.crt', state: 'file', mode: '0640' } + - { path: '/opt/docker/etc/httpd/ssl/server.csr', state: 'file', mode: '0640' } + - { path: '/opt/docker/etc/httpd/ssl/server.key', state: 'file', mode: '0640' } + +- name: Maintain lock directory [Debian family] + file: + path: "/var/lock/apache2" + state: "directory" + mode: "0750" + owner: "www-data" + group: "www-data" + when: ansible_os_family == 'Debian' diff --git a/docker/php-nginx-dev/alpine-3/conf/provision/roles/webdevops-nginx-dev/tasks/main.yml b/docker/php-apache/7.0/conf/provision/roles/webdevops-apache/tasks/main.yml similarity index 100% rename from docker/php-nginx-dev/alpine-3/conf/provision/roles/webdevops-nginx-dev/tasks/main.yml rename to docker/php-apache/7.0/conf/provision/roles/webdevops-apache/tasks/main.yml diff --git a/docker/php-nginx/alpine-3-php7/conf/provision/roles/webdevops-php-nginx/defaults/main.yml b/docker/php-apache/7.0/conf/provision/roles/webdevops-php-apache/defaults/main.yml similarity index 100% rename from docker/php-nginx/alpine-3-php7/conf/provision/roles/webdevops-php-nginx/defaults/main.yml rename to docker/php-apache/7.0/conf/provision/roles/webdevops-php-apache/defaults/main.yml diff --git a/docker/php-apache/7.0/conf/provision/roles/webdevops-php-apache/tasks/bootstrap.yml b/docker/php-apache/7.0/conf/provision/roles/webdevops-php-apache/tasks/bootstrap.yml new file mode 100644 index 000000000..ad5fb2121 --- /dev/null +++ b/docker/php-apache/7.0/conf/provision/roles/webdevops-php-apache/tasks/bootstrap.yml @@ -0,0 +1,8 @@ +--- +- name: Restrict php-fpm to local connection + lineinfile: + dest: '/opt/docker/etc/php/fpm/pool.d/application.conf' + regexp: '^[\s;]*{{ item.key }}[\s]*=' + line: '{{ item.key }} = {{ item.value }}' + with_items: + - { key: 'listen', value: "127.0.0.1:9000" } diff --git a/docker/php-apache/7.0/conf/provision/roles/webdevops-php-apache/tasks/entrypoint.yml b/docker/php-apache/7.0/conf/provision/roles/webdevops-php-apache/tasks/entrypoint.yml new file mode 100644 index 000000000..cd21505a4 --- /dev/null +++ b/docker/php-apache/7.0/conf/provision/roles/webdevops-php-apache/tasks/entrypoint.yml @@ -0,0 +1,2 @@ +--- + diff --git a/docker/php-nginx/alpine-3-php7/conf/provision/roles/webdevops-php-nginx/tasks/main.yml b/docker/php-apache/7.0/conf/provision/roles/webdevops-php-apache/tasks/main.yml similarity index 100% rename from docker/php-nginx/alpine-3-php7/conf/provision/roles/webdevops-php-nginx/tasks/main.yml rename to docker/php-apache/7.0/conf/provision/roles/webdevops-php-apache/tasks/main.yml diff --git a/docker/php-apache/7.1/Dockerfile b/docker/php-apache/7.1/Dockerfile new file mode 100644 index 000000000..c5c2449bd --- /dev/null +++ b/docker/php-apache/7.1/Dockerfile @@ -0,0 +1,29 @@ +#+++++++++++++++++++++++++++++++++++++++ +# Dockerfile for webdevops/php-apache:7.1 +# -- automatically generated -- +#+++++++++++++++++++++++++++++++++++++++ + +FROM webdevops/php:7.1 + +ENV WEB_DOCUMENT_ROOT=/app \ + WEB_DOCUMENT_INDEX=index.php \ + WEB_ALIAS_DOMAIN=*.vm +ENV WEB_PHP_SOCKET=127.0.0.1:9000 + +COPY conf/ /opt/docker/ + +# Install apache +RUN /usr/local/bin/apt-install \ + apache2 \ + apache2-mpm-worker \ + && sed -ri ' \ + s!^(\s*CustomLog)\s+\S+!\1 /proc/self/fd/1!g; \ + s!^(\s*ErrorLog)\s+\S+!\1 /proc/self/fd/2!g; \ + ' /etc/apache2/apache2.conf \ + && rm -f /etc/apache2/sites-enabled/* \ + && a2enmod actions proxy proxy_fcgi ssl rewrite headers expires \ + && /opt/docker/bin/provision run --tag bootstrap --role webdevops-apache --role webdevops-php-apache \ + && /opt/docker/bin/bootstrap.sh \ + && docker-image-cleanup + +EXPOSE 80 443 diff --git a/docker/php-apache/7.1/Dockerfile.jinja2 b/docker/php-apache/7.1/Dockerfile.jinja2 new file mode 100644 index 000000000..50e8b75ec --- /dev/null +++ b/docker/php-apache/7.1/Dockerfile.jinja2 @@ -0,0 +1,10 @@ +{{ docker.from("php", "7.1") }} + +{{ environment.web() }} +{{ environment.webPhp() }} + +{{ docker.copy('conf/', '/opt/docker/') }} + +{{ apache.debian8('php-apache') }} + +{{ docker.expose('80 443') }} diff --git a/docker/php-apache/7.1/conf/bin/service.d/httpd.d/10-init.sh b/docker/php-apache/7.1/conf/bin/service.d/httpd.d/10-init.sh new file mode 100644 index 000000000..b9d57997e --- /dev/null +++ b/docker/php-apache/7.1/conf/bin/service.d/httpd.d/10-init.sh @@ -0,0 +1,21 @@ +if [[ ! -e "$WEB_DOCUMENT_ROOT" ]]; then + echo "" + echo "[WARNING] WEB_DOCUMENT_ROOT does not exists with path \"$WEB_DOCUMENT_ROOT\"!" + echo "" +fi + +# Replace markers +go-replace \ + -s "" -r "$WEB_DOCUMENT_INDEX" \ + -s "" -r "$WEB_DOCUMENT_ROOT" \ + -s "" -r "$WEB_ALIAS_DOMAIN" \ + -s "" -r "$HOSTNAME" \ + -s "" -r "$WEB_PHP_SOCKET" \ + --path=/opt/docker/etc/httpd/ \ + --path-pattern='*.conf' \ + --ignore-empty + +if [[ -z "${WEB_PHP_SOCKET+x}" ]]; then + ## WEB_PHP_SOCKET is not set, remove PHP files + rm -f -- /opt/docker/etc/httpd/conf.d/10-php.conf +fi diff --git a/docker/php-apache/7.1/conf/bin/service.d/httpd.sh b/docker/php-apache/7.1/conf/bin/service.d/httpd.sh new file mode 100644 index 000000000..03eec305a --- /dev/null +++ b/docker/php-apache/7.1/conf/bin/service.d/httpd.sh @@ -0,0 +1,12 @@ +#!/usr/bin/env bash +set -e + +source /opt/docker/bin/config.sh + +includeScriptDir "/opt/docker/bin/service.d/httpd.d/" + +# Apache gets grumpy about PID files pre-existing +rm -f /var/run/apache2/apache2*.pid + +source /etc/apache2/envvars +exec apache2 -DFOREGROUND -DAPACHE_LOCK_DIR diff --git a/docker/php-apache/7.1/conf/etc/httpd/conf.d/.gitkeep b/docker/php-apache/7.1/conf/etc/httpd/conf.d/.gitkeep new file mode 100644 index 000000000..e69de29bb diff --git a/docker/php-apache/7.1/conf/etc/httpd/conf.d/10-error-document.conf b/docker/php-apache/7.1/conf/etc/httpd/conf.d/10-error-document.conf new file mode 100644 index 000000000..ebabf87e4 --- /dev/null +++ b/docker/php-apache/7.1/conf/etc/httpd/conf.d/10-error-document.conf @@ -0,0 +1,15 @@ +####################################### +# Faster error documents +####################################### + + ErrorDocument 400 "400 Bad Request" + ErrorDocument 401 "401 Unauthorized" + ErrorDocument 403 "403 Forbidden" + ErrorDocument 404 "404 Not Found" + ErrorDocument 405 "405 Method Not Allowed" + + ErrorDocument 500 "500 Internal Server Error" + ErrorDocument 501 "501 Not Implemented" + ErrorDocument 502 "502 Bad Gateway" + ErrorDocument 503 "503 Service Unavailable" + diff --git a/docker/php-apache/7.1/conf/etc/httpd/conf.d/10-log.conf b/docker/php-apache/7.1/conf/etc/httpd/conf.d/10-log.conf new file mode 100644 index 000000000..ef0c73d38 --- /dev/null +++ b/docker/php-apache/7.1/conf/etc/httpd/conf.d/10-log.conf @@ -0,0 +1,4 @@ +LogFormat "[httpd:access] %V:%p %h %l %u %t \"%r\" %>s bytesIn:%I bytesOut:%O reqTime:%T" dockerlog +LogLevel warn +CustomLog /docker.stdout dockerlog +ErrorLog /docker.stderr diff --git a/docker/php-apache/7.1/conf/etc/httpd/conf.d/10-php.conf b/docker/php-apache/7.1/conf/etc/httpd/conf.d/10-php.conf new file mode 100644 index 000000000..4368d12ef --- /dev/null +++ b/docker/php-apache/7.1/conf/etc/httpd/conf.d/10-php.conf @@ -0,0 +1,37 @@ +############################# +# mod_proxy_fcgi +# official solution +# apache 2.4 and later +############################# + + + > + ProxySet connectiontimeout=5 timeout=600 + + + + SetHandler "proxy:fcgi://" + + + +############################# +# mod_fastcgi +# apaache 2.2 and 2.4 +############################# + + + AddHandler php-fcgi .php + Action php-fcgi /php-fcgi + Alias /php-fcgi /usr/lib/cgi-bin/php-fcgi + FastCgiExternalServer /usr/lib/cgi-bin/php-fcgi -host "" -pass-header Authorization -idle-timeout 600 + + + + Allow from all + + = 2.4> + Require all granted + + + + diff --git a/docker/php-apache/7.1/conf/etc/httpd/conf.d/10-server.conf b/docker/php-apache/7.1/conf/etc/httpd/conf.d/10-server.conf new file mode 100644 index 000000000..d3a5defbd --- /dev/null +++ b/docker/php-apache/7.1/conf/etc/httpd/conf.d/10-server.conf @@ -0,0 +1,18 @@ +# Settings +TimeOut 1000 +ServerName "" + +DirectoryIndex +DocumentRoot "" + +"> + Options Indexes FollowSymLinks + AllowOverride All + + + Allow from all + + = 2.4> + Require all granted + + diff --git a/docker/php-nginx/alpine-3/conf/etc/nginx/global.conf b/docker/php-apache/7.1/conf/etc/httpd/global.conf similarity index 100% rename from docker/php-nginx/alpine-3/conf/etc/nginx/global.conf rename to docker/php-apache/7.1/conf/etc/httpd/global.conf diff --git a/docker/php-apache/7.1/conf/etc/httpd/main.conf b/docker/php-apache/7.1/conf/etc/httpd/main.conf new file mode 100644 index 000000000..12251c222 --- /dev/null +++ b/docker/php-apache/7.1/conf/etc/httpd/main.conf @@ -0,0 +1,12 @@ +Include /opt/docker/etc/httpd/global.conf +Include /opt/docker/etc/httpd/php.conf + + + Include /opt/docker/etc/httpd/conf.d/*.conf + += 2.4> + IncludeOptional /opt/docker/etc/httpd/conf.d/*.conf + +Include /opt/docker/etc/httpd/vhost.conf + + diff --git a/docker/php-nginx/alpine-3/conf/etc/nginx/php.conf b/docker/php-apache/7.1/conf/etc/httpd/php.conf similarity index 100% rename from docker/php-nginx/alpine-3/conf/etc/nginx/php.conf rename to docker/php-apache/7.1/conf/etc/httpd/php.conf diff --git a/docker/php-nginx/alpine-3/conf/etc/nginx/ssl/server.crt b/docker/php-apache/7.1/conf/etc/httpd/ssl/server.crt similarity index 100% rename from docker/php-nginx/alpine-3/conf/etc/nginx/ssl/server.crt rename to docker/php-apache/7.1/conf/etc/httpd/ssl/server.crt diff --git a/docker/php-nginx/alpine-3/conf/etc/nginx/ssl/server.csr b/docker/php-apache/7.1/conf/etc/httpd/ssl/server.csr similarity index 100% rename from docker/php-nginx/alpine-3/conf/etc/nginx/ssl/server.csr rename to docker/php-apache/7.1/conf/etc/httpd/ssl/server.csr diff --git a/docker/php-nginx/alpine-3/conf/etc/nginx/ssl/server.key b/docker/php-apache/7.1/conf/etc/httpd/ssl/server.key similarity index 100% rename from docker/php-nginx/alpine-3/conf/etc/nginx/ssl/server.key rename to docker/php-apache/7.1/conf/etc/httpd/ssl/server.key diff --git a/docker/php-apache/7.1/conf/etc/httpd/vhost.common.conf b/docker/php-apache/7.1/conf/etc/httpd/vhost.common.conf new file mode 100644 index 000000000..384696b4e --- /dev/null +++ b/docker/php-apache/7.1/conf/etc/httpd/vhost.common.conf @@ -0,0 +1,7 @@ +# compatibility for PHP and TYPO3 Docker Boilerplate + + Include /opt/docker/etc/httpd/vhost.common.d/*.conf + + = 2.4> + IncludeOptional /opt/docker/etc/httpd/vhost.common.d/*.conf + diff --git a/docker/php-apache/7.1/conf/etc/httpd/vhost.common.d/.gitkeep b/docker/php-apache/7.1/conf/etc/httpd/vhost.common.d/.gitkeep new file mode 100644 index 000000000..e69de29bb diff --git a/docker/php-apache/7.1/conf/etc/httpd/vhost.common.d/01-boilerplate.conf b/docker/php-apache/7.1/conf/etc/httpd/vhost.common.d/01-boilerplate.conf new file mode 100644 index 000000000..fdffa2a0f --- /dev/null +++ b/docker/php-apache/7.1/conf/etc/httpd/vhost.common.d/01-boilerplate.conf @@ -0,0 +1 @@ +# placeholder diff --git a/docker/php-apache/7.1/conf/etc/httpd/vhost.conf b/docker/php-apache/7.1/conf/etc/httpd/vhost.conf new file mode 100644 index 000000000..c04a94318 --- /dev/null +++ b/docker/php-apache/7.1/conf/etc/httpd/vhost.conf @@ -0,0 +1,36 @@ +####################################### +# Vhost +####################################### + + + ServerName docker.vm + ServerAlias + DocumentRoot "" + + UseCanonicalName Off + + + Include /opt/docker/etc/httpd/vhost.common.d/*.conf + + = 2.4> + IncludeOptional /opt/docker/etc/httpd/vhost.common.d/*.conf + + + + + + ServerName docker.vm + ServerAlias + DocumentRoot "" + + UseCanonicalName Off + + + Include /opt/docker/etc/httpd/vhost.common.d/*.conf + + = 2.4> + IncludeOptional /opt/docker/etc/httpd/vhost.common.d/*.conf + + + Include /opt/docker/etc/httpd/vhost.ssl.conf + diff --git a/docker/php-apache/7.1/conf/etc/httpd/vhost.ssl.conf b/docker/php-apache/7.1/conf/etc/httpd/vhost.ssl.conf new file mode 100644 index 000000000..cf5fbc604 --- /dev/null +++ b/docker/php-apache/7.1/conf/etc/httpd/vhost.ssl.conf @@ -0,0 +1,26 @@ + ############ + # SSL + ############ + + SSLEngine on + SSLCertificateFile /opt/docker/etc/httpd/ssl/server.crt + SSLCertificateKeyFile /opt/docker/etc/httpd/ssl/server.key + + + SSLOptions +StdEnvVars + + + SSLOptions +StdEnvVars + + + BrowserMatch "MSIE [2-6]" \ + nokeepalive ssl-unclean-shutdown \ + downgrade-1.0 force-response-1.0 + # MSIE 7 and newer should be able to use keepalive + # This regexp is ok with 17-9! + BrowserMatch "MSIE [17-9]" ssl-unclean-shutdown + + ## SSL Hardening + SSLProtocol All -SSLv2 -SSLv3 + SSLHonorCipherOrder on + SSLCipherSuite 'EDH+CAMELLIA:EDH+aRSA:EECDH+aRSA+AESGCM:EECDH+aRSA+SHA384:EECDH+aRSA+SHA256:EECDH:+CAMELLIA256:+AES256:+CAMELLIA128:+AES128:+SSLv3:!aNULL:!eNULL:!LOW:!3DES:!MD5:!EXP:!PSK:!DSS:!RC4:!SEED:!ECDSA:CAMELLIA256-SHA:AES256-SHA:CAMELLIA128-SHA:AES128-SHA' diff --git a/docker/php-apache/7.1/conf/etc/supervisor.d/apache.conf b/docker/php-apache/7.1/conf/etc/supervisor.d/apache.conf new file mode 100644 index 000000000..12a6f86f7 --- /dev/null +++ b/docker/php-apache/7.1/conf/etc/supervisor.d/apache.conf @@ -0,0 +1,14 @@ +[group:apache] +programs=apached +priority=20 + +[program:apached] +command = /opt/docker/bin/service.d/httpd.sh +process_name=%(program_name)s +startsecs = 0 +autostart = true +autorestart = true +stdout_logfile=/dev/stdout +stdout_logfile_maxbytes=0 +stderr_logfile=/dev/stderr +stderr_logfile_maxbytes=0 diff --git a/docker/php-nginx/alpine-3/conf/provision/roles/webdevops-nginx/defaults/main.yml b/docker/php-apache/7.1/conf/provision/roles/webdevops-apache/defaults/main.yml similarity index 100% rename from docker/php-nginx/alpine-3/conf/provision/roles/webdevops-nginx/defaults/main.yml rename to docker/php-apache/7.1/conf/provision/roles/webdevops-apache/defaults/main.yml diff --git a/docker/php-apache/7.1/conf/provision/roles/webdevops-apache/tasks/bootstrap.yml b/docker/php-apache/7.1/conf/provision/roles/webdevops-apache/tasks/bootstrap.yml new file mode 100644 index 000000000..c285be286 --- /dev/null +++ b/docker/php-apache/7.1/conf/provision/roles/webdevops-apache/tasks/bootstrap.yml @@ -0,0 +1,156 @@ +--- + +- name: Set apache vhost file [RedHat family] + set_fact: + apache_main_path: /etc/httpd/ + apache_docker_vhost: /etc/httpd/conf.d/zzz-docker.conf + when: ansible_os_family == 'RedHat' + +- name: Set apache vhost file [Debian family] + set_fact: + apache_main_path: /etc/apache2/ + apache_docker_vhost: /etc/apache2/sites-enabled/10-docker.conf + when: ansible_os_family == 'Debian' + +- name: Set apache vhost file [Alpine family] + set_fact: + apache_main_path: /etc/apache2/ + apache_docker_vhost: /etc/apache2/conf.d/zzz-docker.conf + when: ansible_os_family == 'Alpine' + +- name: Enable apache main config + file: + src: '/opt/docker/etc/httpd/main.conf' + dest: '{{ apache_docker_vhost }}' + state: link + force: yes + +- name: Ensure document root is available + file: + path: "{{ DOCUMENT_ROOT }}" + state: directory + recurse: yes + +- name: Ensure /var/run/apache2 exists + file: + path: '/var/run/apache2' + state: directory + recurse: yes + +- name: Ensure /run/apache2 exists + file: + path: '/run/apache2' + state: directory + recurse: yes + when: ansible_os_family == 'Alpine' + +- name: Find apache2 files + shell: "find '{{ apache_main_path }}' -type f -iname '*.conf' -o -iname 'default*' -o -iname '*log'" + register: apache2_conf_files + +- name: Change CustomLog to Docker stdout + replace: + dest: '{{ item }}' + regexp: '^[\s]*CustomLog ([^\s]+)(.*)' + replace: 'CustomLog /docker.stdout \2' + with_items: "{{ apache2_conf_files.stdout_lines }}" + +- name: Change CustomLog to Docker stdout + replace: + dest: '{{ item }}' + regexp: '^[\s]*ErrorLog ([^\s]+)(.*)' + replace: 'ErrorLog /docker.stdout \2' + with_items: "{{ apache2_conf_files.stdout_lines }}" + +- name: Change TransferLog to Docker stdout + replace: + dest: '{{ item }}' + regexp: '^[\s]*TransferLog ([^\s]+)(.*)' + replace: 'TransferLog /docker.stdout \2' + with_items: "{{ apache2_conf_files.stdout_lines }}" + +- name: Switch MPM to worker [RedHat family] + lineinfile: + dest: '/etc/httpd/conf.modules.d/00-mpm.conf' + regexp: '^[\s#]*{{ item.line }}' + line: '{{ item.prefix }}{{ item.line }}' + with_items: + - { line: 'LoadModule mpm_prefork_module modules/mod_mpm_prefork.so', prefix: "#" } + - { line: 'LoadModule mpm_event_module modules/mod_mpm_event.so', prefix: "" } + when: ansible_os_family == 'RedHat' + +- name: Switch MPM to event for Apache 2.4 and higher [Ubuntu family] + command: "{{ item }}" + with_items: + - 'a2dismod mpm_event' + - 'a2enmod mpm_event' + when: (ansible_distribution == 'Ubuntu' and docker_image_info_distribution_version|int >= 14) or (ansible_distribution == 'Debian' and docker_image_info_distribution_version|int >= 8) + +- name: Manage modules [Alpine family] + lineinfile: + dest: '/etc/apache2/httpd.conf' + regexp: '^[\s#]*{{ item.line }}' + line: '{{ item.prefix }}{{ item.line }}' + with_items: + - { line: 'LoadModule mpm_prefork_module modules/mod_mpm_prefork.so', prefix: "#" } + - { line: 'LoadModule mpm_event_module modules/mod_mpm_event.so', prefix: "" } + - { line: 'LoadModule deflate_module modules/mod_deflate.so', prefix: "" } + - { line: 'LoadModule rewrite_module modules/mod_rewrite.so', prefix: "" } + - { line: 'LoadModule logio_module modules/mod_logio.so', prefix: "" } + - { line: 'LoadModule slotmem_shm_module modules/mod_slotmem_shm.so', prefix: "" } + - { line: 'LoadModule actions_module modules/mod_actions.so', prefix: "" } + - { line: 'LoadModule expires_module modules/mod_expires.so', prefix: "" } + when: ansible_os_family == 'Alpine' + +- name: Fix ssl support [Alpine family] + lineinfile: + dest: '/etc/apache2/conf.d/ssl.conf' + regexp: '{{ item.regexp }}' + line: '{{ item.line }}' + with_items: + - { regexp: 'LoadModule ssl_module', line: 'LoadModule ssl_module /usr/lib/apache2/mod_ssl.so' } + - { regexp: 'LoadModule socache_shmcb_module', line: 'LoadModule socache_shmcb_module /usr/lib/apache2/mod_socache_shmcb.so' } + when: ansible_os_family == 'Alpine' + +- name: Remove default vhost from ssl configuration [Alpine family] + command: sed -i -e '1h;2,$H;$!d;g' -e 's//#-> removed vhost/g' /etc/apache2/conf.d/ssl.conf + when: ansible_os_family == 'Alpine' + +- name: Disable proxy [Alpine family] + lineinfile: + dest: '/etc/apache2/conf.d/proxy.conf' + regexp: '^[\s#]*{{ item.line }}' + line: '{{ item.prefix }}{{ item.line }}' + with_items: + - { line: 'LoadModule proxy_ajp_module modules/mod_proxy_ajp.so', prefix: "#" } + - { line: 'LoadModule proxy_connect_module modules/mod_proxy_connect.so', prefix: "#" } + - { line: 'LoadModule proxy_balancer_module modules/mod_proxy_balancer.so', prefix: "#" } + - { line: 'LoadModule proxy_express_module modules/mod_proxy_express.so', prefix: "#" } + - { line: 'LoadModule proxy_fcgi_module modules/mod_proxy_fcgi.so', prefix: "" } + - { line: 'LoadModule proxy_fdpass_module modules/mod_proxy_fdpass.so', prefix: "#" } + - { line: 'LoadModule proxy_ftp_module modules/mod_proxy_ftp.so', prefix: "#" } + - { line: 'LoadModule proxy_http_module modules/mod_proxy_http.so', prefix: "#" } + - { line: 'LoadModule proxy_scgi_module modules/mod_proxy_scgi.so', prefix: "#" } + when: ansible_os_family == 'Alpine' + +- name: Fix rights of ssl files + file: + path: "{{ item.path }}" + state: "{{ item.state }}" + mode: "{{ item.mode }}" + owner: "root" + group: "root" + with_items: + - { path: '/opt/docker/etc/httpd/ssl', state: 'directory', mode: '0750' } + - { path: '/opt/docker/etc/httpd/ssl/server.crt', state: 'file', mode: '0640' } + - { path: '/opt/docker/etc/httpd/ssl/server.csr', state: 'file', mode: '0640' } + - { path: '/opt/docker/etc/httpd/ssl/server.key', state: 'file', mode: '0640' } + +- name: Maintain lock directory [Debian family] + file: + path: "/var/lock/apache2" + state: "directory" + mode: "0750" + owner: "www-data" + group: "www-data" + when: ansible_os_family == 'Debian' diff --git a/docker/php-nginx-dev/alpine-3/conf/provision/roles/webdevops-nginx/tasks/main.yml b/docker/php-apache/7.1/conf/provision/roles/webdevops-apache/tasks/main.yml similarity index 100% rename from docker/php-nginx-dev/alpine-3/conf/provision/roles/webdevops-nginx/tasks/main.yml rename to docker/php-apache/7.1/conf/provision/roles/webdevops-apache/tasks/main.yml diff --git a/docker/php-nginx/alpine-3/conf/provision/roles/webdevops-php-nginx/defaults/main.yml b/docker/php-apache/7.1/conf/provision/roles/webdevops-php-apache/defaults/main.yml similarity index 100% rename from docker/php-nginx/alpine-3/conf/provision/roles/webdevops-php-nginx/defaults/main.yml rename to docker/php-apache/7.1/conf/provision/roles/webdevops-php-apache/defaults/main.yml diff --git a/docker/php-apache/7.1/conf/provision/roles/webdevops-php-apache/tasks/bootstrap.yml b/docker/php-apache/7.1/conf/provision/roles/webdevops-php-apache/tasks/bootstrap.yml new file mode 100644 index 000000000..ad5fb2121 --- /dev/null +++ b/docker/php-apache/7.1/conf/provision/roles/webdevops-php-apache/tasks/bootstrap.yml @@ -0,0 +1,8 @@ +--- +- name: Restrict php-fpm to local connection + lineinfile: + dest: '/opt/docker/etc/php/fpm/pool.d/application.conf' + regexp: '^[\s;]*{{ item.key }}[\s]*=' + line: '{{ item.key }} = {{ item.value }}' + with_items: + - { key: 'listen', value: "127.0.0.1:9000" } diff --git a/docker/php-apache/7.1/conf/provision/roles/webdevops-php-apache/tasks/entrypoint.yml b/docker/php-apache/7.1/conf/provision/roles/webdevops-php-apache/tasks/entrypoint.yml new file mode 100644 index 000000000..cd21505a4 --- /dev/null +++ b/docker/php-apache/7.1/conf/provision/roles/webdevops-php-apache/tasks/entrypoint.yml @@ -0,0 +1,2 @@ +--- + diff --git a/docker/php-nginx/alpine-3/conf/provision/roles/webdevops-php-nginx/tasks/main.yml b/docker/php-apache/7.1/conf/provision/roles/webdevops-php-apache/tasks/main.yml similarity index 100% rename from docker/php-nginx/alpine-3/conf/provision/roles/webdevops-php-nginx/tasks/main.yml rename to docker/php-apache/7.1/conf/provision/roles/webdevops-php-apache/tasks/main.yml diff --git a/docker/php-apache/alpine b/docker/php-apache/alpine new file mode 120000 index 000000000..a5e678cb6 --- /dev/null +++ b/docker/php-apache/alpine @@ -0,0 +1 @@ +alpine-php7 \ No newline at end of file diff --git a/docker/php-apache/alpine-3 b/docker/php-apache/alpine-3 new file mode 120000 index 000000000..a84cfe247 --- /dev/null +++ b/docker/php-apache/alpine-3 @@ -0,0 +1 @@ +alpine-php5 \ No newline at end of file diff --git a/docker/php-apache/alpine-3-php7 b/docker/php-apache/alpine-3-php7 new file mode 120000 index 000000000..a5e678cb6 --- /dev/null +++ b/docker/php-apache/alpine-3-php7 @@ -0,0 +1 @@ +alpine-php7 \ No newline at end of file diff --git a/docker/php-apache/alpine-3-php7/Dockerfile b/docker/php-apache/alpine-3-php7/Dockerfile deleted file mode 100644 index 693dbec9b..000000000 --- a/docker/php-apache/alpine-3-php7/Dockerfile +++ /dev/null @@ -1,34 +0,0 @@ -#+++++++++++++++++++++++++++++++++++++++ -# Dockerfile for webdevops/php-apache:alpine-3-php7 -# -- automatically generated -- -#+++++++++++++++++++++++++++++++++++++++ - -FROM webdevops/php:alpine-3-php7 - -MAINTAINER info@webdevops.io -LABEL vendor=WebDevOps.io -LABEL io.webdevops.layout=8 -LABEL io.webdevops.version=1.5.0 - -ENV WEB_DOCUMENT_ROOT /app -ENV WEB_DOCUMENT_INDEX index.php -ENV WEB_ALIAS_DOMAIN *.vm -ENV WEB_PHP_SOCKET 127.0.0.1:9000 - -COPY conf/ /opt/docker/ - -# Install apache -RUN /usr/local/bin/apk-install \ - apache2 \ - apache2-utils \ - apache2-proxy \ - apache2-ssl \ - && sed -ri ' \ - s!^(\s*CustomLog)\s+\S+!\1 /proc/self/fd/1!g; \ - s!^(\s*ErrorLog)\s+\S+!\1 /proc/self/fd/2!g; \ - ' /etc/apache2/httpd.conf \ - && /opt/docker/bin/provision run --tag bootstrap --role webdevops-apache --role webdevops-php-apache \ - && /opt/docker/bin/bootstrap.sh - - -EXPOSE 80 443 diff --git a/docker/php-apache/alpine-3-php7/Dockerfile.jinja2 b/docker/php-apache/alpine-3-php7/Dockerfile.jinja2 deleted file mode 100644 index b740ac1d9..000000000 --- a/docker/php-apache/alpine-3-php7/Dockerfile.jinja2 +++ /dev/null @@ -1,12 +0,0 @@ -{{ docker.from("php", "alpine-3-php7") }} - -{{ docker.version() }} - -{{ environment.web() }} -{{ environment.webPhp() }} - -{{ docker.copy('conf/', '/opt/docker/') }} - -{{ apache.alpine('php-apache') }} - -{{ docker.expose('80 443') }} diff --git a/docker/php-apache/alpine-3-php7/conf/bin/service.d/httpd.d/10-init.sh b/docker/php-apache/alpine-3-php7/conf/bin/service.d/httpd.d/10-init.sh deleted file mode 100644 index d3f1a0c9c..000000000 --- a/docker/php-apache/alpine-3-php7/conf/bin/service.d/httpd.d/10-init.sh +++ /dev/null @@ -1,19 +0,0 @@ -if [[ ! -e "$WEB_DOCUMENT_ROOT" ]]; then - echo "" - echo "[WARNING] WEB_DOCUMENT_ROOT does not exists with path \"$WEB_DOCUMENT_ROOT\"!" - echo "" -fi - -# Replace markers -find /opt/docker/etc/httpd/ -iname '*.conf' -print0 | xargs -0 -r rpl --quiet "" "$WEB_DOCUMENT_INDEX" > /dev/null -find /opt/docker/etc/httpd/ -iname '*.conf' -print0 | xargs -0 -r rpl --quiet "" "$WEB_DOCUMENT_ROOT" > /dev/null -find /opt/docker/etc/httpd/ -iname '*.conf' -print0 | xargs -0 -r rpl --quiet "" "$WEB_ALIAS_DOMAIN" > /dev/null -find /opt/docker/etc/httpd/ -iname '*.conf' -print0 | xargs -0 -r rpl --quiet "" "$HOSTNAME" > /dev/null - -if [[ -n "${WEB_PHP_SOCKET+x}" ]]; then - ## WEB_PHP_SOCKET is set - find /opt/docker/etc/httpd/ -iname '*.conf' -print0 | xargs -0 -r rpl --quiet "" "$WEB_PHP_SOCKET" > /dev/null -else - ## WEB_PHP_SOCKET is not set, remove PHP files - rm -f -- /opt/docker/etc/httpd/conf.d/10-php.conf -fi diff --git a/docker/php-apache/alpine-3-php7/conf/etc/httpd/conf.d/10-log.conf b/docker/php-apache/alpine-3-php7/conf/etc/httpd/conf.d/10-log.conf deleted file mode 100644 index e4c4be4f2..000000000 --- a/docker/php-apache/alpine-3-php7/conf/etc/httpd/conf.d/10-log.conf +++ /dev/null @@ -1,4 +0,0 @@ -LogFormat "[httpd:access] %V:%p %h %l %u %t \"%r\" %>s bytesIn:%I bytesOut:%O reqTime:%T" dockerlog -LogLevel warn -CustomLog /proc/self/fd/1 dockerlog -ErrorLog /proc/self/fd/2 diff --git a/docker/php-apache/alpine-3-php7/conf/provision/roles/webdevops-apache/tasks/bootstrap.yml b/docker/php-apache/alpine-3-php7/conf/provision/roles/webdevops-apache/tasks/bootstrap.yml deleted file mode 100644 index 2be18b0e0..000000000 --- a/docker/php-apache/alpine-3-php7/conf/provision/roles/webdevops-apache/tasks/bootstrap.yml +++ /dev/null @@ -1,156 +0,0 @@ ---- - -- name: Set apache vhost file [RedHat family] - set_fact: - apache_main_path: /etc/httpd/ - apache_docker_vhost: /etc/httpd/conf.d/zzz-docker.conf - when: ansible_os_family == 'RedHat' - -- name: Set apache vhost file [Debian family] - set_fact: - apache_main_path: /etc/apache2/ - apache_docker_vhost: /etc/apache2/sites-enabled/10-docker.conf - when: ansible_os_family == 'Debian' - -- name: Set apache vhost file [Alpine family] - set_fact: - apache_main_path: /etc/apache2/ - apache_docker_vhost: /etc/apache2/conf.d/zzz-docker.conf - when: ansible_os_family == 'Alpine' - -- name: Enable apache main config - file: - src: '/opt/docker/etc/httpd/main.conf' - dest: '{{ apache_docker_vhost }}' - state: link - force: yes - -- name: Ensure document root is available - file: - path: "{{ DOCUMENT_ROOT }}" - state: directory - recurse: yes - -- name: Ensure /var/run/apache2 exists - file: - path: '/var/run/apache2' - state: directory - recurse: yes - -- name: Ensure /run/apache2 exists - file: - path: '/run/apache2' - state: directory - recurse: yes - when: ansible_os_family == 'Alpine' - -- name: Find apache2 files - shell: "find '{{ apache_main_path }}' -type f -iname '*.conf' -o -iname 'default*' -o -iname '*log'" - register: apache2_conf_files - -- name: Change CustomLog to Docker stdout - replace: - dest: '{{ item }}' - regexp: '^[\s]*CustomLog ([^\s]+)(.*)' - replace: 'CustomLog /docker.stdout \2' - with_items: "{{ apache2_conf_files.stdout_lines }}" - -- name: Change CustomLog to Docker stdout - replace: - dest: '{{ item }}' - regexp: '^[\s]*ErrorLog ([^\s]+)(.*)' - replace: 'ErrorLog /docker.stdout \2' - with_items: "{{ apache2_conf_files.stdout_lines }}" - -- name: Change TransferLog to Docker stdout - replace: - dest: '{{ item }}' - regexp: '^[\s]*TransferLog ([^\s]+)(.*)' - replace: 'TransferLog /docker.stdout \2' - with_items: "{{ apache2_conf_files.stdout_lines }}" - -- name: Switch MPM to worker [RedHat family] - lineinfile: - dest: '/etc/httpd/conf.modules.d/00-mpm.conf' - regexp: '^[\s#]*{{ item.line }}' - line: '{{ item.prefix }}{{ item.line }}' - with_items: - - { line: 'LoadModule mpm_prefork_module modules/mod_mpm_prefork.so', prefix: "#" } - - { line: 'LoadModule mpm_event_module modules/mod_mpm_event.so', prefix: "" } - when: ansible_os_family == 'RedHat' - -- name: Switch MPM to event for Apache 2.4 and higher [Ubuntu family] - command: "{{ item }}" - with_items: - - 'a2dismod mpm_event' - - 'a2enmod mpm_event' - when: (ansible_distribution == 'Ubuntu' and ansible_lsb.major_release|int >= 14) or (ansible_distribution == 'Debian' and ansible_lsb.major_release|int >= 8) - -- name: Manage modules [Alpine family] - lineinfile: - dest: '/etc/apache2/httpd.conf' - regexp: '^[\s#]*{{ item.line }}' - line: '{{ item.prefix }}{{ item.line }}' - with_items: - - { line: 'LoadModule mpm_prefork_module modules/mod_mpm_prefork.so', prefix: "#" } - - { line: 'LoadModule mpm_event_module modules/mod_mpm_event.so', prefix: "" } - - { line: 'LoadModule deflate_module modules/mod_deflate.so', prefix: "" } - - { line: 'LoadModule rewrite_module modules/mod_rewrite.so', prefix: "" } - - { line: 'LoadModule logio_module modules/mod_logio.so', prefix: "" } - - { line: 'LoadModule slotmem_shm_module modules/mod_slotmem_shm.so', prefix: "" } - - { line: 'LoadModule actions_module modules/mod_actions.so', prefix: "" } - - { line: 'LoadModule expires_module modules/mod_expires.so', prefix: "" } - when: ansible_os_family == 'Alpine' - -- name: Fix ssl support [Alpine family] - lineinfile: - dest: '/etc/apache2/conf.d/ssl.conf' - regexp: '{{ item.regexp }}' - line: '{{ item.line }}' - with_items: - - { regexp: 'LoadModule ssl_module', line: 'LoadModule ssl_module /usr/lib/apache2/mod_ssl.so' } - - { regexp: 'LoadModule socache_shmcb_module', line: 'LoadModule socache_shmcb_module /usr/lib/apache2/mod_socache_shmcb.so' } - when: ansible_os_family == 'Alpine' - -- name: Remove default vhost from ssl configuration [Alpine family] - command: sed -i -e '1h;2,$H;$!d;g' -e 's//#-> removed vhost/g' /etc/apache2/conf.d/ssl.conf - when: ansible_os_family == 'Alpine' - -- name: Disable proxy [Alpine family] - lineinfile: - dest: '/etc/apache2/conf.d/proxy.conf' - regexp: '^[\s#]*{{ item.line }}' - line: '{{ item.prefix }}{{ item.line }}' - with_items: - - { line: 'LoadModule proxy_ajp_module modules/mod_proxy_ajp.so', prefix: "#" } - - { line: 'LoadModule proxy_connect_module modules/mod_proxy_connect.so', prefix: "#" } - - { line: 'LoadModule proxy_balancer_module modules/mod_proxy_balancer.so', prefix: "#" } - - { line: 'LoadModule proxy_express_module modules/mod_proxy_express.so', prefix: "#" } - - { line: 'LoadModule proxy_fcgi_module modules/mod_proxy_fcgi.so', prefix: "" } - - { line: 'LoadModule proxy_fdpass_module modules/mod_proxy_fdpass.so', prefix: "#" } - - { line: 'LoadModule proxy_ftp_module modules/mod_proxy_ftp.so', prefix: "#" } - - { line: 'LoadModule proxy_http_module modules/mod_proxy_http.so', prefix: "#" } - - { line: 'LoadModule proxy_scgi_module modules/mod_proxy_scgi.so', prefix: "#" } - when: ansible_os_family == 'Alpine' - -- name: Fix rights of ssl files - file: - path: "{{ item.path }}" - state: "{{ item.state }}" - mode: "{{ item.mode }}" - owner: "root" - group: "root" - with_items: - - { path: '/opt/docker/etc/httpd/ssl', state: 'directory', mode: '0750' } - - { path: '/opt/docker/etc/httpd/ssl/server.crt', state: 'file', mode: '0640' } - - { path: '/opt/docker/etc/httpd/ssl/server.csr', state: 'file', mode: '0640' } - - { path: '/opt/docker/etc/httpd/ssl/server.key', state: 'file', mode: '0640' } - -- name: Maintain lock directory [Debian family] - file: - path: "/var/lock/apache2" - state: "directory" - mode: "0750" - owner: "www-data" - group: "www-data" - when: ansible_os_family == 'Debian' diff --git a/docker/php-apache/alpine-3/Dockerfile b/docker/php-apache/alpine-3/Dockerfile deleted file mode 100644 index 499a227a5..000000000 --- a/docker/php-apache/alpine-3/Dockerfile +++ /dev/null @@ -1,34 +0,0 @@ -#+++++++++++++++++++++++++++++++++++++++ -# Dockerfile for webdevops/php-apache:alpine-3 -# -- automatically generated -- -#+++++++++++++++++++++++++++++++++++++++ - -FROM webdevops/php:alpine-3 - -MAINTAINER info@webdevops.io -LABEL vendor=WebDevOps.io -LABEL io.webdevops.layout=8 -LABEL io.webdevops.version=1.5.0 - -ENV WEB_DOCUMENT_ROOT /app -ENV WEB_DOCUMENT_INDEX index.php -ENV WEB_ALIAS_DOMAIN *.vm -ENV WEB_PHP_SOCKET 127.0.0.1:9000 - -COPY conf/ /opt/docker/ - -# Install apache -RUN /usr/local/bin/apk-install \ - apache2 \ - apache2-utils \ - apache2-proxy \ - apache2-ssl \ - && sed -ri ' \ - s!^(\s*CustomLog)\s+\S+!\1 /proc/self/fd/1!g; \ - s!^(\s*ErrorLog)\s+\S+!\1 /proc/self/fd/2!g; \ - ' /etc/apache2/httpd.conf \ - && /opt/docker/bin/provision run --tag bootstrap --role webdevops-apache --role webdevops-php-apache \ - && /opt/docker/bin/bootstrap.sh - - -EXPOSE 80 443 diff --git a/docker/php-apache/alpine-3/Dockerfile.jinja2 b/docker/php-apache/alpine-3/Dockerfile.jinja2 deleted file mode 100644 index d1dd382b4..000000000 --- a/docker/php-apache/alpine-3/Dockerfile.jinja2 +++ /dev/null @@ -1,12 +0,0 @@ -{{ docker.from("php", "alpine-3") }} - -{{ docker.version() }} - -{{ environment.web() }} -{{ environment.webPhp() }} - -{{ docker.copy('conf/', '/opt/docker/') }} - -{{ apache.alpine('php-apache') }} - -{{ docker.expose('80 443') }} diff --git a/docker/php-apache/alpine-3/conf/bin/service.d/httpd.d/10-init.sh b/docker/php-apache/alpine-3/conf/bin/service.d/httpd.d/10-init.sh deleted file mode 100644 index d3f1a0c9c..000000000 --- a/docker/php-apache/alpine-3/conf/bin/service.d/httpd.d/10-init.sh +++ /dev/null @@ -1,19 +0,0 @@ -if [[ ! -e "$WEB_DOCUMENT_ROOT" ]]; then - echo "" - echo "[WARNING] WEB_DOCUMENT_ROOT does not exists with path \"$WEB_DOCUMENT_ROOT\"!" - echo "" -fi - -# Replace markers -find /opt/docker/etc/httpd/ -iname '*.conf' -print0 | xargs -0 -r rpl --quiet "" "$WEB_DOCUMENT_INDEX" > /dev/null -find /opt/docker/etc/httpd/ -iname '*.conf' -print0 | xargs -0 -r rpl --quiet "" "$WEB_DOCUMENT_ROOT" > /dev/null -find /opt/docker/etc/httpd/ -iname '*.conf' -print0 | xargs -0 -r rpl --quiet "" "$WEB_ALIAS_DOMAIN" > /dev/null -find /opt/docker/etc/httpd/ -iname '*.conf' -print0 | xargs -0 -r rpl --quiet "" "$HOSTNAME" > /dev/null - -if [[ -n "${WEB_PHP_SOCKET+x}" ]]; then - ## WEB_PHP_SOCKET is set - find /opt/docker/etc/httpd/ -iname '*.conf' -print0 | xargs -0 -r rpl --quiet "" "$WEB_PHP_SOCKET" > /dev/null -else - ## WEB_PHP_SOCKET is not set, remove PHP files - rm -f -- /opt/docker/etc/httpd/conf.d/10-php.conf -fi diff --git a/docker/php-apache/alpine-3/conf/etc/httpd/conf.d/10-log.conf b/docker/php-apache/alpine-3/conf/etc/httpd/conf.d/10-log.conf deleted file mode 100644 index e4c4be4f2..000000000 --- a/docker/php-apache/alpine-3/conf/etc/httpd/conf.d/10-log.conf +++ /dev/null @@ -1,4 +0,0 @@ -LogFormat "[httpd:access] %V:%p %h %l %u %t \"%r\" %>s bytesIn:%I bytesOut:%O reqTime:%T" dockerlog -LogLevel warn -CustomLog /proc/self/fd/1 dockerlog -ErrorLog /proc/self/fd/2 diff --git a/docker/php-apache/alpine-3/conf/provision/roles/webdevops-apache/tasks/bootstrap.yml b/docker/php-apache/alpine-3/conf/provision/roles/webdevops-apache/tasks/bootstrap.yml deleted file mode 100644 index 2be18b0e0..000000000 --- a/docker/php-apache/alpine-3/conf/provision/roles/webdevops-apache/tasks/bootstrap.yml +++ /dev/null @@ -1,156 +0,0 @@ ---- - -- name: Set apache vhost file [RedHat family] - set_fact: - apache_main_path: /etc/httpd/ - apache_docker_vhost: /etc/httpd/conf.d/zzz-docker.conf - when: ansible_os_family == 'RedHat' - -- name: Set apache vhost file [Debian family] - set_fact: - apache_main_path: /etc/apache2/ - apache_docker_vhost: /etc/apache2/sites-enabled/10-docker.conf - when: ansible_os_family == 'Debian' - -- name: Set apache vhost file [Alpine family] - set_fact: - apache_main_path: /etc/apache2/ - apache_docker_vhost: /etc/apache2/conf.d/zzz-docker.conf - when: ansible_os_family == 'Alpine' - -- name: Enable apache main config - file: - src: '/opt/docker/etc/httpd/main.conf' - dest: '{{ apache_docker_vhost }}' - state: link - force: yes - -- name: Ensure document root is available - file: - path: "{{ DOCUMENT_ROOT }}" - state: directory - recurse: yes - -- name: Ensure /var/run/apache2 exists - file: - path: '/var/run/apache2' - state: directory - recurse: yes - -- name: Ensure /run/apache2 exists - file: - path: '/run/apache2' - state: directory - recurse: yes - when: ansible_os_family == 'Alpine' - -- name: Find apache2 files - shell: "find '{{ apache_main_path }}' -type f -iname '*.conf' -o -iname 'default*' -o -iname '*log'" - register: apache2_conf_files - -- name: Change CustomLog to Docker stdout - replace: - dest: '{{ item }}' - regexp: '^[\s]*CustomLog ([^\s]+)(.*)' - replace: 'CustomLog /docker.stdout \2' - with_items: "{{ apache2_conf_files.stdout_lines }}" - -- name: Change CustomLog to Docker stdout - replace: - dest: '{{ item }}' - regexp: '^[\s]*ErrorLog ([^\s]+)(.*)' - replace: 'ErrorLog /docker.stdout \2' - with_items: "{{ apache2_conf_files.stdout_lines }}" - -- name: Change TransferLog to Docker stdout - replace: - dest: '{{ item }}' - regexp: '^[\s]*TransferLog ([^\s]+)(.*)' - replace: 'TransferLog /docker.stdout \2' - with_items: "{{ apache2_conf_files.stdout_lines }}" - -- name: Switch MPM to worker [RedHat family] - lineinfile: - dest: '/etc/httpd/conf.modules.d/00-mpm.conf' - regexp: '^[\s#]*{{ item.line }}' - line: '{{ item.prefix }}{{ item.line }}' - with_items: - - { line: 'LoadModule mpm_prefork_module modules/mod_mpm_prefork.so', prefix: "#" } - - { line: 'LoadModule mpm_event_module modules/mod_mpm_event.so', prefix: "" } - when: ansible_os_family == 'RedHat' - -- name: Switch MPM to event for Apache 2.4 and higher [Ubuntu family] - command: "{{ item }}" - with_items: - - 'a2dismod mpm_event' - - 'a2enmod mpm_event' - when: (ansible_distribution == 'Ubuntu' and ansible_lsb.major_release|int >= 14) or (ansible_distribution == 'Debian' and ansible_lsb.major_release|int >= 8) - -- name: Manage modules [Alpine family] - lineinfile: - dest: '/etc/apache2/httpd.conf' - regexp: '^[\s#]*{{ item.line }}' - line: '{{ item.prefix }}{{ item.line }}' - with_items: - - { line: 'LoadModule mpm_prefork_module modules/mod_mpm_prefork.so', prefix: "#" } - - { line: 'LoadModule mpm_event_module modules/mod_mpm_event.so', prefix: "" } - - { line: 'LoadModule deflate_module modules/mod_deflate.so', prefix: "" } - - { line: 'LoadModule rewrite_module modules/mod_rewrite.so', prefix: "" } - - { line: 'LoadModule logio_module modules/mod_logio.so', prefix: "" } - - { line: 'LoadModule slotmem_shm_module modules/mod_slotmem_shm.so', prefix: "" } - - { line: 'LoadModule actions_module modules/mod_actions.so', prefix: "" } - - { line: 'LoadModule expires_module modules/mod_expires.so', prefix: "" } - when: ansible_os_family == 'Alpine' - -- name: Fix ssl support [Alpine family] - lineinfile: - dest: '/etc/apache2/conf.d/ssl.conf' - regexp: '{{ item.regexp }}' - line: '{{ item.line }}' - with_items: - - { regexp: 'LoadModule ssl_module', line: 'LoadModule ssl_module /usr/lib/apache2/mod_ssl.so' } - - { regexp: 'LoadModule socache_shmcb_module', line: 'LoadModule socache_shmcb_module /usr/lib/apache2/mod_socache_shmcb.so' } - when: ansible_os_family == 'Alpine' - -- name: Remove default vhost from ssl configuration [Alpine family] - command: sed -i -e '1h;2,$H;$!d;g' -e 's//#-> removed vhost/g' /etc/apache2/conf.d/ssl.conf - when: ansible_os_family == 'Alpine' - -- name: Disable proxy [Alpine family] - lineinfile: - dest: '/etc/apache2/conf.d/proxy.conf' - regexp: '^[\s#]*{{ item.line }}' - line: '{{ item.prefix }}{{ item.line }}' - with_items: - - { line: 'LoadModule proxy_ajp_module modules/mod_proxy_ajp.so', prefix: "#" } - - { line: 'LoadModule proxy_connect_module modules/mod_proxy_connect.so', prefix: "#" } - - { line: 'LoadModule proxy_balancer_module modules/mod_proxy_balancer.so', prefix: "#" } - - { line: 'LoadModule proxy_express_module modules/mod_proxy_express.so', prefix: "#" } - - { line: 'LoadModule proxy_fcgi_module modules/mod_proxy_fcgi.so', prefix: "" } - - { line: 'LoadModule proxy_fdpass_module modules/mod_proxy_fdpass.so', prefix: "#" } - - { line: 'LoadModule proxy_ftp_module modules/mod_proxy_ftp.so', prefix: "#" } - - { line: 'LoadModule proxy_http_module modules/mod_proxy_http.so', prefix: "#" } - - { line: 'LoadModule proxy_scgi_module modules/mod_proxy_scgi.so', prefix: "#" } - when: ansible_os_family == 'Alpine' - -- name: Fix rights of ssl files - file: - path: "{{ item.path }}" - state: "{{ item.state }}" - mode: "{{ item.mode }}" - owner: "root" - group: "root" - with_items: - - { path: '/opt/docker/etc/httpd/ssl', state: 'directory', mode: '0750' } - - { path: '/opt/docker/etc/httpd/ssl/server.crt', state: 'file', mode: '0640' } - - { path: '/opt/docker/etc/httpd/ssl/server.csr', state: 'file', mode: '0640' } - - { path: '/opt/docker/etc/httpd/ssl/server.key', state: 'file', mode: '0640' } - -- name: Maintain lock directory [Debian family] - file: - path: "/var/lock/apache2" - state: "directory" - mode: "0750" - owner: "www-data" - group: "www-data" - when: ansible_os_family == 'Debian' diff --git a/docker/php-apache/alpine-php5/Dockerfile b/docker/php-apache/alpine-php5/Dockerfile new file mode 100644 index 000000000..6d18e6a6f --- /dev/null +++ b/docker/php-apache/alpine-php5/Dockerfile @@ -0,0 +1,29 @@ +#+++++++++++++++++++++++++++++++++++++++ +# Dockerfile for webdevops/php-apache:alpine-php5 +# -- automatically generated -- +#+++++++++++++++++++++++++++++++++++++++ + +FROM webdevops/php:alpine-php5 + +ENV WEB_DOCUMENT_ROOT=/app \ + WEB_DOCUMENT_INDEX=index.php \ + WEB_ALIAS_DOMAIN=*.vm +ENV WEB_PHP_SOCKET=127.0.0.1:9000 + +COPY conf/ /opt/docker/ + +# Install apache +RUN /usr/local/bin/apk-install \ + apache2 \ + apache2-utils \ + apache2-proxy \ + apache2-ssl \ + && sed -ri ' \ + s!^(\s*CustomLog)\s+\S+!\1 /proc/self/fd/1!g; \ + s!^(\s*ErrorLog)\s+\S+!\1 /proc/self/fd/2!g; \ + ' /etc/apache2/httpd.conf \ + && /opt/docker/bin/provision run --tag bootstrap --role webdevops-apache --role webdevops-php-apache \ + && /opt/docker/bin/bootstrap.sh \ + && docker-image-cleanup + +EXPOSE 80 443 diff --git a/docker/php-apache/alpine-php5/Dockerfile.jinja2 b/docker/php-apache/alpine-php5/Dockerfile.jinja2 new file mode 100644 index 000000000..687d88290 --- /dev/null +++ b/docker/php-apache/alpine-php5/Dockerfile.jinja2 @@ -0,0 +1,10 @@ +{{ docker.from("php", "alpine-php5") }} + +{{ environment.web() }} +{{ environment.webPhp() }} + +{{ docker.copy('conf/', '/opt/docker/') }} + +{{ apache.alpine('php-apache') }} + +{{ docker.expose('80 443') }} diff --git a/docker/php-apache/alpine-php5/conf/bin/service.d/httpd.d/10-init.sh b/docker/php-apache/alpine-php5/conf/bin/service.d/httpd.d/10-init.sh new file mode 100644 index 000000000..b9d57997e --- /dev/null +++ b/docker/php-apache/alpine-php5/conf/bin/service.d/httpd.d/10-init.sh @@ -0,0 +1,21 @@ +if [[ ! -e "$WEB_DOCUMENT_ROOT" ]]; then + echo "" + echo "[WARNING] WEB_DOCUMENT_ROOT does not exists with path \"$WEB_DOCUMENT_ROOT\"!" + echo "" +fi + +# Replace markers +go-replace \ + -s "" -r "$WEB_DOCUMENT_INDEX" \ + -s "" -r "$WEB_DOCUMENT_ROOT" \ + -s "" -r "$WEB_ALIAS_DOMAIN" \ + -s "" -r "$HOSTNAME" \ + -s "" -r "$WEB_PHP_SOCKET" \ + --path=/opt/docker/etc/httpd/ \ + --path-pattern='*.conf' \ + --ignore-empty + +if [[ -z "${WEB_PHP_SOCKET+x}" ]]; then + ## WEB_PHP_SOCKET is not set, remove PHP files + rm -f -- /opt/docker/etc/httpd/conf.d/10-php.conf +fi diff --git a/docker/php-apache/alpine-3-php7/conf/bin/service.d/httpd.sh b/docker/php-apache/alpine-php5/conf/bin/service.d/httpd.sh similarity index 100% rename from docker/php-apache/alpine-3-php7/conf/bin/service.d/httpd.sh rename to docker/php-apache/alpine-php5/conf/bin/service.d/httpd.sh diff --git a/docker/php-apache/alpine-php5/conf/etc/httpd/conf.d/.gitkeep b/docker/php-apache/alpine-php5/conf/etc/httpd/conf.d/.gitkeep new file mode 100644 index 000000000..e69de29bb diff --git a/docker/php-apache/alpine-php5/conf/etc/httpd/conf.d/10-error-document.conf b/docker/php-apache/alpine-php5/conf/etc/httpd/conf.d/10-error-document.conf new file mode 100644 index 000000000..ebabf87e4 --- /dev/null +++ b/docker/php-apache/alpine-php5/conf/etc/httpd/conf.d/10-error-document.conf @@ -0,0 +1,15 @@ +####################################### +# Faster error documents +####################################### + + ErrorDocument 400 "400 Bad Request" + ErrorDocument 401 "401 Unauthorized" + ErrorDocument 403 "403 Forbidden" + ErrorDocument 404 "404 Not Found" + ErrorDocument 405 "405 Method Not Allowed" + + ErrorDocument 500 "500 Internal Server Error" + ErrorDocument 501 "501 Not Implemented" + ErrorDocument 502 "502 Bad Gateway" + ErrorDocument 503 "503 Service Unavailable" + diff --git a/docker/php-apache/alpine-php5/conf/etc/httpd/conf.d/10-log.conf b/docker/php-apache/alpine-php5/conf/etc/httpd/conf.d/10-log.conf new file mode 100644 index 000000000..ef0c73d38 --- /dev/null +++ b/docker/php-apache/alpine-php5/conf/etc/httpd/conf.d/10-log.conf @@ -0,0 +1,4 @@ +LogFormat "[httpd:access] %V:%p %h %l %u %t \"%r\" %>s bytesIn:%I bytesOut:%O reqTime:%T" dockerlog +LogLevel warn +CustomLog /docker.stdout dockerlog +ErrorLog /docker.stderr diff --git a/docker/php-apache/alpine-php5/conf/etc/httpd/conf.d/10-php.conf b/docker/php-apache/alpine-php5/conf/etc/httpd/conf.d/10-php.conf new file mode 100644 index 000000000..4368d12ef --- /dev/null +++ b/docker/php-apache/alpine-php5/conf/etc/httpd/conf.d/10-php.conf @@ -0,0 +1,37 @@ +############################# +# mod_proxy_fcgi +# official solution +# apache 2.4 and later +############################# + + + > + ProxySet connectiontimeout=5 timeout=600 + + + + SetHandler "proxy:fcgi://" + + + +############################# +# mod_fastcgi +# apaache 2.2 and 2.4 +############################# + + + AddHandler php-fcgi .php + Action php-fcgi /php-fcgi + Alias /php-fcgi /usr/lib/cgi-bin/php-fcgi + FastCgiExternalServer /usr/lib/cgi-bin/php-fcgi -host "" -pass-header Authorization -idle-timeout 600 + + + + Allow from all + + = 2.4> + Require all granted + + + + diff --git a/docker/php-apache/alpine-php5/conf/etc/httpd/conf.d/10-server.conf b/docker/php-apache/alpine-php5/conf/etc/httpd/conf.d/10-server.conf new file mode 100644 index 000000000..d3a5defbd --- /dev/null +++ b/docker/php-apache/alpine-php5/conf/etc/httpd/conf.d/10-server.conf @@ -0,0 +1,18 @@ +# Settings +TimeOut 1000 +ServerName "" + +DirectoryIndex +DocumentRoot "" + +"> + Options Indexes FollowSymLinks + AllowOverride All + + + Allow from all + + = 2.4> + Require all granted + + diff --git a/docker/php-apache/alpine-php5/conf/etc/httpd/global.conf b/docker/php-apache/alpine-php5/conf/etc/httpd/global.conf new file mode 100644 index 000000000..b6141db09 --- /dev/null +++ b/docker/php-apache/alpine-php5/conf/etc/httpd/global.conf @@ -0,0 +1 @@ +# deprecated diff --git a/docker/php-apache/alpine-php5/conf/etc/httpd/main.conf b/docker/php-apache/alpine-php5/conf/etc/httpd/main.conf new file mode 100644 index 000000000..12251c222 --- /dev/null +++ b/docker/php-apache/alpine-php5/conf/etc/httpd/main.conf @@ -0,0 +1,12 @@ +Include /opt/docker/etc/httpd/global.conf +Include /opt/docker/etc/httpd/php.conf + + + Include /opt/docker/etc/httpd/conf.d/*.conf + += 2.4> + IncludeOptional /opt/docker/etc/httpd/conf.d/*.conf + +Include /opt/docker/etc/httpd/vhost.conf + + diff --git a/docker/php-apache/alpine-php5/conf/etc/httpd/php.conf b/docker/php-apache/alpine-php5/conf/etc/httpd/php.conf new file mode 100644 index 000000000..b6141db09 --- /dev/null +++ b/docker/php-apache/alpine-php5/conf/etc/httpd/php.conf @@ -0,0 +1 @@ +# deprecated diff --git a/docker/php-apache/alpine-php5/conf/etc/httpd/ssl/server.crt b/docker/php-apache/alpine-php5/conf/etc/httpd/ssl/server.crt new file mode 100644 index 000000000..6b0694907 --- /dev/null +++ b/docker/php-apache/alpine-php5/conf/etc/httpd/ssl/server.crt @@ -0,0 +1,28 @@ +-----BEGIN CERTIFICATE----- +MIIE1DCCArwCCQDMMwGnSuK0tTANBgkqhkiG9w0BAQsFADAsMRswGQYDVQQKExJE +b2NrZXIgQm9pbGVycGxhdGUxDTALBgNVBAMUBCoudm0wHhcNMTUwNTA0MTcxNDQw +WhcNMjUwNTAxMTcxNDQwWjAsMRswGQYDVQQKExJEb2NrZXIgQm9pbGVycGxhdGUx +DTALBgNVBAMUBCoudm0wggIiMA0GCSqGSIb3DQEBAQUAA4ICDwAwggIKAoICAQDK +3TIUiyDvXelWeY9VXMrpjuZtYpVSDsACLpjFUhMnsP5/iKT0VbeZyqHvmwZjAg4G +Y10d+yZDdgv/xeu0HPOFbtR6pCp10d1tdLHZto5Cyuxu7IQsAVjnD6Ko7XFwtNk7 +9o6JZfAFaGL4w5MokrVmCtspnsMZH7/7zU4f96cbF39zLopnpuXGD6t6DA8Qj3gy +0duaTjs42bYRN+rwLzVKAev99iQ4kPMJn4vV6/Xk6rtoSzC67GQyVZYaFypicD1S +NtsRmgEVvjCBDbrLOneUiRwff6qxEsZi7Hxv7BKFj4iUWnII7K/nP7T6uBHQjHO+ +FpsGkU9lCMrCeVFBe8kKz/cbhd+yLUxXwAPr6gSOPmwn232Gy4tozvqZHpbUxsgx +7sT3ej9K66h1D7J+BjNFWYM1hbnC1r7H/xS7EBzBV8qRoQCVe08Juf5xsouXFakD +clLV4+L+1cxkpwsCQDly5g3tm/TBqA2O+ZJ+YHQDHKkzMyhLs6i0X/M5qvJBiLg1 +GLTCS20rpQ5gXTEGuINqHgwXQWkUO6bhgSYqdHGX3zbZ5+qWpI4eui3dHZ1Ll0VH +6Icpb7ORTQwhc6W8KBlybssYPSlGOEBGUjYGNheoz9FpoSkxCis+P8ZNKtrmpPoq +Su0eOOGFOFHG02eOgPVxSwrDeN9MVJo7BPysGMHJmQIDAQABMA0GCSqGSIb3DQEB +CwUAA4ICAQC63g6NHmQKbiy3G6iaDkpUSbr5Mq2YgU61XnvWVyREqDcy/BXCw9oY +SJ/KUvCpqPnACNOFqjadRAmPiA9nf2WduoCgwQGV/YRFGswSuVvh/3X2TX5NWvbS +t8MQDttQg1dxpiMUjlu3rqhfohBdWJvp2lVSdpDb/MOlXBc/+p7HfOHwhqB7wwPN +NNbSKUbZqZxmD8cOf1X0hASr1yfFPj+2vST3ESaON8S0T2p63YX/sD5jvOUiEuyw +I5WcvLmiRZA07SH8nWyckLY3qWL+OlhSZrlAnolWS00b+7h5LNuRYEjKzwVgntoA +aCopyQih6wIk0+AfJO4sfhJBmQhnIrAaP/zwBH5g9zVizLf5H7U+hNXrMwgw55Sq +vjMdkZHvPKUXTvVit/rYE9H+PY3brkRWzOl4V/i/ZLJJm5805H/NyTbz9kPMJw2Q +nn+KOpfXXySD39f8iuRgSKXsYNul38hxWgcZZ6g+sOOp2n/VUmf0eZUWNnJ8i7AP +4Qif7aDKMcibOwSwsB+DKZXDvZ5XSdnMphtuLS5rPSL81rVRmWC2DMfQ2eP8j0WN +VTroSk0xedQ7Qr+9TNooi9IyzX6n1a2S1UiciEZ3ZcDbXPl/P01m+IYZyPnLv0+9 +ZeioZYh1JLv3/OKsMrMLTfh2ZCj3aXwmc2Owi/wU2LS5QUOMcHH7CQ== +-----END CERTIFICATE----- \ No newline at end of file diff --git a/docker/php-apache/alpine-php5/conf/etc/httpd/ssl/server.csr b/docker/php-apache/alpine-php5/conf/etc/httpd/ssl/server.csr new file mode 100644 index 000000000..8a9909f77 --- /dev/null +++ b/docker/php-apache/alpine-php5/conf/etc/httpd/ssl/server.csr @@ -0,0 +1,26 @@ +-----BEGIN CERTIFICATE REQUEST----- +MIIEcTCCAlkCAQAwLDEbMBkGA1UEChMSRG9ja2VyIEJvaWxlcnBsYXRlMQ0wCwYD +VQQDFAQqLnZtMIICIjANBgkqhkiG9w0BAQEFAAOCAg8AMIICCgKCAgEAyt0yFIsg +713pVnmPVVzK6Y7mbWKVUg7AAi6YxVITJ7D+f4ik9FW3mcqh75sGYwIOBmNdHfsm +Q3YL/8XrtBzzhW7UeqQqddHdbXSx2baOQsrsbuyELAFY5w+iqO1xcLTZO/aOiWXw +BWhi+MOTKJK1ZgrbKZ7DGR+/+81OH/enGxd/cy6KZ6blxg+regwPEI94MtHbmk47 +ONm2ETfq8C81SgHr/fYkOJDzCZ+L1ev15Oq7aEswuuxkMlWWGhcqYnA9UjbbEZoB +Fb4wgQ26yzp3lIkcH3+qsRLGYux8b+wShY+IlFpyCOyv5z+0+rgR0IxzvhabBpFP +ZQjKwnlRQXvJCs/3G4Xfsi1MV8AD6+oEjj5sJ9t9hsuLaM76mR6W1MbIMe7E93o/ +SuuodQ+yfgYzRVmDNYW5wta+x/8UuxAcwVfKkaEAlXtPCbn+cbKLlxWpA3JS1ePi +/tXMZKcLAkA5cuYN7Zv0wagNjvmSfmB0AxypMzMoS7OotF/zOaryQYi4NRi0wktt +K6UOYF0xBriDah4MF0FpFDum4YEmKnRxl9822efqlqSOHrot3R2dS5dFR+iHKW+z +kU0MIXOlvCgZcm7LGD0pRjhARlI2BjYXqM/RaaEpMQorPj/GTSra5qT6KkrtHjjh +hThRxtNnjoD1cUsKw3jfTFSaOwT8rBjByZkCAwEAAaAAMA0GCSqGSIb3DQEBCwUA +A4ICAQBsEBgC2YepuZq/8UqvKMZKVy/etDKXj7BB+QPb+leNiKD7p4LDxHJsZSH8 +Ku9uMPeLfiQDn5jA41k5SlGttzvObd65RdEbO3yHpqsg05EGSDDLfaE1k2Al/qmX +/o8roPZF7+2kZthgMAgkcokS54LYqEYTGqOf3J9Ss0yRIZwhaOVebfFIbIOdpw0B +JNMIJPHTMdZrcuRVI+wR1uPLIlEJzBvxTGbTrvPU25WJFtu+EajKqXO0SHdy0yx8 +uH4ykRBJRc36+oYo7nZ5D56dh7pZn3+9J64FKAOV0Q3KqMFieGy053ezuhJd70eZ +UozTgfjs3WpMzoYmKETSyl3XZSdInRe+sUlKPruTsKyg69oYxjPlrGfAmmGcCFca +TnZinT18dI92zK7OtOVkmYeYKC1lwuhftVrNMXzZuHOGpS9NNYtc4nDqDMIEOfV3 +6rCdu03WjEgJ+Z67tJs16xOx9du4/EHxS2Ijn9DPfVJvYy0TgzDi1BUpjWx0KTLx +C4OQbEZ/QTWmHVbSch/hcZhzbf7SNh5RpnW4EtmcpDFjIKMfxJmoKeiTf7qnilx0 +7uRvsZFKoDKRDOFiPfgMg5AOtLHziYsd9m0tJjC2GHvFuPjzOtzhnUUjmmvht170 +2aqKakjST4amg7jzLcs871HX0/WjOtt29NpOz140blkKf1bisg== +-----END CERTIFICATE REQUEST----- \ No newline at end of file diff --git a/docker/php-apache/alpine-php5/conf/etc/httpd/ssl/server.key b/docker/php-apache/alpine-php5/conf/etc/httpd/ssl/server.key new file mode 100644 index 000000000..c9eec145f --- /dev/null +++ b/docker/php-apache/alpine-php5/conf/etc/httpd/ssl/server.key @@ -0,0 +1,51 @@ +-----BEGIN RSA PRIVATE KEY----- +MIIJKAIBAAKCAgEAyt0yFIsg713pVnmPVVzK6Y7mbWKVUg7AAi6YxVITJ7D+f4ik +9FW3mcqh75sGYwIOBmNdHfsmQ3YL/8XrtBzzhW7UeqQqddHdbXSx2baOQsrsbuyE +LAFY5w+iqO1xcLTZO/aOiWXwBWhi+MOTKJK1ZgrbKZ7DGR+/+81OH/enGxd/cy6K +Z6blxg+regwPEI94MtHbmk47ONm2ETfq8C81SgHr/fYkOJDzCZ+L1ev15Oq7aEsw +uuxkMlWWGhcqYnA9UjbbEZoBFb4wgQ26yzp3lIkcH3+qsRLGYux8b+wShY+IlFpy +COyv5z+0+rgR0IxzvhabBpFPZQjKwnlRQXvJCs/3G4Xfsi1MV8AD6+oEjj5sJ9t9 +hsuLaM76mR6W1MbIMe7E93o/SuuodQ+yfgYzRVmDNYW5wta+x/8UuxAcwVfKkaEA +lXtPCbn+cbKLlxWpA3JS1ePi/tXMZKcLAkA5cuYN7Zv0wagNjvmSfmB0AxypMzMo +S7OotF/zOaryQYi4NRi0wkttK6UOYF0xBriDah4MF0FpFDum4YEmKnRxl9822efq +lqSOHrot3R2dS5dFR+iHKW+zkU0MIXOlvCgZcm7LGD0pRjhARlI2BjYXqM/RaaEp +MQorPj/GTSra5qT6KkrtHjjhhThRxtNnjoD1cUsKw3jfTFSaOwT8rBjByZkCAwEA +AQKCAgAbZPdoUsllyZbC+LNkYZ19ILD5QIDNjfRb1xMGQmkXyQz1B+zOmeyrNfPc +OWEJabOfJTfj3pByN7SzG3US4333HNpQnW6mbmqqZ0HFFqPrXR/Ecuf+UUhCG5hp +m3bgM2vKbyccYsmg0VHcKfzrU7RvTTP/UNMjx2fThwvvwS+ttuSdF0HVcXJB5sfP +OWWnZNhkdHZlRf81VCED/jsZqCZYEh5eMyj9AoXvXL4zayPPf+tC0DSKaXW2Xlxg +tZQhqup8+a9nlxZia0Z9hu8clo6jXkiP8FuKgfCMV0cOjiCKLLHS5svTbLLsVWwJ +F2ZAdVcD6mWQ43qHOEK5NEzGvQKO14CaOLnVT2yAkMcyNohsEgoDP9oCBGDJQbBH +NmtZfpVjjtuTr9P9TEkU1FcBRo0x6Il/DkzamGbOeFAmgnaGElhJ5c/CAG7whaIf +mUfFOBGPH/wESY3gBOACDofeSh27RrlvbLaPiCGKivDUTBmhBsIuso6XqOKbvtfV +/HhhndpdRVfIj4DdE7gIrLIGN977JMVAXFCNz7KrvAWwcOXrCHCoWpklJ9repq8l +26ICY8K7VXktzDHQUmhd88ZWR+9ASURsJghUgZUOcMrEGyvci6Y8hpLhHiNVPHuQ ++ps7tpPsXSntBUqWBzhRZh74+nJlOOV6oYykl30JT2JzB6lwiQKCAQEA9ecn8N2z +20tR2UEiTv/MjVSepQtAAajegvcd1iasvvQKXnh3XLmoZHzH2tTa0lp5RIZpUQPl +lOTwko0lYTBnYblt65AJQ3FTgisNobIpoqE8BFXLm6wggz7CbabjmPGDe173lPGR +sI0YSKYvzrdn4zw8Fh6WULJyZHLi58zJYL3r0WBDiOoxpGaGA1GlmkuIWjhKHaX2 +OvF1vOuQDJ2eDyTc5TYFC0NKG76Mvanov5L/yrhNM/umbmp0SPspzHGZobAKUr20 +OazFT8S+2TA1OTxWNbiPbSimFoaZbEdqsNACGfVJWO8Sh8iqlt5RmEcSiSvGBj6L +QKprRO9Fsp2GawKCAQEA0zGhRsnux4JTNsdUSYsEJtITMj6eE+nl7CoZ9DAOwC5X +6/aSpUE4TT+pWNrt9iluXiGL0j89UJ7r/L1OcsiyzGb8ig9NU4zr1NIGTZ0DstHi +HPYINjeiBJEFIy17kOQn+9/I5c4hBUwz6ihwNoEomymVB/EsLJKAML0AudJGKg+Z +/f/qrS40eab5SAiaKgsh0MZnj+vIxyGBydt6r2HGmjfNITVbXIu6IpO+6NXDwM/e +7v10AAZ3j9+gb1RedLg2ghuIuYU90hmMhtVWsh9nVmaOkMW9/WFgOPYvt/mHH/hR +d4pePZ9kACGmqo/b9sHvHw1YEubtCt1VUiNuFxnJCwKCAQBWnxz0vkRTJY8phsY9 +KeK2jm5sGTBs5T2syLwb6ffENFdKvAjgAw6Mh2And/+1ReWd+/MxdLv03UjZdxsJ +x3FDfXx5FH4O4ebW3a+pnAcKoN1xcX+N0O6LDRqUYcue3sTAOs3gC9CUbr91KAWD +Phw8ccWAzTmKJ7IgLFA982ekyoI9eTmRC159WRgwJxy844qerWF+XC4GyXP+HsTZ +jNRW5Vdi7sqMEyIR7+fIEAhLI88zbATWIPmZv6pC4ybwO7wwtsCMMQNBpdjDprzL +6S12ggikV+U+QKlxGe0FtYqhykRTPJKf32eZqVheWOZJTA/9fgv9ux52oxGycM8O +gmsNAoIBAQC60m5uZnd5uYnPLWkcXYNgq/kbO1UvHHut/FhVMKX7z4MrU0XKNfWO +MECoP5K9bU0aq+Y6KIMe7FapjvT0iSHRu1Cu+HZY8JI2A0xcIAeDijLRl7sP6wrB +q1+2DKgANjRAlWfsEfoX658JBpitPngjOheBnRCMpVQMyUT5HE/BKWf5zwdUB0mY +S+K8nA90HcDeJIS8RcGolbVwUV0oBABhr/cf50lYhqozqCr7YQ33ZGs7Uq3oz8+4 +UARmN2YPLl3Znm3GX12em8c6B0LX8vvA7Jw06Rf2Ksup1+3Ce1PTLiEy9A4FyRf3 +Hc2HmBbnJAtZlr5QikMqlzzAmmLqwH6dAoIBAC+ryaQGJFsijCSuaDfRp/uy9xnd +DjgMdTwjl5WLBmyudChVMANl8eqCbvVO41CN84yORk03oQ4cx0eKxAZaLaSzgkb3 +W0X2nFQe7VJSYMQswCQ+1WfJvEFrIdkEKIa//uQdhqNrgUKSNVhhSTMbNEkDTIWn +ssbv2H9hvUaFt/J/vP9zCKuU5oYvNU7Oi6ZXRYezRn9atlJYanLFoJnHUBRzGms5 +K0vhdCPDXQq87z5Yudoh0jLUQF9Nx0GTWeBceQ9n5hZeRUNQWxP4AJThQX9KSPTS +mbL3Kh4XNRmAUJ2N+Njh+3dg91s+JkKvC1wcspLsmLPQe+9AxBSH9y5JE/8= +-----END RSA PRIVATE KEY----- \ No newline at end of file diff --git a/docker/php-apache/alpine-php5/conf/etc/httpd/vhost.common.conf b/docker/php-apache/alpine-php5/conf/etc/httpd/vhost.common.conf new file mode 100644 index 000000000..384696b4e --- /dev/null +++ b/docker/php-apache/alpine-php5/conf/etc/httpd/vhost.common.conf @@ -0,0 +1,7 @@ +# compatibility for PHP and TYPO3 Docker Boilerplate + + Include /opt/docker/etc/httpd/vhost.common.d/*.conf + + = 2.4> + IncludeOptional /opt/docker/etc/httpd/vhost.common.d/*.conf + diff --git a/docker/php-apache/alpine-php5/conf/etc/httpd/vhost.common.d/.gitkeep b/docker/php-apache/alpine-php5/conf/etc/httpd/vhost.common.d/.gitkeep new file mode 100644 index 000000000..e69de29bb diff --git a/docker/php-apache/alpine-php5/conf/etc/httpd/vhost.common.d/01-boilerplate.conf b/docker/php-apache/alpine-php5/conf/etc/httpd/vhost.common.d/01-boilerplate.conf new file mode 100644 index 000000000..fdffa2a0f --- /dev/null +++ b/docker/php-apache/alpine-php5/conf/etc/httpd/vhost.common.d/01-boilerplate.conf @@ -0,0 +1 @@ +# placeholder diff --git a/docker/php-apache/alpine-php5/conf/etc/httpd/vhost.conf b/docker/php-apache/alpine-php5/conf/etc/httpd/vhost.conf new file mode 100644 index 000000000..c04a94318 --- /dev/null +++ b/docker/php-apache/alpine-php5/conf/etc/httpd/vhost.conf @@ -0,0 +1,36 @@ +####################################### +# Vhost +####################################### + + + ServerName docker.vm + ServerAlias + DocumentRoot "" + + UseCanonicalName Off + + + Include /opt/docker/etc/httpd/vhost.common.d/*.conf + + = 2.4> + IncludeOptional /opt/docker/etc/httpd/vhost.common.d/*.conf + + + + + + ServerName docker.vm + ServerAlias + DocumentRoot "" + + UseCanonicalName Off + + + Include /opt/docker/etc/httpd/vhost.common.d/*.conf + + = 2.4> + IncludeOptional /opt/docker/etc/httpd/vhost.common.d/*.conf + + + Include /opt/docker/etc/httpd/vhost.ssl.conf + diff --git a/docker/php-apache/alpine-php5/conf/etc/httpd/vhost.ssl.conf b/docker/php-apache/alpine-php5/conf/etc/httpd/vhost.ssl.conf new file mode 100644 index 000000000..cf5fbc604 --- /dev/null +++ b/docker/php-apache/alpine-php5/conf/etc/httpd/vhost.ssl.conf @@ -0,0 +1,26 @@ + ############ + # SSL + ############ + + SSLEngine on + SSLCertificateFile /opt/docker/etc/httpd/ssl/server.crt + SSLCertificateKeyFile /opt/docker/etc/httpd/ssl/server.key + + + SSLOptions +StdEnvVars + + + SSLOptions +StdEnvVars + + + BrowserMatch "MSIE [2-6]" \ + nokeepalive ssl-unclean-shutdown \ + downgrade-1.0 force-response-1.0 + # MSIE 7 and newer should be able to use keepalive + # This regexp is ok with 17-9! + BrowserMatch "MSIE [17-9]" ssl-unclean-shutdown + + ## SSL Hardening + SSLProtocol All -SSLv2 -SSLv3 + SSLHonorCipherOrder on + SSLCipherSuite 'EDH+CAMELLIA:EDH+aRSA:EECDH+aRSA+AESGCM:EECDH+aRSA+SHA384:EECDH+aRSA+SHA256:EECDH:+CAMELLIA256:+AES256:+CAMELLIA128:+AES128:+SSLv3:!aNULL:!eNULL:!LOW:!3DES:!MD5:!EXP:!PSK:!DSS:!RC4:!SEED:!ECDSA:CAMELLIA256-SHA:AES256-SHA:CAMELLIA128-SHA:AES128-SHA' diff --git a/docker/php-apache/alpine-php5/conf/etc/supervisor.d/apache.conf b/docker/php-apache/alpine-php5/conf/etc/supervisor.d/apache.conf new file mode 100644 index 000000000..12a6f86f7 --- /dev/null +++ b/docker/php-apache/alpine-php5/conf/etc/supervisor.d/apache.conf @@ -0,0 +1,14 @@ +[group:apache] +programs=apached +priority=20 + +[program:apached] +command = /opt/docker/bin/service.d/httpd.sh +process_name=%(program_name)s +startsecs = 0 +autostart = true +autorestart = true +stdout_logfile=/dev/stdout +stdout_logfile_maxbytes=0 +stderr_logfile=/dev/stderr +stderr_logfile_maxbytes=0 diff --git a/docker/php-apache/alpine-php5/conf/provision/roles/webdevops-apache/defaults/main.yml b/docker/php-apache/alpine-php5/conf/provision/roles/webdevops-apache/defaults/main.yml new file mode 100644 index 000000000..69cba1cb4 --- /dev/null +++ b/docker/php-apache/alpine-php5/conf/provision/roles/webdevops-apache/defaults/main.yml @@ -0,0 +1,3 @@ +--- + +DOCUMENT_ROOT: "{{ lookup('env','WEB_DOCUMENT_ROOT') }}" diff --git a/docker/php-apache/alpine-php5/conf/provision/roles/webdevops-apache/tasks/bootstrap.yml b/docker/php-apache/alpine-php5/conf/provision/roles/webdevops-apache/tasks/bootstrap.yml new file mode 100644 index 000000000..c285be286 --- /dev/null +++ b/docker/php-apache/alpine-php5/conf/provision/roles/webdevops-apache/tasks/bootstrap.yml @@ -0,0 +1,156 @@ +--- + +- name: Set apache vhost file [RedHat family] + set_fact: + apache_main_path: /etc/httpd/ + apache_docker_vhost: /etc/httpd/conf.d/zzz-docker.conf + when: ansible_os_family == 'RedHat' + +- name: Set apache vhost file [Debian family] + set_fact: + apache_main_path: /etc/apache2/ + apache_docker_vhost: /etc/apache2/sites-enabled/10-docker.conf + when: ansible_os_family == 'Debian' + +- name: Set apache vhost file [Alpine family] + set_fact: + apache_main_path: /etc/apache2/ + apache_docker_vhost: /etc/apache2/conf.d/zzz-docker.conf + when: ansible_os_family == 'Alpine' + +- name: Enable apache main config + file: + src: '/opt/docker/etc/httpd/main.conf' + dest: '{{ apache_docker_vhost }}' + state: link + force: yes + +- name: Ensure document root is available + file: + path: "{{ DOCUMENT_ROOT }}" + state: directory + recurse: yes + +- name: Ensure /var/run/apache2 exists + file: + path: '/var/run/apache2' + state: directory + recurse: yes + +- name: Ensure /run/apache2 exists + file: + path: '/run/apache2' + state: directory + recurse: yes + when: ansible_os_family == 'Alpine' + +- name: Find apache2 files + shell: "find '{{ apache_main_path }}' -type f -iname '*.conf' -o -iname 'default*' -o -iname '*log'" + register: apache2_conf_files + +- name: Change CustomLog to Docker stdout + replace: + dest: '{{ item }}' + regexp: '^[\s]*CustomLog ([^\s]+)(.*)' + replace: 'CustomLog /docker.stdout \2' + with_items: "{{ apache2_conf_files.stdout_lines }}" + +- name: Change CustomLog to Docker stdout + replace: + dest: '{{ item }}' + regexp: '^[\s]*ErrorLog ([^\s]+)(.*)' + replace: 'ErrorLog /docker.stdout \2' + with_items: "{{ apache2_conf_files.stdout_lines }}" + +- name: Change TransferLog to Docker stdout + replace: + dest: '{{ item }}' + regexp: '^[\s]*TransferLog ([^\s]+)(.*)' + replace: 'TransferLog /docker.stdout \2' + with_items: "{{ apache2_conf_files.stdout_lines }}" + +- name: Switch MPM to worker [RedHat family] + lineinfile: + dest: '/etc/httpd/conf.modules.d/00-mpm.conf' + regexp: '^[\s#]*{{ item.line }}' + line: '{{ item.prefix }}{{ item.line }}' + with_items: + - { line: 'LoadModule mpm_prefork_module modules/mod_mpm_prefork.so', prefix: "#" } + - { line: 'LoadModule mpm_event_module modules/mod_mpm_event.so', prefix: "" } + when: ansible_os_family == 'RedHat' + +- name: Switch MPM to event for Apache 2.4 and higher [Ubuntu family] + command: "{{ item }}" + with_items: + - 'a2dismod mpm_event' + - 'a2enmod mpm_event' + when: (ansible_distribution == 'Ubuntu' and docker_image_info_distribution_version|int >= 14) or (ansible_distribution == 'Debian' and docker_image_info_distribution_version|int >= 8) + +- name: Manage modules [Alpine family] + lineinfile: + dest: '/etc/apache2/httpd.conf' + regexp: '^[\s#]*{{ item.line }}' + line: '{{ item.prefix }}{{ item.line }}' + with_items: + - { line: 'LoadModule mpm_prefork_module modules/mod_mpm_prefork.so', prefix: "#" } + - { line: 'LoadModule mpm_event_module modules/mod_mpm_event.so', prefix: "" } + - { line: 'LoadModule deflate_module modules/mod_deflate.so', prefix: "" } + - { line: 'LoadModule rewrite_module modules/mod_rewrite.so', prefix: "" } + - { line: 'LoadModule logio_module modules/mod_logio.so', prefix: "" } + - { line: 'LoadModule slotmem_shm_module modules/mod_slotmem_shm.so', prefix: "" } + - { line: 'LoadModule actions_module modules/mod_actions.so', prefix: "" } + - { line: 'LoadModule expires_module modules/mod_expires.so', prefix: "" } + when: ansible_os_family == 'Alpine' + +- name: Fix ssl support [Alpine family] + lineinfile: + dest: '/etc/apache2/conf.d/ssl.conf' + regexp: '{{ item.regexp }}' + line: '{{ item.line }}' + with_items: + - { regexp: 'LoadModule ssl_module', line: 'LoadModule ssl_module /usr/lib/apache2/mod_ssl.so' } + - { regexp: 'LoadModule socache_shmcb_module', line: 'LoadModule socache_shmcb_module /usr/lib/apache2/mod_socache_shmcb.so' } + when: ansible_os_family == 'Alpine' + +- name: Remove default vhost from ssl configuration [Alpine family] + command: sed -i -e '1h;2,$H;$!d;g' -e 's//#-> removed vhost/g' /etc/apache2/conf.d/ssl.conf + when: ansible_os_family == 'Alpine' + +- name: Disable proxy [Alpine family] + lineinfile: + dest: '/etc/apache2/conf.d/proxy.conf' + regexp: '^[\s#]*{{ item.line }}' + line: '{{ item.prefix }}{{ item.line }}' + with_items: + - { line: 'LoadModule proxy_ajp_module modules/mod_proxy_ajp.so', prefix: "#" } + - { line: 'LoadModule proxy_connect_module modules/mod_proxy_connect.so', prefix: "#" } + - { line: 'LoadModule proxy_balancer_module modules/mod_proxy_balancer.so', prefix: "#" } + - { line: 'LoadModule proxy_express_module modules/mod_proxy_express.so', prefix: "#" } + - { line: 'LoadModule proxy_fcgi_module modules/mod_proxy_fcgi.so', prefix: "" } + - { line: 'LoadModule proxy_fdpass_module modules/mod_proxy_fdpass.so', prefix: "#" } + - { line: 'LoadModule proxy_ftp_module modules/mod_proxy_ftp.so', prefix: "#" } + - { line: 'LoadModule proxy_http_module modules/mod_proxy_http.so', prefix: "#" } + - { line: 'LoadModule proxy_scgi_module modules/mod_proxy_scgi.so', prefix: "#" } + when: ansible_os_family == 'Alpine' + +- name: Fix rights of ssl files + file: + path: "{{ item.path }}" + state: "{{ item.state }}" + mode: "{{ item.mode }}" + owner: "root" + group: "root" + with_items: + - { path: '/opt/docker/etc/httpd/ssl', state: 'directory', mode: '0750' } + - { path: '/opt/docker/etc/httpd/ssl/server.crt', state: 'file', mode: '0640' } + - { path: '/opt/docker/etc/httpd/ssl/server.csr', state: 'file', mode: '0640' } + - { path: '/opt/docker/etc/httpd/ssl/server.key', state: 'file', mode: '0640' } + +- name: Maintain lock directory [Debian family] + file: + path: "/var/lock/apache2" + state: "directory" + mode: "0750" + owner: "www-data" + group: "www-data" + when: ansible_os_family == 'Debian' diff --git a/docker/php-nginx-dev/alpine-3/conf/provision/roles/webdevops-php-dev/tasks/main.yml b/docker/php-apache/alpine-php5/conf/provision/roles/webdevops-apache/tasks/main.yml similarity index 100% rename from docker/php-nginx-dev/alpine-3/conf/provision/roles/webdevops-php-dev/tasks/main.yml rename to docker/php-apache/alpine-php5/conf/provision/roles/webdevops-apache/tasks/main.yml diff --git a/docker/base/alpine-3/conf/provision/variables.yml b/docker/php-apache/alpine-php5/conf/provision/roles/webdevops-php-apache/defaults/main.yml similarity index 100% rename from docker/base/alpine-3/conf/provision/variables.yml rename to docker/php-apache/alpine-php5/conf/provision/roles/webdevops-php-apache/defaults/main.yml diff --git a/docker/php-apache/alpine-php5/conf/provision/roles/webdevops-php-apache/tasks/bootstrap.yml b/docker/php-apache/alpine-php5/conf/provision/roles/webdevops-php-apache/tasks/bootstrap.yml new file mode 100644 index 000000000..ad5fb2121 --- /dev/null +++ b/docker/php-apache/alpine-php5/conf/provision/roles/webdevops-php-apache/tasks/bootstrap.yml @@ -0,0 +1,8 @@ +--- +- name: Restrict php-fpm to local connection + lineinfile: + dest: '/opt/docker/etc/php/fpm/pool.d/application.conf' + regexp: '^[\s;]*{{ item.key }}[\s]*=' + line: '{{ item.key }} = {{ item.value }}' + with_items: + - { key: 'listen', value: "127.0.0.1:9000" } diff --git a/docker/php-apache/alpine-php5/conf/provision/roles/webdevops-php-apache/tasks/entrypoint.yml b/docker/php-apache/alpine-php5/conf/provision/roles/webdevops-php-apache/tasks/entrypoint.yml new file mode 100644 index 000000000..cd21505a4 --- /dev/null +++ b/docker/php-apache/alpine-php5/conf/provision/roles/webdevops-php-apache/tasks/entrypoint.yml @@ -0,0 +1,2 @@ +--- + diff --git a/docker/php-apache/alpine-php5/conf/provision/roles/webdevops-php-apache/tasks/main.yml b/docker/php-apache/alpine-php5/conf/provision/roles/webdevops-php-apache/tasks/main.yml new file mode 100644 index 000000000..7895a52a9 --- /dev/null +++ b/docker/php-apache/alpine-php5/conf/provision/roles/webdevops-php-apache/tasks/main.yml @@ -0,0 +1,9 @@ +--- + +- include: bootstrap.yml + tags: + - bootstrap + +- include: entrypoint.yml + tags: + - entrypoint diff --git a/docker/php-apache/alpine-php7/Dockerfile b/docker/php-apache/alpine-php7/Dockerfile new file mode 100644 index 000000000..e355525c4 --- /dev/null +++ b/docker/php-apache/alpine-php7/Dockerfile @@ -0,0 +1,29 @@ +#+++++++++++++++++++++++++++++++++++++++ +# Dockerfile for webdevops/php-apache:alpine-php7 +# -- automatically generated -- +#+++++++++++++++++++++++++++++++++++++++ + +FROM webdevops/php:alpine-php7 + +ENV WEB_DOCUMENT_ROOT=/app \ + WEB_DOCUMENT_INDEX=index.php \ + WEB_ALIAS_DOMAIN=*.vm +ENV WEB_PHP_SOCKET=127.0.0.1:9000 + +COPY conf/ /opt/docker/ + +# Install apache +RUN /usr/local/bin/apk-install \ + apache2 \ + apache2-utils \ + apache2-proxy \ + apache2-ssl \ + && sed -ri ' \ + s!^(\s*CustomLog)\s+\S+!\1 /proc/self/fd/1!g; \ + s!^(\s*ErrorLog)\s+\S+!\1 /proc/self/fd/2!g; \ + ' /etc/apache2/httpd.conf \ + && /opt/docker/bin/provision run --tag bootstrap --role webdevops-apache --role webdevops-php-apache \ + && /opt/docker/bin/bootstrap.sh \ + && docker-image-cleanup + +EXPOSE 80 443 diff --git a/docker/php-apache/alpine-php7/Dockerfile.jinja2 b/docker/php-apache/alpine-php7/Dockerfile.jinja2 new file mode 100644 index 000000000..06ecf33d2 --- /dev/null +++ b/docker/php-apache/alpine-php7/Dockerfile.jinja2 @@ -0,0 +1,10 @@ +{{ docker.from("php", "alpine-php7") }} + +{{ environment.web() }} +{{ environment.webPhp() }} + +{{ docker.copy('conf/', '/opt/docker/') }} + +{{ apache.alpine('php-apache') }} + +{{ docker.expose('80 443') }} diff --git a/docker/php-apache/alpine-php7/conf/bin/service.d/httpd.d/10-init.sh b/docker/php-apache/alpine-php7/conf/bin/service.d/httpd.d/10-init.sh new file mode 100644 index 000000000..b9d57997e --- /dev/null +++ b/docker/php-apache/alpine-php7/conf/bin/service.d/httpd.d/10-init.sh @@ -0,0 +1,21 @@ +if [[ ! -e "$WEB_DOCUMENT_ROOT" ]]; then + echo "" + echo "[WARNING] WEB_DOCUMENT_ROOT does not exists with path \"$WEB_DOCUMENT_ROOT\"!" + echo "" +fi + +# Replace markers +go-replace \ + -s "" -r "$WEB_DOCUMENT_INDEX" \ + -s "" -r "$WEB_DOCUMENT_ROOT" \ + -s "" -r "$WEB_ALIAS_DOMAIN" \ + -s "" -r "$HOSTNAME" \ + -s "" -r "$WEB_PHP_SOCKET" \ + --path=/opt/docker/etc/httpd/ \ + --path-pattern='*.conf' \ + --ignore-empty + +if [[ -z "${WEB_PHP_SOCKET+x}" ]]; then + ## WEB_PHP_SOCKET is not set, remove PHP files + rm -f -- /opt/docker/etc/httpd/conf.d/10-php.conf +fi diff --git a/docker/php-apache/alpine-3/conf/bin/service.d/httpd.sh b/docker/php-apache/alpine-php7/conf/bin/service.d/httpd.sh similarity index 100% rename from docker/php-apache/alpine-3/conf/bin/service.d/httpd.sh rename to docker/php-apache/alpine-php7/conf/bin/service.d/httpd.sh diff --git a/docker/php-apache/alpine-php7/conf/etc/httpd/conf.d/.gitkeep b/docker/php-apache/alpine-php7/conf/etc/httpd/conf.d/.gitkeep new file mode 100644 index 000000000..e69de29bb diff --git a/docker/php-apache/alpine-php7/conf/etc/httpd/conf.d/10-error-document.conf b/docker/php-apache/alpine-php7/conf/etc/httpd/conf.d/10-error-document.conf new file mode 100644 index 000000000..ebabf87e4 --- /dev/null +++ b/docker/php-apache/alpine-php7/conf/etc/httpd/conf.d/10-error-document.conf @@ -0,0 +1,15 @@ +####################################### +# Faster error documents +####################################### + + ErrorDocument 400 "400 Bad Request" + ErrorDocument 401 "401 Unauthorized" + ErrorDocument 403 "403 Forbidden" + ErrorDocument 404 "404 Not Found" + ErrorDocument 405 "405 Method Not Allowed" + + ErrorDocument 500 "500 Internal Server Error" + ErrorDocument 501 "501 Not Implemented" + ErrorDocument 502 "502 Bad Gateway" + ErrorDocument 503 "503 Service Unavailable" + diff --git a/docker/php-apache/alpine-php7/conf/etc/httpd/conf.d/10-log.conf b/docker/php-apache/alpine-php7/conf/etc/httpd/conf.d/10-log.conf new file mode 100644 index 000000000..ef0c73d38 --- /dev/null +++ b/docker/php-apache/alpine-php7/conf/etc/httpd/conf.d/10-log.conf @@ -0,0 +1,4 @@ +LogFormat "[httpd:access] %V:%p %h %l %u %t \"%r\" %>s bytesIn:%I bytesOut:%O reqTime:%T" dockerlog +LogLevel warn +CustomLog /docker.stdout dockerlog +ErrorLog /docker.stderr diff --git a/docker/php-apache/alpine-php7/conf/etc/httpd/conf.d/10-php.conf b/docker/php-apache/alpine-php7/conf/etc/httpd/conf.d/10-php.conf new file mode 100644 index 000000000..4368d12ef --- /dev/null +++ b/docker/php-apache/alpine-php7/conf/etc/httpd/conf.d/10-php.conf @@ -0,0 +1,37 @@ +############################# +# mod_proxy_fcgi +# official solution +# apache 2.4 and later +############################# + + + > + ProxySet connectiontimeout=5 timeout=600 + + + + SetHandler "proxy:fcgi://" + + + +############################# +# mod_fastcgi +# apaache 2.2 and 2.4 +############################# + + + AddHandler php-fcgi .php + Action php-fcgi /php-fcgi + Alias /php-fcgi /usr/lib/cgi-bin/php-fcgi + FastCgiExternalServer /usr/lib/cgi-bin/php-fcgi -host "" -pass-header Authorization -idle-timeout 600 + + + + Allow from all + + = 2.4> + Require all granted + + + + diff --git a/docker/php-apache/alpine-php7/conf/etc/httpd/conf.d/10-server.conf b/docker/php-apache/alpine-php7/conf/etc/httpd/conf.d/10-server.conf new file mode 100644 index 000000000..d3a5defbd --- /dev/null +++ b/docker/php-apache/alpine-php7/conf/etc/httpd/conf.d/10-server.conf @@ -0,0 +1,18 @@ +# Settings +TimeOut 1000 +ServerName "" + +DirectoryIndex +DocumentRoot "" + +"> + Options Indexes FollowSymLinks + AllowOverride All + + + Allow from all + + = 2.4> + Require all granted + + diff --git a/docker/php-apache/alpine-php7/conf/etc/httpd/global.conf b/docker/php-apache/alpine-php7/conf/etc/httpd/global.conf new file mode 100644 index 000000000..b6141db09 --- /dev/null +++ b/docker/php-apache/alpine-php7/conf/etc/httpd/global.conf @@ -0,0 +1 @@ +# deprecated diff --git a/docker/php-apache/alpine-php7/conf/etc/httpd/main.conf b/docker/php-apache/alpine-php7/conf/etc/httpd/main.conf new file mode 100644 index 000000000..12251c222 --- /dev/null +++ b/docker/php-apache/alpine-php7/conf/etc/httpd/main.conf @@ -0,0 +1,12 @@ +Include /opt/docker/etc/httpd/global.conf +Include /opt/docker/etc/httpd/php.conf + + + Include /opt/docker/etc/httpd/conf.d/*.conf + += 2.4> + IncludeOptional /opt/docker/etc/httpd/conf.d/*.conf + +Include /opt/docker/etc/httpd/vhost.conf + + diff --git a/docker/php-apache/alpine-php7/conf/etc/httpd/php.conf b/docker/php-apache/alpine-php7/conf/etc/httpd/php.conf new file mode 100644 index 000000000..b6141db09 --- /dev/null +++ b/docker/php-apache/alpine-php7/conf/etc/httpd/php.conf @@ -0,0 +1 @@ +# deprecated diff --git a/docker/php-apache/alpine-php7/conf/etc/httpd/ssl/server.crt b/docker/php-apache/alpine-php7/conf/etc/httpd/ssl/server.crt new file mode 100644 index 000000000..6b0694907 --- /dev/null +++ b/docker/php-apache/alpine-php7/conf/etc/httpd/ssl/server.crt @@ -0,0 +1,28 @@ +-----BEGIN CERTIFICATE----- +MIIE1DCCArwCCQDMMwGnSuK0tTANBgkqhkiG9w0BAQsFADAsMRswGQYDVQQKExJE +b2NrZXIgQm9pbGVycGxhdGUxDTALBgNVBAMUBCoudm0wHhcNMTUwNTA0MTcxNDQw +WhcNMjUwNTAxMTcxNDQwWjAsMRswGQYDVQQKExJEb2NrZXIgQm9pbGVycGxhdGUx +DTALBgNVBAMUBCoudm0wggIiMA0GCSqGSIb3DQEBAQUAA4ICDwAwggIKAoICAQDK +3TIUiyDvXelWeY9VXMrpjuZtYpVSDsACLpjFUhMnsP5/iKT0VbeZyqHvmwZjAg4G +Y10d+yZDdgv/xeu0HPOFbtR6pCp10d1tdLHZto5Cyuxu7IQsAVjnD6Ko7XFwtNk7 +9o6JZfAFaGL4w5MokrVmCtspnsMZH7/7zU4f96cbF39zLopnpuXGD6t6DA8Qj3gy +0duaTjs42bYRN+rwLzVKAev99iQ4kPMJn4vV6/Xk6rtoSzC67GQyVZYaFypicD1S +NtsRmgEVvjCBDbrLOneUiRwff6qxEsZi7Hxv7BKFj4iUWnII7K/nP7T6uBHQjHO+ +FpsGkU9lCMrCeVFBe8kKz/cbhd+yLUxXwAPr6gSOPmwn232Gy4tozvqZHpbUxsgx +7sT3ej9K66h1D7J+BjNFWYM1hbnC1r7H/xS7EBzBV8qRoQCVe08Juf5xsouXFakD +clLV4+L+1cxkpwsCQDly5g3tm/TBqA2O+ZJ+YHQDHKkzMyhLs6i0X/M5qvJBiLg1 +GLTCS20rpQ5gXTEGuINqHgwXQWkUO6bhgSYqdHGX3zbZ5+qWpI4eui3dHZ1Ll0VH +6Icpb7ORTQwhc6W8KBlybssYPSlGOEBGUjYGNheoz9FpoSkxCis+P8ZNKtrmpPoq +Su0eOOGFOFHG02eOgPVxSwrDeN9MVJo7BPysGMHJmQIDAQABMA0GCSqGSIb3DQEB +CwUAA4ICAQC63g6NHmQKbiy3G6iaDkpUSbr5Mq2YgU61XnvWVyREqDcy/BXCw9oY +SJ/KUvCpqPnACNOFqjadRAmPiA9nf2WduoCgwQGV/YRFGswSuVvh/3X2TX5NWvbS +t8MQDttQg1dxpiMUjlu3rqhfohBdWJvp2lVSdpDb/MOlXBc/+p7HfOHwhqB7wwPN +NNbSKUbZqZxmD8cOf1X0hASr1yfFPj+2vST3ESaON8S0T2p63YX/sD5jvOUiEuyw +I5WcvLmiRZA07SH8nWyckLY3qWL+OlhSZrlAnolWS00b+7h5LNuRYEjKzwVgntoA +aCopyQih6wIk0+AfJO4sfhJBmQhnIrAaP/zwBH5g9zVizLf5H7U+hNXrMwgw55Sq +vjMdkZHvPKUXTvVit/rYE9H+PY3brkRWzOl4V/i/ZLJJm5805H/NyTbz9kPMJw2Q +nn+KOpfXXySD39f8iuRgSKXsYNul38hxWgcZZ6g+sOOp2n/VUmf0eZUWNnJ8i7AP +4Qif7aDKMcibOwSwsB+DKZXDvZ5XSdnMphtuLS5rPSL81rVRmWC2DMfQ2eP8j0WN +VTroSk0xedQ7Qr+9TNooi9IyzX6n1a2S1UiciEZ3ZcDbXPl/P01m+IYZyPnLv0+9 +ZeioZYh1JLv3/OKsMrMLTfh2ZCj3aXwmc2Owi/wU2LS5QUOMcHH7CQ== +-----END CERTIFICATE----- \ No newline at end of file diff --git a/docker/php-apache/alpine-php7/conf/etc/httpd/ssl/server.csr b/docker/php-apache/alpine-php7/conf/etc/httpd/ssl/server.csr new file mode 100644 index 000000000..8a9909f77 --- /dev/null +++ b/docker/php-apache/alpine-php7/conf/etc/httpd/ssl/server.csr @@ -0,0 +1,26 @@ +-----BEGIN CERTIFICATE REQUEST----- +MIIEcTCCAlkCAQAwLDEbMBkGA1UEChMSRG9ja2VyIEJvaWxlcnBsYXRlMQ0wCwYD +VQQDFAQqLnZtMIICIjANBgkqhkiG9w0BAQEFAAOCAg8AMIICCgKCAgEAyt0yFIsg +713pVnmPVVzK6Y7mbWKVUg7AAi6YxVITJ7D+f4ik9FW3mcqh75sGYwIOBmNdHfsm +Q3YL/8XrtBzzhW7UeqQqddHdbXSx2baOQsrsbuyELAFY5w+iqO1xcLTZO/aOiWXw +BWhi+MOTKJK1ZgrbKZ7DGR+/+81OH/enGxd/cy6KZ6blxg+regwPEI94MtHbmk47 +ONm2ETfq8C81SgHr/fYkOJDzCZ+L1ev15Oq7aEswuuxkMlWWGhcqYnA9UjbbEZoB +Fb4wgQ26yzp3lIkcH3+qsRLGYux8b+wShY+IlFpyCOyv5z+0+rgR0IxzvhabBpFP +ZQjKwnlRQXvJCs/3G4Xfsi1MV8AD6+oEjj5sJ9t9hsuLaM76mR6W1MbIMe7E93o/ +SuuodQ+yfgYzRVmDNYW5wta+x/8UuxAcwVfKkaEAlXtPCbn+cbKLlxWpA3JS1ePi +/tXMZKcLAkA5cuYN7Zv0wagNjvmSfmB0AxypMzMoS7OotF/zOaryQYi4NRi0wktt +K6UOYF0xBriDah4MF0FpFDum4YEmKnRxl9822efqlqSOHrot3R2dS5dFR+iHKW+z +kU0MIXOlvCgZcm7LGD0pRjhARlI2BjYXqM/RaaEpMQorPj/GTSra5qT6KkrtHjjh +hThRxtNnjoD1cUsKw3jfTFSaOwT8rBjByZkCAwEAAaAAMA0GCSqGSIb3DQEBCwUA +A4ICAQBsEBgC2YepuZq/8UqvKMZKVy/etDKXj7BB+QPb+leNiKD7p4LDxHJsZSH8 +Ku9uMPeLfiQDn5jA41k5SlGttzvObd65RdEbO3yHpqsg05EGSDDLfaE1k2Al/qmX +/o8roPZF7+2kZthgMAgkcokS54LYqEYTGqOf3J9Ss0yRIZwhaOVebfFIbIOdpw0B +JNMIJPHTMdZrcuRVI+wR1uPLIlEJzBvxTGbTrvPU25WJFtu+EajKqXO0SHdy0yx8 +uH4ykRBJRc36+oYo7nZ5D56dh7pZn3+9J64FKAOV0Q3KqMFieGy053ezuhJd70eZ +UozTgfjs3WpMzoYmKETSyl3XZSdInRe+sUlKPruTsKyg69oYxjPlrGfAmmGcCFca +TnZinT18dI92zK7OtOVkmYeYKC1lwuhftVrNMXzZuHOGpS9NNYtc4nDqDMIEOfV3 +6rCdu03WjEgJ+Z67tJs16xOx9du4/EHxS2Ijn9DPfVJvYy0TgzDi1BUpjWx0KTLx +C4OQbEZ/QTWmHVbSch/hcZhzbf7SNh5RpnW4EtmcpDFjIKMfxJmoKeiTf7qnilx0 +7uRvsZFKoDKRDOFiPfgMg5AOtLHziYsd9m0tJjC2GHvFuPjzOtzhnUUjmmvht170 +2aqKakjST4amg7jzLcs871HX0/WjOtt29NpOz140blkKf1bisg== +-----END CERTIFICATE REQUEST----- \ No newline at end of file diff --git a/docker/php-apache/alpine-php7/conf/etc/httpd/ssl/server.key b/docker/php-apache/alpine-php7/conf/etc/httpd/ssl/server.key new file mode 100644 index 000000000..c9eec145f --- /dev/null +++ b/docker/php-apache/alpine-php7/conf/etc/httpd/ssl/server.key @@ -0,0 +1,51 @@ +-----BEGIN RSA PRIVATE KEY----- +MIIJKAIBAAKCAgEAyt0yFIsg713pVnmPVVzK6Y7mbWKVUg7AAi6YxVITJ7D+f4ik +9FW3mcqh75sGYwIOBmNdHfsmQ3YL/8XrtBzzhW7UeqQqddHdbXSx2baOQsrsbuyE +LAFY5w+iqO1xcLTZO/aOiWXwBWhi+MOTKJK1ZgrbKZ7DGR+/+81OH/enGxd/cy6K +Z6blxg+regwPEI94MtHbmk47ONm2ETfq8C81SgHr/fYkOJDzCZ+L1ev15Oq7aEsw +uuxkMlWWGhcqYnA9UjbbEZoBFb4wgQ26yzp3lIkcH3+qsRLGYux8b+wShY+IlFpy +COyv5z+0+rgR0IxzvhabBpFPZQjKwnlRQXvJCs/3G4Xfsi1MV8AD6+oEjj5sJ9t9 +hsuLaM76mR6W1MbIMe7E93o/SuuodQ+yfgYzRVmDNYW5wta+x/8UuxAcwVfKkaEA +lXtPCbn+cbKLlxWpA3JS1ePi/tXMZKcLAkA5cuYN7Zv0wagNjvmSfmB0AxypMzMo +S7OotF/zOaryQYi4NRi0wkttK6UOYF0xBriDah4MF0FpFDum4YEmKnRxl9822efq +lqSOHrot3R2dS5dFR+iHKW+zkU0MIXOlvCgZcm7LGD0pRjhARlI2BjYXqM/RaaEp +MQorPj/GTSra5qT6KkrtHjjhhThRxtNnjoD1cUsKw3jfTFSaOwT8rBjByZkCAwEA +AQKCAgAbZPdoUsllyZbC+LNkYZ19ILD5QIDNjfRb1xMGQmkXyQz1B+zOmeyrNfPc +OWEJabOfJTfj3pByN7SzG3US4333HNpQnW6mbmqqZ0HFFqPrXR/Ecuf+UUhCG5hp +m3bgM2vKbyccYsmg0VHcKfzrU7RvTTP/UNMjx2fThwvvwS+ttuSdF0HVcXJB5sfP +OWWnZNhkdHZlRf81VCED/jsZqCZYEh5eMyj9AoXvXL4zayPPf+tC0DSKaXW2Xlxg +tZQhqup8+a9nlxZia0Z9hu8clo6jXkiP8FuKgfCMV0cOjiCKLLHS5svTbLLsVWwJ +F2ZAdVcD6mWQ43qHOEK5NEzGvQKO14CaOLnVT2yAkMcyNohsEgoDP9oCBGDJQbBH +NmtZfpVjjtuTr9P9TEkU1FcBRo0x6Il/DkzamGbOeFAmgnaGElhJ5c/CAG7whaIf +mUfFOBGPH/wESY3gBOACDofeSh27RrlvbLaPiCGKivDUTBmhBsIuso6XqOKbvtfV +/HhhndpdRVfIj4DdE7gIrLIGN977JMVAXFCNz7KrvAWwcOXrCHCoWpklJ9repq8l +26ICY8K7VXktzDHQUmhd88ZWR+9ASURsJghUgZUOcMrEGyvci6Y8hpLhHiNVPHuQ ++ps7tpPsXSntBUqWBzhRZh74+nJlOOV6oYykl30JT2JzB6lwiQKCAQEA9ecn8N2z +20tR2UEiTv/MjVSepQtAAajegvcd1iasvvQKXnh3XLmoZHzH2tTa0lp5RIZpUQPl +lOTwko0lYTBnYblt65AJQ3FTgisNobIpoqE8BFXLm6wggz7CbabjmPGDe173lPGR +sI0YSKYvzrdn4zw8Fh6WULJyZHLi58zJYL3r0WBDiOoxpGaGA1GlmkuIWjhKHaX2 +OvF1vOuQDJ2eDyTc5TYFC0NKG76Mvanov5L/yrhNM/umbmp0SPspzHGZobAKUr20 +OazFT8S+2TA1OTxWNbiPbSimFoaZbEdqsNACGfVJWO8Sh8iqlt5RmEcSiSvGBj6L +QKprRO9Fsp2GawKCAQEA0zGhRsnux4JTNsdUSYsEJtITMj6eE+nl7CoZ9DAOwC5X +6/aSpUE4TT+pWNrt9iluXiGL0j89UJ7r/L1OcsiyzGb8ig9NU4zr1NIGTZ0DstHi +HPYINjeiBJEFIy17kOQn+9/I5c4hBUwz6ihwNoEomymVB/EsLJKAML0AudJGKg+Z +/f/qrS40eab5SAiaKgsh0MZnj+vIxyGBydt6r2HGmjfNITVbXIu6IpO+6NXDwM/e +7v10AAZ3j9+gb1RedLg2ghuIuYU90hmMhtVWsh9nVmaOkMW9/WFgOPYvt/mHH/hR +d4pePZ9kACGmqo/b9sHvHw1YEubtCt1VUiNuFxnJCwKCAQBWnxz0vkRTJY8phsY9 +KeK2jm5sGTBs5T2syLwb6ffENFdKvAjgAw6Mh2And/+1ReWd+/MxdLv03UjZdxsJ +x3FDfXx5FH4O4ebW3a+pnAcKoN1xcX+N0O6LDRqUYcue3sTAOs3gC9CUbr91KAWD +Phw8ccWAzTmKJ7IgLFA982ekyoI9eTmRC159WRgwJxy844qerWF+XC4GyXP+HsTZ +jNRW5Vdi7sqMEyIR7+fIEAhLI88zbATWIPmZv6pC4ybwO7wwtsCMMQNBpdjDprzL +6S12ggikV+U+QKlxGe0FtYqhykRTPJKf32eZqVheWOZJTA/9fgv9ux52oxGycM8O +gmsNAoIBAQC60m5uZnd5uYnPLWkcXYNgq/kbO1UvHHut/FhVMKX7z4MrU0XKNfWO +MECoP5K9bU0aq+Y6KIMe7FapjvT0iSHRu1Cu+HZY8JI2A0xcIAeDijLRl7sP6wrB +q1+2DKgANjRAlWfsEfoX658JBpitPngjOheBnRCMpVQMyUT5HE/BKWf5zwdUB0mY +S+K8nA90HcDeJIS8RcGolbVwUV0oBABhr/cf50lYhqozqCr7YQ33ZGs7Uq3oz8+4 +UARmN2YPLl3Znm3GX12em8c6B0LX8vvA7Jw06Rf2Ksup1+3Ce1PTLiEy9A4FyRf3 +Hc2HmBbnJAtZlr5QikMqlzzAmmLqwH6dAoIBAC+ryaQGJFsijCSuaDfRp/uy9xnd +DjgMdTwjl5WLBmyudChVMANl8eqCbvVO41CN84yORk03oQ4cx0eKxAZaLaSzgkb3 +W0X2nFQe7VJSYMQswCQ+1WfJvEFrIdkEKIa//uQdhqNrgUKSNVhhSTMbNEkDTIWn +ssbv2H9hvUaFt/J/vP9zCKuU5oYvNU7Oi6ZXRYezRn9atlJYanLFoJnHUBRzGms5 +K0vhdCPDXQq87z5Yudoh0jLUQF9Nx0GTWeBceQ9n5hZeRUNQWxP4AJThQX9KSPTS +mbL3Kh4XNRmAUJ2N+Njh+3dg91s+JkKvC1wcspLsmLPQe+9AxBSH9y5JE/8= +-----END RSA PRIVATE KEY----- \ No newline at end of file diff --git a/docker/php-apache/alpine-php7/conf/etc/httpd/vhost.common.conf b/docker/php-apache/alpine-php7/conf/etc/httpd/vhost.common.conf new file mode 100644 index 000000000..384696b4e --- /dev/null +++ b/docker/php-apache/alpine-php7/conf/etc/httpd/vhost.common.conf @@ -0,0 +1,7 @@ +# compatibility for PHP and TYPO3 Docker Boilerplate + + Include /opt/docker/etc/httpd/vhost.common.d/*.conf + + = 2.4> + IncludeOptional /opt/docker/etc/httpd/vhost.common.d/*.conf + diff --git a/docker/php-apache/alpine-php7/conf/etc/httpd/vhost.common.d/.gitkeep b/docker/php-apache/alpine-php7/conf/etc/httpd/vhost.common.d/.gitkeep new file mode 100644 index 000000000..e69de29bb diff --git a/docker/php-apache/alpine-php7/conf/etc/httpd/vhost.common.d/01-boilerplate.conf b/docker/php-apache/alpine-php7/conf/etc/httpd/vhost.common.d/01-boilerplate.conf new file mode 100644 index 000000000..fdffa2a0f --- /dev/null +++ b/docker/php-apache/alpine-php7/conf/etc/httpd/vhost.common.d/01-boilerplate.conf @@ -0,0 +1 @@ +# placeholder diff --git a/docker/php-apache/alpine-php7/conf/etc/httpd/vhost.conf b/docker/php-apache/alpine-php7/conf/etc/httpd/vhost.conf new file mode 100644 index 000000000..c04a94318 --- /dev/null +++ b/docker/php-apache/alpine-php7/conf/etc/httpd/vhost.conf @@ -0,0 +1,36 @@ +####################################### +# Vhost +####################################### + + + ServerName docker.vm + ServerAlias + DocumentRoot "" + + UseCanonicalName Off + + + Include /opt/docker/etc/httpd/vhost.common.d/*.conf + + = 2.4> + IncludeOptional /opt/docker/etc/httpd/vhost.common.d/*.conf + + + + + + ServerName docker.vm + ServerAlias + DocumentRoot "" + + UseCanonicalName Off + + + Include /opt/docker/etc/httpd/vhost.common.d/*.conf + + = 2.4> + IncludeOptional /opt/docker/etc/httpd/vhost.common.d/*.conf + + + Include /opt/docker/etc/httpd/vhost.ssl.conf + diff --git a/docker/php-apache/alpine-php7/conf/etc/httpd/vhost.ssl.conf b/docker/php-apache/alpine-php7/conf/etc/httpd/vhost.ssl.conf new file mode 100644 index 000000000..cf5fbc604 --- /dev/null +++ b/docker/php-apache/alpine-php7/conf/etc/httpd/vhost.ssl.conf @@ -0,0 +1,26 @@ + ############ + # SSL + ############ + + SSLEngine on + SSLCertificateFile /opt/docker/etc/httpd/ssl/server.crt + SSLCertificateKeyFile /opt/docker/etc/httpd/ssl/server.key + + + SSLOptions +StdEnvVars + + + SSLOptions +StdEnvVars + + + BrowserMatch "MSIE [2-6]" \ + nokeepalive ssl-unclean-shutdown \ + downgrade-1.0 force-response-1.0 + # MSIE 7 and newer should be able to use keepalive + # This regexp is ok with 17-9! + BrowserMatch "MSIE [17-9]" ssl-unclean-shutdown + + ## SSL Hardening + SSLProtocol All -SSLv2 -SSLv3 + SSLHonorCipherOrder on + SSLCipherSuite 'EDH+CAMELLIA:EDH+aRSA:EECDH+aRSA+AESGCM:EECDH+aRSA+SHA384:EECDH+aRSA+SHA256:EECDH:+CAMELLIA256:+AES256:+CAMELLIA128:+AES128:+SSLv3:!aNULL:!eNULL:!LOW:!3DES:!MD5:!EXP:!PSK:!DSS:!RC4:!SEED:!ECDSA:CAMELLIA256-SHA:AES256-SHA:CAMELLIA128-SHA:AES128-SHA' diff --git a/docker/php-apache/alpine-php7/conf/etc/supervisor.d/apache.conf b/docker/php-apache/alpine-php7/conf/etc/supervisor.d/apache.conf new file mode 100644 index 000000000..12a6f86f7 --- /dev/null +++ b/docker/php-apache/alpine-php7/conf/etc/supervisor.d/apache.conf @@ -0,0 +1,14 @@ +[group:apache] +programs=apached +priority=20 + +[program:apached] +command = /opt/docker/bin/service.d/httpd.sh +process_name=%(program_name)s +startsecs = 0 +autostart = true +autorestart = true +stdout_logfile=/dev/stdout +stdout_logfile_maxbytes=0 +stderr_logfile=/dev/stderr +stderr_logfile_maxbytes=0 diff --git a/docker/php-apache/alpine-php7/conf/provision/roles/webdevops-apache/defaults/main.yml b/docker/php-apache/alpine-php7/conf/provision/roles/webdevops-apache/defaults/main.yml new file mode 100644 index 000000000..69cba1cb4 --- /dev/null +++ b/docker/php-apache/alpine-php7/conf/provision/roles/webdevops-apache/defaults/main.yml @@ -0,0 +1,3 @@ +--- + +DOCUMENT_ROOT: "{{ lookup('env','WEB_DOCUMENT_ROOT') }}" diff --git a/docker/php-apache/alpine-php7/conf/provision/roles/webdevops-apache/tasks/bootstrap.yml b/docker/php-apache/alpine-php7/conf/provision/roles/webdevops-apache/tasks/bootstrap.yml new file mode 100644 index 000000000..c285be286 --- /dev/null +++ b/docker/php-apache/alpine-php7/conf/provision/roles/webdevops-apache/tasks/bootstrap.yml @@ -0,0 +1,156 @@ +--- + +- name: Set apache vhost file [RedHat family] + set_fact: + apache_main_path: /etc/httpd/ + apache_docker_vhost: /etc/httpd/conf.d/zzz-docker.conf + when: ansible_os_family == 'RedHat' + +- name: Set apache vhost file [Debian family] + set_fact: + apache_main_path: /etc/apache2/ + apache_docker_vhost: /etc/apache2/sites-enabled/10-docker.conf + when: ansible_os_family == 'Debian' + +- name: Set apache vhost file [Alpine family] + set_fact: + apache_main_path: /etc/apache2/ + apache_docker_vhost: /etc/apache2/conf.d/zzz-docker.conf + when: ansible_os_family == 'Alpine' + +- name: Enable apache main config + file: + src: '/opt/docker/etc/httpd/main.conf' + dest: '{{ apache_docker_vhost }}' + state: link + force: yes + +- name: Ensure document root is available + file: + path: "{{ DOCUMENT_ROOT }}" + state: directory + recurse: yes + +- name: Ensure /var/run/apache2 exists + file: + path: '/var/run/apache2' + state: directory + recurse: yes + +- name: Ensure /run/apache2 exists + file: + path: '/run/apache2' + state: directory + recurse: yes + when: ansible_os_family == 'Alpine' + +- name: Find apache2 files + shell: "find '{{ apache_main_path }}' -type f -iname '*.conf' -o -iname 'default*' -o -iname '*log'" + register: apache2_conf_files + +- name: Change CustomLog to Docker stdout + replace: + dest: '{{ item }}' + regexp: '^[\s]*CustomLog ([^\s]+)(.*)' + replace: 'CustomLog /docker.stdout \2' + with_items: "{{ apache2_conf_files.stdout_lines }}" + +- name: Change CustomLog to Docker stdout + replace: + dest: '{{ item }}' + regexp: '^[\s]*ErrorLog ([^\s]+)(.*)' + replace: 'ErrorLog /docker.stdout \2' + with_items: "{{ apache2_conf_files.stdout_lines }}" + +- name: Change TransferLog to Docker stdout + replace: + dest: '{{ item }}' + regexp: '^[\s]*TransferLog ([^\s]+)(.*)' + replace: 'TransferLog /docker.stdout \2' + with_items: "{{ apache2_conf_files.stdout_lines }}" + +- name: Switch MPM to worker [RedHat family] + lineinfile: + dest: '/etc/httpd/conf.modules.d/00-mpm.conf' + regexp: '^[\s#]*{{ item.line }}' + line: '{{ item.prefix }}{{ item.line }}' + with_items: + - { line: 'LoadModule mpm_prefork_module modules/mod_mpm_prefork.so', prefix: "#" } + - { line: 'LoadModule mpm_event_module modules/mod_mpm_event.so', prefix: "" } + when: ansible_os_family == 'RedHat' + +- name: Switch MPM to event for Apache 2.4 and higher [Ubuntu family] + command: "{{ item }}" + with_items: + - 'a2dismod mpm_event' + - 'a2enmod mpm_event' + when: (ansible_distribution == 'Ubuntu' and docker_image_info_distribution_version|int >= 14) or (ansible_distribution == 'Debian' and docker_image_info_distribution_version|int >= 8) + +- name: Manage modules [Alpine family] + lineinfile: + dest: '/etc/apache2/httpd.conf' + regexp: '^[\s#]*{{ item.line }}' + line: '{{ item.prefix }}{{ item.line }}' + with_items: + - { line: 'LoadModule mpm_prefork_module modules/mod_mpm_prefork.so', prefix: "#" } + - { line: 'LoadModule mpm_event_module modules/mod_mpm_event.so', prefix: "" } + - { line: 'LoadModule deflate_module modules/mod_deflate.so', prefix: "" } + - { line: 'LoadModule rewrite_module modules/mod_rewrite.so', prefix: "" } + - { line: 'LoadModule logio_module modules/mod_logio.so', prefix: "" } + - { line: 'LoadModule slotmem_shm_module modules/mod_slotmem_shm.so', prefix: "" } + - { line: 'LoadModule actions_module modules/mod_actions.so', prefix: "" } + - { line: 'LoadModule expires_module modules/mod_expires.so', prefix: "" } + when: ansible_os_family == 'Alpine' + +- name: Fix ssl support [Alpine family] + lineinfile: + dest: '/etc/apache2/conf.d/ssl.conf' + regexp: '{{ item.regexp }}' + line: '{{ item.line }}' + with_items: + - { regexp: 'LoadModule ssl_module', line: 'LoadModule ssl_module /usr/lib/apache2/mod_ssl.so' } + - { regexp: 'LoadModule socache_shmcb_module', line: 'LoadModule socache_shmcb_module /usr/lib/apache2/mod_socache_shmcb.so' } + when: ansible_os_family == 'Alpine' + +- name: Remove default vhost from ssl configuration [Alpine family] + command: sed -i -e '1h;2,$H;$!d;g' -e 's//#-> removed vhost/g' /etc/apache2/conf.d/ssl.conf + when: ansible_os_family == 'Alpine' + +- name: Disable proxy [Alpine family] + lineinfile: + dest: '/etc/apache2/conf.d/proxy.conf' + regexp: '^[\s#]*{{ item.line }}' + line: '{{ item.prefix }}{{ item.line }}' + with_items: + - { line: 'LoadModule proxy_ajp_module modules/mod_proxy_ajp.so', prefix: "#" } + - { line: 'LoadModule proxy_connect_module modules/mod_proxy_connect.so', prefix: "#" } + - { line: 'LoadModule proxy_balancer_module modules/mod_proxy_balancer.so', prefix: "#" } + - { line: 'LoadModule proxy_express_module modules/mod_proxy_express.so', prefix: "#" } + - { line: 'LoadModule proxy_fcgi_module modules/mod_proxy_fcgi.so', prefix: "" } + - { line: 'LoadModule proxy_fdpass_module modules/mod_proxy_fdpass.so', prefix: "#" } + - { line: 'LoadModule proxy_ftp_module modules/mod_proxy_ftp.so', prefix: "#" } + - { line: 'LoadModule proxy_http_module modules/mod_proxy_http.so', prefix: "#" } + - { line: 'LoadModule proxy_scgi_module modules/mod_proxy_scgi.so', prefix: "#" } + when: ansible_os_family == 'Alpine' + +- name: Fix rights of ssl files + file: + path: "{{ item.path }}" + state: "{{ item.state }}" + mode: "{{ item.mode }}" + owner: "root" + group: "root" + with_items: + - { path: '/opt/docker/etc/httpd/ssl', state: 'directory', mode: '0750' } + - { path: '/opt/docker/etc/httpd/ssl/server.crt', state: 'file', mode: '0640' } + - { path: '/opt/docker/etc/httpd/ssl/server.csr', state: 'file', mode: '0640' } + - { path: '/opt/docker/etc/httpd/ssl/server.key', state: 'file', mode: '0640' } + +- name: Maintain lock directory [Debian family] + file: + path: "/var/lock/apache2" + state: "directory" + mode: "0750" + owner: "www-data" + group: "www-data" + when: ansible_os_family == 'Debian' diff --git a/docker/php-nginx/alpine-3-php7/conf/provision/roles/webdevops-nginx/tasks/main.yml b/docker/php-apache/alpine-php7/conf/provision/roles/webdevops-apache/tasks/main.yml similarity index 100% rename from docker/php-nginx/alpine-3-php7/conf/provision/roles/webdevops-nginx/tasks/main.yml rename to docker/php-apache/alpine-php7/conf/provision/roles/webdevops-apache/tasks/main.yml diff --git a/docker/php-apache/alpine-php7/conf/provision/roles/webdevops-php-apache/defaults/main.yml b/docker/php-apache/alpine-php7/conf/provision/roles/webdevops-php-apache/defaults/main.yml new file mode 100644 index 000000000..ed97d539c --- /dev/null +++ b/docker/php-apache/alpine-php7/conf/provision/roles/webdevops-php-apache/defaults/main.yml @@ -0,0 +1 @@ +--- diff --git a/docker/php-apache/alpine-php7/conf/provision/roles/webdevops-php-apache/tasks/bootstrap.yml b/docker/php-apache/alpine-php7/conf/provision/roles/webdevops-php-apache/tasks/bootstrap.yml new file mode 100644 index 000000000..ad5fb2121 --- /dev/null +++ b/docker/php-apache/alpine-php7/conf/provision/roles/webdevops-php-apache/tasks/bootstrap.yml @@ -0,0 +1,8 @@ +--- +- name: Restrict php-fpm to local connection + lineinfile: + dest: '/opt/docker/etc/php/fpm/pool.d/application.conf' + regexp: '^[\s;]*{{ item.key }}[\s]*=' + line: '{{ item.key }} = {{ item.value }}' + with_items: + - { key: 'listen', value: "127.0.0.1:9000" } diff --git a/docker/php-apache/alpine-php7/conf/provision/roles/webdevops-php-apache/tasks/entrypoint.yml b/docker/php-apache/alpine-php7/conf/provision/roles/webdevops-php-apache/tasks/entrypoint.yml new file mode 100644 index 000000000..cd21505a4 --- /dev/null +++ b/docker/php-apache/alpine-php7/conf/provision/roles/webdevops-php-apache/tasks/entrypoint.yml @@ -0,0 +1,2 @@ +--- + diff --git a/docker/php-apache/alpine-php7/conf/provision/roles/webdevops-php-apache/tasks/main.yml b/docker/php-apache/alpine-php7/conf/provision/roles/webdevops-php-apache/tasks/main.yml new file mode 100644 index 000000000..7895a52a9 --- /dev/null +++ b/docker/php-apache/alpine-php7/conf/provision/roles/webdevops-php-apache/tasks/main.yml @@ -0,0 +1,9 @@ +--- + +- include: bootstrap.yml + tags: + - bootstrap + +- include: entrypoint.yml + tags: + - entrypoint diff --git a/docker/php-apache/centos-7-php56/Dockerfile b/docker/php-apache/centos-7-php56/Dockerfile index e32a5eef5..bc6ccafd5 100644 --- a/docker/php-apache/centos-7-php56/Dockerfile +++ b/docker/php-apache/centos-7-php56/Dockerfile @@ -5,15 +5,10 @@ FROM webdevops/php:centos-7-php56 -MAINTAINER info@webdevops.io -LABEL vendor=WebDevOps.io -LABEL io.webdevops.layout=8 -LABEL io.webdevops.version=1.5.0 - -ENV WEB_DOCUMENT_ROOT /app -ENV WEB_DOCUMENT_INDEX index.php -ENV WEB_ALIAS_DOMAIN *.vm -ENV WEB_PHP_SOCKET 127.0.0.1:9000 +ENV WEB_DOCUMENT_ROOT=/app \ + WEB_DOCUMENT_INDEX=index.php \ + WEB_ALIAS_DOMAIN=*.vm +ENV WEB_PHP_SOCKET=127.0.0.1:9000 COPY conf/ /opt/docker/ @@ -26,7 +21,7 @@ RUN /usr/local/bin/yum-install \ s!^(\s*ErrorLog)\s+\S+!\1 /proc/self/fd/2!g; \ ' /etc/httpd/conf/httpd.conf /etc/httpd/conf.d/ssl.conf \ && /opt/docker/bin/provision run --tag bootstrap --role webdevops-apache --role webdevops-php-apache \ - && /opt/docker/bin/bootstrap.sh - + && /opt/docker/bin/bootstrap.sh \ + && docker-image-cleanup EXPOSE 80 443 diff --git a/docker/php-apache/centos-7-php56/Dockerfile.jinja2 b/docker/php-apache/centos-7-php56/Dockerfile.jinja2 index bbd157465..c0231d851 100644 --- a/docker/php-apache/centos-7-php56/Dockerfile.jinja2 +++ b/docker/php-apache/centos-7-php56/Dockerfile.jinja2 @@ -1,7 +1,5 @@ {{ docker.from("php", "centos-7-php56") }} -{{ docker.version() }} - {{ environment.web() }} {{ environment.webPhp() }} diff --git a/docker/php-apache/centos-7-php56/conf/bin/service.d/httpd.d/10-init.sh b/docker/php-apache/centos-7-php56/conf/bin/service.d/httpd.d/10-init.sh index d3f1a0c9c..b9d57997e 100644 --- a/docker/php-apache/centos-7-php56/conf/bin/service.d/httpd.d/10-init.sh +++ b/docker/php-apache/centos-7-php56/conf/bin/service.d/httpd.d/10-init.sh @@ -5,15 +5,17 @@ if [[ ! -e "$WEB_DOCUMENT_ROOT" ]]; then fi # Replace markers -find /opt/docker/etc/httpd/ -iname '*.conf' -print0 | xargs -0 -r rpl --quiet "" "$WEB_DOCUMENT_INDEX" > /dev/null -find /opt/docker/etc/httpd/ -iname '*.conf' -print0 | xargs -0 -r rpl --quiet "" "$WEB_DOCUMENT_ROOT" > /dev/null -find /opt/docker/etc/httpd/ -iname '*.conf' -print0 | xargs -0 -r rpl --quiet "" "$WEB_ALIAS_DOMAIN" > /dev/null -find /opt/docker/etc/httpd/ -iname '*.conf' -print0 | xargs -0 -r rpl --quiet "" "$HOSTNAME" > /dev/null +go-replace \ + -s "" -r "$WEB_DOCUMENT_INDEX" \ + -s "" -r "$WEB_DOCUMENT_ROOT" \ + -s "" -r "$WEB_ALIAS_DOMAIN" \ + -s "" -r "$HOSTNAME" \ + -s "" -r "$WEB_PHP_SOCKET" \ + --path=/opt/docker/etc/httpd/ \ + --path-pattern='*.conf' \ + --ignore-empty -if [[ -n "${WEB_PHP_SOCKET+x}" ]]; then - ## WEB_PHP_SOCKET is set - find /opt/docker/etc/httpd/ -iname '*.conf' -print0 | xargs -0 -r rpl --quiet "" "$WEB_PHP_SOCKET" > /dev/null -else +if [[ -z "${WEB_PHP_SOCKET+x}" ]]; then ## WEB_PHP_SOCKET is not set, remove PHP files rm -f -- /opt/docker/etc/httpd/conf.d/10-php.conf fi diff --git a/docker/php-apache/centos-7-php56/conf/etc/httpd/conf.d/10-log.conf b/docker/php-apache/centos-7-php56/conf/etc/httpd/conf.d/10-log.conf index e4c4be4f2..ef0c73d38 100644 --- a/docker/php-apache/centos-7-php56/conf/etc/httpd/conf.d/10-log.conf +++ b/docker/php-apache/centos-7-php56/conf/etc/httpd/conf.d/10-log.conf @@ -1,4 +1,4 @@ LogFormat "[httpd:access] %V:%p %h %l %u %t \"%r\" %>s bytesIn:%I bytesOut:%O reqTime:%T" dockerlog LogLevel warn -CustomLog /proc/self/fd/1 dockerlog -ErrorLog /proc/self/fd/2 +CustomLog /docker.stdout dockerlog +ErrorLog /docker.stderr diff --git a/docker/php-apache/centos-7-php56/conf/provision/roles/webdevops-apache/tasks/bootstrap.yml b/docker/php-apache/centos-7-php56/conf/provision/roles/webdevops-apache/tasks/bootstrap.yml index 2be18b0e0..c285be286 100644 --- a/docker/php-apache/centos-7-php56/conf/provision/roles/webdevops-apache/tasks/bootstrap.yml +++ b/docker/php-apache/centos-7-php56/conf/provision/roles/webdevops-apache/tasks/bootstrap.yml @@ -84,7 +84,7 @@ with_items: - 'a2dismod mpm_event' - 'a2enmod mpm_event' - when: (ansible_distribution == 'Ubuntu' and ansible_lsb.major_release|int >= 14) or (ansible_distribution == 'Debian' and ansible_lsb.major_release|int >= 8) + when: (ansible_distribution == 'Ubuntu' and docker_image_info_distribution_version|int >= 14) or (ansible_distribution == 'Debian' and docker_image_info_distribution_version|int >= 8) - name: Manage modules [Alpine family] lineinfile: diff --git a/docker/php-apache/centos-7-php7/Dockerfile b/docker/php-apache/centos-7-php7/Dockerfile index 85f333a48..a04c97e43 100644 --- a/docker/php-apache/centos-7-php7/Dockerfile +++ b/docker/php-apache/centos-7-php7/Dockerfile @@ -5,15 +5,10 @@ FROM webdevops/php:centos-7-php7 -MAINTAINER info@webdevops.io -LABEL vendor=WebDevOps.io -LABEL io.webdevops.layout=8 -LABEL io.webdevops.version=1.5.0 - -ENV WEB_DOCUMENT_ROOT /app -ENV WEB_DOCUMENT_INDEX index.php -ENV WEB_ALIAS_DOMAIN *.vm -ENV WEB_PHP_SOCKET 127.0.0.1:9000 +ENV WEB_DOCUMENT_ROOT=/app \ + WEB_DOCUMENT_INDEX=index.php \ + WEB_ALIAS_DOMAIN=*.vm +ENV WEB_PHP_SOCKET=127.0.0.1:9000 COPY conf/ /opt/docker/ @@ -26,7 +21,7 @@ RUN /usr/local/bin/yum-install \ s!^(\s*ErrorLog)\s+\S+!\1 /proc/self/fd/2!g; \ ' /etc/httpd/conf/httpd.conf /etc/httpd/conf.d/ssl.conf \ && /opt/docker/bin/provision run --tag bootstrap --role webdevops-apache --role webdevops-php-apache \ - && /opt/docker/bin/bootstrap.sh - + && /opt/docker/bin/bootstrap.sh \ + && docker-image-cleanup EXPOSE 80 443 diff --git a/docker/php-apache/centos-7-php7/Dockerfile.jinja2 b/docker/php-apache/centos-7-php7/Dockerfile.jinja2 index bc5cf8f87..e0fe82e7c 100644 --- a/docker/php-apache/centos-7-php7/Dockerfile.jinja2 +++ b/docker/php-apache/centos-7-php7/Dockerfile.jinja2 @@ -1,7 +1,5 @@ {{ docker.from("php", "centos-7-php7") }} -{{ docker.version() }} - {{ environment.web() }} {{ environment.webPhp() }} diff --git a/docker/php-apache/centos-7-php7/conf/bin/service.d/httpd.d/10-init.sh b/docker/php-apache/centos-7-php7/conf/bin/service.d/httpd.d/10-init.sh index d3f1a0c9c..b9d57997e 100644 --- a/docker/php-apache/centos-7-php7/conf/bin/service.d/httpd.d/10-init.sh +++ b/docker/php-apache/centos-7-php7/conf/bin/service.d/httpd.d/10-init.sh @@ -5,15 +5,17 @@ if [[ ! -e "$WEB_DOCUMENT_ROOT" ]]; then fi # Replace markers -find /opt/docker/etc/httpd/ -iname '*.conf' -print0 | xargs -0 -r rpl --quiet "" "$WEB_DOCUMENT_INDEX" > /dev/null -find /opt/docker/etc/httpd/ -iname '*.conf' -print0 | xargs -0 -r rpl --quiet "" "$WEB_DOCUMENT_ROOT" > /dev/null -find /opt/docker/etc/httpd/ -iname '*.conf' -print0 | xargs -0 -r rpl --quiet "" "$WEB_ALIAS_DOMAIN" > /dev/null -find /opt/docker/etc/httpd/ -iname '*.conf' -print0 | xargs -0 -r rpl --quiet "" "$HOSTNAME" > /dev/null +go-replace \ + -s "" -r "$WEB_DOCUMENT_INDEX" \ + -s "" -r "$WEB_DOCUMENT_ROOT" \ + -s "" -r "$WEB_ALIAS_DOMAIN" \ + -s "" -r "$HOSTNAME" \ + -s "" -r "$WEB_PHP_SOCKET" \ + --path=/opt/docker/etc/httpd/ \ + --path-pattern='*.conf' \ + --ignore-empty -if [[ -n "${WEB_PHP_SOCKET+x}" ]]; then - ## WEB_PHP_SOCKET is set - find /opt/docker/etc/httpd/ -iname '*.conf' -print0 | xargs -0 -r rpl --quiet "" "$WEB_PHP_SOCKET" > /dev/null -else +if [[ -z "${WEB_PHP_SOCKET+x}" ]]; then ## WEB_PHP_SOCKET is not set, remove PHP files rm -f -- /opt/docker/etc/httpd/conf.d/10-php.conf fi diff --git a/docker/php-apache/centos-7-php7/conf/etc/httpd/conf.d/10-log.conf b/docker/php-apache/centos-7-php7/conf/etc/httpd/conf.d/10-log.conf index e4c4be4f2..ef0c73d38 100644 --- a/docker/php-apache/centos-7-php7/conf/etc/httpd/conf.d/10-log.conf +++ b/docker/php-apache/centos-7-php7/conf/etc/httpd/conf.d/10-log.conf @@ -1,4 +1,4 @@ LogFormat "[httpd:access] %V:%p %h %l %u %t \"%r\" %>s bytesIn:%I bytesOut:%O reqTime:%T" dockerlog LogLevel warn -CustomLog /proc/self/fd/1 dockerlog -ErrorLog /proc/self/fd/2 +CustomLog /docker.stdout dockerlog +ErrorLog /docker.stderr diff --git a/docker/php-apache/centos-7-php7/conf/provision/roles/webdevops-apache/tasks/bootstrap.yml b/docker/php-apache/centos-7-php7/conf/provision/roles/webdevops-apache/tasks/bootstrap.yml index 2be18b0e0..c285be286 100644 --- a/docker/php-apache/centos-7-php7/conf/provision/roles/webdevops-apache/tasks/bootstrap.yml +++ b/docker/php-apache/centos-7-php7/conf/provision/roles/webdevops-apache/tasks/bootstrap.yml @@ -84,7 +84,7 @@ with_items: - 'a2dismod mpm_event' - 'a2enmod mpm_event' - when: (ansible_distribution == 'Ubuntu' and ansible_lsb.major_release|int >= 14) or (ansible_distribution == 'Debian' and ansible_lsb.major_release|int >= 8) + when: (ansible_distribution == 'Ubuntu' and docker_image_info_distribution_version|int >= 14) or (ansible_distribution == 'Debian' and docker_image_info_distribution_version|int >= 8) - name: Manage modules [Alpine family] lineinfile: diff --git a/docker/php-apache/centos-7/Dockerfile b/docker/php-apache/centos-7/Dockerfile index bd5d5b4c6..049b849ff 100644 --- a/docker/php-apache/centos-7/Dockerfile +++ b/docker/php-apache/centos-7/Dockerfile @@ -5,15 +5,10 @@ FROM webdevops/php:centos-7 -MAINTAINER info@webdevops.io -LABEL vendor=WebDevOps.io -LABEL io.webdevops.layout=8 -LABEL io.webdevops.version=1.5.0 - -ENV WEB_DOCUMENT_ROOT /app -ENV WEB_DOCUMENT_INDEX index.php -ENV WEB_ALIAS_DOMAIN *.vm -ENV WEB_PHP_SOCKET 127.0.0.1:9000 +ENV WEB_DOCUMENT_ROOT=/app \ + WEB_DOCUMENT_INDEX=index.php \ + WEB_ALIAS_DOMAIN=*.vm +ENV WEB_PHP_SOCKET=127.0.0.1:9000 COPY conf/ /opt/docker/ @@ -26,7 +21,7 @@ RUN /usr/local/bin/yum-install \ s!^(\s*ErrorLog)\s+\S+!\1 /proc/self/fd/2!g; \ ' /etc/httpd/conf/httpd.conf /etc/httpd/conf.d/ssl.conf \ && /opt/docker/bin/provision run --tag bootstrap --role webdevops-apache --role webdevops-php-apache \ - && /opt/docker/bin/bootstrap.sh - + && /opt/docker/bin/bootstrap.sh \ + && docker-image-cleanup EXPOSE 80 443 diff --git a/docker/php-apache/centos-7/Dockerfile.jinja2 b/docker/php-apache/centos-7/Dockerfile.jinja2 index 28e91a3ba..81a28b30c 100644 --- a/docker/php-apache/centos-7/Dockerfile.jinja2 +++ b/docker/php-apache/centos-7/Dockerfile.jinja2 @@ -1,7 +1,5 @@ {{ docker.from("php", "centos-7") }} -{{ docker.version() }} - {{ environment.web() }} {{ environment.webPhp() }} diff --git a/docker/php-apache/centos-7/conf/bin/service.d/httpd.d/10-init.sh b/docker/php-apache/centos-7/conf/bin/service.d/httpd.d/10-init.sh index d3f1a0c9c..b9d57997e 100644 --- a/docker/php-apache/centos-7/conf/bin/service.d/httpd.d/10-init.sh +++ b/docker/php-apache/centos-7/conf/bin/service.d/httpd.d/10-init.sh @@ -5,15 +5,17 @@ if [[ ! -e "$WEB_DOCUMENT_ROOT" ]]; then fi # Replace markers -find /opt/docker/etc/httpd/ -iname '*.conf' -print0 | xargs -0 -r rpl --quiet "" "$WEB_DOCUMENT_INDEX" > /dev/null -find /opt/docker/etc/httpd/ -iname '*.conf' -print0 | xargs -0 -r rpl --quiet "" "$WEB_DOCUMENT_ROOT" > /dev/null -find /opt/docker/etc/httpd/ -iname '*.conf' -print0 | xargs -0 -r rpl --quiet "" "$WEB_ALIAS_DOMAIN" > /dev/null -find /opt/docker/etc/httpd/ -iname '*.conf' -print0 | xargs -0 -r rpl --quiet "" "$HOSTNAME" > /dev/null +go-replace \ + -s "" -r "$WEB_DOCUMENT_INDEX" \ + -s "" -r "$WEB_DOCUMENT_ROOT" \ + -s "" -r "$WEB_ALIAS_DOMAIN" \ + -s "" -r "$HOSTNAME" \ + -s "" -r "$WEB_PHP_SOCKET" \ + --path=/opt/docker/etc/httpd/ \ + --path-pattern='*.conf' \ + --ignore-empty -if [[ -n "${WEB_PHP_SOCKET+x}" ]]; then - ## WEB_PHP_SOCKET is set - find /opt/docker/etc/httpd/ -iname '*.conf' -print0 | xargs -0 -r rpl --quiet "" "$WEB_PHP_SOCKET" > /dev/null -else +if [[ -z "${WEB_PHP_SOCKET+x}" ]]; then ## WEB_PHP_SOCKET is not set, remove PHP files rm -f -- /opt/docker/etc/httpd/conf.d/10-php.conf fi diff --git a/docker/php-apache/centos-7/conf/etc/httpd/conf.d/10-log.conf b/docker/php-apache/centos-7/conf/etc/httpd/conf.d/10-log.conf index e4c4be4f2..ef0c73d38 100644 --- a/docker/php-apache/centos-7/conf/etc/httpd/conf.d/10-log.conf +++ b/docker/php-apache/centos-7/conf/etc/httpd/conf.d/10-log.conf @@ -1,4 +1,4 @@ LogFormat "[httpd:access] %V:%p %h %l %u %t \"%r\" %>s bytesIn:%I bytesOut:%O reqTime:%T" dockerlog LogLevel warn -CustomLog /proc/self/fd/1 dockerlog -ErrorLog /proc/self/fd/2 +CustomLog /docker.stdout dockerlog +ErrorLog /docker.stderr diff --git a/docker/php-apache/centos-7/conf/provision/roles/webdevops-apache/tasks/bootstrap.yml b/docker/php-apache/centos-7/conf/provision/roles/webdevops-apache/tasks/bootstrap.yml index 2be18b0e0..c285be286 100644 --- a/docker/php-apache/centos-7/conf/provision/roles/webdevops-apache/tasks/bootstrap.yml +++ b/docker/php-apache/centos-7/conf/provision/roles/webdevops-apache/tasks/bootstrap.yml @@ -84,7 +84,7 @@ with_items: - 'a2dismod mpm_event' - 'a2enmod mpm_event' - when: (ansible_distribution == 'Ubuntu' and ansible_lsb.major_release|int >= 14) or (ansible_distribution == 'Debian' and ansible_lsb.major_release|int >= 8) + when: (ansible_distribution == 'Ubuntu' and docker_image_info_distribution_version|int >= 14) or (ansible_distribution == 'Debian' and docker_image_info_distribution_version|int >= 8) - name: Manage modules [Alpine family] lineinfile: diff --git a/docker/php-apache/debian-7/Dockerfile b/docker/php-apache/debian-7/Dockerfile index 7773eb024..6144ad347 100644 --- a/docker/php-apache/debian-7/Dockerfile +++ b/docker/php-apache/debian-7/Dockerfile @@ -5,15 +5,10 @@ FROM webdevops/php:debian-7 -MAINTAINER info@webdevops.io -LABEL vendor=WebDevOps.io -LABEL io.webdevops.layout=8 -LABEL io.webdevops.version=1.5.0 - -ENV WEB_DOCUMENT_ROOT /app -ENV WEB_DOCUMENT_INDEX index.php -ENV WEB_ALIAS_DOMAIN *.vm -ENV WEB_PHP_SOCKET 127.0.0.1:9000 +ENV WEB_DOCUMENT_ROOT=/app \ + WEB_DOCUMENT_INDEX=index.php \ + WEB_ALIAS_DOMAIN=*.vm +ENV WEB_PHP_SOCKET=127.0.0.1:9000 COPY conf/ /opt/docker/ @@ -29,7 +24,7 @@ RUN /usr/local/bin/apt-install \ && rm -f /etc/apache2/sites-enabled/* \ && a2enmod actions fastcgi ssl rewrite headers expires \ && /opt/docker/bin/provision run --tag bootstrap --role webdevops-apache --role webdevops-php-apache \ - && /opt/docker/bin/bootstrap.sh - + && /opt/docker/bin/bootstrap.sh \ + && docker-image-cleanup EXPOSE 80 443 diff --git a/docker/php-apache/debian-7/Dockerfile.jinja2 b/docker/php-apache/debian-7/Dockerfile.jinja2 index bd3dd2882..3db5771bb 100644 --- a/docker/php-apache/debian-7/Dockerfile.jinja2 +++ b/docker/php-apache/debian-7/Dockerfile.jinja2 @@ -1,7 +1,5 @@ {{ docker.from("php", "debian-7") }} -{{ docker.version() }} - {{ environment.web() }} {{ environment.webPhp() }} diff --git a/docker/php-apache/debian-7/conf/bin/service.d/httpd.d/10-init.sh b/docker/php-apache/debian-7/conf/bin/service.d/httpd.d/10-init.sh index d3f1a0c9c..b9d57997e 100644 --- a/docker/php-apache/debian-7/conf/bin/service.d/httpd.d/10-init.sh +++ b/docker/php-apache/debian-7/conf/bin/service.d/httpd.d/10-init.sh @@ -5,15 +5,17 @@ if [[ ! -e "$WEB_DOCUMENT_ROOT" ]]; then fi # Replace markers -find /opt/docker/etc/httpd/ -iname '*.conf' -print0 | xargs -0 -r rpl --quiet "" "$WEB_DOCUMENT_INDEX" > /dev/null -find /opt/docker/etc/httpd/ -iname '*.conf' -print0 | xargs -0 -r rpl --quiet "" "$WEB_DOCUMENT_ROOT" > /dev/null -find /opt/docker/etc/httpd/ -iname '*.conf' -print0 | xargs -0 -r rpl --quiet "" "$WEB_ALIAS_DOMAIN" > /dev/null -find /opt/docker/etc/httpd/ -iname '*.conf' -print0 | xargs -0 -r rpl --quiet "" "$HOSTNAME" > /dev/null +go-replace \ + -s "" -r "$WEB_DOCUMENT_INDEX" \ + -s "" -r "$WEB_DOCUMENT_ROOT" \ + -s "" -r "$WEB_ALIAS_DOMAIN" \ + -s "" -r "$HOSTNAME" \ + -s "" -r "$WEB_PHP_SOCKET" \ + --path=/opt/docker/etc/httpd/ \ + --path-pattern='*.conf' \ + --ignore-empty -if [[ -n "${WEB_PHP_SOCKET+x}" ]]; then - ## WEB_PHP_SOCKET is set - find /opt/docker/etc/httpd/ -iname '*.conf' -print0 | xargs -0 -r rpl --quiet "" "$WEB_PHP_SOCKET" > /dev/null -else +if [[ -z "${WEB_PHP_SOCKET+x}" ]]; then ## WEB_PHP_SOCKET is not set, remove PHP files rm -f -- /opt/docker/etc/httpd/conf.d/10-php.conf fi diff --git a/docker/php-apache/debian-7/conf/etc/httpd/conf.d/10-log.conf b/docker/php-apache/debian-7/conf/etc/httpd/conf.d/10-log.conf index e4c4be4f2..ef0c73d38 100644 --- a/docker/php-apache/debian-7/conf/etc/httpd/conf.d/10-log.conf +++ b/docker/php-apache/debian-7/conf/etc/httpd/conf.d/10-log.conf @@ -1,4 +1,4 @@ LogFormat "[httpd:access] %V:%p %h %l %u %t \"%r\" %>s bytesIn:%I bytesOut:%O reqTime:%T" dockerlog LogLevel warn -CustomLog /proc/self/fd/1 dockerlog -ErrorLog /proc/self/fd/2 +CustomLog /docker.stdout dockerlog +ErrorLog /docker.stderr diff --git a/docker/php-apache/debian-7/conf/provision/roles/webdevops-apache/tasks/bootstrap.yml b/docker/php-apache/debian-7/conf/provision/roles/webdevops-apache/tasks/bootstrap.yml index 2be18b0e0..c285be286 100644 --- a/docker/php-apache/debian-7/conf/provision/roles/webdevops-apache/tasks/bootstrap.yml +++ b/docker/php-apache/debian-7/conf/provision/roles/webdevops-apache/tasks/bootstrap.yml @@ -84,7 +84,7 @@ with_items: - 'a2dismod mpm_event' - 'a2enmod mpm_event' - when: (ansible_distribution == 'Ubuntu' and ansible_lsb.major_release|int >= 14) or (ansible_distribution == 'Debian' and ansible_lsb.major_release|int >= 8) + when: (ansible_distribution == 'Ubuntu' and docker_image_info_distribution_version|int >= 14) or (ansible_distribution == 'Debian' and docker_image_info_distribution_version|int >= 8) - name: Manage modules [Alpine family] lineinfile: diff --git a/docker/php-apache/debian-8-php7/Dockerfile b/docker/php-apache/debian-8-php7/Dockerfile index b3fff5338..b109d736b 100644 --- a/docker/php-apache/debian-8-php7/Dockerfile +++ b/docker/php-apache/debian-8-php7/Dockerfile @@ -5,15 +5,10 @@ FROM webdevops/php:debian-8-php7 -MAINTAINER info@webdevops.io -LABEL vendor=WebDevOps.io -LABEL io.webdevops.layout=8 -LABEL io.webdevops.version=1.5.0 - -ENV WEB_DOCUMENT_ROOT /app -ENV WEB_DOCUMENT_INDEX index.php -ENV WEB_ALIAS_DOMAIN *.vm -ENV WEB_PHP_SOCKET 127.0.0.1:9000 +ENV WEB_DOCUMENT_ROOT=/app \ + WEB_DOCUMENT_INDEX=index.php \ + WEB_ALIAS_DOMAIN=*.vm +ENV WEB_PHP_SOCKET=127.0.0.1:9000 COPY conf/ /opt/docker/ @@ -28,7 +23,7 @@ RUN /usr/local/bin/apt-install \ && rm -f /etc/apache2/sites-enabled/* \ && a2enmod actions proxy proxy_fcgi ssl rewrite headers expires \ && /opt/docker/bin/provision run --tag bootstrap --role webdevops-apache --role webdevops-php-apache \ - && /opt/docker/bin/bootstrap.sh - + && /opt/docker/bin/bootstrap.sh \ + && docker-image-cleanup EXPOSE 80 443 diff --git a/docker/php-apache/debian-8-php7/Dockerfile.jinja2 b/docker/php-apache/debian-8-php7/Dockerfile.jinja2 index 4a3d427cb..31b1cc83f 100644 --- a/docker/php-apache/debian-8-php7/Dockerfile.jinja2 +++ b/docker/php-apache/debian-8-php7/Dockerfile.jinja2 @@ -1,7 +1,5 @@ {{ docker.from("php", "debian-8-php7") }} -{{ docker.version() }} - {{ environment.web() }} {{ environment.webPhp() }} diff --git a/docker/php-apache/debian-8-php7/conf/bin/service.d/httpd.d/10-init.sh b/docker/php-apache/debian-8-php7/conf/bin/service.d/httpd.d/10-init.sh index d3f1a0c9c..b9d57997e 100644 --- a/docker/php-apache/debian-8-php7/conf/bin/service.d/httpd.d/10-init.sh +++ b/docker/php-apache/debian-8-php7/conf/bin/service.d/httpd.d/10-init.sh @@ -5,15 +5,17 @@ if [[ ! -e "$WEB_DOCUMENT_ROOT" ]]; then fi # Replace markers -find /opt/docker/etc/httpd/ -iname '*.conf' -print0 | xargs -0 -r rpl --quiet "" "$WEB_DOCUMENT_INDEX" > /dev/null -find /opt/docker/etc/httpd/ -iname '*.conf' -print0 | xargs -0 -r rpl --quiet "" "$WEB_DOCUMENT_ROOT" > /dev/null -find /opt/docker/etc/httpd/ -iname '*.conf' -print0 | xargs -0 -r rpl --quiet "" "$WEB_ALIAS_DOMAIN" > /dev/null -find /opt/docker/etc/httpd/ -iname '*.conf' -print0 | xargs -0 -r rpl --quiet "" "$HOSTNAME" > /dev/null +go-replace \ + -s "" -r "$WEB_DOCUMENT_INDEX" \ + -s "" -r "$WEB_DOCUMENT_ROOT" \ + -s "" -r "$WEB_ALIAS_DOMAIN" \ + -s "" -r "$HOSTNAME" \ + -s "" -r "$WEB_PHP_SOCKET" \ + --path=/opt/docker/etc/httpd/ \ + --path-pattern='*.conf' \ + --ignore-empty -if [[ -n "${WEB_PHP_SOCKET+x}" ]]; then - ## WEB_PHP_SOCKET is set - find /opt/docker/etc/httpd/ -iname '*.conf' -print0 | xargs -0 -r rpl --quiet "" "$WEB_PHP_SOCKET" > /dev/null -else +if [[ -z "${WEB_PHP_SOCKET+x}" ]]; then ## WEB_PHP_SOCKET is not set, remove PHP files rm -f -- /opt/docker/etc/httpd/conf.d/10-php.conf fi diff --git a/docker/php-apache/debian-8-php7/conf/etc/httpd/conf.d/10-log.conf b/docker/php-apache/debian-8-php7/conf/etc/httpd/conf.d/10-log.conf index e4c4be4f2..ef0c73d38 100644 --- a/docker/php-apache/debian-8-php7/conf/etc/httpd/conf.d/10-log.conf +++ b/docker/php-apache/debian-8-php7/conf/etc/httpd/conf.d/10-log.conf @@ -1,4 +1,4 @@ LogFormat "[httpd:access] %V:%p %h %l %u %t \"%r\" %>s bytesIn:%I bytesOut:%O reqTime:%T" dockerlog LogLevel warn -CustomLog /proc/self/fd/1 dockerlog -ErrorLog /proc/self/fd/2 +CustomLog /docker.stdout dockerlog +ErrorLog /docker.stderr diff --git a/docker/php-apache/debian-8-php7/conf/provision/roles/webdevops-apache/tasks/bootstrap.yml b/docker/php-apache/debian-8-php7/conf/provision/roles/webdevops-apache/tasks/bootstrap.yml index 2be18b0e0..c285be286 100644 --- a/docker/php-apache/debian-8-php7/conf/provision/roles/webdevops-apache/tasks/bootstrap.yml +++ b/docker/php-apache/debian-8-php7/conf/provision/roles/webdevops-apache/tasks/bootstrap.yml @@ -84,7 +84,7 @@ with_items: - 'a2dismod mpm_event' - 'a2enmod mpm_event' - when: (ansible_distribution == 'Ubuntu' and ansible_lsb.major_release|int >= 14) or (ansible_distribution == 'Debian' and ansible_lsb.major_release|int >= 8) + when: (ansible_distribution == 'Ubuntu' and docker_image_info_distribution_version|int >= 14) or (ansible_distribution == 'Debian' and docker_image_info_distribution_version|int >= 8) - name: Manage modules [Alpine family] lineinfile: diff --git a/docker/php-apache/debian-8/Dockerfile b/docker/php-apache/debian-8/Dockerfile index 0123662f7..d3a2e8d4d 100644 --- a/docker/php-apache/debian-8/Dockerfile +++ b/docker/php-apache/debian-8/Dockerfile @@ -5,15 +5,10 @@ FROM webdevops/php:debian-8 -MAINTAINER info@webdevops.io -LABEL vendor=WebDevOps.io -LABEL io.webdevops.layout=8 -LABEL io.webdevops.version=1.5.0 - -ENV WEB_DOCUMENT_ROOT /app -ENV WEB_DOCUMENT_INDEX index.php -ENV WEB_ALIAS_DOMAIN *.vm -ENV WEB_PHP_SOCKET 127.0.0.1:9000 +ENV WEB_DOCUMENT_ROOT=/app \ + WEB_DOCUMENT_INDEX=index.php \ + WEB_ALIAS_DOMAIN=*.vm +ENV WEB_PHP_SOCKET=127.0.0.1:9000 COPY conf/ /opt/docker/ @@ -28,7 +23,7 @@ RUN /usr/local/bin/apt-install \ && rm -f /etc/apache2/sites-enabled/* \ && a2enmod actions proxy proxy_fcgi ssl rewrite headers expires \ && /opt/docker/bin/provision run --tag bootstrap --role webdevops-apache --role webdevops-php-apache \ - && /opt/docker/bin/bootstrap.sh - + && /opt/docker/bin/bootstrap.sh \ + && docker-image-cleanup EXPOSE 80 443 diff --git a/docker/php-apache/debian-8/Dockerfile.jinja2 b/docker/php-apache/debian-8/Dockerfile.jinja2 index 2dce31576..252c8871d 100644 --- a/docker/php-apache/debian-8/Dockerfile.jinja2 +++ b/docker/php-apache/debian-8/Dockerfile.jinja2 @@ -1,7 +1,5 @@ {{ docker.from("php", "debian-8") }} -{{ docker.version() }} - {{ environment.web() }} {{ environment.webPhp() }} diff --git a/docker/php-apache/debian-8/conf/bin/service.d/httpd.d/10-init.sh b/docker/php-apache/debian-8/conf/bin/service.d/httpd.d/10-init.sh index d3f1a0c9c..b9d57997e 100644 --- a/docker/php-apache/debian-8/conf/bin/service.d/httpd.d/10-init.sh +++ b/docker/php-apache/debian-8/conf/bin/service.d/httpd.d/10-init.sh @@ -5,15 +5,17 @@ if [[ ! -e "$WEB_DOCUMENT_ROOT" ]]; then fi # Replace markers -find /opt/docker/etc/httpd/ -iname '*.conf' -print0 | xargs -0 -r rpl --quiet "" "$WEB_DOCUMENT_INDEX" > /dev/null -find /opt/docker/etc/httpd/ -iname '*.conf' -print0 | xargs -0 -r rpl --quiet "" "$WEB_DOCUMENT_ROOT" > /dev/null -find /opt/docker/etc/httpd/ -iname '*.conf' -print0 | xargs -0 -r rpl --quiet "" "$WEB_ALIAS_DOMAIN" > /dev/null -find /opt/docker/etc/httpd/ -iname '*.conf' -print0 | xargs -0 -r rpl --quiet "" "$HOSTNAME" > /dev/null +go-replace \ + -s "" -r "$WEB_DOCUMENT_INDEX" \ + -s "" -r "$WEB_DOCUMENT_ROOT" \ + -s "" -r "$WEB_ALIAS_DOMAIN" \ + -s "" -r "$HOSTNAME" \ + -s "" -r "$WEB_PHP_SOCKET" \ + --path=/opt/docker/etc/httpd/ \ + --path-pattern='*.conf' \ + --ignore-empty -if [[ -n "${WEB_PHP_SOCKET+x}" ]]; then - ## WEB_PHP_SOCKET is set - find /opt/docker/etc/httpd/ -iname '*.conf' -print0 | xargs -0 -r rpl --quiet "" "$WEB_PHP_SOCKET" > /dev/null -else +if [[ -z "${WEB_PHP_SOCKET+x}" ]]; then ## WEB_PHP_SOCKET is not set, remove PHP files rm -f -- /opt/docker/etc/httpd/conf.d/10-php.conf fi diff --git a/docker/php-apache/debian-8/conf/etc/httpd/conf.d/10-log.conf b/docker/php-apache/debian-8/conf/etc/httpd/conf.d/10-log.conf index e4c4be4f2..ef0c73d38 100644 --- a/docker/php-apache/debian-8/conf/etc/httpd/conf.d/10-log.conf +++ b/docker/php-apache/debian-8/conf/etc/httpd/conf.d/10-log.conf @@ -1,4 +1,4 @@ LogFormat "[httpd:access] %V:%p %h %l %u %t \"%r\" %>s bytesIn:%I bytesOut:%O reqTime:%T" dockerlog LogLevel warn -CustomLog /proc/self/fd/1 dockerlog -ErrorLog /proc/self/fd/2 +CustomLog /docker.stdout dockerlog +ErrorLog /docker.stderr diff --git a/docker/php-apache/debian-8/conf/provision/roles/webdevops-apache/tasks/bootstrap.yml b/docker/php-apache/debian-8/conf/provision/roles/webdevops-apache/tasks/bootstrap.yml index 2be18b0e0..c285be286 100644 --- a/docker/php-apache/debian-8/conf/provision/roles/webdevops-apache/tasks/bootstrap.yml +++ b/docker/php-apache/debian-8/conf/provision/roles/webdevops-apache/tasks/bootstrap.yml @@ -84,7 +84,7 @@ with_items: - 'a2dismod mpm_event' - 'a2enmod mpm_event' - when: (ansible_distribution == 'Ubuntu' and ansible_lsb.major_release|int >= 14) or (ansible_distribution == 'Debian' and ansible_lsb.major_release|int >= 8) + when: (ansible_distribution == 'Ubuntu' and docker_image_info_distribution_version|int >= 14) or (ansible_distribution == 'Debian' and docker_image_info_distribution_version|int >= 8) - name: Manage modules [Alpine family] lineinfile: diff --git a/docker/php-apache/debian-9/Dockerfile b/docker/php-apache/debian-9/Dockerfile index 73d422bac..7ae952ed8 100644 --- a/docker/php-apache/debian-9/Dockerfile +++ b/docker/php-apache/debian-9/Dockerfile @@ -5,15 +5,10 @@ FROM webdevops/php:debian-9 -MAINTAINER info@webdevops.io -LABEL vendor=WebDevOps.io -LABEL io.webdevops.layout=8 -LABEL io.webdevops.version=1.5.0 - -ENV WEB_DOCUMENT_ROOT /app -ENV WEB_DOCUMENT_INDEX index.php -ENV WEB_ALIAS_DOMAIN *.vm -ENV WEB_PHP_SOCKET 127.0.0.1:9000 +ENV WEB_DOCUMENT_ROOT=/app \ + WEB_DOCUMENT_INDEX=index.php \ + WEB_ALIAS_DOMAIN=*.vm +ENV WEB_PHP_SOCKET=127.0.0.1:9000 COPY conf/ /opt/docker/ @@ -27,7 +22,7 @@ RUN /usr/local/bin/apt-install \ && rm -f /etc/apache2/sites-enabled/* \ && a2enmod actions proxy proxy_fcgi ssl rewrite headers expires \ && /opt/docker/bin/provision run --tag bootstrap --role webdevops-apache --role webdevops-php-apache \ - && /opt/docker/bin/bootstrap.sh - + && /opt/docker/bin/bootstrap.sh \ + && docker-image-cleanup EXPOSE 80 443 diff --git a/docker/php-apache/debian-9/Dockerfile.jinja2 b/docker/php-apache/debian-9/Dockerfile.jinja2 index 17ab1a5b9..5243234d8 100644 --- a/docker/php-apache/debian-9/Dockerfile.jinja2 +++ b/docker/php-apache/debian-9/Dockerfile.jinja2 @@ -1,7 +1,5 @@ {{ docker.from("php", "debian-9") }} -{{ docker.version() }} - {{ environment.web() }} {{ environment.webPhp() }} diff --git a/docker/php-apache/debian-9/conf/bin/service.d/httpd.d/10-init.sh b/docker/php-apache/debian-9/conf/bin/service.d/httpd.d/10-init.sh index d3f1a0c9c..b9d57997e 100644 --- a/docker/php-apache/debian-9/conf/bin/service.d/httpd.d/10-init.sh +++ b/docker/php-apache/debian-9/conf/bin/service.d/httpd.d/10-init.sh @@ -5,15 +5,17 @@ if [[ ! -e "$WEB_DOCUMENT_ROOT" ]]; then fi # Replace markers -find /opt/docker/etc/httpd/ -iname '*.conf' -print0 | xargs -0 -r rpl --quiet "" "$WEB_DOCUMENT_INDEX" > /dev/null -find /opt/docker/etc/httpd/ -iname '*.conf' -print0 | xargs -0 -r rpl --quiet "" "$WEB_DOCUMENT_ROOT" > /dev/null -find /opt/docker/etc/httpd/ -iname '*.conf' -print0 | xargs -0 -r rpl --quiet "" "$WEB_ALIAS_DOMAIN" > /dev/null -find /opt/docker/etc/httpd/ -iname '*.conf' -print0 | xargs -0 -r rpl --quiet "" "$HOSTNAME" > /dev/null +go-replace \ + -s "" -r "$WEB_DOCUMENT_INDEX" \ + -s "" -r "$WEB_DOCUMENT_ROOT" \ + -s "" -r "$WEB_ALIAS_DOMAIN" \ + -s "" -r "$HOSTNAME" \ + -s "" -r "$WEB_PHP_SOCKET" \ + --path=/opt/docker/etc/httpd/ \ + --path-pattern='*.conf' \ + --ignore-empty -if [[ -n "${WEB_PHP_SOCKET+x}" ]]; then - ## WEB_PHP_SOCKET is set - find /opt/docker/etc/httpd/ -iname '*.conf' -print0 | xargs -0 -r rpl --quiet "" "$WEB_PHP_SOCKET" > /dev/null -else +if [[ -z "${WEB_PHP_SOCKET+x}" ]]; then ## WEB_PHP_SOCKET is not set, remove PHP files rm -f -- /opt/docker/etc/httpd/conf.d/10-php.conf fi diff --git a/docker/php-apache/debian-9/conf/etc/httpd/conf.d/10-log.conf b/docker/php-apache/debian-9/conf/etc/httpd/conf.d/10-log.conf index e4c4be4f2..ef0c73d38 100644 --- a/docker/php-apache/debian-9/conf/etc/httpd/conf.d/10-log.conf +++ b/docker/php-apache/debian-9/conf/etc/httpd/conf.d/10-log.conf @@ -1,4 +1,4 @@ LogFormat "[httpd:access] %V:%p %h %l %u %t \"%r\" %>s bytesIn:%I bytesOut:%O reqTime:%T" dockerlog LogLevel warn -CustomLog /proc/self/fd/1 dockerlog -ErrorLog /proc/self/fd/2 +CustomLog /docker.stdout dockerlog +ErrorLog /docker.stderr diff --git a/docker/php-apache/debian-9/conf/provision/roles/webdevops-apache/tasks/bootstrap.yml b/docker/php-apache/debian-9/conf/provision/roles/webdevops-apache/tasks/bootstrap.yml index 2be18b0e0..c285be286 100644 --- a/docker/php-apache/debian-9/conf/provision/roles/webdevops-apache/tasks/bootstrap.yml +++ b/docker/php-apache/debian-9/conf/provision/roles/webdevops-apache/tasks/bootstrap.yml @@ -84,7 +84,7 @@ with_items: - 'a2dismod mpm_event' - 'a2enmod mpm_event' - when: (ansible_distribution == 'Ubuntu' and ansible_lsb.major_release|int >= 14) or (ansible_distribution == 'Debian' and ansible_lsb.major_release|int >= 8) + when: (ansible_distribution == 'Ubuntu' and docker_image_info_distribution_version|int >= 14) or (ansible_distribution == 'Debian' and docker_image_info_distribution_version|int >= 8) - name: Manage modules [Alpine family] lineinfile: diff --git a/docker/php-apache/ubuntu-12.04/Dockerfile b/docker/php-apache/ubuntu-12.04/Dockerfile index 3a5ac53b2..f647ae3c8 100644 --- a/docker/php-apache/ubuntu-12.04/Dockerfile +++ b/docker/php-apache/ubuntu-12.04/Dockerfile @@ -5,15 +5,10 @@ FROM webdevops/php:ubuntu-12.04 -MAINTAINER info@webdevops.io -LABEL vendor=WebDevOps.io -LABEL io.webdevops.layout=8 -LABEL io.webdevops.version=1.5.0 - -ENV WEB_DOCUMENT_ROOT /app -ENV WEB_DOCUMENT_INDEX index.php -ENV WEB_ALIAS_DOMAIN *.vm -ENV WEB_PHP_SOCKET 127.0.0.1:9000 +ENV WEB_DOCUMENT_ROOT=/app \ + WEB_DOCUMENT_INDEX=index.php \ + WEB_ALIAS_DOMAIN=*.vm +ENV WEB_PHP_SOCKET=127.0.0.1:9000 COPY conf/ /opt/docker/ @@ -30,7 +25,7 @@ RUN /usr/local/bin/apt-install \ && a2enmod actions fastcgi ssl rewrite headers version expires \ && mkdir -p /var/lock/apache2 \ && /opt/docker/bin/provision run --tag bootstrap --role webdevops-apache --role webdevops-php-apache \ - && /opt/docker/bin/bootstrap.sh - + && /opt/docker/bin/bootstrap.sh \ + && docker-image-cleanup EXPOSE 80 443 diff --git a/docker/php-apache/ubuntu-12.04/Dockerfile.jinja2 b/docker/php-apache/ubuntu-12.04/Dockerfile.jinja2 index 4aab83610..d7c006a53 100644 --- a/docker/php-apache/ubuntu-12.04/Dockerfile.jinja2 +++ b/docker/php-apache/ubuntu-12.04/Dockerfile.jinja2 @@ -1,7 +1,5 @@ {{ docker.from("php", "ubuntu-12.04") }} -{{ docker.version() }} - {{ environment.web() }} {{ environment.webPhp() }} diff --git a/docker/php-apache/ubuntu-12.04/conf/bin/service.d/httpd.d/10-init.sh b/docker/php-apache/ubuntu-12.04/conf/bin/service.d/httpd.d/10-init.sh index d3f1a0c9c..b9d57997e 100644 --- a/docker/php-apache/ubuntu-12.04/conf/bin/service.d/httpd.d/10-init.sh +++ b/docker/php-apache/ubuntu-12.04/conf/bin/service.d/httpd.d/10-init.sh @@ -5,15 +5,17 @@ if [[ ! -e "$WEB_DOCUMENT_ROOT" ]]; then fi # Replace markers -find /opt/docker/etc/httpd/ -iname '*.conf' -print0 | xargs -0 -r rpl --quiet "" "$WEB_DOCUMENT_INDEX" > /dev/null -find /opt/docker/etc/httpd/ -iname '*.conf' -print0 | xargs -0 -r rpl --quiet "" "$WEB_DOCUMENT_ROOT" > /dev/null -find /opt/docker/etc/httpd/ -iname '*.conf' -print0 | xargs -0 -r rpl --quiet "" "$WEB_ALIAS_DOMAIN" > /dev/null -find /opt/docker/etc/httpd/ -iname '*.conf' -print0 | xargs -0 -r rpl --quiet "" "$HOSTNAME" > /dev/null +go-replace \ + -s "" -r "$WEB_DOCUMENT_INDEX" \ + -s "" -r "$WEB_DOCUMENT_ROOT" \ + -s "" -r "$WEB_ALIAS_DOMAIN" \ + -s "" -r "$HOSTNAME" \ + -s "" -r "$WEB_PHP_SOCKET" \ + --path=/opt/docker/etc/httpd/ \ + --path-pattern='*.conf' \ + --ignore-empty -if [[ -n "${WEB_PHP_SOCKET+x}" ]]; then - ## WEB_PHP_SOCKET is set - find /opt/docker/etc/httpd/ -iname '*.conf' -print0 | xargs -0 -r rpl --quiet "" "$WEB_PHP_SOCKET" > /dev/null -else +if [[ -z "${WEB_PHP_SOCKET+x}" ]]; then ## WEB_PHP_SOCKET is not set, remove PHP files rm -f -- /opt/docker/etc/httpd/conf.d/10-php.conf fi diff --git a/docker/php-apache/ubuntu-12.04/conf/etc/httpd/conf.d/10-log.conf b/docker/php-apache/ubuntu-12.04/conf/etc/httpd/conf.d/10-log.conf index e4c4be4f2..ef0c73d38 100644 --- a/docker/php-apache/ubuntu-12.04/conf/etc/httpd/conf.d/10-log.conf +++ b/docker/php-apache/ubuntu-12.04/conf/etc/httpd/conf.d/10-log.conf @@ -1,4 +1,4 @@ LogFormat "[httpd:access] %V:%p %h %l %u %t \"%r\" %>s bytesIn:%I bytesOut:%O reqTime:%T" dockerlog LogLevel warn -CustomLog /proc/self/fd/1 dockerlog -ErrorLog /proc/self/fd/2 +CustomLog /docker.stdout dockerlog +ErrorLog /docker.stderr diff --git a/docker/php-apache/ubuntu-12.04/conf/provision/roles/webdevops-apache/tasks/bootstrap.yml b/docker/php-apache/ubuntu-12.04/conf/provision/roles/webdevops-apache/tasks/bootstrap.yml index 2be18b0e0..c285be286 100644 --- a/docker/php-apache/ubuntu-12.04/conf/provision/roles/webdevops-apache/tasks/bootstrap.yml +++ b/docker/php-apache/ubuntu-12.04/conf/provision/roles/webdevops-apache/tasks/bootstrap.yml @@ -84,7 +84,7 @@ with_items: - 'a2dismod mpm_event' - 'a2enmod mpm_event' - when: (ansible_distribution == 'Ubuntu' and ansible_lsb.major_release|int >= 14) or (ansible_distribution == 'Debian' and ansible_lsb.major_release|int >= 8) + when: (ansible_distribution == 'Ubuntu' and docker_image_info_distribution_version|int >= 14) or (ansible_distribution == 'Debian' and docker_image_info_distribution_version|int >= 8) - name: Manage modules [Alpine family] lineinfile: diff --git a/docker/php-apache/ubuntu-14.04/Dockerfile b/docker/php-apache/ubuntu-14.04/Dockerfile index 77a9c5504..5ed4d6ab3 100644 --- a/docker/php-apache/ubuntu-14.04/Dockerfile +++ b/docker/php-apache/ubuntu-14.04/Dockerfile @@ -5,15 +5,10 @@ FROM webdevops/php:ubuntu-14.04 -MAINTAINER info@webdevops.io -LABEL vendor=WebDevOps.io -LABEL io.webdevops.layout=8 -LABEL io.webdevops.version=1.5.0 - -ENV WEB_DOCUMENT_ROOT /app -ENV WEB_DOCUMENT_INDEX index.php -ENV WEB_ALIAS_DOMAIN *.vm -ENV WEB_PHP_SOCKET 127.0.0.1:9000 +ENV WEB_DOCUMENT_ROOT=/app \ + WEB_DOCUMENT_INDEX=index.php \ + WEB_ALIAS_DOMAIN=*.vm +ENV WEB_PHP_SOCKET=127.0.0.1:9000 COPY conf/ /opt/docker/ @@ -30,7 +25,7 @@ RUN /usr/local/bin/apt-install \ && a2enmod actions fastcgi ssl rewrite headers expires \ && mkdir -p /var/lock/apache2 \ && /opt/docker/bin/provision run --tag bootstrap --role webdevops-apache --role webdevops-php-apache \ - && /opt/docker/bin/bootstrap.sh - + && /opt/docker/bin/bootstrap.sh \ + && docker-image-cleanup EXPOSE 80 443 diff --git a/docker/php-apache/ubuntu-14.04/Dockerfile.jinja2 b/docker/php-apache/ubuntu-14.04/Dockerfile.jinja2 index 90f10f302..1132aa352 100644 --- a/docker/php-apache/ubuntu-14.04/Dockerfile.jinja2 +++ b/docker/php-apache/ubuntu-14.04/Dockerfile.jinja2 @@ -1,7 +1,5 @@ {{ docker.from("php", "ubuntu-14.04") }} -{{ docker.version() }} - {{ environment.web() }} {{ environment.webPhp() }} diff --git a/docker/php-apache/ubuntu-14.04/conf/bin/service.d/httpd.d/10-init.sh b/docker/php-apache/ubuntu-14.04/conf/bin/service.d/httpd.d/10-init.sh index d3f1a0c9c..b9d57997e 100644 --- a/docker/php-apache/ubuntu-14.04/conf/bin/service.d/httpd.d/10-init.sh +++ b/docker/php-apache/ubuntu-14.04/conf/bin/service.d/httpd.d/10-init.sh @@ -5,15 +5,17 @@ if [[ ! -e "$WEB_DOCUMENT_ROOT" ]]; then fi # Replace markers -find /opt/docker/etc/httpd/ -iname '*.conf' -print0 | xargs -0 -r rpl --quiet "" "$WEB_DOCUMENT_INDEX" > /dev/null -find /opt/docker/etc/httpd/ -iname '*.conf' -print0 | xargs -0 -r rpl --quiet "" "$WEB_DOCUMENT_ROOT" > /dev/null -find /opt/docker/etc/httpd/ -iname '*.conf' -print0 | xargs -0 -r rpl --quiet "" "$WEB_ALIAS_DOMAIN" > /dev/null -find /opt/docker/etc/httpd/ -iname '*.conf' -print0 | xargs -0 -r rpl --quiet "" "$HOSTNAME" > /dev/null +go-replace \ + -s "" -r "$WEB_DOCUMENT_INDEX" \ + -s "" -r "$WEB_DOCUMENT_ROOT" \ + -s "" -r "$WEB_ALIAS_DOMAIN" \ + -s "" -r "$HOSTNAME" \ + -s "" -r "$WEB_PHP_SOCKET" \ + --path=/opt/docker/etc/httpd/ \ + --path-pattern='*.conf' \ + --ignore-empty -if [[ -n "${WEB_PHP_SOCKET+x}" ]]; then - ## WEB_PHP_SOCKET is set - find /opt/docker/etc/httpd/ -iname '*.conf' -print0 | xargs -0 -r rpl --quiet "" "$WEB_PHP_SOCKET" > /dev/null -else +if [[ -z "${WEB_PHP_SOCKET+x}" ]]; then ## WEB_PHP_SOCKET is not set, remove PHP files rm -f -- /opt/docker/etc/httpd/conf.d/10-php.conf fi diff --git a/docker/php-apache/ubuntu-14.04/conf/etc/httpd/conf.d/10-log.conf b/docker/php-apache/ubuntu-14.04/conf/etc/httpd/conf.d/10-log.conf index e4c4be4f2..ef0c73d38 100644 --- a/docker/php-apache/ubuntu-14.04/conf/etc/httpd/conf.d/10-log.conf +++ b/docker/php-apache/ubuntu-14.04/conf/etc/httpd/conf.d/10-log.conf @@ -1,4 +1,4 @@ LogFormat "[httpd:access] %V:%p %h %l %u %t \"%r\" %>s bytesIn:%I bytesOut:%O reqTime:%T" dockerlog LogLevel warn -CustomLog /proc/self/fd/1 dockerlog -ErrorLog /proc/self/fd/2 +CustomLog /docker.stdout dockerlog +ErrorLog /docker.stderr diff --git a/docker/php-apache/ubuntu-14.04/conf/provision/roles/webdevops-apache/tasks/bootstrap.yml b/docker/php-apache/ubuntu-14.04/conf/provision/roles/webdevops-apache/tasks/bootstrap.yml index 2be18b0e0..c285be286 100644 --- a/docker/php-apache/ubuntu-14.04/conf/provision/roles/webdevops-apache/tasks/bootstrap.yml +++ b/docker/php-apache/ubuntu-14.04/conf/provision/roles/webdevops-apache/tasks/bootstrap.yml @@ -84,7 +84,7 @@ with_items: - 'a2dismod mpm_event' - 'a2enmod mpm_event' - when: (ansible_distribution == 'Ubuntu' and ansible_lsb.major_release|int >= 14) or (ansible_distribution == 'Debian' and ansible_lsb.major_release|int >= 8) + when: (ansible_distribution == 'Ubuntu' and docker_image_info_distribution_version|int >= 14) or (ansible_distribution == 'Debian' and docker_image_info_distribution_version|int >= 8) - name: Manage modules [Alpine family] lineinfile: diff --git a/docker/php-apache/ubuntu-15.04/Dockerfile b/docker/php-apache/ubuntu-15.04/Dockerfile index c0fdee1f3..d1a2b950c 100644 --- a/docker/php-apache/ubuntu-15.04/Dockerfile +++ b/docker/php-apache/ubuntu-15.04/Dockerfile @@ -5,15 +5,10 @@ FROM webdevops/php:ubuntu-15.04 -MAINTAINER info@webdevops.io -LABEL vendor=WebDevOps.io -LABEL io.webdevops.layout=8 -LABEL io.webdevops.version=1.5.0 - -ENV WEB_DOCUMENT_ROOT /app -ENV WEB_DOCUMENT_INDEX index.php -ENV WEB_ALIAS_DOMAIN *.vm -ENV WEB_PHP_SOCKET 127.0.0.1:9000 +ENV WEB_DOCUMENT_ROOT=/app \ + WEB_DOCUMENT_INDEX=index.php \ + WEB_ALIAS_DOMAIN=*.vm +ENV WEB_PHP_SOCKET=127.0.0.1:9000 COPY conf/ /opt/docker/ @@ -28,7 +23,7 @@ RUN /usr/local/bin/apt-install \ && ln -sf /opt/docker/etc/httpd/main.conf /etc/apache2/sites-enabled/10-docker.conf \ && a2enmod actions proxy proxy_fcgi ssl rewrite headers expires \ && /opt/docker/bin/provision run --tag bootstrap --role webdevops-apache --role webdevops-php-apache \ - && /opt/docker/bin/bootstrap.sh - + && /opt/docker/bin/bootstrap.sh \ + && docker-image-cleanup EXPOSE 80 443 diff --git a/docker/php-apache/ubuntu-15.04/Dockerfile.jinja2 b/docker/php-apache/ubuntu-15.04/Dockerfile.jinja2 index bf0d4f525..1afc56d64 100644 --- a/docker/php-apache/ubuntu-15.04/Dockerfile.jinja2 +++ b/docker/php-apache/ubuntu-15.04/Dockerfile.jinja2 @@ -1,7 +1,5 @@ {{ docker.from("php", "ubuntu-15.04") }} -{{ docker.version() }} - {{ environment.web() }} {{ environment.webPhp() }} diff --git a/docker/php-apache/ubuntu-15.04/conf/bin/service.d/httpd.d/10-init.sh b/docker/php-apache/ubuntu-15.04/conf/bin/service.d/httpd.d/10-init.sh index d3f1a0c9c..b9d57997e 100644 --- a/docker/php-apache/ubuntu-15.04/conf/bin/service.d/httpd.d/10-init.sh +++ b/docker/php-apache/ubuntu-15.04/conf/bin/service.d/httpd.d/10-init.sh @@ -5,15 +5,17 @@ if [[ ! -e "$WEB_DOCUMENT_ROOT" ]]; then fi # Replace markers -find /opt/docker/etc/httpd/ -iname '*.conf' -print0 | xargs -0 -r rpl --quiet "" "$WEB_DOCUMENT_INDEX" > /dev/null -find /opt/docker/etc/httpd/ -iname '*.conf' -print0 | xargs -0 -r rpl --quiet "" "$WEB_DOCUMENT_ROOT" > /dev/null -find /opt/docker/etc/httpd/ -iname '*.conf' -print0 | xargs -0 -r rpl --quiet "" "$WEB_ALIAS_DOMAIN" > /dev/null -find /opt/docker/etc/httpd/ -iname '*.conf' -print0 | xargs -0 -r rpl --quiet "" "$HOSTNAME" > /dev/null +go-replace \ + -s "" -r "$WEB_DOCUMENT_INDEX" \ + -s "" -r "$WEB_DOCUMENT_ROOT" \ + -s "" -r "$WEB_ALIAS_DOMAIN" \ + -s "" -r "$HOSTNAME" \ + -s "" -r "$WEB_PHP_SOCKET" \ + --path=/opt/docker/etc/httpd/ \ + --path-pattern='*.conf' \ + --ignore-empty -if [[ -n "${WEB_PHP_SOCKET+x}" ]]; then - ## WEB_PHP_SOCKET is set - find /opt/docker/etc/httpd/ -iname '*.conf' -print0 | xargs -0 -r rpl --quiet "" "$WEB_PHP_SOCKET" > /dev/null -else +if [[ -z "${WEB_PHP_SOCKET+x}" ]]; then ## WEB_PHP_SOCKET is not set, remove PHP files rm -f -- /opt/docker/etc/httpd/conf.d/10-php.conf fi diff --git a/docker/php-apache/ubuntu-15.04/conf/etc/httpd/conf.d/10-log.conf b/docker/php-apache/ubuntu-15.04/conf/etc/httpd/conf.d/10-log.conf index e4c4be4f2..ef0c73d38 100644 --- a/docker/php-apache/ubuntu-15.04/conf/etc/httpd/conf.d/10-log.conf +++ b/docker/php-apache/ubuntu-15.04/conf/etc/httpd/conf.d/10-log.conf @@ -1,4 +1,4 @@ LogFormat "[httpd:access] %V:%p %h %l %u %t \"%r\" %>s bytesIn:%I bytesOut:%O reqTime:%T" dockerlog LogLevel warn -CustomLog /proc/self/fd/1 dockerlog -ErrorLog /proc/self/fd/2 +CustomLog /docker.stdout dockerlog +ErrorLog /docker.stderr diff --git a/docker/php-apache/ubuntu-15.04/conf/provision/roles/webdevops-apache/tasks/bootstrap.yml b/docker/php-apache/ubuntu-15.04/conf/provision/roles/webdevops-apache/tasks/bootstrap.yml index 2be18b0e0..c285be286 100644 --- a/docker/php-apache/ubuntu-15.04/conf/provision/roles/webdevops-apache/tasks/bootstrap.yml +++ b/docker/php-apache/ubuntu-15.04/conf/provision/roles/webdevops-apache/tasks/bootstrap.yml @@ -84,7 +84,7 @@ with_items: - 'a2dismod mpm_event' - 'a2enmod mpm_event' - when: (ansible_distribution == 'Ubuntu' and ansible_lsb.major_release|int >= 14) or (ansible_distribution == 'Debian' and ansible_lsb.major_release|int >= 8) + when: (ansible_distribution == 'Ubuntu' and docker_image_info_distribution_version|int >= 14) or (ansible_distribution == 'Debian' and docker_image_info_distribution_version|int >= 8) - name: Manage modules [Alpine family] lineinfile: diff --git a/docker/php-apache/ubuntu-15.10/Dockerfile b/docker/php-apache/ubuntu-15.10/Dockerfile index b39e469a5..b549fb21d 100644 --- a/docker/php-apache/ubuntu-15.10/Dockerfile +++ b/docker/php-apache/ubuntu-15.10/Dockerfile @@ -5,15 +5,10 @@ FROM webdevops/php:ubuntu-15.10 -MAINTAINER info@webdevops.io -LABEL vendor=WebDevOps.io -LABEL io.webdevops.layout=8 -LABEL io.webdevops.version=1.5.0 - -ENV WEB_DOCUMENT_ROOT /app -ENV WEB_DOCUMENT_INDEX index.php -ENV WEB_ALIAS_DOMAIN *.vm -ENV WEB_PHP_SOCKET 127.0.0.1:9000 +ENV WEB_DOCUMENT_ROOT=/app \ + WEB_DOCUMENT_INDEX=index.php \ + WEB_ALIAS_DOMAIN=*.vm +ENV WEB_PHP_SOCKET=127.0.0.1:9000 COPY conf/ /opt/docker/ @@ -28,7 +23,7 @@ RUN /usr/local/bin/apt-install \ && ln -sf /opt/docker/etc/httpd/main.conf /etc/apache2/sites-enabled/10-docker.conf \ && a2enmod actions proxy proxy_fcgi ssl rewrite headers expires \ && /opt/docker/bin/provision run --tag bootstrap --role webdevops-apache --role webdevops-php-apache \ - && /opt/docker/bin/bootstrap.sh - + && /opt/docker/bin/bootstrap.sh \ + && docker-image-cleanup EXPOSE 80 443 diff --git a/docker/php-apache/ubuntu-15.10/Dockerfile.jinja2 b/docker/php-apache/ubuntu-15.10/Dockerfile.jinja2 index dc9ec6109..5cd02e5c8 100644 --- a/docker/php-apache/ubuntu-15.10/Dockerfile.jinja2 +++ b/docker/php-apache/ubuntu-15.10/Dockerfile.jinja2 @@ -1,7 +1,5 @@ {{ docker.from("php", "ubuntu-15.10") }} -{{ docker.version() }} - {{ environment.web() }} {{ environment.webPhp() }} diff --git a/docker/php-apache/ubuntu-15.10/conf/bin/service.d/httpd.d/10-init.sh b/docker/php-apache/ubuntu-15.10/conf/bin/service.d/httpd.d/10-init.sh index d3f1a0c9c..b9d57997e 100644 --- a/docker/php-apache/ubuntu-15.10/conf/bin/service.d/httpd.d/10-init.sh +++ b/docker/php-apache/ubuntu-15.10/conf/bin/service.d/httpd.d/10-init.sh @@ -5,15 +5,17 @@ if [[ ! -e "$WEB_DOCUMENT_ROOT" ]]; then fi # Replace markers -find /opt/docker/etc/httpd/ -iname '*.conf' -print0 | xargs -0 -r rpl --quiet "" "$WEB_DOCUMENT_INDEX" > /dev/null -find /opt/docker/etc/httpd/ -iname '*.conf' -print0 | xargs -0 -r rpl --quiet "" "$WEB_DOCUMENT_ROOT" > /dev/null -find /opt/docker/etc/httpd/ -iname '*.conf' -print0 | xargs -0 -r rpl --quiet "" "$WEB_ALIAS_DOMAIN" > /dev/null -find /opt/docker/etc/httpd/ -iname '*.conf' -print0 | xargs -0 -r rpl --quiet "" "$HOSTNAME" > /dev/null +go-replace \ + -s "" -r "$WEB_DOCUMENT_INDEX" \ + -s "" -r "$WEB_DOCUMENT_ROOT" \ + -s "" -r "$WEB_ALIAS_DOMAIN" \ + -s "" -r "$HOSTNAME" \ + -s "" -r "$WEB_PHP_SOCKET" \ + --path=/opt/docker/etc/httpd/ \ + --path-pattern='*.conf' \ + --ignore-empty -if [[ -n "${WEB_PHP_SOCKET+x}" ]]; then - ## WEB_PHP_SOCKET is set - find /opt/docker/etc/httpd/ -iname '*.conf' -print0 | xargs -0 -r rpl --quiet "" "$WEB_PHP_SOCKET" > /dev/null -else +if [[ -z "${WEB_PHP_SOCKET+x}" ]]; then ## WEB_PHP_SOCKET is not set, remove PHP files rm -f -- /opt/docker/etc/httpd/conf.d/10-php.conf fi diff --git a/docker/php-apache/ubuntu-15.10/conf/etc/httpd/conf.d/10-log.conf b/docker/php-apache/ubuntu-15.10/conf/etc/httpd/conf.d/10-log.conf index e4c4be4f2..ef0c73d38 100644 --- a/docker/php-apache/ubuntu-15.10/conf/etc/httpd/conf.d/10-log.conf +++ b/docker/php-apache/ubuntu-15.10/conf/etc/httpd/conf.d/10-log.conf @@ -1,4 +1,4 @@ LogFormat "[httpd:access] %V:%p %h %l %u %t \"%r\" %>s bytesIn:%I bytesOut:%O reqTime:%T" dockerlog LogLevel warn -CustomLog /proc/self/fd/1 dockerlog -ErrorLog /proc/self/fd/2 +CustomLog /docker.stdout dockerlog +ErrorLog /docker.stderr diff --git a/docker/php-apache/ubuntu-15.10/conf/provision/roles/webdevops-apache/tasks/bootstrap.yml b/docker/php-apache/ubuntu-15.10/conf/provision/roles/webdevops-apache/tasks/bootstrap.yml index 2be18b0e0..c285be286 100644 --- a/docker/php-apache/ubuntu-15.10/conf/provision/roles/webdevops-apache/tasks/bootstrap.yml +++ b/docker/php-apache/ubuntu-15.10/conf/provision/roles/webdevops-apache/tasks/bootstrap.yml @@ -84,7 +84,7 @@ with_items: - 'a2dismod mpm_event' - 'a2enmod mpm_event' - when: (ansible_distribution == 'Ubuntu' and ansible_lsb.major_release|int >= 14) or (ansible_distribution == 'Debian' and ansible_lsb.major_release|int >= 8) + when: (ansible_distribution == 'Ubuntu' and docker_image_info_distribution_version|int >= 14) or (ansible_distribution == 'Debian' and docker_image_info_distribution_version|int >= 8) - name: Manage modules [Alpine family] lineinfile: diff --git a/docker/php-apache/ubuntu-16.04/Dockerfile b/docker/php-apache/ubuntu-16.04/Dockerfile index 884ebf8cf..706919b2e 100644 --- a/docker/php-apache/ubuntu-16.04/Dockerfile +++ b/docker/php-apache/ubuntu-16.04/Dockerfile @@ -5,15 +5,10 @@ FROM webdevops/php:ubuntu-16.04 -MAINTAINER info@webdevops.io -LABEL vendor=WebDevOps.io -LABEL io.webdevops.layout=8 -LABEL io.webdevops.version=1.5.0 - -ENV WEB_DOCUMENT_ROOT /app -ENV WEB_DOCUMENT_INDEX index.php -ENV WEB_ALIAS_DOMAIN *.vm -ENV WEB_PHP_SOCKET 127.0.0.1:9000 +ENV WEB_DOCUMENT_ROOT=/app \ + WEB_DOCUMENT_INDEX=index.php \ + WEB_ALIAS_DOMAIN=*.vm +ENV WEB_PHP_SOCKET=127.0.0.1:9000 COPY conf/ /opt/docker/ @@ -28,7 +23,7 @@ RUN /usr/local/bin/apt-install \ && ln -sf /opt/docker/etc/httpd/main.conf /etc/apache2/sites-enabled/10-docker.conf \ && a2enmod actions proxy proxy_fcgi ssl rewrite headers expires \ && /opt/docker/bin/provision run --tag bootstrap --role webdevops-apache --role webdevops-php-apache \ - && /opt/docker/bin/bootstrap.sh - + && /opt/docker/bin/bootstrap.sh \ + && docker-image-cleanup EXPOSE 80 443 diff --git a/docker/php-apache/ubuntu-16.04/Dockerfile.jinja2 b/docker/php-apache/ubuntu-16.04/Dockerfile.jinja2 index 89fee4ea8..cc2e24dda 100644 --- a/docker/php-apache/ubuntu-16.04/Dockerfile.jinja2 +++ b/docker/php-apache/ubuntu-16.04/Dockerfile.jinja2 @@ -1,7 +1,5 @@ {{ docker.from("php", "ubuntu-16.04") }} -{{ docker.version() }} - {{ environment.web() }} {{ environment.webPhp() }} diff --git a/docker/php-apache/ubuntu-16.04/conf/bin/service.d/httpd.d/10-init.sh b/docker/php-apache/ubuntu-16.04/conf/bin/service.d/httpd.d/10-init.sh index d3f1a0c9c..b9d57997e 100644 --- a/docker/php-apache/ubuntu-16.04/conf/bin/service.d/httpd.d/10-init.sh +++ b/docker/php-apache/ubuntu-16.04/conf/bin/service.d/httpd.d/10-init.sh @@ -5,15 +5,17 @@ if [[ ! -e "$WEB_DOCUMENT_ROOT" ]]; then fi # Replace markers -find /opt/docker/etc/httpd/ -iname '*.conf' -print0 | xargs -0 -r rpl --quiet "" "$WEB_DOCUMENT_INDEX" > /dev/null -find /opt/docker/etc/httpd/ -iname '*.conf' -print0 | xargs -0 -r rpl --quiet "" "$WEB_DOCUMENT_ROOT" > /dev/null -find /opt/docker/etc/httpd/ -iname '*.conf' -print0 | xargs -0 -r rpl --quiet "" "$WEB_ALIAS_DOMAIN" > /dev/null -find /opt/docker/etc/httpd/ -iname '*.conf' -print0 | xargs -0 -r rpl --quiet "" "$HOSTNAME" > /dev/null +go-replace \ + -s "" -r "$WEB_DOCUMENT_INDEX" \ + -s "" -r "$WEB_DOCUMENT_ROOT" \ + -s "" -r "$WEB_ALIAS_DOMAIN" \ + -s "" -r "$HOSTNAME" \ + -s "" -r "$WEB_PHP_SOCKET" \ + --path=/opt/docker/etc/httpd/ \ + --path-pattern='*.conf' \ + --ignore-empty -if [[ -n "${WEB_PHP_SOCKET+x}" ]]; then - ## WEB_PHP_SOCKET is set - find /opt/docker/etc/httpd/ -iname '*.conf' -print0 | xargs -0 -r rpl --quiet "" "$WEB_PHP_SOCKET" > /dev/null -else +if [[ -z "${WEB_PHP_SOCKET+x}" ]]; then ## WEB_PHP_SOCKET is not set, remove PHP files rm -f -- /opt/docker/etc/httpd/conf.d/10-php.conf fi diff --git a/docker/php-apache/ubuntu-16.04/conf/etc/httpd/conf.d/10-log.conf b/docker/php-apache/ubuntu-16.04/conf/etc/httpd/conf.d/10-log.conf index e4c4be4f2..ef0c73d38 100644 --- a/docker/php-apache/ubuntu-16.04/conf/etc/httpd/conf.d/10-log.conf +++ b/docker/php-apache/ubuntu-16.04/conf/etc/httpd/conf.d/10-log.conf @@ -1,4 +1,4 @@ LogFormat "[httpd:access] %V:%p %h %l %u %t \"%r\" %>s bytesIn:%I bytesOut:%O reqTime:%T" dockerlog LogLevel warn -CustomLog /proc/self/fd/1 dockerlog -ErrorLog /proc/self/fd/2 +CustomLog /docker.stdout dockerlog +ErrorLog /docker.stderr diff --git a/docker/php-apache/ubuntu-16.04/conf/provision/roles/webdevops-apache/tasks/bootstrap.yml b/docker/php-apache/ubuntu-16.04/conf/provision/roles/webdevops-apache/tasks/bootstrap.yml index 2be18b0e0..c285be286 100644 --- a/docker/php-apache/ubuntu-16.04/conf/provision/roles/webdevops-apache/tasks/bootstrap.yml +++ b/docker/php-apache/ubuntu-16.04/conf/provision/roles/webdevops-apache/tasks/bootstrap.yml @@ -84,7 +84,7 @@ with_items: - 'a2dismod mpm_event' - 'a2enmod mpm_event' - when: (ansible_distribution == 'Ubuntu' and ansible_lsb.major_release|int >= 14) or (ansible_distribution == 'Debian' and ansible_lsb.major_release|int >= 8) + when: (ansible_distribution == 'Ubuntu' and docker_image_info_distribution_version|int >= 14) or (ansible_distribution == 'Debian' and docker_image_info_distribution_version|int >= 8) - name: Manage modules [Alpine family] lineinfile: diff --git a/docker/php-apache/ubuntu-16.10/Dockerfile b/docker/php-apache/ubuntu-16.10/Dockerfile index 1ace16150..2c71484b3 100644 --- a/docker/php-apache/ubuntu-16.10/Dockerfile +++ b/docker/php-apache/ubuntu-16.10/Dockerfile @@ -5,15 +5,10 @@ FROM webdevops/php:ubuntu-16.10 -MAINTAINER info@webdevops.io -LABEL vendor=WebDevOps.io -LABEL io.webdevops.layout=8 -LABEL io.webdevops.version=1.5.0 - -ENV WEB_DOCUMENT_ROOT /app -ENV WEB_DOCUMENT_INDEX index.php -ENV WEB_ALIAS_DOMAIN *.vm -ENV WEB_PHP_SOCKET 127.0.0.1:9000 +ENV WEB_DOCUMENT_ROOT=/app \ + WEB_DOCUMENT_INDEX=index.php \ + WEB_ALIAS_DOMAIN=*.vm +ENV WEB_PHP_SOCKET=127.0.0.1:9000 COPY conf/ /opt/docker/ @@ -28,7 +23,7 @@ RUN /usr/local/bin/apt-install \ && ln -sf /opt/docker/etc/httpd/main.conf /etc/apache2/sites-enabled/10-docker.conf \ && a2enmod actions proxy proxy_fcgi ssl rewrite headers expires \ && /opt/docker/bin/provision run --tag bootstrap --role webdevops-apache --role webdevops-php-apache \ - && /opt/docker/bin/bootstrap.sh - + && /opt/docker/bin/bootstrap.sh \ + && docker-image-cleanup EXPOSE 80 443 diff --git a/docker/php-apache/ubuntu-16.10/Dockerfile.jinja2 b/docker/php-apache/ubuntu-16.10/Dockerfile.jinja2 index 172219b62..9ce35fdd4 100644 --- a/docker/php-apache/ubuntu-16.10/Dockerfile.jinja2 +++ b/docker/php-apache/ubuntu-16.10/Dockerfile.jinja2 @@ -1,7 +1,5 @@ {{ docker.from("php", "ubuntu-16.10") }} -{{ docker.version() }} - {{ environment.web() }} {{ environment.webPhp() }} diff --git a/docker/php-apache/ubuntu-16.10/conf/bin/service.d/httpd.d/10-init.sh b/docker/php-apache/ubuntu-16.10/conf/bin/service.d/httpd.d/10-init.sh index d3f1a0c9c..b9d57997e 100644 --- a/docker/php-apache/ubuntu-16.10/conf/bin/service.d/httpd.d/10-init.sh +++ b/docker/php-apache/ubuntu-16.10/conf/bin/service.d/httpd.d/10-init.sh @@ -5,15 +5,17 @@ if [[ ! -e "$WEB_DOCUMENT_ROOT" ]]; then fi # Replace markers -find /opt/docker/etc/httpd/ -iname '*.conf' -print0 | xargs -0 -r rpl --quiet "" "$WEB_DOCUMENT_INDEX" > /dev/null -find /opt/docker/etc/httpd/ -iname '*.conf' -print0 | xargs -0 -r rpl --quiet "" "$WEB_DOCUMENT_ROOT" > /dev/null -find /opt/docker/etc/httpd/ -iname '*.conf' -print0 | xargs -0 -r rpl --quiet "" "$WEB_ALIAS_DOMAIN" > /dev/null -find /opt/docker/etc/httpd/ -iname '*.conf' -print0 | xargs -0 -r rpl --quiet "" "$HOSTNAME" > /dev/null +go-replace \ + -s "" -r "$WEB_DOCUMENT_INDEX" \ + -s "" -r "$WEB_DOCUMENT_ROOT" \ + -s "" -r "$WEB_ALIAS_DOMAIN" \ + -s "" -r "$HOSTNAME" \ + -s "" -r "$WEB_PHP_SOCKET" \ + --path=/opt/docker/etc/httpd/ \ + --path-pattern='*.conf' \ + --ignore-empty -if [[ -n "${WEB_PHP_SOCKET+x}" ]]; then - ## WEB_PHP_SOCKET is set - find /opt/docker/etc/httpd/ -iname '*.conf' -print0 | xargs -0 -r rpl --quiet "" "$WEB_PHP_SOCKET" > /dev/null -else +if [[ -z "${WEB_PHP_SOCKET+x}" ]]; then ## WEB_PHP_SOCKET is not set, remove PHP files rm -f -- /opt/docker/etc/httpd/conf.d/10-php.conf fi diff --git a/docker/php-apache/ubuntu-16.10/conf/etc/httpd/conf.d/10-log.conf b/docker/php-apache/ubuntu-16.10/conf/etc/httpd/conf.d/10-log.conf index e4c4be4f2..ef0c73d38 100644 --- a/docker/php-apache/ubuntu-16.10/conf/etc/httpd/conf.d/10-log.conf +++ b/docker/php-apache/ubuntu-16.10/conf/etc/httpd/conf.d/10-log.conf @@ -1,4 +1,4 @@ LogFormat "[httpd:access] %V:%p %h %l %u %t \"%r\" %>s bytesIn:%I bytesOut:%O reqTime:%T" dockerlog LogLevel warn -CustomLog /proc/self/fd/1 dockerlog -ErrorLog /proc/self/fd/2 +CustomLog /docker.stdout dockerlog +ErrorLog /docker.stderr diff --git a/docker/php-apache/ubuntu-16.10/conf/provision/roles/webdevops-apache/tasks/bootstrap.yml b/docker/php-apache/ubuntu-16.10/conf/provision/roles/webdevops-apache/tasks/bootstrap.yml index 2be18b0e0..c285be286 100644 --- a/docker/php-apache/ubuntu-16.10/conf/provision/roles/webdevops-apache/tasks/bootstrap.yml +++ b/docker/php-apache/ubuntu-16.10/conf/provision/roles/webdevops-apache/tasks/bootstrap.yml @@ -84,7 +84,7 @@ with_items: - 'a2dismod mpm_event' - 'a2enmod mpm_event' - when: (ansible_distribution == 'Ubuntu' and ansible_lsb.major_release|int >= 14) or (ansible_distribution == 'Debian' and ansible_lsb.major_release|int >= 8) + when: (ansible_distribution == 'Ubuntu' and docker_image_info_distribution_version|int >= 14) or (ansible_distribution == 'Debian' and docker_image_info_distribution_version|int >= 8) - name: Manage modules [Alpine family] lineinfile: diff --git a/docker/php-dev/5.6/Dockerfile b/docker/php-dev/5.6/Dockerfile new file mode 100644 index 000000000..1ebafdd2e --- /dev/null +++ b/docker/php-dev/5.6/Dockerfile @@ -0,0 +1,22 @@ +#+++++++++++++++++++++++++++++++++++++++ +# Dockerfile for webdevops/php-dev:5.6 +# -- automatically generated -- +#+++++++++++++++++++++++++++++++++++++++ + +FROM webdevops/php:5.6 + +COPY conf/ /opt/docker/ + +# Install development environment +RUN wget -O - https://packagecloud.io/gpg.key | apt-key add - \ + && echo "deb https://packages.blackfire.io/debian any main" | tee /etc/apt/sources.list.d/blackfire.list \ + && /usr/local/bin/apt-install \ + blackfire-php \ + blackfire-agent \ + && pecl install xdebug \ + && echo "zend_extension=xdebug.so" > /usr/local/etc/php/conf.d/xdebug.ini \ + # Enable php development services + && docker-service-enable syslog ssh postfix \ + && /opt/docker/bin/provision run --tag bootstrap --role webdevops-dev --role webdevops-php-dev \ + && /opt/docker/bin/bootstrap.sh \ + && docker-image-cleanup diff --git a/docker/php-dev/5.6/Dockerfile.jinja2 b/docker/php-dev/5.6/Dockerfile.jinja2 new file mode 100644 index 000000000..eeaee7317 --- /dev/null +++ b/docker/php-dev/5.6/Dockerfile.jinja2 @@ -0,0 +1,5 @@ +{{ docker.from("php", "5.6") }} + +{{ docker.copy('conf/', '/opt/docker/') }} + +{{ php.officialDevelopment(version="5.6") }} diff --git a/docker/php-dev/5.6/conf/bin/service.d/blackfire-agent.d/10-init.sh b/docker/php-dev/5.6/conf/bin/service.d/blackfire-agent.d/10-init.sh new file mode 100644 index 000000000..fdffa2a0f --- /dev/null +++ b/docker/php-dev/5.6/conf/bin/service.d/blackfire-agent.d/10-init.sh @@ -0,0 +1 @@ +# placeholder diff --git a/docker/php-nginx-dev/alpine-3/conf/bin/service.d/blackfire-agent.sh b/docker/php-dev/5.6/conf/bin/service.d/blackfire-agent.sh similarity index 100% rename from docker/php-nginx-dev/alpine-3/conf/bin/service.d/blackfire-agent.sh rename to docker/php-dev/5.6/conf/bin/service.d/blackfire-agent.sh diff --git a/docker/php-nginx-dev/alpine-3/conf/etc/supervisor.d/blackfire-agent.conf b/docker/php-dev/5.6/conf/etc/supervisor.d/blackfire-agent.conf similarity index 100% rename from docker/php-nginx-dev/alpine-3/conf/etc/supervisor.d/blackfire-agent.conf rename to docker/php-dev/5.6/conf/etc/supervisor.d/blackfire-agent.conf diff --git a/docker/php-dev/5.6/conf/provision/entrypoint.d/10-php-debugger.sh b/docker/php-dev/5.6/conf/provision/entrypoint.d/10-php-debugger.sh new file mode 100644 index 000000000..b5985a9ef --- /dev/null +++ b/docker/php-dev/5.6/conf/provision/entrypoint.d/10-php-debugger.sh @@ -0,0 +1,96 @@ +#!/usr/bin/env bash + +################################################# +# Debugger switch +################################################# + +PHP_CONF_PATHS=" +/etc/php5/conf.d +/etc/php7/conf.d +/etc/php.d +/etc/php5/mods-available +/etc/php5/cli/conf.d +/etc/php5/cli/conf.d +/etc/php5/fpm/conf.d +/etc/php5/fpm/conf.d +/etc/php/7.0/mods-available +/etc/php/7.0/cli/conf.d +/etc/php/7.0/fpm/conf.d +/usr/local/etc/php/conf.d/" + +function phpModuleRemove() { + if [ "$#" -ne 1 ]; then + echo "You must specify the name of the PHP module which you want to disable" + exit 1 + fi + + echo " - Removing PHP module ${1}" + for CONF_PATH in $PHP_CONF_PATHS; do + rm -f "${CONF_PATH}"/*"${1}".ini + done +} + + +if [[ -n "${PHP_DEBUGGER+x}" ]]; then + case "$PHP_DEBUGGER" in + xdebug) + echo "PHP-Debugger: Xdebug enabled" + phpModuleRemove "blackfire" + ;; + + blackfire) + echo "PHP-Debugger: Blackfire enabled" + phpModuleRemove "xdebug" + docker-service-enable blackfire-agent + ;; + + none) + echo "PHP-Debugger: none" + phpModuleRemove "blackfire" + phpModuleRemove "xdebug" + ;; + esac + +else + + echo "PHP-Debugger: not specified - default is xdebug" + phpModuleRemove "blackfire" + +fi + +################################################# +# PHP debugger environment variables +################################################# + +function phpEnvironmentVariable() { + PHP_INI_KEY="$1" + PHP_ENV_NAME="$2" + + if [[ -n "${!PHP_ENV_NAME+x}" ]]; then + PHP_ENV_VALUE="${!PHP_ENV_NAME}" + echo "${PHP_INI_KEY}=\"${PHP_ENV_VALUE}\"" >> /opt/docker/etc/php/php.ini + fi +} + +################### +# XDEBUG +################### + +# remote debugger +phpEnvironmentVariable "xdebug.remote_connect_back" "XDEBUG_REMOTE_CONNECT_BACK" +phpEnvironmentVariable "xdebug.remote_autostart" "XDEBUG_REMOTE_AUTOSTART" +phpEnvironmentVariable "xdebug.remote_host" "XDEBUG_REMOTE_HOST" +phpEnvironmentVariable "xdebug.remote_port" "XDEBUG_REMOTE_PORT" + +# profiler +phpEnvironmentVariable "xdebug.profiler_enable" "XDEBUG_PROFILER_ENABLE" +phpEnvironmentVariable "xdebug.profiler_enable_trigger" "XDEBUG_PROFILER_ENABLE_TRIGGER" +phpEnvironmentVariable "xdebug.profiler_enable_trigger_value" "XDEBUG_PROFILER_ENABLE_TRIGGER_VALUE" +phpEnvironmentVariable "xdebug.profiler_output_dir" "XDEBUG_PROFILER_OUTPUT_DIR" +phpEnvironmentVariable "xdebug.profiler_output_name" "XDEBUG_PROFILER_OUTPUT_NAME" + +################### +# BLACKFIRE +################### +phpEnvironmentVariable "blackfire.server_id" "BLACKFIRE_SERVER_ID" +phpEnvironmentVariable "blackfire.server_token" "BLACKFIRE_SERVER_TOKEN" diff --git a/docker/php-dev/alpine-3-php7/conf/provision/roles/webdevops-dev/defaults/main.yml b/docker/php-dev/5.6/conf/provision/roles/webdevops-dev/defaults/main.yml similarity index 100% rename from docker/php-dev/alpine-3-php7/conf/provision/roles/webdevops-dev/defaults/main.yml rename to docker/php-dev/5.6/conf/provision/roles/webdevops-dev/defaults/main.yml diff --git a/docker/php-dev/5.6/conf/provision/roles/webdevops-dev/tasks/bootstrap.yml b/docker/php-dev/5.6/conf/provision/roles/webdevops-dev/tasks/bootstrap.yml new file mode 100644 index 000000000..3d7a494ad --- /dev/null +++ b/docker/php-dev/5.6/conf/provision/roles/webdevops-dev/tasks/bootstrap.yml @@ -0,0 +1,17 @@ +--- + +- name: Set application user password + user: + name: "{{ APPLICATION_USER }}" + password: "{{ APPLICATION_PASSWORD | password_hash('sha256') }}" + +- name: Set root password + user: + name: "root" + password: "{{ APPLICATION_PASSWORD | password_hash('sha256') }}" + +- name: Enable ssh root access + lineinfile: + dest: /etc/ssh/sshd_config + regexp: '^PermitRootLogin' + line: 'PermitRootLogin yes' diff --git a/docker/php-nginx/alpine-3/conf/provision/roles/webdevops-nginx/tasks/main.yml b/docker/php-dev/5.6/conf/provision/roles/webdevops-dev/tasks/main.yml similarity index 100% rename from docker/php-nginx/alpine-3/conf/provision/roles/webdevops-nginx/tasks/main.yml rename to docker/php-dev/5.6/conf/provision/roles/webdevops-dev/tasks/main.yml diff --git a/docker/php-nginx-dev/alpine-3/conf/provision/roles/webdevops-php-dev/defaults/main.yml b/docker/php-dev/5.6/conf/provision/roles/webdevops-php-dev/defaults/main.yml similarity index 100% rename from docker/php-nginx-dev/alpine-3/conf/provision/roles/webdevops-php-dev/defaults/main.yml rename to docker/php-dev/5.6/conf/provision/roles/webdevops-php-dev/defaults/main.yml diff --git a/docker/php-dev/5.6/conf/provision/roles/webdevops-php-dev/tasks/bootstrap.yml b/docker/php-dev/5.6/conf/provision/roles/webdevops-php-dev/tasks/bootstrap.yml new file mode 100644 index 000000000..ff02b05fc --- /dev/null +++ b/docker/php-dev/5.6/conf/provision/roles/webdevops-php-dev/tasks/bootstrap.yml @@ -0,0 +1,7 @@ +--- + +- include: bootstrap/php-fpm.yml +- include: bootstrap/php-module.yml +- include: bootstrap/php-module.opcache.yml +- include: bootstrap/php-module.xdebug.yml +- include: bootstrap/php-module.blackfire.yml diff --git a/docker/php-nginx-dev/alpine-3/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/php-fpm.yml b/docker/php-dev/5.6/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/php-fpm.yml similarity index 100% rename from docker/php-nginx-dev/alpine-3/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/php-fpm.yml rename to docker/php-dev/5.6/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/php-fpm.yml diff --git a/docker/php-dev/5.6/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/php-module.blackfire.yml b/docker/php-dev/5.6/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/php-module.blackfire.yml new file mode 100644 index 000000000..faf05f8de --- /dev/null +++ b/docker/php-dev/5.6/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/php-module.blackfire.yml @@ -0,0 +1,10 @@ +--- + +- name: Remove superfluous blackfire configuration file + file: + path: '{{ item }}' + state: absent + with_items: + - /etc/php5/cli/conf.d/zz-blackfire.ini + - /etc/php5/fpm/conf.d/zz-blackfire.ini + when: ansible_distribution == 'Debian' and docker_image_info_distribution_version|int >= 7 diff --git a/docker/php-nginx-dev/alpine-3/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/php-module.opcache.yml b/docker/php-dev/5.6/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/php-module.opcache.yml similarity index 100% rename from docker/php-nginx-dev/alpine-3/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/php-module.opcache.yml rename to docker/php-dev/5.6/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/php-module.opcache.yml diff --git a/docker/php-nginx-dev/alpine-3/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/php-module.xdebug.yml b/docker/php-dev/5.6/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/php-module.xdebug.yml similarity index 100% rename from docker/php-nginx-dev/alpine-3/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/php-module.xdebug.yml rename to docker/php-dev/5.6/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/php-module.xdebug.yml diff --git a/docker/php-nginx-dev/alpine-3/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/php-module.yml b/docker/php-dev/5.6/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/php-module.yml similarity index 100% rename from docker/php-nginx-dev/alpine-3/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/php-module.yml rename to docker/php-dev/5.6/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/php-module.yml diff --git a/docker/php/alpine-3-php7/conf/provision/roles/webdevops-php/tasks/main.yml b/docker/php-dev/5.6/conf/provision/roles/webdevops-php-dev/tasks/main.yml similarity index 100% rename from docker/php/alpine-3-php7/conf/provision/roles/webdevops-php/tasks/main.yml rename to docker/php-dev/5.6/conf/provision/roles/webdevops-php-dev/tasks/main.yml diff --git a/docker/php-dev/7.0/Dockerfile b/docker/php-dev/7.0/Dockerfile new file mode 100644 index 000000000..4337dde09 --- /dev/null +++ b/docker/php-dev/7.0/Dockerfile @@ -0,0 +1,22 @@ +#+++++++++++++++++++++++++++++++++++++++ +# Dockerfile for webdevops/php-dev:7.0 +# -- automatically generated -- +#+++++++++++++++++++++++++++++++++++++++ + +FROM webdevops/php:7.0 + +COPY conf/ /opt/docker/ + +# Install development environment +RUN wget -O - https://packagecloud.io/gpg.key | apt-key add - \ + && echo "deb https://packages.blackfire.io/debian any main" | tee /etc/apt/sources.list.d/blackfire.list \ + && /usr/local/bin/apt-install \ + blackfire-php \ + blackfire-agent \ + && pecl install xdebug \ + && echo "zend_extension=xdebug.so" > /usr/local/etc/php/conf.d/xdebug.ini \ + # Enable php development services + && docker-service-enable syslog ssh postfix \ + && /opt/docker/bin/provision run --tag bootstrap --role webdevops-dev --role webdevops-php-dev \ + && /opt/docker/bin/bootstrap.sh \ + && docker-image-cleanup diff --git a/docker/php-dev/7.0/Dockerfile.jinja2 b/docker/php-dev/7.0/Dockerfile.jinja2 new file mode 100644 index 000000000..3ea77a71d --- /dev/null +++ b/docker/php-dev/7.0/Dockerfile.jinja2 @@ -0,0 +1,5 @@ +{{ docker.from("php", "7.0") }} + +{{ docker.copy('conf/', '/opt/docker/') }} + +{{ php.officialDevelopment(version="7.0") }} diff --git a/docker/php-dev/7.0/conf/bin/service.d/blackfire-agent.d/10-init.sh b/docker/php-dev/7.0/conf/bin/service.d/blackfire-agent.d/10-init.sh new file mode 100644 index 000000000..fdffa2a0f --- /dev/null +++ b/docker/php-dev/7.0/conf/bin/service.d/blackfire-agent.d/10-init.sh @@ -0,0 +1 @@ +# placeholder diff --git a/docker/php-dev/7.0/conf/bin/service.d/blackfire-agent.sh b/docker/php-dev/7.0/conf/bin/service.d/blackfire-agent.sh new file mode 100644 index 000000000..fbec23cf3 --- /dev/null +++ b/docker/php-dev/7.0/conf/bin/service.d/blackfire-agent.sh @@ -0,0 +1,23 @@ +#!/usr/bin/env bash +set -e + +source /opt/docker/bin/config.sh + +BLACKFIRE_ARGS="" + +includeScriptDir "/opt/docker/bin/service.d/syslog-ng.d/" + +# blackfire.server_id +if [[ -n "${BLACKFIRE_SERVER_ID+x}" ]]; then + BLACKFIRE_ARGS="$BLACKFIRE_ARGS --server-id=\"${BLACKFIRE_SERVER_ID}\"" +fi + +# blackfire.server_token +if [[ -n "${BLACKFIRE_SERVER_TOKEN+x}" ]]; then + BLACKFIRE_ARGS="$BLACKFIRE_ARGS --server-token=\"${BLACKFIRE_SERVER_TOKEN}\"" +fi + +# create directory for unix socket +mkdir -p /var/run/blackfire + +eval exec blackfire-agent $BLACKFIRE_ARGS diff --git a/docker/php-dev/7.0/conf/etc/supervisor.d/blackfire-agent.conf b/docker/php-dev/7.0/conf/etc/supervisor.d/blackfire-agent.conf new file mode 100644 index 000000000..897831ddb --- /dev/null +++ b/docker/php-dev/7.0/conf/etc/supervisor.d/blackfire-agent.conf @@ -0,0 +1,14 @@ +[group:blackfire-agent] +programs=blackfire-agentd +priority=25 + +[program:blackfire-agentd] +command = /opt/docker/bin/service.d/blackfire-agent.sh +process_name=%(program_name)s +startsecs = 0 +autostart = false +autorestart = true +stdout_logfile=/dev/stdout +stdout_logfile_maxbytes=0 +stderr_logfile=/dev/stderr +stderr_logfile_maxbytes=0 diff --git a/docker/php-dev/7.0/conf/provision/entrypoint.d/10-php-debugger.sh b/docker/php-dev/7.0/conf/provision/entrypoint.d/10-php-debugger.sh new file mode 100644 index 000000000..b5985a9ef --- /dev/null +++ b/docker/php-dev/7.0/conf/provision/entrypoint.d/10-php-debugger.sh @@ -0,0 +1,96 @@ +#!/usr/bin/env bash + +################################################# +# Debugger switch +################################################# + +PHP_CONF_PATHS=" +/etc/php5/conf.d +/etc/php7/conf.d +/etc/php.d +/etc/php5/mods-available +/etc/php5/cli/conf.d +/etc/php5/cli/conf.d +/etc/php5/fpm/conf.d +/etc/php5/fpm/conf.d +/etc/php/7.0/mods-available +/etc/php/7.0/cli/conf.d +/etc/php/7.0/fpm/conf.d +/usr/local/etc/php/conf.d/" + +function phpModuleRemove() { + if [ "$#" -ne 1 ]; then + echo "You must specify the name of the PHP module which you want to disable" + exit 1 + fi + + echo " - Removing PHP module ${1}" + for CONF_PATH in $PHP_CONF_PATHS; do + rm -f "${CONF_PATH}"/*"${1}".ini + done +} + + +if [[ -n "${PHP_DEBUGGER+x}" ]]; then + case "$PHP_DEBUGGER" in + xdebug) + echo "PHP-Debugger: Xdebug enabled" + phpModuleRemove "blackfire" + ;; + + blackfire) + echo "PHP-Debugger: Blackfire enabled" + phpModuleRemove "xdebug" + docker-service-enable blackfire-agent + ;; + + none) + echo "PHP-Debugger: none" + phpModuleRemove "blackfire" + phpModuleRemove "xdebug" + ;; + esac + +else + + echo "PHP-Debugger: not specified - default is xdebug" + phpModuleRemove "blackfire" + +fi + +################################################# +# PHP debugger environment variables +################################################# + +function phpEnvironmentVariable() { + PHP_INI_KEY="$1" + PHP_ENV_NAME="$2" + + if [[ -n "${!PHP_ENV_NAME+x}" ]]; then + PHP_ENV_VALUE="${!PHP_ENV_NAME}" + echo "${PHP_INI_KEY}=\"${PHP_ENV_VALUE}\"" >> /opt/docker/etc/php/php.ini + fi +} + +################### +# XDEBUG +################### + +# remote debugger +phpEnvironmentVariable "xdebug.remote_connect_back" "XDEBUG_REMOTE_CONNECT_BACK" +phpEnvironmentVariable "xdebug.remote_autostart" "XDEBUG_REMOTE_AUTOSTART" +phpEnvironmentVariable "xdebug.remote_host" "XDEBUG_REMOTE_HOST" +phpEnvironmentVariable "xdebug.remote_port" "XDEBUG_REMOTE_PORT" + +# profiler +phpEnvironmentVariable "xdebug.profiler_enable" "XDEBUG_PROFILER_ENABLE" +phpEnvironmentVariable "xdebug.profiler_enable_trigger" "XDEBUG_PROFILER_ENABLE_TRIGGER" +phpEnvironmentVariable "xdebug.profiler_enable_trigger_value" "XDEBUG_PROFILER_ENABLE_TRIGGER_VALUE" +phpEnvironmentVariable "xdebug.profiler_output_dir" "XDEBUG_PROFILER_OUTPUT_DIR" +phpEnvironmentVariable "xdebug.profiler_output_name" "XDEBUG_PROFILER_OUTPUT_NAME" + +################### +# BLACKFIRE +################### +phpEnvironmentVariable "blackfire.server_id" "BLACKFIRE_SERVER_ID" +phpEnvironmentVariable "blackfire.server_token" "BLACKFIRE_SERVER_TOKEN" diff --git a/docker/php-dev/alpine-3/conf/provision/roles/webdevops-dev/defaults/main.yml b/docker/php-dev/7.0/conf/provision/roles/webdevops-dev/defaults/main.yml similarity index 100% rename from docker/php-dev/alpine-3/conf/provision/roles/webdevops-dev/defaults/main.yml rename to docker/php-dev/7.0/conf/provision/roles/webdevops-dev/defaults/main.yml diff --git a/docker/php-dev/7.0/conf/provision/roles/webdevops-dev/tasks/bootstrap.yml b/docker/php-dev/7.0/conf/provision/roles/webdevops-dev/tasks/bootstrap.yml new file mode 100644 index 000000000..3d7a494ad --- /dev/null +++ b/docker/php-dev/7.0/conf/provision/roles/webdevops-dev/tasks/bootstrap.yml @@ -0,0 +1,17 @@ +--- + +- name: Set application user password + user: + name: "{{ APPLICATION_USER }}" + password: "{{ APPLICATION_PASSWORD | password_hash('sha256') }}" + +- name: Set root password + user: + name: "root" + password: "{{ APPLICATION_PASSWORD | password_hash('sha256') }}" + +- name: Enable ssh root access + lineinfile: + dest: /etc/ssh/sshd_config + regexp: '^PermitRootLogin' + line: 'PermitRootLogin yes' diff --git a/docker/php/alpine-3/conf/provision/roles/webdevops-php/tasks/main.yml b/docker/php-dev/7.0/conf/provision/roles/webdevops-dev/tasks/main.yml similarity index 100% rename from docker/php/alpine-3/conf/provision/roles/webdevops-php/tasks/main.yml rename to docker/php-dev/7.0/conf/provision/roles/webdevops-dev/tasks/main.yml diff --git a/docker/php/alpine-3-php7/conf/provision/roles/webdevops-php/defaults/main.yml b/docker/php-dev/7.0/conf/provision/roles/webdevops-php-dev/defaults/main.yml similarity index 100% rename from docker/php/alpine-3-php7/conf/provision/roles/webdevops-php/defaults/main.yml rename to docker/php-dev/7.0/conf/provision/roles/webdevops-php-dev/defaults/main.yml diff --git a/docker/php-dev/7.0/conf/provision/roles/webdevops-php-dev/tasks/bootstrap.yml b/docker/php-dev/7.0/conf/provision/roles/webdevops-php-dev/tasks/bootstrap.yml new file mode 100644 index 000000000..ff02b05fc --- /dev/null +++ b/docker/php-dev/7.0/conf/provision/roles/webdevops-php-dev/tasks/bootstrap.yml @@ -0,0 +1,7 @@ +--- + +- include: bootstrap/php-fpm.yml +- include: bootstrap/php-module.yml +- include: bootstrap/php-module.opcache.yml +- include: bootstrap/php-module.xdebug.yml +- include: bootstrap/php-module.blackfire.yml diff --git a/docker/php-dev/7.0/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/php-fpm.yml b/docker/php-dev/7.0/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/php-fpm.yml new file mode 100644 index 000000000..9455a78e2 --- /dev/null +++ b/docker/php-dev/7.0/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/php-fpm.yml @@ -0,0 +1,18 @@ +--- + +- name: Configure php-fpm pool user (application.conf) + lineinfile: + dest: '/opt/docker/etc/php/fpm/pool.d/application.conf' + regexp: '^[\s;]*{{ item.key }}[\s]*=' + line: '{{ item.key }} = {{ item.value }}' + with_items: + - { key: 'access.log', value: "/docker.stdout" } + - { key: "access.format", value: '"%R - %u %t \"%m %r%Q%q\" %s %f cpu:%C%% mem:%{megabytes}M reqTime:%d"' } + +- name: Open php-fpm for external connections (eg. debuggers) + lineinfile: + dest: '/opt/docker/etc/php/fpm/pool.d/application.conf' + regexp: '^[\s;]*{{ item.key }}[\s]*=' + line: '{{ item.key }} = {{ item.value }}' + with_items: + - { key: 'listen', value: "0.0.0.0:9000" } diff --git a/docker/php-dev/7.0/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/php-module.blackfire.yml b/docker/php-dev/7.0/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/php-module.blackfire.yml new file mode 100644 index 000000000..faf05f8de --- /dev/null +++ b/docker/php-dev/7.0/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/php-module.blackfire.yml @@ -0,0 +1,10 @@ +--- + +- name: Remove superfluous blackfire configuration file + file: + path: '{{ item }}' + state: absent + with_items: + - /etc/php5/cli/conf.d/zz-blackfire.ini + - /etc/php5/fpm/conf.d/zz-blackfire.ini + when: ansible_distribution == 'Debian' and docker_image_info_distribution_version|int >= 7 diff --git a/docker/php-dev/7.0/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/php-module.opcache.yml b/docker/php-dev/7.0/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/php-module.opcache.yml new file mode 100644 index 000000000..9c243a671 --- /dev/null +++ b/docker/php-dev/7.0/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/php-module.opcache.yml @@ -0,0 +1,14 @@ +--- + +- name: Setup php.ini for development environment + lineinfile: + dest: '/opt/docker/etc/php/php.webdevops.ini' + regexp: '^[\s;]*{{ item.variable }}[\s]*=' + line: '{{ item.variable }} = {{ item.value }}' + with_items: + - { variable: 'opcache.memory_consumption', value: '256' } + - { variable: 'opcache.validate_timestamps', value: '1' } + - { variable: 'opcache.revalidate_freq', value: '0' } + - { variable: 'opcache.interned_strings_buffer', value: '16' } + - { variable: 'opcache.max_accelerated_files', value: '7963' } + - { variable: 'opcache.fast_shutdown', value: '1' } diff --git a/docker/php-dev/7.0/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/php-module.xdebug.yml b/docker/php-dev/7.0/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/php-module.xdebug.yml new file mode 100644 index 000000000..7f20c845e --- /dev/null +++ b/docker/php-dev/7.0/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/php-module.xdebug.yml @@ -0,0 +1,28 @@ +--- + +# Ignored on php7 +- name: Fix php xdebug module [Alpine family] + lineinfile: + dest: '{{ item }}' + regexp: 'extension=xdebug.so' + line: 'zend_extension=xdebug.so' + when: ansible_distribution == 'Alpine' + with_items: + - /etc/php5/conf.d/xdebug.ini + - /etc/php7/conf.d/xdebug.ini + ignore_errors: yes + +- name: Setup php.ini for development environment + lineinfile: + dest: '/opt/docker/etc/php/php.webdevops.ini' + regexp: '^[\s;]*{{ item.variable }}[\s]*=' + line: '{{ item.variable }} = {{ item.value }}' + with_items: + - { variable: 'xdebug.remote_enable', value: '1' } + - { variable: 'xdebug.remote_connect_back', value: '1' } + - { variable: 'xdebug.idekey', value: 'docker' } + - { variable: 'xdebug.cli_color', value: '1' } + - { variable: 'xdebug.max_nesting_level', value: '1000' } + - { variable: 'xdebug.profiler_enable_trigger', value: '1000' } + - { variable: 'xdebug.profiler_output_dir', value: '/tmp/debug/' } + - { variable: 'xhprof.output_dir', value: '/tmp/debug/' } diff --git a/docker/php-dev/7.0/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/php-module.yml b/docker/php-dev/7.0/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/php-module.yml new file mode 100644 index 000000000..31cccd1ae --- /dev/null +++ b/docker/php-dev/7.0/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/php-module.yml @@ -0,0 +1,41 @@ +--- + +############################# +# Workaround PHP configuration files +# for alpine +############################# + +- name: Get list of PHP5 configuration files + command: "ls /etc/php5/conf.d/ |grep .ini" + register: php5_ini + when: ansible_distribution == 'Alpine' + ignore_errors: yes + +- name: Link configuration files from php5 to php + file: + src: '/etc/php5/conf.d/{{ item }}' + dest: '/etc/php/conf.d/{{ item }}' + state: link + with_items: "{{ php5_ini.stdout_lines }}" + when: ansible_distribution == 'Alpine' and php5_ini is defined + ignore_errors: yes + +############################# +# Workaround PHP module files +# for alpine +############################# + +- name: Get list of PHP5 modules + command: "ls /usr/lib/php5/modules/ |grep .so" + register: php5_modules + when: ansible_distribution == 'Alpine' + ignore_errors: yes + +- name: Link module files from php5 to php + file: + src: '/usr/lib/php5/modules/{{ item }}' + dest: '/usr/lib/php/modules/{{ item }}' + state: link + with_items: "{{ php5_modules.stdout_lines }}" + when: ansible_distribution == 'Alpine' and php5_modules is defined + ignore_errors: yes diff --git a/docker/php/debian-7-php7/conf/provision/roles/webdevops-php/tasks/main.yml b/docker/php-dev/7.0/conf/provision/roles/webdevops-php-dev/tasks/main.yml similarity index 100% rename from docker/php/debian-7-php7/conf/provision/roles/webdevops-php/tasks/main.yml rename to docker/php-dev/7.0/conf/provision/roles/webdevops-php-dev/tasks/main.yml diff --git a/docker/php-dev/7.1/Dockerfile b/docker/php-dev/7.1/Dockerfile new file mode 100644 index 000000000..b0eb188dd --- /dev/null +++ b/docker/php-dev/7.1/Dockerfile @@ -0,0 +1,22 @@ +#+++++++++++++++++++++++++++++++++++++++ +# Dockerfile for webdevops/php-dev:7.1 +# -- automatically generated -- +#+++++++++++++++++++++++++++++++++++++++ + +FROM webdevops/php:7.1 + +COPY conf/ /opt/docker/ + +# Install development environment +RUN wget -O - https://packagecloud.io/gpg.key | apt-key add - \ + && echo "deb https://packages.blackfire.io/debian any main" | tee /etc/apt/sources.list.d/blackfire.list \ + && /usr/local/bin/apt-install \ + blackfire-php \ + blackfire-agent \ + && pecl install xdebug \ + && echo "zend_extension=xdebug.so" > /usr/local/etc/php/conf.d/xdebug.ini \ + # Enable php development services + && docker-service-enable syslog ssh postfix \ + && /opt/docker/bin/provision run --tag bootstrap --role webdevops-dev --role webdevops-php-dev \ + && /opt/docker/bin/bootstrap.sh \ + && docker-image-cleanup diff --git a/docker/php-dev/7.1/Dockerfile.jinja2 b/docker/php-dev/7.1/Dockerfile.jinja2 new file mode 100644 index 000000000..af4d5837d --- /dev/null +++ b/docker/php-dev/7.1/Dockerfile.jinja2 @@ -0,0 +1,5 @@ +{{ docker.from("php", "7.1") }} + +{{ docker.copy('conf/', '/opt/docker/') }} + +{{ php.officialDevelopment(version="7.1") }} diff --git a/docker/php-dev/7.1/conf/bin/service.d/blackfire-agent.d/10-init.sh b/docker/php-dev/7.1/conf/bin/service.d/blackfire-agent.d/10-init.sh new file mode 100644 index 000000000..fdffa2a0f --- /dev/null +++ b/docker/php-dev/7.1/conf/bin/service.d/blackfire-agent.d/10-init.sh @@ -0,0 +1 @@ +# placeholder diff --git a/docker/php-dev/7.1/conf/bin/service.d/blackfire-agent.sh b/docker/php-dev/7.1/conf/bin/service.d/blackfire-agent.sh new file mode 100644 index 000000000..fbec23cf3 --- /dev/null +++ b/docker/php-dev/7.1/conf/bin/service.d/blackfire-agent.sh @@ -0,0 +1,23 @@ +#!/usr/bin/env bash +set -e + +source /opt/docker/bin/config.sh + +BLACKFIRE_ARGS="" + +includeScriptDir "/opt/docker/bin/service.d/syslog-ng.d/" + +# blackfire.server_id +if [[ -n "${BLACKFIRE_SERVER_ID+x}" ]]; then + BLACKFIRE_ARGS="$BLACKFIRE_ARGS --server-id=\"${BLACKFIRE_SERVER_ID}\"" +fi + +# blackfire.server_token +if [[ -n "${BLACKFIRE_SERVER_TOKEN+x}" ]]; then + BLACKFIRE_ARGS="$BLACKFIRE_ARGS --server-token=\"${BLACKFIRE_SERVER_TOKEN}\"" +fi + +# create directory for unix socket +mkdir -p /var/run/blackfire + +eval exec blackfire-agent $BLACKFIRE_ARGS diff --git a/docker/php-dev/7.1/conf/etc/supervisor.d/blackfire-agent.conf b/docker/php-dev/7.1/conf/etc/supervisor.d/blackfire-agent.conf new file mode 100644 index 000000000..897831ddb --- /dev/null +++ b/docker/php-dev/7.1/conf/etc/supervisor.d/blackfire-agent.conf @@ -0,0 +1,14 @@ +[group:blackfire-agent] +programs=blackfire-agentd +priority=25 + +[program:blackfire-agentd] +command = /opt/docker/bin/service.d/blackfire-agent.sh +process_name=%(program_name)s +startsecs = 0 +autostart = false +autorestart = true +stdout_logfile=/dev/stdout +stdout_logfile_maxbytes=0 +stderr_logfile=/dev/stderr +stderr_logfile_maxbytes=0 diff --git a/docker/php-dev/7.1/conf/provision/entrypoint.d/10-php-debugger.sh b/docker/php-dev/7.1/conf/provision/entrypoint.d/10-php-debugger.sh new file mode 100644 index 000000000..b5985a9ef --- /dev/null +++ b/docker/php-dev/7.1/conf/provision/entrypoint.d/10-php-debugger.sh @@ -0,0 +1,96 @@ +#!/usr/bin/env bash + +################################################# +# Debugger switch +################################################# + +PHP_CONF_PATHS=" +/etc/php5/conf.d +/etc/php7/conf.d +/etc/php.d +/etc/php5/mods-available +/etc/php5/cli/conf.d +/etc/php5/cli/conf.d +/etc/php5/fpm/conf.d +/etc/php5/fpm/conf.d +/etc/php/7.0/mods-available +/etc/php/7.0/cli/conf.d +/etc/php/7.0/fpm/conf.d +/usr/local/etc/php/conf.d/" + +function phpModuleRemove() { + if [ "$#" -ne 1 ]; then + echo "You must specify the name of the PHP module which you want to disable" + exit 1 + fi + + echo " - Removing PHP module ${1}" + for CONF_PATH in $PHP_CONF_PATHS; do + rm -f "${CONF_PATH}"/*"${1}".ini + done +} + + +if [[ -n "${PHP_DEBUGGER+x}" ]]; then + case "$PHP_DEBUGGER" in + xdebug) + echo "PHP-Debugger: Xdebug enabled" + phpModuleRemove "blackfire" + ;; + + blackfire) + echo "PHP-Debugger: Blackfire enabled" + phpModuleRemove "xdebug" + docker-service-enable blackfire-agent + ;; + + none) + echo "PHP-Debugger: none" + phpModuleRemove "blackfire" + phpModuleRemove "xdebug" + ;; + esac + +else + + echo "PHP-Debugger: not specified - default is xdebug" + phpModuleRemove "blackfire" + +fi + +################################################# +# PHP debugger environment variables +################################################# + +function phpEnvironmentVariable() { + PHP_INI_KEY="$1" + PHP_ENV_NAME="$2" + + if [[ -n "${!PHP_ENV_NAME+x}" ]]; then + PHP_ENV_VALUE="${!PHP_ENV_NAME}" + echo "${PHP_INI_KEY}=\"${PHP_ENV_VALUE}\"" >> /opt/docker/etc/php/php.ini + fi +} + +################### +# XDEBUG +################### + +# remote debugger +phpEnvironmentVariable "xdebug.remote_connect_back" "XDEBUG_REMOTE_CONNECT_BACK" +phpEnvironmentVariable "xdebug.remote_autostart" "XDEBUG_REMOTE_AUTOSTART" +phpEnvironmentVariable "xdebug.remote_host" "XDEBUG_REMOTE_HOST" +phpEnvironmentVariable "xdebug.remote_port" "XDEBUG_REMOTE_PORT" + +# profiler +phpEnvironmentVariable "xdebug.profiler_enable" "XDEBUG_PROFILER_ENABLE" +phpEnvironmentVariable "xdebug.profiler_enable_trigger" "XDEBUG_PROFILER_ENABLE_TRIGGER" +phpEnvironmentVariable "xdebug.profiler_enable_trigger_value" "XDEBUG_PROFILER_ENABLE_TRIGGER_VALUE" +phpEnvironmentVariable "xdebug.profiler_output_dir" "XDEBUG_PROFILER_OUTPUT_DIR" +phpEnvironmentVariable "xdebug.profiler_output_name" "XDEBUG_PROFILER_OUTPUT_NAME" + +################### +# BLACKFIRE +################### +phpEnvironmentVariable "blackfire.server_id" "BLACKFIRE_SERVER_ID" +phpEnvironmentVariable "blackfire.server_token" "BLACKFIRE_SERVER_TOKEN" diff --git a/docker/php-dev/7.1/conf/provision/roles/webdevops-dev/defaults/main.yml b/docker/php-dev/7.1/conf/provision/roles/webdevops-dev/defaults/main.yml new file mode 100644 index 000000000..4406ea8b4 --- /dev/null +++ b/docker/php-dev/7.1/conf/provision/roles/webdevops-dev/defaults/main.yml @@ -0,0 +1,7 @@ +--- + +APPLICATION_USER: "{{ lookup('env','APPLICATION_USER') }}" +APPLICATION_GROUP: "{{ lookup('env','APPLICATION_GROUP') }}" +APPLICATION_UID: "{{ lookup('env','APPLICATION_UID') }}" +APPLICATION_GID: "{{ lookup('env','APPLICATION_GID') }}" +APPLICATION_PASSWORD: "dev" diff --git a/docker/php-dev/7.1/conf/provision/roles/webdevops-dev/tasks/bootstrap.yml b/docker/php-dev/7.1/conf/provision/roles/webdevops-dev/tasks/bootstrap.yml new file mode 100644 index 000000000..3d7a494ad --- /dev/null +++ b/docker/php-dev/7.1/conf/provision/roles/webdevops-dev/tasks/bootstrap.yml @@ -0,0 +1,17 @@ +--- + +- name: Set application user password + user: + name: "{{ APPLICATION_USER }}" + password: "{{ APPLICATION_PASSWORD | password_hash('sha256') }}" + +- name: Set root password + user: + name: "root" + password: "{{ APPLICATION_PASSWORD | password_hash('sha256') }}" + +- name: Enable ssh root access + lineinfile: + dest: /etc/ssh/sshd_config + regexp: '^PermitRootLogin' + line: 'PermitRootLogin yes' diff --git a/provisioning/php/php7/provision/roles/webdevops-php/tasks/main.yml b/docker/php-dev/7.1/conf/provision/roles/webdevops-dev/tasks/main.yml similarity index 100% rename from provisioning/php/php7/provision/roles/webdevops-php/tasks/main.yml rename to docker/php-dev/7.1/conf/provision/roles/webdevops-dev/tasks/main.yml diff --git a/docker/php/alpine-3/conf/provision/roles/webdevops-php/defaults/main.yml b/docker/php-dev/7.1/conf/provision/roles/webdevops-php-dev/defaults/main.yml similarity index 100% rename from docker/php/alpine-3/conf/provision/roles/webdevops-php/defaults/main.yml rename to docker/php-dev/7.1/conf/provision/roles/webdevops-php-dev/defaults/main.yml diff --git a/docker/php-dev/7.1/conf/provision/roles/webdevops-php-dev/tasks/bootstrap.yml b/docker/php-dev/7.1/conf/provision/roles/webdevops-php-dev/tasks/bootstrap.yml new file mode 100644 index 000000000..ff02b05fc --- /dev/null +++ b/docker/php-dev/7.1/conf/provision/roles/webdevops-php-dev/tasks/bootstrap.yml @@ -0,0 +1,7 @@ +--- + +- include: bootstrap/php-fpm.yml +- include: bootstrap/php-module.yml +- include: bootstrap/php-module.opcache.yml +- include: bootstrap/php-module.xdebug.yml +- include: bootstrap/php-module.blackfire.yml diff --git a/docker/php-dev/7.1/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/php-fpm.yml b/docker/php-dev/7.1/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/php-fpm.yml new file mode 100644 index 000000000..9455a78e2 --- /dev/null +++ b/docker/php-dev/7.1/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/php-fpm.yml @@ -0,0 +1,18 @@ +--- + +- name: Configure php-fpm pool user (application.conf) + lineinfile: + dest: '/opt/docker/etc/php/fpm/pool.d/application.conf' + regexp: '^[\s;]*{{ item.key }}[\s]*=' + line: '{{ item.key }} = {{ item.value }}' + with_items: + - { key: 'access.log', value: "/docker.stdout" } + - { key: "access.format", value: '"%R - %u %t \"%m %r%Q%q\" %s %f cpu:%C%% mem:%{megabytes}M reqTime:%d"' } + +- name: Open php-fpm for external connections (eg. debuggers) + lineinfile: + dest: '/opt/docker/etc/php/fpm/pool.d/application.conf' + regexp: '^[\s;]*{{ item.key }}[\s]*=' + line: '{{ item.key }} = {{ item.value }}' + with_items: + - { key: 'listen', value: "0.0.0.0:9000" } diff --git a/docker/php-dev/7.1/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/php-module.blackfire.yml b/docker/php-dev/7.1/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/php-module.blackfire.yml new file mode 100644 index 000000000..faf05f8de --- /dev/null +++ b/docker/php-dev/7.1/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/php-module.blackfire.yml @@ -0,0 +1,10 @@ +--- + +- name: Remove superfluous blackfire configuration file + file: + path: '{{ item }}' + state: absent + with_items: + - /etc/php5/cli/conf.d/zz-blackfire.ini + - /etc/php5/fpm/conf.d/zz-blackfire.ini + when: ansible_distribution == 'Debian' and docker_image_info_distribution_version|int >= 7 diff --git a/docker/php-dev/7.1/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/php-module.opcache.yml b/docker/php-dev/7.1/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/php-module.opcache.yml new file mode 100644 index 000000000..9c243a671 --- /dev/null +++ b/docker/php-dev/7.1/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/php-module.opcache.yml @@ -0,0 +1,14 @@ +--- + +- name: Setup php.ini for development environment + lineinfile: + dest: '/opt/docker/etc/php/php.webdevops.ini' + regexp: '^[\s;]*{{ item.variable }}[\s]*=' + line: '{{ item.variable }} = {{ item.value }}' + with_items: + - { variable: 'opcache.memory_consumption', value: '256' } + - { variable: 'opcache.validate_timestamps', value: '1' } + - { variable: 'opcache.revalidate_freq', value: '0' } + - { variable: 'opcache.interned_strings_buffer', value: '16' } + - { variable: 'opcache.max_accelerated_files', value: '7963' } + - { variable: 'opcache.fast_shutdown', value: '1' } diff --git a/docker/php-dev/7.1/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/php-module.xdebug.yml b/docker/php-dev/7.1/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/php-module.xdebug.yml new file mode 100644 index 000000000..7f20c845e --- /dev/null +++ b/docker/php-dev/7.1/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/php-module.xdebug.yml @@ -0,0 +1,28 @@ +--- + +# Ignored on php7 +- name: Fix php xdebug module [Alpine family] + lineinfile: + dest: '{{ item }}' + regexp: 'extension=xdebug.so' + line: 'zend_extension=xdebug.so' + when: ansible_distribution == 'Alpine' + with_items: + - /etc/php5/conf.d/xdebug.ini + - /etc/php7/conf.d/xdebug.ini + ignore_errors: yes + +- name: Setup php.ini for development environment + lineinfile: + dest: '/opt/docker/etc/php/php.webdevops.ini' + regexp: '^[\s;]*{{ item.variable }}[\s]*=' + line: '{{ item.variable }} = {{ item.value }}' + with_items: + - { variable: 'xdebug.remote_enable', value: '1' } + - { variable: 'xdebug.remote_connect_back', value: '1' } + - { variable: 'xdebug.idekey', value: 'docker' } + - { variable: 'xdebug.cli_color', value: '1' } + - { variable: 'xdebug.max_nesting_level', value: '1000' } + - { variable: 'xdebug.profiler_enable_trigger', value: '1000' } + - { variable: 'xdebug.profiler_output_dir', value: '/tmp/debug/' } + - { variable: 'xhprof.output_dir', value: '/tmp/debug/' } diff --git a/docker/php-dev/7.1/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/php-module.yml b/docker/php-dev/7.1/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/php-module.yml new file mode 100644 index 000000000..31cccd1ae --- /dev/null +++ b/docker/php-dev/7.1/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/php-module.yml @@ -0,0 +1,41 @@ +--- + +############################# +# Workaround PHP configuration files +# for alpine +############################# + +- name: Get list of PHP5 configuration files + command: "ls /etc/php5/conf.d/ |grep .ini" + register: php5_ini + when: ansible_distribution == 'Alpine' + ignore_errors: yes + +- name: Link configuration files from php5 to php + file: + src: '/etc/php5/conf.d/{{ item }}' + dest: '/etc/php/conf.d/{{ item }}' + state: link + with_items: "{{ php5_ini.stdout_lines }}" + when: ansible_distribution == 'Alpine' and php5_ini is defined + ignore_errors: yes + +############################# +# Workaround PHP module files +# for alpine +############################# + +- name: Get list of PHP5 modules + command: "ls /usr/lib/php5/modules/ |grep .so" + register: php5_modules + when: ansible_distribution == 'Alpine' + ignore_errors: yes + +- name: Link module files from php5 to php + file: + src: '/usr/lib/php5/modules/{{ item }}' + dest: '/usr/lib/php/modules/{{ item }}' + state: link + with_items: "{{ php5_modules.stdout_lines }}" + when: ansible_distribution == 'Alpine' and php5_modules is defined + ignore_errors: yes diff --git a/docker/php-dev/7.1/conf/provision/roles/webdevops-php-dev/tasks/main.yml b/docker/php-dev/7.1/conf/provision/roles/webdevops-php-dev/tasks/main.yml new file mode 100644 index 000000000..1806c1a8c --- /dev/null +++ b/docker/php-dev/7.1/conf/provision/roles/webdevops-php-dev/tasks/main.yml @@ -0,0 +1,5 @@ +--- + +- include: bootstrap.yml + tags: + - bootstrap diff --git a/docker/php-dev/alpine b/docker/php-dev/alpine new file mode 120000 index 000000000..a5e678cb6 --- /dev/null +++ b/docker/php-dev/alpine @@ -0,0 +1 @@ +alpine-php7 \ No newline at end of file diff --git a/docker/php-dev/alpine-3 b/docker/php-dev/alpine-3 new file mode 120000 index 000000000..a84cfe247 --- /dev/null +++ b/docker/php-dev/alpine-3 @@ -0,0 +1 @@ +alpine-php5 \ No newline at end of file diff --git a/docker/php-dev/alpine-3-php7 b/docker/php-dev/alpine-3-php7 new file mode 120000 index 000000000..a5e678cb6 --- /dev/null +++ b/docker/php-dev/alpine-3-php7 @@ -0,0 +1 @@ +alpine-php7 \ No newline at end of file diff --git a/docker/php-dev/alpine-3-php7/Dockerfile b/docker/php-dev/alpine-3-php7/Dockerfile deleted file mode 100644 index 40412dea2..000000000 --- a/docker/php-dev/alpine-3-php7/Dockerfile +++ /dev/null @@ -1,23 +0,0 @@ -#+++++++++++++++++++++++++++++++++++++++ -# Dockerfile for webdevops/php-dev:alpine-3-php7 -# -- automatically generated -- -#+++++++++++++++++++++++++++++++++++++++ - -FROM webdevops/php:alpine-3-php7 - -MAINTAINER info@webdevops.io -LABEL vendor=WebDevOps.io -LABEL io.webdevops.layout=8 -LABEL io.webdevops.version=1.5.0 - -COPY conf/ /opt/docker/ - -# Install development environment -RUN /usr/local/bin/apk-install \ - # Install tools - graphviz \ - # Install php development stuff - php7-xdebug \ - && /opt/docker/bin/provision run --tag bootstrap --role webdevops-dev --role webdevops-php-dev \ - && /opt/docker/bin/bootstrap.sh - diff --git a/docker/php-dev/alpine-3-php7/Dockerfile.jinja2 b/docker/php-dev/alpine-3-php7/Dockerfile.jinja2 deleted file mode 100644 index 780f0ecbc..000000000 --- a/docker/php-dev/alpine-3-php7/Dockerfile.jinja2 +++ /dev/null @@ -1,7 +0,0 @@ -{{ docker.from("php", "alpine-3-php7") }} - -{{ docker.version() }} - -{{ docker.copy('conf/', '/opt/docker/') }} - -{{ php7dev.alpine() }} diff --git a/docker/php-dev/alpine-3-php7/conf/provision/entrypoint.d/10-php-debugger.sh b/docker/php-dev/alpine-3-php7/conf/provision/entrypoint.d/10-php-debugger.sh deleted file mode 100644 index 7156e28aa..000000000 --- a/docker/php-dev/alpine-3-php7/conf/provision/entrypoint.d/10-php-debugger.sh +++ /dev/null @@ -1,95 +0,0 @@ -#!/usr/bin/env bash - -################################################# -# Debugger switch -################################################# - -PHP_CONF_PATHS=" -/etc/php5/conf.d -/etc/php7/conf.d -/etc/php.d -/etc/php5/mods-available -/etc/php5/cli/conf.d -/etc/php5/cli/conf.d -/etc/php5/fpm/conf.d -/etc/php5/fpm/conf.d -/etc/php/7.0/mods-available -/etc/php/7.0/cli/conf.d -/etc/php/7.0/fpm/conf.d" - -function phpModuleRemove() { - if [ "$#" -ne 1 ]; then - echo "You must specify the name of the PHP module which you want to disable" - exit 1 - fi - - echo " - Removing PHP module ${1}" - for CONF_PATH in $PHP_CONF_PATHS; do - rm -f "${CONF_PATH}"/*"${1}".ini - done -} - - -if [[ -n "${PHP_DEBUGGER+x}" ]]; then - case "$PHP_DEBUGGER" in - xdebug) - echo "PHP-Debugger: Xdebug enabled" - phpModuleRemove "blackfire" - ;; - - blackfire) - echo "PHP-Debugger: Blackfire enabled" - phpModuleRemove "xdebug" - /opt/docker/bin/control.sh service.enable blackfire-agent - ;; - - none) - echo "PHP-Debugger: none" - phpModuleRemove "blackfire" - phpModuleRemove "xdebug" - ;; - esac - -else - - echo "PHP-Debugger: not specified - default is xdebug" - phpModuleRemove "blackfire" - -fi - -################################################# -# PHP debugger environment variables -################################################# - -function phpEnvironmentVariable() { - PHP_INI_KEY="$1" - PHP_ENV_NAME="$2" - - if [[ -n "${!PHP_ENV_NAME+x}" ]]; then - PHP_ENV_VALUE="${!PHP_ENV_NAME}" - echo "${PHP_INI_KEY}=\"${PHP_ENV_VALUE}\"" >> /opt/docker/etc/php/php.ini - fi -} - -################### -# XDEBUG -################### - -# remote debugger -phpEnvironmentVariable "xdebug.remote_connect_back" "XDEBUG_REMOTE_CONNECT_BACK" -phpEnvironmentVariable "xdebug.remote_autostart" "XDEBUG_REMOTE_AUTOSTART" -phpEnvironmentVariable "xdebug.remote_host" "XDEBUG_REMOTE_HOST" -phpEnvironmentVariable "xdebug.remote_port" "XDEBUG_REMOTE_PORT" - -# profiler -phpEnvironmentVariable "xdebug.profiler_enable" "XDEBUG_PROFILER_ENABLE" -phpEnvironmentVariable "xdebug.profiler_enable_trigger" "XDEBUG_PROFILER_ENABLE_TRIGGER" -phpEnvironmentVariable "xdebug.profiler_enable_trigger_value" "XDEBUG_PROFILER_ENABLE_TRIGGER_VALUE" -phpEnvironmentVariable "xdebug.profiler_output_dir" "XDEBUG_PROFILER_OUTPUT_DIR" -phpEnvironmentVariable "xdebug.profiler_output_name" "XDEBUG_PROFILER_OUTPUT_NAME" - -################### -# BLACKFIRE -################### -phpEnvironmentVariable "blackfire.server_id" "BLACKFIRE_SERVER_ID" -phpEnvironmentVariable "blackfire.server_token" "BLACKFIRE_SERVER_TOKEN" diff --git a/docker/php-dev/alpine-3-php7/conf/provision/roles/webdevops-dev/tasks/bootstrap.yml b/docker/php-dev/alpine-3-php7/conf/provision/roles/webdevops-dev/tasks/bootstrap.yml deleted file mode 100644 index 5c9eafbd0..000000000 --- a/docker/php-dev/alpine-3-php7/conf/provision/roles/webdevops-dev/tasks/bootstrap.yml +++ /dev/null @@ -1,20 +0,0 @@ ---- - -- name: Enable ssh daemon - shell: "/opt/docker/bin/control.sh service.enable ssh" - -- name: Set application user password - user: - name: "{{ APPLICATION_USER }}" - password: "{{ APPLICATION_PASSWORD | password_hash('sha256') }}" - -- name: Set root password - user: - name: "root" - password: "{{ APPLICATION_PASSWORD | password_hash('sha256') }}" - -- name: Enable ssh root access - lineinfile: - dest: /etc/ssh/sshd_config - regexp: '^PermitRootLogin' - line: 'PermitRootLogin yes' diff --git a/docker/php-dev/alpine-3-php7/conf/provision/roles/webdevops-php-dev/tasks/bootstrap.yml b/docker/php-dev/alpine-3-php7/conf/provision/roles/webdevops-php-dev/tasks/bootstrap.yml deleted file mode 100644 index 2c5d76e3d..000000000 --- a/docker/php-dev/alpine-3-php7/conf/provision/roles/webdevops-php-dev/tasks/bootstrap.yml +++ /dev/null @@ -1,8 +0,0 @@ ---- - -- include: bootstrap/tools.yml -- include: bootstrap/php-fpm.yml -- include: bootstrap/php-module.yml -- include: bootstrap/php-module.opcache.yml -- include: bootstrap/php-module.xdebug.yml -- include: bootstrap/php-module.blackfire.yml diff --git a/docker/php-dev/alpine-3-php7/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/php-module.blackfire.yml b/docker/php-dev/alpine-3-php7/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/php-module.blackfire.yml deleted file mode 100644 index 1a3db9bac..000000000 --- a/docker/php-dev/alpine-3-php7/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/php-module.blackfire.yml +++ /dev/null @@ -1,10 +0,0 @@ ---- - -- name: Remove superfluous blackfire configuration file - file: - path: '{{ item }}' - state: absent - with_items: - - /etc/php5/cli/conf.d/zz-blackfire.ini - - /etc/php5/fpm/conf.d/zz-blackfire.ini - when: ansible_distribution == 'Debian' and ansible_lsb.major_release|int >= 7 diff --git a/docker/php-dev/alpine-3-php7/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/tools.yml b/docker/php-dev/alpine-3-php7/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/tools.yml deleted file mode 100644 index c49cb0e34..000000000 --- a/docker/php-dev/alpine-3-php7/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/tools.yml +++ /dev/null @@ -1,23 +0,0 @@ ---- - -- name: Downloading Tools - shell: curl -o "{{ item.dest }}" "{{ item.url }}" && chmod 755 "{{ item.dest }}" - with_items: - - { url: "https://phar.phpunit.de/phploc.phar", dest: /usr/local/bin/phploc } - - { url: "https://phar.phpunit.de/phpunit.phar", dest: /usr/local/bin/phpunit } - - { url: "http://static.pdepend.org/php/latest/pdepend.phar", dest: /usr/local/bin/pdepend } - - { url: "http://static.phpmd.org/php/latest/phpmd.phar", dest: /usr/local/bin/phpmd } - - { url: "https://squizlabs.github.io/PHP_CodeSniffer/phpcs.phar", dest: /usr/local/bin/phpcs } - - { url: "https://squizlabs.github.io/PHP_CodeSniffer/phpcbf.phar", dest: /usr/local/bin/phpcbf } - - { url: "https://phar.phpunit.de/phpcpd.phar", dest: /usr/local/bin/phpcpd } - - { url: "https://phar.phpunit.de/phpdcd.phar", dest: /usr/local/bin/phpdcd } - - { url: "https://github.com/Halleck45/PhpMetrics/raw/master/build/phpmetrics.phar", dest: /usr/local/bin/phpmetrics } - - { url: "http://get.sensiolabs.org/php-cs-fixer.phar", dest: /usr/local/bin/php-cs-fixer } - - { url: "https://github.com/sensiolabs-de/deprecation-detector/releases/download/0.1.0-alpha4/deprecation-detector.phar", dest: /usr/local/bin/deprecation-detector } - - { url: "https://github.com/sensiolabs-de/deprecation-detector/releases/download/0.1.0-alpha4/deprecation-detector.phar", dest: /usr/local/bin/deprecation-detector } - -- name: Install Tools via composer - raw: COMPOSER_HOME="/usr/local/composer" COMPOSER_BIN_DIR="/usr/local/bin" composer global require "{{ item.package }}" "{{ item.version }}" - with_items: - - { package: "sstalle/php7cc" , version: "*" } - - { package: "phpspec/phpspec" , version: "~2.0" } diff --git a/docker/php-dev/alpine-3/Dockerfile b/docker/php-dev/alpine-3/Dockerfile deleted file mode 100644 index 0ca5b4565..000000000 --- a/docker/php-dev/alpine-3/Dockerfile +++ /dev/null @@ -1,23 +0,0 @@ -#+++++++++++++++++++++++++++++++++++++++ -# Dockerfile for webdevops/php-dev:alpine-3 -# -- automatically generated -- -#+++++++++++++++++++++++++++++++++++++++ - -FROM webdevops/php:alpine-3 - -MAINTAINER info@webdevops.io -LABEL vendor=WebDevOps.io -LABEL io.webdevops.layout=8 -LABEL io.webdevops.version=1.5.0 - -COPY conf/ /opt/docker/ - -# Install development environment -RUN /usr/local/bin/apk-install \ - # Install tools - graphviz \ - # Install php development stuff - php5-xdebug \ - && /opt/docker/bin/provision run --tag bootstrap --role webdevops-dev --role webdevops-php-dev \ - && /opt/docker/bin/bootstrap.sh - diff --git a/docker/php-dev/alpine-3/Dockerfile.jinja2 b/docker/php-dev/alpine-3/Dockerfile.jinja2 deleted file mode 100644 index 2ef976fe7..000000000 --- a/docker/php-dev/alpine-3/Dockerfile.jinja2 +++ /dev/null @@ -1,7 +0,0 @@ -{{ docker.from("php", "alpine-3") }} - -{{ docker.version() }} - -{{ docker.copy('conf/', '/opt/docker/') }} - -{{ php5dev.alpine() }} diff --git a/docker/php-dev/alpine-3/conf/provision/entrypoint.d/10-php-debugger.sh b/docker/php-dev/alpine-3/conf/provision/entrypoint.d/10-php-debugger.sh deleted file mode 100644 index 7156e28aa..000000000 --- a/docker/php-dev/alpine-3/conf/provision/entrypoint.d/10-php-debugger.sh +++ /dev/null @@ -1,95 +0,0 @@ -#!/usr/bin/env bash - -################################################# -# Debugger switch -################################################# - -PHP_CONF_PATHS=" -/etc/php5/conf.d -/etc/php7/conf.d -/etc/php.d -/etc/php5/mods-available -/etc/php5/cli/conf.d -/etc/php5/cli/conf.d -/etc/php5/fpm/conf.d -/etc/php5/fpm/conf.d -/etc/php/7.0/mods-available -/etc/php/7.0/cli/conf.d -/etc/php/7.0/fpm/conf.d" - -function phpModuleRemove() { - if [ "$#" -ne 1 ]; then - echo "You must specify the name of the PHP module which you want to disable" - exit 1 - fi - - echo " - Removing PHP module ${1}" - for CONF_PATH in $PHP_CONF_PATHS; do - rm -f "${CONF_PATH}"/*"${1}".ini - done -} - - -if [[ -n "${PHP_DEBUGGER+x}" ]]; then - case "$PHP_DEBUGGER" in - xdebug) - echo "PHP-Debugger: Xdebug enabled" - phpModuleRemove "blackfire" - ;; - - blackfire) - echo "PHP-Debugger: Blackfire enabled" - phpModuleRemove "xdebug" - /opt/docker/bin/control.sh service.enable blackfire-agent - ;; - - none) - echo "PHP-Debugger: none" - phpModuleRemove "blackfire" - phpModuleRemove "xdebug" - ;; - esac - -else - - echo "PHP-Debugger: not specified - default is xdebug" - phpModuleRemove "blackfire" - -fi - -################################################# -# PHP debugger environment variables -################################################# - -function phpEnvironmentVariable() { - PHP_INI_KEY="$1" - PHP_ENV_NAME="$2" - - if [[ -n "${!PHP_ENV_NAME+x}" ]]; then - PHP_ENV_VALUE="${!PHP_ENV_NAME}" - echo "${PHP_INI_KEY}=\"${PHP_ENV_VALUE}\"" >> /opt/docker/etc/php/php.ini - fi -} - -################### -# XDEBUG -################### - -# remote debugger -phpEnvironmentVariable "xdebug.remote_connect_back" "XDEBUG_REMOTE_CONNECT_BACK" -phpEnvironmentVariable "xdebug.remote_autostart" "XDEBUG_REMOTE_AUTOSTART" -phpEnvironmentVariable "xdebug.remote_host" "XDEBUG_REMOTE_HOST" -phpEnvironmentVariable "xdebug.remote_port" "XDEBUG_REMOTE_PORT" - -# profiler -phpEnvironmentVariable "xdebug.profiler_enable" "XDEBUG_PROFILER_ENABLE" -phpEnvironmentVariable "xdebug.profiler_enable_trigger" "XDEBUG_PROFILER_ENABLE_TRIGGER" -phpEnvironmentVariable "xdebug.profiler_enable_trigger_value" "XDEBUG_PROFILER_ENABLE_TRIGGER_VALUE" -phpEnvironmentVariable "xdebug.profiler_output_dir" "XDEBUG_PROFILER_OUTPUT_DIR" -phpEnvironmentVariable "xdebug.profiler_output_name" "XDEBUG_PROFILER_OUTPUT_NAME" - -################### -# BLACKFIRE -################### -phpEnvironmentVariable "blackfire.server_id" "BLACKFIRE_SERVER_ID" -phpEnvironmentVariable "blackfire.server_token" "BLACKFIRE_SERVER_TOKEN" diff --git a/docker/php-dev/alpine-3/conf/provision/roles/webdevops-dev/tasks/bootstrap.yml b/docker/php-dev/alpine-3/conf/provision/roles/webdevops-dev/tasks/bootstrap.yml deleted file mode 100644 index 5c9eafbd0..000000000 --- a/docker/php-dev/alpine-3/conf/provision/roles/webdevops-dev/tasks/bootstrap.yml +++ /dev/null @@ -1,20 +0,0 @@ ---- - -- name: Enable ssh daemon - shell: "/opt/docker/bin/control.sh service.enable ssh" - -- name: Set application user password - user: - name: "{{ APPLICATION_USER }}" - password: "{{ APPLICATION_PASSWORD | password_hash('sha256') }}" - -- name: Set root password - user: - name: "root" - password: "{{ APPLICATION_PASSWORD | password_hash('sha256') }}" - -- name: Enable ssh root access - lineinfile: - dest: /etc/ssh/sshd_config - regexp: '^PermitRootLogin' - line: 'PermitRootLogin yes' diff --git a/docker/php-dev/alpine-3/conf/provision/roles/webdevops-php-dev/tasks/bootstrap.yml b/docker/php-dev/alpine-3/conf/provision/roles/webdevops-php-dev/tasks/bootstrap.yml deleted file mode 100644 index 2c5d76e3d..000000000 --- a/docker/php-dev/alpine-3/conf/provision/roles/webdevops-php-dev/tasks/bootstrap.yml +++ /dev/null @@ -1,8 +0,0 @@ ---- - -- include: bootstrap/tools.yml -- include: bootstrap/php-fpm.yml -- include: bootstrap/php-module.yml -- include: bootstrap/php-module.opcache.yml -- include: bootstrap/php-module.xdebug.yml -- include: bootstrap/php-module.blackfire.yml diff --git a/docker/php-dev/alpine-3/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/php-module.blackfire.yml b/docker/php-dev/alpine-3/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/php-module.blackfire.yml deleted file mode 100644 index 1a3db9bac..000000000 --- a/docker/php-dev/alpine-3/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/php-module.blackfire.yml +++ /dev/null @@ -1,10 +0,0 @@ ---- - -- name: Remove superfluous blackfire configuration file - file: - path: '{{ item }}' - state: absent - with_items: - - /etc/php5/cli/conf.d/zz-blackfire.ini - - /etc/php5/fpm/conf.d/zz-blackfire.ini - when: ansible_distribution == 'Debian' and ansible_lsb.major_release|int >= 7 diff --git a/docker/php-dev/alpine-3/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/tools.yml b/docker/php-dev/alpine-3/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/tools.yml deleted file mode 100644 index c49cb0e34..000000000 --- a/docker/php-dev/alpine-3/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/tools.yml +++ /dev/null @@ -1,23 +0,0 @@ ---- - -- name: Downloading Tools - shell: curl -o "{{ item.dest }}" "{{ item.url }}" && chmod 755 "{{ item.dest }}" - with_items: - - { url: "https://phar.phpunit.de/phploc.phar", dest: /usr/local/bin/phploc } - - { url: "https://phar.phpunit.de/phpunit.phar", dest: /usr/local/bin/phpunit } - - { url: "http://static.pdepend.org/php/latest/pdepend.phar", dest: /usr/local/bin/pdepend } - - { url: "http://static.phpmd.org/php/latest/phpmd.phar", dest: /usr/local/bin/phpmd } - - { url: "https://squizlabs.github.io/PHP_CodeSniffer/phpcs.phar", dest: /usr/local/bin/phpcs } - - { url: "https://squizlabs.github.io/PHP_CodeSniffer/phpcbf.phar", dest: /usr/local/bin/phpcbf } - - { url: "https://phar.phpunit.de/phpcpd.phar", dest: /usr/local/bin/phpcpd } - - { url: "https://phar.phpunit.de/phpdcd.phar", dest: /usr/local/bin/phpdcd } - - { url: "https://github.com/Halleck45/PhpMetrics/raw/master/build/phpmetrics.phar", dest: /usr/local/bin/phpmetrics } - - { url: "http://get.sensiolabs.org/php-cs-fixer.phar", dest: /usr/local/bin/php-cs-fixer } - - { url: "https://github.com/sensiolabs-de/deprecation-detector/releases/download/0.1.0-alpha4/deprecation-detector.phar", dest: /usr/local/bin/deprecation-detector } - - { url: "https://github.com/sensiolabs-de/deprecation-detector/releases/download/0.1.0-alpha4/deprecation-detector.phar", dest: /usr/local/bin/deprecation-detector } - -- name: Install Tools via composer - raw: COMPOSER_HOME="/usr/local/composer" COMPOSER_BIN_DIR="/usr/local/bin" composer global require "{{ item.package }}" "{{ item.version }}" - with_items: - - { package: "sstalle/php7cc" , version: "*" } - - { package: "phpspec/phpspec" , version: "~2.0" } diff --git a/docker/php-dev/alpine-php5/Dockerfile b/docker/php-dev/alpine-php5/Dockerfile new file mode 100644 index 000000000..7057af4da --- /dev/null +++ b/docker/php-dev/alpine-php5/Dockerfile @@ -0,0 +1,23 @@ +#+++++++++++++++++++++++++++++++++++++++ +# Dockerfile for webdevops/php-dev:alpine-php5 +# -- automatically generated -- +#+++++++++++++++++++++++++++++++++++++++ + +FROM webdevops/php:alpine-php5 + +COPY conf/ /opt/docker/ + +# Install development environment +RUN /usr/local/bin/apk-install \ + # Install tools + graphviz \ + # Install php development stuff + php5-xdebug \ + # Tools + nano \ + vim \ + # Enable php development services + && docker-service-enable syslog ssh postfix \ + && /opt/docker/bin/provision run --tag bootstrap --role webdevops-dev --role webdevops-php-dev \ + && /opt/docker/bin/bootstrap.sh \ + && docker-image-cleanup diff --git a/docker/php-dev/alpine-php5/Dockerfile.jinja2 b/docker/php-dev/alpine-php5/Dockerfile.jinja2 new file mode 100644 index 000000000..5a19e8b50 --- /dev/null +++ b/docker/php-dev/alpine-php5/Dockerfile.jinja2 @@ -0,0 +1,5 @@ +{{ docker.from("php", "alpine-php5") }} + +{{ docker.copy('conf/', '/opt/docker/') }} + +{{ php5dev.alpine() }} diff --git a/docker/php-dev/alpine-php5/conf/bin/service.d/blackfire-agent.d/10-init.sh b/docker/php-dev/alpine-php5/conf/bin/service.d/blackfire-agent.d/10-init.sh new file mode 100644 index 000000000..fdffa2a0f --- /dev/null +++ b/docker/php-dev/alpine-php5/conf/bin/service.d/blackfire-agent.d/10-init.sh @@ -0,0 +1 @@ +# placeholder diff --git a/docker/php-dev/alpine-php5/conf/bin/service.d/blackfire-agent.sh b/docker/php-dev/alpine-php5/conf/bin/service.d/blackfire-agent.sh new file mode 100644 index 000000000..fbec23cf3 --- /dev/null +++ b/docker/php-dev/alpine-php5/conf/bin/service.d/blackfire-agent.sh @@ -0,0 +1,23 @@ +#!/usr/bin/env bash +set -e + +source /opt/docker/bin/config.sh + +BLACKFIRE_ARGS="" + +includeScriptDir "/opt/docker/bin/service.d/syslog-ng.d/" + +# blackfire.server_id +if [[ -n "${BLACKFIRE_SERVER_ID+x}" ]]; then + BLACKFIRE_ARGS="$BLACKFIRE_ARGS --server-id=\"${BLACKFIRE_SERVER_ID}\"" +fi + +# blackfire.server_token +if [[ -n "${BLACKFIRE_SERVER_TOKEN+x}" ]]; then + BLACKFIRE_ARGS="$BLACKFIRE_ARGS --server-token=\"${BLACKFIRE_SERVER_TOKEN}\"" +fi + +# create directory for unix socket +mkdir -p /var/run/blackfire + +eval exec blackfire-agent $BLACKFIRE_ARGS diff --git a/docker/php-dev/alpine-php5/conf/etc/supervisor.d/blackfire-agent.conf b/docker/php-dev/alpine-php5/conf/etc/supervisor.d/blackfire-agent.conf new file mode 100644 index 000000000..897831ddb --- /dev/null +++ b/docker/php-dev/alpine-php5/conf/etc/supervisor.d/blackfire-agent.conf @@ -0,0 +1,14 @@ +[group:blackfire-agent] +programs=blackfire-agentd +priority=25 + +[program:blackfire-agentd] +command = /opt/docker/bin/service.d/blackfire-agent.sh +process_name=%(program_name)s +startsecs = 0 +autostart = false +autorestart = true +stdout_logfile=/dev/stdout +stdout_logfile_maxbytes=0 +stderr_logfile=/dev/stderr +stderr_logfile_maxbytes=0 diff --git a/docker/php-dev/alpine-php5/conf/provision/entrypoint.d/10-php-debugger.sh b/docker/php-dev/alpine-php5/conf/provision/entrypoint.d/10-php-debugger.sh new file mode 100644 index 000000000..b5985a9ef --- /dev/null +++ b/docker/php-dev/alpine-php5/conf/provision/entrypoint.d/10-php-debugger.sh @@ -0,0 +1,96 @@ +#!/usr/bin/env bash + +################################################# +# Debugger switch +################################################# + +PHP_CONF_PATHS=" +/etc/php5/conf.d +/etc/php7/conf.d +/etc/php.d +/etc/php5/mods-available +/etc/php5/cli/conf.d +/etc/php5/cli/conf.d +/etc/php5/fpm/conf.d +/etc/php5/fpm/conf.d +/etc/php/7.0/mods-available +/etc/php/7.0/cli/conf.d +/etc/php/7.0/fpm/conf.d +/usr/local/etc/php/conf.d/" + +function phpModuleRemove() { + if [ "$#" -ne 1 ]; then + echo "You must specify the name of the PHP module which you want to disable" + exit 1 + fi + + echo " - Removing PHP module ${1}" + for CONF_PATH in $PHP_CONF_PATHS; do + rm -f "${CONF_PATH}"/*"${1}".ini + done +} + + +if [[ -n "${PHP_DEBUGGER+x}" ]]; then + case "$PHP_DEBUGGER" in + xdebug) + echo "PHP-Debugger: Xdebug enabled" + phpModuleRemove "blackfire" + ;; + + blackfire) + echo "PHP-Debugger: Blackfire enabled" + phpModuleRemove "xdebug" + docker-service-enable blackfire-agent + ;; + + none) + echo "PHP-Debugger: none" + phpModuleRemove "blackfire" + phpModuleRemove "xdebug" + ;; + esac + +else + + echo "PHP-Debugger: not specified - default is xdebug" + phpModuleRemove "blackfire" + +fi + +################################################# +# PHP debugger environment variables +################################################# + +function phpEnvironmentVariable() { + PHP_INI_KEY="$1" + PHP_ENV_NAME="$2" + + if [[ -n "${!PHP_ENV_NAME+x}" ]]; then + PHP_ENV_VALUE="${!PHP_ENV_NAME}" + echo "${PHP_INI_KEY}=\"${PHP_ENV_VALUE}\"" >> /opt/docker/etc/php/php.ini + fi +} + +################### +# XDEBUG +################### + +# remote debugger +phpEnvironmentVariable "xdebug.remote_connect_back" "XDEBUG_REMOTE_CONNECT_BACK" +phpEnvironmentVariable "xdebug.remote_autostart" "XDEBUG_REMOTE_AUTOSTART" +phpEnvironmentVariable "xdebug.remote_host" "XDEBUG_REMOTE_HOST" +phpEnvironmentVariable "xdebug.remote_port" "XDEBUG_REMOTE_PORT" + +# profiler +phpEnvironmentVariable "xdebug.profiler_enable" "XDEBUG_PROFILER_ENABLE" +phpEnvironmentVariable "xdebug.profiler_enable_trigger" "XDEBUG_PROFILER_ENABLE_TRIGGER" +phpEnvironmentVariable "xdebug.profiler_enable_trigger_value" "XDEBUG_PROFILER_ENABLE_TRIGGER_VALUE" +phpEnvironmentVariable "xdebug.profiler_output_dir" "XDEBUG_PROFILER_OUTPUT_DIR" +phpEnvironmentVariable "xdebug.profiler_output_name" "XDEBUG_PROFILER_OUTPUT_NAME" + +################### +# BLACKFIRE +################### +phpEnvironmentVariable "blackfire.server_id" "BLACKFIRE_SERVER_ID" +phpEnvironmentVariable "blackfire.server_token" "BLACKFIRE_SERVER_TOKEN" diff --git a/docker/php-dev/alpine-php5/conf/provision/roles/webdevops-dev/defaults/main.yml b/docker/php-dev/alpine-php5/conf/provision/roles/webdevops-dev/defaults/main.yml new file mode 100644 index 000000000..4406ea8b4 --- /dev/null +++ b/docker/php-dev/alpine-php5/conf/provision/roles/webdevops-dev/defaults/main.yml @@ -0,0 +1,7 @@ +--- + +APPLICATION_USER: "{{ lookup('env','APPLICATION_USER') }}" +APPLICATION_GROUP: "{{ lookup('env','APPLICATION_GROUP') }}" +APPLICATION_UID: "{{ lookup('env','APPLICATION_UID') }}" +APPLICATION_GID: "{{ lookup('env','APPLICATION_GID') }}" +APPLICATION_PASSWORD: "dev" diff --git a/docker/php-dev/alpine-php5/conf/provision/roles/webdevops-dev/tasks/bootstrap.yml b/docker/php-dev/alpine-php5/conf/provision/roles/webdevops-dev/tasks/bootstrap.yml new file mode 100644 index 000000000..3d7a494ad --- /dev/null +++ b/docker/php-dev/alpine-php5/conf/provision/roles/webdevops-dev/tasks/bootstrap.yml @@ -0,0 +1,17 @@ +--- + +- name: Set application user password + user: + name: "{{ APPLICATION_USER }}" + password: "{{ APPLICATION_PASSWORD | password_hash('sha256') }}" + +- name: Set root password + user: + name: "root" + password: "{{ APPLICATION_PASSWORD | password_hash('sha256') }}" + +- name: Enable ssh root access + lineinfile: + dest: /etc/ssh/sshd_config + regexp: '^PermitRootLogin' + line: 'PermitRootLogin yes' diff --git a/docker/php-dev/alpine-php5/conf/provision/roles/webdevops-dev/tasks/main.yml b/docker/php-dev/alpine-php5/conf/provision/roles/webdevops-dev/tasks/main.yml new file mode 100644 index 000000000..1806c1a8c --- /dev/null +++ b/docker/php-dev/alpine-php5/conf/provision/roles/webdevops-dev/tasks/main.yml @@ -0,0 +1,5 @@ +--- + +- include: bootstrap.yml + tags: + - bootstrap diff --git a/docker/php/debian-7-php7/conf/provision/roles/webdevops-php/defaults/main.yml b/docker/php-dev/alpine-php5/conf/provision/roles/webdevops-php-dev/defaults/main.yml similarity index 100% rename from docker/php/debian-7-php7/conf/provision/roles/webdevops-php/defaults/main.yml rename to docker/php-dev/alpine-php5/conf/provision/roles/webdevops-php-dev/defaults/main.yml diff --git a/docker/php-dev/alpine-php5/conf/provision/roles/webdevops-php-dev/tasks/bootstrap.yml b/docker/php-dev/alpine-php5/conf/provision/roles/webdevops-php-dev/tasks/bootstrap.yml new file mode 100644 index 000000000..ff02b05fc --- /dev/null +++ b/docker/php-dev/alpine-php5/conf/provision/roles/webdevops-php-dev/tasks/bootstrap.yml @@ -0,0 +1,7 @@ +--- + +- include: bootstrap/php-fpm.yml +- include: bootstrap/php-module.yml +- include: bootstrap/php-module.opcache.yml +- include: bootstrap/php-module.xdebug.yml +- include: bootstrap/php-module.blackfire.yml diff --git a/docker/php-dev/alpine-php5/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/php-fpm.yml b/docker/php-dev/alpine-php5/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/php-fpm.yml new file mode 100644 index 000000000..9455a78e2 --- /dev/null +++ b/docker/php-dev/alpine-php5/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/php-fpm.yml @@ -0,0 +1,18 @@ +--- + +- name: Configure php-fpm pool user (application.conf) + lineinfile: + dest: '/opt/docker/etc/php/fpm/pool.d/application.conf' + regexp: '^[\s;]*{{ item.key }}[\s]*=' + line: '{{ item.key }} = {{ item.value }}' + with_items: + - { key: 'access.log', value: "/docker.stdout" } + - { key: "access.format", value: '"%R - %u %t \"%m %r%Q%q\" %s %f cpu:%C%% mem:%{megabytes}M reqTime:%d"' } + +- name: Open php-fpm for external connections (eg. debuggers) + lineinfile: + dest: '/opt/docker/etc/php/fpm/pool.d/application.conf' + regexp: '^[\s;]*{{ item.key }}[\s]*=' + line: '{{ item.key }} = {{ item.value }}' + with_items: + - { key: 'listen', value: "0.0.0.0:9000" } diff --git a/docker/php-dev/alpine-php5/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/php-module.blackfire.yml b/docker/php-dev/alpine-php5/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/php-module.blackfire.yml new file mode 100644 index 000000000..faf05f8de --- /dev/null +++ b/docker/php-dev/alpine-php5/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/php-module.blackfire.yml @@ -0,0 +1,10 @@ +--- + +- name: Remove superfluous blackfire configuration file + file: + path: '{{ item }}' + state: absent + with_items: + - /etc/php5/cli/conf.d/zz-blackfire.ini + - /etc/php5/fpm/conf.d/zz-blackfire.ini + when: ansible_distribution == 'Debian' and docker_image_info_distribution_version|int >= 7 diff --git a/docker/php-dev/alpine-php5/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/php-module.opcache.yml b/docker/php-dev/alpine-php5/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/php-module.opcache.yml new file mode 100644 index 000000000..9c243a671 --- /dev/null +++ b/docker/php-dev/alpine-php5/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/php-module.opcache.yml @@ -0,0 +1,14 @@ +--- + +- name: Setup php.ini for development environment + lineinfile: + dest: '/opt/docker/etc/php/php.webdevops.ini' + regexp: '^[\s;]*{{ item.variable }}[\s]*=' + line: '{{ item.variable }} = {{ item.value }}' + with_items: + - { variable: 'opcache.memory_consumption', value: '256' } + - { variable: 'opcache.validate_timestamps', value: '1' } + - { variable: 'opcache.revalidate_freq', value: '0' } + - { variable: 'opcache.interned_strings_buffer', value: '16' } + - { variable: 'opcache.max_accelerated_files', value: '7963' } + - { variable: 'opcache.fast_shutdown', value: '1' } diff --git a/docker/php-dev/alpine-php5/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/php-module.xdebug.yml b/docker/php-dev/alpine-php5/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/php-module.xdebug.yml new file mode 100644 index 000000000..7f20c845e --- /dev/null +++ b/docker/php-dev/alpine-php5/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/php-module.xdebug.yml @@ -0,0 +1,28 @@ +--- + +# Ignored on php7 +- name: Fix php xdebug module [Alpine family] + lineinfile: + dest: '{{ item }}' + regexp: 'extension=xdebug.so' + line: 'zend_extension=xdebug.so' + when: ansible_distribution == 'Alpine' + with_items: + - /etc/php5/conf.d/xdebug.ini + - /etc/php7/conf.d/xdebug.ini + ignore_errors: yes + +- name: Setup php.ini for development environment + lineinfile: + dest: '/opt/docker/etc/php/php.webdevops.ini' + regexp: '^[\s;]*{{ item.variable }}[\s]*=' + line: '{{ item.variable }} = {{ item.value }}' + with_items: + - { variable: 'xdebug.remote_enable', value: '1' } + - { variable: 'xdebug.remote_connect_back', value: '1' } + - { variable: 'xdebug.idekey', value: 'docker' } + - { variable: 'xdebug.cli_color', value: '1' } + - { variable: 'xdebug.max_nesting_level', value: '1000' } + - { variable: 'xdebug.profiler_enable_trigger', value: '1000' } + - { variable: 'xdebug.profiler_output_dir', value: '/tmp/debug/' } + - { variable: 'xhprof.output_dir', value: '/tmp/debug/' } diff --git a/docker/php-dev/alpine-php5/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/php-module.yml b/docker/php-dev/alpine-php5/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/php-module.yml new file mode 100644 index 000000000..31cccd1ae --- /dev/null +++ b/docker/php-dev/alpine-php5/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/php-module.yml @@ -0,0 +1,41 @@ +--- + +############################# +# Workaround PHP configuration files +# for alpine +############################# + +- name: Get list of PHP5 configuration files + command: "ls /etc/php5/conf.d/ |grep .ini" + register: php5_ini + when: ansible_distribution == 'Alpine' + ignore_errors: yes + +- name: Link configuration files from php5 to php + file: + src: '/etc/php5/conf.d/{{ item }}' + dest: '/etc/php/conf.d/{{ item }}' + state: link + with_items: "{{ php5_ini.stdout_lines }}" + when: ansible_distribution == 'Alpine' and php5_ini is defined + ignore_errors: yes + +############################# +# Workaround PHP module files +# for alpine +############################# + +- name: Get list of PHP5 modules + command: "ls /usr/lib/php5/modules/ |grep .so" + register: php5_modules + when: ansible_distribution == 'Alpine' + ignore_errors: yes + +- name: Link module files from php5 to php + file: + src: '/usr/lib/php5/modules/{{ item }}' + dest: '/usr/lib/php/modules/{{ item }}' + state: link + with_items: "{{ php5_modules.stdout_lines }}" + when: ansible_distribution == 'Alpine' and php5_modules is defined + ignore_errors: yes diff --git a/docker/php-dev/alpine-php5/conf/provision/roles/webdevops-php-dev/tasks/main.yml b/docker/php-dev/alpine-php5/conf/provision/roles/webdevops-php-dev/tasks/main.yml new file mode 100644 index 000000000..1806c1a8c --- /dev/null +++ b/docker/php-dev/alpine-php5/conf/provision/roles/webdevops-php-dev/tasks/main.yml @@ -0,0 +1,5 @@ +--- + +- include: bootstrap.yml + tags: + - bootstrap diff --git a/docker/php-dev/alpine-php7/Dockerfile b/docker/php-dev/alpine-php7/Dockerfile new file mode 100644 index 000000000..6e0f23d62 --- /dev/null +++ b/docker/php-dev/alpine-php7/Dockerfile @@ -0,0 +1,20 @@ +#+++++++++++++++++++++++++++++++++++++++ +# Dockerfile for webdevops/php-dev:alpine-php7 +# -- automatically generated -- +#+++++++++++++++++++++++++++++++++++++++ + +FROM webdevops/php:alpine-php7 + +COPY conf/ /opt/docker/ + +# Install development environment +RUN /usr/local/bin/apk-install \ + # Install tools + graphviz \ + # Install php development stuff + php7-xdebug \ + # Enable php development services + && docker-service-enable syslog ssh postfix \ + && /opt/docker/bin/provision run --tag bootstrap --role webdevops-dev --role webdevops-php-dev \ + && /opt/docker/bin/bootstrap.sh \ + && docker-image-cleanup diff --git a/docker/php-dev/alpine-php7/Dockerfile.jinja2 b/docker/php-dev/alpine-php7/Dockerfile.jinja2 new file mode 100644 index 000000000..8070a0dae --- /dev/null +++ b/docker/php-dev/alpine-php7/Dockerfile.jinja2 @@ -0,0 +1,5 @@ +{{ docker.from("php", "alpine-php7") }} + +{{ docker.copy('conf/', '/opt/docker/') }} + +{{ php7dev.alpine() }} diff --git a/docker/php-dev/alpine-php7/conf/bin/service.d/blackfire-agent.d/10-init.sh b/docker/php-dev/alpine-php7/conf/bin/service.d/blackfire-agent.d/10-init.sh new file mode 100644 index 000000000..fdffa2a0f --- /dev/null +++ b/docker/php-dev/alpine-php7/conf/bin/service.d/blackfire-agent.d/10-init.sh @@ -0,0 +1 @@ +# placeholder diff --git a/docker/php-dev/alpine-php7/conf/bin/service.d/blackfire-agent.sh b/docker/php-dev/alpine-php7/conf/bin/service.d/blackfire-agent.sh new file mode 100644 index 000000000..fbec23cf3 --- /dev/null +++ b/docker/php-dev/alpine-php7/conf/bin/service.d/blackfire-agent.sh @@ -0,0 +1,23 @@ +#!/usr/bin/env bash +set -e + +source /opt/docker/bin/config.sh + +BLACKFIRE_ARGS="" + +includeScriptDir "/opt/docker/bin/service.d/syslog-ng.d/" + +# blackfire.server_id +if [[ -n "${BLACKFIRE_SERVER_ID+x}" ]]; then + BLACKFIRE_ARGS="$BLACKFIRE_ARGS --server-id=\"${BLACKFIRE_SERVER_ID}\"" +fi + +# blackfire.server_token +if [[ -n "${BLACKFIRE_SERVER_TOKEN+x}" ]]; then + BLACKFIRE_ARGS="$BLACKFIRE_ARGS --server-token=\"${BLACKFIRE_SERVER_TOKEN}\"" +fi + +# create directory for unix socket +mkdir -p /var/run/blackfire + +eval exec blackfire-agent $BLACKFIRE_ARGS diff --git a/docker/php-dev/alpine-php7/conf/etc/supervisor.d/blackfire-agent.conf b/docker/php-dev/alpine-php7/conf/etc/supervisor.d/blackfire-agent.conf new file mode 100644 index 000000000..897831ddb --- /dev/null +++ b/docker/php-dev/alpine-php7/conf/etc/supervisor.d/blackfire-agent.conf @@ -0,0 +1,14 @@ +[group:blackfire-agent] +programs=blackfire-agentd +priority=25 + +[program:blackfire-agentd] +command = /opt/docker/bin/service.d/blackfire-agent.sh +process_name=%(program_name)s +startsecs = 0 +autostart = false +autorestart = true +stdout_logfile=/dev/stdout +stdout_logfile_maxbytes=0 +stderr_logfile=/dev/stderr +stderr_logfile_maxbytes=0 diff --git a/docker/php-dev/alpine-php7/conf/provision/entrypoint.d/10-php-debugger.sh b/docker/php-dev/alpine-php7/conf/provision/entrypoint.d/10-php-debugger.sh new file mode 100644 index 000000000..b5985a9ef --- /dev/null +++ b/docker/php-dev/alpine-php7/conf/provision/entrypoint.d/10-php-debugger.sh @@ -0,0 +1,96 @@ +#!/usr/bin/env bash + +################################################# +# Debugger switch +################################################# + +PHP_CONF_PATHS=" +/etc/php5/conf.d +/etc/php7/conf.d +/etc/php.d +/etc/php5/mods-available +/etc/php5/cli/conf.d +/etc/php5/cli/conf.d +/etc/php5/fpm/conf.d +/etc/php5/fpm/conf.d +/etc/php/7.0/mods-available +/etc/php/7.0/cli/conf.d +/etc/php/7.0/fpm/conf.d +/usr/local/etc/php/conf.d/" + +function phpModuleRemove() { + if [ "$#" -ne 1 ]; then + echo "You must specify the name of the PHP module which you want to disable" + exit 1 + fi + + echo " - Removing PHP module ${1}" + for CONF_PATH in $PHP_CONF_PATHS; do + rm -f "${CONF_PATH}"/*"${1}".ini + done +} + + +if [[ -n "${PHP_DEBUGGER+x}" ]]; then + case "$PHP_DEBUGGER" in + xdebug) + echo "PHP-Debugger: Xdebug enabled" + phpModuleRemove "blackfire" + ;; + + blackfire) + echo "PHP-Debugger: Blackfire enabled" + phpModuleRemove "xdebug" + docker-service-enable blackfire-agent + ;; + + none) + echo "PHP-Debugger: none" + phpModuleRemove "blackfire" + phpModuleRemove "xdebug" + ;; + esac + +else + + echo "PHP-Debugger: not specified - default is xdebug" + phpModuleRemove "blackfire" + +fi + +################################################# +# PHP debugger environment variables +################################################# + +function phpEnvironmentVariable() { + PHP_INI_KEY="$1" + PHP_ENV_NAME="$2" + + if [[ -n "${!PHP_ENV_NAME+x}" ]]; then + PHP_ENV_VALUE="${!PHP_ENV_NAME}" + echo "${PHP_INI_KEY}=\"${PHP_ENV_VALUE}\"" >> /opt/docker/etc/php/php.ini + fi +} + +################### +# XDEBUG +################### + +# remote debugger +phpEnvironmentVariable "xdebug.remote_connect_back" "XDEBUG_REMOTE_CONNECT_BACK" +phpEnvironmentVariable "xdebug.remote_autostart" "XDEBUG_REMOTE_AUTOSTART" +phpEnvironmentVariable "xdebug.remote_host" "XDEBUG_REMOTE_HOST" +phpEnvironmentVariable "xdebug.remote_port" "XDEBUG_REMOTE_PORT" + +# profiler +phpEnvironmentVariable "xdebug.profiler_enable" "XDEBUG_PROFILER_ENABLE" +phpEnvironmentVariable "xdebug.profiler_enable_trigger" "XDEBUG_PROFILER_ENABLE_TRIGGER" +phpEnvironmentVariable "xdebug.profiler_enable_trigger_value" "XDEBUG_PROFILER_ENABLE_TRIGGER_VALUE" +phpEnvironmentVariable "xdebug.profiler_output_dir" "XDEBUG_PROFILER_OUTPUT_DIR" +phpEnvironmentVariable "xdebug.profiler_output_name" "XDEBUG_PROFILER_OUTPUT_NAME" + +################### +# BLACKFIRE +################### +phpEnvironmentVariable "blackfire.server_id" "BLACKFIRE_SERVER_ID" +phpEnvironmentVariable "blackfire.server_token" "BLACKFIRE_SERVER_TOKEN" diff --git a/docker/php-dev/alpine-php7/conf/provision/roles/webdevops-dev/defaults/main.yml b/docker/php-dev/alpine-php7/conf/provision/roles/webdevops-dev/defaults/main.yml new file mode 100644 index 000000000..4406ea8b4 --- /dev/null +++ b/docker/php-dev/alpine-php7/conf/provision/roles/webdevops-dev/defaults/main.yml @@ -0,0 +1,7 @@ +--- + +APPLICATION_USER: "{{ lookup('env','APPLICATION_USER') }}" +APPLICATION_GROUP: "{{ lookup('env','APPLICATION_GROUP') }}" +APPLICATION_UID: "{{ lookup('env','APPLICATION_UID') }}" +APPLICATION_GID: "{{ lookup('env','APPLICATION_GID') }}" +APPLICATION_PASSWORD: "dev" diff --git a/docker/php-dev/alpine-php7/conf/provision/roles/webdevops-dev/tasks/bootstrap.yml b/docker/php-dev/alpine-php7/conf/provision/roles/webdevops-dev/tasks/bootstrap.yml new file mode 100644 index 000000000..3d7a494ad --- /dev/null +++ b/docker/php-dev/alpine-php7/conf/provision/roles/webdevops-dev/tasks/bootstrap.yml @@ -0,0 +1,17 @@ +--- + +- name: Set application user password + user: + name: "{{ APPLICATION_USER }}" + password: "{{ APPLICATION_PASSWORD | password_hash('sha256') }}" + +- name: Set root password + user: + name: "root" + password: "{{ APPLICATION_PASSWORD | password_hash('sha256') }}" + +- name: Enable ssh root access + lineinfile: + dest: /etc/ssh/sshd_config + regexp: '^PermitRootLogin' + line: 'PermitRootLogin yes' diff --git a/docker/php-dev/alpine-php7/conf/provision/roles/webdevops-dev/tasks/main.yml b/docker/php-dev/alpine-php7/conf/provision/roles/webdevops-dev/tasks/main.yml new file mode 100644 index 000000000..1806c1a8c --- /dev/null +++ b/docker/php-dev/alpine-php7/conf/provision/roles/webdevops-dev/tasks/main.yml @@ -0,0 +1,5 @@ +--- + +- include: bootstrap.yml + tags: + - bootstrap diff --git a/provisioning/php/php7/provision/roles/webdevops-php/defaults/main.yml b/docker/php-dev/alpine-php7/conf/provision/roles/webdevops-php-dev/defaults/main.yml similarity index 100% rename from provisioning/php/php7/provision/roles/webdevops-php/defaults/main.yml rename to docker/php-dev/alpine-php7/conf/provision/roles/webdevops-php-dev/defaults/main.yml diff --git a/docker/php-dev/alpine-php7/conf/provision/roles/webdevops-php-dev/tasks/bootstrap.yml b/docker/php-dev/alpine-php7/conf/provision/roles/webdevops-php-dev/tasks/bootstrap.yml new file mode 100644 index 000000000..ff02b05fc --- /dev/null +++ b/docker/php-dev/alpine-php7/conf/provision/roles/webdevops-php-dev/tasks/bootstrap.yml @@ -0,0 +1,7 @@ +--- + +- include: bootstrap/php-fpm.yml +- include: bootstrap/php-module.yml +- include: bootstrap/php-module.opcache.yml +- include: bootstrap/php-module.xdebug.yml +- include: bootstrap/php-module.blackfire.yml diff --git a/docker/php-dev/alpine-php7/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/php-fpm.yml b/docker/php-dev/alpine-php7/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/php-fpm.yml new file mode 100644 index 000000000..9455a78e2 --- /dev/null +++ b/docker/php-dev/alpine-php7/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/php-fpm.yml @@ -0,0 +1,18 @@ +--- + +- name: Configure php-fpm pool user (application.conf) + lineinfile: + dest: '/opt/docker/etc/php/fpm/pool.d/application.conf' + regexp: '^[\s;]*{{ item.key }}[\s]*=' + line: '{{ item.key }} = {{ item.value }}' + with_items: + - { key: 'access.log', value: "/docker.stdout" } + - { key: "access.format", value: '"%R - %u %t \"%m %r%Q%q\" %s %f cpu:%C%% mem:%{megabytes}M reqTime:%d"' } + +- name: Open php-fpm for external connections (eg. debuggers) + lineinfile: + dest: '/opt/docker/etc/php/fpm/pool.d/application.conf' + regexp: '^[\s;]*{{ item.key }}[\s]*=' + line: '{{ item.key }} = {{ item.value }}' + with_items: + - { key: 'listen', value: "0.0.0.0:9000" } diff --git a/docker/php-dev/alpine-php7/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/php-module.blackfire.yml b/docker/php-dev/alpine-php7/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/php-module.blackfire.yml new file mode 100644 index 000000000..faf05f8de --- /dev/null +++ b/docker/php-dev/alpine-php7/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/php-module.blackfire.yml @@ -0,0 +1,10 @@ +--- + +- name: Remove superfluous blackfire configuration file + file: + path: '{{ item }}' + state: absent + with_items: + - /etc/php5/cli/conf.d/zz-blackfire.ini + - /etc/php5/fpm/conf.d/zz-blackfire.ini + when: ansible_distribution == 'Debian' and docker_image_info_distribution_version|int >= 7 diff --git a/docker/php-dev/alpine-php7/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/php-module.opcache.yml b/docker/php-dev/alpine-php7/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/php-module.opcache.yml new file mode 100644 index 000000000..9c243a671 --- /dev/null +++ b/docker/php-dev/alpine-php7/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/php-module.opcache.yml @@ -0,0 +1,14 @@ +--- + +- name: Setup php.ini for development environment + lineinfile: + dest: '/opt/docker/etc/php/php.webdevops.ini' + regexp: '^[\s;]*{{ item.variable }}[\s]*=' + line: '{{ item.variable }} = {{ item.value }}' + with_items: + - { variable: 'opcache.memory_consumption', value: '256' } + - { variable: 'opcache.validate_timestamps', value: '1' } + - { variable: 'opcache.revalidate_freq', value: '0' } + - { variable: 'opcache.interned_strings_buffer', value: '16' } + - { variable: 'opcache.max_accelerated_files', value: '7963' } + - { variable: 'opcache.fast_shutdown', value: '1' } diff --git a/docker/php-dev/alpine-php7/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/php-module.xdebug.yml b/docker/php-dev/alpine-php7/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/php-module.xdebug.yml new file mode 100644 index 000000000..7f20c845e --- /dev/null +++ b/docker/php-dev/alpine-php7/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/php-module.xdebug.yml @@ -0,0 +1,28 @@ +--- + +# Ignored on php7 +- name: Fix php xdebug module [Alpine family] + lineinfile: + dest: '{{ item }}' + regexp: 'extension=xdebug.so' + line: 'zend_extension=xdebug.so' + when: ansible_distribution == 'Alpine' + with_items: + - /etc/php5/conf.d/xdebug.ini + - /etc/php7/conf.d/xdebug.ini + ignore_errors: yes + +- name: Setup php.ini for development environment + lineinfile: + dest: '/opt/docker/etc/php/php.webdevops.ini' + regexp: '^[\s;]*{{ item.variable }}[\s]*=' + line: '{{ item.variable }} = {{ item.value }}' + with_items: + - { variable: 'xdebug.remote_enable', value: '1' } + - { variable: 'xdebug.remote_connect_back', value: '1' } + - { variable: 'xdebug.idekey', value: 'docker' } + - { variable: 'xdebug.cli_color', value: '1' } + - { variable: 'xdebug.max_nesting_level', value: '1000' } + - { variable: 'xdebug.profiler_enable_trigger', value: '1000' } + - { variable: 'xdebug.profiler_output_dir', value: '/tmp/debug/' } + - { variable: 'xhprof.output_dir', value: '/tmp/debug/' } diff --git a/docker/php-dev/alpine-php7/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/php-module.yml b/docker/php-dev/alpine-php7/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/php-module.yml new file mode 100644 index 000000000..31cccd1ae --- /dev/null +++ b/docker/php-dev/alpine-php7/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/php-module.yml @@ -0,0 +1,41 @@ +--- + +############################# +# Workaround PHP configuration files +# for alpine +############################# + +- name: Get list of PHP5 configuration files + command: "ls /etc/php5/conf.d/ |grep .ini" + register: php5_ini + when: ansible_distribution == 'Alpine' + ignore_errors: yes + +- name: Link configuration files from php5 to php + file: + src: '/etc/php5/conf.d/{{ item }}' + dest: '/etc/php/conf.d/{{ item }}' + state: link + with_items: "{{ php5_ini.stdout_lines }}" + when: ansible_distribution == 'Alpine' and php5_ini is defined + ignore_errors: yes + +############################# +# Workaround PHP module files +# for alpine +############################# + +- name: Get list of PHP5 modules + command: "ls /usr/lib/php5/modules/ |grep .so" + register: php5_modules + when: ansible_distribution == 'Alpine' + ignore_errors: yes + +- name: Link module files from php5 to php + file: + src: '/usr/lib/php5/modules/{{ item }}' + dest: '/usr/lib/php/modules/{{ item }}' + state: link + with_items: "{{ php5_modules.stdout_lines }}" + when: ansible_distribution == 'Alpine' and php5_modules is defined + ignore_errors: yes diff --git a/docker/php-dev/alpine-php7/conf/provision/roles/webdevops-php-dev/tasks/main.yml b/docker/php-dev/alpine-php7/conf/provision/roles/webdevops-php-dev/tasks/main.yml new file mode 100644 index 000000000..1806c1a8c --- /dev/null +++ b/docker/php-dev/alpine-php7/conf/provision/roles/webdevops-php-dev/tasks/main.yml @@ -0,0 +1,5 @@ +--- + +- include: bootstrap.yml + tags: + - bootstrap diff --git a/docker/php-dev/centos-7-php56/Dockerfile b/docker/php-dev/centos-7-php56/Dockerfile index 91d83c541..674beddbf 100644 --- a/docker/php-dev/centos-7-php56/Dockerfile +++ b/docker/php-dev/centos-7-php56/Dockerfile @@ -5,11 +5,6 @@ FROM webdevops/php:centos-7-php56 -MAINTAINER info@webdevops.io -LABEL vendor=WebDevOps.io -LABEL io.webdevops.layout=8 -LABEL io.webdevops.version=1.5.0 - COPY conf/ /opt/docker/ RUN wget -O - "https://packages.blackfire.io/fedora/blackfire.repo" | tee /etc/yum.repos.d/blackfire.repo \ @@ -20,6 +15,11 @@ RUN wget -O - "https://packages.blackfire.io/fedora/blackfire.repo" | tee /etc/y php56w-pecl-xdebug \ blackfire-php \ blackfire-agent \ + # Tools + nano \ + vim \ + # Enable php development services + && docker-service-enable syslog ssh postfix \ && /opt/docker/bin/provision run --tag bootstrap --role webdevops-dev --role webdevops-php-dev \ - && /opt/docker/bin/bootstrap.sh - + && /opt/docker/bin/bootstrap.sh \ + && docker-image-cleanup diff --git a/docker/php-dev/centos-7-php56/Dockerfile.jinja2 b/docker/php-dev/centos-7-php56/Dockerfile.jinja2 index ec60cec8b..684aad399 100644 --- a/docker/php-dev/centos-7-php56/Dockerfile.jinja2 +++ b/docker/php-dev/centos-7-php56/Dockerfile.jinja2 @@ -1,7 +1,5 @@ {{ docker.from("php", "centos-7-php56") }} -{{ docker.version() }} - {{ docker.copy('conf/', '/opt/docker/') }} {{ php5dev.webtatic() }} diff --git a/docker/php-dev/centos-7-php56/conf/provision/entrypoint.d/10-php-debugger.sh b/docker/php-dev/centos-7-php56/conf/provision/entrypoint.d/10-php-debugger.sh index 7156e28aa..b5985a9ef 100644 --- a/docker/php-dev/centos-7-php56/conf/provision/entrypoint.d/10-php-debugger.sh +++ b/docker/php-dev/centos-7-php56/conf/provision/entrypoint.d/10-php-debugger.sh @@ -15,7 +15,8 @@ PHP_CONF_PATHS=" /etc/php5/fpm/conf.d /etc/php/7.0/mods-available /etc/php/7.0/cli/conf.d -/etc/php/7.0/fpm/conf.d" +/etc/php/7.0/fpm/conf.d +/usr/local/etc/php/conf.d/" function phpModuleRemove() { if [ "$#" -ne 1 ]; then @@ -40,7 +41,7 @@ if [[ -n "${PHP_DEBUGGER+x}" ]]; then blackfire) echo "PHP-Debugger: Blackfire enabled" phpModuleRemove "xdebug" - /opt/docker/bin/control.sh service.enable blackfire-agent + docker-service-enable blackfire-agent ;; none) diff --git a/docker/php-dev/centos-7-php56/conf/provision/roles/webdevops-dev/tasks/bootstrap.yml b/docker/php-dev/centos-7-php56/conf/provision/roles/webdevops-dev/tasks/bootstrap.yml index 5c9eafbd0..3d7a494ad 100644 --- a/docker/php-dev/centos-7-php56/conf/provision/roles/webdevops-dev/tasks/bootstrap.yml +++ b/docker/php-dev/centos-7-php56/conf/provision/roles/webdevops-dev/tasks/bootstrap.yml @@ -1,8 +1,5 @@ --- -- name: Enable ssh daemon - shell: "/opt/docker/bin/control.sh service.enable ssh" - - name: Set application user password user: name: "{{ APPLICATION_USER }}" diff --git a/docker/php-dev/centos-7-php56/conf/provision/roles/webdevops-php-dev/tasks/bootstrap.yml b/docker/php-dev/centos-7-php56/conf/provision/roles/webdevops-php-dev/tasks/bootstrap.yml index 2c5d76e3d..ff02b05fc 100644 --- a/docker/php-dev/centos-7-php56/conf/provision/roles/webdevops-php-dev/tasks/bootstrap.yml +++ b/docker/php-dev/centos-7-php56/conf/provision/roles/webdevops-php-dev/tasks/bootstrap.yml @@ -1,6 +1,5 @@ --- -- include: bootstrap/tools.yml - include: bootstrap/php-fpm.yml - include: bootstrap/php-module.yml - include: bootstrap/php-module.opcache.yml diff --git a/docker/php-dev/centos-7-php56/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/php-module.blackfire.yml b/docker/php-dev/centos-7-php56/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/php-module.blackfire.yml index 1a3db9bac..faf05f8de 100644 --- a/docker/php-dev/centos-7-php56/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/php-module.blackfire.yml +++ b/docker/php-dev/centos-7-php56/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/php-module.blackfire.yml @@ -7,4 +7,4 @@ with_items: - /etc/php5/cli/conf.d/zz-blackfire.ini - /etc/php5/fpm/conf.d/zz-blackfire.ini - when: ansible_distribution == 'Debian' and ansible_lsb.major_release|int >= 7 + when: ansible_distribution == 'Debian' and docker_image_info_distribution_version|int >= 7 diff --git a/docker/php-dev/centos-7-php56/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/tools.yml b/docker/php-dev/centos-7-php56/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/tools.yml deleted file mode 100644 index c49cb0e34..000000000 --- a/docker/php-dev/centos-7-php56/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/tools.yml +++ /dev/null @@ -1,23 +0,0 @@ ---- - -- name: Downloading Tools - shell: curl -o "{{ item.dest }}" "{{ item.url }}" && chmod 755 "{{ item.dest }}" - with_items: - - { url: "https://phar.phpunit.de/phploc.phar", dest: /usr/local/bin/phploc } - - { url: "https://phar.phpunit.de/phpunit.phar", dest: /usr/local/bin/phpunit } - - { url: "http://static.pdepend.org/php/latest/pdepend.phar", dest: /usr/local/bin/pdepend } - - { url: "http://static.phpmd.org/php/latest/phpmd.phar", dest: /usr/local/bin/phpmd } - - { url: "https://squizlabs.github.io/PHP_CodeSniffer/phpcs.phar", dest: /usr/local/bin/phpcs } - - { url: "https://squizlabs.github.io/PHP_CodeSniffer/phpcbf.phar", dest: /usr/local/bin/phpcbf } - - { url: "https://phar.phpunit.de/phpcpd.phar", dest: /usr/local/bin/phpcpd } - - { url: "https://phar.phpunit.de/phpdcd.phar", dest: /usr/local/bin/phpdcd } - - { url: "https://github.com/Halleck45/PhpMetrics/raw/master/build/phpmetrics.phar", dest: /usr/local/bin/phpmetrics } - - { url: "http://get.sensiolabs.org/php-cs-fixer.phar", dest: /usr/local/bin/php-cs-fixer } - - { url: "https://github.com/sensiolabs-de/deprecation-detector/releases/download/0.1.0-alpha4/deprecation-detector.phar", dest: /usr/local/bin/deprecation-detector } - - { url: "https://github.com/sensiolabs-de/deprecation-detector/releases/download/0.1.0-alpha4/deprecation-detector.phar", dest: /usr/local/bin/deprecation-detector } - -- name: Install Tools via composer - raw: COMPOSER_HOME="/usr/local/composer" COMPOSER_BIN_DIR="/usr/local/bin" composer global require "{{ item.package }}" "{{ item.version }}" - with_items: - - { package: "sstalle/php7cc" , version: "*" } - - { package: "phpspec/phpspec" , version: "~2.0" } diff --git a/docker/php-dev/centos-7-php7/Dockerfile b/docker/php-dev/centos-7-php7/Dockerfile index ea12d38d4..a1f40a005 100644 --- a/docker/php-dev/centos-7-php7/Dockerfile +++ b/docker/php-dev/centos-7-php7/Dockerfile @@ -5,11 +5,6 @@ FROM webdevops/php:centos-7-php7 -MAINTAINER info@webdevops.io -LABEL vendor=WebDevOps.io -LABEL io.webdevops.layout=8 -LABEL io.webdevops.version=1.5.0 - COPY conf/ /opt/docker/ RUN wget -O - "https://packages.blackfire.io/fedora/blackfire.repo" | tee /etc/yum.repos.d/blackfire.repo \ @@ -20,6 +15,8 @@ RUN wget -O - "https://packages.blackfire.io/fedora/blackfire.repo" | tee /etc/y php70w-pecl-xdebug \ blackfire-php \ blackfire-agent \ + # Enable php development services + && docker-service-enable syslog ssh postfix \ && /opt/docker/bin/provision run --tag bootstrap --role webdevops-dev --role webdevops-php-dev \ - && /opt/docker/bin/bootstrap.sh - + && /opt/docker/bin/bootstrap.sh \ + && docker-image-cleanup diff --git a/docker/php-dev/centos-7-php7/Dockerfile.jinja2 b/docker/php-dev/centos-7-php7/Dockerfile.jinja2 index cfb5ffb19..7d6d0ea32 100644 --- a/docker/php-dev/centos-7-php7/Dockerfile.jinja2 +++ b/docker/php-dev/centos-7-php7/Dockerfile.jinja2 @@ -1,7 +1,5 @@ {{ docker.from("php", "centos-7-php7") }} -{{ docker.version() }} - {{ docker.copy('conf/', '/opt/docker/') }} {{ php7dev.webtatic() }} diff --git a/docker/php-dev/centos-7-php7/conf/provision/entrypoint.d/10-php-debugger.sh b/docker/php-dev/centos-7-php7/conf/provision/entrypoint.d/10-php-debugger.sh index 7156e28aa..b5985a9ef 100644 --- a/docker/php-dev/centos-7-php7/conf/provision/entrypoint.d/10-php-debugger.sh +++ b/docker/php-dev/centos-7-php7/conf/provision/entrypoint.d/10-php-debugger.sh @@ -15,7 +15,8 @@ PHP_CONF_PATHS=" /etc/php5/fpm/conf.d /etc/php/7.0/mods-available /etc/php/7.0/cli/conf.d -/etc/php/7.0/fpm/conf.d" +/etc/php/7.0/fpm/conf.d +/usr/local/etc/php/conf.d/" function phpModuleRemove() { if [ "$#" -ne 1 ]; then @@ -40,7 +41,7 @@ if [[ -n "${PHP_DEBUGGER+x}" ]]; then blackfire) echo "PHP-Debugger: Blackfire enabled" phpModuleRemove "xdebug" - /opt/docker/bin/control.sh service.enable blackfire-agent + docker-service-enable blackfire-agent ;; none) diff --git a/docker/php-dev/centos-7-php7/conf/provision/roles/webdevops-dev/tasks/bootstrap.yml b/docker/php-dev/centos-7-php7/conf/provision/roles/webdevops-dev/tasks/bootstrap.yml index 5c9eafbd0..3d7a494ad 100644 --- a/docker/php-dev/centos-7-php7/conf/provision/roles/webdevops-dev/tasks/bootstrap.yml +++ b/docker/php-dev/centos-7-php7/conf/provision/roles/webdevops-dev/tasks/bootstrap.yml @@ -1,8 +1,5 @@ --- -- name: Enable ssh daemon - shell: "/opt/docker/bin/control.sh service.enable ssh" - - name: Set application user password user: name: "{{ APPLICATION_USER }}" diff --git a/docker/php-dev/centos-7-php7/conf/provision/roles/webdevops-php-dev/tasks/bootstrap.yml b/docker/php-dev/centos-7-php7/conf/provision/roles/webdevops-php-dev/tasks/bootstrap.yml index 2c5d76e3d..ff02b05fc 100644 --- a/docker/php-dev/centos-7-php7/conf/provision/roles/webdevops-php-dev/tasks/bootstrap.yml +++ b/docker/php-dev/centos-7-php7/conf/provision/roles/webdevops-php-dev/tasks/bootstrap.yml @@ -1,6 +1,5 @@ --- -- include: bootstrap/tools.yml - include: bootstrap/php-fpm.yml - include: bootstrap/php-module.yml - include: bootstrap/php-module.opcache.yml diff --git a/docker/php-dev/centos-7-php7/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/php-module.blackfire.yml b/docker/php-dev/centos-7-php7/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/php-module.blackfire.yml index 1a3db9bac..faf05f8de 100644 --- a/docker/php-dev/centos-7-php7/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/php-module.blackfire.yml +++ b/docker/php-dev/centos-7-php7/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/php-module.blackfire.yml @@ -7,4 +7,4 @@ with_items: - /etc/php5/cli/conf.d/zz-blackfire.ini - /etc/php5/fpm/conf.d/zz-blackfire.ini - when: ansible_distribution == 'Debian' and ansible_lsb.major_release|int >= 7 + when: ansible_distribution == 'Debian' and docker_image_info_distribution_version|int >= 7 diff --git a/docker/php-dev/centos-7-php7/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/tools.yml b/docker/php-dev/centos-7-php7/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/tools.yml deleted file mode 100644 index c49cb0e34..000000000 --- a/docker/php-dev/centos-7-php7/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/tools.yml +++ /dev/null @@ -1,23 +0,0 @@ ---- - -- name: Downloading Tools - shell: curl -o "{{ item.dest }}" "{{ item.url }}" && chmod 755 "{{ item.dest }}" - with_items: - - { url: "https://phar.phpunit.de/phploc.phar", dest: /usr/local/bin/phploc } - - { url: "https://phar.phpunit.de/phpunit.phar", dest: /usr/local/bin/phpunit } - - { url: "http://static.pdepend.org/php/latest/pdepend.phar", dest: /usr/local/bin/pdepend } - - { url: "http://static.phpmd.org/php/latest/phpmd.phar", dest: /usr/local/bin/phpmd } - - { url: "https://squizlabs.github.io/PHP_CodeSniffer/phpcs.phar", dest: /usr/local/bin/phpcs } - - { url: "https://squizlabs.github.io/PHP_CodeSniffer/phpcbf.phar", dest: /usr/local/bin/phpcbf } - - { url: "https://phar.phpunit.de/phpcpd.phar", dest: /usr/local/bin/phpcpd } - - { url: "https://phar.phpunit.de/phpdcd.phar", dest: /usr/local/bin/phpdcd } - - { url: "https://github.com/Halleck45/PhpMetrics/raw/master/build/phpmetrics.phar", dest: /usr/local/bin/phpmetrics } - - { url: "http://get.sensiolabs.org/php-cs-fixer.phar", dest: /usr/local/bin/php-cs-fixer } - - { url: "https://github.com/sensiolabs-de/deprecation-detector/releases/download/0.1.0-alpha4/deprecation-detector.phar", dest: /usr/local/bin/deprecation-detector } - - { url: "https://github.com/sensiolabs-de/deprecation-detector/releases/download/0.1.0-alpha4/deprecation-detector.phar", dest: /usr/local/bin/deprecation-detector } - -- name: Install Tools via composer - raw: COMPOSER_HOME="/usr/local/composer" COMPOSER_BIN_DIR="/usr/local/bin" composer global require "{{ item.package }}" "{{ item.version }}" - with_items: - - { package: "sstalle/php7cc" , version: "*" } - - { package: "phpspec/phpspec" , version: "~2.0" } diff --git a/docker/php-dev/centos-7/Dockerfile b/docker/php-dev/centos-7/Dockerfile index 6d9787d0e..524665a41 100644 --- a/docker/php-dev/centos-7/Dockerfile +++ b/docker/php-dev/centos-7/Dockerfile @@ -5,11 +5,6 @@ FROM webdevops/php:centos-7 -MAINTAINER info@webdevops.io -LABEL vendor=WebDevOps.io -LABEL io.webdevops.layout=8 -LABEL io.webdevops.version=1.5.0 - COPY conf/ /opt/docker/ # Install development environment @@ -21,6 +16,11 @@ RUN wget -O - "https://packages.blackfire.io/fedora/blackfire.repo" | tee /etc/y php-pecl-xdebug \ blackfire-php \ blackfire-agent \ + # Tools + nano \ + vim \ + # Enable php development services + && docker-service-enable syslog ssh postfix \ && /opt/docker/bin/provision run --tag bootstrap --role webdevops-dev --role webdevops-php-dev \ - && /opt/docker/bin/bootstrap.sh - + && /opt/docker/bin/bootstrap.sh \ + && docker-image-cleanup diff --git a/docker/php-dev/centos-7/Dockerfile.jinja2 b/docker/php-dev/centos-7/Dockerfile.jinja2 index fafe25a99..b3826dc4e 100644 --- a/docker/php-dev/centos-7/Dockerfile.jinja2 +++ b/docker/php-dev/centos-7/Dockerfile.jinja2 @@ -1,7 +1,5 @@ {{ docker.from("php", "centos-7") }} -{{ docker.version() }} - {{ docker.copy('conf/', '/opt/docker/') }} {{ php5dev.centos() }} diff --git a/docker/php-dev/centos-7/conf/provision/entrypoint.d/10-php-debugger.sh b/docker/php-dev/centos-7/conf/provision/entrypoint.d/10-php-debugger.sh index 7156e28aa..b5985a9ef 100644 --- a/docker/php-dev/centos-7/conf/provision/entrypoint.d/10-php-debugger.sh +++ b/docker/php-dev/centos-7/conf/provision/entrypoint.d/10-php-debugger.sh @@ -15,7 +15,8 @@ PHP_CONF_PATHS=" /etc/php5/fpm/conf.d /etc/php/7.0/mods-available /etc/php/7.0/cli/conf.d -/etc/php/7.0/fpm/conf.d" +/etc/php/7.0/fpm/conf.d +/usr/local/etc/php/conf.d/" function phpModuleRemove() { if [ "$#" -ne 1 ]; then @@ -40,7 +41,7 @@ if [[ -n "${PHP_DEBUGGER+x}" ]]; then blackfire) echo "PHP-Debugger: Blackfire enabled" phpModuleRemove "xdebug" - /opt/docker/bin/control.sh service.enable blackfire-agent + docker-service-enable blackfire-agent ;; none) diff --git a/docker/php-dev/centos-7/conf/provision/roles/webdevops-dev/tasks/bootstrap.yml b/docker/php-dev/centos-7/conf/provision/roles/webdevops-dev/tasks/bootstrap.yml index 5c9eafbd0..3d7a494ad 100644 --- a/docker/php-dev/centos-7/conf/provision/roles/webdevops-dev/tasks/bootstrap.yml +++ b/docker/php-dev/centos-7/conf/provision/roles/webdevops-dev/tasks/bootstrap.yml @@ -1,8 +1,5 @@ --- -- name: Enable ssh daemon - shell: "/opt/docker/bin/control.sh service.enable ssh" - - name: Set application user password user: name: "{{ APPLICATION_USER }}" diff --git a/docker/php-dev/centos-7/conf/provision/roles/webdevops-php-dev/tasks/bootstrap.yml b/docker/php-dev/centos-7/conf/provision/roles/webdevops-php-dev/tasks/bootstrap.yml index 2c5d76e3d..ff02b05fc 100644 --- a/docker/php-dev/centos-7/conf/provision/roles/webdevops-php-dev/tasks/bootstrap.yml +++ b/docker/php-dev/centos-7/conf/provision/roles/webdevops-php-dev/tasks/bootstrap.yml @@ -1,6 +1,5 @@ --- -- include: bootstrap/tools.yml - include: bootstrap/php-fpm.yml - include: bootstrap/php-module.yml - include: bootstrap/php-module.opcache.yml diff --git a/docker/php-dev/centos-7/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/php-module.blackfire.yml b/docker/php-dev/centos-7/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/php-module.blackfire.yml index 1a3db9bac..faf05f8de 100644 --- a/docker/php-dev/centos-7/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/php-module.blackfire.yml +++ b/docker/php-dev/centos-7/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/php-module.blackfire.yml @@ -7,4 +7,4 @@ with_items: - /etc/php5/cli/conf.d/zz-blackfire.ini - /etc/php5/fpm/conf.d/zz-blackfire.ini - when: ansible_distribution == 'Debian' and ansible_lsb.major_release|int >= 7 + when: ansible_distribution == 'Debian' and docker_image_info_distribution_version|int >= 7 diff --git a/docker/php-dev/centos-7/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/tools.yml b/docker/php-dev/centos-7/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/tools.yml deleted file mode 100644 index c49cb0e34..000000000 --- a/docker/php-dev/centos-7/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/tools.yml +++ /dev/null @@ -1,23 +0,0 @@ ---- - -- name: Downloading Tools - shell: curl -o "{{ item.dest }}" "{{ item.url }}" && chmod 755 "{{ item.dest }}" - with_items: - - { url: "https://phar.phpunit.de/phploc.phar", dest: /usr/local/bin/phploc } - - { url: "https://phar.phpunit.de/phpunit.phar", dest: /usr/local/bin/phpunit } - - { url: "http://static.pdepend.org/php/latest/pdepend.phar", dest: /usr/local/bin/pdepend } - - { url: "http://static.phpmd.org/php/latest/phpmd.phar", dest: /usr/local/bin/phpmd } - - { url: "https://squizlabs.github.io/PHP_CodeSniffer/phpcs.phar", dest: /usr/local/bin/phpcs } - - { url: "https://squizlabs.github.io/PHP_CodeSniffer/phpcbf.phar", dest: /usr/local/bin/phpcbf } - - { url: "https://phar.phpunit.de/phpcpd.phar", dest: /usr/local/bin/phpcpd } - - { url: "https://phar.phpunit.de/phpdcd.phar", dest: /usr/local/bin/phpdcd } - - { url: "https://github.com/Halleck45/PhpMetrics/raw/master/build/phpmetrics.phar", dest: /usr/local/bin/phpmetrics } - - { url: "http://get.sensiolabs.org/php-cs-fixer.phar", dest: /usr/local/bin/php-cs-fixer } - - { url: "https://github.com/sensiolabs-de/deprecation-detector/releases/download/0.1.0-alpha4/deprecation-detector.phar", dest: /usr/local/bin/deprecation-detector } - - { url: "https://github.com/sensiolabs-de/deprecation-detector/releases/download/0.1.0-alpha4/deprecation-detector.phar", dest: /usr/local/bin/deprecation-detector } - -- name: Install Tools via composer - raw: COMPOSER_HOME="/usr/local/composer" COMPOSER_BIN_DIR="/usr/local/bin" composer global require "{{ item.package }}" "{{ item.version }}" - with_items: - - { package: "sstalle/php7cc" , version: "*" } - - { package: "phpspec/phpspec" , version: "~2.0" } diff --git a/docker/php-dev/debian-7-php7/Dockerfile.disabled b/docker/php-dev/debian-7-php7/Dockerfile.disabled deleted file mode 100644 index c4ba1392e..000000000 --- a/docker/php-dev/debian-7-php7/Dockerfile.disabled +++ /dev/null @@ -1,26 +0,0 @@ -#++++++++++++++++++++++++++++++++++++++ -# Debian 7 PHP Docker container -#++++++++++++++++++++++++++++++++++++++ - -FROM webdevops/base:debian-7 -MAINTAINER info@webdevops.io - -ENV WEB_DOCUMENT_ROOT /app - -# Install dotdeb -RUN echo "deb http://packages.dotdeb.org wheezy all" >> /etc/apt/sources.list \ - && echo "deb-src http://packages.dotdeb.org wheezy all" >> /etc/apt/sources.list \ - && wget wget -O- https://www.dotdeb.org/dotdeb.gpg | apt-key add - - -# Install tools -RUN /usr/local/bin/apt-install \ - imagemagick \ - graphviz - -COPY conf/ /opt/docker/ -RUN bash /opt/docker/bin/control.sh provision.role.bootstrap webdevops-php-dev \ - && bash /opt/docker/bin/bootstrap.sh - -EXPOSE 9000 - -CMD ["supervisord"] diff --git a/docker/php-dev/debian-7-php7/Dockerfile.jinja2.disabled b/docker/php-dev/debian-7-php7/Dockerfile.jinja2.disabled deleted file mode 100644 index 95f9f7b47..000000000 --- a/docker/php-dev/debian-7-php7/Dockerfile.jinja2.disabled +++ /dev/null @@ -1,7 +0,0 @@ -{{ docker.from("php", "debian-7-php7") }} - -{{ docker.version() }} - -{{ docker.copy('conf/', '/opt/docker/') }} - -{{ php7dev.debian() }} diff --git a/docker/php-dev/debian-7-php7/conf/provision/roles/webdevops-php-dev/tasks/bootstrap.yml b/docker/php-dev/debian-7-php7/conf/provision/roles/webdevops-php-dev/tasks/bootstrap.yml deleted file mode 100644 index 9d1d85a8c..000000000 --- a/docker/php-dev/debian-7-php7/conf/provision/roles/webdevops-php-dev/tasks/bootstrap.yml +++ /dev/null @@ -1,23 +0,0 @@ ---- - -- name: Downloading Tools - get_url: url={{ item.url }} dest={{ item.dest }} mode=0755 - with_items: - - { url: "https://phar.phpunit.de/phploc.phar", dest: /usr/local/bin/phploc } - - { url: "https://phar.phpunit.de/phpunit.phar", dest: /usr/local/bin/phpunit } - - { url: "http://static.pdepend.org/php/latest/pdepend.phar", dest: /usr/local/bin/pdepend } - - { url: "http://static.phpmd.org/php/latest/phpmd.phar", dest: /usr/local/bin/phpmd } - - { url: "https://squizlabs.github.io/PHP_CodeSniffer/phpcs.phar", dest: /usr/local/bin/phpcs } - - { url: "https://squizlabs.github.io/PHP_CodeSniffer/phpcbf.phar", dest: /usr/local/bin/phpcbf } - - { url: "https://phar.phpunit.de/phpcpd.phar", dest: /usr/local/bin/phpcpd } - - { url: "https://phar.phpunit.de/phpdcd.phar", dest: /usr/local/bin/phpdcd } - - { url: "https://github.com/Halleck45/PhpMetrics/raw/master/build/phpmetrics.phar", dest: /usr/local/bin/phpmetrics } - - { url: "http://get.sensiolabs.org/php-cs-fixer.phar", dest: /usr/local/bin/php-cs-fixer } - - { url: "https://github.com/sensiolabs-de/deprecation-detector/releases/download/0.1.0-alpha4/deprecation-detector.phar", dest: /usr/local/bin/deprecation-detector } - - { url: "https://github.com/sensiolabs-de/deprecation-detector/releases/download/0.1.0-alpha4/deprecation-detector.phar", dest: /usr/local/bin/deprecation-detector } - -- name: Install Tools via composer - raw: COMPOSER_HOME="/usr/local/composer" COMPOSER_BIN_DIR="/usr/local/bin" composer global require "{{ item.package }}" "{{ item.version }}" - with_items: - - { package: "sstalle/php7cc" , version: "*" } - - { package: "phpspec/phpspec" , version: "~2.0" } \ No newline at end of file diff --git a/docker/php-dev/debian-7/Dockerfile b/docker/php-dev/debian-7/Dockerfile index 51661fbcc..e463811db 100644 --- a/docker/php-dev/debian-7/Dockerfile +++ b/docker/php-dev/debian-7/Dockerfile @@ -5,11 +5,6 @@ FROM webdevops/php:debian-7 -MAINTAINER info@webdevops.io -LABEL vendor=WebDevOps.io -LABEL io.webdevops.layout=8 -LABEL io.webdevops.version=1.5.0 - COPY conf/ /opt/docker/ # Install development environment @@ -22,6 +17,11 @@ RUN wget -O - https://packagecloud.io/gpg.key | apt-key add - \ php5-xdebug \ blackfire-php \ blackfire-agent \ + # Tools + nano \ + vim \ + # Enable php development services + && docker-service-enable syslog ssh postfix \ && /opt/docker/bin/provision run --tag bootstrap --role webdevops-dev --role webdevops-php-dev \ - && /opt/docker/bin/bootstrap.sh - + && /opt/docker/bin/bootstrap.sh \ + && docker-image-cleanup diff --git a/docker/php-dev/debian-7/Dockerfile.jinja2 b/docker/php-dev/debian-7/Dockerfile.jinja2 index 6f94cf373..ff010faa3 100644 --- a/docker/php-dev/debian-7/Dockerfile.jinja2 +++ b/docker/php-dev/debian-7/Dockerfile.jinja2 @@ -1,7 +1,5 @@ {{ docker.from("php", "debian-7") }} -{{ docker.version() }} - {{ docker.copy('conf/', '/opt/docker/') }} {{ php5dev.debian() }} diff --git a/docker/php-dev/debian-7/conf/provision/entrypoint.d/10-php-debugger.sh b/docker/php-dev/debian-7/conf/provision/entrypoint.d/10-php-debugger.sh index 7156e28aa..b5985a9ef 100644 --- a/docker/php-dev/debian-7/conf/provision/entrypoint.d/10-php-debugger.sh +++ b/docker/php-dev/debian-7/conf/provision/entrypoint.d/10-php-debugger.sh @@ -15,7 +15,8 @@ PHP_CONF_PATHS=" /etc/php5/fpm/conf.d /etc/php/7.0/mods-available /etc/php/7.0/cli/conf.d -/etc/php/7.0/fpm/conf.d" +/etc/php/7.0/fpm/conf.d +/usr/local/etc/php/conf.d/" function phpModuleRemove() { if [ "$#" -ne 1 ]; then @@ -40,7 +41,7 @@ if [[ -n "${PHP_DEBUGGER+x}" ]]; then blackfire) echo "PHP-Debugger: Blackfire enabled" phpModuleRemove "xdebug" - /opt/docker/bin/control.sh service.enable blackfire-agent + docker-service-enable blackfire-agent ;; none) diff --git a/docker/php-dev/debian-7/conf/provision/roles/webdevops-dev/tasks/bootstrap.yml b/docker/php-dev/debian-7/conf/provision/roles/webdevops-dev/tasks/bootstrap.yml index 5c9eafbd0..3d7a494ad 100644 --- a/docker/php-dev/debian-7/conf/provision/roles/webdevops-dev/tasks/bootstrap.yml +++ b/docker/php-dev/debian-7/conf/provision/roles/webdevops-dev/tasks/bootstrap.yml @@ -1,8 +1,5 @@ --- -- name: Enable ssh daemon - shell: "/opt/docker/bin/control.sh service.enable ssh" - - name: Set application user password user: name: "{{ APPLICATION_USER }}" diff --git a/docker/php-dev/debian-7/conf/provision/roles/webdevops-php-dev/tasks/bootstrap.yml b/docker/php-dev/debian-7/conf/provision/roles/webdevops-php-dev/tasks/bootstrap.yml index 2c5d76e3d..ff02b05fc 100644 --- a/docker/php-dev/debian-7/conf/provision/roles/webdevops-php-dev/tasks/bootstrap.yml +++ b/docker/php-dev/debian-7/conf/provision/roles/webdevops-php-dev/tasks/bootstrap.yml @@ -1,6 +1,5 @@ --- -- include: bootstrap/tools.yml - include: bootstrap/php-fpm.yml - include: bootstrap/php-module.yml - include: bootstrap/php-module.opcache.yml diff --git a/docker/php-dev/debian-7/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/php-module.blackfire.yml b/docker/php-dev/debian-7/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/php-module.blackfire.yml index 1a3db9bac..faf05f8de 100644 --- a/docker/php-dev/debian-7/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/php-module.blackfire.yml +++ b/docker/php-dev/debian-7/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/php-module.blackfire.yml @@ -7,4 +7,4 @@ with_items: - /etc/php5/cli/conf.d/zz-blackfire.ini - /etc/php5/fpm/conf.d/zz-blackfire.ini - when: ansible_distribution == 'Debian' and ansible_lsb.major_release|int >= 7 + when: ansible_distribution == 'Debian' and docker_image_info_distribution_version|int >= 7 diff --git a/docker/php-dev/debian-7/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/tools.yml b/docker/php-dev/debian-7/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/tools.yml deleted file mode 100644 index c49cb0e34..000000000 --- a/docker/php-dev/debian-7/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/tools.yml +++ /dev/null @@ -1,23 +0,0 @@ ---- - -- name: Downloading Tools - shell: curl -o "{{ item.dest }}" "{{ item.url }}" && chmod 755 "{{ item.dest }}" - with_items: - - { url: "https://phar.phpunit.de/phploc.phar", dest: /usr/local/bin/phploc } - - { url: "https://phar.phpunit.de/phpunit.phar", dest: /usr/local/bin/phpunit } - - { url: "http://static.pdepend.org/php/latest/pdepend.phar", dest: /usr/local/bin/pdepend } - - { url: "http://static.phpmd.org/php/latest/phpmd.phar", dest: /usr/local/bin/phpmd } - - { url: "https://squizlabs.github.io/PHP_CodeSniffer/phpcs.phar", dest: /usr/local/bin/phpcs } - - { url: "https://squizlabs.github.io/PHP_CodeSniffer/phpcbf.phar", dest: /usr/local/bin/phpcbf } - - { url: "https://phar.phpunit.de/phpcpd.phar", dest: /usr/local/bin/phpcpd } - - { url: "https://phar.phpunit.de/phpdcd.phar", dest: /usr/local/bin/phpdcd } - - { url: "https://github.com/Halleck45/PhpMetrics/raw/master/build/phpmetrics.phar", dest: /usr/local/bin/phpmetrics } - - { url: "http://get.sensiolabs.org/php-cs-fixer.phar", dest: /usr/local/bin/php-cs-fixer } - - { url: "https://github.com/sensiolabs-de/deprecation-detector/releases/download/0.1.0-alpha4/deprecation-detector.phar", dest: /usr/local/bin/deprecation-detector } - - { url: "https://github.com/sensiolabs-de/deprecation-detector/releases/download/0.1.0-alpha4/deprecation-detector.phar", dest: /usr/local/bin/deprecation-detector } - -- name: Install Tools via composer - raw: COMPOSER_HOME="/usr/local/composer" COMPOSER_BIN_DIR="/usr/local/bin" composer global require "{{ item.package }}" "{{ item.version }}" - with_items: - - { package: "sstalle/php7cc" , version: "*" } - - { package: "phpspec/phpspec" , version: "~2.0" } diff --git a/docker/php-dev/debian-8-php7/Dockerfile b/docker/php-dev/debian-8-php7/Dockerfile index fc369c00a..d97145704 100644 --- a/docker/php-dev/debian-8-php7/Dockerfile +++ b/docker/php-dev/debian-8-php7/Dockerfile @@ -5,11 +5,6 @@ FROM webdevops/php:debian-8-php7 -MAINTAINER info@webdevops.io -LABEL vendor=WebDevOps.io -LABEL io.webdevops.layout=8 -LABEL io.webdevops.version=1.5.0 - COPY conf/ /opt/docker/ # Install development environment @@ -22,6 +17,8 @@ RUN wget -O - https://packagecloud.io/gpg.key | apt-key add - \ # php7.0-xdebug \ # Is currently not available blackfire-php \ blackfire-agent \ + # Enable php development services + && docker-service-enable syslog ssh postfix \ && /opt/docker/bin/provision run --tag bootstrap --role webdevops-dev --role webdevops-php-dev \ - && /opt/docker/bin/bootstrap.sh - + && /opt/docker/bin/bootstrap.sh \ + && docker-image-cleanup diff --git a/docker/php-dev/debian-8-php7/Dockerfile.jinja2 b/docker/php-dev/debian-8-php7/Dockerfile.jinja2 index 30f869711..f95b8c96f 100644 --- a/docker/php-dev/debian-8-php7/Dockerfile.jinja2 +++ b/docker/php-dev/debian-8-php7/Dockerfile.jinja2 @@ -1,7 +1,5 @@ {{ docker.from("php", "debian-8-php7") }} -{{ docker.version() }} - {{ docker.copy('conf/', '/opt/docker/') }} {{ php7dev.debianSury() }} diff --git a/docker/php-dev/debian-8-php7/conf/provision/entrypoint.d/10-php-debugger.sh b/docker/php-dev/debian-8-php7/conf/provision/entrypoint.d/10-php-debugger.sh index 7156e28aa..b5985a9ef 100644 --- a/docker/php-dev/debian-8-php7/conf/provision/entrypoint.d/10-php-debugger.sh +++ b/docker/php-dev/debian-8-php7/conf/provision/entrypoint.d/10-php-debugger.sh @@ -15,7 +15,8 @@ PHP_CONF_PATHS=" /etc/php5/fpm/conf.d /etc/php/7.0/mods-available /etc/php/7.0/cli/conf.d -/etc/php/7.0/fpm/conf.d" +/etc/php/7.0/fpm/conf.d +/usr/local/etc/php/conf.d/" function phpModuleRemove() { if [ "$#" -ne 1 ]; then @@ -40,7 +41,7 @@ if [[ -n "${PHP_DEBUGGER+x}" ]]; then blackfire) echo "PHP-Debugger: Blackfire enabled" phpModuleRemove "xdebug" - /opt/docker/bin/control.sh service.enable blackfire-agent + docker-service-enable blackfire-agent ;; none) diff --git a/docker/php-dev/debian-8-php7/conf/provision/roles/webdevops-dev/tasks/bootstrap.yml b/docker/php-dev/debian-8-php7/conf/provision/roles/webdevops-dev/tasks/bootstrap.yml index 5c9eafbd0..3d7a494ad 100644 --- a/docker/php-dev/debian-8-php7/conf/provision/roles/webdevops-dev/tasks/bootstrap.yml +++ b/docker/php-dev/debian-8-php7/conf/provision/roles/webdevops-dev/tasks/bootstrap.yml @@ -1,8 +1,5 @@ --- -- name: Enable ssh daemon - shell: "/opt/docker/bin/control.sh service.enable ssh" - - name: Set application user password user: name: "{{ APPLICATION_USER }}" diff --git a/docker/php-dev/debian-8-php7/conf/provision/roles/webdevops-php-dev/tasks/bootstrap.yml b/docker/php-dev/debian-8-php7/conf/provision/roles/webdevops-php-dev/tasks/bootstrap.yml index 2c5d76e3d..ff02b05fc 100644 --- a/docker/php-dev/debian-8-php7/conf/provision/roles/webdevops-php-dev/tasks/bootstrap.yml +++ b/docker/php-dev/debian-8-php7/conf/provision/roles/webdevops-php-dev/tasks/bootstrap.yml @@ -1,6 +1,5 @@ --- -- include: bootstrap/tools.yml - include: bootstrap/php-fpm.yml - include: bootstrap/php-module.yml - include: bootstrap/php-module.opcache.yml diff --git a/docker/php-dev/debian-8-php7/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/php-module.blackfire.yml b/docker/php-dev/debian-8-php7/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/php-module.blackfire.yml index 1a3db9bac..faf05f8de 100644 --- a/docker/php-dev/debian-8-php7/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/php-module.blackfire.yml +++ b/docker/php-dev/debian-8-php7/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/php-module.blackfire.yml @@ -7,4 +7,4 @@ with_items: - /etc/php5/cli/conf.d/zz-blackfire.ini - /etc/php5/fpm/conf.d/zz-blackfire.ini - when: ansible_distribution == 'Debian' and ansible_lsb.major_release|int >= 7 + when: ansible_distribution == 'Debian' and docker_image_info_distribution_version|int >= 7 diff --git a/docker/php-dev/debian-8-php7/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/tools.yml b/docker/php-dev/debian-8-php7/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/tools.yml deleted file mode 100644 index c49cb0e34..000000000 --- a/docker/php-dev/debian-8-php7/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/tools.yml +++ /dev/null @@ -1,23 +0,0 @@ ---- - -- name: Downloading Tools - shell: curl -o "{{ item.dest }}" "{{ item.url }}" && chmod 755 "{{ item.dest }}" - with_items: - - { url: "https://phar.phpunit.de/phploc.phar", dest: /usr/local/bin/phploc } - - { url: "https://phar.phpunit.de/phpunit.phar", dest: /usr/local/bin/phpunit } - - { url: "http://static.pdepend.org/php/latest/pdepend.phar", dest: /usr/local/bin/pdepend } - - { url: "http://static.phpmd.org/php/latest/phpmd.phar", dest: /usr/local/bin/phpmd } - - { url: "https://squizlabs.github.io/PHP_CodeSniffer/phpcs.phar", dest: /usr/local/bin/phpcs } - - { url: "https://squizlabs.github.io/PHP_CodeSniffer/phpcbf.phar", dest: /usr/local/bin/phpcbf } - - { url: "https://phar.phpunit.de/phpcpd.phar", dest: /usr/local/bin/phpcpd } - - { url: "https://phar.phpunit.de/phpdcd.phar", dest: /usr/local/bin/phpdcd } - - { url: "https://github.com/Halleck45/PhpMetrics/raw/master/build/phpmetrics.phar", dest: /usr/local/bin/phpmetrics } - - { url: "http://get.sensiolabs.org/php-cs-fixer.phar", dest: /usr/local/bin/php-cs-fixer } - - { url: "https://github.com/sensiolabs-de/deprecation-detector/releases/download/0.1.0-alpha4/deprecation-detector.phar", dest: /usr/local/bin/deprecation-detector } - - { url: "https://github.com/sensiolabs-de/deprecation-detector/releases/download/0.1.0-alpha4/deprecation-detector.phar", dest: /usr/local/bin/deprecation-detector } - -- name: Install Tools via composer - raw: COMPOSER_HOME="/usr/local/composer" COMPOSER_BIN_DIR="/usr/local/bin" composer global require "{{ item.package }}" "{{ item.version }}" - with_items: - - { package: "sstalle/php7cc" , version: "*" } - - { package: "phpspec/phpspec" , version: "~2.0" } diff --git a/docker/php-dev/debian-8/Dockerfile b/docker/php-dev/debian-8/Dockerfile index 6c077d718..f472d5819 100644 --- a/docker/php-dev/debian-8/Dockerfile +++ b/docker/php-dev/debian-8/Dockerfile @@ -5,11 +5,6 @@ FROM webdevops/php:debian-8 -MAINTAINER info@webdevops.io -LABEL vendor=WebDevOps.io -LABEL io.webdevops.layout=8 -LABEL io.webdevops.version=1.5.0 - COPY conf/ /opt/docker/ # Install development environment @@ -22,6 +17,11 @@ RUN wget -O - https://packagecloud.io/gpg.key | apt-key add - \ php5-xdebug \ blackfire-php \ blackfire-agent \ + # Tools + nano \ + vim \ + # Enable php development services + && docker-service-enable syslog ssh postfix \ && /opt/docker/bin/provision run --tag bootstrap --role webdevops-dev --role webdevops-php-dev \ - && /opt/docker/bin/bootstrap.sh - + && /opt/docker/bin/bootstrap.sh \ + && docker-image-cleanup diff --git a/docker/php-dev/debian-8/Dockerfile.jinja2 b/docker/php-dev/debian-8/Dockerfile.jinja2 index 8b1c32658..7a0788482 100644 --- a/docker/php-dev/debian-8/Dockerfile.jinja2 +++ b/docker/php-dev/debian-8/Dockerfile.jinja2 @@ -1,7 +1,5 @@ {{ docker.from("php", "debian-8") }} -{{ docker.version() }} - {{ docker.copy('conf/', '/opt/docker/') }} {{ php5dev.debian() }} diff --git a/docker/php-dev/debian-8/conf/provision/entrypoint.d/10-php-debugger.sh b/docker/php-dev/debian-8/conf/provision/entrypoint.d/10-php-debugger.sh index 7156e28aa..b5985a9ef 100644 --- a/docker/php-dev/debian-8/conf/provision/entrypoint.d/10-php-debugger.sh +++ b/docker/php-dev/debian-8/conf/provision/entrypoint.d/10-php-debugger.sh @@ -15,7 +15,8 @@ PHP_CONF_PATHS=" /etc/php5/fpm/conf.d /etc/php/7.0/mods-available /etc/php/7.0/cli/conf.d -/etc/php/7.0/fpm/conf.d" +/etc/php/7.0/fpm/conf.d +/usr/local/etc/php/conf.d/" function phpModuleRemove() { if [ "$#" -ne 1 ]; then @@ -40,7 +41,7 @@ if [[ -n "${PHP_DEBUGGER+x}" ]]; then blackfire) echo "PHP-Debugger: Blackfire enabled" phpModuleRemove "xdebug" - /opt/docker/bin/control.sh service.enable blackfire-agent + docker-service-enable blackfire-agent ;; none) diff --git a/docker/php-dev/debian-8/conf/provision/roles/webdevops-dev/tasks/bootstrap.yml b/docker/php-dev/debian-8/conf/provision/roles/webdevops-dev/tasks/bootstrap.yml index 5c9eafbd0..3d7a494ad 100644 --- a/docker/php-dev/debian-8/conf/provision/roles/webdevops-dev/tasks/bootstrap.yml +++ b/docker/php-dev/debian-8/conf/provision/roles/webdevops-dev/tasks/bootstrap.yml @@ -1,8 +1,5 @@ --- -- name: Enable ssh daemon - shell: "/opt/docker/bin/control.sh service.enable ssh" - - name: Set application user password user: name: "{{ APPLICATION_USER }}" diff --git a/docker/php-dev/debian-8/conf/provision/roles/webdevops-php-dev/tasks/bootstrap.yml b/docker/php-dev/debian-8/conf/provision/roles/webdevops-php-dev/tasks/bootstrap.yml index 2c5d76e3d..ff02b05fc 100644 --- a/docker/php-dev/debian-8/conf/provision/roles/webdevops-php-dev/tasks/bootstrap.yml +++ b/docker/php-dev/debian-8/conf/provision/roles/webdevops-php-dev/tasks/bootstrap.yml @@ -1,6 +1,5 @@ --- -- include: bootstrap/tools.yml - include: bootstrap/php-fpm.yml - include: bootstrap/php-module.yml - include: bootstrap/php-module.opcache.yml diff --git a/docker/php-dev/debian-8/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/php-module.blackfire.yml b/docker/php-dev/debian-8/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/php-module.blackfire.yml index 1a3db9bac..faf05f8de 100644 --- a/docker/php-dev/debian-8/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/php-module.blackfire.yml +++ b/docker/php-dev/debian-8/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/php-module.blackfire.yml @@ -7,4 +7,4 @@ with_items: - /etc/php5/cli/conf.d/zz-blackfire.ini - /etc/php5/fpm/conf.d/zz-blackfire.ini - when: ansible_distribution == 'Debian' and ansible_lsb.major_release|int >= 7 + when: ansible_distribution == 'Debian' and docker_image_info_distribution_version|int >= 7 diff --git a/docker/php-dev/debian-8/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/tools.yml b/docker/php-dev/debian-8/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/tools.yml deleted file mode 100644 index c49cb0e34..000000000 --- a/docker/php-dev/debian-8/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/tools.yml +++ /dev/null @@ -1,23 +0,0 @@ ---- - -- name: Downloading Tools - shell: curl -o "{{ item.dest }}" "{{ item.url }}" && chmod 755 "{{ item.dest }}" - with_items: - - { url: "https://phar.phpunit.de/phploc.phar", dest: /usr/local/bin/phploc } - - { url: "https://phar.phpunit.de/phpunit.phar", dest: /usr/local/bin/phpunit } - - { url: "http://static.pdepend.org/php/latest/pdepend.phar", dest: /usr/local/bin/pdepend } - - { url: "http://static.phpmd.org/php/latest/phpmd.phar", dest: /usr/local/bin/phpmd } - - { url: "https://squizlabs.github.io/PHP_CodeSniffer/phpcs.phar", dest: /usr/local/bin/phpcs } - - { url: "https://squizlabs.github.io/PHP_CodeSniffer/phpcbf.phar", dest: /usr/local/bin/phpcbf } - - { url: "https://phar.phpunit.de/phpcpd.phar", dest: /usr/local/bin/phpcpd } - - { url: "https://phar.phpunit.de/phpdcd.phar", dest: /usr/local/bin/phpdcd } - - { url: "https://github.com/Halleck45/PhpMetrics/raw/master/build/phpmetrics.phar", dest: /usr/local/bin/phpmetrics } - - { url: "http://get.sensiolabs.org/php-cs-fixer.phar", dest: /usr/local/bin/php-cs-fixer } - - { url: "https://github.com/sensiolabs-de/deprecation-detector/releases/download/0.1.0-alpha4/deprecation-detector.phar", dest: /usr/local/bin/deprecation-detector } - - { url: "https://github.com/sensiolabs-de/deprecation-detector/releases/download/0.1.0-alpha4/deprecation-detector.phar", dest: /usr/local/bin/deprecation-detector } - -- name: Install Tools via composer - raw: COMPOSER_HOME="/usr/local/composer" COMPOSER_BIN_DIR="/usr/local/bin" composer global require "{{ item.package }}" "{{ item.version }}" - with_items: - - { package: "sstalle/php7cc" , version: "*" } - - { package: "phpspec/phpspec" , version: "~2.0" } diff --git a/docker/php-dev/debian-9/Dockerfile b/docker/php-dev/debian-9/Dockerfile index 9bbf28516..5d8938dae 100644 --- a/docker/php-dev/debian-9/Dockerfile +++ b/docker/php-dev/debian-9/Dockerfile @@ -5,11 +5,6 @@ FROM webdevops/php:debian-9 -MAINTAINER info@webdevops.io -LABEL vendor=WebDevOps.io -LABEL io.webdevops.layout=8 -LABEL io.webdevops.version=1.5.0 - COPY conf/ /opt/docker/ # Install development environment @@ -22,6 +17,8 @@ RUN wget -O - https://packagecloud.io/gpg.key | apt-key add - \ php-xdebug \ blackfire-php \ blackfire-agent \ + # Enable php development services + && docker-service-enable syslog ssh postfix \ && /opt/docker/bin/provision run --tag bootstrap --role webdevops-dev --role webdevops-php-dev \ - && /opt/docker/bin/bootstrap.sh - + && /opt/docker/bin/bootstrap.sh \ + && docker-image-cleanup diff --git a/docker/php-dev/debian-9/Dockerfile.jinja2 b/docker/php-dev/debian-9/Dockerfile.jinja2 index 5890a8f4f..32d512f39 100644 --- a/docker/php-dev/debian-9/Dockerfile.jinja2 +++ b/docker/php-dev/debian-9/Dockerfile.jinja2 @@ -1,7 +1,5 @@ {{ docker.from("php", "debian-9") }} -{{ docker.version() }} - {{ docker.copy('conf/', '/opt/docker/') }} {{ php7dev.debian() }} diff --git a/docker/php-dev/debian-9/conf/provision/entrypoint.d/10-php-debugger.sh b/docker/php-dev/debian-9/conf/provision/entrypoint.d/10-php-debugger.sh index 7156e28aa..b5985a9ef 100644 --- a/docker/php-dev/debian-9/conf/provision/entrypoint.d/10-php-debugger.sh +++ b/docker/php-dev/debian-9/conf/provision/entrypoint.d/10-php-debugger.sh @@ -15,7 +15,8 @@ PHP_CONF_PATHS=" /etc/php5/fpm/conf.d /etc/php/7.0/mods-available /etc/php/7.0/cli/conf.d -/etc/php/7.0/fpm/conf.d" +/etc/php/7.0/fpm/conf.d +/usr/local/etc/php/conf.d/" function phpModuleRemove() { if [ "$#" -ne 1 ]; then @@ -40,7 +41,7 @@ if [[ -n "${PHP_DEBUGGER+x}" ]]; then blackfire) echo "PHP-Debugger: Blackfire enabled" phpModuleRemove "xdebug" - /opt/docker/bin/control.sh service.enable blackfire-agent + docker-service-enable blackfire-agent ;; none) diff --git a/docker/php-dev/debian-9/conf/provision/roles/webdevops-dev/tasks/bootstrap.yml b/docker/php-dev/debian-9/conf/provision/roles/webdevops-dev/tasks/bootstrap.yml index 5c9eafbd0..3d7a494ad 100644 --- a/docker/php-dev/debian-9/conf/provision/roles/webdevops-dev/tasks/bootstrap.yml +++ b/docker/php-dev/debian-9/conf/provision/roles/webdevops-dev/tasks/bootstrap.yml @@ -1,8 +1,5 @@ --- -- name: Enable ssh daemon - shell: "/opt/docker/bin/control.sh service.enable ssh" - - name: Set application user password user: name: "{{ APPLICATION_USER }}" diff --git a/docker/php-dev/debian-9/conf/provision/roles/webdevops-php-dev/tasks/bootstrap.yml b/docker/php-dev/debian-9/conf/provision/roles/webdevops-php-dev/tasks/bootstrap.yml index 2c5d76e3d..ff02b05fc 100644 --- a/docker/php-dev/debian-9/conf/provision/roles/webdevops-php-dev/tasks/bootstrap.yml +++ b/docker/php-dev/debian-9/conf/provision/roles/webdevops-php-dev/tasks/bootstrap.yml @@ -1,6 +1,5 @@ --- -- include: bootstrap/tools.yml - include: bootstrap/php-fpm.yml - include: bootstrap/php-module.yml - include: bootstrap/php-module.opcache.yml diff --git a/docker/php-dev/debian-9/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/php-module.blackfire.yml b/docker/php-dev/debian-9/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/php-module.blackfire.yml index 1a3db9bac..faf05f8de 100644 --- a/docker/php-dev/debian-9/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/php-module.blackfire.yml +++ b/docker/php-dev/debian-9/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/php-module.blackfire.yml @@ -7,4 +7,4 @@ with_items: - /etc/php5/cli/conf.d/zz-blackfire.ini - /etc/php5/fpm/conf.d/zz-blackfire.ini - when: ansible_distribution == 'Debian' and ansible_lsb.major_release|int >= 7 + when: ansible_distribution == 'Debian' and docker_image_info_distribution_version|int >= 7 diff --git a/docker/php-dev/debian-9/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/tools.yml b/docker/php-dev/debian-9/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/tools.yml deleted file mode 100644 index c49cb0e34..000000000 --- a/docker/php-dev/debian-9/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/tools.yml +++ /dev/null @@ -1,23 +0,0 @@ ---- - -- name: Downloading Tools - shell: curl -o "{{ item.dest }}" "{{ item.url }}" && chmod 755 "{{ item.dest }}" - with_items: - - { url: "https://phar.phpunit.de/phploc.phar", dest: /usr/local/bin/phploc } - - { url: "https://phar.phpunit.de/phpunit.phar", dest: /usr/local/bin/phpunit } - - { url: "http://static.pdepend.org/php/latest/pdepend.phar", dest: /usr/local/bin/pdepend } - - { url: "http://static.phpmd.org/php/latest/phpmd.phar", dest: /usr/local/bin/phpmd } - - { url: "https://squizlabs.github.io/PHP_CodeSniffer/phpcs.phar", dest: /usr/local/bin/phpcs } - - { url: "https://squizlabs.github.io/PHP_CodeSniffer/phpcbf.phar", dest: /usr/local/bin/phpcbf } - - { url: "https://phar.phpunit.de/phpcpd.phar", dest: /usr/local/bin/phpcpd } - - { url: "https://phar.phpunit.de/phpdcd.phar", dest: /usr/local/bin/phpdcd } - - { url: "https://github.com/Halleck45/PhpMetrics/raw/master/build/phpmetrics.phar", dest: /usr/local/bin/phpmetrics } - - { url: "http://get.sensiolabs.org/php-cs-fixer.phar", dest: /usr/local/bin/php-cs-fixer } - - { url: "https://github.com/sensiolabs-de/deprecation-detector/releases/download/0.1.0-alpha4/deprecation-detector.phar", dest: /usr/local/bin/deprecation-detector } - - { url: "https://github.com/sensiolabs-de/deprecation-detector/releases/download/0.1.0-alpha4/deprecation-detector.phar", dest: /usr/local/bin/deprecation-detector } - -- name: Install Tools via composer - raw: COMPOSER_HOME="/usr/local/composer" COMPOSER_BIN_DIR="/usr/local/bin" composer global require "{{ item.package }}" "{{ item.version }}" - with_items: - - { package: "sstalle/php7cc" , version: "*" } - - { package: "phpspec/phpspec" , version: "~2.0" } diff --git a/docker/php-dev/ubuntu-12.04/Dockerfile b/docker/php-dev/ubuntu-12.04/Dockerfile index 7f1578b13..47c604c29 100644 --- a/docker/php-dev/ubuntu-12.04/Dockerfile +++ b/docker/php-dev/ubuntu-12.04/Dockerfile @@ -5,11 +5,6 @@ FROM webdevops/php:ubuntu-12.04 -MAINTAINER info@webdevops.io -LABEL vendor=WebDevOps.io -LABEL io.webdevops.layout=8 -LABEL io.webdevops.version=1.5.0 - COPY conf/ /opt/docker/ # Install development environment @@ -22,6 +17,11 @@ RUN wget -O - https://packagecloud.io/gpg.key | apt-key add - \ php5-xdebug \ blackfire-php \ blackfire-agent \ + # Tools + nano \ + vim \ + # Enable php development services + && docker-service-enable syslog ssh postfix \ && /opt/docker/bin/provision run --tag bootstrap --role webdevops-dev --role webdevops-php-dev \ - && /opt/docker/bin/bootstrap.sh - + && /opt/docker/bin/bootstrap.sh \ + && docker-image-cleanup diff --git a/docker/php-dev/ubuntu-12.04/Dockerfile.jinja2 b/docker/php-dev/ubuntu-12.04/Dockerfile.jinja2 index 9a5f1836b..88cb3745f 100644 --- a/docker/php-dev/ubuntu-12.04/Dockerfile.jinja2 +++ b/docker/php-dev/ubuntu-12.04/Dockerfile.jinja2 @@ -1,7 +1,5 @@ {{ docker.from("php", "ubuntu-12.04") }} -{{ docker.version() }} - {{ docker.copy('conf/', '/opt/docker/') }} {{ php5dev.ubuntu() }} diff --git a/docker/php-dev/ubuntu-12.04/conf/provision/entrypoint.d/10-php-debugger.sh b/docker/php-dev/ubuntu-12.04/conf/provision/entrypoint.d/10-php-debugger.sh index 7156e28aa..b5985a9ef 100644 --- a/docker/php-dev/ubuntu-12.04/conf/provision/entrypoint.d/10-php-debugger.sh +++ b/docker/php-dev/ubuntu-12.04/conf/provision/entrypoint.d/10-php-debugger.sh @@ -15,7 +15,8 @@ PHP_CONF_PATHS=" /etc/php5/fpm/conf.d /etc/php/7.0/mods-available /etc/php/7.0/cli/conf.d -/etc/php/7.0/fpm/conf.d" +/etc/php/7.0/fpm/conf.d +/usr/local/etc/php/conf.d/" function phpModuleRemove() { if [ "$#" -ne 1 ]; then @@ -40,7 +41,7 @@ if [[ -n "${PHP_DEBUGGER+x}" ]]; then blackfire) echo "PHP-Debugger: Blackfire enabled" phpModuleRemove "xdebug" - /opt/docker/bin/control.sh service.enable blackfire-agent + docker-service-enable blackfire-agent ;; none) diff --git a/docker/php-dev/ubuntu-12.04/conf/provision/roles/webdevops-dev/tasks/bootstrap.yml b/docker/php-dev/ubuntu-12.04/conf/provision/roles/webdevops-dev/tasks/bootstrap.yml index 5c9eafbd0..3d7a494ad 100644 --- a/docker/php-dev/ubuntu-12.04/conf/provision/roles/webdevops-dev/tasks/bootstrap.yml +++ b/docker/php-dev/ubuntu-12.04/conf/provision/roles/webdevops-dev/tasks/bootstrap.yml @@ -1,8 +1,5 @@ --- -- name: Enable ssh daemon - shell: "/opt/docker/bin/control.sh service.enable ssh" - - name: Set application user password user: name: "{{ APPLICATION_USER }}" diff --git a/docker/php-dev/ubuntu-12.04/conf/provision/roles/webdevops-php-dev/tasks/bootstrap.yml b/docker/php-dev/ubuntu-12.04/conf/provision/roles/webdevops-php-dev/tasks/bootstrap.yml index 2c5d76e3d..ff02b05fc 100644 --- a/docker/php-dev/ubuntu-12.04/conf/provision/roles/webdevops-php-dev/tasks/bootstrap.yml +++ b/docker/php-dev/ubuntu-12.04/conf/provision/roles/webdevops-php-dev/tasks/bootstrap.yml @@ -1,6 +1,5 @@ --- -- include: bootstrap/tools.yml - include: bootstrap/php-fpm.yml - include: bootstrap/php-module.yml - include: bootstrap/php-module.opcache.yml diff --git a/docker/php-dev/ubuntu-12.04/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/php-module.blackfire.yml b/docker/php-dev/ubuntu-12.04/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/php-module.blackfire.yml index 1a3db9bac..faf05f8de 100644 --- a/docker/php-dev/ubuntu-12.04/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/php-module.blackfire.yml +++ b/docker/php-dev/ubuntu-12.04/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/php-module.blackfire.yml @@ -7,4 +7,4 @@ with_items: - /etc/php5/cli/conf.d/zz-blackfire.ini - /etc/php5/fpm/conf.d/zz-blackfire.ini - when: ansible_distribution == 'Debian' and ansible_lsb.major_release|int >= 7 + when: ansible_distribution == 'Debian' and docker_image_info_distribution_version|int >= 7 diff --git a/docker/php-dev/ubuntu-12.04/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/tools.yml b/docker/php-dev/ubuntu-12.04/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/tools.yml deleted file mode 100644 index c49cb0e34..000000000 --- a/docker/php-dev/ubuntu-12.04/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/tools.yml +++ /dev/null @@ -1,23 +0,0 @@ ---- - -- name: Downloading Tools - shell: curl -o "{{ item.dest }}" "{{ item.url }}" && chmod 755 "{{ item.dest }}" - with_items: - - { url: "https://phar.phpunit.de/phploc.phar", dest: /usr/local/bin/phploc } - - { url: "https://phar.phpunit.de/phpunit.phar", dest: /usr/local/bin/phpunit } - - { url: "http://static.pdepend.org/php/latest/pdepend.phar", dest: /usr/local/bin/pdepend } - - { url: "http://static.phpmd.org/php/latest/phpmd.phar", dest: /usr/local/bin/phpmd } - - { url: "https://squizlabs.github.io/PHP_CodeSniffer/phpcs.phar", dest: /usr/local/bin/phpcs } - - { url: "https://squizlabs.github.io/PHP_CodeSniffer/phpcbf.phar", dest: /usr/local/bin/phpcbf } - - { url: "https://phar.phpunit.de/phpcpd.phar", dest: /usr/local/bin/phpcpd } - - { url: "https://phar.phpunit.de/phpdcd.phar", dest: /usr/local/bin/phpdcd } - - { url: "https://github.com/Halleck45/PhpMetrics/raw/master/build/phpmetrics.phar", dest: /usr/local/bin/phpmetrics } - - { url: "http://get.sensiolabs.org/php-cs-fixer.phar", dest: /usr/local/bin/php-cs-fixer } - - { url: "https://github.com/sensiolabs-de/deprecation-detector/releases/download/0.1.0-alpha4/deprecation-detector.phar", dest: /usr/local/bin/deprecation-detector } - - { url: "https://github.com/sensiolabs-de/deprecation-detector/releases/download/0.1.0-alpha4/deprecation-detector.phar", dest: /usr/local/bin/deprecation-detector } - -- name: Install Tools via composer - raw: COMPOSER_HOME="/usr/local/composer" COMPOSER_BIN_DIR="/usr/local/bin" composer global require "{{ item.package }}" "{{ item.version }}" - with_items: - - { package: "sstalle/php7cc" , version: "*" } - - { package: "phpspec/phpspec" , version: "~2.0" } diff --git a/docker/php-dev/ubuntu-14.04/Dockerfile b/docker/php-dev/ubuntu-14.04/Dockerfile index a92222480..48d76f324 100644 --- a/docker/php-dev/ubuntu-14.04/Dockerfile +++ b/docker/php-dev/ubuntu-14.04/Dockerfile @@ -5,11 +5,6 @@ FROM webdevops/php:ubuntu-14.04 -MAINTAINER info@webdevops.io -LABEL vendor=WebDevOps.io -LABEL io.webdevops.layout=8 -LABEL io.webdevops.version=1.5.0 - COPY conf/ /opt/docker/ # Install development environment @@ -22,6 +17,11 @@ RUN wget -O - https://packagecloud.io/gpg.key | apt-key add - \ php5-xdebug \ blackfire-php \ blackfire-agent \ + # Tools + nano \ + vim \ + # Enable php development services + && docker-service-enable syslog ssh postfix \ && /opt/docker/bin/provision run --tag bootstrap --role webdevops-dev --role webdevops-php-dev \ - && /opt/docker/bin/bootstrap.sh - + && /opt/docker/bin/bootstrap.sh \ + && docker-image-cleanup diff --git a/docker/php-dev/ubuntu-14.04/Dockerfile.jinja2 b/docker/php-dev/ubuntu-14.04/Dockerfile.jinja2 index f061e1381..7f15be3b6 100644 --- a/docker/php-dev/ubuntu-14.04/Dockerfile.jinja2 +++ b/docker/php-dev/ubuntu-14.04/Dockerfile.jinja2 @@ -1,7 +1,5 @@ {{ docker.from("php", "ubuntu-14.04") }} -{{ docker.version() }} - {{ docker.copy('conf/', '/opt/docker/') }} {{ php5dev.ubuntu() }} diff --git a/docker/php-dev/ubuntu-14.04/conf/provision/entrypoint.d/10-php-debugger.sh b/docker/php-dev/ubuntu-14.04/conf/provision/entrypoint.d/10-php-debugger.sh index 7156e28aa..b5985a9ef 100644 --- a/docker/php-dev/ubuntu-14.04/conf/provision/entrypoint.d/10-php-debugger.sh +++ b/docker/php-dev/ubuntu-14.04/conf/provision/entrypoint.d/10-php-debugger.sh @@ -15,7 +15,8 @@ PHP_CONF_PATHS=" /etc/php5/fpm/conf.d /etc/php/7.0/mods-available /etc/php/7.0/cli/conf.d -/etc/php/7.0/fpm/conf.d" +/etc/php/7.0/fpm/conf.d +/usr/local/etc/php/conf.d/" function phpModuleRemove() { if [ "$#" -ne 1 ]; then @@ -40,7 +41,7 @@ if [[ -n "${PHP_DEBUGGER+x}" ]]; then blackfire) echo "PHP-Debugger: Blackfire enabled" phpModuleRemove "xdebug" - /opt/docker/bin/control.sh service.enable blackfire-agent + docker-service-enable blackfire-agent ;; none) diff --git a/docker/php-dev/ubuntu-14.04/conf/provision/roles/webdevops-dev/tasks/bootstrap.yml b/docker/php-dev/ubuntu-14.04/conf/provision/roles/webdevops-dev/tasks/bootstrap.yml index 5c9eafbd0..3d7a494ad 100644 --- a/docker/php-dev/ubuntu-14.04/conf/provision/roles/webdevops-dev/tasks/bootstrap.yml +++ b/docker/php-dev/ubuntu-14.04/conf/provision/roles/webdevops-dev/tasks/bootstrap.yml @@ -1,8 +1,5 @@ --- -- name: Enable ssh daemon - shell: "/opt/docker/bin/control.sh service.enable ssh" - - name: Set application user password user: name: "{{ APPLICATION_USER }}" diff --git a/docker/php-dev/ubuntu-14.04/conf/provision/roles/webdevops-php-dev/tasks/bootstrap.yml b/docker/php-dev/ubuntu-14.04/conf/provision/roles/webdevops-php-dev/tasks/bootstrap.yml index 2c5d76e3d..ff02b05fc 100644 --- a/docker/php-dev/ubuntu-14.04/conf/provision/roles/webdevops-php-dev/tasks/bootstrap.yml +++ b/docker/php-dev/ubuntu-14.04/conf/provision/roles/webdevops-php-dev/tasks/bootstrap.yml @@ -1,6 +1,5 @@ --- -- include: bootstrap/tools.yml - include: bootstrap/php-fpm.yml - include: bootstrap/php-module.yml - include: bootstrap/php-module.opcache.yml diff --git a/docker/php-dev/ubuntu-14.04/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/php-module.blackfire.yml b/docker/php-dev/ubuntu-14.04/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/php-module.blackfire.yml index 1a3db9bac..faf05f8de 100644 --- a/docker/php-dev/ubuntu-14.04/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/php-module.blackfire.yml +++ b/docker/php-dev/ubuntu-14.04/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/php-module.blackfire.yml @@ -7,4 +7,4 @@ with_items: - /etc/php5/cli/conf.d/zz-blackfire.ini - /etc/php5/fpm/conf.d/zz-blackfire.ini - when: ansible_distribution == 'Debian' and ansible_lsb.major_release|int >= 7 + when: ansible_distribution == 'Debian' and docker_image_info_distribution_version|int >= 7 diff --git a/docker/php-dev/ubuntu-14.04/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/tools.yml b/docker/php-dev/ubuntu-14.04/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/tools.yml deleted file mode 100644 index c49cb0e34..000000000 --- a/docker/php-dev/ubuntu-14.04/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/tools.yml +++ /dev/null @@ -1,23 +0,0 @@ ---- - -- name: Downloading Tools - shell: curl -o "{{ item.dest }}" "{{ item.url }}" && chmod 755 "{{ item.dest }}" - with_items: - - { url: "https://phar.phpunit.de/phploc.phar", dest: /usr/local/bin/phploc } - - { url: "https://phar.phpunit.de/phpunit.phar", dest: /usr/local/bin/phpunit } - - { url: "http://static.pdepend.org/php/latest/pdepend.phar", dest: /usr/local/bin/pdepend } - - { url: "http://static.phpmd.org/php/latest/phpmd.phar", dest: /usr/local/bin/phpmd } - - { url: "https://squizlabs.github.io/PHP_CodeSniffer/phpcs.phar", dest: /usr/local/bin/phpcs } - - { url: "https://squizlabs.github.io/PHP_CodeSniffer/phpcbf.phar", dest: /usr/local/bin/phpcbf } - - { url: "https://phar.phpunit.de/phpcpd.phar", dest: /usr/local/bin/phpcpd } - - { url: "https://phar.phpunit.de/phpdcd.phar", dest: /usr/local/bin/phpdcd } - - { url: "https://github.com/Halleck45/PhpMetrics/raw/master/build/phpmetrics.phar", dest: /usr/local/bin/phpmetrics } - - { url: "http://get.sensiolabs.org/php-cs-fixer.phar", dest: /usr/local/bin/php-cs-fixer } - - { url: "https://github.com/sensiolabs-de/deprecation-detector/releases/download/0.1.0-alpha4/deprecation-detector.phar", dest: /usr/local/bin/deprecation-detector } - - { url: "https://github.com/sensiolabs-de/deprecation-detector/releases/download/0.1.0-alpha4/deprecation-detector.phar", dest: /usr/local/bin/deprecation-detector } - -- name: Install Tools via composer - raw: COMPOSER_HOME="/usr/local/composer" COMPOSER_BIN_DIR="/usr/local/bin" composer global require "{{ item.package }}" "{{ item.version }}" - with_items: - - { package: "sstalle/php7cc" , version: "*" } - - { package: "phpspec/phpspec" , version: "~2.0" } diff --git a/docker/php-dev/ubuntu-15.04/Dockerfile b/docker/php-dev/ubuntu-15.04/Dockerfile index a130d6bab..a93d8b132 100644 --- a/docker/php-dev/ubuntu-15.04/Dockerfile +++ b/docker/php-dev/ubuntu-15.04/Dockerfile @@ -5,11 +5,6 @@ FROM webdevops/php:ubuntu-15.04 -MAINTAINER info@webdevops.io -LABEL vendor=WebDevOps.io -LABEL io.webdevops.layout=8 -LABEL io.webdevops.version=1.5.0 - COPY conf/ /opt/docker/ # Install development environment @@ -22,6 +17,11 @@ RUN wget -O - https://packagecloud.io/gpg.key | apt-key add - \ php5-xdebug \ blackfire-php \ blackfire-agent \ + # Tools + nano \ + vim \ + # Enable php development services + && docker-service-enable syslog ssh postfix \ && /opt/docker/bin/provision run --tag bootstrap --role webdevops-dev --role webdevops-php-dev \ - && /opt/docker/bin/bootstrap.sh - + && /opt/docker/bin/bootstrap.sh \ + && docker-image-cleanup diff --git a/docker/php-dev/ubuntu-15.04/Dockerfile.jinja2 b/docker/php-dev/ubuntu-15.04/Dockerfile.jinja2 index 72876fc4b..4f1e5e17a 100644 --- a/docker/php-dev/ubuntu-15.04/Dockerfile.jinja2 +++ b/docker/php-dev/ubuntu-15.04/Dockerfile.jinja2 @@ -1,7 +1,5 @@ {{ docker.from("php", "ubuntu-15.04") }} -{{ docker.version() }} - {{ docker.copy('conf/', '/opt/docker/') }} {{ php5dev.ubuntu() }} diff --git a/docker/php-dev/ubuntu-15.04/conf/provision/entrypoint.d/10-php-debugger.sh b/docker/php-dev/ubuntu-15.04/conf/provision/entrypoint.d/10-php-debugger.sh index 7156e28aa..b5985a9ef 100644 --- a/docker/php-dev/ubuntu-15.04/conf/provision/entrypoint.d/10-php-debugger.sh +++ b/docker/php-dev/ubuntu-15.04/conf/provision/entrypoint.d/10-php-debugger.sh @@ -15,7 +15,8 @@ PHP_CONF_PATHS=" /etc/php5/fpm/conf.d /etc/php/7.0/mods-available /etc/php/7.0/cli/conf.d -/etc/php/7.0/fpm/conf.d" +/etc/php/7.0/fpm/conf.d +/usr/local/etc/php/conf.d/" function phpModuleRemove() { if [ "$#" -ne 1 ]; then @@ -40,7 +41,7 @@ if [[ -n "${PHP_DEBUGGER+x}" ]]; then blackfire) echo "PHP-Debugger: Blackfire enabled" phpModuleRemove "xdebug" - /opt/docker/bin/control.sh service.enable blackfire-agent + docker-service-enable blackfire-agent ;; none) diff --git a/docker/php-dev/ubuntu-15.04/conf/provision/roles/webdevops-dev/tasks/bootstrap.yml b/docker/php-dev/ubuntu-15.04/conf/provision/roles/webdevops-dev/tasks/bootstrap.yml index 5c9eafbd0..3d7a494ad 100644 --- a/docker/php-dev/ubuntu-15.04/conf/provision/roles/webdevops-dev/tasks/bootstrap.yml +++ b/docker/php-dev/ubuntu-15.04/conf/provision/roles/webdevops-dev/tasks/bootstrap.yml @@ -1,8 +1,5 @@ --- -- name: Enable ssh daemon - shell: "/opt/docker/bin/control.sh service.enable ssh" - - name: Set application user password user: name: "{{ APPLICATION_USER }}" diff --git a/docker/php-dev/ubuntu-15.04/conf/provision/roles/webdevops-php-dev/tasks/bootstrap.yml b/docker/php-dev/ubuntu-15.04/conf/provision/roles/webdevops-php-dev/tasks/bootstrap.yml index 2c5d76e3d..ff02b05fc 100644 --- a/docker/php-dev/ubuntu-15.04/conf/provision/roles/webdevops-php-dev/tasks/bootstrap.yml +++ b/docker/php-dev/ubuntu-15.04/conf/provision/roles/webdevops-php-dev/tasks/bootstrap.yml @@ -1,6 +1,5 @@ --- -- include: bootstrap/tools.yml - include: bootstrap/php-fpm.yml - include: bootstrap/php-module.yml - include: bootstrap/php-module.opcache.yml diff --git a/docker/php-dev/ubuntu-15.04/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/php-module.blackfire.yml b/docker/php-dev/ubuntu-15.04/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/php-module.blackfire.yml index 1a3db9bac..faf05f8de 100644 --- a/docker/php-dev/ubuntu-15.04/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/php-module.blackfire.yml +++ b/docker/php-dev/ubuntu-15.04/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/php-module.blackfire.yml @@ -7,4 +7,4 @@ with_items: - /etc/php5/cli/conf.d/zz-blackfire.ini - /etc/php5/fpm/conf.d/zz-blackfire.ini - when: ansible_distribution == 'Debian' and ansible_lsb.major_release|int >= 7 + when: ansible_distribution == 'Debian' and docker_image_info_distribution_version|int >= 7 diff --git a/docker/php-dev/ubuntu-15.04/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/tools.yml b/docker/php-dev/ubuntu-15.04/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/tools.yml deleted file mode 100644 index c49cb0e34..000000000 --- a/docker/php-dev/ubuntu-15.04/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/tools.yml +++ /dev/null @@ -1,23 +0,0 @@ ---- - -- name: Downloading Tools - shell: curl -o "{{ item.dest }}" "{{ item.url }}" && chmod 755 "{{ item.dest }}" - with_items: - - { url: "https://phar.phpunit.de/phploc.phar", dest: /usr/local/bin/phploc } - - { url: "https://phar.phpunit.de/phpunit.phar", dest: /usr/local/bin/phpunit } - - { url: "http://static.pdepend.org/php/latest/pdepend.phar", dest: /usr/local/bin/pdepend } - - { url: "http://static.phpmd.org/php/latest/phpmd.phar", dest: /usr/local/bin/phpmd } - - { url: "https://squizlabs.github.io/PHP_CodeSniffer/phpcs.phar", dest: /usr/local/bin/phpcs } - - { url: "https://squizlabs.github.io/PHP_CodeSniffer/phpcbf.phar", dest: /usr/local/bin/phpcbf } - - { url: "https://phar.phpunit.de/phpcpd.phar", dest: /usr/local/bin/phpcpd } - - { url: "https://phar.phpunit.de/phpdcd.phar", dest: /usr/local/bin/phpdcd } - - { url: "https://github.com/Halleck45/PhpMetrics/raw/master/build/phpmetrics.phar", dest: /usr/local/bin/phpmetrics } - - { url: "http://get.sensiolabs.org/php-cs-fixer.phar", dest: /usr/local/bin/php-cs-fixer } - - { url: "https://github.com/sensiolabs-de/deprecation-detector/releases/download/0.1.0-alpha4/deprecation-detector.phar", dest: /usr/local/bin/deprecation-detector } - - { url: "https://github.com/sensiolabs-de/deprecation-detector/releases/download/0.1.0-alpha4/deprecation-detector.phar", dest: /usr/local/bin/deprecation-detector } - -- name: Install Tools via composer - raw: COMPOSER_HOME="/usr/local/composer" COMPOSER_BIN_DIR="/usr/local/bin" composer global require "{{ item.package }}" "{{ item.version }}" - with_items: - - { package: "sstalle/php7cc" , version: "*" } - - { package: "phpspec/phpspec" , version: "~2.0" } diff --git a/docker/php-dev/ubuntu-15.10/Dockerfile b/docker/php-dev/ubuntu-15.10/Dockerfile index 2ec19de44..8e7e3373e 100644 --- a/docker/php-dev/ubuntu-15.10/Dockerfile +++ b/docker/php-dev/ubuntu-15.10/Dockerfile @@ -5,11 +5,6 @@ FROM webdevops/php:ubuntu-15.10 -MAINTAINER info@webdevops.io -LABEL vendor=WebDevOps.io -LABEL io.webdevops.layout=8 -LABEL io.webdevops.version=1.5.0 - COPY conf/ /opt/docker/ # Install development environment @@ -22,6 +17,11 @@ RUN wget -O - https://packagecloud.io/gpg.key | apt-key add - \ php5-xdebug \ blackfire-php \ blackfire-agent \ + # Tools + nano \ + vim \ + # Enable php development services + && docker-service-enable syslog ssh postfix \ && /opt/docker/bin/provision run --tag bootstrap --role webdevops-dev --role webdevops-php-dev \ - && /opt/docker/bin/bootstrap.sh - + && /opt/docker/bin/bootstrap.sh \ + && docker-image-cleanup diff --git a/docker/php-dev/ubuntu-15.10/Dockerfile.jinja2 b/docker/php-dev/ubuntu-15.10/Dockerfile.jinja2 index b1bb02ffa..2f3ecfce1 100644 --- a/docker/php-dev/ubuntu-15.10/Dockerfile.jinja2 +++ b/docker/php-dev/ubuntu-15.10/Dockerfile.jinja2 @@ -1,7 +1,5 @@ {{ docker.from("php", "ubuntu-15.10") }} -{{ docker.version() }} - {{ docker.copy('conf/', '/opt/docker/') }} {{ php5dev.ubuntu() }} diff --git a/docker/php-dev/ubuntu-15.10/conf/provision/entrypoint.d/10-php-debugger.sh b/docker/php-dev/ubuntu-15.10/conf/provision/entrypoint.d/10-php-debugger.sh index 7156e28aa..b5985a9ef 100644 --- a/docker/php-dev/ubuntu-15.10/conf/provision/entrypoint.d/10-php-debugger.sh +++ b/docker/php-dev/ubuntu-15.10/conf/provision/entrypoint.d/10-php-debugger.sh @@ -15,7 +15,8 @@ PHP_CONF_PATHS=" /etc/php5/fpm/conf.d /etc/php/7.0/mods-available /etc/php/7.0/cli/conf.d -/etc/php/7.0/fpm/conf.d" +/etc/php/7.0/fpm/conf.d +/usr/local/etc/php/conf.d/" function phpModuleRemove() { if [ "$#" -ne 1 ]; then @@ -40,7 +41,7 @@ if [[ -n "${PHP_DEBUGGER+x}" ]]; then blackfire) echo "PHP-Debugger: Blackfire enabled" phpModuleRemove "xdebug" - /opt/docker/bin/control.sh service.enable blackfire-agent + docker-service-enable blackfire-agent ;; none) diff --git a/docker/php-dev/ubuntu-15.10/conf/provision/roles/webdevops-dev/tasks/bootstrap.yml b/docker/php-dev/ubuntu-15.10/conf/provision/roles/webdevops-dev/tasks/bootstrap.yml index 5c9eafbd0..3d7a494ad 100644 --- a/docker/php-dev/ubuntu-15.10/conf/provision/roles/webdevops-dev/tasks/bootstrap.yml +++ b/docker/php-dev/ubuntu-15.10/conf/provision/roles/webdevops-dev/tasks/bootstrap.yml @@ -1,8 +1,5 @@ --- -- name: Enable ssh daemon - shell: "/opt/docker/bin/control.sh service.enable ssh" - - name: Set application user password user: name: "{{ APPLICATION_USER }}" diff --git a/docker/php-dev/ubuntu-15.10/conf/provision/roles/webdevops-php-dev/tasks/bootstrap.yml b/docker/php-dev/ubuntu-15.10/conf/provision/roles/webdevops-php-dev/tasks/bootstrap.yml index 2c5d76e3d..ff02b05fc 100644 --- a/docker/php-dev/ubuntu-15.10/conf/provision/roles/webdevops-php-dev/tasks/bootstrap.yml +++ b/docker/php-dev/ubuntu-15.10/conf/provision/roles/webdevops-php-dev/tasks/bootstrap.yml @@ -1,6 +1,5 @@ --- -- include: bootstrap/tools.yml - include: bootstrap/php-fpm.yml - include: bootstrap/php-module.yml - include: bootstrap/php-module.opcache.yml diff --git a/docker/php-dev/ubuntu-15.10/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/php-module.blackfire.yml b/docker/php-dev/ubuntu-15.10/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/php-module.blackfire.yml index 1a3db9bac..faf05f8de 100644 --- a/docker/php-dev/ubuntu-15.10/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/php-module.blackfire.yml +++ b/docker/php-dev/ubuntu-15.10/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/php-module.blackfire.yml @@ -7,4 +7,4 @@ with_items: - /etc/php5/cli/conf.d/zz-blackfire.ini - /etc/php5/fpm/conf.d/zz-blackfire.ini - when: ansible_distribution == 'Debian' and ansible_lsb.major_release|int >= 7 + when: ansible_distribution == 'Debian' and docker_image_info_distribution_version|int >= 7 diff --git a/docker/php-dev/ubuntu-15.10/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/tools.yml b/docker/php-dev/ubuntu-15.10/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/tools.yml deleted file mode 100644 index c49cb0e34..000000000 --- a/docker/php-dev/ubuntu-15.10/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/tools.yml +++ /dev/null @@ -1,23 +0,0 @@ ---- - -- name: Downloading Tools - shell: curl -o "{{ item.dest }}" "{{ item.url }}" && chmod 755 "{{ item.dest }}" - with_items: - - { url: "https://phar.phpunit.de/phploc.phar", dest: /usr/local/bin/phploc } - - { url: "https://phar.phpunit.de/phpunit.phar", dest: /usr/local/bin/phpunit } - - { url: "http://static.pdepend.org/php/latest/pdepend.phar", dest: /usr/local/bin/pdepend } - - { url: "http://static.phpmd.org/php/latest/phpmd.phar", dest: /usr/local/bin/phpmd } - - { url: "https://squizlabs.github.io/PHP_CodeSniffer/phpcs.phar", dest: /usr/local/bin/phpcs } - - { url: "https://squizlabs.github.io/PHP_CodeSniffer/phpcbf.phar", dest: /usr/local/bin/phpcbf } - - { url: "https://phar.phpunit.de/phpcpd.phar", dest: /usr/local/bin/phpcpd } - - { url: "https://phar.phpunit.de/phpdcd.phar", dest: /usr/local/bin/phpdcd } - - { url: "https://github.com/Halleck45/PhpMetrics/raw/master/build/phpmetrics.phar", dest: /usr/local/bin/phpmetrics } - - { url: "http://get.sensiolabs.org/php-cs-fixer.phar", dest: /usr/local/bin/php-cs-fixer } - - { url: "https://github.com/sensiolabs-de/deprecation-detector/releases/download/0.1.0-alpha4/deprecation-detector.phar", dest: /usr/local/bin/deprecation-detector } - - { url: "https://github.com/sensiolabs-de/deprecation-detector/releases/download/0.1.0-alpha4/deprecation-detector.phar", dest: /usr/local/bin/deprecation-detector } - -- name: Install Tools via composer - raw: COMPOSER_HOME="/usr/local/composer" COMPOSER_BIN_DIR="/usr/local/bin" composer global require "{{ item.package }}" "{{ item.version }}" - with_items: - - { package: "sstalle/php7cc" , version: "*" } - - { package: "phpspec/phpspec" , version: "~2.0" } diff --git a/docker/php-dev/ubuntu-16.04/Dockerfile b/docker/php-dev/ubuntu-16.04/Dockerfile index ad3e1edc9..7403ae880 100644 --- a/docker/php-dev/ubuntu-16.04/Dockerfile +++ b/docker/php-dev/ubuntu-16.04/Dockerfile @@ -5,11 +5,6 @@ FROM webdevops/php:ubuntu-16.04 -MAINTAINER info@webdevops.io -LABEL vendor=WebDevOps.io -LABEL io.webdevops.layout=8 -LABEL io.webdevops.version=1.5.0 - COPY conf/ /opt/docker/ # Install development environment @@ -22,6 +17,8 @@ RUN wget -O - https://packagecloud.io/gpg.key | apt-key add - \ php-xdebug \ blackfire-php \ blackfire-agent \ + # Enable php development services + && docker-service-enable syslog ssh postfix \ && /opt/docker/bin/provision run --tag bootstrap --role webdevops-dev --role webdevops-php-dev \ - && /opt/docker/bin/bootstrap.sh - + && /opt/docker/bin/bootstrap.sh \ + && docker-image-cleanup diff --git a/docker/php-dev/ubuntu-16.04/Dockerfile.jinja2 b/docker/php-dev/ubuntu-16.04/Dockerfile.jinja2 index 5cad015b0..3c5eff25b 100644 --- a/docker/php-dev/ubuntu-16.04/Dockerfile.jinja2 +++ b/docker/php-dev/ubuntu-16.04/Dockerfile.jinja2 @@ -1,7 +1,5 @@ {{ docker.from("php", "ubuntu-16.04") }} -{{ docker.version() }} - {{ docker.copy('conf/', '/opt/docker/') }} {{ php7dev.ubuntu() }} diff --git a/docker/php-dev/ubuntu-16.04/conf/provision/entrypoint.d/10-php-debugger.sh b/docker/php-dev/ubuntu-16.04/conf/provision/entrypoint.d/10-php-debugger.sh index 7156e28aa..b5985a9ef 100644 --- a/docker/php-dev/ubuntu-16.04/conf/provision/entrypoint.d/10-php-debugger.sh +++ b/docker/php-dev/ubuntu-16.04/conf/provision/entrypoint.d/10-php-debugger.sh @@ -15,7 +15,8 @@ PHP_CONF_PATHS=" /etc/php5/fpm/conf.d /etc/php/7.0/mods-available /etc/php/7.0/cli/conf.d -/etc/php/7.0/fpm/conf.d" +/etc/php/7.0/fpm/conf.d +/usr/local/etc/php/conf.d/" function phpModuleRemove() { if [ "$#" -ne 1 ]; then @@ -40,7 +41,7 @@ if [[ -n "${PHP_DEBUGGER+x}" ]]; then blackfire) echo "PHP-Debugger: Blackfire enabled" phpModuleRemove "xdebug" - /opt/docker/bin/control.sh service.enable blackfire-agent + docker-service-enable blackfire-agent ;; none) diff --git a/docker/php-dev/ubuntu-16.04/conf/provision/roles/webdevops-dev/tasks/bootstrap.yml b/docker/php-dev/ubuntu-16.04/conf/provision/roles/webdevops-dev/tasks/bootstrap.yml index 5c9eafbd0..3d7a494ad 100644 --- a/docker/php-dev/ubuntu-16.04/conf/provision/roles/webdevops-dev/tasks/bootstrap.yml +++ b/docker/php-dev/ubuntu-16.04/conf/provision/roles/webdevops-dev/tasks/bootstrap.yml @@ -1,8 +1,5 @@ --- -- name: Enable ssh daemon - shell: "/opt/docker/bin/control.sh service.enable ssh" - - name: Set application user password user: name: "{{ APPLICATION_USER }}" diff --git a/docker/php-dev/ubuntu-16.04/conf/provision/roles/webdevops-php-dev/tasks/bootstrap.yml b/docker/php-dev/ubuntu-16.04/conf/provision/roles/webdevops-php-dev/tasks/bootstrap.yml index 2c5d76e3d..ff02b05fc 100644 --- a/docker/php-dev/ubuntu-16.04/conf/provision/roles/webdevops-php-dev/tasks/bootstrap.yml +++ b/docker/php-dev/ubuntu-16.04/conf/provision/roles/webdevops-php-dev/tasks/bootstrap.yml @@ -1,6 +1,5 @@ --- -- include: bootstrap/tools.yml - include: bootstrap/php-fpm.yml - include: bootstrap/php-module.yml - include: bootstrap/php-module.opcache.yml diff --git a/docker/php-dev/ubuntu-16.04/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/php-module.blackfire.yml b/docker/php-dev/ubuntu-16.04/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/php-module.blackfire.yml index 1a3db9bac..faf05f8de 100644 --- a/docker/php-dev/ubuntu-16.04/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/php-module.blackfire.yml +++ b/docker/php-dev/ubuntu-16.04/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/php-module.blackfire.yml @@ -7,4 +7,4 @@ with_items: - /etc/php5/cli/conf.d/zz-blackfire.ini - /etc/php5/fpm/conf.d/zz-blackfire.ini - when: ansible_distribution == 'Debian' and ansible_lsb.major_release|int >= 7 + when: ansible_distribution == 'Debian' and docker_image_info_distribution_version|int >= 7 diff --git a/docker/php-dev/ubuntu-16.04/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/tools.yml b/docker/php-dev/ubuntu-16.04/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/tools.yml deleted file mode 100644 index c49cb0e34..000000000 --- a/docker/php-dev/ubuntu-16.04/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/tools.yml +++ /dev/null @@ -1,23 +0,0 @@ ---- - -- name: Downloading Tools - shell: curl -o "{{ item.dest }}" "{{ item.url }}" && chmod 755 "{{ item.dest }}" - with_items: - - { url: "https://phar.phpunit.de/phploc.phar", dest: /usr/local/bin/phploc } - - { url: "https://phar.phpunit.de/phpunit.phar", dest: /usr/local/bin/phpunit } - - { url: "http://static.pdepend.org/php/latest/pdepend.phar", dest: /usr/local/bin/pdepend } - - { url: "http://static.phpmd.org/php/latest/phpmd.phar", dest: /usr/local/bin/phpmd } - - { url: "https://squizlabs.github.io/PHP_CodeSniffer/phpcs.phar", dest: /usr/local/bin/phpcs } - - { url: "https://squizlabs.github.io/PHP_CodeSniffer/phpcbf.phar", dest: /usr/local/bin/phpcbf } - - { url: "https://phar.phpunit.de/phpcpd.phar", dest: /usr/local/bin/phpcpd } - - { url: "https://phar.phpunit.de/phpdcd.phar", dest: /usr/local/bin/phpdcd } - - { url: "https://github.com/Halleck45/PhpMetrics/raw/master/build/phpmetrics.phar", dest: /usr/local/bin/phpmetrics } - - { url: "http://get.sensiolabs.org/php-cs-fixer.phar", dest: /usr/local/bin/php-cs-fixer } - - { url: "https://github.com/sensiolabs-de/deprecation-detector/releases/download/0.1.0-alpha4/deprecation-detector.phar", dest: /usr/local/bin/deprecation-detector } - - { url: "https://github.com/sensiolabs-de/deprecation-detector/releases/download/0.1.0-alpha4/deprecation-detector.phar", dest: /usr/local/bin/deprecation-detector } - -- name: Install Tools via composer - raw: COMPOSER_HOME="/usr/local/composer" COMPOSER_BIN_DIR="/usr/local/bin" composer global require "{{ item.package }}" "{{ item.version }}" - with_items: - - { package: "sstalle/php7cc" , version: "*" } - - { package: "phpspec/phpspec" , version: "~2.0" } diff --git a/docker/php-dev/ubuntu-16.10/Dockerfile b/docker/php-dev/ubuntu-16.10/Dockerfile index 3d3752800..f236a7397 100644 --- a/docker/php-dev/ubuntu-16.10/Dockerfile +++ b/docker/php-dev/ubuntu-16.10/Dockerfile @@ -5,11 +5,6 @@ FROM webdevops/php:ubuntu-16.10 -MAINTAINER info@webdevops.io -LABEL vendor=WebDevOps.io -LABEL io.webdevops.layout=8 -LABEL io.webdevops.version=1.5.0 - COPY conf/ /opt/docker/ # Install development environment @@ -22,6 +17,8 @@ RUN wget -O - https://packagecloud.io/gpg.key | apt-key add - \ php-xdebug \ blackfire-php \ blackfire-agent \ + # Enable php development services + && docker-service-enable syslog ssh postfix \ && /opt/docker/bin/provision run --tag bootstrap --role webdevops-dev --role webdevops-php-dev \ - && /opt/docker/bin/bootstrap.sh - + && /opt/docker/bin/bootstrap.sh \ + && docker-image-cleanup diff --git a/docker/php-dev/ubuntu-16.10/Dockerfile.jinja2 b/docker/php-dev/ubuntu-16.10/Dockerfile.jinja2 index da4b27875..c8dffa64b 100644 --- a/docker/php-dev/ubuntu-16.10/Dockerfile.jinja2 +++ b/docker/php-dev/ubuntu-16.10/Dockerfile.jinja2 @@ -1,7 +1,5 @@ {{ docker.from("php", "ubuntu-16.10") }} -{{ docker.version() }} - {{ docker.copy('conf/', '/opt/docker/') }} {{ php7dev.ubuntu() }} diff --git a/docker/php-dev/ubuntu-16.10/conf/provision/entrypoint.d/10-php-debugger.sh b/docker/php-dev/ubuntu-16.10/conf/provision/entrypoint.d/10-php-debugger.sh index 7156e28aa..b5985a9ef 100644 --- a/docker/php-dev/ubuntu-16.10/conf/provision/entrypoint.d/10-php-debugger.sh +++ b/docker/php-dev/ubuntu-16.10/conf/provision/entrypoint.d/10-php-debugger.sh @@ -15,7 +15,8 @@ PHP_CONF_PATHS=" /etc/php5/fpm/conf.d /etc/php/7.0/mods-available /etc/php/7.0/cli/conf.d -/etc/php/7.0/fpm/conf.d" +/etc/php/7.0/fpm/conf.d +/usr/local/etc/php/conf.d/" function phpModuleRemove() { if [ "$#" -ne 1 ]; then @@ -40,7 +41,7 @@ if [[ -n "${PHP_DEBUGGER+x}" ]]; then blackfire) echo "PHP-Debugger: Blackfire enabled" phpModuleRemove "xdebug" - /opt/docker/bin/control.sh service.enable blackfire-agent + docker-service-enable blackfire-agent ;; none) diff --git a/docker/php-dev/ubuntu-16.10/conf/provision/roles/webdevops-dev/tasks/bootstrap.yml b/docker/php-dev/ubuntu-16.10/conf/provision/roles/webdevops-dev/tasks/bootstrap.yml index 5c9eafbd0..3d7a494ad 100644 --- a/docker/php-dev/ubuntu-16.10/conf/provision/roles/webdevops-dev/tasks/bootstrap.yml +++ b/docker/php-dev/ubuntu-16.10/conf/provision/roles/webdevops-dev/tasks/bootstrap.yml @@ -1,8 +1,5 @@ --- -- name: Enable ssh daemon - shell: "/opt/docker/bin/control.sh service.enable ssh" - - name: Set application user password user: name: "{{ APPLICATION_USER }}" diff --git a/docker/php-dev/ubuntu-16.10/conf/provision/roles/webdevops-php-dev/tasks/bootstrap.yml b/docker/php-dev/ubuntu-16.10/conf/provision/roles/webdevops-php-dev/tasks/bootstrap.yml index 2c5d76e3d..ff02b05fc 100644 --- a/docker/php-dev/ubuntu-16.10/conf/provision/roles/webdevops-php-dev/tasks/bootstrap.yml +++ b/docker/php-dev/ubuntu-16.10/conf/provision/roles/webdevops-php-dev/tasks/bootstrap.yml @@ -1,6 +1,5 @@ --- -- include: bootstrap/tools.yml - include: bootstrap/php-fpm.yml - include: bootstrap/php-module.yml - include: bootstrap/php-module.opcache.yml diff --git a/docker/php-dev/ubuntu-16.10/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/php-module.blackfire.yml b/docker/php-dev/ubuntu-16.10/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/php-module.blackfire.yml index 1a3db9bac..faf05f8de 100644 --- a/docker/php-dev/ubuntu-16.10/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/php-module.blackfire.yml +++ b/docker/php-dev/ubuntu-16.10/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/php-module.blackfire.yml @@ -7,4 +7,4 @@ with_items: - /etc/php5/cli/conf.d/zz-blackfire.ini - /etc/php5/fpm/conf.d/zz-blackfire.ini - when: ansible_distribution == 'Debian' and ansible_lsb.major_release|int >= 7 + when: ansible_distribution == 'Debian' and docker_image_info_distribution_version|int >= 7 diff --git a/docker/php-dev/ubuntu-16.10/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/tools.yml b/docker/php-dev/ubuntu-16.10/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/tools.yml deleted file mode 100644 index c49cb0e34..000000000 --- a/docker/php-dev/ubuntu-16.10/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/tools.yml +++ /dev/null @@ -1,23 +0,0 @@ ---- - -- name: Downloading Tools - shell: curl -o "{{ item.dest }}" "{{ item.url }}" && chmod 755 "{{ item.dest }}" - with_items: - - { url: "https://phar.phpunit.de/phploc.phar", dest: /usr/local/bin/phploc } - - { url: "https://phar.phpunit.de/phpunit.phar", dest: /usr/local/bin/phpunit } - - { url: "http://static.pdepend.org/php/latest/pdepend.phar", dest: /usr/local/bin/pdepend } - - { url: "http://static.phpmd.org/php/latest/phpmd.phar", dest: /usr/local/bin/phpmd } - - { url: "https://squizlabs.github.io/PHP_CodeSniffer/phpcs.phar", dest: /usr/local/bin/phpcs } - - { url: "https://squizlabs.github.io/PHP_CodeSniffer/phpcbf.phar", dest: /usr/local/bin/phpcbf } - - { url: "https://phar.phpunit.de/phpcpd.phar", dest: /usr/local/bin/phpcpd } - - { url: "https://phar.phpunit.de/phpdcd.phar", dest: /usr/local/bin/phpdcd } - - { url: "https://github.com/Halleck45/PhpMetrics/raw/master/build/phpmetrics.phar", dest: /usr/local/bin/phpmetrics } - - { url: "http://get.sensiolabs.org/php-cs-fixer.phar", dest: /usr/local/bin/php-cs-fixer } - - { url: "https://github.com/sensiolabs-de/deprecation-detector/releases/download/0.1.0-alpha4/deprecation-detector.phar", dest: /usr/local/bin/deprecation-detector } - - { url: "https://github.com/sensiolabs-de/deprecation-detector/releases/download/0.1.0-alpha4/deprecation-detector.phar", dest: /usr/local/bin/deprecation-detector } - -- name: Install Tools via composer - raw: COMPOSER_HOME="/usr/local/composer" COMPOSER_BIN_DIR="/usr/local/bin" composer global require "{{ item.package }}" "{{ item.version }}" - with_items: - - { package: "sstalle/php7cc" , version: "*" } - - { package: "phpspec/phpspec" , version: "~2.0" } diff --git a/docker/php-nginx-dev/5.6/Dockerfile b/docker/php-nginx-dev/5.6/Dockerfile new file mode 100644 index 000000000..d90a6c753 --- /dev/null +++ b/docker/php-nginx-dev/5.6/Dockerfile @@ -0,0 +1,23 @@ +#+++++++++++++++++++++++++++++++++++++++ +# Dockerfile for webdevops/php-nginx-dev:5.6 +# -- automatically generated -- +#+++++++++++++++++++++++++++++++++++++++ + +FROM webdevops/php-dev:5.6 + +ENV WEB_DOCUMENT_ROOT=/app \ + WEB_DOCUMENT_INDEX=index.php \ + WEB_ALIAS_DOMAIN=*.vm +ENV WEB_PHP_SOCKET=127.0.0.1:9000 +ENV WEB_NO_CACHE_PATTERN="\.(css|js|gif|png|jpg|svg|json|xml)$" + +COPY conf/ /opt/docker/ + +# Install nginx +RUN /usr/local/bin/apt-install \ + nginx \ + && /opt/docker/bin/provision run --tag bootstrap --role webdevops-nginx --role webdevops-php-nginx --role webdevops-nginx-dev --role webdevops-php-dev \ + && /opt/docker/bin/bootstrap.sh \ + && docker-image-cleanup + +EXPOSE 80 443 diff --git a/docker/php-nginx-dev/5.6/Dockerfile.jinja2 b/docker/php-nginx-dev/5.6/Dockerfile.jinja2 new file mode 100644 index 000000000..0ddd264a1 --- /dev/null +++ b/docker/php-nginx-dev/5.6/Dockerfile.jinja2 @@ -0,0 +1,11 @@ +{{ docker.from("php-dev", "5.6") }} + +{{ environment.web() }} +{{ environment.webPhp() }} +{{ environment.webDevelopment() }} + +{{ docker.copy('conf/', '/opt/docker/') }} + +{{ nginx.debian('php-nginx nginx-dev php-dev') }} + +{{ docker.expose('80 443') }} diff --git a/docker/php-nginx-dev/5.6/conf/bin/service.d/blackfire-agent.d/10-init.sh b/docker/php-nginx-dev/5.6/conf/bin/service.d/blackfire-agent.d/10-init.sh new file mode 100644 index 000000000..fdffa2a0f --- /dev/null +++ b/docker/php-nginx-dev/5.6/conf/bin/service.d/blackfire-agent.d/10-init.sh @@ -0,0 +1 @@ +# placeholder diff --git a/docker/php-nginx-dev/5.6/conf/bin/service.d/blackfire-agent.sh b/docker/php-nginx-dev/5.6/conf/bin/service.d/blackfire-agent.sh new file mode 100644 index 000000000..fbec23cf3 --- /dev/null +++ b/docker/php-nginx-dev/5.6/conf/bin/service.d/blackfire-agent.sh @@ -0,0 +1,23 @@ +#!/usr/bin/env bash +set -e + +source /opt/docker/bin/config.sh + +BLACKFIRE_ARGS="" + +includeScriptDir "/opt/docker/bin/service.d/syslog-ng.d/" + +# blackfire.server_id +if [[ -n "${BLACKFIRE_SERVER_ID+x}" ]]; then + BLACKFIRE_ARGS="$BLACKFIRE_ARGS --server-id=\"${BLACKFIRE_SERVER_ID}\"" +fi + +# blackfire.server_token +if [[ -n "${BLACKFIRE_SERVER_TOKEN+x}" ]]; then + BLACKFIRE_ARGS="$BLACKFIRE_ARGS --server-token=\"${BLACKFIRE_SERVER_TOKEN}\"" +fi + +# create directory for unix socket +mkdir -p /var/run/blackfire + +eval exec blackfire-agent $BLACKFIRE_ARGS diff --git a/docker/php-nginx-dev/5.6/conf/bin/service.d/nginx.d/10-init.sh b/docker/php-nginx-dev/5.6/conf/bin/service.d/nginx.d/10-init.sh new file mode 100644 index 000000000..27b9776cc --- /dev/null +++ b/docker/php-nginx-dev/5.6/conf/bin/service.d/nginx.d/10-init.sh @@ -0,0 +1,25 @@ +if [[ ! -e "$WEB_DOCUMENT_ROOT" ]]; then + echo "" + echo "[WARNING] WEB_DOCUMENT_ROOT does not exists with path \"$WEB_DOCUMENT_ROOT\"!" + echo "" +fi + +# Prevent startup of nginx (ubuntu 16.04 needs it) +ln -f -s /var/lib/nginx/logs /var/log/nginx + +# Replace markers +go-replace \ + -s "" -r "$WEB_DOCUMENT_INDEX" \ + -s "" -r "$WEB_DOCUMENT_ROOT" \ + -s "" -r "$WEB_ALIAS_DOMAIN" \ + -s "" -r "$HOSTNAME" \ + -s "" -r "$WEB_PHP_SOCKET" \ + --path=/opt/docker/etc/nginx/ \ + --path-pattern='*.conf' \ + --ignore-empty + +if [[ -z "${WEB_PHP_SOCKET+x}" ]]; then + ## WEB_PHP_SOCKET is not set, remove PHP files + rm -f -- /opt/docker/etc/nginx/conf.d/10-php.conf + rm -f -- /opt/docker/etc/nginx/vhost.common.d/10-php.conf +fi diff --git a/docker/php-nginx-dev/5.6/conf/bin/service.d/nginx.d/12-development.sh b/docker/php-nginx-dev/5.6/conf/bin/service.d/nginx.d/12-development.sh new file mode 100644 index 000000000..f4695f059 --- /dev/null +++ b/docker/php-nginx-dev/5.6/conf/bin/service.d/nginx.d/12-development.sh @@ -0,0 +1,7 @@ +go-replace \ + -s "" \ + -r "$WEB_NO_CACHE_PATTERN" \ + --path=/opt/docker/etc/nginx/ \ + --path-pattern='*.conf' \ + --ignore-empty + diff --git a/docker/php-nginx-dev/alpine-3-php7/conf/bin/service.d/nginx.sh b/docker/php-nginx-dev/5.6/conf/bin/service.d/nginx.sh similarity index 100% rename from docker/php-nginx-dev/alpine-3-php7/conf/bin/service.d/nginx.sh rename to docker/php-nginx-dev/5.6/conf/bin/service.d/nginx.sh diff --git a/docker/php-nginx-dev/5.6/conf/etc/nginx/conf.d/.gitkeep b/docker/php-nginx-dev/5.6/conf/etc/nginx/conf.d/.gitkeep new file mode 100644 index 000000000..e69de29bb diff --git a/docker/php-nginx-dev/5.6/conf/etc/nginx/conf.d/02-dev.conf b/docker/php-nginx-dev/5.6/conf/etc/nginx/conf.d/02-dev.conf new file mode 100644 index 000000000..fdffa2a0f --- /dev/null +++ b/docker/php-nginx-dev/5.6/conf/etc/nginx/conf.d/02-dev.conf @@ -0,0 +1 @@ +# placeholder diff --git a/docker/php-nginx-dev/alpine-3-php7/conf/etc/nginx/conf.d/10-php.conf b/docker/php-nginx-dev/5.6/conf/etc/nginx/conf.d/10-php.conf similarity index 100% rename from docker/php-nginx-dev/alpine-3-php7/conf/etc/nginx/conf.d/10-php.conf rename to docker/php-nginx-dev/5.6/conf/etc/nginx/conf.d/10-php.conf diff --git a/docker/php-nginx-dev/5.6/conf/etc/nginx/global.conf b/docker/php-nginx-dev/5.6/conf/etc/nginx/global.conf new file mode 100644 index 000000000..b6141db09 --- /dev/null +++ b/docker/php-nginx-dev/5.6/conf/etc/nginx/global.conf @@ -0,0 +1 @@ +# deprecated diff --git a/docker/php-nginx-dev/alpine-3-php7/conf/etc/nginx/main.conf b/docker/php-nginx-dev/5.6/conf/etc/nginx/main.conf similarity index 100% rename from docker/php-nginx-dev/alpine-3-php7/conf/etc/nginx/main.conf rename to docker/php-nginx-dev/5.6/conf/etc/nginx/main.conf diff --git a/docker/php-nginx-dev/5.6/conf/etc/nginx/php.conf b/docker/php-nginx-dev/5.6/conf/etc/nginx/php.conf new file mode 100644 index 000000000..b6141db09 --- /dev/null +++ b/docker/php-nginx-dev/5.6/conf/etc/nginx/php.conf @@ -0,0 +1 @@ +# deprecated diff --git a/docker/php-nginx-dev/5.6/conf/etc/nginx/ssl/server.crt b/docker/php-nginx-dev/5.6/conf/etc/nginx/ssl/server.crt new file mode 100644 index 000000000..6b0694907 --- /dev/null +++ b/docker/php-nginx-dev/5.6/conf/etc/nginx/ssl/server.crt @@ -0,0 +1,28 @@ +-----BEGIN CERTIFICATE----- +MIIE1DCCArwCCQDMMwGnSuK0tTANBgkqhkiG9w0BAQsFADAsMRswGQYDVQQKExJE +b2NrZXIgQm9pbGVycGxhdGUxDTALBgNVBAMUBCoudm0wHhcNMTUwNTA0MTcxNDQw +WhcNMjUwNTAxMTcxNDQwWjAsMRswGQYDVQQKExJEb2NrZXIgQm9pbGVycGxhdGUx +DTALBgNVBAMUBCoudm0wggIiMA0GCSqGSIb3DQEBAQUAA4ICDwAwggIKAoICAQDK +3TIUiyDvXelWeY9VXMrpjuZtYpVSDsACLpjFUhMnsP5/iKT0VbeZyqHvmwZjAg4G +Y10d+yZDdgv/xeu0HPOFbtR6pCp10d1tdLHZto5Cyuxu7IQsAVjnD6Ko7XFwtNk7 +9o6JZfAFaGL4w5MokrVmCtspnsMZH7/7zU4f96cbF39zLopnpuXGD6t6DA8Qj3gy +0duaTjs42bYRN+rwLzVKAev99iQ4kPMJn4vV6/Xk6rtoSzC67GQyVZYaFypicD1S +NtsRmgEVvjCBDbrLOneUiRwff6qxEsZi7Hxv7BKFj4iUWnII7K/nP7T6uBHQjHO+ +FpsGkU9lCMrCeVFBe8kKz/cbhd+yLUxXwAPr6gSOPmwn232Gy4tozvqZHpbUxsgx +7sT3ej9K66h1D7J+BjNFWYM1hbnC1r7H/xS7EBzBV8qRoQCVe08Juf5xsouXFakD +clLV4+L+1cxkpwsCQDly5g3tm/TBqA2O+ZJ+YHQDHKkzMyhLs6i0X/M5qvJBiLg1 +GLTCS20rpQ5gXTEGuINqHgwXQWkUO6bhgSYqdHGX3zbZ5+qWpI4eui3dHZ1Ll0VH +6Icpb7ORTQwhc6W8KBlybssYPSlGOEBGUjYGNheoz9FpoSkxCis+P8ZNKtrmpPoq +Su0eOOGFOFHG02eOgPVxSwrDeN9MVJo7BPysGMHJmQIDAQABMA0GCSqGSIb3DQEB +CwUAA4ICAQC63g6NHmQKbiy3G6iaDkpUSbr5Mq2YgU61XnvWVyREqDcy/BXCw9oY +SJ/KUvCpqPnACNOFqjadRAmPiA9nf2WduoCgwQGV/YRFGswSuVvh/3X2TX5NWvbS +t8MQDttQg1dxpiMUjlu3rqhfohBdWJvp2lVSdpDb/MOlXBc/+p7HfOHwhqB7wwPN +NNbSKUbZqZxmD8cOf1X0hASr1yfFPj+2vST3ESaON8S0T2p63YX/sD5jvOUiEuyw +I5WcvLmiRZA07SH8nWyckLY3qWL+OlhSZrlAnolWS00b+7h5LNuRYEjKzwVgntoA +aCopyQih6wIk0+AfJO4sfhJBmQhnIrAaP/zwBH5g9zVizLf5H7U+hNXrMwgw55Sq +vjMdkZHvPKUXTvVit/rYE9H+PY3brkRWzOl4V/i/ZLJJm5805H/NyTbz9kPMJw2Q +nn+KOpfXXySD39f8iuRgSKXsYNul38hxWgcZZ6g+sOOp2n/VUmf0eZUWNnJ8i7AP +4Qif7aDKMcibOwSwsB+DKZXDvZ5XSdnMphtuLS5rPSL81rVRmWC2DMfQ2eP8j0WN +VTroSk0xedQ7Qr+9TNooi9IyzX6n1a2S1UiciEZ3ZcDbXPl/P01m+IYZyPnLv0+9 +ZeioZYh1JLv3/OKsMrMLTfh2ZCj3aXwmc2Owi/wU2LS5QUOMcHH7CQ== +-----END CERTIFICATE----- \ No newline at end of file diff --git a/docker/php-nginx-dev/5.6/conf/etc/nginx/ssl/server.csr b/docker/php-nginx-dev/5.6/conf/etc/nginx/ssl/server.csr new file mode 100644 index 000000000..8a9909f77 --- /dev/null +++ b/docker/php-nginx-dev/5.6/conf/etc/nginx/ssl/server.csr @@ -0,0 +1,26 @@ +-----BEGIN CERTIFICATE REQUEST----- +MIIEcTCCAlkCAQAwLDEbMBkGA1UEChMSRG9ja2VyIEJvaWxlcnBsYXRlMQ0wCwYD +VQQDFAQqLnZtMIICIjANBgkqhkiG9w0BAQEFAAOCAg8AMIICCgKCAgEAyt0yFIsg +713pVnmPVVzK6Y7mbWKVUg7AAi6YxVITJ7D+f4ik9FW3mcqh75sGYwIOBmNdHfsm +Q3YL/8XrtBzzhW7UeqQqddHdbXSx2baOQsrsbuyELAFY5w+iqO1xcLTZO/aOiWXw +BWhi+MOTKJK1ZgrbKZ7DGR+/+81OH/enGxd/cy6KZ6blxg+regwPEI94MtHbmk47 +ONm2ETfq8C81SgHr/fYkOJDzCZ+L1ev15Oq7aEswuuxkMlWWGhcqYnA9UjbbEZoB +Fb4wgQ26yzp3lIkcH3+qsRLGYux8b+wShY+IlFpyCOyv5z+0+rgR0IxzvhabBpFP +ZQjKwnlRQXvJCs/3G4Xfsi1MV8AD6+oEjj5sJ9t9hsuLaM76mR6W1MbIMe7E93o/ +SuuodQ+yfgYzRVmDNYW5wta+x/8UuxAcwVfKkaEAlXtPCbn+cbKLlxWpA3JS1ePi +/tXMZKcLAkA5cuYN7Zv0wagNjvmSfmB0AxypMzMoS7OotF/zOaryQYi4NRi0wktt +K6UOYF0xBriDah4MF0FpFDum4YEmKnRxl9822efqlqSOHrot3R2dS5dFR+iHKW+z +kU0MIXOlvCgZcm7LGD0pRjhARlI2BjYXqM/RaaEpMQorPj/GTSra5qT6KkrtHjjh +hThRxtNnjoD1cUsKw3jfTFSaOwT8rBjByZkCAwEAAaAAMA0GCSqGSIb3DQEBCwUA +A4ICAQBsEBgC2YepuZq/8UqvKMZKVy/etDKXj7BB+QPb+leNiKD7p4LDxHJsZSH8 +Ku9uMPeLfiQDn5jA41k5SlGttzvObd65RdEbO3yHpqsg05EGSDDLfaE1k2Al/qmX +/o8roPZF7+2kZthgMAgkcokS54LYqEYTGqOf3J9Ss0yRIZwhaOVebfFIbIOdpw0B +JNMIJPHTMdZrcuRVI+wR1uPLIlEJzBvxTGbTrvPU25WJFtu+EajKqXO0SHdy0yx8 +uH4ykRBJRc36+oYo7nZ5D56dh7pZn3+9J64FKAOV0Q3KqMFieGy053ezuhJd70eZ +UozTgfjs3WpMzoYmKETSyl3XZSdInRe+sUlKPruTsKyg69oYxjPlrGfAmmGcCFca +TnZinT18dI92zK7OtOVkmYeYKC1lwuhftVrNMXzZuHOGpS9NNYtc4nDqDMIEOfV3 +6rCdu03WjEgJ+Z67tJs16xOx9du4/EHxS2Ijn9DPfVJvYy0TgzDi1BUpjWx0KTLx +C4OQbEZ/QTWmHVbSch/hcZhzbf7SNh5RpnW4EtmcpDFjIKMfxJmoKeiTf7qnilx0 +7uRvsZFKoDKRDOFiPfgMg5AOtLHziYsd9m0tJjC2GHvFuPjzOtzhnUUjmmvht170 +2aqKakjST4amg7jzLcs871HX0/WjOtt29NpOz140blkKf1bisg== +-----END CERTIFICATE REQUEST----- \ No newline at end of file diff --git a/docker/php-nginx-dev/5.6/conf/etc/nginx/ssl/server.key b/docker/php-nginx-dev/5.6/conf/etc/nginx/ssl/server.key new file mode 100644 index 000000000..c9eec145f --- /dev/null +++ b/docker/php-nginx-dev/5.6/conf/etc/nginx/ssl/server.key @@ -0,0 +1,51 @@ +-----BEGIN RSA PRIVATE KEY----- +MIIJKAIBAAKCAgEAyt0yFIsg713pVnmPVVzK6Y7mbWKVUg7AAi6YxVITJ7D+f4ik +9FW3mcqh75sGYwIOBmNdHfsmQ3YL/8XrtBzzhW7UeqQqddHdbXSx2baOQsrsbuyE +LAFY5w+iqO1xcLTZO/aOiWXwBWhi+MOTKJK1ZgrbKZ7DGR+/+81OH/enGxd/cy6K +Z6blxg+regwPEI94MtHbmk47ONm2ETfq8C81SgHr/fYkOJDzCZ+L1ev15Oq7aEsw +uuxkMlWWGhcqYnA9UjbbEZoBFb4wgQ26yzp3lIkcH3+qsRLGYux8b+wShY+IlFpy +COyv5z+0+rgR0IxzvhabBpFPZQjKwnlRQXvJCs/3G4Xfsi1MV8AD6+oEjj5sJ9t9 +hsuLaM76mR6W1MbIMe7E93o/SuuodQ+yfgYzRVmDNYW5wta+x/8UuxAcwVfKkaEA +lXtPCbn+cbKLlxWpA3JS1ePi/tXMZKcLAkA5cuYN7Zv0wagNjvmSfmB0AxypMzMo +S7OotF/zOaryQYi4NRi0wkttK6UOYF0xBriDah4MF0FpFDum4YEmKnRxl9822efq +lqSOHrot3R2dS5dFR+iHKW+zkU0MIXOlvCgZcm7LGD0pRjhARlI2BjYXqM/RaaEp +MQorPj/GTSra5qT6KkrtHjjhhThRxtNnjoD1cUsKw3jfTFSaOwT8rBjByZkCAwEA +AQKCAgAbZPdoUsllyZbC+LNkYZ19ILD5QIDNjfRb1xMGQmkXyQz1B+zOmeyrNfPc +OWEJabOfJTfj3pByN7SzG3US4333HNpQnW6mbmqqZ0HFFqPrXR/Ecuf+UUhCG5hp +m3bgM2vKbyccYsmg0VHcKfzrU7RvTTP/UNMjx2fThwvvwS+ttuSdF0HVcXJB5sfP +OWWnZNhkdHZlRf81VCED/jsZqCZYEh5eMyj9AoXvXL4zayPPf+tC0DSKaXW2Xlxg +tZQhqup8+a9nlxZia0Z9hu8clo6jXkiP8FuKgfCMV0cOjiCKLLHS5svTbLLsVWwJ +F2ZAdVcD6mWQ43qHOEK5NEzGvQKO14CaOLnVT2yAkMcyNohsEgoDP9oCBGDJQbBH +NmtZfpVjjtuTr9P9TEkU1FcBRo0x6Il/DkzamGbOeFAmgnaGElhJ5c/CAG7whaIf +mUfFOBGPH/wESY3gBOACDofeSh27RrlvbLaPiCGKivDUTBmhBsIuso6XqOKbvtfV +/HhhndpdRVfIj4DdE7gIrLIGN977JMVAXFCNz7KrvAWwcOXrCHCoWpklJ9repq8l +26ICY8K7VXktzDHQUmhd88ZWR+9ASURsJghUgZUOcMrEGyvci6Y8hpLhHiNVPHuQ ++ps7tpPsXSntBUqWBzhRZh74+nJlOOV6oYykl30JT2JzB6lwiQKCAQEA9ecn8N2z +20tR2UEiTv/MjVSepQtAAajegvcd1iasvvQKXnh3XLmoZHzH2tTa0lp5RIZpUQPl +lOTwko0lYTBnYblt65AJQ3FTgisNobIpoqE8BFXLm6wggz7CbabjmPGDe173lPGR +sI0YSKYvzrdn4zw8Fh6WULJyZHLi58zJYL3r0WBDiOoxpGaGA1GlmkuIWjhKHaX2 +OvF1vOuQDJ2eDyTc5TYFC0NKG76Mvanov5L/yrhNM/umbmp0SPspzHGZobAKUr20 +OazFT8S+2TA1OTxWNbiPbSimFoaZbEdqsNACGfVJWO8Sh8iqlt5RmEcSiSvGBj6L +QKprRO9Fsp2GawKCAQEA0zGhRsnux4JTNsdUSYsEJtITMj6eE+nl7CoZ9DAOwC5X +6/aSpUE4TT+pWNrt9iluXiGL0j89UJ7r/L1OcsiyzGb8ig9NU4zr1NIGTZ0DstHi +HPYINjeiBJEFIy17kOQn+9/I5c4hBUwz6ihwNoEomymVB/EsLJKAML0AudJGKg+Z +/f/qrS40eab5SAiaKgsh0MZnj+vIxyGBydt6r2HGmjfNITVbXIu6IpO+6NXDwM/e +7v10AAZ3j9+gb1RedLg2ghuIuYU90hmMhtVWsh9nVmaOkMW9/WFgOPYvt/mHH/hR +d4pePZ9kACGmqo/b9sHvHw1YEubtCt1VUiNuFxnJCwKCAQBWnxz0vkRTJY8phsY9 +KeK2jm5sGTBs5T2syLwb6ffENFdKvAjgAw6Mh2And/+1ReWd+/MxdLv03UjZdxsJ +x3FDfXx5FH4O4ebW3a+pnAcKoN1xcX+N0O6LDRqUYcue3sTAOs3gC9CUbr91KAWD +Phw8ccWAzTmKJ7IgLFA982ekyoI9eTmRC159WRgwJxy844qerWF+XC4GyXP+HsTZ +jNRW5Vdi7sqMEyIR7+fIEAhLI88zbATWIPmZv6pC4ybwO7wwtsCMMQNBpdjDprzL +6S12ggikV+U+QKlxGe0FtYqhykRTPJKf32eZqVheWOZJTA/9fgv9ux52oxGycM8O +gmsNAoIBAQC60m5uZnd5uYnPLWkcXYNgq/kbO1UvHHut/FhVMKX7z4MrU0XKNfWO +MECoP5K9bU0aq+Y6KIMe7FapjvT0iSHRu1Cu+HZY8JI2A0xcIAeDijLRl7sP6wrB +q1+2DKgANjRAlWfsEfoX658JBpitPngjOheBnRCMpVQMyUT5HE/BKWf5zwdUB0mY +S+K8nA90HcDeJIS8RcGolbVwUV0oBABhr/cf50lYhqozqCr7YQ33ZGs7Uq3oz8+4 +UARmN2YPLl3Znm3GX12em8c6B0LX8vvA7Jw06Rf2Ksup1+3Ce1PTLiEy9A4FyRf3 +Hc2HmBbnJAtZlr5QikMqlzzAmmLqwH6dAoIBAC+ryaQGJFsijCSuaDfRp/uy9xnd +DjgMdTwjl5WLBmyudChVMANl8eqCbvVO41CN84yORk03oQ4cx0eKxAZaLaSzgkb3 +W0X2nFQe7VJSYMQswCQ+1WfJvEFrIdkEKIa//uQdhqNrgUKSNVhhSTMbNEkDTIWn +ssbv2H9hvUaFt/J/vP9zCKuU5oYvNU7Oi6ZXRYezRn9atlJYanLFoJnHUBRzGms5 +K0vhdCPDXQq87z5Yudoh0jLUQF9Nx0GTWeBceQ9n5hZeRUNQWxP4AJThQX9KSPTS +mbL3Kh4XNRmAUJ2N+Njh+3dg91s+JkKvC1wcspLsmLPQe+9AxBSH9y5JE/8= +-----END RSA PRIVATE KEY----- \ No newline at end of file diff --git a/docker/php-nginx-dev/alpine-3-php7/conf/etc/nginx/vhost.common.conf b/docker/php-nginx-dev/5.6/conf/etc/nginx/vhost.common.conf similarity index 100% rename from docker/php-nginx-dev/alpine-3-php7/conf/etc/nginx/vhost.common.conf rename to docker/php-nginx-dev/5.6/conf/etc/nginx/vhost.common.conf diff --git a/docker/php-nginx-dev/5.6/conf/etc/nginx/vhost.common.d/.gitkeep b/docker/php-nginx-dev/5.6/conf/etc/nginx/vhost.common.d/.gitkeep new file mode 100644 index 000000000..e69de29bb diff --git a/docker/php-nginx-dev/alpine-3-php7/conf/etc/nginx/vhost.common.d/02-dev.conf b/docker/php-nginx-dev/5.6/conf/etc/nginx/vhost.common.d/02-dev.conf similarity index 100% rename from docker/php-nginx-dev/alpine-3-php7/conf/etc/nginx/vhost.common.d/02-dev.conf rename to docker/php-nginx-dev/5.6/conf/etc/nginx/vhost.common.d/02-dev.conf diff --git a/docker/php-nginx-dev/5.6/conf/etc/nginx/vhost.common.d/10-general.conf b/docker/php-nginx-dev/5.6/conf/etc/nginx/vhost.common.d/10-general.conf new file mode 100644 index 000000000..d3fd0aa5e --- /dev/null +++ b/docker/php-nginx-dev/5.6/conf/etc/nginx/vhost.common.d/10-general.conf @@ -0,0 +1 @@ +client_max_body_size 50m; diff --git a/docker/php-nginx-dev/alpine-3-php7/conf/etc/nginx/vhost.common.d/10-location-root.conf b/docker/php-nginx-dev/5.6/conf/etc/nginx/vhost.common.d/10-location-root.conf similarity index 100% rename from docker/php-nginx-dev/alpine-3-php7/conf/etc/nginx/vhost.common.d/10-location-root.conf rename to docker/php-nginx-dev/5.6/conf/etc/nginx/vhost.common.d/10-location-root.conf diff --git a/docker/php-nginx-dev/5.6/conf/etc/nginx/vhost.common.d/10-log.conf b/docker/php-nginx-dev/5.6/conf/etc/nginx/vhost.common.d/10-log.conf new file mode 100644 index 000000000..a2cd929e7 --- /dev/null +++ b/docker/php-nginx-dev/5.6/conf/etc/nginx/vhost.common.d/10-log.conf @@ -0,0 +1,2 @@ +access_log /docker.stdout; +error_log /docker.stderr info; diff --git a/docker/php-nginx-dev/alpine-3-php7/conf/etc/nginx/vhost.common.d/10-php.conf b/docker/php-nginx-dev/5.6/conf/etc/nginx/vhost.common.d/10-php.conf similarity index 100% rename from docker/php-nginx-dev/alpine-3-php7/conf/etc/nginx/vhost.common.d/10-php.conf rename to docker/php-nginx-dev/5.6/conf/etc/nginx/vhost.common.d/10-php.conf diff --git a/docker/php-nginx-dev/5.6/conf/etc/nginx/vhost.conf b/docker/php-nginx-dev/5.6/conf/etc/nginx/vhost.conf new file mode 100644 index 000000000..8225f314a --- /dev/null +++ b/docker/php-nginx-dev/5.6/conf/etc/nginx/vhost.conf @@ -0,0 +1,26 @@ +server { + listen 80 default_server; + + server_name _ docker; + + root ""; + index ; + + include /opt/docker/etc/nginx/vhost.common.d/*.conf; +} + +############## +# SSL +############## + +server { + listen 443 default_server; + + server_name _ docker; + + root ""; + index ; + + include /opt/docker/etc/nginx/vhost.common.d/*.conf; + include /opt/docker/etc/nginx/vhost.ssl.conf; +} diff --git a/docker/php-nginx-dev/alpine-3-php7/conf/etc/nginx/vhost.ssl.conf b/docker/php-nginx-dev/5.6/conf/etc/nginx/vhost.ssl.conf similarity index 100% rename from docker/php-nginx-dev/alpine-3-php7/conf/etc/nginx/vhost.ssl.conf rename to docker/php-nginx-dev/5.6/conf/etc/nginx/vhost.ssl.conf diff --git a/docker/php-nginx-dev/5.6/conf/etc/supervisor.d/blackfire-agent.conf b/docker/php-nginx-dev/5.6/conf/etc/supervisor.d/blackfire-agent.conf new file mode 100644 index 000000000..897831ddb --- /dev/null +++ b/docker/php-nginx-dev/5.6/conf/etc/supervisor.d/blackfire-agent.conf @@ -0,0 +1,14 @@ +[group:blackfire-agent] +programs=blackfire-agentd +priority=25 + +[program:blackfire-agentd] +command = /opt/docker/bin/service.d/blackfire-agent.sh +process_name=%(program_name)s +startsecs = 0 +autostart = false +autorestart = true +stdout_logfile=/dev/stdout +stdout_logfile_maxbytes=0 +stderr_logfile=/dev/stderr +stderr_logfile_maxbytes=0 diff --git a/docker/php-nginx-dev/alpine-3-php7/conf/etc/supervisor.d/nginx.conf b/docker/php-nginx-dev/5.6/conf/etc/supervisor.d/nginx.conf similarity index 100% rename from docker/php-nginx-dev/alpine-3-php7/conf/etc/supervisor.d/nginx.conf rename to docker/php-nginx-dev/5.6/conf/etc/supervisor.d/nginx.conf diff --git a/docker/php-nginx-dev/5.6/conf/provision/entrypoint.d/10-php-debugger.sh b/docker/php-nginx-dev/5.6/conf/provision/entrypoint.d/10-php-debugger.sh new file mode 100644 index 000000000..b5985a9ef --- /dev/null +++ b/docker/php-nginx-dev/5.6/conf/provision/entrypoint.d/10-php-debugger.sh @@ -0,0 +1,96 @@ +#!/usr/bin/env bash + +################################################# +# Debugger switch +################################################# + +PHP_CONF_PATHS=" +/etc/php5/conf.d +/etc/php7/conf.d +/etc/php.d +/etc/php5/mods-available +/etc/php5/cli/conf.d +/etc/php5/cli/conf.d +/etc/php5/fpm/conf.d +/etc/php5/fpm/conf.d +/etc/php/7.0/mods-available +/etc/php/7.0/cli/conf.d +/etc/php/7.0/fpm/conf.d +/usr/local/etc/php/conf.d/" + +function phpModuleRemove() { + if [ "$#" -ne 1 ]; then + echo "You must specify the name of the PHP module which you want to disable" + exit 1 + fi + + echo " - Removing PHP module ${1}" + for CONF_PATH in $PHP_CONF_PATHS; do + rm -f "${CONF_PATH}"/*"${1}".ini + done +} + + +if [[ -n "${PHP_DEBUGGER+x}" ]]; then + case "$PHP_DEBUGGER" in + xdebug) + echo "PHP-Debugger: Xdebug enabled" + phpModuleRemove "blackfire" + ;; + + blackfire) + echo "PHP-Debugger: Blackfire enabled" + phpModuleRemove "xdebug" + docker-service-enable blackfire-agent + ;; + + none) + echo "PHP-Debugger: none" + phpModuleRemove "blackfire" + phpModuleRemove "xdebug" + ;; + esac + +else + + echo "PHP-Debugger: not specified - default is xdebug" + phpModuleRemove "blackfire" + +fi + +################################################# +# PHP debugger environment variables +################################################# + +function phpEnvironmentVariable() { + PHP_INI_KEY="$1" + PHP_ENV_NAME="$2" + + if [[ -n "${!PHP_ENV_NAME+x}" ]]; then + PHP_ENV_VALUE="${!PHP_ENV_NAME}" + echo "${PHP_INI_KEY}=\"${PHP_ENV_VALUE}\"" >> /opt/docker/etc/php/php.ini + fi +} + +################### +# XDEBUG +################### + +# remote debugger +phpEnvironmentVariable "xdebug.remote_connect_back" "XDEBUG_REMOTE_CONNECT_BACK" +phpEnvironmentVariable "xdebug.remote_autostart" "XDEBUG_REMOTE_AUTOSTART" +phpEnvironmentVariable "xdebug.remote_host" "XDEBUG_REMOTE_HOST" +phpEnvironmentVariable "xdebug.remote_port" "XDEBUG_REMOTE_PORT" + +# profiler +phpEnvironmentVariable "xdebug.profiler_enable" "XDEBUG_PROFILER_ENABLE" +phpEnvironmentVariable "xdebug.profiler_enable_trigger" "XDEBUG_PROFILER_ENABLE_TRIGGER" +phpEnvironmentVariable "xdebug.profiler_enable_trigger_value" "XDEBUG_PROFILER_ENABLE_TRIGGER_VALUE" +phpEnvironmentVariable "xdebug.profiler_output_dir" "XDEBUG_PROFILER_OUTPUT_DIR" +phpEnvironmentVariable "xdebug.profiler_output_name" "XDEBUG_PROFILER_OUTPUT_NAME" + +################### +# BLACKFIRE +################### +phpEnvironmentVariable "blackfire.server_id" "BLACKFIRE_SERVER_ID" +phpEnvironmentVariable "blackfire.server_token" "BLACKFIRE_SERVER_TOKEN" diff --git a/docker/php-nginx-dev/5.6/conf/provision/roles/webdevops-nginx-dev/defaults/main.yml b/docker/php-nginx-dev/5.6/conf/provision/roles/webdevops-nginx-dev/defaults/main.yml new file mode 100644 index 000000000..81f5b7efd --- /dev/null +++ b/docker/php-nginx-dev/5.6/conf/provision/roles/webdevops-nginx-dev/defaults/main.yml @@ -0,0 +1,6 @@ +--- + +APPLICATION_USER: "{{ lookup('env','APPLICATION_USER') }}" +APPLICATION_GROUP: "{{ lookup('env','APPLICATION_GROUP') }}" +APPLICATION_UID: "{{ lookup('env','APPLICATION_UID') }}" +APPLICATION_GID: "{{ lookup('env','APPLICATION_GID') }}" diff --git a/docker/php-nginx-dev/alpine-3-php7/conf/provision/roles/webdevops-nginx-dev/tasks/bootstrap.yml b/docker/php-nginx-dev/5.6/conf/provision/roles/webdevops-nginx-dev/tasks/bootstrap.yml similarity index 100% rename from docker/php-nginx-dev/alpine-3-php7/conf/provision/roles/webdevops-nginx-dev/tasks/bootstrap.yml rename to docker/php-nginx-dev/5.6/conf/provision/roles/webdevops-nginx-dev/tasks/bootstrap.yml diff --git a/docker/php-nginx-dev/alpine-3-php7/conf/provision/roles/webdevops-nginx-dev/tasks/bootstrap/nginx.yml b/docker/php-nginx-dev/5.6/conf/provision/roles/webdevops-nginx-dev/tasks/bootstrap/nginx.yml similarity index 100% rename from docker/php-nginx-dev/alpine-3-php7/conf/provision/roles/webdevops-nginx-dev/tasks/bootstrap/nginx.yml rename to docker/php-nginx-dev/5.6/conf/provision/roles/webdevops-nginx-dev/tasks/bootstrap/nginx.yml diff --git a/docker/php-nginx-dev/5.6/conf/provision/roles/webdevops-nginx-dev/tasks/main.yml b/docker/php-nginx-dev/5.6/conf/provision/roles/webdevops-nginx-dev/tasks/main.yml new file mode 100644 index 000000000..1806c1a8c --- /dev/null +++ b/docker/php-nginx-dev/5.6/conf/provision/roles/webdevops-nginx-dev/tasks/main.yml @@ -0,0 +1,5 @@ +--- + +- include: bootstrap.yml + tags: + - bootstrap diff --git a/docker/php-nginx-dev/5.6/conf/provision/roles/webdevops-nginx/defaults/main.yml b/docker/php-nginx-dev/5.6/conf/provision/roles/webdevops-nginx/defaults/main.yml new file mode 100644 index 000000000..69cba1cb4 --- /dev/null +++ b/docker/php-nginx-dev/5.6/conf/provision/roles/webdevops-nginx/defaults/main.yml @@ -0,0 +1,3 @@ +--- + +DOCUMENT_ROOT: "{{ lookup('env','WEB_DOCUMENT_ROOT') }}" diff --git a/docker/php-nginx-dev/alpine-3-php7/conf/provision/roles/webdevops-nginx/tasks/bootstrap.yml b/docker/php-nginx-dev/5.6/conf/provision/roles/webdevops-nginx/tasks/bootstrap.yml similarity index 100% rename from docker/php-nginx-dev/alpine-3-php7/conf/provision/roles/webdevops-nginx/tasks/bootstrap.yml rename to docker/php-nginx-dev/5.6/conf/provision/roles/webdevops-nginx/tasks/bootstrap.yml diff --git a/docker/php-nginx-dev/5.6/conf/provision/roles/webdevops-nginx/tasks/main.yml b/docker/php-nginx-dev/5.6/conf/provision/roles/webdevops-nginx/tasks/main.yml new file mode 100644 index 000000000..1806c1a8c --- /dev/null +++ b/docker/php-nginx-dev/5.6/conf/provision/roles/webdevops-nginx/tasks/main.yml @@ -0,0 +1,5 @@ +--- + +- include: bootstrap.yml + tags: + - bootstrap diff --git a/docker/php-nginx-dev/5.6/conf/provision/roles/webdevops-php-dev/defaults/main.yml b/docker/php-nginx-dev/5.6/conf/provision/roles/webdevops-php-dev/defaults/main.yml new file mode 100644 index 000000000..81f5b7efd --- /dev/null +++ b/docker/php-nginx-dev/5.6/conf/provision/roles/webdevops-php-dev/defaults/main.yml @@ -0,0 +1,6 @@ +--- + +APPLICATION_USER: "{{ lookup('env','APPLICATION_USER') }}" +APPLICATION_GROUP: "{{ lookup('env','APPLICATION_GROUP') }}" +APPLICATION_UID: "{{ lookup('env','APPLICATION_UID') }}" +APPLICATION_GID: "{{ lookup('env','APPLICATION_GID') }}" diff --git a/docker/php-nginx-dev/5.6/conf/provision/roles/webdevops-php-dev/tasks/bootstrap.yml b/docker/php-nginx-dev/5.6/conf/provision/roles/webdevops-php-dev/tasks/bootstrap.yml new file mode 100644 index 000000000..ff02b05fc --- /dev/null +++ b/docker/php-nginx-dev/5.6/conf/provision/roles/webdevops-php-dev/tasks/bootstrap.yml @@ -0,0 +1,7 @@ +--- + +- include: bootstrap/php-fpm.yml +- include: bootstrap/php-module.yml +- include: bootstrap/php-module.opcache.yml +- include: bootstrap/php-module.xdebug.yml +- include: bootstrap/php-module.blackfire.yml diff --git a/docker/php-nginx-dev/5.6/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/php-fpm.yml b/docker/php-nginx-dev/5.6/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/php-fpm.yml new file mode 100644 index 000000000..9455a78e2 --- /dev/null +++ b/docker/php-nginx-dev/5.6/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/php-fpm.yml @@ -0,0 +1,18 @@ +--- + +- name: Configure php-fpm pool user (application.conf) + lineinfile: + dest: '/opt/docker/etc/php/fpm/pool.d/application.conf' + regexp: '^[\s;]*{{ item.key }}[\s]*=' + line: '{{ item.key }} = {{ item.value }}' + with_items: + - { key: 'access.log', value: "/docker.stdout" } + - { key: "access.format", value: '"%R - %u %t \"%m %r%Q%q\" %s %f cpu:%C%% mem:%{megabytes}M reqTime:%d"' } + +- name: Open php-fpm for external connections (eg. debuggers) + lineinfile: + dest: '/opt/docker/etc/php/fpm/pool.d/application.conf' + regexp: '^[\s;]*{{ item.key }}[\s]*=' + line: '{{ item.key }} = {{ item.value }}' + with_items: + - { key: 'listen', value: "0.0.0.0:9000" } diff --git a/docker/php-nginx-dev/5.6/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/php-module.blackfire.yml b/docker/php-nginx-dev/5.6/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/php-module.blackfire.yml new file mode 100644 index 000000000..faf05f8de --- /dev/null +++ b/docker/php-nginx-dev/5.6/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/php-module.blackfire.yml @@ -0,0 +1,10 @@ +--- + +- name: Remove superfluous blackfire configuration file + file: + path: '{{ item }}' + state: absent + with_items: + - /etc/php5/cli/conf.d/zz-blackfire.ini + - /etc/php5/fpm/conf.d/zz-blackfire.ini + when: ansible_distribution == 'Debian' and docker_image_info_distribution_version|int >= 7 diff --git a/docker/php-nginx-dev/5.6/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/php-module.opcache.yml b/docker/php-nginx-dev/5.6/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/php-module.opcache.yml new file mode 100644 index 000000000..9c243a671 --- /dev/null +++ b/docker/php-nginx-dev/5.6/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/php-module.opcache.yml @@ -0,0 +1,14 @@ +--- + +- name: Setup php.ini for development environment + lineinfile: + dest: '/opt/docker/etc/php/php.webdevops.ini' + regexp: '^[\s;]*{{ item.variable }}[\s]*=' + line: '{{ item.variable }} = {{ item.value }}' + with_items: + - { variable: 'opcache.memory_consumption', value: '256' } + - { variable: 'opcache.validate_timestamps', value: '1' } + - { variable: 'opcache.revalidate_freq', value: '0' } + - { variable: 'opcache.interned_strings_buffer', value: '16' } + - { variable: 'opcache.max_accelerated_files', value: '7963' } + - { variable: 'opcache.fast_shutdown', value: '1' } diff --git a/docker/php-nginx-dev/5.6/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/php-module.xdebug.yml b/docker/php-nginx-dev/5.6/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/php-module.xdebug.yml new file mode 100644 index 000000000..7f20c845e --- /dev/null +++ b/docker/php-nginx-dev/5.6/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/php-module.xdebug.yml @@ -0,0 +1,28 @@ +--- + +# Ignored on php7 +- name: Fix php xdebug module [Alpine family] + lineinfile: + dest: '{{ item }}' + regexp: 'extension=xdebug.so' + line: 'zend_extension=xdebug.so' + when: ansible_distribution == 'Alpine' + with_items: + - /etc/php5/conf.d/xdebug.ini + - /etc/php7/conf.d/xdebug.ini + ignore_errors: yes + +- name: Setup php.ini for development environment + lineinfile: + dest: '/opt/docker/etc/php/php.webdevops.ini' + regexp: '^[\s;]*{{ item.variable }}[\s]*=' + line: '{{ item.variable }} = {{ item.value }}' + with_items: + - { variable: 'xdebug.remote_enable', value: '1' } + - { variable: 'xdebug.remote_connect_back', value: '1' } + - { variable: 'xdebug.idekey', value: 'docker' } + - { variable: 'xdebug.cli_color', value: '1' } + - { variable: 'xdebug.max_nesting_level', value: '1000' } + - { variable: 'xdebug.profiler_enable_trigger', value: '1000' } + - { variable: 'xdebug.profiler_output_dir', value: '/tmp/debug/' } + - { variable: 'xhprof.output_dir', value: '/tmp/debug/' } diff --git a/docker/php-nginx-dev/5.6/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/php-module.yml b/docker/php-nginx-dev/5.6/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/php-module.yml new file mode 100644 index 000000000..31cccd1ae --- /dev/null +++ b/docker/php-nginx-dev/5.6/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/php-module.yml @@ -0,0 +1,41 @@ +--- + +############################# +# Workaround PHP configuration files +# for alpine +############################# + +- name: Get list of PHP5 configuration files + command: "ls /etc/php5/conf.d/ |grep .ini" + register: php5_ini + when: ansible_distribution == 'Alpine' + ignore_errors: yes + +- name: Link configuration files from php5 to php + file: + src: '/etc/php5/conf.d/{{ item }}' + dest: '/etc/php/conf.d/{{ item }}' + state: link + with_items: "{{ php5_ini.stdout_lines }}" + when: ansible_distribution == 'Alpine' and php5_ini is defined + ignore_errors: yes + +############################# +# Workaround PHP module files +# for alpine +############################# + +- name: Get list of PHP5 modules + command: "ls /usr/lib/php5/modules/ |grep .so" + register: php5_modules + when: ansible_distribution == 'Alpine' + ignore_errors: yes + +- name: Link module files from php5 to php + file: + src: '/usr/lib/php5/modules/{{ item }}' + dest: '/usr/lib/php/modules/{{ item }}' + state: link + with_items: "{{ php5_modules.stdout_lines }}" + when: ansible_distribution == 'Alpine' and php5_modules is defined + ignore_errors: yes diff --git a/docker/php-nginx-dev/5.6/conf/provision/roles/webdevops-php-dev/tasks/main.yml b/docker/php-nginx-dev/5.6/conf/provision/roles/webdevops-php-dev/tasks/main.yml new file mode 100644 index 000000000..1806c1a8c --- /dev/null +++ b/docker/php-nginx-dev/5.6/conf/provision/roles/webdevops-php-dev/tasks/main.yml @@ -0,0 +1,5 @@ +--- + +- include: bootstrap.yml + tags: + - bootstrap diff --git a/docker/php-nginx-dev/5.6/conf/provision/roles/webdevops-php-nginx/defaults/main.yml b/docker/php-nginx-dev/5.6/conf/provision/roles/webdevops-php-nginx/defaults/main.yml new file mode 100644 index 000000000..ed97d539c --- /dev/null +++ b/docker/php-nginx-dev/5.6/conf/provision/roles/webdevops-php-nginx/defaults/main.yml @@ -0,0 +1 @@ +--- diff --git a/docker/php-nginx-dev/alpine-3-php7/conf/provision/roles/webdevops-php-nginx/tasks/bootstrap.yml b/docker/php-nginx-dev/5.6/conf/provision/roles/webdevops-php-nginx/tasks/bootstrap.yml similarity index 100% rename from docker/php-nginx-dev/alpine-3-php7/conf/provision/roles/webdevops-php-nginx/tasks/bootstrap.yml rename to docker/php-nginx-dev/5.6/conf/provision/roles/webdevops-php-nginx/tasks/bootstrap.yml diff --git a/docker/php-nginx-dev/5.6/conf/provision/roles/webdevops-php-nginx/tasks/entrypoint.yml b/docker/php-nginx-dev/5.6/conf/provision/roles/webdevops-php-nginx/tasks/entrypoint.yml new file mode 100644 index 000000000..cd21505a4 --- /dev/null +++ b/docker/php-nginx-dev/5.6/conf/provision/roles/webdevops-php-nginx/tasks/entrypoint.yml @@ -0,0 +1,2 @@ +--- + diff --git a/docker/php-nginx-dev/5.6/conf/provision/roles/webdevops-php-nginx/tasks/main.yml b/docker/php-nginx-dev/5.6/conf/provision/roles/webdevops-php-nginx/tasks/main.yml new file mode 100644 index 000000000..7895a52a9 --- /dev/null +++ b/docker/php-nginx-dev/5.6/conf/provision/roles/webdevops-php-nginx/tasks/main.yml @@ -0,0 +1,9 @@ +--- + +- include: bootstrap.yml + tags: + - bootstrap + +- include: entrypoint.yml + tags: + - entrypoint diff --git a/docker/php-nginx-dev/7.0/Dockerfile b/docker/php-nginx-dev/7.0/Dockerfile new file mode 100644 index 000000000..a8373c551 --- /dev/null +++ b/docker/php-nginx-dev/7.0/Dockerfile @@ -0,0 +1,23 @@ +#+++++++++++++++++++++++++++++++++++++++ +# Dockerfile for webdevops/php-nginx-dev:7.0 +# -- automatically generated -- +#+++++++++++++++++++++++++++++++++++++++ + +FROM webdevops/php-dev:7.0 + +ENV WEB_DOCUMENT_ROOT=/app \ + WEB_DOCUMENT_INDEX=index.php \ + WEB_ALIAS_DOMAIN=*.vm +ENV WEB_PHP_SOCKET=127.0.0.1:9000 +ENV WEB_NO_CACHE_PATTERN="\.(css|js|gif|png|jpg|svg|json|xml)$" + +COPY conf/ /opt/docker/ + +# Install nginx +RUN /usr/local/bin/apt-install \ + nginx \ + && /opt/docker/bin/provision run --tag bootstrap --role webdevops-nginx --role webdevops-php-nginx --role webdevops-nginx-dev --role webdevops-php-dev \ + && /opt/docker/bin/bootstrap.sh \ + && docker-image-cleanup + +EXPOSE 80 443 diff --git a/docker/php-nginx-dev/7.0/Dockerfile.jinja2 b/docker/php-nginx-dev/7.0/Dockerfile.jinja2 new file mode 100644 index 000000000..540a89b14 --- /dev/null +++ b/docker/php-nginx-dev/7.0/Dockerfile.jinja2 @@ -0,0 +1,11 @@ +{{ docker.from("php-dev", "7.0") }} + +{{ environment.web() }} +{{ environment.webPhp() }} +{{ environment.webDevelopment() }} + +{{ docker.copy('conf/', '/opt/docker/') }} + +{{ nginx.debian('php-nginx nginx-dev php-dev') }} + +{{ docker.expose('80 443') }} diff --git a/docker/php-nginx-dev/7.0/conf/bin/service.d/blackfire-agent.d/10-init.sh b/docker/php-nginx-dev/7.0/conf/bin/service.d/blackfire-agent.d/10-init.sh new file mode 100644 index 000000000..fdffa2a0f --- /dev/null +++ b/docker/php-nginx-dev/7.0/conf/bin/service.d/blackfire-agent.d/10-init.sh @@ -0,0 +1 @@ +# placeholder diff --git a/docker/php-nginx-dev/7.0/conf/bin/service.d/blackfire-agent.sh b/docker/php-nginx-dev/7.0/conf/bin/service.d/blackfire-agent.sh new file mode 100644 index 000000000..fbec23cf3 --- /dev/null +++ b/docker/php-nginx-dev/7.0/conf/bin/service.d/blackfire-agent.sh @@ -0,0 +1,23 @@ +#!/usr/bin/env bash +set -e + +source /opt/docker/bin/config.sh + +BLACKFIRE_ARGS="" + +includeScriptDir "/opt/docker/bin/service.d/syslog-ng.d/" + +# blackfire.server_id +if [[ -n "${BLACKFIRE_SERVER_ID+x}" ]]; then + BLACKFIRE_ARGS="$BLACKFIRE_ARGS --server-id=\"${BLACKFIRE_SERVER_ID}\"" +fi + +# blackfire.server_token +if [[ -n "${BLACKFIRE_SERVER_TOKEN+x}" ]]; then + BLACKFIRE_ARGS="$BLACKFIRE_ARGS --server-token=\"${BLACKFIRE_SERVER_TOKEN}\"" +fi + +# create directory for unix socket +mkdir -p /var/run/blackfire + +eval exec blackfire-agent $BLACKFIRE_ARGS diff --git a/docker/php-nginx-dev/7.0/conf/bin/service.d/nginx.d/10-init.sh b/docker/php-nginx-dev/7.0/conf/bin/service.d/nginx.d/10-init.sh new file mode 100644 index 000000000..27b9776cc --- /dev/null +++ b/docker/php-nginx-dev/7.0/conf/bin/service.d/nginx.d/10-init.sh @@ -0,0 +1,25 @@ +if [[ ! -e "$WEB_DOCUMENT_ROOT" ]]; then + echo "" + echo "[WARNING] WEB_DOCUMENT_ROOT does not exists with path \"$WEB_DOCUMENT_ROOT\"!" + echo "" +fi + +# Prevent startup of nginx (ubuntu 16.04 needs it) +ln -f -s /var/lib/nginx/logs /var/log/nginx + +# Replace markers +go-replace \ + -s "" -r "$WEB_DOCUMENT_INDEX" \ + -s "" -r "$WEB_DOCUMENT_ROOT" \ + -s "" -r "$WEB_ALIAS_DOMAIN" \ + -s "" -r "$HOSTNAME" \ + -s "" -r "$WEB_PHP_SOCKET" \ + --path=/opt/docker/etc/nginx/ \ + --path-pattern='*.conf' \ + --ignore-empty + +if [[ -z "${WEB_PHP_SOCKET+x}" ]]; then + ## WEB_PHP_SOCKET is not set, remove PHP files + rm -f -- /opt/docker/etc/nginx/conf.d/10-php.conf + rm -f -- /opt/docker/etc/nginx/vhost.common.d/10-php.conf +fi diff --git a/docker/php-nginx-dev/7.0/conf/bin/service.d/nginx.d/12-development.sh b/docker/php-nginx-dev/7.0/conf/bin/service.d/nginx.d/12-development.sh new file mode 100644 index 000000000..f4695f059 --- /dev/null +++ b/docker/php-nginx-dev/7.0/conf/bin/service.d/nginx.d/12-development.sh @@ -0,0 +1,7 @@ +go-replace \ + -s "" \ + -r "$WEB_NO_CACHE_PATTERN" \ + --path=/opt/docker/etc/nginx/ \ + --path-pattern='*.conf' \ + --ignore-empty + diff --git a/docker/php-nginx-dev/alpine-3/conf/bin/service.d/nginx.sh b/docker/php-nginx-dev/7.0/conf/bin/service.d/nginx.sh similarity index 100% rename from docker/php-nginx-dev/alpine-3/conf/bin/service.d/nginx.sh rename to docker/php-nginx-dev/7.0/conf/bin/service.d/nginx.sh diff --git a/docker/php-nginx-dev/7.0/conf/etc/nginx/conf.d/.gitkeep b/docker/php-nginx-dev/7.0/conf/etc/nginx/conf.d/.gitkeep new file mode 100644 index 000000000..e69de29bb diff --git a/docker/php-nginx-dev/7.0/conf/etc/nginx/conf.d/02-dev.conf b/docker/php-nginx-dev/7.0/conf/etc/nginx/conf.d/02-dev.conf new file mode 100644 index 000000000..fdffa2a0f --- /dev/null +++ b/docker/php-nginx-dev/7.0/conf/etc/nginx/conf.d/02-dev.conf @@ -0,0 +1 @@ +# placeholder diff --git a/docker/php-nginx-dev/alpine-3/conf/etc/nginx/conf.d/10-php.conf b/docker/php-nginx-dev/7.0/conf/etc/nginx/conf.d/10-php.conf similarity index 100% rename from docker/php-nginx-dev/alpine-3/conf/etc/nginx/conf.d/10-php.conf rename to docker/php-nginx-dev/7.0/conf/etc/nginx/conf.d/10-php.conf diff --git a/docker/php-nginx-dev/7.0/conf/etc/nginx/global.conf b/docker/php-nginx-dev/7.0/conf/etc/nginx/global.conf new file mode 100644 index 000000000..b6141db09 --- /dev/null +++ b/docker/php-nginx-dev/7.0/conf/etc/nginx/global.conf @@ -0,0 +1 @@ +# deprecated diff --git a/docker/php-nginx-dev/alpine-3/conf/etc/nginx/main.conf b/docker/php-nginx-dev/7.0/conf/etc/nginx/main.conf similarity index 100% rename from docker/php-nginx-dev/alpine-3/conf/etc/nginx/main.conf rename to docker/php-nginx-dev/7.0/conf/etc/nginx/main.conf diff --git a/docker/php-nginx-dev/7.0/conf/etc/nginx/php.conf b/docker/php-nginx-dev/7.0/conf/etc/nginx/php.conf new file mode 100644 index 000000000..b6141db09 --- /dev/null +++ b/docker/php-nginx-dev/7.0/conf/etc/nginx/php.conf @@ -0,0 +1 @@ +# deprecated diff --git a/docker/php-nginx-dev/7.0/conf/etc/nginx/ssl/server.crt b/docker/php-nginx-dev/7.0/conf/etc/nginx/ssl/server.crt new file mode 100644 index 000000000..6b0694907 --- /dev/null +++ b/docker/php-nginx-dev/7.0/conf/etc/nginx/ssl/server.crt @@ -0,0 +1,28 @@ +-----BEGIN CERTIFICATE----- +MIIE1DCCArwCCQDMMwGnSuK0tTANBgkqhkiG9w0BAQsFADAsMRswGQYDVQQKExJE +b2NrZXIgQm9pbGVycGxhdGUxDTALBgNVBAMUBCoudm0wHhcNMTUwNTA0MTcxNDQw +WhcNMjUwNTAxMTcxNDQwWjAsMRswGQYDVQQKExJEb2NrZXIgQm9pbGVycGxhdGUx +DTALBgNVBAMUBCoudm0wggIiMA0GCSqGSIb3DQEBAQUAA4ICDwAwggIKAoICAQDK +3TIUiyDvXelWeY9VXMrpjuZtYpVSDsACLpjFUhMnsP5/iKT0VbeZyqHvmwZjAg4G +Y10d+yZDdgv/xeu0HPOFbtR6pCp10d1tdLHZto5Cyuxu7IQsAVjnD6Ko7XFwtNk7 +9o6JZfAFaGL4w5MokrVmCtspnsMZH7/7zU4f96cbF39zLopnpuXGD6t6DA8Qj3gy +0duaTjs42bYRN+rwLzVKAev99iQ4kPMJn4vV6/Xk6rtoSzC67GQyVZYaFypicD1S +NtsRmgEVvjCBDbrLOneUiRwff6qxEsZi7Hxv7BKFj4iUWnII7K/nP7T6uBHQjHO+ +FpsGkU9lCMrCeVFBe8kKz/cbhd+yLUxXwAPr6gSOPmwn232Gy4tozvqZHpbUxsgx +7sT3ej9K66h1D7J+BjNFWYM1hbnC1r7H/xS7EBzBV8qRoQCVe08Juf5xsouXFakD +clLV4+L+1cxkpwsCQDly5g3tm/TBqA2O+ZJ+YHQDHKkzMyhLs6i0X/M5qvJBiLg1 +GLTCS20rpQ5gXTEGuINqHgwXQWkUO6bhgSYqdHGX3zbZ5+qWpI4eui3dHZ1Ll0VH +6Icpb7ORTQwhc6W8KBlybssYPSlGOEBGUjYGNheoz9FpoSkxCis+P8ZNKtrmpPoq +Su0eOOGFOFHG02eOgPVxSwrDeN9MVJo7BPysGMHJmQIDAQABMA0GCSqGSIb3DQEB +CwUAA4ICAQC63g6NHmQKbiy3G6iaDkpUSbr5Mq2YgU61XnvWVyREqDcy/BXCw9oY +SJ/KUvCpqPnACNOFqjadRAmPiA9nf2WduoCgwQGV/YRFGswSuVvh/3X2TX5NWvbS +t8MQDttQg1dxpiMUjlu3rqhfohBdWJvp2lVSdpDb/MOlXBc/+p7HfOHwhqB7wwPN +NNbSKUbZqZxmD8cOf1X0hASr1yfFPj+2vST3ESaON8S0T2p63YX/sD5jvOUiEuyw +I5WcvLmiRZA07SH8nWyckLY3qWL+OlhSZrlAnolWS00b+7h5LNuRYEjKzwVgntoA +aCopyQih6wIk0+AfJO4sfhJBmQhnIrAaP/zwBH5g9zVizLf5H7U+hNXrMwgw55Sq +vjMdkZHvPKUXTvVit/rYE9H+PY3brkRWzOl4V/i/ZLJJm5805H/NyTbz9kPMJw2Q +nn+KOpfXXySD39f8iuRgSKXsYNul38hxWgcZZ6g+sOOp2n/VUmf0eZUWNnJ8i7AP +4Qif7aDKMcibOwSwsB+DKZXDvZ5XSdnMphtuLS5rPSL81rVRmWC2DMfQ2eP8j0WN +VTroSk0xedQ7Qr+9TNooi9IyzX6n1a2S1UiciEZ3ZcDbXPl/P01m+IYZyPnLv0+9 +ZeioZYh1JLv3/OKsMrMLTfh2ZCj3aXwmc2Owi/wU2LS5QUOMcHH7CQ== +-----END CERTIFICATE----- \ No newline at end of file diff --git a/docker/php-nginx-dev/7.0/conf/etc/nginx/ssl/server.csr b/docker/php-nginx-dev/7.0/conf/etc/nginx/ssl/server.csr new file mode 100644 index 000000000..8a9909f77 --- /dev/null +++ b/docker/php-nginx-dev/7.0/conf/etc/nginx/ssl/server.csr @@ -0,0 +1,26 @@ +-----BEGIN CERTIFICATE REQUEST----- +MIIEcTCCAlkCAQAwLDEbMBkGA1UEChMSRG9ja2VyIEJvaWxlcnBsYXRlMQ0wCwYD +VQQDFAQqLnZtMIICIjANBgkqhkiG9w0BAQEFAAOCAg8AMIICCgKCAgEAyt0yFIsg +713pVnmPVVzK6Y7mbWKVUg7AAi6YxVITJ7D+f4ik9FW3mcqh75sGYwIOBmNdHfsm +Q3YL/8XrtBzzhW7UeqQqddHdbXSx2baOQsrsbuyELAFY5w+iqO1xcLTZO/aOiWXw +BWhi+MOTKJK1ZgrbKZ7DGR+/+81OH/enGxd/cy6KZ6blxg+regwPEI94MtHbmk47 +ONm2ETfq8C81SgHr/fYkOJDzCZ+L1ev15Oq7aEswuuxkMlWWGhcqYnA9UjbbEZoB +Fb4wgQ26yzp3lIkcH3+qsRLGYux8b+wShY+IlFpyCOyv5z+0+rgR0IxzvhabBpFP +ZQjKwnlRQXvJCs/3G4Xfsi1MV8AD6+oEjj5sJ9t9hsuLaM76mR6W1MbIMe7E93o/ +SuuodQ+yfgYzRVmDNYW5wta+x/8UuxAcwVfKkaEAlXtPCbn+cbKLlxWpA3JS1ePi +/tXMZKcLAkA5cuYN7Zv0wagNjvmSfmB0AxypMzMoS7OotF/zOaryQYi4NRi0wktt +K6UOYF0xBriDah4MF0FpFDum4YEmKnRxl9822efqlqSOHrot3R2dS5dFR+iHKW+z +kU0MIXOlvCgZcm7LGD0pRjhARlI2BjYXqM/RaaEpMQorPj/GTSra5qT6KkrtHjjh +hThRxtNnjoD1cUsKw3jfTFSaOwT8rBjByZkCAwEAAaAAMA0GCSqGSIb3DQEBCwUA +A4ICAQBsEBgC2YepuZq/8UqvKMZKVy/etDKXj7BB+QPb+leNiKD7p4LDxHJsZSH8 +Ku9uMPeLfiQDn5jA41k5SlGttzvObd65RdEbO3yHpqsg05EGSDDLfaE1k2Al/qmX +/o8roPZF7+2kZthgMAgkcokS54LYqEYTGqOf3J9Ss0yRIZwhaOVebfFIbIOdpw0B +JNMIJPHTMdZrcuRVI+wR1uPLIlEJzBvxTGbTrvPU25WJFtu+EajKqXO0SHdy0yx8 +uH4ykRBJRc36+oYo7nZ5D56dh7pZn3+9J64FKAOV0Q3KqMFieGy053ezuhJd70eZ +UozTgfjs3WpMzoYmKETSyl3XZSdInRe+sUlKPruTsKyg69oYxjPlrGfAmmGcCFca +TnZinT18dI92zK7OtOVkmYeYKC1lwuhftVrNMXzZuHOGpS9NNYtc4nDqDMIEOfV3 +6rCdu03WjEgJ+Z67tJs16xOx9du4/EHxS2Ijn9DPfVJvYy0TgzDi1BUpjWx0KTLx +C4OQbEZ/QTWmHVbSch/hcZhzbf7SNh5RpnW4EtmcpDFjIKMfxJmoKeiTf7qnilx0 +7uRvsZFKoDKRDOFiPfgMg5AOtLHziYsd9m0tJjC2GHvFuPjzOtzhnUUjmmvht170 +2aqKakjST4amg7jzLcs871HX0/WjOtt29NpOz140blkKf1bisg== +-----END CERTIFICATE REQUEST----- \ No newline at end of file diff --git a/docker/php-nginx-dev/7.0/conf/etc/nginx/ssl/server.key b/docker/php-nginx-dev/7.0/conf/etc/nginx/ssl/server.key new file mode 100644 index 000000000..c9eec145f --- /dev/null +++ b/docker/php-nginx-dev/7.0/conf/etc/nginx/ssl/server.key @@ -0,0 +1,51 @@ +-----BEGIN RSA PRIVATE KEY----- +MIIJKAIBAAKCAgEAyt0yFIsg713pVnmPVVzK6Y7mbWKVUg7AAi6YxVITJ7D+f4ik +9FW3mcqh75sGYwIOBmNdHfsmQ3YL/8XrtBzzhW7UeqQqddHdbXSx2baOQsrsbuyE +LAFY5w+iqO1xcLTZO/aOiWXwBWhi+MOTKJK1ZgrbKZ7DGR+/+81OH/enGxd/cy6K +Z6blxg+regwPEI94MtHbmk47ONm2ETfq8C81SgHr/fYkOJDzCZ+L1ev15Oq7aEsw +uuxkMlWWGhcqYnA9UjbbEZoBFb4wgQ26yzp3lIkcH3+qsRLGYux8b+wShY+IlFpy +COyv5z+0+rgR0IxzvhabBpFPZQjKwnlRQXvJCs/3G4Xfsi1MV8AD6+oEjj5sJ9t9 +hsuLaM76mR6W1MbIMe7E93o/SuuodQ+yfgYzRVmDNYW5wta+x/8UuxAcwVfKkaEA +lXtPCbn+cbKLlxWpA3JS1ePi/tXMZKcLAkA5cuYN7Zv0wagNjvmSfmB0AxypMzMo +S7OotF/zOaryQYi4NRi0wkttK6UOYF0xBriDah4MF0FpFDum4YEmKnRxl9822efq +lqSOHrot3R2dS5dFR+iHKW+zkU0MIXOlvCgZcm7LGD0pRjhARlI2BjYXqM/RaaEp +MQorPj/GTSra5qT6KkrtHjjhhThRxtNnjoD1cUsKw3jfTFSaOwT8rBjByZkCAwEA +AQKCAgAbZPdoUsllyZbC+LNkYZ19ILD5QIDNjfRb1xMGQmkXyQz1B+zOmeyrNfPc +OWEJabOfJTfj3pByN7SzG3US4333HNpQnW6mbmqqZ0HFFqPrXR/Ecuf+UUhCG5hp +m3bgM2vKbyccYsmg0VHcKfzrU7RvTTP/UNMjx2fThwvvwS+ttuSdF0HVcXJB5sfP +OWWnZNhkdHZlRf81VCED/jsZqCZYEh5eMyj9AoXvXL4zayPPf+tC0DSKaXW2Xlxg +tZQhqup8+a9nlxZia0Z9hu8clo6jXkiP8FuKgfCMV0cOjiCKLLHS5svTbLLsVWwJ +F2ZAdVcD6mWQ43qHOEK5NEzGvQKO14CaOLnVT2yAkMcyNohsEgoDP9oCBGDJQbBH +NmtZfpVjjtuTr9P9TEkU1FcBRo0x6Il/DkzamGbOeFAmgnaGElhJ5c/CAG7whaIf +mUfFOBGPH/wESY3gBOACDofeSh27RrlvbLaPiCGKivDUTBmhBsIuso6XqOKbvtfV +/HhhndpdRVfIj4DdE7gIrLIGN977JMVAXFCNz7KrvAWwcOXrCHCoWpklJ9repq8l +26ICY8K7VXktzDHQUmhd88ZWR+9ASURsJghUgZUOcMrEGyvci6Y8hpLhHiNVPHuQ ++ps7tpPsXSntBUqWBzhRZh74+nJlOOV6oYykl30JT2JzB6lwiQKCAQEA9ecn8N2z +20tR2UEiTv/MjVSepQtAAajegvcd1iasvvQKXnh3XLmoZHzH2tTa0lp5RIZpUQPl +lOTwko0lYTBnYblt65AJQ3FTgisNobIpoqE8BFXLm6wggz7CbabjmPGDe173lPGR +sI0YSKYvzrdn4zw8Fh6WULJyZHLi58zJYL3r0WBDiOoxpGaGA1GlmkuIWjhKHaX2 +OvF1vOuQDJ2eDyTc5TYFC0NKG76Mvanov5L/yrhNM/umbmp0SPspzHGZobAKUr20 +OazFT8S+2TA1OTxWNbiPbSimFoaZbEdqsNACGfVJWO8Sh8iqlt5RmEcSiSvGBj6L +QKprRO9Fsp2GawKCAQEA0zGhRsnux4JTNsdUSYsEJtITMj6eE+nl7CoZ9DAOwC5X +6/aSpUE4TT+pWNrt9iluXiGL0j89UJ7r/L1OcsiyzGb8ig9NU4zr1NIGTZ0DstHi +HPYINjeiBJEFIy17kOQn+9/I5c4hBUwz6ihwNoEomymVB/EsLJKAML0AudJGKg+Z +/f/qrS40eab5SAiaKgsh0MZnj+vIxyGBydt6r2HGmjfNITVbXIu6IpO+6NXDwM/e +7v10AAZ3j9+gb1RedLg2ghuIuYU90hmMhtVWsh9nVmaOkMW9/WFgOPYvt/mHH/hR +d4pePZ9kACGmqo/b9sHvHw1YEubtCt1VUiNuFxnJCwKCAQBWnxz0vkRTJY8phsY9 +KeK2jm5sGTBs5T2syLwb6ffENFdKvAjgAw6Mh2And/+1ReWd+/MxdLv03UjZdxsJ +x3FDfXx5FH4O4ebW3a+pnAcKoN1xcX+N0O6LDRqUYcue3sTAOs3gC9CUbr91KAWD +Phw8ccWAzTmKJ7IgLFA982ekyoI9eTmRC159WRgwJxy844qerWF+XC4GyXP+HsTZ +jNRW5Vdi7sqMEyIR7+fIEAhLI88zbATWIPmZv6pC4ybwO7wwtsCMMQNBpdjDprzL +6S12ggikV+U+QKlxGe0FtYqhykRTPJKf32eZqVheWOZJTA/9fgv9ux52oxGycM8O +gmsNAoIBAQC60m5uZnd5uYnPLWkcXYNgq/kbO1UvHHut/FhVMKX7z4MrU0XKNfWO +MECoP5K9bU0aq+Y6KIMe7FapjvT0iSHRu1Cu+HZY8JI2A0xcIAeDijLRl7sP6wrB +q1+2DKgANjRAlWfsEfoX658JBpitPngjOheBnRCMpVQMyUT5HE/BKWf5zwdUB0mY +S+K8nA90HcDeJIS8RcGolbVwUV0oBABhr/cf50lYhqozqCr7YQ33ZGs7Uq3oz8+4 +UARmN2YPLl3Znm3GX12em8c6B0LX8vvA7Jw06Rf2Ksup1+3Ce1PTLiEy9A4FyRf3 +Hc2HmBbnJAtZlr5QikMqlzzAmmLqwH6dAoIBAC+ryaQGJFsijCSuaDfRp/uy9xnd +DjgMdTwjl5WLBmyudChVMANl8eqCbvVO41CN84yORk03oQ4cx0eKxAZaLaSzgkb3 +W0X2nFQe7VJSYMQswCQ+1WfJvEFrIdkEKIa//uQdhqNrgUKSNVhhSTMbNEkDTIWn +ssbv2H9hvUaFt/J/vP9zCKuU5oYvNU7Oi6ZXRYezRn9atlJYanLFoJnHUBRzGms5 +K0vhdCPDXQq87z5Yudoh0jLUQF9Nx0GTWeBceQ9n5hZeRUNQWxP4AJThQX9KSPTS +mbL3Kh4XNRmAUJ2N+Njh+3dg91s+JkKvC1wcspLsmLPQe+9AxBSH9y5JE/8= +-----END RSA PRIVATE KEY----- \ No newline at end of file diff --git a/docker/php-nginx-dev/alpine-3/conf/etc/nginx/vhost.common.conf b/docker/php-nginx-dev/7.0/conf/etc/nginx/vhost.common.conf similarity index 100% rename from docker/php-nginx-dev/alpine-3/conf/etc/nginx/vhost.common.conf rename to docker/php-nginx-dev/7.0/conf/etc/nginx/vhost.common.conf diff --git a/docker/php-nginx-dev/7.0/conf/etc/nginx/vhost.common.d/.gitkeep b/docker/php-nginx-dev/7.0/conf/etc/nginx/vhost.common.d/.gitkeep new file mode 100644 index 000000000..e69de29bb diff --git a/docker/php-nginx-dev/alpine-3/conf/etc/nginx/vhost.common.d/02-dev.conf b/docker/php-nginx-dev/7.0/conf/etc/nginx/vhost.common.d/02-dev.conf similarity index 100% rename from docker/php-nginx-dev/alpine-3/conf/etc/nginx/vhost.common.d/02-dev.conf rename to docker/php-nginx-dev/7.0/conf/etc/nginx/vhost.common.d/02-dev.conf diff --git a/docker/php-nginx-dev/7.0/conf/etc/nginx/vhost.common.d/10-general.conf b/docker/php-nginx-dev/7.0/conf/etc/nginx/vhost.common.d/10-general.conf new file mode 100644 index 000000000..d3fd0aa5e --- /dev/null +++ b/docker/php-nginx-dev/7.0/conf/etc/nginx/vhost.common.d/10-general.conf @@ -0,0 +1 @@ +client_max_body_size 50m; diff --git a/docker/php-nginx-dev/alpine-3/conf/etc/nginx/vhost.common.d/10-location-root.conf b/docker/php-nginx-dev/7.0/conf/etc/nginx/vhost.common.d/10-location-root.conf similarity index 100% rename from docker/php-nginx-dev/alpine-3/conf/etc/nginx/vhost.common.d/10-location-root.conf rename to docker/php-nginx-dev/7.0/conf/etc/nginx/vhost.common.d/10-location-root.conf diff --git a/docker/php-nginx-dev/7.0/conf/etc/nginx/vhost.common.d/10-log.conf b/docker/php-nginx-dev/7.0/conf/etc/nginx/vhost.common.d/10-log.conf new file mode 100644 index 000000000..a2cd929e7 --- /dev/null +++ b/docker/php-nginx-dev/7.0/conf/etc/nginx/vhost.common.d/10-log.conf @@ -0,0 +1,2 @@ +access_log /docker.stdout; +error_log /docker.stderr info; diff --git a/docker/php-nginx-dev/alpine-3/conf/etc/nginx/vhost.common.d/10-php.conf b/docker/php-nginx-dev/7.0/conf/etc/nginx/vhost.common.d/10-php.conf similarity index 100% rename from docker/php-nginx-dev/alpine-3/conf/etc/nginx/vhost.common.d/10-php.conf rename to docker/php-nginx-dev/7.0/conf/etc/nginx/vhost.common.d/10-php.conf diff --git a/docker/php-nginx-dev/7.0/conf/etc/nginx/vhost.conf b/docker/php-nginx-dev/7.0/conf/etc/nginx/vhost.conf new file mode 100644 index 000000000..8225f314a --- /dev/null +++ b/docker/php-nginx-dev/7.0/conf/etc/nginx/vhost.conf @@ -0,0 +1,26 @@ +server { + listen 80 default_server; + + server_name _ docker; + + root ""; + index ; + + include /opt/docker/etc/nginx/vhost.common.d/*.conf; +} + +############## +# SSL +############## + +server { + listen 443 default_server; + + server_name _ docker; + + root ""; + index ; + + include /opt/docker/etc/nginx/vhost.common.d/*.conf; + include /opt/docker/etc/nginx/vhost.ssl.conf; +} diff --git a/docker/php-nginx-dev/alpine-3/conf/etc/nginx/vhost.ssl.conf b/docker/php-nginx-dev/7.0/conf/etc/nginx/vhost.ssl.conf similarity index 100% rename from docker/php-nginx-dev/alpine-3/conf/etc/nginx/vhost.ssl.conf rename to docker/php-nginx-dev/7.0/conf/etc/nginx/vhost.ssl.conf diff --git a/docker/php-nginx-dev/7.0/conf/etc/supervisor.d/blackfire-agent.conf b/docker/php-nginx-dev/7.0/conf/etc/supervisor.d/blackfire-agent.conf new file mode 100644 index 000000000..897831ddb --- /dev/null +++ b/docker/php-nginx-dev/7.0/conf/etc/supervisor.d/blackfire-agent.conf @@ -0,0 +1,14 @@ +[group:blackfire-agent] +programs=blackfire-agentd +priority=25 + +[program:blackfire-agentd] +command = /opt/docker/bin/service.d/blackfire-agent.sh +process_name=%(program_name)s +startsecs = 0 +autostart = false +autorestart = true +stdout_logfile=/dev/stdout +stdout_logfile_maxbytes=0 +stderr_logfile=/dev/stderr +stderr_logfile_maxbytes=0 diff --git a/docker/php-nginx-dev/alpine-3/conf/etc/supervisor.d/nginx.conf b/docker/php-nginx-dev/7.0/conf/etc/supervisor.d/nginx.conf similarity index 100% rename from docker/php-nginx-dev/alpine-3/conf/etc/supervisor.d/nginx.conf rename to docker/php-nginx-dev/7.0/conf/etc/supervisor.d/nginx.conf diff --git a/docker/php-nginx-dev/7.0/conf/provision/entrypoint.d/10-php-debugger.sh b/docker/php-nginx-dev/7.0/conf/provision/entrypoint.d/10-php-debugger.sh new file mode 100644 index 000000000..b5985a9ef --- /dev/null +++ b/docker/php-nginx-dev/7.0/conf/provision/entrypoint.d/10-php-debugger.sh @@ -0,0 +1,96 @@ +#!/usr/bin/env bash + +################################################# +# Debugger switch +################################################# + +PHP_CONF_PATHS=" +/etc/php5/conf.d +/etc/php7/conf.d +/etc/php.d +/etc/php5/mods-available +/etc/php5/cli/conf.d +/etc/php5/cli/conf.d +/etc/php5/fpm/conf.d +/etc/php5/fpm/conf.d +/etc/php/7.0/mods-available +/etc/php/7.0/cli/conf.d +/etc/php/7.0/fpm/conf.d +/usr/local/etc/php/conf.d/" + +function phpModuleRemove() { + if [ "$#" -ne 1 ]; then + echo "You must specify the name of the PHP module which you want to disable" + exit 1 + fi + + echo " - Removing PHP module ${1}" + for CONF_PATH in $PHP_CONF_PATHS; do + rm -f "${CONF_PATH}"/*"${1}".ini + done +} + + +if [[ -n "${PHP_DEBUGGER+x}" ]]; then + case "$PHP_DEBUGGER" in + xdebug) + echo "PHP-Debugger: Xdebug enabled" + phpModuleRemove "blackfire" + ;; + + blackfire) + echo "PHP-Debugger: Blackfire enabled" + phpModuleRemove "xdebug" + docker-service-enable blackfire-agent + ;; + + none) + echo "PHP-Debugger: none" + phpModuleRemove "blackfire" + phpModuleRemove "xdebug" + ;; + esac + +else + + echo "PHP-Debugger: not specified - default is xdebug" + phpModuleRemove "blackfire" + +fi + +################################################# +# PHP debugger environment variables +################################################# + +function phpEnvironmentVariable() { + PHP_INI_KEY="$1" + PHP_ENV_NAME="$2" + + if [[ -n "${!PHP_ENV_NAME+x}" ]]; then + PHP_ENV_VALUE="${!PHP_ENV_NAME}" + echo "${PHP_INI_KEY}=\"${PHP_ENV_VALUE}\"" >> /opt/docker/etc/php/php.ini + fi +} + +################### +# XDEBUG +################### + +# remote debugger +phpEnvironmentVariable "xdebug.remote_connect_back" "XDEBUG_REMOTE_CONNECT_BACK" +phpEnvironmentVariable "xdebug.remote_autostart" "XDEBUG_REMOTE_AUTOSTART" +phpEnvironmentVariable "xdebug.remote_host" "XDEBUG_REMOTE_HOST" +phpEnvironmentVariable "xdebug.remote_port" "XDEBUG_REMOTE_PORT" + +# profiler +phpEnvironmentVariable "xdebug.profiler_enable" "XDEBUG_PROFILER_ENABLE" +phpEnvironmentVariable "xdebug.profiler_enable_trigger" "XDEBUG_PROFILER_ENABLE_TRIGGER" +phpEnvironmentVariable "xdebug.profiler_enable_trigger_value" "XDEBUG_PROFILER_ENABLE_TRIGGER_VALUE" +phpEnvironmentVariable "xdebug.profiler_output_dir" "XDEBUG_PROFILER_OUTPUT_DIR" +phpEnvironmentVariable "xdebug.profiler_output_name" "XDEBUG_PROFILER_OUTPUT_NAME" + +################### +# BLACKFIRE +################### +phpEnvironmentVariable "blackfire.server_id" "BLACKFIRE_SERVER_ID" +phpEnvironmentVariable "blackfire.server_token" "BLACKFIRE_SERVER_TOKEN" diff --git a/docker/php-nginx-dev/7.0/conf/provision/roles/webdevops-nginx-dev/defaults/main.yml b/docker/php-nginx-dev/7.0/conf/provision/roles/webdevops-nginx-dev/defaults/main.yml new file mode 100644 index 000000000..81f5b7efd --- /dev/null +++ b/docker/php-nginx-dev/7.0/conf/provision/roles/webdevops-nginx-dev/defaults/main.yml @@ -0,0 +1,6 @@ +--- + +APPLICATION_USER: "{{ lookup('env','APPLICATION_USER') }}" +APPLICATION_GROUP: "{{ lookup('env','APPLICATION_GROUP') }}" +APPLICATION_UID: "{{ lookup('env','APPLICATION_UID') }}" +APPLICATION_GID: "{{ lookup('env','APPLICATION_GID') }}" diff --git a/docker/php-nginx-dev/alpine-3/conf/provision/roles/webdevops-nginx-dev/tasks/bootstrap.yml b/docker/php-nginx-dev/7.0/conf/provision/roles/webdevops-nginx-dev/tasks/bootstrap.yml similarity index 100% rename from docker/php-nginx-dev/alpine-3/conf/provision/roles/webdevops-nginx-dev/tasks/bootstrap.yml rename to docker/php-nginx-dev/7.0/conf/provision/roles/webdevops-nginx-dev/tasks/bootstrap.yml diff --git a/docker/php-nginx-dev/alpine-3/conf/provision/roles/webdevops-nginx-dev/tasks/bootstrap/nginx.yml b/docker/php-nginx-dev/7.0/conf/provision/roles/webdevops-nginx-dev/tasks/bootstrap/nginx.yml similarity index 100% rename from docker/php-nginx-dev/alpine-3/conf/provision/roles/webdevops-nginx-dev/tasks/bootstrap/nginx.yml rename to docker/php-nginx-dev/7.0/conf/provision/roles/webdevops-nginx-dev/tasks/bootstrap/nginx.yml diff --git a/docker/php-nginx-dev/7.0/conf/provision/roles/webdevops-nginx-dev/tasks/main.yml b/docker/php-nginx-dev/7.0/conf/provision/roles/webdevops-nginx-dev/tasks/main.yml new file mode 100644 index 000000000..1806c1a8c --- /dev/null +++ b/docker/php-nginx-dev/7.0/conf/provision/roles/webdevops-nginx-dev/tasks/main.yml @@ -0,0 +1,5 @@ +--- + +- include: bootstrap.yml + tags: + - bootstrap diff --git a/docker/php-nginx-dev/7.0/conf/provision/roles/webdevops-nginx/defaults/main.yml b/docker/php-nginx-dev/7.0/conf/provision/roles/webdevops-nginx/defaults/main.yml new file mode 100644 index 000000000..69cba1cb4 --- /dev/null +++ b/docker/php-nginx-dev/7.0/conf/provision/roles/webdevops-nginx/defaults/main.yml @@ -0,0 +1,3 @@ +--- + +DOCUMENT_ROOT: "{{ lookup('env','WEB_DOCUMENT_ROOT') }}" diff --git a/docker/php-nginx-dev/alpine-3/conf/provision/roles/webdevops-nginx/tasks/bootstrap.yml b/docker/php-nginx-dev/7.0/conf/provision/roles/webdevops-nginx/tasks/bootstrap.yml similarity index 100% rename from docker/php-nginx-dev/alpine-3/conf/provision/roles/webdevops-nginx/tasks/bootstrap.yml rename to docker/php-nginx-dev/7.0/conf/provision/roles/webdevops-nginx/tasks/bootstrap.yml diff --git a/docker/php-nginx-dev/7.0/conf/provision/roles/webdevops-nginx/tasks/main.yml b/docker/php-nginx-dev/7.0/conf/provision/roles/webdevops-nginx/tasks/main.yml new file mode 100644 index 000000000..1806c1a8c --- /dev/null +++ b/docker/php-nginx-dev/7.0/conf/provision/roles/webdevops-nginx/tasks/main.yml @@ -0,0 +1,5 @@ +--- + +- include: bootstrap.yml + tags: + - bootstrap diff --git a/docker/php-nginx-dev/7.0/conf/provision/roles/webdevops-php-dev/defaults/main.yml b/docker/php-nginx-dev/7.0/conf/provision/roles/webdevops-php-dev/defaults/main.yml new file mode 100644 index 000000000..81f5b7efd --- /dev/null +++ b/docker/php-nginx-dev/7.0/conf/provision/roles/webdevops-php-dev/defaults/main.yml @@ -0,0 +1,6 @@ +--- + +APPLICATION_USER: "{{ lookup('env','APPLICATION_USER') }}" +APPLICATION_GROUP: "{{ lookup('env','APPLICATION_GROUP') }}" +APPLICATION_UID: "{{ lookup('env','APPLICATION_UID') }}" +APPLICATION_GID: "{{ lookup('env','APPLICATION_GID') }}" diff --git a/docker/php-nginx-dev/7.0/conf/provision/roles/webdevops-php-dev/tasks/bootstrap.yml b/docker/php-nginx-dev/7.0/conf/provision/roles/webdevops-php-dev/tasks/bootstrap.yml new file mode 100644 index 000000000..ff02b05fc --- /dev/null +++ b/docker/php-nginx-dev/7.0/conf/provision/roles/webdevops-php-dev/tasks/bootstrap.yml @@ -0,0 +1,7 @@ +--- + +- include: bootstrap/php-fpm.yml +- include: bootstrap/php-module.yml +- include: bootstrap/php-module.opcache.yml +- include: bootstrap/php-module.xdebug.yml +- include: bootstrap/php-module.blackfire.yml diff --git a/docker/php-nginx-dev/7.0/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/php-fpm.yml b/docker/php-nginx-dev/7.0/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/php-fpm.yml new file mode 100644 index 000000000..9455a78e2 --- /dev/null +++ b/docker/php-nginx-dev/7.0/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/php-fpm.yml @@ -0,0 +1,18 @@ +--- + +- name: Configure php-fpm pool user (application.conf) + lineinfile: + dest: '/opt/docker/etc/php/fpm/pool.d/application.conf' + regexp: '^[\s;]*{{ item.key }}[\s]*=' + line: '{{ item.key }} = {{ item.value }}' + with_items: + - { key: 'access.log', value: "/docker.stdout" } + - { key: "access.format", value: '"%R - %u %t \"%m %r%Q%q\" %s %f cpu:%C%% mem:%{megabytes}M reqTime:%d"' } + +- name: Open php-fpm for external connections (eg. debuggers) + lineinfile: + dest: '/opt/docker/etc/php/fpm/pool.d/application.conf' + regexp: '^[\s;]*{{ item.key }}[\s]*=' + line: '{{ item.key }} = {{ item.value }}' + with_items: + - { key: 'listen', value: "0.0.0.0:9000" } diff --git a/docker/php-nginx-dev/7.0/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/php-module.blackfire.yml b/docker/php-nginx-dev/7.0/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/php-module.blackfire.yml new file mode 100644 index 000000000..faf05f8de --- /dev/null +++ b/docker/php-nginx-dev/7.0/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/php-module.blackfire.yml @@ -0,0 +1,10 @@ +--- + +- name: Remove superfluous blackfire configuration file + file: + path: '{{ item }}' + state: absent + with_items: + - /etc/php5/cli/conf.d/zz-blackfire.ini + - /etc/php5/fpm/conf.d/zz-blackfire.ini + when: ansible_distribution == 'Debian' and docker_image_info_distribution_version|int >= 7 diff --git a/docker/php-nginx-dev/7.0/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/php-module.opcache.yml b/docker/php-nginx-dev/7.0/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/php-module.opcache.yml new file mode 100644 index 000000000..9c243a671 --- /dev/null +++ b/docker/php-nginx-dev/7.0/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/php-module.opcache.yml @@ -0,0 +1,14 @@ +--- + +- name: Setup php.ini for development environment + lineinfile: + dest: '/opt/docker/etc/php/php.webdevops.ini' + regexp: '^[\s;]*{{ item.variable }}[\s]*=' + line: '{{ item.variable }} = {{ item.value }}' + with_items: + - { variable: 'opcache.memory_consumption', value: '256' } + - { variable: 'opcache.validate_timestamps', value: '1' } + - { variable: 'opcache.revalidate_freq', value: '0' } + - { variable: 'opcache.interned_strings_buffer', value: '16' } + - { variable: 'opcache.max_accelerated_files', value: '7963' } + - { variable: 'opcache.fast_shutdown', value: '1' } diff --git a/docker/php-nginx-dev/7.0/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/php-module.xdebug.yml b/docker/php-nginx-dev/7.0/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/php-module.xdebug.yml new file mode 100644 index 000000000..7f20c845e --- /dev/null +++ b/docker/php-nginx-dev/7.0/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/php-module.xdebug.yml @@ -0,0 +1,28 @@ +--- + +# Ignored on php7 +- name: Fix php xdebug module [Alpine family] + lineinfile: + dest: '{{ item }}' + regexp: 'extension=xdebug.so' + line: 'zend_extension=xdebug.so' + when: ansible_distribution == 'Alpine' + with_items: + - /etc/php5/conf.d/xdebug.ini + - /etc/php7/conf.d/xdebug.ini + ignore_errors: yes + +- name: Setup php.ini for development environment + lineinfile: + dest: '/opt/docker/etc/php/php.webdevops.ini' + regexp: '^[\s;]*{{ item.variable }}[\s]*=' + line: '{{ item.variable }} = {{ item.value }}' + with_items: + - { variable: 'xdebug.remote_enable', value: '1' } + - { variable: 'xdebug.remote_connect_back', value: '1' } + - { variable: 'xdebug.idekey', value: 'docker' } + - { variable: 'xdebug.cli_color', value: '1' } + - { variable: 'xdebug.max_nesting_level', value: '1000' } + - { variable: 'xdebug.profiler_enable_trigger', value: '1000' } + - { variable: 'xdebug.profiler_output_dir', value: '/tmp/debug/' } + - { variable: 'xhprof.output_dir', value: '/tmp/debug/' } diff --git a/docker/php-nginx-dev/7.0/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/php-module.yml b/docker/php-nginx-dev/7.0/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/php-module.yml new file mode 100644 index 000000000..31cccd1ae --- /dev/null +++ b/docker/php-nginx-dev/7.0/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/php-module.yml @@ -0,0 +1,41 @@ +--- + +############################# +# Workaround PHP configuration files +# for alpine +############################# + +- name: Get list of PHP5 configuration files + command: "ls /etc/php5/conf.d/ |grep .ini" + register: php5_ini + when: ansible_distribution == 'Alpine' + ignore_errors: yes + +- name: Link configuration files from php5 to php + file: + src: '/etc/php5/conf.d/{{ item }}' + dest: '/etc/php/conf.d/{{ item }}' + state: link + with_items: "{{ php5_ini.stdout_lines }}" + when: ansible_distribution == 'Alpine' and php5_ini is defined + ignore_errors: yes + +############################# +# Workaround PHP module files +# for alpine +############################# + +- name: Get list of PHP5 modules + command: "ls /usr/lib/php5/modules/ |grep .so" + register: php5_modules + when: ansible_distribution == 'Alpine' + ignore_errors: yes + +- name: Link module files from php5 to php + file: + src: '/usr/lib/php5/modules/{{ item }}' + dest: '/usr/lib/php/modules/{{ item }}' + state: link + with_items: "{{ php5_modules.stdout_lines }}" + when: ansible_distribution == 'Alpine' and php5_modules is defined + ignore_errors: yes diff --git a/docker/php-nginx-dev/7.0/conf/provision/roles/webdevops-php-dev/tasks/main.yml b/docker/php-nginx-dev/7.0/conf/provision/roles/webdevops-php-dev/tasks/main.yml new file mode 100644 index 000000000..1806c1a8c --- /dev/null +++ b/docker/php-nginx-dev/7.0/conf/provision/roles/webdevops-php-dev/tasks/main.yml @@ -0,0 +1,5 @@ +--- + +- include: bootstrap.yml + tags: + - bootstrap diff --git a/docker/php-nginx-dev/7.0/conf/provision/roles/webdevops-php-nginx/defaults/main.yml b/docker/php-nginx-dev/7.0/conf/provision/roles/webdevops-php-nginx/defaults/main.yml new file mode 100644 index 000000000..ed97d539c --- /dev/null +++ b/docker/php-nginx-dev/7.0/conf/provision/roles/webdevops-php-nginx/defaults/main.yml @@ -0,0 +1 @@ +--- diff --git a/docker/php-nginx-dev/alpine-3/conf/provision/roles/webdevops-php-nginx/tasks/bootstrap.yml b/docker/php-nginx-dev/7.0/conf/provision/roles/webdevops-php-nginx/tasks/bootstrap.yml similarity index 100% rename from docker/php-nginx-dev/alpine-3/conf/provision/roles/webdevops-php-nginx/tasks/bootstrap.yml rename to docker/php-nginx-dev/7.0/conf/provision/roles/webdevops-php-nginx/tasks/bootstrap.yml diff --git a/docker/php-nginx-dev/7.0/conf/provision/roles/webdevops-php-nginx/tasks/entrypoint.yml b/docker/php-nginx-dev/7.0/conf/provision/roles/webdevops-php-nginx/tasks/entrypoint.yml new file mode 100644 index 000000000..cd21505a4 --- /dev/null +++ b/docker/php-nginx-dev/7.0/conf/provision/roles/webdevops-php-nginx/tasks/entrypoint.yml @@ -0,0 +1,2 @@ +--- + diff --git a/docker/php-nginx-dev/7.0/conf/provision/roles/webdevops-php-nginx/tasks/main.yml b/docker/php-nginx-dev/7.0/conf/provision/roles/webdevops-php-nginx/tasks/main.yml new file mode 100644 index 000000000..7895a52a9 --- /dev/null +++ b/docker/php-nginx-dev/7.0/conf/provision/roles/webdevops-php-nginx/tasks/main.yml @@ -0,0 +1,9 @@ +--- + +- include: bootstrap.yml + tags: + - bootstrap + +- include: entrypoint.yml + tags: + - entrypoint diff --git a/docker/php-nginx-dev/7.1/Dockerfile b/docker/php-nginx-dev/7.1/Dockerfile new file mode 100644 index 000000000..0b1f7775e --- /dev/null +++ b/docker/php-nginx-dev/7.1/Dockerfile @@ -0,0 +1,23 @@ +#+++++++++++++++++++++++++++++++++++++++ +# Dockerfile for webdevops/php-nginx-dev:7.1 +# -- automatically generated -- +#+++++++++++++++++++++++++++++++++++++++ + +FROM webdevops/php-dev:7.1 + +ENV WEB_DOCUMENT_ROOT=/app \ + WEB_DOCUMENT_INDEX=index.php \ + WEB_ALIAS_DOMAIN=*.vm +ENV WEB_PHP_SOCKET=127.0.0.1:9000 +ENV WEB_NO_CACHE_PATTERN="\.(css|js|gif|png|jpg|svg|json|xml)$" + +COPY conf/ /opt/docker/ + +# Install nginx +RUN /usr/local/bin/apt-install \ + nginx \ + && /opt/docker/bin/provision run --tag bootstrap --role webdevops-nginx --role webdevops-php-nginx --role webdevops-nginx-dev --role webdevops-php-dev \ + && /opt/docker/bin/bootstrap.sh \ + && docker-image-cleanup + +EXPOSE 80 443 diff --git a/docker/php-nginx-dev/7.1/Dockerfile.jinja2 b/docker/php-nginx-dev/7.1/Dockerfile.jinja2 new file mode 100644 index 000000000..d508434dd --- /dev/null +++ b/docker/php-nginx-dev/7.1/Dockerfile.jinja2 @@ -0,0 +1,11 @@ +{{ docker.from("php-dev", "7.1") }} + +{{ environment.web() }} +{{ environment.webPhp() }} +{{ environment.webDevelopment() }} + +{{ docker.copy('conf/', '/opt/docker/') }} + +{{ nginx.debian('php-nginx nginx-dev php-dev') }} + +{{ docker.expose('80 443') }} diff --git a/docker/php-nginx-dev/7.1/conf/bin/service.d/blackfire-agent.d/10-init.sh b/docker/php-nginx-dev/7.1/conf/bin/service.d/blackfire-agent.d/10-init.sh new file mode 100644 index 000000000..fdffa2a0f --- /dev/null +++ b/docker/php-nginx-dev/7.1/conf/bin/service.d/blackfire-agent.d/10-init.sh @@ -0,0 +1 @@ +# placeholder diff --git a/docker/php-nginx-dev/7.1/conf/bin/service.d/blackfire-agent.sh b/docker/php-nginx-dev/7.1/conf/bin/service.d/blackfire-agent.sh new file mode 100644 index 000000000..fbec23cf3 --- /dev/null +++ b/docker/php-nginx-dev/7.1/conf/bin/service.d/blackfire-agent.sh @@ -0,0 +1,23 @@ +#!/usr/bin/env bash +set -e + +source /opt/docker/bin/config.sh + +BLACKFIRE_ARGS="" + +includeScriptDir "/opt/docker/bin/service.d/syslog-ng.d/" + +# blackfire.server_id +if [[ -n "${BLACKFIRE_SERVER_ID+x}" ]]; then + BLACKFIRE_ARGS="$BLACKFIRE_ARGS --server-id=\"${BLACKFIRE_SERVER_ID}\"" +fi + +# blackfire.server_token +if [[ -n "${BLACKFIRE_SERVER_TOKEN+x}" ]]; then + BLACKFIRE_ARGS="$BLACKFIRE_ARGS --server-token=\"${BLACKFIRE_SERVER_TOKEN}\"" +fi + +# create directory for unix socket +mkdir -p /var/run/blackfire + +eval exec blackfire-agent $BLACKFIRE_ARGS diff --git a/docker/php-nginx-dev/7.1/conf/bin/service.d/nginx.d/10-init.sh b/docker/php-nginx-dev/7.1/conf/bin/service.d/nginx.d/10-init.sh new file mode 100644 index 000000000..27b9776cc --- /dev/null +++ b/docker/php-nginx-dev/7.1/conf/bin/service.d/nginx.d/10-init.sh @@ -0,0 +1,25 @@ +if [[ ! -e "$WEB_DOCUMENT_ROOT" ]]; then + echo "" + echo "[WARNING] WEB_DOCUMENT_ROOT does not exists with path \"$WEB_DOCUMENT_ROOT\"!" + echo "" +fi + +# Prevent startup of nginx (ubuntu 16.04 needs it) +ln -f -s /var/lib/nginx/logs /var/log/nginx + +# Replace markers +go-replace \ + -s "" -r "$WEB_DOCUMENT_INDEX" \ + -s "" -r "$WEB_DOCUMENT_ROOT" \ + -s "" -r "$WEB_ALIAS_DOMAIN" \ + -s "" -r "$HOSTNAME" \ + -s "" -r "$WEB_PHP_SOCKET" \ + --path=/opt/docker/etc/nginx/ \ + --path-pattern='*.conf' \ + --ignore-empty + +if [[ -z "${WEB_PHP_SOCKET+x}" ]]; then + ## WEB_PHP_SOCKET is not set, remove PHP files + rm -f -- /opt/docker/etc/nginx/conf.d/10-php.conf + rm -f -- /opt/docker/etc/nginx/vhost.common.d/10-php.conf +fi diff --git a/docker/php-nginx-dev/7.1/conf/bin/service.d/nginx.d/12-development.sh b/docker/php-nginx-dev/7.1/conf/bin/service.d/nginx.d/12-development.sh new file mode 100644 index 000000000..f4695f059 --- /dev/null +++ b/docker/php-nginx-dev/7.1/conf/bin/service.d/nginx.d/12-development.sh @@ -0,0 +1,7 @@ +go-replace \ + -s "" \ + -r "$WEB_NO_CACHE_PATTERN" \ + --path=/opt/docker/etc/nginx/ \ + --path-pattern='*.conf' \ + --ignore-empty + diff --git a/docker/php-nginx/alpine-3-php7/conf/bin/service.d/nginx.sh b/docker/php-nginx-dev/7.1/conf/bin/service.d/nginx.sh similarity index 100% rename from docker/php-nginx/alpine-3-php7/conf/bin/service.d/nginx.sh rename to docker/php-nginx-dev/7.1/conf/bin/service.d/nginx.sh diff --git a/docker/php-nginx-dev/7.1/conf/etc/nginx/conf.d/.gitkeep b/docker/php-nginx-dev/7.1/conf/etc/nginx/conf.d/.gitkeep new file mode 100644 index 000000000..e69de29bb diff --git a/docker/php-nginx-dev/7.1/conf/etc/nginx/conf.d/02-dev.conf b/docker/php-nginx-dev/7.1/conf/etc/nginx/conf.d/02-dev.conf new file mode 100644 index 000000000..fdffa2a0f --- /dev/null +++ b/docker/php-nginx-dev/7.1/conf/etc/nginx/conf.d/02-dev.conf @@ -0,0 +1 @@ +# placeholder diff --git a/docker/php-nginx/alpine-3-php7/conf/etc/nginx/conf.d/10-php.conf b/docker/php-nginx-dev/7.1/conf/etc/nginx/conf.d/10-php.conf similarity index 100% rename from docker/php-nginx/alpine-3-php7/conf/etc/nginx/conf.d/10-php.conf rename to docker/php-nginx-dev/7.1/conf/etc/nginx/conf.d/10-php.conf diff --git a/docker/php-nginx-dev/7.1/conf/etc/nginx/global.conf b/docker/php-nginx-dev/7.1/conf/etc/nginx/global.conf new file mode 100644 index 000000000..b6141db09 --- /dev/null +++ b/docker/php-nginx-dev/7.1/conf/etc/nginx/global.conf @@ -0,0 +1 @@ +# deprecated diff --git a/docker/php-nginx/alpine-3-php7/conf/etc/nginx/main.conf b/docker/php-nginx-dev/7.1/conf/etc/nginx/main.conf similarity index 100% rename from docker/php-nginx/alpine-3-php7/conf/etc/nginx/main.conf rename to docker/php-nginx-dev/7.1/conf/etc/nginx/main.conf diff --git a/docker/php-nginx-dev/7.1/conf/etc/nginx/php.conf b/docker/php-nginx-dev/7.1/conf/etc/nginx/php.conf new file mode 100644 index 000000000..b6141db09 --- /dev/null +++ b/docker/php-nginx-dev/7.1/conf/etc/nginx/php.conf @@ -0,0 +1 @@ +# deprecated diff --git a/docker/php-nginx-dev/7.1/conf/etc/nginx/ssl/server.crt b/docker/php-nginx-dev/7.1/conf/etc/nginx/ssl/server.crt new file mode 100644 index 000000000..6b0694907 --- /dev/null +++ b/docker/php-nginx-dev/7.1/conf/etc/nginx/ssl/server.crt @@ -0,0 +1,28 @@ +-----BEGIN CERTIFICATE----- +MIIE1DCCArwCCQDMMwGnSuK0tTANBgkqhkiG9w0BAQsFADAsMRswGQYDVQQKExJE +b2NrZXIgQm9pbGVycGxhdGUxDTALBgNVBAMUBCoudm0wHhcNMTUwNTA0MTcxNDQw +WhcNMjUwNTAxMTcxNDQwWjAsMRswGQYDVQQKExJEb2NrZXIgQm9pbGVycGxhdGUx +DTALBgNVBAMUBCoudm0wggIiMA0GCSqGSIb3DQEBAQUAA4ICDwAwggIKAoICAQDK +3TIUiyDvXelWeY9VXMrpjuZtYpVSDsACLpjFUhMnsP5/iKT0VbeZyqHvmwZjAg4G +Y10d+yZDdgv/xeu0HPOFbtR6pCp10d1tdLHZto5Cyuxu7IQsAVjnD6Ko7XFwtNk7 +9o6JZfAFaGL4w5MokrVmCtspnsMZH7/7zU4f96cbF39zLopnpuXGD6t6DA8Qj3gy +0duaTjs42bYRN+rwLzVKAev99iQ4kPMJn4vV6/Xk6rtoSzC67GQyVZYaFypicD1S +NtsRmgEVvjCBDbrLOneUiRwff6qxEsZi7Hxv7BKFj4iUWnII7K/nP7T6uBHQjHO+ +FpsGkU9lCMrCeVFBe8kKz/cbhd+yLUxXwAPr6gSOPmwn232Gy4tozvqZHpbUxsgx +7sT3ej9K66h1D7J+BjNFWYM1hbnC1r7H/xS7EBzBV8qRoQCVe08Juf5xsouXFakD +clLV4+L+1cxkpwsCQDly5g3tm/TBqA2O+ZJ+YHQDHKkzMyhLs6i0X/M5qvJBiLg1 +GLTCS20rpQ5gXTEGuINqHgwXQWkUO6bhgSYqdHGX3zbZ5+qWpI4eui3dHZ1Ll0VH +6Icpb7ORTQwhc6W8KBlybssYPSlGOEBGUjYGNheoz9FpoSkxCis+P8ZNKtrmpPoq +Su0eOOGFOFHG02eOgPVxSwrDeN9MVJo7BPysGMHJmQIDAQABMA0GCSqGSIb3DQEB +CwUAA4ICAQC63g6NHmQKbiy3G6iaDkpUSbr5Mq2YgU61XnvWVyREqDcy/BXCw9oY +SJ/KUvCpqPnACNOFqjadRAmPiA9nf2WduoCgwQGV/YRFGswSuVvh/3X2TX5NWvbS +t8MQDttQg1dxpiMUjlu3rqhfohBdWJvp2lVSdpDb/MOlXBc/+p7HfOHwhqB7wwPN +NNbSKUbZqZxmD8cOf1X0hASr1yfFPj+2vST3ESaON8S0T2p63YX/sD5jvOUiEuyw +I5WcvLmiRZA07SH8nWyckLY3qWL+OlhSZrlAnolWS00b+7h5LNuRYEjKzwVgntoA +aCopyQih6wIk0+AfJO4sfhJBmQhnIrAaP/zwBH5g9zVizLf5H7U+hNXrMwgw55Sq +vjMdkZHvPKUXTvVit/rYE9H+PY3brkRWzOl4V/i/ZLJJm5805H/NyTbz9kPMJw2Q +nn+KOpfXXySD39f8iuRgSKXsYNul38hxWgcZZ6g+sOOp2n/VUmf0eZUWNnJ8i7AP +4Qif7aDKMcibOwSwsB+DKZXDvZ5XSdnMphtuLS5rPSL81rVRmWC2DMfQ2eP8j0WN +VTroSk0xedQ7Qr+9TNooi9IyzX6n1a2S1UiciEZ3ZcDbXPl/P01m+IYZyPnLv0+9 +ZeioZYh1JLv3/OKsMrMLTfh2ZCj3aXwmc2Owi/wU2LS5QUOMcHH7CQ== +-----END CERTIFICATE----- \ No newline at end of file diff --git a/docker/php-nginx-dev/7.1/conf/etc/nginx/ssl/server.csr b/docker/php-nginx-dev/7.1/conf/etc/nginx/ssl/server.csr new file mode 100644 index 000000000..8a9909f77 --- /dev/null +++ b/docker/php-nginx-dev/7.1/conf/etc/nginx/ssl/server.csr @@ -0,0 +1,26 @@ +-----BEGIN CERTIFICATE REQUEST----- +MIIEcTCCAlkCAQAwLDEbMBkGA1UEChMSRG9ja2VyIEJvaWxlcnBsYXRlMQ0wCwYD +VQQDFAQqLnZtMIICIjANBgkqhkiG9w0BAQEFAAOCAg8AMIICCgKCAgEAyt0yFIsg +713pVnmPVVzK6Y7mbWKVUg7AAi6YxVITJ7D+f4ik9FW3mcqh75sGYwIOBmNdHfsm +Q3YL/8XrtBzzhW7UeqQqddHdbXSx2baOQsrsbuyELAFY5w+iqO1xcLTZO/aOiWXw +BWhi+MOTKJK1ZgrbKZ7DGR+/+81OH/enGxd/cy6KZ6blxg+regwPEI94MtHbmk47 +ONm2ETfq8C81SgHr/fYkOJDzCZ+L1ev15Oq7aEswuuxkMlWWGhcqYnA9UjbbEZoB +Fb4wgQ26yzp3lIkcH3+qsRLGYux8b+wShY+IlFpyCOyv5z+0+rgR0IxzvhabBpFP +ZQjKwnlRQXvJCs/3G4Xfsi1MV8AD6+oEjj5sJ9t9hsuLaM76mR6W1MbIMe7E93o/ +SuuodQ+yfgYzRVmDNYW5wta+x/8UuxAcwVfKkaEAlXtPCbn+cbKLlxWpA3JS1ePi +/tXMZKcLAkA5cuYN7Zv0wagNjvmSfmB0AxypMzMoS7OotF/zOaryQYi4NRi0wktt +K6UOYF0xBriDah4MF0FpFDum4YEmKnRxl9822efqlqSOHrot3R2dS5dFR+iHKW+z +kU0MIXOlvCgZcm7LGD0pRjhARlI2BjYXqM/RaaEpMQorPj/GTSra5qT6KkrtHjjh +hThRxtNnjoD1cUsKw3jfTFSaOwT8rBjByZkCAwEAAaAAMA0GCSqGSIb3DQEBCwUA +A4ICAQBsEBgC2YepuZq/8UqvKMZKVy/etDKXj7BB+QPb+leNiKD7p4LDxHJsZSH8 +Ku9uMPeLfiQDn5jA41k5SlGttzvObd65RdEbO3yHpqsg05EGSDDLfaE1k2Al/qmX +/o8roPZF7+2kZthgMAgkcokS54LYqEYTGqOf3J9Ss0yRIZwhaOVebfFIbIOdpw0B +JNMIJPHTMdZrcuRVI+wR1uPLIlEJzBvxTGbTrvPU25WJFtu+EajKqXO0SHdy0yx8 +uH4ykRBJRc36+oYo7nZ5D56dh7pZn3+9J64FKAOV0Q3KqMFieGy053ezuhJd70eZ +UozTgfjs3WpMzoYmKETSyl3XZSdInRe+sUlKPruTsKyg69oYxjPlrGfAmmGcCFca +TnZinT18dI92zK7OtOVkmYeYKC1lwuhftVrNMXzZuHOGpS9NNYtc4nDqDMIEOfV3 +6rCdu03WjEgJ+Z67tJs16xOx9du4/EHxS2Ijn9DPfVJvYy0TgzDi1BUpjWx0KTLx +C4OQbEZ/QTWmHVbSch/hcZhzbf7SNh5RpnW4EtmcpDFjIKMfxJmoKeiTf7qnilx0 +7uRvsZFKoDKRDOFiPfgMg5AOtLHziYsd9m0tJjC2GHvFuPjzOtzhnUUjmmvht170 +2aqKakjST4amg7jzLcs871HX0/WjOtt29NpOz140blkKf1bisg== +-----END CERTIFICATE REQUEST----- \ No newline at end of file diff --git a/docker/php-nginx-dev/7.1/conf/etc/nginx/ssl/server.key b/docker/php-nginx-dev/7.1/conf/etc/nginx/ssl/server.key new file mode 100644 index 000000000..c9eec145f --- /dev/null +++ b/docker/php-nginx-dev/7.1/conf/etc/nginx/ssl/server.key @@ -0,0 +1,51 @@ +-----BEGIN RSA PRIVATE KEY----- +MIIJKAIBAAKCAgEAyt0yFIsg713pVnmPVVzK6Y7mbWKVUg7AAi6YxVITJ7D+f4ik +9FW3mcqh75sGYwIOBmNdHfsmQ3YL/8XrtBzzhW7UeqQqddHdbXSx2baOQsrsbuyE +LAFY5w+iqO1xcLTZO/aOiWXwBWhi+MOTKJK1ZgrbKZ7DGR+/+81OH/enGxd/cy6K +Z6blxg+regwPEI94MtHbmk47ONm2ETfq8C81SgHr/fYkOJDzCZ+L1ev15Oq7aEsw +uuxkMlWWGhcqYnA9UjbbEZoBFb4wgQ26yzp3lIkcH3+qsRLGYux8b+wShY+IlFpy +COyv5z+0+rgR0IxzvhabBpFPZQjKwnlRQXvJCs/3G4Xfsi1MV8AD6+oEjj5sJ9t9 +hsuLaM76mR6W1MbIMe7E93o/SuuodQ+yfgYzRVmDNYW5wta+x/8UuxAcwVfKkaEA +lXtPCbn+cbKLlxWpA3JS1ePi/tXMZKcLAkA5cuYN7Zv0wagNjvmSfmB0AxypMzMo +S7OotF/zOaryQYi4NRi0wkttK6UOYF0xBriDah4MF0FpFDum4YEmKnRxl9822efq +lqSOHrot3R2dS5dFR+iHKW+zkU0MIXOlvCgZcm7LGD0pRjhARlI2BjYXqM/RaaEp +MQorPj/GTSra5qT6KkrtHjjhhThRxtNnjoD1cUsKw3jfTFSaOwT8rBjByZkCAwEA +AQKCAgAbZPdoUsllyZbC+LNkYZ19ILD5QIDNjfRb1xMGQmkXyQz1B+zOmeyrNfPc +OWEJabOfJTfj3pByN7SzG3US4333HNpQnW6mbmqqZ0HFFqPrXR/Ecuf+UUhCG5hp +m3bgM2vKbyccYsmg0VHcKfzrU7RvTTP/UNMjx2fThwvvwS+ttuSdF0HVcXJB5sfP +OWWnZNhkdHZlRf81VCED/jsZqCZYEh5eMyj9AoXvXL4zayPPf+tC0DSKaXW2Xlxg +tZQhqup8+a9nlxZia0Z9hu8clo6jXkiP8FuKgfCMV0cOjiCKLLHS5svTbLLsVWwJ +F2ZAdVcD6mWQ43qHOEK5NEzGvQKO14CaOLnVT2yAkMcyNohsEgoDP9oCBGDJQbBH +NmtZfpVjjtuTr9P9TEkU1FcBRo0x6Il/DkzamGbOeFAmgnaGElhJ5c/CAG7whaIf +mUfFOBGPH/wESY3gBOACDofeSh27RrlvbLaPiCGKivDUTBmhBsIuso6XqOKbvtfV +/HhhndpdRVfIj4DdE7gIrLIGN977JMVAXFCNz7KrvAWwcOXrCHCoWpklJ9repq8l +26ICY8K7VXktzDHQUmhd88ZWR+9ASURsJghUgZUOcMrEGyvci6Y8hpLhHiNVPHuQ ++ps7tpPsXSntBUqWBzhRZh74+nJlOOV6oYykl30JT2JzB6lwiQKCAQEA9ecn8N2z +20tR2UEiTv/MjVSepQtAAajegvcd1iasvvQKXnh3XLmoZHzH2tTa0lp5RIZpUQPl +lOTwko0lYTBnYblt65AJQ3FTgisNobIpoqE8BFXLm6wggz7CbabjmPGDe173lPGR +sI0YSKYvzrdn4zw8Fh6WULJyZHLi58zJYL3r0WBDiOoxpGaGA1GlmkuIWjhKHaX2 +OvF1vOuQDJ2eDyTc5TYFC0NKG76Mvanov5L/yrhNM/umbmp0SPspzHGZobAKUr20 +OazFT8S+2TA1OTxWNbiPbSimFoaZbEdqsNACGfVJWO8Sh8iqlt5RmEcSiSvGBj6L +QKprRO9Fsp2GawKCAQEA0zGhRsnux4JTNsdUSYsEJtITMj6eE+nl7CoZ9DAOwC5X +6/aSpUE4TT+pWNrt9iluXiGL0j89UJ7r/L1OcsiyzGb8ig9NU4zr1NIGTZ0DstHi +HPYINjeiBJEFIy17kOQn+9/I5c4hBUwz6ihwNoEomymVB/EsLJKAML0AudJGKg+Z +/f/qrS40eab5SAiaKgsh0MZnj+vIxyGBydt6r2HGmjfNITVbXIu6IpO+6NXDwM/e +7v10AAZ3j9+gb1RedLg2ghuIuYU90hmMhtVWsh9nVmaOkMW9/WFgOPYvt/mHH/hR +d4pePZ9kACGmqo/b9sHvHw1YEubtCt1VUiNuFxnJCwKCAQBWnxz0vkRTJY8phsY9 +KeK2jm5sGTBs5T2syLwb6ffENFdKvAjgAw6Mh2And/+1ReWd+/MxdLv03UjZdxsJ +x3FDfXx5FH4O4ebW3a+pnAcKoN1xcX+N0O6LDRqUYcue3sTAOs3gC9CUbr91KAWD +Phw8ccWAzTmKJ7IgLFA982ekyoI9eTmRC159WRgwJxy844qerWF+XC4GyXP+HsTZ +jNRW5Vdi7sqMEyIR7+fIEAhLI88zbATWIPmZv6pC4ybwO7wwtsCMMQNBpdjDprzL +6S12ggikV+U+QKlxGe0FtYqhykRTPJKf32eZqVheWOZJTA/9fgv9ux52oxGycM8O +gmsNAoIBAQC60m5uZnd5uYnPLWkcXYNgq/kbO1UvHHut/FhVMKX7z4MrU0XKNfWO +MECoP5K9bU0aq+Y6KIMe7FapjvT0iSHRu1Cu+HZY8JI2A0xcIAeDijLRl7sP6wrB +q1+2DKgANjRAlWfsEfoX658JBpitPngjOheBnRCMpVQMyUT5HE/BKWf5zwdUB0mY +S+K8nA90HcDeJIS8RcGolbVwUV0oBABhr/cf50lYhqozqCr7YQ33ZGs7Uq3oz8+4 +UARmN2YPLl3Znm3GX12em8c6B0LX8vvA7Jw06Rf2Ksup1+3Ce1PTLiEy9A4FyRf3 +Hc2HmBbnJAtZlr5QikMqlzzAmmLqwH6dAoIBAC+ryaQGJFsijCSuaDfRp/uy9xnd +DjgMdTwjl5WLBmyudChVMANl8eqCbvVO41CN84yORk03oQ4cx0eKxAZaLaSzgkb3 +W0X2nFQe7VJSYMQswCQ+1WfJvEFrIdkEKIa//uQdhqNrgUKSNVhhSTMbNEkDTIWn +ssbv2H9hvUaFt/J/vP9zCKuU5oYvNU7Oi6ZXRYezRn9atlJYanLFoJnHUBRzGms5 +K0vhdCPDXQq87z5Yudoh0jLUQF9Nx0GTWeBceQ9n5hZeRUNQWxP4AJThQX9KSPTS +mbL3Kh4XNRmAUJ2N+Njh+3dg91s+JkKvC1wcspLsmLPQe+9AxBSH9y5JE/8= +-----END RSA PRIVATE KEY----- \ No newline at end of file diff --git a/docker/php-nginx/alpine-3-php7/conf/etc/nginx/vhost.common.conf b/docker/php-nginx-dev/7.1/conf/etc/nginx/vhost.common.conf similarity index 100% rename from docker/php-nginx/alpine-3-php7/conf/etc/nginx/vhost.common.conf rename to docker/php-nginx-dev/7.1/conf/etc/nginx/vhost.common.conf diff --git a/docker/php-nginx-dev/7.1/conf/etc/nginx/vhost.common.d/.gitkeep b/docker/php-nginx-dev/7.1/conf/etc/nginx/vhost.common.d/.gitkeep new file mode 100644 index 000000000..e69de29bb diff --git a/docker/php-nginx-dev/7.1/conf/etc/nginx/vhost.common.d/02-dev.conf b/docker/php-nginx-dev/7.1/conf/etc/nginx/vhost.common.d/02-dev.conf new file mode 100644 index 000000000..4f80ec9d3 --- /dev/null +++ b/docker/php-nginx-dev/7.1/conf/etc/nginx/vhost.common.d/02-dev.conf @@ -0,0 +1,6 @@ +location ~* { + expires off; + add_header Cache-Control private; + + try_files $uri $uri/ /?$query_string; +} diff --git a/docker/php-nginx-dev/7.1/conf/etc/nginx/vhost.common.d/10-general.conf b/docker/php-nginx-dev/7.1/conf/etc/nginx/vhost.common.d/10-general.conf new file mode 100644 index 000000000..d3fd0aa5e --- /dev/null +++ b/docker/php-nginx-dev/7.1/conf/etc/nginx/vhost.common.d/10-general.conf @@ -0,0 +1 @@ +client_max_body_size 50m; diff --git a/docker/php-nginx/alpine-3-php7/conf/etc/nginx/vhost.common.d/10-location-root.conf b/docker/php-nginx-dev/7.1/conf/etc/nginx/vhost.common.d/10-location-root.conf similarity index 100% rename from docker/php-nginx/alpine-3-php7/conf/etc/nginx/vhost.common.d/10-location-root.conf rename to docker/php-nginx-dev/7.1/conf/etc/nginx/vhost.common.d/10-location-root.conf diff --git a/docker/php-nginx-dev/7.1/conf/etc/nginx/vhost.common.d/10-log.conf b/docker/php-nginx-dev/7.1/conf/etc/nginx/vhost.common.d/10-log.conf new file mode 100644 index 000000000..a2cd929e7 --- /dev/null +++ b/docker/php-nginx-dev/7.1/conf/etc/nginx/vhost.common.d/10-log.conf @@ -0,0 +1,2 @@ +access_log /docker.stdout; +error_log /docker.stderr info; diff --git a/docker/php-nginx/alpine-3-php7/conf/etc/nginx/vhost.common.d/10-php.conf b/docker/php-nginx-dev/7.1/conf/etc/nginx/vhost.common.d/10-php.conf similarity index 100% rename from docker/php-nginx/alpine-3-php7/conf/etc/nginx/vhost.common.d/10-php.conf rename to docker/php-nginx-dev/7.1/conf/etc/nginx/vhost.common.d/10-php.conf diff --git a/docker/php-nginx-dev/7.1/conf/etc/nginx/vhost.conf b/docker/php-nginx-dev/7.1/conf/etc/nginx/vhost.conf new file mode 100644 index 000000000..8225f314a --- /dev/null +++ b/docker/php-nginx-dev/7.1/conf/etc/nginx/vhost.conf @@ -0,0 +1,26 @@ +server { + listen 80 default_server; + + server_name _ docker; + + root ""; + index ; + + include /opt/docker/etc/nginx/vhost.common.d/*.conf; +} + +############## +# SSL +############## + +server { + listen 443 default_server; + + server_name _ docker; + + root ""; + index ; + + include /opt/docker/etc/nginx/vhost.common.d/*.conf; + include /opt/docker/etc/nginx/vhost.ssl.conf; +} diff --git a/docker/php-nginx/alpine-3-php7/conf/etc/nginx/vhost.ssl.conf b/docker/php-nginx-dev/7.1/conf/etc/nginx/vhost.ssl.conf similarity index 100% rename from docker/php-nginx/alpine-3-php7/conf/etc/nginx/vhost.ssl.conf rename to docker/php-nginx-dev/7.1/conf/etc/nginx/vhost.ssl.conf diff --git a/docker/php-nginx-dev/7.1/conf/etc/supervisor.d/blackfire-agent.conf b/docker/php-nginx-dev/7.1/conf/etc/supervisor.d/blackfire-agent.conf new file mode 100644 index 000000000..897831ddb --- /dev/null +++ b/docker/php-nginx-dev/7.1/conf/etc/supervisor.d/blackfire-agent.conf @@ -0,0 +1,14 @@ +[group:blackfire-agent] +programs=blackfire-agentd +priority=25 + +[program:blackfire-agentd] +command = /opt/docker/bin/service.d/blackfire-agent.sh +process_name=%(program_name)s +startsecs = 0 +autostart = false +autorestart = true +stdout_logfile=/dev/stdout +stdout_logfile_maxbytes=0 +stderr_logfile=/dev/stderr +stderr_logfile_maxbytes=0 diff --git a/docker/php-nginx/alpine-3-php7/conf/etc/supervisor.d/nginx.conf b/docker/php-nginx-dev/7.1/conf/etc/supervisor.d/nginx.conf similarity index 100% rename from docker/php-nginx/alpine-3-php7/conf/etc/supervisor.d/nginx.conf rename to docker/php-nginx-dev/7.1/conf/etc/supervisor.d/nginx.conf diff --git a/docker/php-nginx-dev/7.1/conf/provision/entrypoint.d/10-php-debugger.sh b/docker/php-nginx-dev/7.1/conf/provision/entrypoint.d/10-php-debugger.sh new file mode 100644 index 000000000..b5985a9ef --- /dev/null +++ b/docker/php-nginx-dev/7.1/conf/provision/entrypoint.d/10-php-debugger.sh @@ -0,0 +1,96 @@ +#!/usr/bin/env bash + +################################################# +# Debugger switch +################################################# + +PHP_CONF_PATHS=" +/etc/php5/conf.d +/etc/php7/conf.d +/etc/php.d +/etc/php5/mods-available +/etc/php5/cli/conf.d +/etc/php5/cli/conf.d +/etc/php5/fpm/conf.d +/etc/php5/fpm/conf.d +/etc/php/7.0/mods-available +/etc/php/7.0/cli/conf.d +/etc/php/7.0/fpm/conf.d +/usr/local/etc/php/conf.d/" + +function phpModuleRemove() { + if [ "$#" -ne 1 ]; then + echo "You must specify the name of the PHP module which you want to disable" + exit 1 + fi + + echo " - Removing PHP module ${1}" + for CONF_PATH in $PHP_CONF_PATHS; do + rm -f "${CONF_PATH}"/*"${1}".ini + done +} + + +if [[ -n "${PHP_DEBUGGER+x}" ]]; then + case "$PHP_DEBUGGER" in + xdebug) + echo "PHP-Debugger: Xdebug enabled" + phpModuleRemove "blackfire" + ;; + + blackfire) + echo "PHP-Debugger: Blackfire enabled" + phpModuleRemove "xdebug" + docker-service-enable blackfire-agent + ;; + + none) + echo "PHP-Debugger: none" + phpModuleRemove "blackfire" + phpModuleRemove "xdebug" + ;; + esac + +else + + echo "PHP-Debugger: not specified - default is xdebug" + phpModuleRemove "blackfire" + +fi + +################################################# +# PHP debugger environment variables +################################################# + +function phpEnvironmentVariable() { + PHP_INI_KEY="$1" + PHP_ENV_NAME="$2" + + if [[ -n "${!PHP_ENV_NAME+x}" ]]; then + PHP_ENV_VALUE="${!PHP_ENV_NAME}" + echo "${PHP_INI_KEY}=\"${PHP_ENV_VALUE}\"" >> /opt/docker/etc/php/php.ini + fi +} + +################### +# XDEBUG +################### + +# remote debugger +phpEnvironmentVariable "xdebug.remote_connect_back" "XDEBUG_REMOTE_CONNECT_BACK" +phpEnvironmentVariable "xdebug.remote_autostart" "XDEBUG_REMOTE_AUTOSTART" +phpEnvironmentVariable "xdebug.remote_host" "XDEBUG_REMOTE_HOST" +phpEnvironmentVariable "xdebug.remote_port" "XDEBUG_REMOTE_PORT" + +# profiler +phpEnvironmentVariable "xdebug.profiler_enable" "XDEBUG_PROFILER_ENABLE" +phpEnvironmentVariable "xdebug.profiler_enable_trigger" "XDEBUG_PROFILER_ENABLE_TRIGGER" +phpEnvironmentVariable "xdebug.profiler_enable_trigger_value" "XDEBUG_PROFILER_ENABLE_TRIGGER_VALUE" +phpEnvironmentVariable "xdebug.profiler_output_dir" "XDEBUG_PROFILER_OUTPUT_DIR" +phpEnvironmentVariable "xdebug.profiler_output_name" "XDEBUG_PROFILER_OUTPUT_NAME" + +################### +# BLACKFIRE +################### +phpEnvironmentVariable "blackfire.server_id" "BLACKFIRE_SERVER_ID" +phpEnvironmentVariable "blackfire.server_token" "BLACKFIRE_SERVER_TOKEN" diff --git a/docker/php-nginx-dev/7.1/conf/provision/roles/webdevops-nginx-dev/defaults/main.yml b/docker/php-nginx-dev/7.1/conf/provision/roles/webdevops-nginx-dev/defaults/main.yml new file mode 100644 index 000000000..81f5b7efd --- /dev/null +++ b/docker/php-nginx-dev/7.1/conf/provision/roles/webdevops-nginx-dev/defaults/main.yml @@ -0,0 +1,6 @@ +--- + +APPLICATION_USER: "{{ lookup('env','APPLICATION_USER') }}" +APPLICATION_GROUP: "{{ lookup('env','APPLICATION_GROUP') }}" +APPLICATION_UID: "{{ lookup('env','APPLICATION_UID') }}" +APPLICATION_GID: "{{ lookup('env','APPLICATION_GID') }}" diff --git a/docker/php-nginx-dev/7.1/conf/provision/roles/webdevops-nginx-dev/tasks/bootstrap.yml b/docker/php-nginx-dev/7.1/conf/provision/roles/webdevops-nginx-dev/tasks/bootstrap.yml new file mode 100644 index 000000000..3e783736c --- /dev/null +++ b/docker/php-nginx-dev/7.1/conf/provision/roles/webdevops-nginx-dev/tasks/bootstrap.yml @@ -0,0 +1,3 @@ +--- + +- include: bootstrap/nginx.yml diff --git a/docker/php-nginx-dev/7.1/conf/provision/roles/webdevops-nginx-dev/tasks/bootstrap/nginx.yml b/docker/php-nginx-dev/7.1/conf/provision/roles/webdevops-nginx-dev/tasks/bootstrap/nginx.yml new file mode 100644 index 000000000..8075b2d9d --- /dev/null +++ b/docker/php-nginx-dev/7.1/conf/provision/roles/webdevops-nginx-dev/tasks/bootstrap/nginx.yml @@ -0,0 +1,9 @@ +--- + +- name: Disable sendfile for nginx + lineinfile: + dest: /etc/nginx/nginx.conf + regexp: '[\s;]*{{ item.key }}[\s]*' + line: '{{ item.key }} {{ item.value }};' + with_items: + - { key: 'sendfile', value: "off" } diff --git a/docker/php-nginx-dev/7.1/conf/provision/roles/webdevops-nginx-dev/tasks/main.yml b/docker/php-nginx-dev/7.1/conf/provision/roles/webdevops-nginx-dev/tasks/main.yml new file mode 100644 index 000000000..1806c1a8c --- /dev/null +++ b/docker/php-nginx-dev/7.1/conf/provision/roles/webdevops-nginx-dev/tasks/main.yml @@ -0,0 +1,5 @@ +--- + +- include: bootstrap.yml + tags: + - bootstrap diff --git a/docker/php-nginx-dev/7.1/conf/provision/roles/webdevops-nginx/defaults/main.yml b/docker/php-nginx-dev/7.1/conf/provision/roles/webdevops-nginx/defaults/main.yml new file mode 100644 index 000000000..69cba1cb4 --- /dev/null +++ b/docker/php-nginx-dev/7.1/conf/provision/roles/webdevops-nginx/defaults/main.yml @@ -0,0 +1,3 @@ +--- + +DOCUMENT_ROOT: "{{ lookup('env','WEB_DOCUMENT_ROOT') }}" diff --git a/docker/php-nginx/alpine-3-php7/conf/provision/roles/webdevops-nginx/tasks/bootstrap.yml b/docker/php-nginx-dev/7.1/conf/provision/roles/webdevops-nginx/tasks/bootstrap.yml similarity index 100% rename from docker/php-nginx/alpine-3-php7/conf/provision/roles/webdevops-nginx/tasks/bootstrap.yml rename to docker/php-nginx-dev/7.1/conf/provision/roles/webdevops-nginx/tasks/bootstrap.yml diff --git a/docker/php-nginx-dev/7.1/conf/provision/roles/webdevops-nginx/tasks/main.yml b/docker/php-nginx-dev/7.1/conf/provision/roles/webdevops-nginx/tasks/main.yml new file mode 100644 index 000000000..1806c1a8c --- /dev/null +++ b/docker/php-nginx-dev/7.1/conf/provision/roles/webdevops-nginx/tasks/main.yml @@ -0,0 +1,5 @@ +--- + +- include: bootstrap.yml + tags: + - bootstrap diff --git a/docker/php-nginx-dev/7.1/conf/provision/roles/webdevops-php-dev/defaults/main.yml b/docker/php-nginx-dev/7.1/conf/provision/roles/webdevops-php-dev/defaults/main.yml new file mode 100644 index 000000000..81f5b7efd --- /dev/null +++ b/docker/php-nginx-dev/7.1/conf/provision/roles/webdevops-php-dev/defaults/main.yml @@ -0,0 +1,6 @@ +--- + +APPLICATION_USER: "{{ lookup('env','APPLICATION_USER') }}" +APPLICATION_GROUP: "{{ lookup('env','APPLICATION_GROUP') }}" +APPLICATION_UID: "{{ lookup('env','APPLICATION_UID') }}" +APPLICATION_GID: "{{ lookup('env','APPLICATION_GID') }}" diff --git a/docker/php-nginx-dev/7.1/conf/provision/roles/webdevops-php-dev/tasks/bootstrap.yml b/docker/php-nginx-dev/7.1/conf/provision/roles/webdevops-php-dev/tasks/bootstrap.yml new file mode 100644 index 000000000..ff02b05fc --- /dev/null +++ b/docker/php-nginx-dev/7.1/conf/provision/roles/webdevops-php-dev/tasks/bootstrap.yml @@ -0,0 +1,7 @@ +--- + +- include: bootstrap/php-fpm.yml +- include: bootstrap/php-module.yml +- include: bootstrap/php-module.opcache.yml +- include: bootstrap/php-module.xdebug.yml +- include: bootstrap/php-module.blackfire.yml diff --git a/docker/php-nginx-dev/7.1/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/php-fpm.yml b/docker/php-nginx-dev/7.1/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/php-fpm.yml new file mode 100644 index 000000000..9455a78e2 --- /dev/null +++ b/docker/php-nginx-dev/7.1/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/php-fpm.yml @@ -0,0 +1,18 @@ +--- + +- name: Configure php-fpm pool user (application.conf) + lineinfile: + dest: '/opt/docker/etc/php/fpm/pool.d/application.conf' + regexp: '^[\s;]*{{ item.key }}[\s]*=' + line: '{{ item.key }} = {{ item.value }}' + with_items: + - { key: 'access.log', value: "/docker.stdout" } + - { key: "access.format", value: '"%R - %u %t \"%m %r%Q%q\" %s %f cpu:%C%% mem:%{megabytes}M reqTime:%d"' } + +- name: Open php-fpm for external connections (eg. debuggers) + lineinfile: + dest: '/opt/docker/etc/php/fpm/pool.d/application.conf' + regexp: '^[\s;]*{{ item.key }}[\s]*=' + line: '{{ item.key }} = {{ item.value }}' + with_items: + - { key: 'listen', value: "0.0.0.0:9000" } diff --git a/docker/php-nginx-dev/7.1/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/php-module.blackfire.yml b/docker/php-nginx-dev/7.1/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/php-module.blackfire.yml new file mode 100644 index 000000000..faf05f8de --- /dev/null +++ b/docker/php-nginx-dev/7.1/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/php-module.blackfire.yml @@ -0,0 +1,10 @@ +--- + +- name: Remove superfluous blackfire configuration file + file: + path: '{{ item }}' + state: absent + with_items: + - /etc/php5/cli/conf.d/zz-blackfire.ini + - /etc/php5/fpm/conf.d/zz-blackfire.ini + when: ansible_distribution == 'Debian' and docker_image_info_distribution_version|int >= 7 diff --git a/docker/php-nginx-dev/7.1/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/php-module.opcache.yml b/docker/php-nginx-dev/7.1/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/php-module.opcache.yml new file mode 100644 index 000000000..9c243a671 --- /dev/null +++ b/docker/php-nginx-dev/7.1/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/php-module.opcache.yml @@ -0,0 +1,14 @@ +--- + +- name: Setup php.ini for development environment + lineinfile: + dest: '/opt/docker/etc/php/php.webdevops.ini' + regexp: '^[\s;]*{{ item.variable }}[\s]*=' + line: '{{ item.variable }} = {{ item.value }}' + with_items: + - { variable: 'opcache.memory_consumption', value: '256' } + - { variable: 'opcache.validate_timestamps', value: '1' } + - { variable: 'opcache.revalidate_freq', value: '0' } + - { variable: 'opcache.interned_strings_buffer', value: '16' } + - { variable: 'opcache.max_accelerated_files', value: '7963' } + - { variable: 'opcache.fast_shutdown', value: '1' } diff --git a/docker/php-nginx-dev/7.1/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/php-module.xdebug.yml b/docker/php-nginx-dev/7.1/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/php-module.xdebug.yml new file mode 100644 index 000000000..7f20c845e --- /dev/null +++ b/docker/php-nginx-dev/7.1/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/php-module.xdebug.yml @@ -0,0 +1,28 @@ +--- + +# Ignored on php7 +- name: Fix php xdebug module [Alpine family] + lineinfile: + dest: '{{ item }}' + regexp: 'extension=xdebug.so' + line: 'zend_extension=xdebug.so' + when: ansible_distribution == 'Alpine' + with_items: + - /etc/php5/conf.d/xdebug.ini + - /etc/php7/conf.d/xdebug.ini + ignore_errors: yes + +- name: Setup php.ini for development environment + lineinfile: + dest: '/opt/docker/etc/php/php.webdevops.ini' + regexp: '^[\s;]*{{ item.variable }}[\s]*=' + line: '{{ item.variable }} = {{ item.value }}' + with_items: + - { variable: 'xdebug.remote_enable', value: '1' } + - { variable: 'xdebug.remote_connect_back', value: '1' } + - { variable: 'xdebug.idekey', value: 'docker' } + - { variable: 'xdebug.cli_color', value: '1' } + - { variable: 'xdebug.max_nesting_level', value: '1000' } + - { variable: 'xdebug.profiler_enable_trigger', value: '1000' } + - { variable: 'xdebug.profiler_output_dir', value: '/tmp/debug/' } + - { variable: 'xhprof.output_dir', value: '/tmp/debug/' } diff --git a/docker/php-nginx-dev/7.1/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/php-module.yml b/docker/php-nginx-dev/7.1/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/php-module.yml new file mode 100644 index 000000000..31cccd1ae --- /dev/null +++ b/docker/php-nginx-dev/7.1/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/php-module.yml @@ -0,0 +1,41 @@ +--- + +############################# +# Workaround PHP configuration files +# for alpine +############################# + +- name: Get list of PHP5 configuration files + command: "ls /etc/php5/conf.d/ |grep .ini" + register: php5_ini + when: ansible_distribution == 'Alpine' + ignore_errors: yes + +- name: Link configuration files from php5 to php + file: + src: '/etc/php5/conf.d/{{ item }}' + dest: '/etc/php/conf.d/{{ item }}' + state: link + with_items: "{{ php5_ini.stdout_lines }}" + when: ansible_distribution == 'Alpine' and php5_ini is defined + ignore_errors: yes + +############################# +# Workaround PHP module files +# for alpine +############################# + +- name: Get list of PHP5 modules + command: "ls /usr/lib/php5/modules/ |grep .so" + register: php5_modules + when: ansible_distribution == 'Alpine' + ignore_errors: yes + +- name: Link module files from php5 to php + file: + src: '/usr/lib/php5/modules/{{ item }}' + dest: '/usr/lib/php/modules/{{ item }}' + state: link + with_items: "{{ php5_modules.stdout_lines }}" + when: ansible_distribution == 'Alpine' and php5_modules is defined + ignore_errors: yes diff --git a/docker/php-nginx-dev/7.1/conf/provision/roles/webdevops-php-dev/tasks/main.yml b/docker/php-nginx-dev/7.1/conf/provision/roles/webdevops-php-dev/tasks/main.yml new file mode 100644 index 000000000..1806c1a8c --- /dev/null +++ b/docker/php-nginx-dev/7.1/conf/provision/roles/webdevops-php-dev/tasks/main.yml @@ -0,0 +1,5 @@ +--- + +- include: bootstrap.yml + tags: + - bootstrap diff --git a/docker/php-nginx-dev/7.1/conf/provision/roles/webdevops-php-nginx/defaults/main.yml b/docker/php-nginx-dev/7.1/conf/provision/roles/webdevops-php-nginx/defaults/main.yml new file mode 100644 index 000000000..ed97d539c --- /dev/null +++ b/docker/php-nginx-dev/7.1/conf/provision/roles/webdevops-php-nginx/defaults/main.yml @@ -0,0 +1 @@ +--- diff --git a/docker/php-nginx/alpine-3-php7/conf/provision/roles/webdevops-php-nginx/tasks/bootstrap.yml b/docker/php-nginx-dev/7.1/conf/provision/roles/webdevops-php-nginx/tasks/bootstrap.yml similarity index 100% rename from docker/php-nginx/alpine-3-php7/conf/provision/roles/webdevops-php-nginx/tasks/bootstrap.yml rename to docker/php-nginx-dev/7.1/conf/provision/roles/webdevops-php-nginx/tasks/bootstrap.yml diff --git a/docker/php-nginx-dev/7.1/conf/provision/roles/webdevops-php-nginx/tasks/entrypoint.yml b/docker/php-nginx-dev/7.1/conf/provision/roles/webdevops-php-nginx/tasks/entrypoint.yml new file mode 100644 index 000000000..cd21505a4 --- /dev/null +++ b/docker/php-nginx-dev/7.1/conf/provision/roles/webdevops-php-nginx/tasks/entrypoint.yml @@ -0,0 +1,2 @@ +--- + diff --git a/docker/php-nginx-dev/7.1/conf/provision/roles/webdevops-php-nginx/tasks/main.yml b/docker/php-nginx-dev/7.1/conf/provision/roles/webdevops-php-nginx/tasks/main.yml new file mode 100644 index 000000000..7895a52a9 --- /dev/null +++ b/docker/php-nginx-dev/7.1/conf/provision/roles/webdevops-php-nginx/tasks/main.yml @@ -0,0 +1,9 @@ +--- + +- include: bootstrap.yml + tags: + - bootstrap + +- include: entrypoint.yml + tags: + - entrypoint diff --git a/docker/php-nginx-dev/alpine b/docker/php-nginx-dev/alpine new file mode 120000 index 000000000..a5e678cb6 --- /dev/null +++ b/docker/php-nginx-dev/alpine @@ -0,0 +1 @@ +alpine-php7 \ No newline at end of file diff --git a/docker/php-nginx-dev/alpine-3 b/docker/php-nginx-dev/alpine-3 new file mode 120000 index 000000000..a84cfe247 --- /dev/null +++ b/docker/php-nginx-dev/alpine-3 @@ -0,0 +1 @@ +alpine-php5 \ No newline at end of file diff --git a/docker/php-nginx-dev/alpine-3-php7 b/docker/php-nginx-dev/alpine-3-php7 new file mode 120000 index 000000000..a5e678cb6 --- /dev/null +++ b/docker/php-nginx-dev/alpine-3-php7 @@ -0,0 +1 @@ +alpine-php7 \ No newline at end of file diff --git a/docker/php-nginx-dev/alpine-3-php7/Dockerfile b/docker/php-nginx-dev/alpine-3-php7/Dockerfile deleted file mode 100644 index 4e8a1d541..000000000 --- a/docker/php-nginx-dev/alpine-3-php7/Dockerfile +++ /dev/null @@ -1,28 +0,0 @@ -#+++++++++++++++++++++++++++++++++++++++ -# Dockerfile for webdevops/php-nginx-dev:alpine-3-php7 -# -- automatically generated -- -#+++++++++++++++++++++++++++++++++++++++ - -FROM webdevops/php-dev:alpine-3-php7 - -MAINTAINER info@webdevops.io -LABEL vendor=WebDevOps.io -LABEL io.webdevops.layout=8 -LABEL io.webdevops.version=1.5.0 - -ENV WEB_DOCUMENT_ROOT /app -ENV WEB_DOCUMENT_INDEX index.php -ENV WEB_ALIAS_DOMAIN *.vm -ENV WEB_PHP_SOCKET 127.0.0.1:9000 -ENV WEB_NO_CACHE_PATTERN "\.(css|js|gif|png|jpg|svg|json|xml)$" - -COPY conf/ /opt/docker/ - -# Install nginx -RUN /usr/local/bin/apk-install \ - nginx \ - && /opt/docker/bin/provision run --tag bootstrap --role webdevops-nginx --role webdevops-php-nginx --role webdevops-nginx-dev --role webdevops-php-dev \ - && /opt/docker/bin/bootstrap.sh - - -EXPOSE 80 443 diff --git a/docker/php-nginx-dev/alpine-3-php7/Dockerfile.jinja2 b/docker/php-nginx-dev/alpine-3-php7/Dockerfile.jinja2 deleted file mode 100644 index 2d52cb8cd..000000000 --- a/docker/php-nginx-dev/alpine-3-php7/Dockerfile.jinja2 +++ /dev/null @@ -1,13 +0,0 @@ -{{ docker.from("php-dev", "alpine-3-php7") }} - -{{ docker.version() }} - -{{ environment.web() }} -{{ environment.webPhp() }} -{{ environment.webDevelopment() }} - -{{ docker.copy('conf/', '/opt/docker/') }} - -{{ nginx.alpine('php-nginx nginx-dev php-dev') }} - -{{ docker.expose('80 443') }} diff --git a/docker/php-nginx-dev/alpine-3-php7/conf/bin/service.d/nginx.d/10-init.sh b/docker/php-nginx-dev/alpine-3-php7/conf/bin/service.d/nginx.d/10-init.sh deleted file mode 100644 index 75a84a4eb..000000000 --- a/docker/php-nginx-dev/alpine-3-php7/conf/bin/service.d/nginx.d/10-init.sh +++ /dev/null @@ -1,23 +0,0 @@ -if [[ ! -e "$WEB_DOCUMENT_ROOT" ]]; then - echo "" - echo "[WARNING] WEB_DOCUMENT_ROOT does not exists with path \"$WEB_DOCUMENT_ROOT\"!" - echo "" -fi - -# Prevent startup of nginx (ubuntu 16.04 needs it) -ln -f -s /var/lib/nginx/logs /var/log/nginx - -# Replace markers -find /opt/docker/etc/nginx/ -iname '*.conf' -print0 | xargs -0 -r rpl --quiet "" "$WEB_DOCUMENT_INDEX" > /dev/null -find /opt/docker/etc/nginx/ -iname '*.conf' -print0 | xargs -0 -r rpl --quiet "" "$WEB_DOCUMENT_ROOT" > /dev/null -find /opt/docker/etc/nginx/ -iname '*.conf' -print0 | xargs -0 -r rpl --quiet "" "$WEB_ALIAS_DOMAIN" > /dev/null -find /opt/docker/etc/nginx/ -iname '*.conf' -print0 | xargs -0 -r rpl --quiet "" "$HOSTNAME" > /dev/null - -if [[ -n "${WEB_PHP_SOCKET+x}" ]]; then - ## WEB_PHP_SOCKET is set - find /opt/docker/etc/nginx/ -iname '*.conf' -print0 | xargs -0 -r rpl --quiet "" "$WEB_PHP_SOCKET" > /dev/null -else - ## WEB_PHP_SOCKET is not set, remove PHP files - rm -f -- /opt/docker/etc/nginx/conf.d/10-php.conf - rm -f -- /opt/docker/etc/nginx/vhost.common.d/10-php.conf -fi diff --git a/docker/php-nginx-dev/alpine-3-php7/conf/bin/service.d/nginx.d/12-development.sh b/docker/php-nginx-dev/alpine-3-php7/conf/bin/service.d/nginx.d/12-development.sh deleted file mode 100644 index fa4b601a9..000000000 --- a/docker/php-nginx-dev/alpine-3-php7/conf/bin/service.d/nginx.d/12-development.sh +++ /dev/null @@ -1 +0,0 @@ -find /opt/docker/etc/nginx/ -iname '*.conf' -print0 | xargs -0 -r rpl --quiet "" "$WEB_NO_CACHE_PATTERN" > /dev/null diff --git a/docker/php-nginx-dev/alpine-3-php7/conf/etc/nginx/vhost.conf b/docker/php-nginx-dev/alpine-3-php7/conf/etc/nginx/vhost.conf deleted file mode 100644 index d07e27094..000000000 --- a/docker/php-nginx-dev/alpine-3-php7/conf/etc/nginx/vhost.conf +++ /dev/null @@ -1,38 +0,0 @@ -server { - listen 80 default_server; - listen 8000 default_server; - - server_name _ docker; - - access_log /docker.stdout; - error_log /docker.stdout info; - - root ""; - index ; - - client_max_body_size 50m; - - include /opt/docker/etc/nginx/vhost.common.d/*.conf; -} - -############## -# SSL -############## - -server { - listen 443 default_server; - listen 8443 default_server; - - server_name _ docker; - - access_log /docker.stdout; - error_log /docker.stdout info; - - root ""; - index ; - - client_max_body_size 50m; - - include /opt/docker/etc/nginx/vhost.common.d/*.conf; - include /opt/docker/etc/nginx/vhost.ssl.conf; -} diff --git a/docker/php-nginx-dev/alpine-3-php7/conf/provision/entrypoint.d/10-php-debugger.sh b/docker/php-nginx-dev/alpine-3-php7/conf/provision/entrypoint.d/10-php-debugger.sh deleted file mode 100644 index 7156e28aa..000000000 --- a/docker/php-nginx-dev/alpine-3-php7/conf/provision/entrypoint.d/10-php-debugger.sh +++ /dev/null @@ -1,95 +0,0 @@ -#!/usr/bin/env bash - -################################################# -# Debugger switch -################################################# - -PHP_CONF_PATHS=" -/etc/php5/conf.d -/etc/php7/conf.d -/etc/php.d -/etc/php5/mods-available -/etc/php5/cli/conf.d -/etc/php5/cli/conf.d -/etc/php5/fpm/conf.d -/etc/php5/fpm/conf.d -/etc/php/7.0/mods-available -/etc/php/7.0/cli/conf.d -/etc/php/7.0/fpm/conf.d" - -function phpModuleRemove() { - if [ "$#" -ne 1 ]; then - echo "You must specify the name of the PHP module which you want to disable" - exit 1 - fi - - echo " - Removing PHP module ${1}" - for CONF_PATH in $PHP_CONF_PATHS; do - rm -f "${CONF_PATH}"/*"${1}".ini - done -} - - -if [[ -n "${PHP_DEBUGGER+x}" ]]; then - case "$PHP_DEBUGGER" in - xdebug) - echo "PHP-Debugger: Xdebug enabled" - phpModuleRemove "blackfire" - ;; - - blackfire) - echo "PHP-Debugger: Blackfire enabled" - phpModuleRemove "xdebug" - /opt/docker/bin/control.sh service.enable blackfire-agent - ;; - - none) - echo "PHP-Debugger: none" - phpModuleRemove "blackfire" - phpModuleRemove "xdebug" - ;; - esac - -else - - echo "PHP-Debugger: not specified - default is xdebug" - phpModuleRemove "blackfire" - -fi - -################################################# -# PHP debugger environment variables -################################################# - -function phpEnvironmentVariable() { - PHP_INI_KEY="$1" - PHP_ENV_NAME="$2" - - if [[ -n "${!PHP_ENV_NAME+x}" ]]; then - PHP_ENV_VALUE="${!PHP_ENV_NAME}" - echo "${PHP_INI_KEY}=\"${PHP_ENV_VALUE}\"" >> /opt/docker/etc/php/php.ini - fi -} - -################### -# XDEBUG -################### - -# remote debugger -phpEnvironmentVariable "xdebug.remote_connect_back" "XDEBUG_REMOTE_CONNECT_BACK" -phpEnvironmentVariable "xdebug.remote_autostart" "XDEBUG_REMOTE_AUTOSTART" -phpEnvironmentVariable "xdebug.remote_host" "XDEBUG_REMOTE_HOST" -phpEnvironmentVariable "xdebug.remote_port" "XDEBUG_REMOTE_PORT" - -# profiler -phpEnvironmentVariable "xdebug.profiler_enable" "XDEBUG_PROFILER_ENABLE" -phpEnvironmentVariable "xdebug.profiler_enable_trigger" "XDEBUG_PROFILER_ENABLE_TRIGGER" -phpEnvironmentVariable "xdebug.profiler_enable_trigger_value" "XDEBUG_PROFILER_ENABLE_TRIGGER_VALUE" -phpEnvironmentVariable "xdebug.profiler_output_dir" "XDEBUG_PROFILER_OUTPUT_DIR" -phpEnvironmentVariable "xdebug.profiler_output_name" "XDEBUG_PROFILER_OUTPUT_NAME" - -################### -# BLACKFIRE -################### -phpEnvironmentVariable "blackfire.server_id" "BLACKFIRE_SERVER_ID" -phpEnvironmentVariable "blackfire.server_token" "BLACKFIRE_SERVER_TOKEN" diff --git a/docker/php-nginx-dev/alpine-3-php7/conf/provision/roles/webdevops-php-dev/tasks/bootstrap.yml b/docker/php-nginx-dev/alpine-3-php7/conf/provision/roles/webdevops-php-dev/tasks/bootstrap.yml deleted file mode 100644 index 2c5d76e3d..000000000 --- a/docker/php-nginx-dev/alpine-3-php7/conf/provision/roles/webdevops-php-dev/tasks/bootstrap.yml +++ /dev/null @@ -1,8 +0,0 @@ ---- - -- include: bootstrap/tools.yml -- include: bootstrap/php-fpm.yml -- include: bootstrap/php-module.yml -- include: bootstrap/php-module.opcache.yml -- include: bootstrap/php-module.xdebug.yml -- include: bootstrap/php-module.blackfire.yml diff --git a/docker/php-nginx-dev/alpine-3-php7/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/php-module.blackfire.yml b/docker/php-nginx-dev/alpine-3-php7/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/php-module.blackfire.yml deleted file mode 100644 index 1a3db9bac..000000000 --- a/docker/php-nginx-dev/alpine-3-php7/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/php-module.blackfire.yml +++ /dev/null @@ -1,10 +0,0 @@ ---- - -- name: Remove superfluous blackfire configuration file - file: - path: '{{ item }}' - state: absent - with_items: - - /etc/php5/cli/conf.d/zz-blackfire.ini - - /etc/php5/fpm/conf.d/zz-blackfire.ini - when: ansible_distribution == 'Debian' and ansible_lsb.major_release|int >= 7 diff --git a/docker/php-nginx-dev/alpine-3-php7/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/tools.yml b/docker/php-nginx-dev/alpine-3-php7/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/tools.yml deleted file mode 100644 index c49cb0e34..000000000 --- a/docker/php-nginx-dev/alpine-3-php7/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/tools.yml +++ /dev/null @@ -1,23 +0,0 @@ ---- - -- name: Downloading Tools - shell: curl -o "{{ item.dest }}" "{{ item.url }}" && chmod 755 "{{ item.dest }}" - with_items: - - { url: "https://phar.phpunit.de/phploc.phar", dest: /usr/local/bin/phploc } - - { url: "https://phar.phpunit.de/phpunit.phar", dest: /usr/local/bin/phpunit } - - { url: "http://static.pdepend.org/php/latest/pdepend.phar", dest: /usr/local/bin/pdepend } - - { url: "http://static.phpmd.org/php/latest/phpmd.phar", dest: /usr/local/bin/phpmd } - - { url: "https://squizlabs.github.io/PHP_CodeSniffer/phpcs.phar", dest: /usr/local/bin/phpcs } - - { url: "https://squizlabs.github.io/PHP_CodeSniffer/phpcbf.phar", dest: /usr/local/bin/phpcbf } - - { url: "https://phar.phpunit.de/phpcpd.phar", dest: /usr/local/bin/phpcpd } - - { url: "https://phar.phpunit.de/phpdcd.phar", dest: /usr/local/bin/phpdcd } - - { url: "https://github.com/Halleck45/PhpMetrics/raw/master/build/phpmetrics.phar", dest: /usr/local/bin/phpmetrics } - - { url: "http://get.sensiolabs.org/php-cs-fixer.phar", dest: /usr/local/bin/php-cs-fixer } - - { url: "https://github.com/sensiolabs-de/deprecation-detector/releases/download/0.1.0-alpha4/deprecation-detector.phar", dest: /usr/local/bin/deprecation-detector } - - { url: "https://github.com/sensiolabs-de/deprecation-detector/releases/download/0.1.0-alpha4/deprecation-detector.phar", dest: /usr/local/bin/deprecation-detector } - -- name: Install Tools via composer - raw: COMPOSER_HOME="/usr/local/composer" COMPOSER_BIN_DIR="/usr/local/bin" composer global require "{{ item.package }}" "{{ item.version }}" - with_items: - - { package: "sstalle/php7cc" , version: "*" } - - { package: "phpspec/phpspec" , version: "~2.0" } diff --git a/docker/php-nginx-dev/alpine-3/Dockerfile b/docker/php-nginx-dev/alpine-3/Dockerfile deleted file mode 100644 index 5dfa6dd86..000000000 --- a/docker/php-nginx-dev/alpine-3/Dockerfile +++ /dev/null @@ -1,28 +0,0 @@ -#+++++++++++++++++++++++++++++++++++++++ -# Dockerfile for webdevops/php-nginx-dev:alpine-3 -# -- automatically generated -- -#+++++++++++++++++++++++++++++++++++++++ - -FROM webdevops/php-dev:alpine-3 - -MAINTAINER info@webdevops.io -LABEL vendor=WebDevOps.io -LABEL io.webdevops.layout=8 -LABEL io.webdevops.version=1.5.0 - -ENV WEB_DOCUMENT_ROOT /app -ENV WEB_DOCUMENT_INDEX index.php -ENV WEB_ALIAS_DOMAIN *.vm -ENV WEB_PHP_SOCKET 127.0.0.1:9000 -ENV WEB_NO_CACHE_PATTERN "\.(css|js|gif|png|jpg|svg|json|xml)$" - -COPY conf/ /opt/docker/ - -# Install nginx -RUN /usr/local/bin/apk-install \ - nginx \ - && /opt/docker/bin/provision run --tag bootstrap --role webdevops-nginx --role webdevops-php-nginx --role webdevops-nginx-dev --role webdevops-php-dev \ - && /opt/docker/bin/bootstrap.sh - - -EXPOSE 80 443 diff --git a/docker/php-nginx-dev/alpine-3/Dockerfile.jinja2 b/docker/php-nginx-dev/alpine-3/Dockerfile.jinja2 deleted file mode 100644 index b22f3c32b..000000000 --- a/docker/php-nginx-dev/alpine-3/Dockerfile.jinja2 +++ /dev/null @@ -1,13 +0,0 @@ -{{ docker.from("php-dev", "alpine-3") }} - -{{ docker.version() }} - -{{ environment.web() }} -{{ environment.webPhp() }} -{{ environment.webDevelopment() }} - -{{ docker.copy('conf/', '/opt/docker/') }} - -{{ nginx.alpine('php-nginx nginx-dev php-dev') }} - -{{ docker.expose('80 443') }} diff --git a/docker/php-nginx-dev/alpine-3/conf/bin/service.d/nginx.d/10-init.sh b/docker/php-nginx-dev/alpine-3/conf/bin/service.d/nginx.d/10-init.sh deleted file mode 100644 index 75a84a4eb..000000000 --- a/docker/php-nginx-dev/alpine-3/conf/bin/service.d/nginx.d/10-init.sh +++ /dev/null @@ -1,23 +0,0 @@ -if [[ ! -e "$WEB_DOCUMENT_ROOT" ]]; then - echo "" - echo "[WARNING] WEB_DOCUMENT_ROOT does not exists with path \"$WEB_DOCUMENT_ROOT\"!" - echo "" -fi - -# Prevent startup of nginx (ubuntu 16.04 needs it) -ln -f -s /var/lib/nginx/logs /var/log/nginx - -# Replace markers -find /opt/docker/etc/nginx/ -iname '*.conf' -print0 | xargs -0 -r rpl --quiet "" "$WEB_DOCUMENT_INDEX" > /dev/null -find /opt/docker/etc/nginx/ -iname '*.conf' -print0 | xargs -0 -r rpl --quiet "" "$WEB_DOCUMENT_ROOT" > /dev/null -find /opt/docker/etc/nginx/ -iname '*.conf' -print0 | xargs -0 -r rpl --quiet "" "$WEB_ALIAS_DOMAIN" > /dev/null -find /opt/docker/etc/nginx/ -iname '*.conf' -print0 | xargs -0 -r rpl --quiet "" "$HOSTNAME" > /dev/null - -if [[ -n "${WEB_PHP_SOCKET+x}" ]]; then - ## WEB_PHP_SOCKET is set - find /opt/docker/etc/nginx/ -iname '*.conf' -print0 | xargs -0 -r rpl --quiet "" "$WEB_PHP_SOCKET" > /dev/null -else - ## WEB_PHP_SOCKET is not set, remove PHP files - rm -f -- /opt/docker/etc/nginx/conf.d/10-php.conf - rm -f -- /opt/docker/etc/nginx/vhost.common.d/10-php.conf -fi diff --git a/docker/php-nginx-dev/alpine-3/conf/bin/service.d/nginx.d/12-development.sh b/docker/php-nginx-dev/alpine-3/conf/bin/service.d/nginx.d/12-development.sh deleted file mode 100644 index fa4b601a9..000000000 --- a/docker/php-nginx-dev/alpine-3/conf/bin/service.d/nginx.d/12-development.sh +++ /dev/null @@ -1 +0,0 @@ -find /opt/docker/etc/nginx/ -iname '*.conf' -print0 | xargs -0 -r rpl --quiet "" "$WEB_NO_CACHE_PATTERN" > /dev/null diff --git a/docker/php-nginx-dev/alpine-3/conf/etc/nginx/vhost.conf b/docker/php-nginx-dev/alpine-3/conf/etc/nginx/vhost.conf deleted file mode 100644 index d07e27094..000000000 --- a/docker/php-nginx-dev/alpine-3/conf/etc/nginx/vhost.conf +++ /dev/null @@ -1,38 +0,0 @@ -server { - listen 80 default_server; - listen 8000 default_server; - - server_name _ docker; - - access_log /docker.stdout; - error_log /docker.stdout info; - - root ""; - index ; - - client_max_body_size 50m; - - include /opt/docker/etc/nginx/vhost.common.d/*.conf; -} - -############## -# SSL -############## - -server { - listen 443 default_server; - listen 8443 default_server; - - server_name _ docker; - - access_log /docker.stdout; - error_log /docker.stdout info; - - root ""; - index ; - - client_max_body_size 50m; - - include /opt/docker/etc/nginx/vhost.common.d/*.conf; - include /opt/docker/etc/nginx/vhost.ssl.conf; -} diff --git a/docker/php-nginx-dev/alpine-3/conf/provision/entrypoint.d/10-php-debugger.sh b/docker/php-nginx-dev/alpine-3/conf/provision/entrypoint.d/10-php-debugger.sh deleted file mode 100644 index 7156e28aa..000000000 --- a/docker/php-nginx-dev/alpine-3/conf/provision/entrypoint.d/10-php-debugger.sh +++ /dev/null @@ -1,95 +0,0 @@ -#!/usr/bin/env bash - -################################################# -# Debugger switch -################################################# - -PHP_CONF_PATHS=" -/etc/php5/conf.d -/etc/php7/conf.d -/etc/php.d -/etc/php5/mods-available -/etc/php5/cli/conf.d -/etc/php5/cli/conf.d -/etc/php5/fpm/conf.d -/etc/php5/fpm/conf.d -/etc/php/7.0/mods-available -/etc/php/7.0/cli/conf.d -/etc/php/7.0/fpm/conf.d" - -function phpModuleRemove() { - if [ "$#" -ne 1 ]; then - echo "You must specify the name of the PHP module which you want to disable" - exit 1 - fi - - echo " - Removing PHP module ${1}" - for CONF_PATH in $PHP_CONF_PATHS; do - rm -f "${CONF_PATH}"/*"${1}".ini - done -} - - -if [[ -n "${PHP_DEBUGGER+x}" ]]; then - case "$PHP_DEBUGGER" in - xdebug) - echo "PHP-Debugger: Xdebug enabled" - phpModuleRemove "blackfire" - ;; - - blackfire) - echo "PHP-Debugger: Blackfire enabled" - phpModuleRemove "xdebug" - /opt/docker/bin/control.sh service.enable blackfire-agent - ;; - - none) - echo "PHP-Debugger: none" - phpModuleRemove "blackfire" - phpModuleRemove "xdebug" - ;; - esac - -else - - echo "PHP-Debugger: not specified - default is xdebug" - phpModuleRemove "blackfire" - -fi - -################################################# -# PHP debugger environment variables -################################################# - -function phpEnvironmentVariable() { - PHP_INI_KEY="$1" - PHP_ENV_NAME="$2" - - if [[ -n "${!PHP_ENV_NAME+x}" ]]; then - PHP_ENV_VALUE="${!PHP_ENV_NAME}" - echo "${PHP_INI_KEY}=\"${PHP_ENV_VALUE}\"" >> /opt/docker/etc/php/php.ini - fi -} - -################### -# XDEBUG -################### - -# remote debugger -phpEnvironmentVariable "xdebug.remote_connect_back" "XDEBUG_REMOTE_CONNECT_BACK" -phpEnvironmentVariable "xdebug.remote_autostart" "XDEBUG_REMOTE_AUTOSTART" -phpEnvironmentVariable "xdebug.remote_host" "XDEBUG_REMOTE_HOST" -phpEnvironmentVariable "xdebug.remote_port" "XDEBUG_REMOTE_PORT" - -# profiler -phpEnvironmentVariable "xdebug.profiler_enable" "XDEBUG_PROFILER_ENABLE" -phpEnvironmentVariable "xdebug.profiler_enable_trigger" "XDEBUG_PROFILER_ENABLE_TRIGGER" -phpEnvironmentVariable "xdebug.profiler_enable_trigger_value" "XDEBUG_PROFILER_ENABLE_TRIGGER_VALUE" -phpEnvironmentVariable "xdebug.profiler_output_dir" "XDEBUG_PROFILER_OUTPUT_DIR" -phpEnvironmentVariable "xdebug.profiler_output_name" "XDEBUG_PROFILER_OUTPUT_NAME" - -################### -# BLACKFIRE -################### -phpEnvironmentVariable "blackfire.server_id" "BLACKFIRE_SERVER_ID" -phpEnvironmentVariable "blackfire.server_token" "BLACKFIRE_SERVER_TOKEN" diff --git a/docker/php-nginx-dev/alpine-3/conf/provision/roles/webdevops-php-dev/tasks/bootstrap.yml b/docker/php-nginx-dev/alpine-3/conf/provision/roles/webdevops-php-dev/tasks/bootstrap.yml deleted file mode 100644 index 2c5d76e3d..000000000 --- a/docker/php-nginx-dev/alpine-3/conf/provision/roles/webdevops-php-dev/tasks/bootstrap.yml +++ /dev/null @@ -1,8 +0,0 @@ ---- - -- include: bootstrap/tools.yml -- include: bootstrap/php-fpm.yml -- include: bootstrap/php-module.yml -- include: bootstrap/php-module.opcache.yml -- include: bootstrap/php-module.xdebug.yml -- include: bootstrap/php-module.blackfire.yml diff --git a/docker/php-nginx-dev/alpine-3/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/php-module.blackfire.yml b/docker/php-nginx-dev/alpine-3/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/php-module.blackfire.yml deleted file mode 100644 index 1a3db9bac..000000000 --- a/docker/php-nginx-dev/alpine-3/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/php-module.blackfire.yml +++ /dev/null @@ -1,10 +0,0 @@ ---- - -- name: Remove superfluous blackfire configuration file - file: - path: '{{ item }}' - state: absent - with_items: - - /etc/php5/cli/conf.d/zz-blackfire.ini - - /etc/php5/fpm/conf.d/zz-blackfire.ini - when: ansible_distribution == 'Debian' and ansible_lsb.major_release|int >= 7 diff --git a/docker/php-nginx-dev/alpine-3/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/tools.yml b/docker/php-nginx-dev/alpine-3/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/tools.yml deleted file mode 100644 index c49cb0e34..000000000 --- a/docker/php-nginx-dev/alpine-3/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/tools.yml +++ /dev/null @@ -1,23 +0,0 @@ ---- - -- name: Downloading Tools - shell: curl -o "{{ item.dest }}" "{{ item.url }}" && chmod 755 "{{ item.dest }}" - with_items: - - { url: "https://phar.phpunit.de/phploc.phar", dest: /usr/local/bin/phploc } - - { url: "https://phar.phpunit.de/phpunit.phar", dest: /usr/local/bin/phpunit } - - { url: "http://static.pdepend.org/php/latest/pdepend.phar", dest: /usr/local/bin/pdepend } - - { url: "http://static.phpmd.org/php/latest/phpmd.phar", dest: /usr/local/bin/phpmd } - - { url: "https://squizlabs.github.io/PHP_CodeSniffer/phpcs.phar", dest: /usr/local/bin/phpcs } - - { url: "https://squizlabs.github.io/PHP_CodeSniffer/phpcbf.phar", dest: /usr/local/bin/phpcbf } - - { url: "https://phar.phpunit.de/phpcpd.phar", dest: /usr/local/bin/phpcpd } - - { url: "https://phar.phpunit.de/phpdcd.phar", dest: /usr/local/bin/phpdcd } - - { url: "https://github.com/Halleck45/PhpMetrics/raw/master/build/phpmetrics.phar", dest: /usr/local/bin/phpmetrics } - - { url: "http://get.sensiolabs.org/php-cs-fixer.phar", dest: /usr/local/bin/php-cs-fixer } - - { url: "https://github.com/sensiolabs-de/deprecation-detector/releases/download/0.1.0-alpha4/deprecation-detector.phar", dest: /usr/local/bin/deprecation-detector } - - { url: "https://github.com/sensiolabs-de/deprecation-detector/releases/download/0.1.0-alpha4/deprecation-detector.phar", dest: /usr/local/bin/deprecation-detector } - -- name: Install Tools via composer - raw: COMPOSER_HOME="/usr/local/composer" COMPOSER_BIN_DIR="/usr/local/bin" composer global require "{{ item.package }}" "{{ item.version }}" - with_items: - - { package: "sstalle/php7cc" , version: "*" } - - { package: "phpspec/phpspec" , version: "~2.0" } diff --git a/docker/php-nginx-dev/alpine-php5/Dockerfile b/docker/php-nginx-dev/alpine-php5/Dockerfile new file mode 100644 index 000000000..a028d3d80 --- /dev/null +++ b/docker/php-nginx-dev/alpine-php5/Dockerfile @@ -0,0 +1,23 @@ +#+++++++++++++++++++++++++++++++++++++++ +# Dockerfile for webdevops/php-nginx-dev:alpine-php5 +# -- automatically generated -- +#+++++++++++++++++++++++++++++++++++++++ + +FROM webdevops/php-dev:alpine-php5 + +ENV WEB_DOCUMENT_ROOT=/app \ + WEB_DOCUMENT_INDEX=index.php \ + WEB_ALIAS_DOMAIN=*.vm +ENV WEB_PHP_SOCKET=127.0.0.1:9000 +ENV WEB_NO_CACHE_PATTERN="\.(css|js|gif|png|jpg|svg|json|xml)$" + +COPY conf/ /opt/docker/ + +# Install nginx +RUN /usr/local/bin/apk-install \ + nginx \ + && /opt/docker/bin/provision run --tag bootstrap --role webdevops-nginx --role webdevops-php-nginx --role webdevops-nginx-dev --role webdevops-php-dev \ + && /opt/docker/bin/bootstrap.sh \ + && docker-image-cleanup + +EXPOSE 80 443 diff --git a/docker/php-nginx-dev/alpine-php5/Dockerfile.jinja2 b/docker/php-nginx-dev/alpine-php5/Dockerfile.jinja2 new file mode 100644 index 000000000..5d4708d9e --- /dev/null +++ b/docker/php-nginx-dev/alpine-php5/Dockerfile.jinja2 @@ -0,0 +1,11 @@ +{{ docker.from("php-dev", "alpine-php5") }} + +{{ environment.web() }} +{{ environment.webPhp() }} +{{ environment.webDevelopment() }} + +{{ docker.copy('conf/', '/opt/docker/') }} + +{{ nginx.alpine('php-nginx nginx-dev php-dev') }} + +{{ docker.expose('80 443') }} diff --git a/docker/php-nginx-dev/alpine-php5/conf/bin/service.d/blackfire-agent.d/10-init.sh b/docker/php-nginx-dev/alpine-php5/conf/bin/service.d/blackfire-agent.d/10-init.sh new file mode 100644 index 000000000..fdffa2a0f --- /dev/null +++ b/docker/php-nginx-dev/alpine-php5/conf/bin/service.d/blackfire-agent.d/10-init.sh @@ -0,0 +1 @@ +# placeholder diff --git a/docker/php-nginx-dev/alpine-php5/conf/bin/service.d/blackfire-agent.sh b/docker/php-nginx-dev/alpine-php5/conf/bin/service.d/blackfire-agent.sh new file mode 100644 index 000000000..fbec23cf3 --- /dev/null +++ b/docker/php-nginx-dev/alpine-php5/conf/bin/service.d/blackfire-agent.sh @@ -0,0 +1,23 @@ +#!/usr/bin/env bash +set -e + +source /opt/docker/bin/config.sh + +BLACKFIRE_ARGS="" + +includeScriptDir "/opt/docker/bin/service.d/syslog-ng.d/" + +# blackfire.server_id +if [[ -n "${BLACKFIRE_SERVER_ID+x}" ]]; then + BLACKFIRE_ARGS="$BLACKFIRE_ARGS --server-id=\"${BLACKFIRE_SERVER_ID}\"" +fi + +# blackfire.server_token +if [[ -n "${BLACKFIRE_SERVER_TOKEN+x}" ]]; then + BLACKFIRE_ARGS="$BLACKFIRE_ARGS --server-token=\"${BLACKFIRE_SERVER_TOKEN}\"" +fi + +# create directory for unix socket +mkdir -p /var/run/blackfire + +eval exec blackfire-agent $BLACKFIRE_ARGS diff --git a/docker/php-nginx-dev/alpine-php5/conf/bin/service.d/nginx.d/10-init.sh b/docker/php-nginx-dev/alpine-php5/conf/bin/service.d/nginx.d/10-init.sh new file mode 100644 index 000000000..27b9776cc --- /dev/null +++ b/docker/php-nginx-dev/alpine-php5/conf/bin/service.d/nginx.d/10-init.sh @@ -0,0 +1,25 @@ +if [[ ! -e "$WEB_DOCUMENT_ROOT" ]]; then + echo "" + echo "[WARNING] WEB_DOCUMENT_ROOT does not exists with path \"$WEB_DOCUMENT_ROOT\"!" + echo "" +fi + +# Prevent startup of nginx (ubuntu 16.04 needs it) +ln -f -s /var/lib/nginx/logs /var/log/nginx + +# Replace markers +go-replace \ + -s "" -r "$WEB_DOCUMENT_INDEX" \ + -s "" -r "$WEB_DOCUMENT_ROOT" \ + -s "" -r "$WEB_ALIAS_DOMAIN" \ + -s "" -r "$HOSTNAME" \ + -s "" -r "$WEB_PHP_SOCKET" \ + --path=/opt/docker/etc/nginx/ \ + --path-pattern='*.conf' \ + --ignore-empty + +if [[ -z "${WEB_PHP_SOCKET+x}" ]]; then + ## WEB_PHP_SOCKET is not set, remove PHP files + rm -f -- /opt/docker/etc/nginx/conf.d/10-php.conf + rm -f -- /opt/docker/etc/nginx/vhost.common.d/10-php.conf +fi diff --git a/docker/php-nginx-dev/alpine-php5/conf/bin/service.d/nginx.d/12-development.sh b/docker/php-nginx-dev/alpine-php5/conf/bin/service.d/nginx.d/12-development.sh new file mode 100644 index 000000000..f4695f059 --- /dev/null +++ b/docker/php-nginx-dev/alpine-php5/conf/bin/service.d/nginx.d/12-development.sh @@ -0,0 +1,7 @@ +go-replace \ + -s "" \ + -r "$WEB_NO_CACHE_PATTERN" \ + --path=/opt/docker/etc/nginx/ \ + --path-pattern='*.conf' \ + --ignore-empty + diff --git a/docker/php-nginx/alpine-3/conf/bin/service.d/nginx.sh b/docker/php-nginx-dev/alpine-php5/conf/bin/service.d/nginx.sh similarity index 100% rename from docker/php-nginx/alpine-3/conf/bin/service.d/nginx.sh rename to docker/php-nginx-dev/alpine-php5/conf/bin/service.d/nginx.sh diff --git a/docker/php-nginx-dev/alpine-php5/conf/etc/nginx/conf.d/.gitkeep b/docker/php-nginx-dev/alpine-php5/conf/etc/nginx/conf.d/.gitkeep new file mode 100644 index 000000000..e69de29bb diff --git a/docker/php-nginx-dev/alpine-php5/conf/etc/nginx/conf.d/02-dev.conf b/docker/php-nginx-dev/alpine-php5/conf/etc/nginx/conf.d/02-dev.conf new file mode 100644 index 000000000..fdffa2a0f --- /dev/null +++ b/docker/php-nginx-dev/alpine-php5/conf/etc/nginx/conf.d/02-dev.conf @@ -0,0 +1 @@ +# placeholder diff --git a/docker/php-nginx/alpine-3/conf/etc/nginx/conf.d/10-php.conf b/docker/php-nginx-dev/alpine-php5/conf/etc/nginx/conf.d/10-php.conf similarity index 100% rename from docker/php-nginx/alpine-3/conf/etc/nginx/conf.d/10-php.conf rename to docker/php-nginx-dev/alpine-php5/conf/etc/nginx/conf.d/10-php.conf diff --git a/docker/php-nginx-dev/alpine-php5/conf/etc/nginx/global.conf b/docker/php-nginx-dev/alpine-php5/conf/etc/nginx/global.conf new file mode 100644 index 000000000..b6141db09 --- /dev/null +++ b/docker/php-nginx-dev/alpine-php5/conf/etc/nginx/global.conf @@ -0,0 +1 @@ +# deprecated diff --git a/docker/php-nginx/alpine-3/conf/etc/nginx/main.conf b/docker/php-nginx-dev/alpine-php5/conf/etc/nginx/main.conf similarity index 100% rename from docker/php-nginx/alpine-3/conf/etc/nginx/main.conf rename to docker/php-nginx-dev/alpine-php5/conf/etc/nginx/main.conf diff --git a/docker/php-nginx-dev/alpine-3-php7/conf/etc/nginx/nginx.conf b/docker/php-nginx-dev/alpine-php5/conf/etc/nginx/nginx.conf similarity index 100% rename from docker/php-nginx-dev/alpine-3-php7/conf/etc/nginx/nginx.conf rename to docker/php-nginx-dev/alpine-php5/conf/etc/nginx/nginx.conf diff --git a/docker/php-nginx-dev/alpine-php5/conf/etc/nginx/php.conf b/docker/php-nginx-dev/alpine-php5/conf/etc/nginx/php.conf new file mode 100644 index 000000000..b6141db09 --- /dev/null +++ b/docker/php-nginx-dev/alpine-php5/conf/etc/nginx/php.conf @@ -0,0 +1 @@ +# deprecated diff --git a/docker/php-nginx-dev/alpine-php5/conf/etc/nginx/ssl/server.crt b/docker/php-nginx-dev/alpine-php5/conf/etc/nginx/ssl/server.crt new file mode 100644 index 000000000..6b0694907 --- /dev/null +++ b/docker/php-nginx-dev/alpine-php5/conf/etc/nginx/ssl/server.crt @@ -0,0 +1,28 @@ +-----BEGIN CERTIFICATE----- +MIIE1DCCArwCCQDMMwGnSuK0tTANBgkqhkiG9w0BAQsFADAsMRswGQYDVQQKExJE +b2NrZXIgQm9pbGVycGxhdGUxDTALBgNVBAMUBCoudm0wHhcNMTUwNTA0MTcxNDQw +WhcNMjUwNTAxMTcxNDQwWjAsMRswGQYDVQQKExJEb2NrZXIgQm9pbGVycGxhdGUx +DTALBgNVBAMUBCoudm0wggIiMA0GCSqGSIb3DQEBAQUAA4ICDwAwggIKAoICAQDK +3TIUiyDvXelWeY9VXMrpjuZtYpVSDsACLpjFUhMnsP5/iKT0VbeZyqHvmwZjAg4G +Y10d+yZDdgv/xeu0HPOFbtR6pCp10d1tdLHZto5Cyuxu7IQsAVjnD6Ko7XFwtNk7 +9o6JZfAFaGL4w5MokrVmCtspnsMZH7/7zU4f96cbF39zLopnpuXGD6t6DA8Qj3gy +0duaTjs42bYRN+rwLzVKAev99iQ4kPMJn4vV6/Xk6rtoSzC67GQyVZYaFypicD1S +NtsRmgEVvjCBDbrLOneUiRwff6qxEsZi7Hxv7BKFj4iUWnII7K/nP7T6uBHQjHO+ +FpsGkU9lCMrCeVFBe8kKz/cbhd+yLUxXwAPr6gSOPmwn232Gy4tozvqZHpbUxsgx +7sT3ej9K66h1D7J+BjNFWYM1hbnC1r7H/xS7EBzBV8qRoQCVe08Juf5xsouXFakD +clLV4+L+1cxkpwsCQDly5g3tm/TBqA2O+ZJ+YHQDHKkzMyhLs6i0X/M5qvJBiLg1 +GLTCS20rpQ5gXTEGuINqHgwXQWkUO6bhgSYqdHGX3zbZ5+qWpI4eui3dHZ1Ll0VH +6Icpb7ORTQwhc6W8KBlybssYPSlGOEBGUjYGNheoz9FpoSkxCis+P8ZNKtrmpPoq +Su0eOOGFOFHG02eOgPVxSwrDeN9MVJo7BPysGMHJmQIDAQABMA0GCSqGSIb3DQEB +CwUAA4ICAQC63g6NHmQKbiy3G6iaDkpUSbr5Mq2YgU61XnvWVyREqDcy/BXCw9oY +SJ/KUvCpqPnACNOFqjadRAmPiA9nf2WduoCgwQGV/YRFGswSuVvh/3X2TX5NWvbS +t8MQDttQg1dxpiMUjlu3rqhfohBdWJvp2lVSdpDb/MOlXBc/+p7HfOHwhqB7wwPN +NNbSKUbZqZxmD8cOf1X0hASr1yfFPj+2vST3ESaON8S0T2p63YX/sD5jvOUiEuyw +I5WcvLmiRZA07SH8nWyckLY3qWL+OlhSZrlAnolWS00b+7h5LNuRYEjKzwVgntoA +aCopyQih6wIk0+AfJO4sfhJBmQhnIrAaP/zwBH5g9zVizLf5H7U+hNXrMwgw55Sq +vjMdkZHvPKUXTvVit/rYE9H+PY3brkRWzOl4V/i/ZLJJm5805H/NyTbz9kPMJw2Q +nn+KOpfXXySD39f8iuRgSKXsYNul38hxWgcZZ6g+sOOp2n/VUmf0eZUWNnJ8i7AP +4Qif7aDKMcibOwSwsB+DKZXDvZ5XSdnMphtuLS5rPSL81rVRmWC2DMfQ2eP8j0WN +VTroSk0xedQ7Qr+9TNooi9IyzX6n1a2S1UiciEZ3ZcDbXPl/P01m+IYZyPnLv0+9 +ZeioZYh1JLv3/OKsMrMLTfh2ZCj3aXwmc2Owi/wU2LS5QUOMcHH7CQ== +-----END CERTIFICATE----- \ No newline at end of file diff --git a/docker/php-nginx-dev/alpine-php5/conf/etc/nginx/ssl/server.csr b/docker/php-nginx-dev/alpine-php5/conf/etc/nginx/ssl/server.csr new file mode 100644 index 000000000..8a9909f77 --- /dev/null +++ b/docker/php-nginx-dev/alpine-php5/conf/etc/nginx/ssl/server.csr @@ -0,0 +1,26 @@ +-----BEGIN CERTIFICATE REQUEST----- +MIIEcTCCAlkCAQAwLDEbMBkGA1UEChMSRG9ja2VyIEJvaWxlcnBsYXRlMQ0wCwYD +VQQDFAQqLnZtMIICIjANBgkqhkiG9w0BAQEFAAOCAg8AMIICCgKCAgEAyt0yFIsg +713pVnmPVVzK6Y7mbWKVUg7AAi6YxVITJ7D+f4ik9FW3mcqh75sGYwIOBmNdHfsm +Q3YL/8XrtBzzhW7UeqQqddHdbXSx2baOQsrsbuyELAFY5w+iqO1xcLTZO/aOiWXw +BWhi+MOTKJK1ZgrbKZ7DGR+/+81OH/enGxd/cy6KZ6blxg+regwPEI94MtHbmk47 +ONm2ETfq8C81SgHr/fYkOJDzCZ+L1ev15Oq7aEswuuxkMlWWGhcqYnA9UjbbEZoB +Fb4wgQ26yzp3lIkcH3+qsRLGYux8b+wShY+IlFpyCOyv5z+0+rgR0IxzvhabBpFP +ZQjKwnlRQXvJCs/3G4Xfsi1MV8AD6+oEjj5sJ9t9hsuLaM76mR6W1MbIMe7E93o/ +SuuodQ+yfgYzRVmDNYW5wta+x/8UuxAcwVfKkaEAlXtPCbn+cbKLlxWpA3JS1ePi +/tXMZKcLAkA5cuYN7Zv0wagNjvmSfmB0AxypMzMoS7OotF/zOaryQYi4NRi0wktt +K6UOYF0xBriDah4MF0FpFDum4YEmKnRxl9822efqlqSOHrot3R2dS5dFR+iHKW+z +kU0MIXOlvCgZcm7LGD0pRjhARlI2BjYXqM/RaaEpMQorPj/GTSra5qT6KkrtHjjh +hThRxtNnjoD1cUsKw3jfTFSaOwT8rBjByZkCAwEAAaAAMA0GCSqGSIb3DQEBCwUA +A4ICAQBsEBgC2YepuZq/8UqvKMZKVy/etDKXj7BB+QPb+leNiKD7p4LDxHJsZSH8 +Ku9uMPeLfiQDn5jA41k5SlGttzvObd65RdEbO3yHpqsg05EGSDDLfaE1k2Al/qmX +/o8roPZF7+2kZthgMAgkcokS54LYqEYTGqOf3J9Ss0yRIZwhaOVebfFIbIOdpw0B +JNMIJPHTMdZrcuRVI+wR1uPLIlEJzBvxTGbTrvPU25WJFtu+EajKqXO0SHdy0yx8 +uH4ykRBJRc36+oYo7nZ5D56dh7pZn3+9J64FKAOV0Q3KqMFieGy053ezuhJd70eZ +UozTgfjs3WpMzoYmKETSyl3XZSdInRe+sUlKPruTsKyg69oYxjPlrGfAmmGcCFca +TnZinT18dI92zK7OtOVkmYeYKC1lwuhftVrNMXzZuHOGpS9NNYtc4nDqDMIEOfV3 +6rCdu03WjEgJ+Z67tJs16xOx9du4/EHxS2Ijn9DPfVJvYy0TgzDi1BUpjWx0KTLx +C4OQbEZ/QTWmHVbSch/hcZhzbf7SNh5RpnW4EtmcpDFjIKMfxJmoKeiTf7qnilx0 +7uRvsZFKoDKRDOFiPfgMg5AOtLHziYsd9m0tJjC2GHvFuPjzOtzhnUUjmmvht170 +2aqKakjST4amg7jzLcs871HX0/WjOtt29NpOz140blkKf1bisg== +-----END CERTIFICATE REQUEST----- \ No newline at end of file diff --git a/docker/php-nginx-dev/alpine-php5/conf/etc/nginx/ssl/server.key b/docker/php-nginx-dev/alpine-php5/conf/etc/nginx/ssl/server.key new file mode 100644 index 000000000..c9eec145f --- /dev/null +++ b/docker/php-nginx-dev/alpine-php5/conf/etc/nginx/ssl/server.key @@ -0,0 +1,51 @@ +-----BEGIN RSA PRIVATE KEY----- +MIIJKAIBAAKCAgEAyt0yFIsg713pVnmPVVzK6Y7mbWKVUg7AAi6YxVITJ7D+f4ik +9FW3mcqh75sGYwIOBmNdHfsmQ3YL/8XrtBzzhW7UeqQqddHdbXSx2baOQsrsbuyE +LAFY5w+iqO1xcLTZO/aOiWXwBWhi+MOTKJK1ZgrbKZ7DGR+/+81OH/enGxd/cy6K +Z6blxg+regwPEI94MtHbmk47ONm2ETfq8C81SgHr/fYkOJDzCZ+L1ev15Oq7aEsw +uuxkMlWWGhcqYnA9UjbbEZoBFb4wgQ26yzp3lIkcH3+qsRLGYux8b+wShY+IlFpy +COyv5z+0+rgR0IxzvhabBpFPZQjKwnlRQXvJCs/3G4Xfsi1MV8AD6+oEjj5sJ9t9 +hsuLaM76mR6W1MbIMe7E93o/SuuodQ+yfgYzRVmDNYW5wta+x/8UuxAcwVfKkaEA +lXtPCbn+cbKLlxWpA3JS1ePi/tXMZKcLAkA5cuYN7Zv0wagNjvmSfmB0AxypMzMo +S7OotF/zOaryQYi4NRi0wkttK6UOYF0xBriDah4MF0FpFDum4YEmKnRxl9822efq +lqSOHrot3R2dS5dFR+iHKW+zkU0MIXOlvCgZcm7LGD0pRjhARlI2BjYXqM/RaaEp +MQorPj/GTSra5qT6KkrtHjjhhThRxtNnjoD1cUsKw3jfTFSaOwT8rBjByZkCAwEA +AQKCAgAbZPdoUsllyZbC+LNkYZ19ILD5QIDNjfRb1xMGQmkXyQz1B+zOmeyrNfPc +OWEJabOfJTfj3pByN7SzG3US4333HNpQnW6mbmqqZ0HFFqPrXR/Ecuf+UUhCG5hp +m3bgM2vKbyccYsmg0VHcKfzrU7RvTTP/UNMjx2fThwvvwS+ttuSdF0HVcXJB5sfP +OWWnZNhkdHZlRf81VCED/jsZqCZYEh5eMyj9AoXvXL4zayPPf+tC0DSKaXW2Xlxg +tZQhqup8+a9nlxZia0Z9hu8clo6jXkiP8FuKgfCMV0cOjiCKLLHS5svTbLLsVWwJ +F2ZAdVcD6mWQ43qHOEK5NEzGvQKO14CaOLnVT2yAkMcyNohsEgoDP9oCBGDJQbBH +NmtZfpVjjtuTr9P9TEkU1FcBRo0x6Il/DkzamGbOeFAmgnaGElhJ5c/CAG7whaIf +mUfFOBGPH/wESY3gBOACDofeSh27RrlvbLaPiCGKivDUTBmhBsIuso6XqOKbvtfV +/HhhndpdRVfIj4DdE7gIrLIGN977JMVAXFCNz7KrvAWwcOXrCHCoWpklJ9repq8l +26ICY8K7VXktzDHQUmhd88ZWR+9ASURsJghUgZUOcMrEGyvci6Y8hpLhHiNVPHuQ ++ps7tpPsXSntBUqWBzhRZh74+nJlOOV6oYykl30JT2JzB6lwiQKCAQEA9ecn8N2z +20tR2UEiTv/MjVSepQtAAajegvcd1iasvvQKXnh3XLmoZHzH2tTa0lp5RIZpUQPl +lOTwko0lYTBnYblt65AJQ3FTgisNobIpoqE8BFXLm6wggz7CbabjmPGDe173lPGR +sI0YSKYvzrdn4zw8Fh6WULJyZHLi58zJYL3r0WBDiOoxpGaGA1GlmkuIWjhKHaX2 +OvF1vOuQDJ2eDyTc5TYFC0NKG76Mvanov5L/yrhNM/umbmp0SPspzHGZobAKUr20 +OazFT8S+2TA1OTxWNbiPbSimFoaZbEdqsNACGfVJWO8Sh8iqlt5RmEcSiSvGBj6L +QKprRO9Fsp2GawKCAQEA0zGhRsnux4JTNsdUSYsEJtITMj6eE+nl7CoZ9DAOwC5X +6/aSpUE4TT+pWNrt9iluXiGL0j89UJ7r/L1OcsiyzGb8ig9NU4zr1NIGTZ0DstHi +HPYINjeiBJEFIy17kOQn+9/I5c4hBUwz6ihwNoEomymVB/EsLJKAML0AudJGKg+Z +/f/qrS40eab5SAiaKgsh0MZnj+vIxyGBydt6r2HGmjfNITVbXIu6IpO+6NXDwM/e +7v10AAZ3j9+gb1RedLg2ghuIuYU90hmMhtVWsh9nVmaOkMW9/WFgOPYvt/mHH/hR +d4pePZ9kACGmqo/b9sHvHw1YEubtCt1VUiNuFxnJCwKCAQBWnxz0vkRTJY8phsY9 +KeK2jm5sGTBs5T2syLwb6ffENFdKvAjgAw6Mh2And/+1ReWd+/MxdLv03UjZdxsJ +x3FDfXx5FH4O4ebW3a+pnAcKoN1xcX+N0O6LDRqUYcue3sTAOs3gC9CUbr91KAWD +Phw8ccWAzTmKJ7IgLFA982ekyoI9eTmRC159WRgwJxy844qerWF+XC4GyXP+HsTZ +jNRW5Vdi7sqMEyIR7+fIEAhLI88zbATWIPmZv6pC4ybwO7wwtsCMMQNBpdjDprzL +6S12ggikV+U+QKlxGe0FtYqhykRTPJKf32eZqVheWOZJTA/9fgv9ux52oxGycM8O +gmsNAoIBAQC60m5uZnd5uYnPLWkcXYNgq/kbO1UvHHut/FhVMKX7z4MrU0XKNfWO +MECoP5K9bU0aq+Y6KIMe7FapjvT0iSHRu1Cu+HZY8JI2A0xcIAeDijLRl7sP6wrB +q1+2DKgANjRAlWfsEfoX658JBpitPngjOheBnRCMpVQMyUT5HE/BKWf5zwdUB0mY +S+K8nA90HcDeJIS8RcGolbVwUV0oBABhr/cf50lYhqozqCr7YQ33ZGs7Uq3oz8+4 +UARmN2YPLl3Znm3GX12em8c6B0LX8vvA7Jw06Rf2Ksup1+3Ce1PTLiEy9A4FyRf3 +Hc2HmBbnJAtZlr5QikMqlzzAmmLqwH6dAoIBAC+ryaQGJFsijCSuaDfRp/uy9xnd +DjgMdTwjl5WLBmyudChVMANl8eqCbvVO41CN84yORk03oQ4cx0eKxAZaLaSzgkb3 +W0X2nFQe7VJSYMQswCQ+1WfJvEFrIdkEKIa//uQdhqNrgUKSNVhhSTMbNEkDTIWn +ssbv2H9hvUaFt/J/vP9zCKuU5oYvNU7Oi6ZXRYezRn9atlJYanLFoJnHUBRzGms5 +K0vhdCPDXQq87z5Yudoh0jLUQF9Nx0GTWeBceQ9n5hZeRUNQWxP4AJThQX9KSPTS +mbL3Kh4XNRmAUJ2N+Njh+3dg91s+JkKvC1wcspLsmLPQe+9AxBSH9y5JE/8= +-----END RSA PRIVATE KEY----- \ No newline at end of file diff --git a/docker/php-nginx/alpine-3/conf/etc/nginx/vhost.common.conf b/docker/php-nginx-dev/alpine-php5/conf/etc/nginx/vhost.common.conf similarity index 100% rename from docker/php-nginx/alpine-3/conf/etc/nginx/vhost.common.conf rename to docker/php-nginx-dev/alpine-php5/conf/etc/nginx/vhost.common.conf diff --git a/docker/php-nginx-dev/alpine-php5/conf/etc/nginx/vhost.common.d/.gitkeep b/docker/php-nginx-dev/alpine-php5/conf/etc/nginx/vhost.common.d/.gitkeep new file mode 100644 index 000000000..e69de29bb diff --git a/docker/php-nginx-dev/alpine-php5/conf/etc/nginx/vhost.common.d/02-dev.conf b/docker/php-nginx-dev/alpine-php5/conf/etc/nginx/vhost.common.d/02-dev.conf new file mode 100644 index 000000000..4f80ec9d3 --- /dev/null +++ b/docker/php-nginx-dev/alpine-php5/conf/etc/nginx/vhost.common.d/02-dev.conf @@ -0,0 +1,6 @@ +location ~* { + expires off; + add_header Cache-Control private; + + try_files $uri $uri/ /?$query_string; +} diff --git a/docker/php-nginx-dev/alpine-php5/conf/etc/nginx/vhost.common.d/10-general.conf b/docker/php-nginx-dev/alpine-php5/conf/etc/nginx/vhost.common.d/10-general.conf new file mode 100644 index 000000000..d3fd0aa5e --- /dev/null +++ b/docker/php-nginx-dev/alpine-php5/conf/etc/nginx/vhost.common.d/10-general.conf @@ -0,0 +1 @@ +client_max_body_size 50m; diff --git a/docker/php-nginx/alpine-3/conf/etc/nginx/vhost.common.d/10-location-root.conf b/docker/php-nginx-dev/alpine-php5/conf/etc/nginx/vhost.common.d/10-location-root.conf similarity index 100% rename from docker/php-nginx/alpine-3/conf/etc/nginx/vhost.common.d/10-location-root.conf rename to docker/php-nginx-dev/alpine-php5/conf/etc/nginx/vhost.common.d/10-location-root.conf diff --git a/docker/php-nginx-dev/alpine-php5/conf/etc/nginx/vhost.common.d/10-log.conf b/docker/php-nginx-dev/alpine-php5/conf/etc/nginx/vhost.common.d/10-log.conf new file mode 100644 index 000000000..a2cd929e7 --- /dev/null +++ b/docker/php-nginx-dev/alpine-php5/conf/etc/nginx/vhost.common.d/10-log.conf @@ -0,0 +1,2 @@ +access_log /docker.stdout; +error_log /docker.stderr info; diff --git a/docker/php-nginx/alpine-3/conf/etc/nginx/vhost.common.d/10-php.conf b/docker/php-nginx-dev/alpine-php5/conf/etc/nginx/vhost.common.d/10-php.conf similarity index 100% rename from docker/php-nginx/alpine-3/conf/etc/nginx/vhost.common.d/10-php.conf rename to docker/php-nginx-dev/alpine-php5/conf/etc/nginx/vhost.common.d/10-php.conf diff --git a/docker/php-nginx-dev/alpine-php5/conf/etc/nginx/vhost.conf b/docker/php-nginx-dev/alpine-php5/conf/etc/nginx/vhost.conf new file mode 100644 index 000000000..8225f314a --- /dev/null +++ b/docker/php-nginx-dev/alpine-php5/conf/etc/nginx/vhost.conf @@ -0,0 +1,26 @@ +server { + listen 80 default_server; + + server_name _ docker; + + root ""; + index ; + + include /opt/docker/etc/nginx/vhost.common.d/*.conf; +} + +############## +# SSL +############## + +server { + listen 443 default_server; + + server_name _ docker; + + root ""; + index ; + + include /opt/docker/etc/nginx/vhost.common.d/*.conf; + include /opt/docker/etc/nginx/vhost.ssl.conf; +} diff --git a/docker/php-nginx/alpine-3/conf/etc/nginx/vhost.ssl.conf b/docker/php-nginx-dev/alpine-php5/conf/etc/nginx/vhost.ssl.conf similarity index 100% rename from docker/php-nginx/alpine-3/conf/etc/nginx/vhost.ssl.conf rename to docker/php-nginx-dev/alpine-php5/conf/etc/nginx/vhost.ssl.conf diff --git a/docker/php-nginx-dev/alpine-php5/conf/etc/supervisor.d/blackfire-agent.conf b/docker/php-nginx-dev/alpine-php5/conf/etc/supervisor.d/blackfire-agent.conf new file mode 100644 index 000000000..897831ddb --- /dev/null +++ b/docker/php-nginx-dev/alpine-php5/conf/etc/supervisor.d/blackfire-agent.conf @@ -0,0 +1,14 @@ +[group:blackfire-agent] +programs=blackfire-agentd +priority=25 + +[program:blackfire-agentd] +command = /opt/docker/bin/service.d/blackfire-agent.sh +process_name=%(program_name)s +startsecs = 0 +autostart = false +autorestart = true +stdout_logfile=/dev/stdout +stdout_logfile_maxbytes=0 +stderr_logfile=/dev/stderr +stderr_logfile_maxbytes=0 diff --git a/docker/php-nginx/alpine-3/conf/etc/supervisor.d/nginx.conf b/docker/php-nginx-dev/alpine-php5/conf/etc/supervisor.d/nginx.conf similarity index 100% rename from docker/php-nginx/alpine-3/conf/etc/supervisor.d/nginx.conf rename to docker/php-nginx-dev/alpine-php5/conf/etc/supervisor.d/nginx.conf diff --git a/docker/php-nginx-dev/alpine-php5/conf/provision/entrypoint.d/10-php-debugger.sh b/docker/php-nginx-dev/alpine-php5/conf/provision/entrypoint.d/10-php-debugger.sh new file mode 100644 index 000000000..b5985a9ef --- /dev/null +++ b/docker/php-nginx-dev/alpine-php5/conf/provision/entrypoint.d/10-php-debugger.sh @@ -0,0 +1,96 @@ +#!/usr/bin/env bash + +################################################# +# Debugger switch +################################################# + +PHP_CONF_PATHS=" +/etc/php5/conf.d +/etc/php7/conf.d +/etc/php.d +/etc/php5/mods-available +/etc/php5/cli/conf.d +/etc/php5/cli/conf.d +/etc/php5/fpm/conf.d +/etc/php5/fpm/conf.d +/etc/php/7.0/mods-available +/etc/php/7.0/cli/conf.d +/etc/php/7.0/fpm/conf.d +/usr/local/etc/php/conf.d/" + +function phpModuleRemove() { + if [ "$#" -ne 1 ]; then + echo "You must specify the name of the PHP module which you want to disable" + exit 1 + fi + + echo " - Removing PHP module ${1}" + for CONF_PATH in $PHP_CONF_PATHS; do + rm -f "${CONF_PATH}"/*"${1}".ini + done +} + + +if [[ -n "${PHP_DEBUGGER+x}" ]]; then + case "$PHP_DEBUGGER" in + xdebug) + echo "PHP-Debugger: Xdebug enabled" + phpModuleRemove "blackfire" + ;; + + blackfire) + echo "PHP-Debugger: Blackfire enabled" + phpModuleRemove "xdebug" + docker-service-enable blackfire-agent + ;; + + none) + echo "PHP-Debugger: none" + phpModuleRemove "blackfire" + phpModuleRemove "xdebug" + ;; + esac + +else + + echo "PHP-Debugger: not specified - default is xdebug" + phpModuleRemove "blackfire" + +fi + +################################################# +# PHP debugger environment variables +################################################# + +function phpEnvironmentVariable() { + PHP_INI_KEY="$1" + PHP_ENV_NAME="$2" + + if [[ -n "${!PHP_ENV_NAME+x}" ]]; then + PHP_ENV_VALUE="${!PHP_ENV_NAME}" + echo "${PHP_INI_KEY}=\"${PHP_ENV_VALUE}\"" >> /opt/docker/etc/php/php.ini + fi +} + +################### +# XDEBUG +################### + +# remote debugger +phpEnvironmentVariable "xdebug.remote_connect_back" "XDEBUG_REMOTE_CONNECT_BACK" +phpEnvironmentVariable "xdebug.remote_autostart" "XDEBUG_REMOTE_AUTOSTART" +phpEnvironmentVariable "xdebug.remote_host" "XDEBUG_REMOTE_HOST" +phpEnvironmentVariable "xdebug.remote_port" "XDEBUG_REMOTE_PORT" + +# profiler +phpEnvironmentVariable "xdebug.profiler_enable" "XDEBUG_PROFILER_ENABLE" +phpEnvironmentVariable "xdebug.profiler_enable_trigger" "XDEBUG_PROFILER_ENABLE_TRIGGER" +phpEnvironmentVariable "xdebug.profiler_enable_trigger_value" "XDEBUG_PROFILER_ENABLE_TRIGGER_VALUE" +phpEnvironmentVariable "xdebug.profiler_output_dir" "XDEBUG_PROFILER_OUTPUT_DIR" +phpEnvironmentVariable "xdebug.profiler_output_name" "XDEBUG_PROFILER_OUTPUT_NAME" + +################### +# BLACKFIRE +################### +phpEnvironmentVariable "blackfire.server_id" "BLACKFIRE_SERVER_ID" +phpEnvironmentVariable "blackfire.server_token" "BLACKFIRE_SERVER_TOKEN" diff --git a/docker/php-nginx-dev/alpine-php5/conf/provision/roles/webdevops-nginx-dev/defaults/main.yml b/docker/php-nginx-dev/alpine-php5/conf/provision/roles/webdevops-nginx-dev/defaults/main.yml new file mode 100644 index 000000000..81f5b7efd --- /dev/null +++ b/docker/php-nginx-dev/alpine-php5/conf/provision/roles/webdevops-nginx-dev/defaults/main.yml @@ -0,0 +1,6 @@ +--- + +APPLICATION_USER: "{{ lookup('env','APPLICATION_USER') }}" +APPLICATION_GROUP: "{{ lookup('env','APPLICATION_GROUP') }}" +APPLICATION_UID: "{{ lookup('env','APPLICATION_UID') }}" +APPLICATION_GID: "{{ lookup('env','APPLICATION_GID') }}" diff --git a/docker/php-nginx-dev/alpine-php5/conf/provision/roles/webdevops-nginx-dev/tasks/bootstrap.yml b/docker/php-nginx-dev/alpine-php5/conf/provision/roles/webdevops-nginx-dev/tasks/bootstrap.yml new file mode 100644 index 000000000..3e783736c --- /dev/null +++ b/docker/php-nginx-dev/alpine-php5/conf/provision/roles/webdevops-nginx-dev/tasks/bootstrap.yml @@ -0,0 +1,3 @@ +--- + +- include: bootstrap/nginx.yml diff --git a/docker/php-nginx-dev/alpine-php5/conf/provision/roles/webdevops-nginx-dev/tasks/bootstrap/nginx.yml b/docker/php-nginx-dev/alpine-php5/conf/provision/roles/webdevops-nginx-dev/tasks/bootstrap/nginx.yml new file mode 100644 index 000000000..8075b2d9d --- /dev/null +++ b/docker/php-nginx-dev/alpine-php5/conf/provision/roles/webdevops-nginx-dev/tasks/bootstrap/nginx.yml @@ -0,0 +1,9 @@ +--- + +- name: Disable sendfile for nginx + lineinfile: + dest: /etc/nginx/nginx.conf + regexp: '[\s;]*{{ item.key }}[\s]*' + line: '{{ item.key }} {{ item.value }};' + with_items: + - { key: 'sendfile', value: "off" } diff --git a/docker/php-nginx-dev/alpine-php5/conf/provision/roles/webdevops-nginx-dev/tasks/main.yml b/docker/php-nginx-dev/alpine-php5/conf/provision/roles/webdevops-nginx-dev/tasks/main.yml new file mode 100644 index 000000000..1806c1a8c --- /dev/null +++ b/docker/php-nginx-dev/alpine-php5/conf/provision/roles/webdevops-nginx-dev/tasks/main.yml @@ -0,0 +1,5 @@ +--- + +- include: bootstrap.yml + tags: + - bootstrap diff --git a/docker/php-nginx-dev/alpine-php5/conf/provision/roles/webdevops-nginx/defaults/main.yml b/docker/php-nginx-dev/alpine-php5/conf/provision/roles/webdevops-nginx/defaults/main.yml new file mode 100644 index 000000000..69cba1cb4 --- /dev/null +++ b/docker/php-nginx-dev/alpine-php5/conf/provision/roles/webdevops-nginx/defaults/main.yml @@ -0,0 +1,3 @@ +--- + +DOCUMENT_ROOT: "{{ lookup('env','WEB_DOCUMENT_ROOT') }}" diff --git a/docker/php-nginx/alpine-3/conf/provision/roles/webdevops-nginx/tasks/bootstrap.yml b/docker/php-nginx-dev/alpine-php5/conf/provision/roles/webdevops-nginx/tasks/bootstrap.yml similarity index 100% rename from docker/php-nginx/alpine-3/conf/provision/roles/webdevops-nginx/tasks/bootstrap.yml rename to docker/php-nginx-dev/alpine-php5/conf/provision/roles/webdevops-nginx/tasks/bootstrap.yml diff --git a/docker/php-nginx-dev/alpine-php5/conf/provision/roles/webdevops-nginx/tasks/main.yml b/docker/php-nginx-dev/alpine-php5/conf/provision/roles/webdevops-nginx/tasks/main.yml new file mode 100644 index 000000000..1806c1a8c --- /dev/null +++ b/docker/php-nginx-dev/alpine-php5/conf/provision/roles/webdevops-nginx/tasks/main.yml @@ -0,0 +1,5 @@ +--- + +- include: bootstrap.yml + tags: + - bootstrap diff --git a/docker/php-nginx-dev/alpine-php5/conf/provision/roles/webdevops-php-dev/defaults/main.yml b/docker/php-nginx-dev/alpine-php5/conf/provision/roles/webdevops-php-dev/defaults/main.yml new file mode 100644 index 000000000..81f5b7efd --- /dev/null +++ b/docker/php-nginx-dev/alpine-php5/conf/provision/roles/webdevops-php-dev/defaults/main.yml @@ -0,0 +1,6 @@ +--- + +APPLICATION_USER: "{{ lookup('env','APPLICATION_USER') }}" +APPLICATION_GROUP: "{{ lookup('env','APPLICATION_GROUP') }}" +APPLICATION_UID: "{{ lookup('env','APPLICATION_UID') }}" +APPLICATION_GID: "{{ lookup('env','APPLICATION_GID') }}" diff --git a/docker/php-nginx-dev/alpine-php5/conf/provision/roles/webdevops-php-dev/tasks/bootstrap.yml b/docker/php-nginx-dev/alpine-php5/conf/provision/roles/webdevops-php-dev/tasks/bootstrap.yml new file mode 100644 index 000000000..ff02b05fc --- /dev/null +++ b/docker/php-nginx-dev/alpine-php5/conf/provision/roles/webdevops-php-dev/tasks/bootstrap.yml @@ -0,0 +1,7 @@ +--- + +- include: bootstrap/php-fpm.yml +- include: bootstrap/php-module.yml +- include: bootstrap/php-module.opcache.yml +- include: bootstrap/php-module.xdebug.yml +- include: bootstrap/php-module.blackfire.yml diff --git a/docker/php-nginx-dev/alpine-php5/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/php-fpm.yml b/docker/php-nginx-dev/alpine-php5/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/php-fpm.yml new file mode 100644 index 000000000..9455a78e2 --- /dev/null +++ b/docker/php-nginx-dev/alpine-php5/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/php-fpm.yml @@ -0,0 +1,18 @@ +--- + +- name: Configure php-fpm pool user (application.conf) + lineinfile: + dest: '/opt/docker/etc/php/fpm/pool.d/application.conf' + regexp: '^[\s;]*{{ item.key }}[\s]*=' + line: '{{ item.key }} = {{ item.value }}' + with_items: + - { key: 'access.log', value: "/docker.stdout" } + - { key: "access.format", value: '"%R - %u %t \"%m %r%Q%q\" %s %f cpu:%C%% mem:%{megabytes}M reqTime:%d"' } + +- name: Open php-fpm for external connections (eg. debuggers) + lineinfile: + dest: '/opt/docker/etc/php/fpm/pool.d/application.conf' + regexp: '^[\s;]*{{ item.key }}[\s]*=' + line: '{{ item.key }} = {{ item.value }}' + with_items: + - { key: 'listen', value: "0.0.0.0:9000" } diff --git a/docker/php-nginx-dev/alpine-php5/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/php-module.blackfire.yml b/docker/php-nginx-dev/alpine-php5/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/php-module.blackfire.yml new file mode 100644 index 000000000..faf05f8de --- /dev/null +++ b/docker/php-nginx-dev/alpine-php5/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/php-module.blackfire.yml @@ -0,0 +1,10 @@ +--- + +- name: Remove superfluous blackfire configuration file + file: + path: '{{ item }}' + state: absent + with_items: + - /etc/php5/cli/conf.d/zz-blackfire.ini + - /etc/php5/fpm/conf.d/zz-blackfire.ini + when: ansible_distribution == 'Debian' and docker_image_info_distribution_version|int >= 7 diff --git a/docker/php-nginx-dev/alpine-php5/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/php-module.opcache.yml b/docker/php-nginx-dev/alpine-php5/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/php-module.opcache.yml new file mode 100644 index 000000000..9c243a671 --- /dev/null +++ b/docker/php-nginx-dev/alpine-php5/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/php-module.opcache.yml @@ -0,0 +1,14 @@ +--- + +- name: Setup php.ini for development environment + lineinfile: + dest: '/opt/docker/etc/php/php.webdevops.ini' + regexp: '^[\s;]*{{ item.variable }}[\s]*=' + line: '{{ item.variable }} = {{ item.value }}' + with_items: + - { variable: 'opcache.memory_consumption', value: '256' } + - { variable: 'opcache.validate_timestamps', value: '1' } + - { variable: 'opcache.revalidate_freq', value: '0' } + - { variable: 'opcache.interned_strings_buffer', value: '16' } + - { variable: 'opcache.max_accelerated_files', value: '7963' } + - { variable: 'opcache.fast_shutdown', value: '1' } diff --git a/docker/php-nginx-dev/alpine-php5/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/php-module.xdebug.yml b/docker/php-nginx-dev/alpine-php5/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/php-module.xdebug.yml new file mode 100644 index 000000000..7f20c845e --- /dev/null +++ b/docker/php-nginx-dev/alpine-php5/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/php-module.xdebug.yml @@ -0,0 +1,28 @@ +--- + +# Ignored on php7 +- name: Fix php xdebug module [Alpine family] + lineinfile: + dest: '{{ item }}' + regexp: 'extension=xdebug.so' + line: 'zend_extension=xdebug.so' + when: ansible_distribution == 'Alpine' + with_items: + - /etc/php5/conf.d/xdebug.ini + - /etc/php7/conf.d/xdebug.ini + ignore_errors: yes + +- name: Setup php.ini for development environment + lineinfile: + dest: '/opt/docker/etc/php/php.webdevops.ini' + regexp: '^[\s;]*{{ item.variable }}[\s]*=' + line: '{{ item.variable }} = {{ item.value }}' + with_items: + - { variable: 'xdebug.remote_enable', value: '1' } + - { variable: 'xdebug.remote_connect_back', value: '1' } + - { variable: 'xdebug.idekey', value: 'docker' } + - { variable: 'xdebug.cli_color', value: '1' } + - { variable: 'xdebug.max_nesting_level', value: '1000' } + - { variable: 'xdebug.profiler_enable_trigger', value: '1000' } + - { variable: 'xdebug.profiler_output_dir', value: '/tmp/debug/' } + - { variable: 'xhprof.output_dir', value: '/tmp/debug/' } diff --git a/docker/php-nginx-dev/alpine-php5/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/php-module.yml b/docker/php-nginx-dev/alpine-php5/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/php-module.yml new file mode 100644 index 000000000..31cccd1ae --- /dev/null +++ b/docker/php-nginx-dev/alpine-php5/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/php-module.yml @@ -0,0 +1,41 @@ +--- + +############################# +# Workaround PHP configuration files +# for alpine +############################# + +- name: Get list of PHP5 configuration files + command: "ls /etc/php5/conf.d/ |grep .ini" + register: php5_ini + when: ansible_distribution == 'Alpine' + ignore_errors: yes + +- name: Link configuration files from php5 to php + file: + src: '/etc/php5/conf.d/{{ item }}' + dest: '/etc/php/conf.d/{{ item }}' + state: link + with_items: "{{ php5_ini.stdout_lines }}" + when: ansible_distribution == 'Alpine' and php5_ini is defined + ignore_errors: yes + +############################# +# Workaround PHP module files +# for alpine +############################# + +- name: Get list of PHP5 modules + command: "ls /usr/lib/php5/modules/ |grep .so" + register: php5_modules + when: ansible_distribution == 'Alpine' + ignore_errors: yes + +- name: Link module files from php5 to php + file: + src: '/usr/lib/php5/modules/{{ item }}' + dest: '/usr/lib/php/modules/{{ item }}' + state: link + with_items: "{{ php5_modules.stdout_lines }}" + when: ansible_distribution == 'Alpine' and php5_modules is defined + ignore_errors: yes diff --git a/docker/php-nginx-dev/alpine-php5/conf/provision/roles/webdevops-php-dev/tasks/main.yml b/docker/php-nginx-dev/alpine-php5/conf/provision/roles/webdevops-php-dev/tasks/main.yml new file mode 100644 index 000000000..1806c1a8c --- /dev/null +++ b/docker/php-nginx-dev/alpine-php5/conf/provision/roles/webdevops-php-dev/tasks/main.yml @@ -0,0 +1,5 @@ +--- + +- include: bootstrap.yml + tags: + - bootstrap diff --git a/docker/php-nginx-dev/alpine-php5/conf/provision/roles/webdevops-php-nginx/defaults/main.yml b/docker/php-nginx-dev/alpine-php5/conf/provision/roles/webdevops-php-nginx/defaults/main.yml new file mode 100644 index 000000000..ed97d539c --- /dev/null +++ b/docker/php-nginx-dev/alpine-php5/conf/provision/roles/webdevops-php-nginx/defaults/main.yml @@ -0,0 +1 @@ +--- diff --git a/docker/php-nginx/alpine-3/conf/provision/roles/webdevops-php-nginx/tasks/bootstrap.yml b/docker/php-nginx-dev/alpine-php5/conf/provision/roles/webdevops-php-nginx/tasks/bootstrap.yml similarity index 100% rename from docker/php-nginx/alpine-3/conf/provision/roles/webdevops-php-nginx/tasks/bootstrap.yml rename to docker/php-nginx-dev/alpine-php5/conf/provision/roles/webdevops-php-nginx/tasks/bootstrap.yml diff --git a/docker/php-nginx-dev/alpine-php5/conf/provision/roles/webdevops-php-nginx/tasks/entrypoint.yml b/docker/php-nginx-dev/alpine-php5/conf/provision/roles/webdevops-php-nginx/tasks/entrypoint.yml new file mode 100644 index 000000000..cd21505a4 --- /dev/null +++ b/docker/php-nginx-dev/alpine-php5/conf/provision/roles/webdevops-php-nginx/tasks/entrypoint.yml @@ -0,0 +1,2 @@ +--- + diff --git a/docker/php-nginx-dev/alpine-php5/conf/provision/roles/webdevops-php-nginx/tasks/main.yml b/docker/php-nginx-dev/alpine-php5/conf/provision/roles/webdevops-php-nginx/tasks/main.yml new file mode 100644 index 000000000..7895a52a9 --- /dev/null +++ b/docker/php-nginx-dev/alpine-php5/conf/provision/roles/webdevops-php-nginx/tasks/main.yml @@ -0,0 +1,9 @@ +--- + +- include: bootstrap.yml + tags: + - bootstrap + +- include: entrypoint.yml + tags: + - entrypoint diff --git a/docker/php-nginx-dev/alpine-php7/Dockerfile b/docker/php-nginx-dev/alpine-php7/Dockerfile new file mode 100644 index 000000000..6130a5c0b --- /dev/null +++ b/docker/php-nginx-dev/alpine-php7/Dockerfile @@ -0,0 +1,23 @@ +#+++++++++++++++++++++++++++++++++++++++ +# Dockerfile for webdevops/php-nginx-dev:alpine-php7 +# -- automatically generated -- +#+++++++++++++++++++++++++++++++++++++++ + +FROM webdevops/php-dev:alpine-php7 + +ENV WEB_DOCUMENT_ROOT=/app \ + WEB_DOCUMENT_INDEX=index.php \ + WEB_ALIAS_DOMAIN=*.vm +ENV WEB_PHP_SOCKET=127.0.0.1:9000 +ENV WEB_NO_CACHE_PATTERN="\.(css|js|gif|png|jpg|svg|json|xml)$" + +COPY conf/ /opt/docker/ + +# Install nginx +RUN /usr/local/bin/apk-install \ + nginx \ + && /opt/docker/bin/provision run --tag bootstrap --role webdevops-nginx --role webdevops-php-nginx --role webdevops-nginx-dev --role webdevops-php-dev \ + && /opt/docker/bin/bootstrap.sh \ + && docker-image-cleanup + +EXPOSE 80 443 diff --git a/docker/php-nginx-dev/alpine-php7/Dockerfile.jinja2 b/docker/php-nginx-dev/alpine-php7/Dockerfile.jinja2 new file mode 100644 index 000000000..fb5e20418 --- /dev/null +++ b/docker/php-nginx-dev/alpine-php7/Dockerfile.jinja2 @@ -0,0 +1,11 @@ +{{ docker.from("php-dev", "alpine-php7") }} + +{{ environment.web() }} +{{ environment.webPhp() }} +{{ environment.webDevelopment() }} + +{{ docker.copy('conf/', '/opt/docker/') }} + +{{ nginx.alpine('php-nginx nginx-dev php-dev') }} + +{{ docker.expose('80 443') }} diff --git a/docker/php-nginx-dev/alpine-php7/conf/bin/service.d/blackfire-agent.d/10-init.sh b/docker/php-nginx-dev/alpine-php7/conf/bin/service.d/blackfire-agent.d/10-init.sh new file mode 100644 index 000000000..fdffa2a0f --- /dev/null +++ b/docker/php-nginx-dev/alpine-php7/conf/bin/service.d/blackfire-agent.d/10-init.sh @@ -0,0 +1 @@ +# placeholder diff --git a/docker/php-nginx-dev/alpine-php7/conf/bin/service.d/blackfire-agent.sh b/docker/php-nginx-dev/alpine-php7/conf/bin/service.d/blackfire-agent.sh new file mode 100644 index 000000000..fbec23cf3 --- /dev/null +++ b/docker/php-nginx-dev/alpine-php7/conf/bin/service.d/blackfire-agent.sh @@ -0,0 +1,23 @@ +#!/usr/bin/env bash +set -e + +source /opt/docker/bin/config.sh + +BLACKFIRE_ARGS="" + +includeScriptDir "/opt/docker/bin/service.d/syslog-ng.d/" + +# blackfire.server_id +if [[ -n "${BLACKFIRE_SERVER_ID+x}" ]]; then + BLACKFIRE_ARGS="$BLACKFIRE_ARGS --server-id=\"${BLACKFIRE_SERVER_ID}\"" +fi + +# blackfire.server_token +if [[ -n "${BLACKFIRE_SERVER_TOKEN+x}" ]]; then + BLACKFIRE_ARGS="$BLACKFIRE_ARGS --server-token=\"${BLACKFIRE_SERVER_TOKEN}\"" +fi + +# create directory for unix socket +mkdir -p /var/run/blackfire + +eval exec blackfire-agent $BLACKFIRE_ARGS diff --git a/docker/php-nginx-dev/alpine-php7/conf/bin/service.d/nginx.d/10-init.sh b/docker/php-nginx-dev/alpine-php7/conf/bin/service.d/nginx.d/10-init.sh new file mode 100644 index 000000000..27b9776cc --- /dev/null +++ b/docker/php-nginx-dev/alpine-php7/conf/bin/service.d/nginx.d/10-init.sh @@ -0,0 +1,25 @@ +if [[ ! -e "$WEB_DOCUMENT_ROOT" ]]; then + echo "" + echo "[WARNING] WEB_DOCUMENT_ROOT does not exists with path \"$WEB_DOCUMENT_ROOT\"!" + echo "" +fi + +# Prevent startup of nginx (ubuntu 16.04 needs it) +ln -f -s /var/lib/nginx/logs /var/log/nginx + +# Replace markers +go-replace \ + -s "" -r "$WEB_DOCUMENT_INDEX" \ + -s "" -r "$WEB_DOCUMENT_ROOT" \ + -s "" -r "$WEB_ALIAS_DOMAIN" \ + -s "" -r "$HOSTNAME" \ + -s "" -r "$WEB_PHP_SOCKET" \ + --path=/opt/docker/etc/nginx/ \ + --path-pattern='*.conf' \ + --ignore-empty + +if [[ -z "${WEB_PHP_SOCKET+x}" ]]; then + ## WEB_PHP_SOCKET is not set, remove PHP files + rm -f -- /opt/docker/etc/nginx/conf.d/10-php.conf + rm -f -- /opt/docker/etc/nginx/vhost.common.d/10-php.conf +fi diff --git a/docker/php-nginx-dev/alpine-php7/conf/bin/service.d/nginx.d/12-development.sh b/docker/php-nginx-dev/alpine-php7/conf/bin/service.d/nginx.d/12-development.sh new file mode 100644 index 000000000..f4695f059 --- /dev/null +++ b/docker/php-nginx-dev/alpine-php7/conf/bin/service.d/nginx.d/12-development.sh @@ -0,0 +1,7 @@ +go-replace \ + -s "" \ + -r "$WEB_NO_CACHE_PATTERN" \ + --path=/opt/docker/etc/nginx/ \ + --path-pattern='*.conf' \ + --ignore-empty + diff --git a/docker/php-nginx-dev/alpine-php7/conf/bin/service.d/nginx.sh b/docker/php-nginx-dev/alpine-php7/conf/bin/service.d/nginx.sh new file mode 100644 index 000000000..f5cd26167 --- /dev/null +++ b/docker/php-nginx-dev/alpine-php7/conf/bin/service.d/nginx.sh @@ -0,0 +1,7 @@ +#!/usr/bin/env bash + +source /opt/docker/bin/config.sh + +includeScriptDir "/opt/docker/bin/service.d/nginx.d/" + +exec /usr/sbin/nginx diff --git a/docker/php-nginx-dev/alpine-php7/conf/etc/nginx/conf.d/.gitkeep b/docker/php-nginx-dev/alpine-php7/conf/etc/nginx/conf.d/.gitkeep new file mode 100644 index 000000000..e69de29bb diff --git a/docker/php-nginx-dev/alpine-php7/conf/etc/nginx/conf.d/02-dev.conf b/docker/php-nginx-dev/alpine-php7/conf/etc/nginx/conf.d/02-dev.conf new file mode 100644 index 000000000..fdffa2a0f --- /dev/null +++ b/docker/php-nginx-dev/alpine-php7/conf/etc/nginx/conf.d/02-dev.conf @@ -0,0 +1 @@ +# placeholder diff --git a/docker/php-nginx-dev/alpine-php7/conf/etc/nginx/conf.d/10-php.conf b/docker/php-nginx-dev/alpine-php7/conf/etc/nginx/conf.d/10-php.conf new file mode 100644 index 000000000..9abe45f0a --- /dev/null +++ b/docker/php-nginx-dev/alpine-php7/conf/etc/nginx/conf.d/10-php.conf @@ -0,0 +1,3 @@ +upstream php { + server ; +} diff --git a/docker/php-nginx-dev/alpine-php7/conf/etc/nginx/global.conf b/docker/php-nginx-dev/alpine-php7/conf/etc/nginx/global.conf new file mode 100644 index 000000000..b6141db09 --- /dev/null +++ b/docker/php-nginx-dev/alpine-php7/conf/etc/nginx/global.conf @@ -0,0 +1 @@ +# deprecated diff --git a/docker/php-nginx-dev/alpine-php7/conf/etc/nginx/main.conf b/docker/php-nginx-dev/alpine-php7/conf/etc/nginx/main.conf new file mode 100644 index 000000000..06de0651b --- /dev/null +++ b/docker/php-nginx-dev/alpine-php7/conf/etc/nginx/main.conf @@ -0,0 +1,4 @@ +include /opt/docker/etc/nginx/global.conf; +include /opt/docker/etc/nginx/php.conf; +include /opt/docker/etc/nginx/conf.d/*.conf; +include /opt/docker/etc/nginx/vhost.conf; diff --git a/docker/php-nginx-dev/alpine-3/conf/etc/nginx/nginx.conf b/docker/php-nginx-dev/alpine-php7/conf/etc/nginx/nginx.conf similarity index 100% rename from docker/php-nginx-dev/alpine-3/conf/etc/nginx/nginx.conf rename to docker/php-nginx-dev/alpine-php7/conf/etc/nginx/nginx.conf diff --git a/docker/php-nginx-dev/alpine-php7/conf/etc/nginx/php.conf b/docker/php-nginx-dev/alpine-php7/conf/etc/nginx/php.conf new file mode 100644 index 000000000..b6141db09 --- /dev/null +++ b/docker/php-nginx-dev/alpine-php7/conf/etc/nginx/php.conf @@ -0,0 +1 @@ +# deprecated diff --git a/docker/php-nginx-dev/alpine-php7/conf/etc/nginx/ssl/server.crt b/docker/php-nginx-dev/alpine-php7/conf/etc/nginx/ssl/server.crt new file mode 100644 index 000000000..6b0694907 --- /dev/null +++ b/docker/php-nginx-dev/alpine-php7/conf/etc/nginx/ssl/server.crt @@ -0,0 +1,28 @@ +-----BEGIN CERTIFICATE----- +MIIE1DCCArwCCQDMMwGnSuK0tTANBgkqhkiG9w0BAQsFADAsMRswGQYDVQQKExJE +b2NrZXIgQm9pbGVycGxhdGUxDTALBgNVBAMUBCoudm0wHhcNMTUwNTA0MTcxNDQw +WhcNMjUwNTAxMTcxNDQwWjAsMRswGQYDVQQKExJEb2NrZXIgQm9pbGVycGxhdGUx +DTALBgNVBAMUBCoudm0wggIiMA0GCSqGSIb3DQEBAQUAA4ICDwAwggIKAoICAQDK +3TIUiyDvXelWeY9VXMrpjuZtYpVSDsACLpjFUhMnsP5/iKT0VbeZyqHvmwZjAg4G +Y10d+yZDdgv/xeu0HPOFbtR6pCp10d1tdLHZto5Cyuxu7IQsAVjnD6Ko7XFwtNk7 +9o6JZfAFaGL4w5MokrVmCtspnsMZH7/7zU4f96cbF39zLopnpuXGD6t6DA8Qj3gy +0duaTjs42bYRN+rwLzVKAev99iQ4kPMJn4vV6/Xk6rtoSzC67GQyVZYaFypicD1S +NtsRmgEVvjCBDbrLOneUiRwff6qxEsZi7Hxv7BKFj4iUWnII7K/nP7T6uBHQjHO+ +FpsGkU9lCMrCeVFBe8kKz/cbhd+yLUxXwAPr6gSOPmwn232Gy4tozvqZHpbUxsgx +7sT3ej9K66h1D7J+BjNFWYM1hbnC1r7H/xS7EBzBV8qRoQCVe08Juf5xsouXFakD +clLV4+L+1cxkpwsCQDly5g3tm/TBqA2O+ZJ+YHQDHKkzMyhLs6i0X/M5qvJBiLg1 +GLTCS20rpQ5gXTEGuINqHgwXQWkUO6bhgSYqdHGX3zbZ5+qWpI4eui3dHZ1Ll0VH +6Icpb7ORTQwhc6W8KBlybssYPSlGOEBGUjYGNheoz9FpoSkxCis+P8ZNKtrmpPoq +Su0eOOGFOFHG02eOgPVxSwrDeN9MVJo7BPysGMHJmQIDAQABMA0GCSqGSIb3DQEB +CwUAA4ICAQC63g6NHmQKbiy3G6iaDkpUSbr5Mq2YgU61XnvWVyREqDcy/BXCw9oY +SJ/KUvCpqPnACNOFqjadRAmPiA9nf2WduoCgwQGV/YRFGswSuVvh/3X2TX5NWvbS +t8MQDttQg1dxpiMUjlu3rqhfohBdWJvp2lVSdpDb/MOlXBc/+p7HfOHwhqB7wwPN +NNbSKUbZqZxmD8cOf1X0hASr1yfFPj+2vST3ESaON8S0T2p63YX/sD5jvOUiEuyw +I5WcvLmiRZA07SH8nWyckLY3qWL+OlhSZrlAnolWS00b+7h5LNuRYEjKzwVgntoA +aCopyQih6wIk0+AfJO4sfhJBmQhnIrAaP/zwBH5g9zVizLf5H7U+hNXrMwgw55Sq +vjMdkZHvPKUXTvVit/rYE9H+PY3brkRWzOl4V/i/ZLJJm5805H/NyTbz9kPMJw2Q +nn+KOpfXXySD39f8iuRgSKXsYNul38hxWgcZZ6g+sOOp2n/VUmf0eZUWNnJ8i7AP +4Qif7aDKMcibOwSwsB+DKZXDvZ5XSdnMphtuLS5rPSL81rVRmWC2DMfQ2eP8j0WN +VTroSk0xedQ7Qr+9TNooi9IyzX6n1a2S1UiciEZ3ZcDbXPl/P01m+IYZyPnLv0+9 +ZeioZYh1JLv3/OKsMrMLTfh2ZCj3aXwmc2Owi/wU2LS5QUOMcHH7CQ== +-----END CERTIFICATE----- \ No newline at end of file diff --git a/docker/php-nginx-dev/alpine-php7/conf/etc/nginx/ssl/server.csr b/docker/php-nginx-dev/alpine-php7/conf/etc/nginx/ssl/server.csr new file mode 100644 index 000000000..8a9909f77 --- /dev/null +++ b/docker/php-nginx-dev/alpine-php7/conf/etc/nginx/ssl/server.csr @@ -0,0 +1,26 @@ +-----BEGIN CERTIFICATE REQUEST----- +MIIEcTCCAlkCAQAwLDEbMBkGA1UEChMSRG9ja2VyIEJvaWxlcnBsYXRlMQ0wCwYD +VQQDFAQqLnZtMIICIjANBgkqhkiG9w0BAQEFAAOCAg8AMIICCgKCAgEAyt0yFIsg +713pVnmPVVzK6Y7mbWKVUg7AAi6YxVITJ7D+f4ik9FW3mcqh75sGYwIOBmNdHfsm +Q3YL/8XrtBzzhW7UeqQqddHdbXSx2baOQsrsbuyELAFY5w+iqO1xcLTZO/aOiWXw +BWhi+MOTKJK1ZgrbKZ7DGR+/+81OH/enGxd/cy6KZ6blxg+regwPEI94MtHbmk47 +ONm2ETfq8C81SgHr/fYkOJDzCZ+L1ev15Oq7aEswuuxkMlWWGhcqYnA9UjbbEZoB +Fb4wgQ26yzp3lIkcH3+qsRLGYux8b+wShY+IlFpyCOyv5z+0+rgR0IxzvhabBpFP +ZQjKwnlRQXvJCs/3G4Xfsi1MV8AD6+oEjj5sJ9t9hsuLaM76mR6W1MbIMe7E93o/ +SuuodQ+yfgYzRVmDNYW5wta+x/8UuxAcwVfKkaEAlXtPCbn+cbKLlxWpA3JS1ePi +/tXMZKcLAkA5cuYN7Zv0wagNjvmSfmB0AxypMzMoS7OotF/zOaryQYi4NRi0wktt +K6UOYF0xBriDah4MF0FpFDum4YEmKnRxl9822efqlqSOHrot3R2dS5dFR+iHKW+z +kU0MIXOlvCgZcm7LGD0pRjhARlI2BjYXqM/RaaEpMQorPj/GTSra5qT6KkrtHjjh +hThRxtNnjoD1cUsKw3jfTFSaOwT8rBjByZkCAwEAAaAAMA0GCSqGSIb3DQEBCwUA +A4ICAQBsEBgC2YepuZq/8UqvKMZKVy/etDKXj7BB+QPb+leNiKD7p4LDxHJsZSH8 +Ku9uMPeLfiQDn5jA41k5SlGttzvObd65RdEbO3yHpqsg05EGSDDLfaE1k2Al/qmX +/o8roPZF7+2kZthgMAgkcokS54LYqEYTGqOf3J9Ss0yRIZwhaOVebfFIbIOdpw0B +JNMIJPHTMdZrcuRVI+wR1uPLIlEJzBvxTGbTrvPU25WJFtu+EajKqXO0SHdy0yx8 +uH4ykRBJRc36+oYo7nZ5D56dh7pZn3+9J64FKAOV0Q3KqMFieGy053ezuhJd70eZ +UozTgfjs3WpMzoYmKETSyl3XZSdInRe+sUlKPruTsKyg69oYxjPlrGfAmmGcCFca +TnZinT18dI92zK7OtOVkmYeYKC1lwuhftVrNMXzZuHOGpS9NNYtc4nDqDMIEOfV3 +6rCdu03WjEgJ+Z67tJs16xOx9du4/EHxS2Ijn9DPfVJvYy0TgzDi1BUpjWx0KTLx +C4OQbEZ/QTWmHVbSch/hcZhzbf7SNh5RpnW4EtmcpDFjIKMfxJmoKeiTf7qnilx0 +7uRvsZFKoDKRDOFiPfgMg5AOtLHziYsd9m0tJjC2GHvFuPjzOtzhnUUjmmvht170 +2aqKakjST4amg7jzLcs871HX0/WjOtt29NpOz140blkKf1bisg== +-----END CERTIFICATE REQUEST----- \ No newline at end of file diff --git a/docker/php-nginx-dev/alpine-php7/conf/etc/nginx/ssl/server.key b/docker/php-nginx-dev/alpine-php7/conf/etc/nginx/ssl/server.key new file mode 100644 index 000000000..c9eec145f --- /dev/null +++ b/docker/php-nginx-dev/alpine-php7/conf/etc/nginx/ssl/server.key @@ -0,0 +1,51 @@ +-----BEGIN RSA PRIVATE KEY----- +MIIJKAIBAAKCAgEAyt0yFIsg713pVnmPVVzK6Y7mbWKVUg7AAi6YxVITJ7D+f4ik +9FW3mcqh75sGYwIOBmNdHfsmQ3YL/8XrtBzzhW7UeqQqddHdbXSx2baOQsrsbuyE +LAFY5w+iqO1xcLTZO/aOiWXwBWhi+MOTKJK1ZgrbKZ7DGR+/+81OH/enGxd/cy6K +Z6blxg+regwPEI94MtHbmk47ONm2ETfq8C81SgHr/fYkOJDzCZ+L1ev15Oq7aEsw +uuxkMlWWGhcqYnA9UjbbEZoBFb4wgQ26yzp3lIkcH3+qsRLGYux8b+wShY+IlFpy +COyv5z+0+rgR0IxzvhabBpFPZQjKwnlRQXvJCs/3G4Xfsi1MV8AD6+oEjj5sJ9t9 +hsuLaM76mR6W1MbIMe7E93o/SuuodQ+yfgYzRVmDNYW5wta+x/8UuxAcwVfKkaEA +lXtPCbn+cbKLlxWpA3JS1ePi/tXMZKcLAkA5cuYN7Zv0wagNjvmSfmB0AxypMzMo +S7OotF/zOaryQYi4NRi0wkttK6UOYF0xBriDah4MF0FpFDum4YEmKnRxl9822efq +lqSOHrot3R2dS5dFR+iHKW+zkU0MIXOlvCgZcm7LGD0pRjhARlI2BjYXqM/RaaEp +MQorPj/GTSra5qT6KkrtHjjhhThRxtNnjoD1cUsKw3jfTFSaOwT8rBjByZkCAwEA +AQKCAgAbZPdoUsllyZbC+LNkYZ19ILD5QIDNjfRb1xMGQmkXyQz1B+zOmeyrNfPc +OWEJabOfJTfj3pByN7SzG3US4333HNpQnW6mbmqqZ0HFFqPrXR/Ecuf+UUhCG5hp +m3bgM2vKbyccYsmg0VHcKfzrU7RvTTP/UNMjx2fThwvvwS+ttuSdF0HVcXJB5sfP +OWWnZNhkdHZlRf81VCED/jsZqCZYEh5eMyj9AoXvXL4zayPPf+tC0DSKaXW2Xlxg +tZQhqup8+a9nlxZia0Z9hu8clo6jXkiP8FuKgfCMV0cOjiCKLLHS5svTbLLsVWwJ +F2ZAdVcD6mWQ43qHOEK5NEzGvQKO14CaOLnVT2yAkMcyNohsEgoDP9oCBGDJQbBH +NmtZfpVjjtuTr9P9TEkU1FcBRo0x6Il/DkzamGbOeFAmgnaGElhJ5c/CAG7whaIf +mUfFOBGPH/wESY3gBOACDofeSh27RrlvbLaPiCGKivDUTBmhBsIuso6XqOKbvtfV +/HhhndpdRVfIj4DdE7gIrLIGN977JMVAXFCNz7KrvAWwcOXrCHCoWpklJ9repq8l +26ICY8K7VXktzDHQUmhd88ZWR+9ASURsJghUgZUOcMrEGyvci6Y8hpLhHiNVPHuQ ++ps7tpPsXSntBUqWBzhRZh74+nJlOOV6oYykl30JT2JzB6lwiQKCAQEA9ecn8N2z +20tR2UEiTv/MjVSepQtAAajegvcd1iasvvQKXnh3XLmoZHzH2tTa0lp5RIZpUQPl +lOTwko0lYTBnYblt65AJQ3FTgisNobIpoqE8BFXLm6wggz7CbabjmPGDe173lPGR +sI0YSKYvzrdn4zw8Fh6WULJyZHLi58zJYL3r0WBDiOoxpGaGA1GlmkuIWjhKHaX2 +OvF1vOuQDJ2eDyTc5TYFC0NKG76Mvanov5L/yrhNM/umbmp0SPspzHGZobAKUr20 +OazFT8S+2TA1OTxWNbiPbSimFoaZbEdqsNACGfVJWO8Sh8iqlt5RmEcSiSvGBj6L +QKprRO9Fsp2GawKCAQEA0zGhRsnux4JTNsdUSYsEJtITMj6eE+nl7CoZ9DAOwC5X +6/aSpUE4TT+pWNrt9iluXiGL0j89UJ7r/L1OcsiyzGb8ig9NU4zr1NIGTZ0DstHi +HPYINjeiBJEFIy17kOQn+9/I5c4hBUwz6ihwNoEomymVB/EsLJKAML0AudJGKg+Z +/f/qrS40eab5SAiaKgsh0MZnj+vIxyGBydt6r2HGmjfNITVbXIu6IpO+6NXDwM/e +7v10AAZ3j9+gb1RedLg2ghuIuYU90hmMhtVWsh9nVmaOkMW9/WFgOPYvt/mHH/hR +d4pePZ9kACGmqo/b9sHvHw1YEubtCt1VUiNuFxnJCwKCAQBWnxz0vkRTJY8phsY9 +KeK2jm5sGTBs5T2syLwb6ffENFdKvAjgAw6Mh2And/+1ReWd+/MxdLv03UjZdxsJ +x3FDfXx5FH4O4ebW3a+pnAcKoN1xcX+N0O6LDRqUYcue3sTAOs3gC9CUbr91KAWD +Phw8ccWAzTmKJ7IgLFA982ekyoI9eTmRC159WRgwJxy844qerWF+XC4GyXP+HsTZ +jNRW5Vdi7sqMEyIR7+fIEAhLI88zbATWIPmZv6pC4ybwO7wwtsCMMQNBpdjDprzL +6S12ggikV+U+QKlxGe0FtYqhykRTPJKf32eZqVheWOZJTA/9fgv9ux52oxGycM8O +gmsNAoIBAQC60m5uZnd5uYnPLWkcXYNgq/kbO1UvHHut/FhVMKX7z4MrU0XKNfWO +MECoP5K9bU0aq+Y6KIMe7FapjvT0iSHRu1Cu+HZY8JI2A0xcIAeDijLRl7sP6wrB +q1+2DKgANjRAlWfsEfoX658JBpitPngjOheBnRCMpVQMyUT5HE/BKWf5zwdUB0mY +S+K8nA90HcDeJIS8RcGolbVwUV0oBABhr/cf50lYhqozqCr7YQ33ZGs7Uq3oz8+4 +UARmN2YPLl3Znm3GX12em8c6B0LX8vvA7Jw06Rf2Ksup1+3Ce1PTLiEy9A4FyRf3 +Hc2HmBbnJAtZlr5QikMqlzzAmmLqwH6dAoIBAC+ryaQGJFsijCSuaDfRp/uy9xnd +DjgMdTwjl5WLBmyudChVMANl8eqCbvVO41CN84yORk03oQ4cx0eKxAZaLaSzgkb3 +W0X2nFQe7VJSYMQswCQ+1WfJvEFrIdkEKIa//uQdhqNrgUKSNVhhSTMbNEkDTIWn +ssbv2H9hvUaFt/J/vP9zCKuU5oYvNU7Oi6ZXRYezRn9atlJYanLFoJnHUBRzGms5 +K0vhdCPDXQq87z5Yudoh0jLUQF9Nx0GTWeBceQ9n5hZeRUNQWxP4AJThQX9KSPTS +mbL3Kh4XNRmAUJ2N+Njh+3dg91s+JkKvC1wcspLsmLPQe+9AxBSH9y5JE/8= +-----END RSA PRIVATE KEY----- \ No newline at end of file diff --git a/docker/php-nginx-dev/alpine-php7/conf/etc/nginx/vhost.common.conf b/docker/php-nginx-dev/alpine-php7/conf/etc/nginx/vhost.common.conf new file mode 100644 index 000000000..a5df62ef8 --- /dev/null +++ b/docker/php-nginx-dev/alpine-php7/conf/etc/nginx/vhost.common.conf @@ -0,0 +1,2 @@ +# compatibility for PHP and TYPO3 Docker Boilerplate +include /opt/docker/etc/nginx/vhost.common.d/*.conf; diff --git a/docker/php-nginx-dev/alpine-php7/conf/etc/nginx/vhost.common.d/.gitkeep b/docker/php-nginx-dev/alpine-php7/conf/etc/nginx/vhost.common.d/.gitkeep new file mode 100644 index 000000000..e69de29bb diff --git a/docker/php-nginx-dev/alpine-php7/conf/etc/nginx/vhost.common.d/02-dev.conf b/docker/php-nginx-dev/alpine-php7/conf/etc/nginx/vhost.common.d/02-dev.conf new file mode 100644 index 000000000..4f80ec9d3 --- /dev/null +++ b/docker/php-nginx-dev/alpine-php7/conf/etc/nginx/vhost.common.d/02-dev.conf @@ -0,0 +1,6 @@ +location ~* { + expires off; + add_header Cache-Control private; + + try_files $uri $uri/ /?$query_string; +} diff --git a/docker/php-nginx-dev/alpine-php7/conf/etc/nginx/vhost.common.d/10-general.conf b/docker/php-nginx-dev/alpine-php7/conf/etc/nginx/vhost.common.d/10-general.conf new file mode 100644 index 000000000..d3fd0aa5e --- /dev/null +++ b/docker/php-nginx-dev/alpine-php7/conf/etc/nginx/vhost.common.d/10-general.conf @@ -0,0 +1 @@ +client_max_body_size 50m; diff --git a/docker/php-nginx-dev/alpine-php7/conf/etc/nginx/vhost.common.d/10-location-root.conf b/docker/php-nginx-dev/alpine-php7/conf/etc/nginx/vhost.common.d/10-location-root.conf new file mode 100644 index 000000000..28fd811bc --- /dev/null +++ b/docker/php-nginx-dev/alpine-php7/conf/etc/nginx/vhost.common.d/10-location-root.conf @@ -0,0 +1,3 @@ +location / { + try_files $uri $uri/ /?$query_string; +} diff --git a/docker/php-nginx-dev/alpine-php7/conf/etc/nginx/vhost.common.d/10-log.conf b/docker/php-nginx-dev/alpine-php7/conf/etc/nginx/vhost.common.d/10-log.conf new file mode 100644 index 000000000..a2cd929e7 --- /dev/null +++ b/docker/php-nginx-dev/alpine-php7/conf/etc/nginx/vhost.common.d/10-log.conf @@ -0,0 +1,2 @@ +access_log /docker.stdout; +error_log /docker.stderr info; diff --git a/docker/php-nginx-dev/alpine-php7/conf/etc/nginx/vhost.common.d/10-php.conf b/docker/php-nginx-dev/alpine-php7/conf/etc/nginx/vhost.common.d/10-php.conf new file mode 100644 index 000000000..274beac87 --- /dev/null +++ b/docker/php-nginx-dev/alpine-php7/conf/etc/nginx/vhost.common.d/10-php.conf @@ -0,0 +1,7 @@ +location ~ \.php$ { + fastcgi_split_path_info ^(.+\.php)(/.+)$; + fastcgi_pass php; + include fastcgi_params; + fastcgi_param SCRIPT_FILENAME $request_filename; + fastcgi_read_timeout 1000; +} diff --git a/docker/php-nginx-dev/alpine-php7/conf/etc/nginx/vhost.conf b/docker/php-nginx-dev/alpine-php7/conf/etc/nginx/vhost.conf new file mode 100644 index 000000000..8225f314a --- /dev/null +++ b/docker/php-nginx-dev/alpine-php7/conf/etc/nginx/vhost.conf @@ -0,0 +1,26 @@ +server { + listen 80 default_server; + + server_name _ docker; + + root ""; + index ; + + include /opt/docker/etc/nginx/vhost.common.d/*.conf; +} + +############## +# SSL +############## + +server { + listen 443 default_server; + + server_name _ docker; + + root ""; + index ; + + include /opt/docker/etc/nginx/vhost.common.d/*.conf; + include /opt/docker/etc/nginx/vhost.ssl.conf; +} diff --git a/docker/php-nginx-dev/alpine-php7/conf/etc/nginx/vhost.ssl.conf b/docker/php-nginx-dev/alpine-php7/conf/etc/nginx/vhost.ssl.conf new file mode 100644 index 000000000..4ddba251d --- /dev/null +++ b/docker/php-nginx-dev/alpine-php7/conf/etc/nginx/vhost.ssl.conf @@ -0,0 +1,7 @@ +ssl on; +ssl_protocols TLSv1 TLSv1.1 TLSv1.2; # not possible to do exclusive +ssl_ciphers 'EDH+CAMELLIA:EDH+aRSA:EECDH+aRSA+AESGCM:EECDH+aRSA+SHA384:EECDH+aRSA+SHA256:EECDH:+CAMELLIA256:+AES256:+CAMELLIA128:+AES128:+SSLv3:!aNULL:!eNULL:!LOW:!3DES:!MD5:!EXP:!PSK:!DSS:!RC4:!SEED:!ECDSA:CAMELLIA256-SHA:AES256-SHA:CAMELLIA128-SHA:AES128-SHA'; +ssl_prefer_server_ciphers on; + +ssl_certificate /opt/docker/etc/nginx/ssl/server.crt; +ssl_certificate_key /opt/docker/etc/nginx/ssl/server.key; diff --git a/docker/php-nginx-dev/alpine-php7/conf/etc/supervisor.d/blackfire-agent.conf b/docker/php-nginx-dev/alpine-php7/conf/etc/supervisor.d/blackfire-agent.conf new file mode 100644 index 000000000..897831ddb --- /dev/null +++ b/docker/php-nginx-dev/alpine-php7/conf/etc/supervisor.d/blackfire-agent.conf @@ -0,0 +1,14 @@ +[group:blackfire-agent] +programs=blackfire-agentd +priority=25 + +[program:blackfire-agentd] +command = /opt/docker/bin/service.d/blackfire-agent.sh +process_name=%(program_name)s +startsecs = 0 +autostart = false +autorestart = true +stdout_logfile=/dev/stdout +stdout_logfile_maxbytes=0 +stderr_logfile=/dev/stderr +stderr_logfile_maxbytes=0 diff --git a/docker/php-nginx-dev/alpine-php7/conf/etc/supervisor.d/nginx.conf b/docker/php-nginx-dev/alpine-php7/conf/etc/supervisor.d/nginx.conf new file mode 100644 index 000000000..657bf499b --- /dev/null +++ b/docker/php-nginx-dev/alpine-php7/conf/etc/supervisor.d/nginx.conf @@ -0,0 +1,14 @@ +[group:nginx] +programs=nginxd +priority=20 + +[program:nginxd] +command = /opt/docker/bin/service.d/nginx.sh +process_name=%(program_name)s +startsecs = 0 +autostart = true +autorestart = true +stdout_logfile=/dev/stdout +stdout_logfile_maxbytes=0 +stderr_logfile=/dev/stderr +stderr_logfile_maxbytes=0 diff --git a/docker/php-nginx-dev/alpine-php7/conf/provision/entrypoint.d/10-php-debugger.sh b/docker/php-nginx-dev/alpine-php7/conf/provision/entrypoint.d/10-php-debugger.sh new file mode 100644 index 000000000..b5985a9ef --- /dev/null +++ b/docker/php-nginx-dev/alpine-php7/conf/provision/entrypoint.d/10-php-debugger.sh @@ -0,0 +1,96 @@ +#!/usr/bin/env bash + +################################################# +# Debugger switch +################################################# + +PHP_CONF_PATHS=" +/etc/php5/conf.d +/etc/php7/conf.d +/etc/php.d +/etc/php5/mods-available +/etc/php5/cli/conf.d +/etc/php5/cli/conf.d +/etc/php5/fpm/conf.d +/etc/php5/fpm/conf.d +/etc/php/7.0/mods-available +/etc/php/7.0/cli/conf.d +/etc/php/7.0/fpm/conf.d +/usr/local/etc/php/conf.d/" + +function phpModuleRemove() { + if [ "$#" -ne 1 ]; then + echo "You must specify the name of the PHP module which you want to disable" + exit 1 + fi + + echo " - Removing PHP module ${1}" + for CONF_PATH in $PHP_CONF_PATHS; do + rm -f "${CONF_PATH}"/*"${1}".ini + done +} + + +if [[ -n "${PHP_DEBUGGER+x}" ]]; then + case "$PHP_DEBUGGER" in + xdebug) + echo "PHP-Debugger: Xdebug enabled" + phpModuleRemove "blackfire" + ;; + + blackfire) + echo "PHP-Debugger: Blackfire enabled" + phpModuleRemove "xdebug" + docker-service-enable blackfire-agent + ;; + + none) + echo "PHP-Debugger: none" + phpModuleRemove "blackfire" + phpModuleRemove "xdebug" + ;; + esac + +else + + echo "PHP-Debugger: not specified - default is xdebug" + phpModuleRemove "blackfire" + +fi + +################################################# +# PHP debugger environment variables +################################################# + +function phpEnvironmentVariable() { + PHP_INI_KEY="$1" + PHP_ENV_NAME="$2" + + if [[ -n "${!PHP_ENV_NAME+x}" ]]; then + PHP_ENV_VALUE="${!PHP_ENV_NAME}" + echo "${PHP_INI_KEY}=\"${PHP_ENV_VALUE}\"" >> /opt/docker/etc/php/php.ini + fi +} + +################### +# XDEBUG +################### + +# remote debugger +phpEnvironmentVariable "xdebug.remote_connect_back" "XDEBUG_REMOTE_CONNECT_BACK" +phpEnvironmentVariable "xdebug.remote_autostart" "XDEBUG_REMOTE_AUTOSTART" +phpEnvironmentVariable "xdebug.remote_host" "XDEBUG_REMOTE_HOST" +phpEnvironmentVariable "xdebug.remote_port" "XDEBUG_REMOTE_PORT" + +# profiler +phpEnvironmentVariable "xdebug.profiler_enable" "XDEBUG_PROFILER_ENABLE" +phpEnvironmentVariable "xdebug.profiler_enable_trigger" "XDEBUG_PROFILER_ENABLE_TRIGGER" +phpEnvironmentVariable "xdebug.profiler_enable_trigger_value" "XDEBUG_PROFILER_ENABLE_TRIGGER_VALUE" +phpEnvironmentVariable "xdebug.profiler_output_dir" "XDEBUG_PROFILER_OUTPUT_DIR" +phpEnvironmentVariable "xdebug.profiler_output_name" "XDEBUG_PROFILER_OUTPUT_NAME" + +################### +# BLACKFIRE +################### +phpEnvironmentVariable "blackfire.server_id" "BLACKFIRE_SERVER_ID" +phpEnvironmentVariable "blackfire.server_token" "BLACKFIRE_SERVER_TOKEN" diff --git a/docker/php-nginx-dev/alpine-php7/conf/provision/roles/webdevops-nginx-dev/defaults/main.yml b/docker/php-nginx-dev/alpine-php7/conf/provision/roles/webdevops-nginx-dev/defaults/main.yml new file mode 100644 index 000000000..81f5b7efd --- /dev/null +++ b/docker/php-nginx-dev/alpine-php7/conf/provision/roles/webdevops-nginx-dev/defaults/main.yml @@ -0,0 +1,6 @@ +--- + +APPLICATION_USER: "{{ lookup('env','APPLICATION_USER') }}" +APPLICATION_GROUP: "{{ lookup('env','APPLICATION_GROUP') }}" +APPLICATION_UID: "{{ lookup('env','APPLICATION_UID') }}" +APPLICATION_GID: "{{ lookup('env','APPLICATION_GID') }}" diff --git a/docker/php-nginx-dev/alpine-php7/conf/provision/roles/webdevops-nginx-dev/tasks/bootstrap.yml b/docker/php-nginx-dev/alpine-php7/conf/provision/roles/webdevops-nginx-dev/tasks/bootstrap.yml new file mode 100644 index 000000000..3e783736c --- /dev/null +++ b/docker/php-nginx-dev/alpine-php7/conf/provision/roles/webdevops-nginx-dev/tasks/bootstrap.yml @@ -0,0 +1,3 @@ +--- + +- include: bootstrap/nginx.yml diff --git a/docker/php-nginx-dev/alpine-php7/conf/provision/roles/webdevops-nginx-dev/tasks/bootstrap/nginx.yml b/docker/php-nginx-dev/alpine-php7/conf/provision/roles/webdevops-nginx-dev/tasks/bootstrap/nginx.yml new file mode 100644 index 000000000..8075b2d9d --- /dev/null +++ b/docker/php-nginx-dev/alpine-php7/conf/provision/roles/webdevops-nginx-dev/tasks/bootstrap/nginx.yml @@ -0,0 +1,9 @@ +--- + +- name: Disable sendfile for nginx + lineinfile: + dest: /etc/nginx/nginx.conf + regexp: '[\s;]*{{ item.key }}[\s]*' + line: '{{ item.key }} {{ item.value }};' + with_items: + - { key: 'sendfile', value: "off" } diff --git a/docker/php-nginx-dev/alpine-php7/conf/provision/roles/webdevops-nginx-dev/tasks/main.yml b/docker/php-nginx-dev/alpine-php7/conf/provision/roles/webdevops-nginx-dev/tasks/main.yml new file mode 100644 index 000000000..1806c1a8c --- /dev/null +++ b/docker/php-nginx-dev/alpine-php7/conf/provision/roles/webdevops-nginx-dev/tasks/main.yml @@ -0,0 +1,5 @@ +--- + +- include: bootstrap.yml + tags: + - bootstrap diff --git a/docker/php-nginx-dev/alpine-php7/conf/provision/roles/webdevops-nginx/defaults/main.yml b/docker/php-nginx-dev/alpine-php7/conf/provision/roles/webdevops-nginx/defaults/main.yml new file mode 100644 index 000000000..69cba1cb4 --- /dev/null +++ b/docker/php-nginx-dev/alpine-php7/conf/provision/roles/webdevops-nginx/defaults/main.yml @@ -0,0 +1,3 @@ +--- + +DOCUMENT_ROOT: "{{ lookup('env','WEB_DOCUMENT_ROOT') }}" diff --git a/docker/php-nginx-dev/alpine-php7/conf/provision/roles/webdevops-nginx/tasks/bootstrap.yml b/docker/php-nginx-dev/alpine-php7/conf/provision/roles/webdevops-nginx/tasks/bootstrap.yml new file mode 100644 index 000000000..7edb04ee4 --- /dev/null +++ b/docker/php-nginx-dev/alpine-php7/conf/provision/roles/webdevops-nginx/tasks/bootstrap.yml @@ -0,0 +1,86 @@ +--- + +- name: Diable nginx demonize mode + lineinfile: + dest: /etc/nginx/nginx.conf + regexp: '[\s;]*{{ item.key }}[\s]*' + line: '{{ item.key }} {{ item.value }};' + with_items: + - { key: 'daemon', value: "off" } + +- name: Set access_log to stdout + replace: + dest: /etc/nginx/nginx.conf + regexp: '^([ \t]*access_log)[ \t]*([^\t ;]+)(.*;)$' + replace: '\1 /docker.stdout \3' + +- name: Set access_log to stdout + replace: + dest: /etc/nginx/nginx.conf + regexp: '^([ \t]*error_log)[ \t]*([^\t ;]+)(.*;)$' + replace: '\1 /docker.stdout \3' + +- name: Enable nginx main config + file: + src: '/opt/docker/etc/nginx/main.conf' + dest: '/etc/nginx/conf.d/10-docker.conf' + state: link + force: yes + +- name: Remove default vhost + file: + path: "{{ item }}" + state: absent + with_items: + # Debian family + - "/etc/nginx/sites-enabled/default" + # Alpine + - "/etc/nginx/conf.d/default.conf" + + +- name: Replace default nginx.conf [RedHat/Alpine family] + file: + src: '/opt/docker/etc/nginx/nginx.conf' + dest: '/etc/nginx/nginx.conf' + state: link + force: yes + when: ansible_os_family == 'RedHat' or ansible_os_family == 'Alpine' + +- name: Ensure document root is available + file: + path: "{{ DOCUMENT_ROOT }}" + state: directory + recurse: yes + +- name: Remove old log directory + file: + path: "/var/lib/nginx/logs" + state: absent + +- name: Create log directory + file: + path: "/var/lib/nginx/logs" + state: directory + +- name: Create stdout symlinks + file: + dest: "{{ item }}" + src: "/docker.stdout" + state: link + force: yes + with_items: + - "/var/lib/nginx/logs/access.log" + - "/var/lib/nginx/logs/error.log" + +- name: Fix rights of ssl files + file: + path: "{{ item.path }}" + state: "{{ item.state }}" + mode: "{{ item.mode }}" + owner: "root" + group: "root" + with_items: + - { path: '/opt/docker/etc/nginx/ssl', state: 'directory', mode: '0750' } + - { path: '/opt/docker/etc/nginx/ssl/server.crt', state: 'file', mode: '0640' } + - { path: '/opt/docker/etc/nginx/ssl/server.csr', state: 'file', mode: '0640' } + - { path: '/opt/docker/etc/nginx/ssl/server.key', state: 'file', mode: '0640' } diff --git a/docker/php-nginx-dev/alpine-php7/conf/provision/roles/webdevops-nginx/tasks/main.yml b/docker/php-nginx-dev/alpine-php7/conf/provision/roles/webdevops-nginx/tasks/main.yml new file mode 100644 index 000000000..1806c1a8c --- /dev/null +++ b/docker/php-nginx-dev/alpine-php7/conf/provision/roles/webdevops-nginx/tasks/main.yml @@ -0,0 +1,5 @@ +--- + +- include: bootstrap.yml + tags: + - bootstrap diff --git a/docker/php-nginx-dev/alpine-php7/conf/provision/roles/webdevops-php-dev/defaults/main.yml b/docker/php-nginx-dev/alpine-php7/conf/provision/roles/webdevops-php-dev/defaults/main.yml new file mode 100644 index 000000000..81f5b7efd --- /dev/null +++ b/docker/php-nginx-dev/alpine-php7/conf/provision/roles/webdevops-php-dev/defaults/main.yml @@ -0,0 +1,6 @@ +--- + +APPLICATION_USER: "{{ lookup('env','APPLICATION_USER') }}" +APPLICATION_GROUP: "{{ lookup('env','APPLICATION_GROUP') }}" +APPLICATION_UID: "{{ lookup('env','APPLICATION_UID') }}" +APPLICATION_GID: "{{ lookup('env','APPLICATION_GID') }}" diff --git a/docker/php-nginx-dev/alpine-php7/conf/provision/roles/webdevops-php-dev/tasks/bootstrap.yml b/docker/php-nginx-dev/alpine-php7/conf/provision/roles/webdevops-php-dev/tasks/bootstrap.yml new file mode 100644 index 000000000..ff02b05fc --- /dev/null +++ b/docker/php-nginx-dev/alpine-php7/conf/provision/roles/webdevops-php-dev/tasks/bootstrap.yml @@ -0,0 +1,7 @@ +--- + +- include: bootstrap/php-fpm.yml +- include: bootstrap/php-module.yml +- include: bootstrap/php-module.opcache.yml +- include: bootstrap/php-module.xdebug.yml +- include: bootstrap/php-module.blackfire.yml diff --git a/docker/php-nginx-dev/alpine-php7/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/php-fpm.yml b/docker/php-nginx-dev/alpine-php7/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/php-fpm.yml new file mode 100644 index 000000000..9455a78e2 --- /dev/null +++ b/docker/php-nginx-dev/alpine-php7/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/php-fpm.yml @@ -0,0 +1,18 @@ +--- + +- name: Configure php-fpm pool user (application.conf) + lineinfile: + dest: '/opt/docker/etc/php/fpm/pool.d/application.conf' + regexp: '^[\s;]*{{ item.key }}[\s]*=' + line: '{{ item.key }} = {{ item.value }}' + with_items: + - { key: 'access.log', value: "/docker.stdout" } + - { key: "access.format", value: '"%R - %u %t \"%m %r%Q%q\" %s %f cpu:%C%% mem:%{megabytes}M reqTime:%d"' } + +- name: Open php-fpm for external connections (eg. debuggers) + lineinfile: + dest: '/opt/docker/etc/php/fpm/pool.d/application.conf' + regexp: '^[\s;]*{{ item.key }}[\s]*=' + line: '{{ item.key }} = {{ item.value }}' + with_items: + - { key: 'listen', value: "0.0.0.0:9000" } diff --git a/docker/php-nginx-dev/alpine-php7/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/php-module.blackfire.yml b/docker/php-nginx-dev/alpine-php7/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/php-module.blackfire.yml new file mode 100644 index 000000000..faf05f8de --- /dev/null +++ b/docker/php-nginx-dev/alpine-php7/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/php-module.blackfire.yml @@ -0,0 +1,10 @@ +--- + +- name: Remove superfluous blackfire configuration file + file: + path: '{{ item }}' + state: absent + with_items: + - /etc/php5/cli/conf.d/zz-blackfire.ini + - /etc/php5/fpm/conf.d/zz-blackfire.ini + when: ansible_distribution == 'Debian' and docker_image_info_distribution_version|int >= 7 diff --git a/docker/php-nginx-dev/alpine-php7/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/php-module.opcache.yml b/docker/php-nginx-dev/alpine-php7/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/php-module.opcache.yml new file mode 100644 index 000000000..9c243a671 --- /dev/null +++ b/docker/php-nginx-dev/alpine-php7/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/php-module.opcache.yml @@ -0,0 +1,14 @@ +--- + +- name: Setup php.ini for development environment + lineinfile: + dest: '/opt/docker/etc/php/php.webdevops.ini' + regexp: '^[\s;]*{{ item.variable }}[\s]*=' + line: '{{ item.variable }} = {{ item.value }}' + with_items: + - { variable: 'opcache.memory_consumption', value: '256' } + - { variable: 'opcache.validate_timestamps', value: '1' } + - { variable: 'opcache.revalidate_freq', value: '0' } + - { variable: 'opcache.interned_strings_buffer', value: '16' } + - { variable: 'opcache.max_accelerated_files', value: '7963' } + - { variable: 'opcache.fast_shutdown', value: '1' } diff --git a/docker/php-nginx-dev/alpine-php7/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/php-module.xdebug.yml b/docker/php-nginx-dev/alpine-php7/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/php-module.xdebug.yml new file mode 100644 index 000000000..7f20c845e --- /dev/null +++ b/docker/php-nginx-dev/alpine-php7/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/php-module.xdebug.yml @@ -0,0 +1,28 @@ +--- + +# Ignored on php7 +- name: Fix php xdebug module [Alpine family] + lineinfile: + dest: '{{ item }}' + regexp: 'extension=xdebug.so' + line: 'zend_extension=xdebug.so' + when: ansible_distribution == 'Alpine' + with_items: + - /etc/php5/conf.d/xdebug.ini + - /etc/php7/conf.d/xdebug.ini + ignore_errors: yes + +- name: Setup php.ini for development environment + lineinfile: + dest: '/opt/docker/etc/php/php.webdevops.ini' + regexp: '^[\s;]*{{ item.variable }}[\s]*=' + line: '{{ item.variable }} = {{ item.value }}' + with_items: + - { variable: 'xdebug.remote_enable', value: '1' } + - { variable: 'xdebug.remote_connect_back', value: '1' } + - { variable: 'xdebug.idekey', value: 'docker' } + - { variable: 'xdebug.cli_color', value: '1' } + - { variable: 'xdebug.max_nesting_level', value: '1000' } + - { variable: 'xdebug.profiler_enable_trigger', value: '1000' } + - { variable: 'xdebug.profiler_output_dir', value: '/tmp/debug/' } + - { variable: 'xhprof.output_dir', value: '/tmp/debug/' } diff --git a/docker/php-nginx-dev/alpine-php7/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/php-module.yml b/docker/php-nginx-dev/alpine-php7/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/php-module.yml new file mode 100644 index 000000000..31cccd1ae --- /dev/null +++ b/docker/php-nginx-dev/alpine-php7/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/php-module.yml @@ -0,0 +1,41 @@ +--- + +############################# +# Workaround PHP configuration files +# for alpine +############################# + +- name: Get list of PHP5 configuration files + command: "ls /etc/php5/conf.d/ |grep .ini" + register: php5_ini + when: ansible_distribution == 'Alpine' + ignore_errors: yes + +- name: Link configuration files from php5 to php + file: + src: '/etc/php5/conf.d/{{ item }}' + dest: '/etc/php/conf.d/{{ item }}' + state: link + with_items: "{{ php5_ini.stdout_lines }}" + when: ansible_distribution == 'Alpine' and php5_ini is defined + ignore_errors: yes + +############################# +# Workaround PHP module files +# for alpine +############################# + +- name: Get list of PHP5 modules + command: "ls /usr/lib/php5/modules/ |grep .so" + register: php5_modules + when: ansible_distribution == 'Alpine' + ignore_errors: yes + +- name: Link module files from php5 to php + file: + src: '/usr/lib/php5/modules/{{ item }}' + dest: '/usr/lib/php/modules/{{ item }}' + state: link + with_items: "{{ php5_modules.stdout_lines }}" + when: ansible_distribution == 'Alpine' and php5_modules is defined + ignore_errors: yes diff --git a/docker/php-nginx-dev/alpine-php7/conf/provision/roles/webdevops-php-dev/tasks/main.yml b/docker/php-nginx-dev/alpine-php7/conf/provision/roles/webdevops-php-dev/tasks/main.yml new file mode 100644 index 000000000..1806c1a8c --- /dev/null +++ b/docker/php-nginx-dev/alpine-php7/conf/provision/roles/webdevops-php-dev/tasks/main.yml @@ -0,0 +1,5 @@ +--- + +- include: bootstrap.yml + tags: + - bootstrap diff --git a/docker/php-nginx-dev/alpine-php7/conf/provision/roles/webdevops-php-nginx/defaults/main.yml b/docker/php-nginx-dev/alpine-php7/conf/provision/roles/webdevops-php-nginx/defaults/main.yml new file mode 100644 index 000000000..ed97d539c --- /dev/null +++ b/docker/php-nginx-dev/alpine-php7/conf/provision/roles/webdevops-php-nginx/defaults/main.yml @@ -0,0 +1 @@ +--- diff --git a/docker/php-nginx-dev/alpine-php7/conf/provision/roles/webdevops-php-nginx/tasks/bootstrap.yml b/docker/php-nginx-dev/alpine-php7/conf/provision/roles/webdevops-php-nginx/tasks/bootstrap.yml new file mode 100644 index 000000000..a2866e0d0 --- /dev/null +++ b/docker/php-nginx-dev/alpine-php7/conf/provision/roles/webdevops-php-nginx/tasks/bootstrap.yml @@ -0,0 +1,9 @@ +--- + +- name: Restrict php-fpm to local connection + lineinfile: + dest: '/opt/docker/etc/php/fpm/pool.d/application.conf' + regexp: '^[\s;]*{{ item.key }}[\s]*=' + line: '{{ item.key }} = {{ item.value }}' + with_items: + - { key: 'listen', value: "127.0.0.1:9000" } diff --git a/docker/php-nginx-dev/alpine-php7/conf/provision/roles/webdevops-php-nginx/tasks/entrypoint.yml b/docker/php-nginx-dev/alpine-php7/conf/provision/roles/webdevops-php-nginx/tasks/entrypoint.yml new file mode 100644 index 000000000..cd21505a4 --- /dev/null +++ b/docker/php-nginx-dev/alpine-php7/conf/provision/roles/webdevops-php-nginx/tasks/entrypoint.yml @@ -0,0 +1,2 @@ +--- + diff --git a/docker/php-nginx-dev/alpine-php7/conf/provision/roles/webdevops-php-nginx/tasks/main.yml b/docker/php-nginx-dev/alpine-php7/conf/provision/roles/webdevops-php-nginx/tasks/main.yml new file mode 100644 index 000000000..7895a52a9 --- /dev/null +++ b/docker/php-nginx-dev/alpine-php7/conf/provision/roles/webdevops-php-nginx/tasks/main.yml @@ -0,0 +1,9 @@ +--- + +- include: bootstrap.yml + tags: + - bootstrap + +- include: entrypoint.yml + tags: + - entrypoint diff --git a/docker/php-nginx-dev/centos-7-php56/Dockerfile b/docker/php-nginx-dev/centos-7-php56/Dockerfile index a7daf26f2..c37513757 100644 --- a/docker/php-nginx-dev/centos-7-php56/Dockerfile +++ b/docker/php-nginx-dev/centos-7-php56/Dockerfile @@ -5,16 +5,11 @@ FROM webdevops/php-dev:centos-7-php56 -MAINTAINER info@webdevops.io -LABEL vendor=WebDevOps.io -LABEL io.webdevops.layout=8 -LABEL io.webdevops.version=1.5.0 - -ENV WEB_DOCUMENT_ROOT /app -ENV WEB_DOCUMENT_INDEX index.php -ENV WEB_ALIAS_DOMAIN *.vm -ENV WEB_PHP_SOCKET 127.0.0.1:9000 -ENV WEB_NO_CACHE_PATTERN "\.(css|js|gif|png|jpg|svg|json|xml)$" +ENV WEB_DOCUMENT_ROOT=/app \ + WEB_DOCUMENT_INDEX=index.php \ + WEB_ALIAS_DOMAIN=*.vm +ENV WEB_PHP_SOCKET=127.0.0.1:9000 +ENV WEB_NO_CACHE_PATTERN="\.(css|js|gif|png|jpg|svg|json|xml)$" COPY conf/ /opt/docker/ @@ -22,7 +17,7 @@ COPY conf/ /opt/docker/ RUN /usr/local/bin/yum-install \ nginx \ && /opt/docker/bin/provision run --tag bootstrap --role webdevops-nginx --role webdevops-php-nginx --role webdevops-nginx-dev --role webdevops-php-dev \ - && /opt/docker/bin/bootstrap.sh - + && /opt/docker/bin/bootstrap.sh \ + && docker-image-cleanup EXPOSE 80 443 diff --git a/docker/php-nginx-dev/centos-7-php56/Dockerfile.jinja2 b/docker/php-nginx-dev/centos-7-php56/Dockerfile.jinja2 index 690ea2869..028a39575 100644 --- a/docker/php-nginx-dev/centos-7-php56/Dockerfile.jinja2 +++ b/docker/php-nginx-dev/centos-7-php56/Dockerfile.jinja2 @@ -1,7 +1,5 @@ {{ docker.from("php-dev", "centos-7-php56") }} -{{ docker.version() }} - {{ environment.web() }} {{ environment.webPhp() }} {{ environment.webDevelopment() }} diff --git a/docker/php-nginx-dev/centos-7-php56/conf/bin/service.d/nginx.d/10-init.sh b/docker/php-nginx-dev/centos-7-php56/conf/bin/service.d/nginx.d/10-init.sh index 75a84a4eb..27b9776cc 100644 --- a/docker/php-nginx-dev/centos-7-php56/conf/bin/service.d/nginx.d/10-init.sh +++ b/docker/php-nginx-dev/centos-7-php56/conf/bin/service.d/nginx.d/10-init.sh @@ -8,15 +8,17 @@ fi ln -f -s /var/lib/nginx/logs /var/log/nginx # Replace markers -find /opt/docker/etc/nginx/ -iname '*.conf' -print0 | xargs -0 -r rpl --quiet "" "$WEB_DOCUMENT_INDEX" > /dev/null -find /opt/docker/etc/nginx/ -iname '*.conf' -print0 | xargs -0 -r rpl --quiet "" "$WEB_DOCUMENT_ROOT" > /dev/null -find /opt/docker/etc/nginx/ -iname '*.conf' -print0 | xargs -0 -r rpl --quiet "" "$WEB_ALIAS_DOMAIN" > /dev/null -find /opt/docker/etc/nginx/ -iname '*.conf' -print0 | xargs -0 -r rpl --quiet "" "$HOSTNAME" > /dev/null +go-replace \ + -s "" -r "$WEB_DOCUMENT_INDEX" \ + -s "" -r "$WEB_DOCUMENT_ROOT" \ + -s "" -r "$WEB_ALIAS_DOMAIN" \ + -s "" -r "$HOSTNAME" \ + -s "" -r "$WEB_PHP_SOCKET" \ + --path=/opt/docker/etc/nginx/ \ + --path-pattern='*.conf' \ + --ignore-empty -if [[ -n "${WEB_PHP_SOCKET+x}" ]]; then - ## WEB_PHP_SOCKET is set - find /opt/docker/etc/nginx/ -iname '*.conf' -print0 | xargs -0 -r rpl --quiet "" "$WEB_PHP_SOCKET" > /dev/null -else +if [[ -z "${WEB_PHP_SOCKET+x}" ]]; then ## WEB_PHP_SOCKET is not set, remove PHP files rm -f -- /opt/docker/etc/nginx/conf.d/10-php.conf rm -f -- /opt/docker/etc/nginx/vhost.common.d/10-php.conf diff --git a/docker/php-nginx-dev/centos-7-php56/conf/bin/service.d/nginx.d/12-development.sh b/docker/php-nginx-dev/centos-7-php56/conf/bin/service.d/nginx.d/12-development.sh index fa4b601a9..f4695f059 100644 --- a/docker/php-nginx-dev/centos-7-php56/conf/bin/service.d/nginx.d/12-development.sh +++ b/docker/php-nginx-dev/centos-7-php56/conf/bin/service.d/nginx.d/12-development.sh @@ -1 +1,7 @@ -find /opt/docker/etc/nginx/ -iname '*.conf' -print0 | xargs -0 -r rpl --quiet "" "$WEB_NO_CACHE_PATTERN" > /dev/null +go-replace \ + -s "" \ + -r "$WEB_NO_CACHE_PATTERN" \ + --path=/opt/docker/etc/nginx/ \ + --path-pattern='*.conf' \ + --ignore-empty + diff --git a/docker/php-nginx-dev/centos-7-php56/conf/etc/nginx/vhost.common.d/10-general.conf b/docker/php-nginx-dev/centos-7-php56/conf/etc/nginx/vhost.common.d/10-general.conf new file mode 100644 index 000000000..d3fd0aa5e --- /dev/null +++ b/docker/php-nginx-dev/centos-7-php56/conf/etc/nginx/vhost.common.d/10-general.conf @@ -0,0 +1 @@ +client_max_body_size 50m; diff --git a/docker/php-nginx-dev/centos-7-php56/conf/etc/nginx/vhost.common.d/10-log.conf b/docker/php-nginx-dev/centos-7-php56/conf/etc/nginx/vhost.common.d/10-log.conf new file mode 100644 index 000000000..a2cd929e7 --- /dev/null +++ b/docker/php-nginx-dev/centos-7-php56/conf/etc/nginx/vhost.common.d/10-log.conf @@ -0,0 +1,2 @@ +access_log /docker.stdout; +error_log /docker.stderr info; diff --git a/docker/php-nginx-dev/centos-7-php56/conf/etc/nginx/vhost.conf b/docker/php-nginx-dev/centos-7-php56/conf/etc/nginx/vhost.conf index d07e27094..8225f314a 100644 --- a/docker/php-nginx-dev/centos-7-php56/conf/etc/nginx/vhost.conf +++ b/docker/php-nginx-dev/centos-7-php56/conf/etc/nginx/vhost.conf @@ -1,17 +1,11 @@ server { - listen 80 default_server; - listen 8000 default_server; + listen 80 default_server; server_name _ docker; - access_log /docker.stdout; - error_log /docker.stdout info; - root ""; index ; - client_max_body_size 50m; - include /opt/docker/etc/nginx/vhost.common.d/*.conf; } @@ -20,19 +14,13 @@ server { ############## server { - listen 443 default_server; - listen 8443 default_server; + listen 443 default_server; server_name _ docker; - access_log /docker.stdout; - error_log /docker.stdout info; - root ""; index ; - client_max_body_size 50m; - include /opt/docker/etc/nginx/vhost.common.d/*.conf; include /opt/docker/etc/nginx/vhost.ssl.conf; } diff --git a/docker/php-nginx-dev/centos-7-php56/conf/provision/entrypoint.d/10-php-debugger.sh b/docker/php-nginx-dev/centos-7-php56/conf/provision/entrypoint.d/10-php-debugger.sh index 7156e28aa..b5985a9ef 100644 --- a/docker/php-nginx-dev/centos-7-php56/conf/provision/entrypoint.d/10-php-debugger.sh +++ b/docker/php-nginx-dev/centos-7-php56/conf/provision/entrypoint.d/10-php-debugger.sh @@ -15,7 +15,8 @@ PHP_CONF_PATHS=" /etc/php5/fpm/conf.d /etc/php/7.0/mods-available /etc/php/7.0/cli/conf.d -/etc/php/7.0/fpm/conf.d" +/etc/php/7.0/fpm/conf.d +/usr/local/etc/php/conf.d/" function phpModuleRemove() { if [ "$#" -ne 1 ]; then @@ -40,7 +41,7 @@ if [[ -n "${PHP_DEBUGGER+x}" ]]; then blackfire) echo "PHP-Debugger: Blackfire enabled" phpModuleRemove "xdebug" - /opt/docker/bin/control.sh service.enable blackfire-agent + docker-service-enable blackfire-agent ;; none) diff --git a/docker/php-nginx-dev/centos-7-php56/conf/provision/roles/webdevops-php-dev/tasks/bootstrap.yml b/docker/php-nginx-dev/centos-7-php56/conf/provision/roles/webdevops-php-dev/tasks/bootstrap.yml index 2c5d76e3d..ff02b05fc 100644 --- a/docker/php-nginx-dev/centos-7-php56/conf/provision/roles/webdevops-php-dev/tasks/bootstrap.yml +++ b/docker/php-nginx-dev/centos-7-php56/conf/provision/roles/webdevops-php-dev/tasks/bootstrap.yml @@ -1,6 +1,5 @@ --- -- include: bootstrap/tools.yml - include: bootstrap/php-fpm.yml - include: bootstrap/php-module.yml - include: bootstrap/php-module.opcache.yml diff --git a/docker/php-nginx-dev/centos-7-php56/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/php-module.blackfire.yml b/docker/php-nginx-dev/centos-7-php56/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/php-module.blackfire.yml index 1a3db9bac..faf05f8de 100644 --- a/docker/php-nginx-dev/centos-7-php56/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/php-module.blackfire.yml +++ b/docker/php-nginx-dev/centos-7-php56/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/php-module.blackfire.yml @@ -7,4 +7,4 @@ with_items: - /etc/php5/cli/conf.d/zz-blackfire.ini - /etc/php5/fpm/conf.d/zz-blackfire.ini - when: ansible_distribution == 'Debian' and ansible_lsb.major_release|int >= 7 + when: ansible_distribution == 'Debian' and docker_image_info_distribution_version|int >= 7 diff --git a/docker/php-nginx-dev/centos-7-php56/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/tools.yml b/docker/php-nginx-dev/centos-7-php56/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/tools.yml deleted file mode 100644 index c49cb0e34..000000000 --- a/docker/php-nginx-dev/centos-7-php56/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/tools.yml +++ /dev/null @@ -1,23 +0,0 @@ ---- - -- name: Downloading Tools - shell: curl -o "{{ item.dest }}" "{{ item.url }}" && chmod 755 "{{ item.dest }}" - with_items: - - { url: "https://phar.phpunit.de/phploc.phar", dest: /usr/local/bin/phploc } - - { url: "https://phar.phpunit.de/phpunit.phar", dest: /usr/local/bin/phpunit } - - { url: "http://static.pdepend.org/php/latest/pdepend.phar", dest: /usr/local/bin/pdepend } - - { url: "http://static.phpmd.org/php/latest/phpmd.phar", dest: /usr/local/bin/phpmd } - - { url: "https://squizlabs.github.io/PHP_CodeSniffer/phpcs.phar", dest: /usr/local/bin/phpcs } - - { url: "https://squizlabs.github.io/PHP_CodeSniffer/phpcbf.phar", dest: /usr/local/bin/phpcbf } - - { url: "https://phar.phpunit.de/phpcpd.phar", dest: /usr/local/bin/phpcpd } - - { url: "https://phar.phpunit.de/phpdcd.phar", dest: /usr/local/bin/phpdcd } - - { url: "https://github.com/Halleck45/PhpMetrics/raw/master/build/phpmetrics.phar", dest: /usr/local/bin/phpmetrics } - - { url: "http://get.sensiolabs.org/php-cs-fixer.phar", dest: /usr/local/bin/php-cs-fixer } - - { url: "https://github.com/sensiolabs-de/deprecation-detector/releases/download/0.1.0-alpha4/deprecation-detector.phar", dest: /usr/local/bin/deprecation-detector } - - { url: "https://github.com/sensiolabs-de/deprecation-detector/releases/download/0.1.0-alpha4/deprecation-detector.phar", dest: /usr/local/bin/deprecation-detector } - -- name: Install Tools via composer - raw: COMPOSER_HOME="/usr/local/composer" COMPOSER_BIN_DIR="/usr/local/bin" composer global require "{{ item.package }}" "{{ item.version }}" - with_items: - - { package: "sstalle/php7cc" , version: "*" } - - { package: "phpspec/phpspec" , version: "~2.0" } diff --git a/docker/php-nginx-dev/centos-7-php7/Dockerfile b/docker/php-nginx-dev/centos-7-php7/Dockerfile index e8fe8d959..0f3f94e2a 100644 --- a/docker/php-nginx-dev/centos-7-php7/Dockerfile +++ b/docker/php-nginx-dev/centos-7-php7/Dockerfile @@ -5,16 +5,11 @@ FROM webdevops/php-dev:centos-7-php7 -MAINTAINER info@webdevops.io -LABEL vendor=WebDevOps.io -LABEL io.webdevops.layout=8 -LABEL io.webdevops.version=1.5.0 - -ENV WEB_DOCUMENT_ROOT /app -ENV WEB_DOCUMENT_INDEX index.php -ENV WEB_ALIAS_DOMAIN *.vm -ENV WEB_PHP_SOCKET 127.0.0.1:9000 -ENV WEB_NO_CACHE_PATTERN "\.(css|js|gif|png|jpg|svg|json|xml)$" +ENV WEB_DOCUMENT_ROOT=/app \ + WEB_DOCUMENT_INDEX=index.php \ + WEB_ALIAS_DOMAIN=*.vm +ENV WEB_PHP_SOCKET=127.0.0.1:9000 +ENV WEB_NO_CACHE_PATTERN="\.(css|js|gif|png|jpg|svg|json|xml)$" COPY conf/ /opt/docker/ @@ -22,7 +17,7 @@ COPY conf/ /opt/docker/ RUN /usr/local/bin/yum-install \ nginx \ && /opt/docker/bin/provision run --tag bootstrap --role webdevops-nginx --role webdevops-php-nginx --role webdevops-nginx-dev --role webdevops-php-dev \ - && /opt/docker/bin/bootstrap.sh - + && /opt/docker/bin/bootstrap.sh \ + && docker-image-cleanup EXPOSE 80 443 diff --git a/docker/php-nginx-dev/centos-7-php7/Dockerfile.jinja2 b/docker/php-nginx-dev/centos-7-php7/Dockerfile.jinja2 index 9c9e1bc46..c20b51c83 100644 --- a/docker/php-nginx-dev/centos-7-php7/Dockerfile.jinja2 +++ b/docker/php-nginx-dev/centos-7-php7/Dockerfile.jinja2 @@ -1,7 +1,5 @@ {{ docker.from("php-dev", "centos-7-php7") }} -{{ docker.version() }} - {{ environment.web() }} {{ environment.webPhp() }} {{ environment.webDevelopment() }} diff --git a/docker/php-nginx-dev/centos-7-php7/conf/bin/service.d/nginx.d/10-init.sh b/docker/php-nginx-dev/centos-7-php7/conf/bin/service.d/nginx.d/10-init.sh index 75a84a4eb..27b9776cc 100644 --- a/docker/php-nginx-dev/centos-7-php7/conf/bin/service.d/nginx.d/10-init.sh +++ b/docker/php-nginx-dev/centos-7-php7/conf/bin/service.d/nginx.d/10-init.sh @@ -8,15 +8,17 @@ fi ln -f -s /var/lib/nginx/logs /var/log/nginx # Replace markers -find /opt/docker/etc/nginx/ -iname '*.conf' -print0 | xargs -0 -r rpl --quiet "" "$WEB_DOCUMENT_INDEX" > /dev/null -find /opt/docker/etc/nginx/ -iname '*.conf' -print0 | xargs -0 -r rpl --quiet "" "$WEB_DOCUMENT_ROOT" > /dev/null -find /opt/docker/etc/nginx/ -iname '*.conf' -print0 | xargs -0 -r rpl --quiet "" "$WEB_ALIAS_DOMAIN" > /dev/null -find /opt/docker/etc/nginx/ -iname '*.conf' -print0 | xargs -0 -r rpl --quiet "" "$HOSTNAME" > /dev/null +go-replace \ + -s "" -r "$WEB_DOCUMENT_INDEX" \ + -s "" -r "$WEB_DOCUMENT_ROOT" \ + -s "" -r "$WEB_ALIAS_DOMAIN" \ + -s "" -r "$HOSTNAME" \ + -s "" -r "$WEB_PHP_SOCKET" \ + --path=/opt/docker/etc/nginx/ \ + --path-pattern='*.conf' \ + --ignore-empty -if [[ -n "${WEB_PHP_SOCKET+x}" ]]; then - ## WEB_PHP_SOCKET is set - find /opt/docker/etc/nginx/ -iname '*.conf' -print0 | xargs -0 -r rpl --quiet "" "$WEB_PHP_SOCKET" > /dev/null -else +if [[ -z "${WEB_PHP_SOCKET+x}" ]]; then ## WEB_PHP_SOCKET is not set, remove PHP files rm -f -- /opt/docker/etc/nginx/conf.d/10-php.conf rm -f -- /opt/docker/etc/nginx/vhost.common.d/10-php.conf diff --git a/docker/php-nginx-dev/centos-7-php7/conf/bin/service.d/nginx.d/12-development.sh b/docker/php-nginx-dev/centos-7-php7/conf/bin/service.d/nginx.d/12-development.sh index fa4b601a9..f4695f059 100644 --- a/docker/php-nginx-dev/centos-7-php7/conf/bin/service.d/nginx.d/12-development.sh +++ b/docker/php-nginx-dev/centos-7-php7/conf/bin/service.d/nginx.d/12-development.sh @@ -1 +1,7 @@ -find /opt/docker/etc/nginx/ -iname '*.conf' -print0 | xargs -0 -r rpl --quiet "" "$WEB_NO_CACHE_PATTERN" > /dev/null +go-replace \ + -s "" \ + -r "$WEB_NO_CACHE_PATTERN" \ + --path=/opt/docker/etc/nginx/ \ + --path-pattern='*.conf' \ + --ignore-empty + diff --git a/docker/php-nginx-dev/centos-7-php7/conf/etc/nginx/vhost.common.d/10-general.conf b/docker/php-nginx-dev/centos-7-php7/conf/etc/nginx/vhost.common.d/10-general.conf new file mode 100644 index 000000000..d3fd0aa5e --- /dev/null +++ b/docker/php-nginx-dev/centos-7-php7/conf/etc/nginx/vhost.common.d/10-general.conf @@ -0,0 +1 @@ +client_max_body_size 50m; diff --git a/docker/php-nginx-dev/centos-7-php7/conf/etc/nginx/vhost.common.d/10-log.conf b/docker/php-nginx-dev/centos-7-php7/conf/etc/nginx/vhost.common.d/10-log.conf new file mode 100644 index 000000000..a2cd929e7 --- /dev/null +++ b/docker/php-nginx-dev/centos-7-php7/conf/etc/nginx/vhost.common.d/10-log.conf @@ -0,0 +1,2 @@ +access_log /docker.stdout; +error_log /docker.stderr info; diff --git a/docker/php-nginx-dev/centos-7-php7/conf/etc/nginx/vhost.conf b/docker/php-nginx-dev/centos-7-php7/conf/etc/nginx/vhost.conf index d07e27094..8225f314a 100644 --- a/docker/php-nginx-dev/centos-7-php7/conf/etc/nginx/vhost.conf +++ b/docker/php-nginx-dev/centos-7-php7/conf/etc/nginx/vhost.conf @@ -1,17 +1,11 @@ server { - listen 80 default_server; - listen 8000 default_server; + listen 80 default_server; server_name _ docker; - access_log /docker.stdout; - error_log /docker.stdout info; - root ""; index ; - client_max_body_size 50m; - include /opt/docker/etc/nginx/vhost.common.d/*.conf; } @@ -20,19 +14,13 @@ server { ############## server { - listen 443 default_server; - listen 8443 default_server; + listen 443 default_server; server_name _ docker; - access_log /docker.stdout; - error_log /docker.stdout info; - root ""; index ; - client_max_body_size 50m; - include /opt/docker/etc/nginx/vhost.common.d/*.conf; include /opt/docker/etc/nginx/vhost.ssl.conf; } diff --git a/docker/php-nginx-dev/centos-7-php7/conf/provision/entrypoint.d/10-php-debugger.sh b/docker/php-nginx-dev/centos-7-php7/conf/provision/entrypoint.d/10-php-debugger.sh index 7156e28aa..b5985a9ef 100644 --- a/docker/php-nginx-dev/centos-7-php7/conf/provision/entrypoint.d/10-php-debugger.sh +++ b/docker/php-nginx-dev/centos-7-php7/conf/provision/entrypoint.d/10-php-debugger.sh @@ -15,7 +15,8 @@ PHP_CONF_PATHS=" /etc/php5/fpm/conf.d /etc/php/7.0/mods-available /etc/php/7.0/cli/conf.d -/etc/php/7.0/fpm/conf.d" +/etc/php/7.0/fpm/conf.d +/usr/local/etc/php/conf.d/" function phpModuleRemove() { if [ "$#" -ne 1 ]; then @@ -40,7 +41,7 @@ if [[ -n "${PHP_DEBUGGER+x}" ]]; then blackfire) echo "PHP-Debugger: Blackfire enabled" phpModuleRemove "xdebug" - /opt/docker/bin/control.sh service.enable blackfire-agent + docker-service-enable blackfire-agent ;; none) diff --git a/docker/php-nginx-dev/centos-7-php7/conf/provision/roles/webdevops-php-dev/tasks/bootstrap.yml b/docker/php-nginx-dev/centos-7-php7/conf/provision/roles/webdevops-php-dev/tasks/bootstrap.yml index 2c5d76e3d..ff02b05fc 100644 --- a/docker/php-nginx-dev/centos-7-php7/conf/provision/roles/webdevops-php-dev/tasks/bootstrap.yml +++ b/docker/php-nginx-dev/centos-7-php7/conf/provision/roles/webdevops-php-dev/tasks/bootstrap.yml @@ -1,6 +1,5 @@ --- -- include: bootstrap/tools.yml - include: bootstrap/php-fpm.yml - include: bootstrap/php-module.yml - include: bootstrap/php-module.opcache.yml diff --git a/docker/php-nginx-dev/centos-7-php7/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/php-module.blackfire.yml b/docker/php-nginx-dev/centos-7-php7/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/php-module.blackfire.yml index 1a3db9bac..faf05f8de 100644 --- a/docker/php-nginx-dev/centos-7-php7/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/php-module.blackfire.yml +++ b/docker/php-nginx-dev/centos-7-php7/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/php-module.blackfire.yml @@ -7,4 +7,4 @@ with_items: - /etc/php5/cli/conf.d/zz-blackfire.ini - /etc/php5/fpm/conf.d/zz-blackfire.ini - when: ansible_distribution == 'Debian' and ansible_lsb.major_release|int >= 7 + when: ansible_distribution == 'Debian' and docker_image_info_distribution_version|int >= 7 diff --git a/docker/php-nginx-dev/centos-7-php7/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/tools.yml b/docker/php-nginx-dev/centos-7-php7/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/tools.yml deleted file mode 100644 index c49cb0e34..000000000 --- a/docker/php-nginx-dev/centos-7-php7/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/tools.yml +++ /dev/null @@ -1,23 +0,0 @@ ---- - -- name: Downloading Tools - shell: curl -o "{{ item.dest }}" "{{ item.url }}" && chmod 755 "{{ item.dest }}" - with_items: - - { url: "https://phar.phpunit.de/phploc.phar", dest: /usr/local/bin/phploc } - - { url: "https://phar.phpunit.de/phpunit.phar", dest: /usr/local/bin/phpunit } - - { url: "http://static.pdepend.org/php/latest/pdepend.phar", dest: /usr/local/bin/pdepend } - - { url: "http://static.phpmd.org/php/latest/phpmd.phar", dest: /usr/local/bin/phpmd } - - { url: "https://squizlabs.github.io/PHP_CodeSniffer/phpcs.phar", dest: /usr/local/bin/phpcs } - - { url: "https://squizlabs.github.io/PHP_CodeSniffer/phpcbf.phar", dest: /usr/local/bin/phpcbf } - - { url: "https://phar.phpunit.de/phpcpd.phar", dest: /usr/local/bin/phpcpd } - - { url: "https://phar.phpunit.de/phpdcd.phar", dest: /usr/local/bin/phpdcd } - - { url: "https://github.com/Halleck45/PhpMetrics/raw/master/build/phpmetrics.phar", dest: /usr/local/bin/phpmetrics } - - { url: "http://get.sensiolabs.org/php-cs-fixer.phar", dest: /usr/local/bin/php-cs-fixer } - - { url: "https://github.com/sensiolabs-de/deprecation-detector/releases/download/0.1.0-alpha4/deprecation-detector.phar", dest: /usr/local/bin/deprecation-detector } - - { url: "https://github.com/sensiolabs-de/deprecation-detector/releases/download/0.1.0-alpha4/deprecation-detector.phar", dest: /usr/local/bin/deprecation-detector } - -- name: Install Tools via composer - raw: COMPOSER_HOME="/usr/local/composer" COMPOSER_BIN_DIR="/usr/local/bin" composer global require "{{ item.package }}" "{{ item.version }}" - with_items: - - { package: "sstalle/php7cc" , version: "*" } - - { package: "phpspec/phpspec" , version: "~2.0" } diff --git a/docker/php-nginx-dev/centos-7/Dockerfile b/docker/php-nginx-dev/centos-7/Dockerfile index 314777eba..61d9f64e5 100644 --- a/docker/php-nginx-dev/centos-7/Dockerfile +++ b/docker/php-nginx-dev/centos-7/Dockerfile @@ -5,16 +5,11 @@ FROM webdevops/php-dev:centos-7 -MAINTAINER info@webdevops.io -LABEL vendor=WebDevOps.io -LABEL io.webdevops.layout=8 -LABEL io.webdevops.version=1.5.0 - -ENV WEB_DOCUMENT_ROOT /app -ENV WEB_DOCUMENT_INDEX index.php -ENV WEB_ALIAS_DOMAIN *.vm -ENV WEB_PHP_SOCKET 127.0.0.1:9000 -ENV WEB_NO_CACHE_PATTERN "\.(css|js|gif|png|jpg|svg|json|xml)$" +ENV WEB_DOCUMENT_ROOT=/app \ + WEB_DOCUMENT_INDEX=index.php \ + WEB_ALIAS_DOMAIN=*.vm +ENV WEB_PHP_SOCKET=127.0.0.1:9000 +ENV WEB_NO_CACHE_PATTERN="\.(css|js|gif|png|jpg|svg|json|xml)$" COPY conf/ /opt/docker/ @@ -22,7 +17,7 @@ COPY conf/ /opt/docker/ RUN /usr/local/bin/yum-install \ nginx \ && /opt/docker/bin/provision run --tag bootstrap --role webdevops-nginx --role webdevops-php-nginx --role webdevops-nginx-dev --role webdevops-php-dev \ - && /opt/docker/bin/bootstrap.sh - + && /opt/docker/bin/bootstrap.sh \ + && docker-image-cleanup EXPOSE 80 443 diff --git a/docker/php-nginx-dev/centos-7/Dockerfile.jinja2 b/docker/php-nginx-dev/centos-7/Dockerfile.jinja2 index d973b6b9b..5b6dbabb0 100644 --- a/docker/php-nginx-dev/centos-7/Dockerfile.jinja2 +++ b/docker/php-nginx-dev/centos-7/Dockerfile.jinja2 @@ -1,7 +1,5 @@ {{ docker.from("php-dev", "centos-7") }} -{{ docker.version() }} - {{ environment.web() }} {{ environment.webPhp() }} {{ environment.webDevelopment() }} diff --git a/docker/php-nginx-dev/centos-7/conf/bin/service.d/nginx.d/10-init.sh b/docker/php-nginx-dev/centos-7/conf/bin/service.d/nginx.d/10-init.sh index 75a84a4eb..27b9776cc 100644 --- a/docker/php-nginx-dev/centos-7/conf/bin/service.d/nginx.d/10-init.sh +++ b/docker/php-nginx-dev/centos-7/conf/bin/service.d/nginx.d/10-init.sh @@ -8,15 +8,17 @@ fi ln -f -s /var/lib/nginx/logs /var/log/nginx # Replace markers -find /opt/docker/etc/nginx/ -iname '*.conf' -print0 | xargs -0 -r rpl --quiet "" "$WEB_DOCUMENT_INDEX" > /dev/null -find /opt/docker/etc/nginx/ -iname '*.conf' -print0 | xargs -0 -r rpl --quiet "" "$WEB_DOCUMENT_ROOT" > /dev/null -find /opt/docker/etc/nginx/ -iname '*.conf' -print0 | xargs -0 -r rpl --quiet "" "$WEB_ALIAS_DOMAIN" > /dev/null -find /opt/docker/etc/nginx/ -iname '*.conf' -print0 | xargs -0 -r rpl --quiet "" "$HOSTNAME" > /dev/null +go-replace \ + -s "" -r "$WEB_DOCUMENT_INDEX" \ + -s "" -r "$WEB_DOCUMENT_ROOT" \ + -s "" -r "$WEB_ALIAS_DOMAIN" \ + -s "" -r "$HOSTNAME" \ + -s "" -r "$WEB_PHP_SOCKET" \ + --path=/opt/docker/etc/nginx/ \ + --path-pattern='*.conf' \ + --ignore-empty -if [[ -n "${WEB_PHP_SOCKET+x}" ]]; then - ## WEB_PHP_SOCKET is set - find /opt/docker/etc/nginx/ -iname '*.conf' -print0 | xargs -0 -r rpl --quiet "" "$WEB_PHP_SOCKET" > /dev/null -else +if [[ -z "${WEB_PHP_SOCKET+x}" ]]; then ## WEB_PHP_SOCKET is not set, remove PHP files rm -f -- /opt/docker/etc/nginx/conf.d/10-php.conf rm -f -- /opt/docker/etc/nginx/vhost.common.d/10-php.conf diff --git a/docker/php-nginx-dev/centos-7/conf/bin/service.d/nginx.d/12-development.sh b/docker/php-nginx-dev/centos-7/conf/bin/service.d/nginx.d/12-development.sh index fa4b601a9..f4695f059 100644 --- a/docker/php-nginx-dev/centos-7/conf/bin/service.d/nginx.d/12-development.sh +++ b/docker/php-nginx-dev/centos-7/conf/bin/service.d/nginx.d/12-development.sh @@ -1 +1,7 @@ -find /opt/docker/etc/nginx/ -iname '*.conf' -print0 | xargs -0 -r rpl --quiet "" "$WEB_NO_CACHE_PATTERN" > /dev/null +go-replace \ + -s "" \ + -r "$WEB_NO_CACHE_PATTERN" \ + --path=/opt/docker/etc/nginx/ \ + --path-pattern='*.conf' \ + --ignore-empty + diff --git a/docker/php-nginx-dev/centos-7/conf/etc/nginx/vhost.common.d/10-general.conf b/docker/php-nginx-dev/centos-7/conf/etc/nginx/vhost.common.d/10-general.conf new file mode 100644 index 000000000..d3fd0aa5e --- /dev/null +++ b/docker/php-nginx-dev/centos-7/conf/etc/nginx/vhost.common.d/10-general.conf @@ -0,0 +1 @@ +client_max_body_size 50m; diff --git a/docker/php-nginx-dev/centos-7/conf/etc/nginx/vhost.common.d/10-log.conf b/docker/php-nginx-dev/centos-7/conf/etc/nginx/vhost.common.d/10-log.conf new file mode 100644 index 000000000..a2cd929e7 --- /dev/null +++ b/docker/php-nginx-dev/centos-7/conf/etc/nginx/vhost.common.d/10-log.conf @@ -0,0 +1,2 @@ +access_log /docker.stdout; +error_log /docker.stderr info; diff --git a/docker/php-nginx-dev/centos-7/conf/etc/nginx/vhost.conf b/docker/php-nginx-dev/centos-7/conf/etc/nginx/vhost.conf index d07e27094..8225f314a 100644 --- a/docker/php-nginx-dev/centos-7/conf/etc/nginx/vhost.conf +++ b/docker/php-nginx-dev/centos-7/conf/etc/nginx/vhost.conf @@ -1,17 +1,11 @@ server { - listen 80 default_server; - listen 8000 default_server; + listen 80 default_server; server_name _ docker; - access_log /docker.stdout; - error_log /docker.stdout info; - root ""; index ; - client_max_body_size 50m; - include /opt/docker/etc/nginx/vhost.common.d/*.conf; } @@ -20,19 +14,13 @@ server { ############## server { - listen 443 default_server; - listen 8443 default_server; + listen 443 default_server; server_name _ docker; - access_log /docker.stdout; - error_log /docker.stdout info; - root ""; index ; - client_max_body_size 50m; - include /opt/docker/etc/nginx/vhost.common.d/*.conf; include /opt/docker/etc/nginx/vhost.ssl.conf; } diff --git a/docker/php-nginx-dev/centos-7/conf/provision/entrypoint.d/10-php-debugger.sh b/docker/php-nginx-dev/centos-7/conf/provision/entrypoint.d/10-php-debugger.sh index 7156e28aa..b5985a9ef 100644 --- a/docker/php-nginx-dev/centos-7/conf/provision/entrypoint.d/10-php-debugger.sh +++ b/docker/php-nginx-dev/centos-7/conf/provision/entrypoint.d/10-php-debugger.sh @@ -15,7 +15,8 @@ PHP_CONF_PATHS=" /etc/php5/fpm/conf.d /etc/php/7.0/mods-available /etc/php/7.0/cli/conf.d -/etc/php/7.0/fpm/conf.d" +/etc/php/7.0/fpm/conf.d +/usr/local/etc/php/conf.d/" function phpModuleRemove() { if [ "$#" -ne 1 ]; then @@ -40,7 +41,7 @@ if [[ -n "${PHP_DEBUGGER+x}" ]]; then blackfire) echo "PHP-Debugger: Blackfire enabled" phpModuleRemove "xdebug" - /opt/docker/bin/control.sh service.enable blackfire-agent + docker-service-enable blackfire-agent ;; none) diff --git a/docker/php-nginx-dev/centos-7/conf/provision/roles/webdevops-php-dev/tasks/bootstrap.yml b/docker/php-nginx-dev/centos-7/conf/provision/roles/webdevops-php-dev/tasks/bootstrap.yml index 2c5d76e3d..ff02b05fc 100644 --- a/docker/php-nginx-dev/centos-7/conf/provision/roles/webdevops-php-dev/tasks/bootstrap.yml +++ b/docker/php-nginx-dev/centos-7/conf/provision/roles/webdevops-php-dev/tasks/bootstrap.yml @@ -1,6 +1,5 @@ --- -- include: bootstrap/tools.yml - include: bootstrap/php-fpm.yml - include: bootstrap/php-module.yml - include: bootstrap/php-module.opcache.yml diff --git a/docker/php-nginx-dev/centos-7/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/php-module.blackfire.yml b/docker/php-nginx-dev/centos-7/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/php-module.blackfire.yml index 1a3db9bac..faf05f8de 100644 --- a/docker/php-nginx-dev/centos-7/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/php-module.blackfire.yml +++ b/docker/php-nginx-dev/centos-7/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/php-module.blackfire.yml @@ -7,4 +7,4 @@ with_items: - /etc/php5/cli/conf.d/zz-blackfire.ini - /etc/php5/fpm/conf.d/zz-blackfire.ini - when: ansible_distribution == 'Debian' and ansible_lsb.major_release|int >= 7 + when: ansible_distribution == 'Debian' and docker_image_info_distribution_version|int >= 7 diff --git a/docker/php-nginx-dev/centos-7/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/tools.yml b/docker/php-nginx-dev/centos-7/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/tools.yml deleted file mode 100644 index c49cb0e34..000000000 --- a/docker/php-nginx-dev/centos-7/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/tools.yml +++ /dev/null @@ -1,23 +0,0 @@ ---- - -- name: Downloading Tools - shell: curl -o "{{ item.dest }}" "{{ item.url }}" && chmod 755 "{{ item.dest }}" - with_items: - - { url: "https://phar.phpunit.de/phploc.phar", dest: /usr/local/bin/phploc } - - { url: "https://phar.phpunit.de/phpunit.phar", dest: /usr/local/bin/phpunit } - - { url: "http://static.pdepend.org/php/latest/pdepend.phar", dest: /usr/local/bin/pdepend } - - { url: "http://static.phpmd.org/php/latest/phpmd.phar", dest: /usr/local/bin/phpmd } - - { url: "https://squizlabs.github.io/PHP_CodeSniffer/phpcs.phar", dest: /usr/local/bin/phpcs } - - { url: "https://squizlabs.github.io/PHP_CodeSniffer/phpcbf.phar", dest: /usr/local/bin/phpcbf } - - { url: "https://phar.phpunit.de/phpcpd.phar", dest: /usr/local/bin/phpcpd } - - { url: "https://phar.phpunit.de/phpdcd.phar", dest: /usr/local/bin/phpdcd } - - { url: "https://github.com/Halleck45/PhpMetrics/raw/master/build/phpmetrics.phar", dest: /usr/local/bin/phpmetrics } - - { url: "http://get.sensiolabs.org/php-cs-fixer.phar", dest: /usr/local/bin/php-cs-fixer } - - { url: "https://github.com/sensiolabs-de/deprecation-detector/releases/download/0.1.0-alpha4/deprecation-detector.phar", dest: /usr/local/bin/deprecation-detector } - - { url: "https://github.com/sensiolabs-de/deprecation-detector/releases/download/0.1.0-alpha4/deprecation-detector.phar", dest: /usr/local/bin/deprecation-detector } - -- name: Install Tools via composer - raw: COMPOSER_HOME="/usr/local/composer" COMPOSER_BIN_DIR="/usr/local/bin" composer global require "{{ item.package }}" "{{ item.version }}" - with_items: - - { package: "sstalle/php7cc" , version: "*" } - - { package: "phpspec/phpspec" , version: "~2.0" } diff --git a/docker/php-nginx-dev/debian-7/Dockerfile b/docker/php-nginx-dev/debian-7/Dockerfile index 2a4679085..a2a52833c 100644 --- a/docker/php-nginx-dev/debian-7/Dockerfile +++ b/docker/php-nginx-dev/debian-7/Dockerfile @@ -5,16 +5,11 @@ FROM webdevops/php-dev:debian-7 -MAINTAINER info@webdevops.io -LABEL vendor=WebDevOps.io -LABEL io.webdevops.layout=8 -LABEL io.webdevops.version=1.5.0 - -ENV WEB_DOCUMENT_ROOT /app -ENV WEB_DOCUMENT_INDEX index.php -ENV WEB_ALIAS_DOMAIN *.vm -ENV WEB_PHP_SOCKET 127.0.0.1:9000 -ENV WEB_NO_CACHE_PATTERN "\.(css|js|gif|png|jpg|svg|json|xml)$" +ENV WEB_DOCUMENT_ROOT=/app \ + WEB_DOCUMENT_INDEX=index.php \ + WEB_ALIAS_DOMAIN=*.vm +ENV WEB_PHP_SOCKET=127.0.0.1:9000 +ENV WEB_NO_CACHE_PATTERN="\.(css|js|gif|png|jpg|svg|json|xml)$" COPY conf/ /opt/docker/ @@ -22,7 +17,7 @@ COPY conf/ /opt/docker/ RUN /usr/local/bin/apt-install \ nginx \ && /opt/docker/bin/provision run --tag bootstrap --role webdevops-nginx --role webdevops-php-nginx --role webdevops-nginx-dev --role webdevops-php-dev \ - && /opt/docker/bin/bootstrap.sh - + && /opt/docker/bin/bootstrap.sh \ + && docker-image-cleanup EXPOSE 80 443 diff --git a/docker/php-nginx-dev/debian-7/Dockerfile.jinja2 b/docker/php-nginx-dev/debian-7/Dockerfile.jinja2 index b806f1625..c85f90c57 100644 --- a/docker/php-nginx-dev/debian-7/Dockerfile.jinja2 +++ b/docker/php-nginx-dev/debian-7/Dockerfile.jinja2 @@ -1,7 +1,5 @@ {{ docker.from("php-dev", "debian-7") }} -{{ docker.version() }} - {{ environment.web() }} {{ environment.webPhp() }} {{ environment.webDevelopment() }} diff --git a/docker/php-nginx-dev/debian-7/conf/bin/service.d/nginx.d/10-init.sh b/docker/php-nginx-dev/debian-7/conf/bin/service.d/nginx.d/10-init.sh index 75a84a4eb..27b9776cc 100644 --- a/docker/php-nginx-dev/debian-7/conf/bin/service.d/nginx.d/10-init.sh +++ b/docker/php-nginx-dev/debian-7/conf/bin/service.d/nginx.d/10-init.sh @@ -8,15 +8,17 @@ fi ln -f -s /var/lib/nginx/logs /var/log/nginx # Replace markers -find /opt/docker/etc/nginx/ -iname '*.conf' -print0 | xargs -0 -r rpl --quiet "" "$WEB_DOCUMENT_INDEX" > /dev/null -find /opt/docker/etc/nginx/ -iname '*.conf' -print0 | xargs -0 -r rpl --quiet "" "$WEB_DOCUMENT_ROOT" > /dev/null -find /opt/docker/etc/nginx/ -iname '*.conf' -print0 | xargs -0 -r rpl --quiet "" "$WEB_ALIAS_DOMAIN" > /dev/null -find /opt/docker/etc/nginx/ -iname '*.conf' -print0 | xargs -0 -r rpl --quiet "" "$HOSTNAME" > /dev/null +go-replace \ + -s "" -r "$WEB_DOCUMENT_INDEX" \ + -s "" -r "$WEB_DOCUMENT_ROOT" \ + -s "" -r "$WEB_ALIAS_DOMAIN" \ + -s "" -r "$HOSTNAME" \ + -s "" -r "$WEB_PHP_SOCKET" \ + --path=/opt/docker/etc/nginx/ \ + --path-pattern='*.conf' \ + --ignore-empty -if [[ -n "${WEB_PHP_SOCKET+x}" ]]; then - ## WEB_PHP_SOCKET is set - find /opt/docker/etc/nginx/ -iname '*.conf' -print0 | xargs -0 -r rpl --quiet "" "$WEB_PHP_SOCKET" > /dev/null -else +if [[ -z "${WEB_PHP_SOCKET+x}" ]]; then ## WEB_PHP_SOCKET is not set, remove PHP files rm -f -- /opt/docker/etc/nginx/conf.d/10-php.conf rm -f -- /opt/docker/etc/nginx/vhost.common.d/10-php.conf diff --git a/docker/php-nginx-dev/debian-7/conf/bin/service.d/nginx.d/12-development.sh b/docker/php-nginx-dev/debian-7/conf/bin/service.d/nginx.d/12-development.sh index fa4b601a9..f4695f059 100644 --- a/docker/php-nginx-dev/debian-7/conf/bin/service.d/nginx.d/12-development.sh +++ b/docker/php-nginx-dev/debian-7/conf/bin/service.d/nginx.d/12-development.sh @@ -1 +1,7 @@ -find /opt/docker/etc/nginx/ -iname '*.conf' -print0 | xargs -0 -r rpl --quiet "" "$WEB_NO_CACHE_PATTERN" > /dev/null +go-replace \ + -s "" \ + -r "$WEB_NO_CACHE_PATTERN" \ + --path=/opt/docker/etc/nginx/ \ + --path-pattern='*.conf' \ + --ignore-empty + diff --git a/docker/php-nginx-dev/debian-7/conf/etc/nginx/vhost.common.d/10-general.conf b/docker/php-nginx-dev/debian-7/conf/etc/nginx/vhost.common.d/10-general.conf new file mode 100644 index 000000000..d3fd0aa5e --- /dev/null +++ b/docker/php-nginx-dev/debian-7/conf/etc/nginx/vhost.common.d/10-general.conf @@ -0,0 +1 @@ +client_max_body_size 50m; diff --git a/docker/php-nginx-dev/debian-7/conf/etc/nginx/vhost.common.d/10-log.conf b/docker/php-nginx-dev/debian-7/conf/etc/nginx/vhost.common.d/10-log.conf new file mode 100644 index 000000000..a2cd929e7 --- /dev/null +++ b/docker/php-nginx-dev/debian-7/conf/etc/nginx/vhost.common.d/10-log.conf @@ -0,0 +1,2 @@ +access_log /docker.stdout; +error_log /docker.stderr info; diff --git a/docker/php-nginx-dev/debian-7/conf/etc/nginx/vhost.conf b/docker/php-nginx-dev/debian-7/conf/etc/nginx/vhost.conf index d07e27094..8225f314a 100644 --- a/docker/php-nginx-dev/debian-7/conf/etc/nginx/vhost.conf +++ b/docker/php-nginx-dev/debian-7/conf/etc/nginx/vhost.conf @@ -1,17 +1,11 @@ server { - listen 80 default_server; - listen 8000 default_server; + listen 80 default_server; server_name _ docker; - access_log /docker.stdout; - error_log /docker.stdout info; - root ""; index ; - client_max_body_size 50m; - include /opt/docker/etc/nginx/vhost.common.d/*.conf; } @@ -20,19 +14,13 @@ server { ############## server { - listen 443 default_server; - listen 8443 default_server; + listen 443 default_server; server_name _ docker; - access_log /docker.stdout; - error_log /docker.stdout info; - root ""; index ; - client_max_body_size 50m; - include /opt/docker/etc/nginx/vhost.common.d/*.conf; include /opt/docker/etc/nginx/vhost.ssl.conf; } diff --git a/docker/php-nginx-dev/debian-7/conf/provision/entrypoint.d/10-php-debugger.sh b/docker/php-nginx-dev/debian-7/conf/provision/entrypoint.d/10-php-debugger.sh index 7156e28aa..b5985a9ef 100644 --- a/docker/php-nginx-dev/debian-7/conf/provision/entrypoint.d/10-php-debugger.sh +++ b/docker/php-nginx-dev/debian-7/conf/provision/entrypoint.d/10-php-debugger.sh @@ -15,7 +15,8 @@ PHP_CONF_PATHS=" /etc/php5/fpm/conf.d /etc/php/7.0/mods-available /etc/php/7.0/cli/conf.d -/etc/php/7.0/fpm/conf.d" +/etc/php/7.0/fpm/conf.d +/usr/local/etc/php/conf.d/" function phpModuleRemove() { if [ "$#" -ne 1 ]; then @@ -40,7 +41,7 @@ if [[ -n "${PHP_DEBUGGER+x}" ]]; then blackfire) echo "PHP-Debugger: Blackfire enabled" phpModuleRemove "xdebug" - /opt/docker/bin/control.sh service.enable blackfire-agent + docker-service-enable blackfire-agent ;; none) diff --git a/docker/php-nginx-dev/debian-7/conf/provision/roles/webdevops-php-dev/tasks/bootstrap.yml b/docker/php-nginx-dev/debian-7/conf/provision/roles/webdevops-php-dev/tasks/bootstrap.yml index 2c5d76e3d..ff02b05fc 100644 --- a/docker/php-nginx-dev/debian-7/conf/provision/roles/webdevops-php-dev/tasks/bootstrap.yml +++ b/docker/php-nginx-dev/debian-7/conf/provision/roles/webdevops-php-dev/tasks/bootstrap.yml @@ -1,6 +1,5 @@ --- -- include: bootstrap/tools.yml - include: bootstrap/php-fpm.yml - include: bootstrap/php-module.yml - include: bootstrap/php-module.opcache.yml diff --git a/docker/php-nginx-dev/debian-7/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/php-module.blackfire.yml b/docker/php-nginx-dev/debian-7/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/php-module.blackfire.yml index 1a3db9bac..faf05f8de 100644 --- a/docker/php-nginx-dev/debian-7/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/php-module.blackfire.yml +++ b/docker/php-nginx-dev/debian-7/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/php-module.blackfire.yml @@ -7,4 +7,4 @@ with_items: - /etc/php5/cli/conf.d/zz-blackfire.ini - /etc/php5/fpm/conf.d/zz-blackfire.ini - when: ansible_distribution == 'Debian' and ansible_lsb.major_release|int >= 7 + when: ansible_distribution == 'Debian' and docker_image_info_distribution_version|int >= 7 diff --git a/docker/php-nginx-dev/debian-7/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/tools.yml b/docker/php-nginx-dev/debian-7/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/tools.yml deleted file mode 100644 index c49cb0e34..000000000 --- a/docker/php-nginx-dev/debian-7/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/tools.yml +++ /dev/null @@ -1,23 +0,0 @@ ---- - -- name: Downloading Tools - shell: curl -o "{{ item.dest }}" "{{ item.url }}" && chmod 755 "{{ item.dest }}" - with_items: - - { url: "https://phar.phpunit.de/phploc.phar", dest: /usr/local/bin/phploc } - - { url: "https://phar.phpunit.de/phpunit.phar", dest: /usr/local/bin/phpunit } - - { url: "http://static.pdepend.org/php/latest/pdepend.phar", dest: /usr/local/bin/pdepend } - - { url: "http://static.phpmd.org/php/latest/phpmd.phar", dest: /usr/local/bin/phpmd } - - { url: "https://squizlabs.github.io/PHP_CodeSniffer/phpcs.phar", dest: /usr/local/bin/phpcs } - - { url: "https://squizlabs.github.io/PHP_CodeSniffer/phpcbf.phar", dest: /usr/local/bin/phpcbf } - - { url: "https://phar.phpunit.de/phpcpd.phar", dest: /usr/local/bin/phpcpd } - - { url: "https://phar.phpunit.de/phpdcd.phar", dest: /usr/local/bin/phpdcd } - - { url: "https://github.com/Halleck45/PhpMetrics/raw/master/build/phpmetrics.phar", dest: /usr/local/bin/phpmetrics } - - { url: "http://get.sensiolabs.org/php-cs-fixer.phar", dest: /usr/local/bin/php-cs-fixer } - - { url: "https://github.com/sensiolabs-de/deprecation-detector/releases/download/0.1.0-alpha4/deprecation-detector.phar", dest: /usr/local/bin/deprecation-detector } - - { url: "https://github.com/sensiolabs-de/deprecation-detector/releases/download/0.1.0-alpha4/deprecation-detector.phar", dest: /usr/local/bin/deprecation-detector } - -- name: Install Tools via composer - raw: COMPOSER_HOME="/usr/local/composer" COMPOSER_BIN_DIR="/usr/local/bin" composer global require "{{ item.package }}" "{{ item.version }}" - with_items: - - { package: "sstalle/php7cc" , version: "*" } - - { package: "phpspec/phpspec" , version: "~2.0" } diff --git a/docker/php-nginx-dev/debian-8-php7/Dockerfile b/docker/php-nginx-dev/debian-8-php7/Dockerfile index 0901bdd5d..abdf9664f 100644 --- a/docker/php-nginx-dev/debian-8-php7/Dockerfile +++ b/docker/php-nginx-dev/debian-8-php7/Dockerfile @@ -5,16 +5,11 @@ FROM webdevops/php-dev:debian-8-php7 -MAINTAINER info@webdevops.io -LABEL vendor=WebDevOps.io -LABEL io.webdevops.layout=8 -LABEL io.webdevops.version=1.5.0 - -ENV WEB_DOCUMENT_ROOT /app -ENV WEB_DOCUMENT_INDEX index.php -ENV WEB_ALIAS_DOMAIN *.vm -ENV WEB_PHP_SOCKET 127.0.0.1:9000 -ENV WEB_NO_CACHE_PATTERN "\.(css|js|gif|png|jpg|svg|json|xml)$" +ENV WEB_DOCUMENT_ROOT=/app \ + WEB_DOCUMENT_INDEX=index.php \ + WEB_ALIAS_DOMAIN=*.vm +ENV WEB_PHP_SOCKET=127.0.0.1:9000 +ENV WEB_NO_CACHE_PATTERN="\.(css|js|gif|png|jpg|svg|json|xml)$" COPY conf/ /opt/docker/ @@ -22,7 +17,7 @@ COPY conf/ /opt/docker/ RUN /usr/local/bin/apt-install \ nginx \ && /opt/docker/bin/provision run --tag bootstrap --role webdevops-nginx --role webdevops-php-nginx --role webdevops-nginx-dev --role webdevops-php-dev \ - && /opt/docker/bin/bootstrap.sh - + && /opt/docker/bin/bootstrap.sh \ + && docker-image-cleanup EXPOSE 80 443 diff --git a/docker/php-nginx-dev/debian-8-php7/Dockerfile.jinja2 b/docker/php-nginx-dev/debian-8-php7/Dockerfile.jinja2 index 6161deb68..a39c254e7 100644 --- a/docker/php-nginx-dev/debian-8-php7/Dockerfile.jinja2 +++ b/docker/php-nginx-dev/debian-8-php7/Dockerfile.jinja2 @@ -1,7 +1,5 @@ {{ docker.from("php-dev", "debian-8-php7") }} -{{ docker.version() }} - {{ environment.web() }} {{ environment.webPhp() }} {{ environment.webDevelopment() }} diff --git a/docker/php-nginx-dev/debian-8-php7/conf/bin/service.d/nginx.d/10-init.sh b/docker/php-nginx-dev/debian-8-php7/conf/bin/service.d/nginx.d/10-init.sh index 75a84a4eb..27b9776cc 100644 --- a/docker/php-nginx-dev/debian-8-php7/conf/bin/service.d/nginx.d/10-init.sh +++ b/docker/php-nginx-dev/debian-8-php7/conf/bin/service.d/nginx.d/10-init.sh @@ -8,15 +8,17 @@ fi ln -f -s /var/lib/nginx/logs /var/log/nginx # Replace markers -find /opt/docker/etc/nginx/ -iname '*.conf' -print0 | xargs -0 -r rpl --quiet "" "$WEB_DOCUMENT_INDEX" > /dev/null -find /opt/docker/etc/nginx/ -iname '*.conf' -print0 | xargs -0 -r rpl --quiet "" "$WEB_DOCUMENT_ROOT" > /dev/null -find /opt/docker/etc/nginx/ -iname '*.conf' -print0 | xargs -0 -r rpl --quiet "" "$WEB_ALIAS_DOMAIN" > /dev/null -find /opt/docker/etc/nginx/ -iname '*.conf' -print0 | xargs -0 -r rpl --quiet "" "$HOSTNAME" > /dev/null +go-replace \ + -s "" -r "$WEB_DOCUMENT_INDEX" \ + -s "" -r "$WEB_DOCUMENT_ROOT" \ + -s "" -r "$WEB_ALIAS_DOMAIN" \ + -s "" -r "$HOSTNAME" \ + -s "" -r "$WEB_PHP_SOCKET" \ + --path=/opt/docker/etc/nginx/ \ + --path-pattern='*.conf' \ + --ignore-empty -if [[ -n "${WEB_PHP_SOCKET+x}" ]]; then - ## WEB_PHP_SOCKET is set - find /opt/docker/etc/nginx/ -iname '*.conf' -print0 | xargs -0 -r rpl --quiet "" "$WEB_PHP_SOCKET" > /dev/null -else +if [[ -z "${WEB_PHP_SOCKET+x}" ]]; then ## WEB_PHP_SOCKET is not set, remove PHP files rm -f -- /opt/docker/etc/nginx/conf.d/10-php.conf rm -f -- /opt/docker/etc/nginx/vhost.common.d/10-php.conf diff --git a/docker/php-nginx-dev/debian-8-php7/conf/bin/service.d/nginx.d/12-development.sh b/docker/php-nginx-dev/debian-8-php7/conf/bin/service.d/nginx.d/12-development.sh index fa4b601a9..f4695f059 100644 --- a/docker/php-nginx-dev/debian-8-php7/conf/bin/service.d/nginx.d/12-development.sh +++ b/docker/php-nginx-dev/debian-8-php7/conf/bin/service.d/nginx.d/12-development.sh @@ -1 +1,7 @@ -find /opt/docker/etc/nginx/ -iname '*.conf' -print0 | xargs -0 -r rpl --quiet "" "$WEB_NO_CACHE_PATTERN" > /dev/null +go-replace \ + -s "" \ + -r "$WEB_NO_CACHE_PATTERN" \ + --path=/opt/docker/etc/nginx/ \ + --path-pattern='*.conf' \ + --ignore-empty + diff --git a/docker/php-nginx-dev/debian-8-php7/conf/etc/nginx/vhost.common.d/10-general.conf b/docker/php-nginx-dev/debian-8-php7/conf/etc/nginx/vhost.common.d/10-general.conf new file mode 100644 index 000000000..d3fd0aa5e --- /dev/null +++ b/docker/php-nginx-dev/debian-8-php7/conf/etc/nginx/vhost.common.d/10-general.conf @@ -0,0 +1 @@ +client_max_body_size 50m; diff --git a/docker/php-nginx-dev/debian-8-php7/conf/etc/nginx/vhost.common.d/10-log.conf b/docker/php-nginx-dev/debian-8-php7/conf/etc/nginx/vhost.common.d/10-log.conf new file mode 100644 index 000000000..a2cd929e7 --- /dev/null +++ b/docker/php-nginx-dev/debian-8-php7/conf/etc/nginx/vhost.common.d/10-log.conf @@ -0,0 +1,2 @@ +access_log /docker.stdout; +error_log /docker.stderr info; diff --git a/docker/php-nginx-dev/debian-8-php7/conf/etc/nginx/vhost.conf b/docker/php-nginx-dev/debian-8-php7/conf/etc/nginx/vhost.conf index d07e27094..8225f314a 100644 --- a/docker/php-nginx-dev/debian-8-php7/conf/etc/nginx/vhost.conf +++ b/docker/php-nginx-dev/debian-8-php7/conf/etc/nginx/vhost.conf @@ -1,17 +1,11 @@ server { - listen 80 default_server; - listen 8000 default_server; + listen 80 default_server; server_name _ docker; - access_log /docker.stdout; - error_log /docker.stdout info; - root ""; index ; - client_max_body_size 50m; - include /opt/docker/etc/nginx/vhost.common.d/*.conf; } @@ -20,19 +14,13 @@ server { ############## server { - listen 443 default_server; - listen 8443 default_server; + listen 443 default_server; server_name _ docker; - access_log /docker.stdout; - error_log /docker.stdout info; - root ""; index ; - client_max_body_size 50m; - include /opt/docker/etc/nginx/vhost.common.d/*.conf; include /opt/docker/etc/nginx/vhost.ssl.conf; } diff --git a/docker/php-nginx-dev/debian-8-php7/conf/provision/entrypoint.d/10-php-debugger.sh b/docker/php-nginx-dev/debian-8-php7/conf/provision/entrypoint.d/10-php-debugger.sh index 7156e28aa..b5985a9ef 100644 --- a/docker/php-nginx-dev/debian-8-php7/conf/provision/entrypoint.d/10-php-debugger.sh +++ b/docker/php-nginx-dev/debian-8-php7/conf/provision/entrypoint.d/10-php-debugger.sh @@ -15,7 +15,8 @@ PHP_CONF_PATHS=" /etc/php5/fpm/conf.d /etc/php/7.0/mods-available /etc/php/7.0/cli/conf.d -/etc/php/7.0/fpm/conf.d" +/etc/php/7.0/fpm/conf.d +/usr/local/etc/php/conf.d/" function phpModuleRemove() { if [ "$#" -ne 1 ]; then @@ -40,7 +41,7 @@ if [[ -n "${PHP_DEBUGGER+x}" ]]; then blackfire) echo "PHP-Debugger: Blackfire enabled" phpModuleRemove "xdebug" - /opt/docker/bin/control.sh service.enable blackfire-agent + docker-service-enable blackfire-agent ;; none) diff --git a/docker/php-nginx-dev/debian-8-php7/conf/provision/roles/webdevops-php-dev/tasks/bootstrap.yml b/docker/php-nginx-dev/debian-8-php7/conf/provision/roles/webdevops-php-dev/tasks/bootstrap.yml index 2c5d76e3d..ff02b05fc 100644 --- a/docker/php-nginx-dev/debian-8-php7/conf/provision/roles/webdevops-php-dev/tasks/bootstrap.yml +++ b/docker/php-nginx-dev/debian-8-php7/conf/provision/roles/webdevops-php-dev/tasks/bootstrap.yml @@ -1,6 +1,5 @@ --- -- include: bootstrap/tools.yml - include: bootstrap/php-fpm.yml - include: bootstrap/php-module.yml - include: bootstrap/php-module.opcache.yml diff --git a/docker/php-nginx-dev/debian-8-php7/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/php-module.blackfire.yml b/docker/php-nginx-dev/debian-8-php7/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/php-module.blackfire.yml index 1a3db9bac..faf05f8de 100644 --- a/docker/php-nginx-dev/debian-8-php7/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/php-module.blackfire.yml +++ b/docker/php-nginx-dev/debian-8-php7/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/php-module.blackfire.yml @@ -7,4 +7,4 @@ with_items: - /etc/php5/cli/conf.d/zz-blackfire.ini - /etc/php5/fpm/conf.d/zz-blackfire.ini - when: ansible_distribution == 'Debian' and ansible_lsb.major_release|int >= 7 + when: ansible_distribution == 'Debian' and docker_image_info_distribution_version|int >= 7 diff --git a/docker/php-nginx-dev/debian-8-php7/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/tools.yml b/docker/php-nginx-dev/debian-8-php7/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/tools.yml deleted file mode 100644 index c49cb0e34..000000000 --- a/docker/php-nginx-dev/debian-8-php7/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/tools.yml +++ /dev/null @@ -1,23 +0,0 @@ ---- - -- name: Downloading Tools - shell: curl -o "{{ item.dest }}" "{{ item.url }}" && chmod 755 "{{ item.dest }}" - with_items: - - { url: "https://phar.phpunit.de/phploc.phar", dest: /usr/local/bin/phploc } - - { url: "https://phar.phpunit.de/phpunit.phar", dest: /usr/local/bin/phpunit } - - { url: "http://static.pdepend.org/php/latest/pdepend.phar", dest: /usr/local/bin/pdepend } - - { url: "http://static.phpmd.org/php/latest/phpmd.phar", dest: /usr/local/bin/phpmd } - - { url: "https://squizlabs.github.io/PHP_CodeSniffer/phpcs.phar", dest: /usr/local/bin/phpcs } - - { url: "https://squizlabs.github.io/PHP_CodeSniffer/phpcbf.phar", dest: /usr/local/bin/phpcbf } - - { url: "https://phar.phpunit.de/phpcpd.phar", dest: /usr/local/bin/phpcpd } - - { url: "https://phar.phpunit.de/phpdcd.phar", dest: /usr/local/bin/phpdcd } - - { url: "https://github.com/Halleck45/PhpMetrics/raw/master/build/phpmetrics.phar", dest: /usr/local/bin/phpmetrics } - - { url: "http://get.sensiolabs.org/php-cs-fixer.phar", dest: /usr/local/bin/php-cs-fixer } - - { url: "https://github.com/sensiolabs-de/deprecation-detector/releases/download/0.1.0-alpha4/deprecation-detector.phar", dest: /usr/local/bin/deprecation-detector } - - { url: "https://github.com/sensiolabs-de/deprecation-detector/releases/download/0.1.0-alpha4/deprecation-detector.phar", dest: /usr/local/bin/deprecation-detector } - -- name: Install Tools via composer - raw: COMPOSER_HOME="/usr/local/composer" COMPOSER_BIN_DIR="/usr/local/bin" composer global require "{{ item.package }}" "{{ item.version }}" - with_items: - - { package: "sstalle/php7cc" , version: "*" } - - { package: "phpspec/phpspec" , version: "~2.0" } diff --git a/docker/php-nginx-dev/debian-8/Dockerfile b/docker/php-nginx-dev/debian-8/Dockerfile index 05da8876d..c5b3645d4 100644 --- a/docker/php-nginx-dev/debian-8/Dockerfile +++ b/docker/php-nginx-dev/debian-8/Dockerfile @@ -5,16 +5,11 @@ FROM webdevops/php-dev:debian-8 -MAINTAINER info@webdevops.io -LABEL vendor=WebDevOps.io -LABEL io.webdevops.layout=8 -LABEL io.webdevops.version=1.5.0 - -ENV WEB_DOCUMENT_ROOT /app -ENV WEB_DOCUMENT_INDEX index.php -ENV WEB_ALIAS_DOMAIN *.vm -ENV WEB_PHP_SOCKET 127.0.0.1:9000 -ENV WEB_NO_CACHE_PATTERN "\.(css|js|gif|png|jpg|svg|json|xml)$" +ENV WEB_DOCUMENT_ROOT=/app \ + WEB_DOCUMENT_INDEX=index.php \ + WEB_ALIAS_DOMAIN=*.vm +ENV WEB_PHP_SOCKET=127.0.0.1:9000 +ENV WEB_NO_CACHE_PATTERN="\.(css|js|gif|png|jpg|svg|json|xml)$" COPY conf/ /opt/docker/ @@ -22,7 +17,7 @@ COPY conf/ /opt/docker/ RUN /usr/local/bin/apt-install \ nginx \ && /opt/docker/bin/provision run --tag bootstrap --role webdevops-nginx --role webdevops-php-nginx --role webdevops-nginx-dev --role webdevops-php-dev \ - && /opt/docker/bin/bootstrap.sh - + && /opt/docker/bin/bootstrap.sh \ + && docker-image-cleanup EXPOSE 80 443 diff --git a/docker/php-nginx-dev/debian-8/Dockerfile.jinja2 b/docker/php-nginx-dev/debian-8/Dockerfile.jinja2 index cf886a9ef..c6d3cc0e3 100644 --- a/docker/php-nginx-dev/debian-8/Dockerfile.jinja2 +++ b/docker/php-nginx-dev/debian-8/Dockerfile.jinja2 @@ -1,7 +1,5 @@ {{ docker.from("php-dev", "debian-8") }} -{{ docker.version() }} - {{ environment.web() }} {{ environment.webPhp() }} {{ environment.webDevelopment() }} diff --git a/docker/php-nginx-dev/debian-8/conf/bin/service.d/nginx.d/10-init.sh b/docker/php-nginx-dev/debian-8/conf/bin/service.d/nginx.d/10-init.sh index 75a84a4eb..27b9776cc 100644 --- a/docker/php-nginx-dev/debian-8/conf/bin/service.d/nginx.d/10-init.sh +++ b/docker/php-nginx-dev/debian-8/conf/bin/service.d/nginx.d/10-init.sh @@ -8,15 +8,17 @@ fi ln -f -s /var/lib/nginx/logs /var/log/nginx # Replace markers -find /opt/docker/etc/nginx/ -iname '*.conf' -print0 | xargs -0 -r rpl --quiet "" "$WEB_DOCUMENT_INDEX" > /dev/null -find /opt/docker/etc/nginx/ -iname '*.conf' -print0 | xargs -0 -r rpl --quiet "" "$WEB_DOCUMENT_ROOT" > /dev/null -find /opt/docker/etc/nginx/ -iname '*.conf' -print0 | xargs -0 -r rpl --quiet "" "$WEB_ALIAS_DOMAIN" > /dev/null -find /opt/docker/etc/nginx/ -iname '*.conf' -print0 | xargs -0 -r rpl --quiet "" "$HOSTNAME" > /dev/null +go-replace \ + -s "" -r "$WEB_DOCUMENT_INDEX" \ + -s "" -r "$WEB_DOCUMENT_ROOT" \ + -s "" -r "$WEB_ALIAS_DOMAIN" \ + -s "" -r "$HOSTNAME" \ + -s "" -r "$WEB_PHP_SOCKET" \ + --path=/opt/docker/etc/nginx/ \ + --path-pattern='*.conf' \ + --ignore-empty -if [[ -n "${WEB_PHP_SOCKET+x}" ]]; then - ## WEB_PHP_SOCKET is set - find /opt/docker/etc/nginx/ -iname '*.conf' -print0 | xargs -0 -r rpl --quiet "" "$WEB_PHP_SOCKET" > /dev/null -else +if [[ -z "${WEB_PHP_SOCKET+x}" ]]; then ## WEB_PHP_SOCKET is not set, remove PHP files rm -f -- /opt/docker/etc/nginx/conf.d/10-php.conf rm -f -- /opt/docker/etc/nginx/vhost.common.d/10-php.conf diff --git a/docker/php-nginx-dev/debian-8/conf/bin/service.d/nginx.d/12-development.sh b/docker/php-nginx-dev/debian-8/conf/bin/service.d/nginx.d/12-development.sh index fa4b601a9..f4695f059 100644 --- a/docker/php-nginx-dev/debian-8/conf/bin/service.d/nginx.d/12-development.sh +++ b/docker/php-nginx-dev/debian-8/conf/bin/service.d/nginx.d/12-development.sh @@ -1 +1,7 @@ -find /opt/docker/etc/nginx/ -iname '*.conf' -print0 | xargs -0 -r rpl --quiet "" "$WEB_NO_CACHE_PATTERN" > /dev/null +go-replace \ + -s "" \ + -r "$WEB_NO_CACHE_PATTERN" \ + --path=/opt/docker/etc/nginx/ \ + --path-pattern='*.conf' \ + --ignore-empty + diff --git a/docker/php-nginx-dev/debian-8/conf/etc/nginx/vhost.common.d/10-general.conf b/docker/php-nginx-dev/debian-8/conf/etc/nginx/vhost.common.d/10-general.conf new file mode 100644 index 000000000..d3fd0aa5e --- /dev/null +++ b/docker/php-nginx-dev/debian-8/conf/etc/nginx/vhost.common.d/10-general.conf @@ -0,0 +1 @@ +client_max_body_size 50m; diff --git a/docker/php-nginx-dev/debian-8/conf/etc/nginx/vhost.common.d/10-log.conf b/docker/php-nginx-dev/debian-8/conf/etc/nginx/vhost.common.d/10-log.conf new file mode 100644 index 000000000..a2cd929e7 --- /dev/null +++ b/docker/php-nginx-dev/debian-8/conf/etc/nginx/vhost.common.d/10-log.conf @@ -0,0 +1,2 @@ +access_log /docker.stdout; +error_log /docker.stderr info; diff --git a/docker/php-nginx-dev/debian-8/conf/etc/nginx/vhost.conf b/docker/php-nginx-dev/debian-8/conf/etc/nginx/vhost.conf index d07e27094..8225f314a 100644 --- a/docker/php-nginx-dev/debian-8/conf/etc/nginx/vhost.conf +++ b/docker/php-nginx-dev/debian-8/conf/etc/nginx/vhost.conf @@ -1,17 +1,11 @@ server { - listen 80 default_server; - listen 8000 default_server; + listen 80 default_server; server_name _ docker; - access_log /docker.stdout; - error_log /docker.stdout info; - root ""; index ; - client_max_body_size 50m; - include /opt/docker/etc/nginx/vhost.common.d/*.conf; } @@ -20,19 +14,13 @@ server { ############## server { - listen 443 default_server; - listen 8443 default_server; + listen 443 default_server; server_name _ docker; - access_log /docker.stdout; - error_log /docker.stdout info; - root ""; index ; - client_max_body_size 50m; - include /opt/docker/etc/nginx/vhost.common.d/*.conf; include /opt/docker/etc/nginx/vhost.ssl.conf; } diff --git a/docker/php-nginx-dev/debian-8/conf/provision/entrypoint.d/10-php-debugger.sh b/docker/php-nginx-dev/debian-8/conf/provision/entrypoint.d/10-php-debugger.sh index 7156e28aa..b5985a9ef 100644 --- a/docker/php-nginx-dev/debian-8/conf/provision/entrypoint.d/10-php-debugger.sh +++ b/docker/php-nginx-dev/debian-8/conf/provision/entrypoint.d/10-php-debugger.sh @@ -15,7 +15,8 @@ PHP_CONF_PATHS=" /etc/php5/fpm/conf.d /etc/php/7.0/mods-available /etc/php/7.0/cli/conf.d -/etc/php/7.0/fpm/conf.d" +/etc/php/7.0/fpm/conf.d +/usr/local/etc/php/conf.d/" function phpModuleRemove() { if [ "$#" -ne 1 ]; then @@ -40,7 +41,7 @@ if [[ -n "${PHP_DEBUGGER+x}" ]]; then blackfire) echo "PHP-Debugger: Blackfire enabled" phpModuleRemove "xdebug" - /opt/docker/bin/control.sh service.enable blackfire-agent + docker-service-enable blackfire-agent ;; none) diff --git a/docker/php-nginx-dev/debian-8/conf/provision/roles/webdevops-php-dev/tasks/bootstrap.yml b/docker/php-nginx-dev/debian-8/conf/provision/roles/webdevops-php-dev/tasks/bootstrap.yml index 2c5d76e3d..ff02b05fc 100644 --- a/docker/php-nginx-dev/debian-8/conf/provision/roles/webdevops-php-dev/tasks/bootstrap.yml +++ b/docker/php-nginx-dev/debian-8/conf/provision/roles/webdevops-php-dev/tasks/bootstrap.yml @@ -1,6 +1,5 @@ --- -- include: bootstrap/tools.yml - include: bootstrap/php-fpm.yml - include: bootstrap/php-module.yml - include: bootstrap/php-module.opcache.yml diff --git a/docker/php-nginx-dev/debian-8/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/php-module.blackfire.yml b/docker/php-nginx-dev/debian-8/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/php-module.blackfire.yml index 1a3db9bac..faf05f8de 100644 --- a/docker/php-nginx-dev/debian-8/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/php-module.blackfire.yml +++ b/docker/php-nginx-dev/debian-8/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/php-module.blackfire.yml @@ -7,4 +7,4 @@ with_items: - /etc/php5/cli/conf.d/zz-blackfire.ini - /etc/php5/fpm/conf.d/zz-blackfire.ini - when: ansible_distribution == 'Debian' and ansible_lsb.major_release|int >= 7 + when: ansible_distribution == 'Debian' and docker_image_info_distribution_version|int >= 7 diff --git a/docker/php-nginx-dev/debian-8/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/tools.yml b/docker/php-nginx-dev/debian-8/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/tools.yml deleted file mode 100644 index c49cb0e34..000000000 --- a/docker/php-nginx-dev/debian-8/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/tools.yml +++ /dev/null @@ -1,23 +0,0 @@ ---- - -- name: Downloading Tools - shell: curl -o "{{ item.dest }}" "{{ item.url }}" && chmod 755 "{{ item.dest }}" - with_items: - - { url: "https://phar.phpunit.de/phploc.phar", dest: /usr/local/bin/phploc } - - { url: "https://phar.phpunit.de/phpunit.phar", dest: /usr/local/bin/phpunit } - - { url: "http://static.pdepend.org/php/latest/pdepend.phar", dest: /usr/local/bin/pdepend } - - { url: "http://static.phpmd.org/php/latest/phpmd.phar", dest: /usr/local/bin/phpmd } - - { url: "https://squizlabs.github.io/PHP_CodeSniffer/phpcs.phar", dest: /usr/local/bin/phpcs } - - { url: "https://squizlabs.github.io/PHP_CodeSniffer/phpcbf.phar", dest: /usr/local/bin/phpcbf } - - { url: "https://phar.phpunit.de/phpcpd.phar", dest: /usr/local/bin/phpcpd } - - { url: "https://phar.phpunit.de/phpdcd.phar", dest: /usr/local/bin/phpdcd } - - { url: "https://github.com/Halleck45/PhpMetrics/raw/master/build/phpmetrics.phar", dest: /usr/local/bin/phpmetrics } - - { url: "http://get.sensiolabs.org/php-cs-fixer.phar", dest: /usr/local/bin/php-cs-fixer } - - { url: "https://github.com/sensiolabs-de/deprecation-detector/releases/download/0.1.0-alpha4/deprecation-detector.phar", dest: /usr/local/bin/deprecation-detector } - - { url: "https://github.com/sensiolabs-de/deprecation-detector/releases/download/0.1.0-alpha4/deprecation-detector.phar", dest: /usr/local/bin/deprecation-detector } - -- name: Install Tools via composer - raw: COMPOSER_HOME="/usr/local/composer" COMPOSER_BIN_DIR="/usr/local/bin" composer global require "{{ item.package }}" "{{ item.version }}" - with_items: - - { package: "sstalle/php7cc" , version: "*" } - - { package: "phpspec/phpspec" , version: "~2.0" } diff --git a/docker/php-nginx-dev/debian-9/Dockerfile b/docker/php-nginx-dev/debian-9/Dockerfile index ddc584031..79caf2ff0 100644 --- a/docker/php-nginx-dev/debian-9/Dockerfile +++ b/docker/php-nginx-dev/debian-9/Dockerfile @@ -5,16 +5,11 @@ FROM webdevops/php-dev:debian-9 -MAINTAINER info@webdevops.io -LABEL vendor=WebDevOps.io -LABEL io.webdevops.layout=8 -LABEL io.webdevops.version=1.5.0 - -ENV WEB_DOCUMENT_ROOT /app -ENV WEB_DOCUMENT_INDEX index.php -ENV WEB_ALIAS_DOMAIN *.vm -ENV WEB_PHP_SOCKET 127.0.0.1:9000 -ENV WEB_NO_CACHE_PATTERN "\.(css|js|gif|png|jpg|svg|json|xml)$" +ENV WEB_DOCUMENT_ROOT=/app \ + WEB_DOCUMENT_INDEX=index.php \ + WEB_ALIAS_DOMAIN=*.vm +ENV WEB_PHP_SOCKET=127.0.0.1:9000 +ENV WEB_NO_CACHE_PATTERN="\.(css|js|gif|png|jpg|svg|json|xml)$" COPY conf/ /opt/docker/ @@ -22,7 +17,7 @@ COPY conf/ /opt/docker/ RUN /usr/local/bin/apt-install \ nginx \ && /opt/docker/bin/provision run --tag bootstrap --role webdevops-nginx --role webdevops-php-nginx --role webdevops-nginx-dev --role webdevops-php-dev \ - && /opt/docker/bin/bootstrap.sh - + && /opt/docker/bin/bootstrap.sh \ + && docker-image-cleanup EXPOSE 80 443 diff --git a/docker/php-nginx-dev/debian-9/Dockerfile.jinja2 b/docker/php-nginx-dev/debian-9/Dockerfile.jinja2 index 67a0fb9d8..8aad79fec 100644 --- a/docker/php-nginx-dev/debian-9/Dockerfile.jinja2 +++ b/docker/php-nginx-dev/debian-9/Dockerfile.jinja2 @@ -1,7 +1,5 @@ {{ docker.from("php-dev", "debian-9") }} -{{ docker.version() }} - {{ environment.web() }} {{ environment.webPhp() }} {{ environment.webDevelopment() }} diff --git a/docker/php-nginx-dev/debian-9/conf/bin/service.d/nginx.d/10-init.sh b/docker/php-nginx-dev/debian-9/conf/bin/service.d/nginx.d/10-init.sh index 75a84a4eb..27b9776cc 100644 --- a/docker/php-nginx-dev/debian-9/conf/bin/service.d/nginx.d/10-init.sh +++ b/docker/php-nginx-dev/debian-9/conf/bin/service.d/nginx.d/10-init.sh @@ -8,15 +8,17 @@ fi ln -f -s /var/lib/nginx/logs /var/log/nginx # Replace markers -find /opt/docker/etc/nginx/ -iname '*.conf' -print0 | xargs -0 -r rpl --quiet "" "$WEB_DOCUMENT_INDEX" > /dev/null -find /opt/docker/etc/nginx/ -iname '*.conf' -print0 | xargs -0 -r rpl --quiet "" "$WEB_DOCUMENT_ROOT" > /dev/null -find /opt/docker/etc/nginx/ -iname '*.conf' -print0 | xargs -0 -r rpl --quiet "" "$WEB_ALIAS_DOMAIN" > /dev/null -find /opt/docker/etc/nginx/ -iname '*.conf' -print0 | xargs -0 -r rpl --quiet "" "$HOSTNAME" > /dev/null +go-replace \ + -s "" -r "$WEB_DOCUMENT_INDEX" \ + -s "" -r "$WEB_DOCUMENT_ROOT" \ + -s "" -r "$WEB_ALIAS_DOMAIN" \ + -s "" -r "$HOSTNAME" \ + -s "" -r "$WEB_PHP_SOCKET" \ + --path=/opt/docker/etc/nginx/ \ + --path-pattern='*.conf' \ + --ignore-empty -if [[ -n "${WEB_PHP_SOCKET+x}" ]]; then - ## WEB_PHP_SOCKET is set - find /opt/docker/etc/nginx/ -iname '*.conf' -print0 | xargs -0 -r rpl --quiet "" "$WEB_PHP_SOCKET" > /dev/null -else +if [[ -z "${WEB_PHP_SOCKET+x}" ]]; then ## WEB_PHP_SOCKET is not set, remove PHP files rm -f -- /opt/docker/etc/nginx/conf.d/10-php.conf rm -f -- /opt/docker/etc/nginx/vhost.common.d/10-php.conf diff --git a/docker/php-nginx-dev/debian-9/conf/bin/service.d/nginx.d/12-development.sh b/docker/php-nginx-dev/debian-9/conf/bin/service.d/nginx.d/12-development.sh index fa4b601a9..f4695f059 100644 --- a/docker/php-nginx-dev/debian-9/conf/bin/service.d/nginx.d/12-development.sh +++ b/docker/php-nginx-dev/debian-9/conf/bin/service.d/nginx.d/12-development.sh @@ -1 +1,7 @@ -find /opt/docker/etc/nginx/ -iname '*.conf' -print0 | xargs -0 -r rpl --quiet "" "$WEB_NO_CACHE_PATTERN" > /dev/null +go-replace \ + -s "" \ + -r "$WEB_NO_CACHE_PATTERN" \ + --path=/opt/docker/etc/nginx/ \ + --path-pattern='*.conf' \ + --ignore-empty + diff --git a/docker/php-nginx-dev/debian-9/conf/etc/nginx/vhost.common.d/10-general.conf b/docker/php-nginx-dev/debian-9/conf/etc/nginx/vhost.common.d/10-general.conf new file mode 100644 index 000000000..d3fd0aa5e --- /dev/null +++ b/docker/php-nginx-dev/debian-9/conf/etc/nginx/vhost.common.d/10-general.conf @@ -0,0 +1 @@ +client_max_body_size 50m; diff --git a/docker/php-nginx-dev/debian-9/conf/etc/nginx/vhost.common.d/10-log.conf b/docker/php-nginx-dev/debian-9/conf/etc/nginx/vhost.common.d/10-log.conf new file mode 100644 index 000000000..a2cd929e7 --- /dev/null +++ b/docker/php-nginx-dev/debian-9/conf/etc/nginx/vhost.common.d/10-log.conf @@ -0,0 +1,2 @@ +access_log /docker.stdout; +error_log /docker.stderr info; diff --git a/docker/php-nginx-dev/debian-9/conf/etc/nginx/vhost.conf b/docker/php-nginx-dev/debian-9/conf/etc/nginx/vhost.conf index d07e27094..8225f314a 100644 --- a/docker/php-nginx-dev/debian-9/conf/etc/nginx/vhost.conf +++ b/docker/php-nginx-dev/debian-9/conf/etc/nginx/vhost.conf @@ -1,17 +1,11 @@ server { - listen 80 default_server; - listen 8000 default_server; + listen 80 default_server; server_name _ docker; - access_log /docker.stdout; - error_log /docker.stdout info; - root ""; index ; - client_max_body_size 50m; - include /opt/docker/etc/nginx/vhost.common.d/*.conf; } @@ -20,19 +14,13 @@ server { ############## server { - listen 443 default_server; - listen 8443 default_server; + listen 443 default_server; server_name _ docker; - access_log /docker.stdout; - error_log /docker.stdout info; - root ""; index ; - client_max_body_size 50m; - include /opt/docker/etc/nginx/vhost.common.d/*.conf; include /opt/docker/etc/nginx/vhost.ssl.conf; } diff --git a/docker/php-nginx-dev/debian-9/conf/provision/entrypoint.d/10-php-debugger.sh b/docker/php-nginx-dev/debian-9/conf/provision/entrypoint.d/10-php-debugger.sh index 7156e28aa..b5985a9ef 100644 --- a/docker/php-nginx-dev/debian-9/conf/provision/entrypoint.d/10-php-debugger.sh +++ b/docker/php-nginx-dev/debian-9/conf/provision/entrypoint.d/10-php-debugger.sh @@ -15,7 +15,8 @@ PHP_CONF_PATHS=" /etc/php5/fpm/conf.d /etc/php/7.0/mods-available /etc/php/7.0/cli/conf.d -/etc/php/7.0/fpm/conf.d" +/etc/php/7.0/fpm/conf.d +/usr/local/etc/php/conf.d/" function phpModuleRemove() { if [ "$#" -ne 1 ]; then @@ -40,7 +41,7 @@ if [[ -n "${PHP_DEBUGGER+x}" ]]; then blackfire) echo "PHP-Debugger: Blackfire enabled" phpModuleRemove "xdebug" - /opt/docker/bin/control.sh service.enable blackfire-agent + docker-service-enable blackfire-agent ;; none) diff --git a/docker/php-nginx-dev/debian-9/conf/provision/roles/webdevops-php-dev/tasks/bootstrap.yml b/docker/php-nginx-dev/debian-9/conf/provision/roles/webdevops-php-dev/tasks/bootstrap.yml index 2c5d76e3d..ff02b05fc 100644 --- a/docker/php-nginx-dev/debian-9/conf/provision/roles/webdevops-php-dev/tasks/bootstrap.yml +++ b/docker/php-nginx-dev/debian-9/conf/provision/roles/webdevops-php-dev/tasks/bootstrap.yml @@ -1,6 +1,5 @@ --- -- include: bootstrap/tools.yml - include: bootstrap/php-fpm.yml - include: bootstrap/php-module.yml - include: bootstrap/php-module.opcache.yml diff --git a/docker/php-nginx-dev/debian-9/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/php-module.blackfire.yml b/docker/php-nginx-dev/debian-9/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/php-module.blackfire.yml index 1a3db9bac..faf05f8de 100644 --- a/docker/php-nginx-dev/debian-9/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/php-module.blackfire.yml +++ b/docker/php-nginx-dev/debian-9/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/php-module.blackfire.yml @@ -7,4 +7,4 @@ with_items: - /etc/php5/cli/conf.d/zz-blackfire.ini - /etc/php5/fpm/conf.d/zz-blackfire.ini - when: ansible_distribution == 'Debian' and ansible_lsb.major_release|int >= 7 + when: ansible_distribution == 'Debian' and docker_image_info_distribution_version|int >= 7 diff --git a/docker/php-nginx-dev/debian-9/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/tools.yml b/docker/php-nginx-dev/debian-9/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/tools.yml deleted file mode 100644 index c49cb0e34..000000000 --- a/docker/php-nginx-dev/debian-9/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/tools.yml +++ /dev/null @@ -1,23 +0,0 @@ ---- - -- name: Downloading Tools - shell: curl -o "{{ item.dest }}" "{{ item.url }}" && chmod 755 "{{ item.dest }}" - with_items: - - { url: "https://phar.phpunit.de/phploc.phar", dest: /usr/local/bin/phploc } - - { url: "https://phar.phpunit.de/phpunit.phar", dest: /usr/local/bin/phpunit } - - { url: "http://static.pdepend.org/php/latest/pdepend.phar", dest: /usr/local/bin/pdepend } - - { url: "http://static.phpmd.org/php/latest/phpmd.phar", dest: /usr/local/bin/phpmd } - - { url: "https://squizlabs.github.io/PHP_CodeSniffer/phpcs.phar", dest: /usr/local/bin/phpcs } - - { url: "https://squizlabs.github.io/PHP_CodeSniffer/phpcbf.phar", dest: /usr/local/bin/phpcbf } - - { url: "https://phar.phpunit.de/phpcpd.phar", dest: /usr/local/bin/phpcpd } - - { url: "https://phar.phpunit.de/phpdcd.phar", dest: /usr/local/bin/phpdcd } - - { url: "https://github.com/Halleck45/PhpMetrics/raw/master/build/phpmetrics.phar", dest: /usr/local/bin/phpmetrics } - - { url: "http://get.sensiolabs.org/php-cs-fixer.phar", dest: /usr/local/bin/php-cs-fixer } - - { url: "https://github.com/sensiolabs-de/deprecation-detector/releases/download/0.1.0-alpha4/deprecation-detector.phar", dest: /usr/local/bin/deprecation-detector } - - { url: "https://github.com/sensiolabs-de/deprecation-detector/releases/download/0.1.0-alpha4/deprecation-detector.phar", dest: /usr/local/bin/deprecation-detector } - -- name: Install Tools via composer - raw: COMPOSER_HOME="/usr/local/composer" COMPOSER_BIN_DIR="/usr/local/bin" composer global require "{{ item.package }}" "{{ item.version }}" - with_items: - - { package: "sstalle/php7cc" , version: "*" } - - { package: "phpspec/phpspec" , version: "~2.0" } diff --git a/docker/php-nginx-dev/ubuntu-12.04/Dockerfile b/docker/php-nginx-dev/ubuntu-12.04/Dockerfile index 359650c2a..42b1875d7 100644 --- a/docker/php-nginx-dev/ubuntu-12.04/Dockerfile +++ b/docker/php-nginx-dev/ubuntu-12.04/Dockerfile @@ -5,16 +5,11 @@ FROM webdevops/php-dev:ubuntu-12.04 -MAINTAINER info@webdevops.io -LABEL vendor=WebDevOps.io -LABEL io.webdevops.layout=8 -LABEL io.webdevops.version=1.5.0 - -ENV WEB_DOCUMENT_ROOT /app -ENV WEB_DOCUMENT_INDEX index.php -ENV WEB_ALIAS_DOMAIN *.vm -ENV WEB_PHP_SOCKET 127.0.0.1:9000 -ENV WEB_NO_CACHE_PATTERN "\.(css|js|gif|png|jpg|svg|json|xml)$" +ENV WEB_DOCUMENT_ROOT=/app \ + WEB_DOCUMENT_INDEX=index.php \ + WEB_ALIAS_DOMAIN=*.vm +ENV WEB_PHP_SOCKET=127.0.0.1:9000 +ENV WEB_NO_CACHE_PATTERN="\.(css|js|gif|png|jpg|svg|json|xml)$" COPY conf/ /opt/docker/ @@ -22,7 +17,7 @@ COPY conf/ /opt/docker/ RUN /usr/local/bin/apt-install \ nginx \ && /opt/docker/bin/provision run --tag bootstrap --role webdevops-nginx --role webdevops-php-nginx --role webdevops-nginx-dev --role webdevops-php-dev \ - && /opt/docker/bin/bootstrap.sh - + && /opt/docker/bin/bootstrap.sh \ + && docker-image-cleanup EXPOSE 80 443 diff --git a/docker/php-nginx-dev/ubuntu-12.04/Dockerfile.jinja2 b/docker/php-nginx-dev/ubuntu-12.04/Dockerfile.jinja2 index ef6065c03..2dda3f85c 100644 --- a/docker/php-nginx-dev/ubuntu-12.04/Dockerfile.jinja2 +++ b/docker/php-nginx-dev/ubuntu-12.04/Dockerfile.jinja2 @@ -1,7 +1,5 @@ {{ docker.from("php-dev", "ubuntu-12.04") }} -{{ docker.version() }} - {{ environment.web() }} {{ environment.webPhp() }} {{ environment.webDevelopment() }} diff --git a/docker/php-nginx-dev/ubuntu-12.04/conf/bin/service.d/nginx.d/10-init.sh b/docker/php-nginx-dev/ubuntu-12.04/conf/bin/service.d/nginx.d/10-init.sh index 75a84a4eb..27b9776cc 100644 --- a/docker/php-nginx-dev/ubuntu-12.04/conf/bin/service.d/nginx.d/10-init.sh +++ b/docker/php-nginx-dev/ubuntu-12.04/conf/bin/service.d/nginx.d/10-init.sh @@ -8,15 +8,17 @@ fi ln -f -s /var/lib/nginx/logs /var/log/nginx # Replace markers -find /opt/docker/etc/nginx/ -iname '*.conf' -print0 | xargs -0 -r rpl --quiet "" "$WEB_DOCUMENT_INDEX" > /dev/null -find /opt/docker/etc/nginx/ -iname '*.conf' -print0 | xargs -0 -r rpl --quiet "" "$WEB_DOCUMENT_ROOT" > /dev/null -find /opt/docker/etc/nginx/ -iname '*.conf' -print0 | xargs -0 -r rpl --quiet "" "$WEB_ALIAS_DOMAIN" > /dev/null -find /opt/docker/etc/nginx/ -iname '*.conf' -print0 | xargs -0 -r rpl --quiet "" "$HOSTNAME" > /dev/null +go-replace \ + -s "" -r "$WEB_DOCUMENT_INDEX" \ + -s "" -r "$WEB_DOCUMENT_ROOT" \ + -s "" -r "$WEB_ALIAS_DOMAIN" \ + -s "" -r "$HOSTNAME" \ + -s "" -r "$WEB_PHP_SOCKET" \ + --path=/opt/docker/etc/nginx/ \ + --path-pattern='*.conf' \ + --ignore-empty -if [[ -n "${WEB_PHP_SOCKET+x}" ]]; then - ## WEB_PHP_SOCKET is set - find /opt/docker/etc/nginx/ -iname '*.conf' -print0 | xargs -0 -r rpl --quiet "" "$WEB_PHP_SOCKET" > /dev/null -else +if [[ -z "${WEB_PHP_SOCKET+x}" ]]; then ## WEB_PHP_SOCKET is not set, remove PHP files rm -f -- /opt/docker/etc/nginx/conf.d/10-php.conf rm -f -- /opt/docker/etc/nginx/vhost.common.d/10-php.conf diff --git a/docker/php-nginx-dev/ubuntu-12.04/conf/bin/service.d/nginx.d/12-development.sh b/docker/php-nginx-dev/ubuntu-12.04/conf/bin/service.d/nginx.d/12-development.sh index fa4b601a9..f4695f059 100644 --- a/docker/php-nginx-dev/ubuntu-12.04/conf/bin/service.d/nginx.d/12-development.sh +++ b/docker/php-nginx-dev/ubuntu-12.04/conf/bin/service.d/nginx.d/12-development.sh @@ -1 +1,7 @@ -find /opt/docker/etc/nginx/ -iname '*.conf' -print0 | xargs -0 -r rpl --quiet "" "$WEB_NO_CACHE_PATTERN" > /dev/null +go-replace \ + -s "" \ + -r "$WEB_NO_CACHE_PATTERN" \ + --path=/opt/docker/etc/nginx/ \ + --path-pattern='*.conf' \ + --ignore-empty + diff --git a/docker/php-nginx-dev/ubuntu-12.04/conf/etc/nginx/vhost.common.d/10-general.conf b/docker/php-nginx-dev/ubuntu-12.04/conf/etc/nginx/vhost.common.d/10-general.conf new file mode 100644 index 000000000..d3fd0aa5e --- /dev/null +++ b/docker/php-nginx-dev/ubuntu-12.04/conf/etc/nginx/vhost.common.d/10-general.conf @@ -0,0 +1 @@ +client_max_body_size 50m; diff --git a/docker/php-nginx-dev/ubuntu-12.04/conf/etc/nginx/vhost.common.d/10-log.conf b/docker/php-nginx-dev/ubuntu-12.04/conf/etc/nginx/vhost.common.d/10-log.conf new file mode 100644 index 000000000..a2cd929e7 --- /dev/null +++ b/docker/php-nginx-dev/ubuntu-12.04/conf/etc/nginx/vhost.common.d/10-log.conf @@ -0,0 +1,2 @@ +access_log /docker.stdout; +error_log /docker.stderr info; diff --git a/docker/php-nginx-dev/ubuntu-12.04/conf/etc/nginx/vhost.conf b/docker/php-nginx-dev/ubuntu-12.04/conf/etc/nginx/vhost.conf index d07e27094..8225f314a 100644 --- a/docker/php-nginx-dev/ubuntu-12.04/conf/etc/nginx/vhost.conf +++ b/docker/php-nginx-dev/ubuntu-12.04/conf/etc/nginx/vhost.conf @@ -1,17 +1,11 @@ server { - listen 80 default_server; - listen 8000 default_server; + listen 80 default_server; server_name _ docker; - access_log /docker.stdout; - error_log /docker.stdout info; - root ""; index ; - client_max_body_size 50m; - include /opt/docker/etc/nginx/vhost.common.d/*.conf; } @@ -20,19 +14,13 @@ server { ############## server { - listen 443 default_server; - listen 8443 default_server; + listen 443 default_server; server_name _ docker; - access_log /docker.stdout; - error_log /docker.stdout info; - root ""; index ; - client_max_body_size 50m; - include /opt/docker/etc/nginx/vhost.common.d/*.conf; include /opt/docker/etc/nginx/vhost.ssl.conf; } diff --git a/docker/php-nginx-dev/ubuntu-12.04/conf/provision/entrypoint.d/10-php-debugger.sh b/docker/php-nginx-dev/ubuntu-12.04/conf/provision/entrypoint.d/10-php-debugger.sh index 7156e28aa..b5985a9ef 100644 --- a/docker/php-nginx-dev/ubuntu-12.04/conf/provision/entrypoint.d/10-php-debugger.sh +++ b/docker/php-nginx-dev/ubuntu-12.04/conf/provision/entrypoint.d/10-php-debugger.sh @@ -15,7 +15,8 @@ PHP_CONF_PATHS=" /etc/php5/fpm/conf.d /etc/php/7.0/mods-available /etc/php/7.0/cli/conf.d -/etc/php/7.0/fpm/conf.d" +/etc/php/7.0/fpm/conf.d +/usr/local/etc/php/conf.d/" function phpModuleRemove() { if [ "$#" -ne 1 ]; then @@ -40,7 +41,7 @@ if [[ -n "${PHP_DEBUGGER+x}" ]]; then blackfire) echo "PHP-Debugger: Blackfire enabled" phpModuleRemove "xdebug" - /opt/docker/bin/control.sh service.enable blackfire-agent + docker-service-enable blackfire-agent ;; none) diff --git a/docker/php-nginx-dev/ubuntu-12.04/conf/provision/roles/webdevops-php-dev/tasks/bootstrap.yml b/docker/php-nginx-dev/ubuntu-12.04/conf/provision/roles/webdevops-php-dev/tasks/bootstrap.yml index 2c5d76e3d..ff02b05fc 100644 --- a/docker/php-nginx-dev/ubuntu-12.04/conf/provision/roles/webdevops-php-dev/tasks/bootstrap.yml +++ b/docker/php-nginx-dev/ubuntu-12.04/conf/provision/roles/webdevops-php-dev/tasks/bootstrap.yml @@ -1,6 +1,5 @@ --- -- include: bootstrap/tools.yml - include: bootstrap/php-fpm.yml - include: bootstrap/php-module.yml - include: bootstrap/php-module.opcache.yml diff --git a/docker/php-nginx-dev/ubuntu-12.04/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/php-module.blackfire.yml b/docker/php-nginx-dev/ubuntu-12.04/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/php-module.blackfire.yml index 1a3db9bac..faf05f8de 100644 --- a/docker/php-nginx-dev/ubuntu-12.04/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/php-module.blackfire.yml +++ b/docker/php-nginx-dev/ubuntu-12.04/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/php-module.blackfire.yml @@ -7,4 +7,4 @@ with_items: - /etc/php5/cli/conf.d/zz-blackfire.ini - /etc/php5/fpm/conf.d/zz-blackfire.ini - when: ansible_distribution == 'Debian' and ansible_lsb.major_release|int >= 7 + when: ansible_distribution == 'Debian' and docker_image_info_distribution_version|int >= 7 diff --git a/docker/php-nginx-dev/ubuntu-12.04/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/tools.yml b/docker/php-nginx-dev/ubuntu-12.04/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/tools.yml deleted file mode 100644 index c49cb0e34..000000000 --- a/docker/php-nginx-dev/ubuntu-12.04/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/tools.yml +++ /dev/null @@ -1,23 +0,0 @@ ---- - -- name: Downloading Tools - shell: curl -o "{{ item.dest }}" "{{ item.url }}" && chmod 755 "{{ item.dest }}" - with_items: - - { url: "https://phar.phpunit.de/phploc.phar", dest: /usr/local/bin/phploc } - - { url: "https://phar.phpunit.de/phpunit.phar", dest: /usr/local/bin/phpunit } - - { url: "http://static.pdepend.org/php/latest/pdepend.phar", dest: /usr/local/bin/pdepend } - - { url: "http://static.phpmd.org/php/latest/phpmd.phar", dest: /usr/local/bin/phpmd } - - { url: "https://squizlabs.github.io/PHP_CodeSniffer/phpcs.phar", dest: /usr/local/bin/phpcs } - - { url: "https://squizlabs.github.io/PHP_CodeSniffer/phpcbf.phar", dest: /usr/local/bin/phpcbf } - - { url: "https://phar.phpunit.de/phpcpd.phar", dest: /usr/local/bin/phpcpd } - - { url: "https://phar.phpunit.de/phpdcd.phar", dest: /usr/local/bin/phpdcd } - - { url: "https://github.com/Halleck45/PhpMetrics/raw/master/build/phpmetrics.phar", dest: /usr/local/bin/phpmetrics } - - { url: "http://get.sensiolabs.org/php-cs-fixer.phar", dest: /usr/local/bin/php-cs-fixer } - - { url: "https://github.com/sensiolabs-de/deprecation-detector/releases/download/0.1.0-alpha4/deprecation-detector.phar", dest: /usr/local/bin/deprecation-detector } - - { url: "https://github.com/sensiolabs-de/deprecation-detector/releases/download/0.1.0-alpha4/deprecation-detector.phar", dest: /usr/local/bin/deprecation-detector } - -- name: Install Tools via composer - raw: COMPOSER_HOME="/usr/local/composer" COMPOSER_BIN_DIR="/usr/local/bin" composer global require "{{ item.package }}" "{{ item.version }}" - with_items: - - { package: "sstalle/php7cc" , version: "*" } - - { package: "phpspec/phpspec" , version: "~2.0" } diff --git a/docker/php-nginx-dev/ubuntu-14.04/Dockerfile b/docker/php-nginx-dev/ubuntu-14.04/Dockerfile index 5d3fb3f0c..c94164426 100644 --- a/docker/php-nginx-dev/ubuntu-14.04/Dockerfile +++ b/docker/php-nginx-dev/ubuntu-14.04/Dockerfile @@ -5,16 +5,11 @@ FROM webdevops/php-dev:ubuntu-14.04 -MAINTAINER info@webdevops.io -LABEL vendor=WebDevOps.io -LABEL io.webdevops.layout=8 -LABEL io.webdevops.version=1.5.0 - -ENV WEB_DOCUMENT_ROOT /app -ENV WEB_DOCUMENT_INDEX index.php -ENV WEB_ALIAS_DOMAIN *.vm -ENV WEB_PHP_SOCKET 127.0.0.1:9000 -ENV WEB_NO_CACHE_PATTERN "\.(css|js|gif|png|jpg|svg|json|xml)$" +ENV WEB_DOCUMENT_ROOT=/app \ + WEB_DOCUMENT_INDEX=index.php \ + WEB_ALIAS_DOMAIN=*.vm +ENV WEB_PHP_SOCKET=127.0.0.1:9000 +ENV WEB_NO_CACHE_PATTERN="\.(css|js|gif|png|jpg|svg|json|xml)$" COPY conf/ /opt/docker/ @@ -22,7 +17,7 @@ COPY conf/ /opt/docker/ RUN /usr/local/bin/apt-install \ nginx \ && /opt/docker/bin/provision run --tag bootstrap --role webdevops-nginx --role webdevops-php-nginx --role webdevops-nginx-dev --role webdevops-php-dev \ - && /opt/docker/bin/bootstrap.sh - + && /opt/docker/bin/bootstrap.sh \ + && docker-image-cleanup EXPOSE 80 443 diff --git a/docker/php-nginx-dev/ubuntu-14.04/Dockerfile.jinja2 b/docker/php-nginx-dev/ubuntu-14.04/Dockerfile.jinja2 index 722acec8d..6a989cd9c 100644 --- a/docker/php-nginx-dev/ubuntu-14.04/Dockerfile.jinja2 +++ b/docker/php-nginx-dev/ubuntu-14.04/Dockerfile.jinja2 @@ -1,7 +1,5 @@ {{ docker.from("php-dev", "ubuntu-14.04") }} -{{ docker.version() }} - {{ environment.web() }} {{ environment.webPhp() }} {{ environment.webDevelopment() }} diff --git a/docker/php-nginx-dev/ubuntu-14.04/conf/bin/service.d/nginx.d/10-init.sh b/docker/php-nginx-dev/ubuntu-14.04/conf/bin/service.d/nginx.d/10-init.sh index 75a84a4eb..27b9776cc 100644 --- a/docker/php-nginx-dev/ubuntu-14.04/conf/bin/service.d/nginx.d/10-init.sh +++ b/docker/php-nginx-dev/ubuntu-14.04/conf/bin/service.d/nginx.d/10-init.sh @@ -8,15 +8,17 @@ fi ln -f -s /var/lib/nginx/logs /var/log/nginx # Replace markers -find /opt/docker/etc/nginx/ -iname '*.conf' -print0 | xargs -0 -r rpl --quiet "" "$WEB_DOCUMENT_INDEX" > /dev/null -find /opt/docker/etc/nginx/ -iname '*.conf' -print0 | xargs -0 -r rpl --quiet "" "$WEB_DOCUMENT_ROOT" > /dev/null -find /opt/docker/etc/nginx/ -iname '*.conf' -print0 | xargs -0 -r rpl --quiet "" "$WEB_ALIAS_DOMAIN" > /dev/null -find /opt/docker/etc/nginx/ -iname '*.conf' -print0 | xargs -0 -r rpl --quiet "" "$HOSTNAME" > /dev/null +go-replace \ + -s "" -r "$WEB_DOCUMENT_INDEX" \ + -s "" -r "$WEB_DOCUMENT_ROOT" \ + -s "" -r "$WEB_ALIAS_DOMAIN" \ + -s "" -r "$HOSTNAME" \ + -s "" -r "$WEB_PHP_SOCKET" \ + --path=/opt/docker/etc/nginx/ \ + --path-pattern='*.conf' \ + --ignore-empty -if [[ -n "${WEB_PHP_SOCKET+x}" ]]; then - ## WEB_PHP_SOCKET is set - find /opt/docker/etc/nginx/ -iname '*.conf' -print0 | xargs -0 -r rpl --quiet "" "$WEB_PHP_SOCKET" > /dev/null -else +if [[ -z "${WEB_PHP_SOCKET+x}" ]]; then ## WEB_PHP_SOCKET is not set, remove PHP files rm -f -- /opt/docker/etc/nginx/conf.d/10-php.conf rm -f -- /opt/docker/etc/nginx/vhost.common.d/10-php.conf diff --git a/docker/php-nginx-dev/ubuntu-14.04/conf/bin/service.d/nginx.d/12-development.sh b/docker/php-nginx-dev/ubuntu-14.04/conf/bin/service.d/nginx.d/12-development.sh index fa4b601a9..f4695f059 100644 --- a/docker/php-nginx-dev/ubuntu-14.04/conf/bin/service.d/nginx.d/12-development.sh +++ b/docker/php-nginx-dev/ubuntu-14.04/conf/bin/service.d/nginx.d/12-development.sh @@ -1 +1,7 @@ -find /opt/docker/etc/nginx/ -iname '*.conf' -print0 | xargs -0 -r rpl --quiet "" "$WEB_NO_CACHE_PATTERN" > /dev/null +go-replace \ + -s "" \ + -r "$WEB_NO_CACHE_PATTERN" \ + --path=/opt/docker/etc/nginx/ \ + --path-pattern='*.conf' \ + --ignore-empty + diff --git a/docker/php-nginx-dev/ubuntu-14.04/conf/etc/nginx/vhost.common.d/10-general.conf b/docker/php-nginx-dev/ubuntu-14.04/conf/etc/nginx/vhost.common.d/10-general.conf new file mode 100644 index 000000000..d3fd0aa5e --- /dev/null +++ b/docker/php-nginx-dev/ubuntu-14.04/conf/etc/nginx/vhost.common.d/10-general.conf @@ -0,0 +1 @@ +client_max_body_size 50m; diff --git a/docker/php-nginx-dev/ubuntu-14.04/conf/etc/nginx/vhost.common.d/10-log.conf b/docker/php-nginx-dev/ubuntu-14.04/conf/etc/nginx/vhost.common.d/10-log.conf new file mode 100644 index 000000000..a2cd929e7 --- /dev/null +++ b/docker/php-nginx-dev/ubuntu-14.04/conf/etc/nginx/vhost.common.d/10-log.conf @@ -0,0 +1,2 @@ +access_log /docker.stdout; +error_log /docker.stderr info; diff --git a/docker/php-nginx-dev/ubuntu-14.04/conf/etc/nginx/vhost.conf b/docker/php-nginx-dev/ubuntu-14.04/conf/etc/nginx/vhost.conf index d07e27094..8225f314a 100644 --- a/docker/php-nginx-dev/ubuntu-14.04/conf/etc/nginx/vhost.conf +++ b/docker/php-nginx-dev/ubuntu-14.04/conf/etc/nginx/vhost.conf @@ -1,17 +1,11 @@ server { - listen 80 default_server; - listen 8000 default_server; + listen 80 default_server; server_name _ docker; - access_log /docker.stdout; - error_log /docker.stdout info; - root ""; index ; - client_max_body_size 50m; - include /opt/docker/etc/nginx/vhost.common.d/*.conf; } @@ -20,19 +14,13 @@ server { ############## server { - listen 443 default_server; - listen 8443 default_server; + listen 443 default_server; server_name _ docker; - access_log /docker.stdout; - error_log /docker.stdout info; - root ""; index ; - client_max_body_size 50m; - include /opt/docker/etc/nginx/vhost.common.d/*.conf; include /opt/docker/etc/nginx/vhost.ssl.conf; } diff --git a/docker/php-nginx-dev/ubuntu-14.04/conf/provision/entrypoint.d/10-php-debugger.sh b/docker/php-nginx-dev/ubuntu-14.04/conf/provision/entrypoint.d/10-php-debugger.sh index 7156e28aa..b5985a9ef 100644 --- a/docker/php-nginx-dev/ubuntu-14.04/conf/provision/entrypoint.d/10-php-debugger.sh +++ b/docker/php-nginx-dev/ubuntu-14.04/conf/provision/entrypoint.d/10-php-debugger.sh @@ -15,7 +15,8 @@ PHP_CONF_PATHS=" /etc/php5/fpm/conf.d /etc/php/7.0/mods-available /etc/php/7.0/cli/conf.d -/etc/php/7.0/fpm/conf.d" +/etc/php/7.0/fpm/conf.d +/usr/local/etc/php/conf.d/" function phpModuleRemove() { if [ "$#" -ne 1 ]; then @@ -40,7 +41,7 @@ if [[ -n "${PHP_DEBUGGER+x}" ]]; then blackfire) echo "PHP-Debugger: Blackfire enabled" phpModuleRemove "xdebug" - /opt/docker/bin/control.sh service.enable blackfire-agent + docker-service-enable blackfire-agent ;; none) diff --git a/docker/php-nginx-dev/ubuntu-14.04/conf/provision/roles/webdevops-php-dev/tasks/bootstrap.yml b/docker/php-nginx-dev/ubuntu-14.04/conf/provision/roles/webdevops-php-dev/tasks/bootstrap.yml index 2c5d76e3d..ff02b05fc 100644 --- a/docker/php-nginx-dev/ubuntu-14.04/conf/provision/roles/webdevops-php-dev/tasks/bootstrap.yml +++ b/docker/php-nginx-dev/ubuntu-14.04/conf/provision/roles/webdevops-php-dev/tasks/bootstrap.yml @@ -1,6 +1,5 @@ --- -- include: bootstrap/tools.yml - include: bootstrap/php-fpm.yml - include: bootstrap/php-module.yml - include: bootstrap/php-module.opcache.yml diff --git a/docker/php-nginx-dev/ubuntu-14.04/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/php-module.blackfire.yml b/docker/php-nginx-dev/ubuntu-14.04/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/php-module.blackfire.yml index 1a3db9bac..faf05f8de 100644 --- a/docker/php-nginx-dev/ubuntu-14.04/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/php-module.blackfire.yml +++ b/docker/php-nginx-dev/ubuntu-14.04/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/php-module.blackfire.yml @@ -7,4 +7,4 @@ with_items: - /etc/php5/cli/conf.d/zz-blackfire.ini - /etc/php5/fpm/conf.d/zz-blackfire.ini - when: ansible_distribution == 'Debian' and ansible_lsb.major_release|int >= 7 + when: ansible_distribution == 'Debian' and docker_image_info_distribution_version|int >= 7 diff --git a/docker/php-nginx-dev/ubuntu-14.04/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/tools.yml b/docker/php-nginx-dev/ubuntu-14.04/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/tools.yml deleted file mode 100644 index c49cb0e34..000000000 --- a/docker/php-nginx-dev/ubuntu-14.04/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/tools.yml +++ /dev/null @@ -1,23 +0,0 @@ ---- - -- name: Downloading Tools - shell: curl -o "{{ item.dest }}" "{{ item.url }}" && chmod 755 "{{ item.dest }}" - with_items: - - { url: "https://phar.phpunit.de/phploc.phar", dest: /usr/local/bin/phploc } - - { url: "https://phar.phpunit.de/phpunit.phar", dest: /usr/local/bin/phpunit } - - { url: "http://static.pdepend.org/php/latest/pdepend.phar", dest: /usr/local/bin/pdepend } - - { url: "http://static.phpmd.org/php/latest/phpmd.phar", dest: /usr/local/bin/phpmd } - - { url: "https://squizlabs.github.io/PHP_CodeSniffer/phpcs.phar", dest: /usr/local/bin/phpcs } - - { url: "https://squizlabs.github.io/PHP_CodeSniffer/phpcbf.phar", dest: /usr/local/bin/phpcbf } - - { url: "https://phar.phpunit.de/phpcpd.phar", dest: /usr/local/bin/phpcpd } - - { url: "https://phar.phpunit.de/phpdcd.phar", dest: /usr/local/bin/phpdcd } - - { url: "https://github.com/Halleck45/PhpMetrics/raw/master/build/phpmetrics.phar", dest: /usr/local/bin/phpmetrics } - - { url: "http://get.sensiolabs.org/php-cs-fixer.phar", dest: /usr/local/bin/php-cs-fixer } - - { url: "https://github.com/sensiolabs-de/deprecation-detector/releases/download/0.1.0-alpha4/deprecation-detector.phar", dest: /usr/local/bin/deprecation-detector } - - { url: "https://github.com/sensiolabs-de/deprecation-detector/releases/download/0.1.0-alpha4/deprecation-detector.phar", dest: /usr/local/bin/deprecation-detector } - -- name: Install Tools via composer - raw: COMPOSER_HOME="/usr/local/composer" COMPOSER_BIN_DIR="/usr/local/bin" composer global require "{{ item.package }}" "{{ item.version }}" - with_items: - - { package: "sstalle/php7cc" , version: "*" } - - { package: "phpspec/phpspec" , version: "~2.0" } diff --git a/docker/php-nginx-dev/ubuntu-15.04/Dockerfile b/docker/php-nginx-dev/ubuntu-15.04/Dockerfile index 1359c2a3c..c80a82263 100644 --- a/docker/php-nginx-dev/ubuntu-15.04/Dockerfile +++ b/docker/php-nginx-dev/ubuntu-15.04/Dockerfile @@ -5,16 +5,11 @@ FROM webdevops/php-dev:ubuntu-15.04 -MAINTAINER info@webdevops.io -LABEL vendor=WebDevOps.io -LABEL io.webdevops.layout=8 -LABEL io.webdevops.version=1.5.0 - -ENV WEB_DOCUMENT_ROOT /app -ENV WEB_DOCUMENT_INDEX index.php -ENV WEB_ALIAS_DOMAIN *.vm -ENV WEB_PHP_SOCKET 127.0.0.1:9000 -ENV WEB_NO_CACHE_PATTERN "\.(css|js|gif|png|jpg|svg|json|xml)$" +ENV WEB_DOCUMENT_ROOT=/app \ + WEB_DOCUMENT_INDEX=index.php \ + WEB_ALIAS_DOMAIN=*.vm +ENV WEB_PHP_SOCKET=127.0.0.1:9000 +ENV WEB_NO_CACHE_PATTERN="\.(css|js|gif|png|jpg|svg|json|xml)$" COPY conf/ /opt/docker/ @@ -22,7 +17,7 @@ COPY conf/ /opt/docker/ RUN /usr/local/bin/apt-install \ nginx \ && /opt/docker/bin/provision run --tag bootstrap --role webdevops-nginx --role webdevops-php-nginx --role webdevops-nginx-dev --role webdevops-php-dev \ - && /opt/docker/bin/bootstrap.sh - + && /opt/docker/bin/bootstrap.sh \ + && docker-image-cleanup EXPOSE 80 443 diff --git a/docker/php-nginx-dev/ubuntu-15.04/Dockerfile.jinja2 b/docker/php-nginx-dev/ubuntu-15.04/Dockerfile.jinja2 index 964154705..3255cde01 100644 --- a/docker/php-nginx-dev/ubuntu-15.04/Dockerfile.jinja2 +++ b/docker/php-nginx-dev/ubuntu-15.04/Dockerfile.jinja2 @@ -1,7 +1,5 @@ {{ docker.from("php-dev", "ubuntu-15.04") }} -{{ docker.version() }} - {{ environment.web() }} {{ environment.webPhp() }} {{ environment.webDevelopment() }} diff --git a/docker/php-nginx-dev/ubuntu-15.04/conf/bin/service.d/nginx.d/10-init.sh b/docker/php-nginx-dev/ubuntu-15.04/conf/bin/service.d/nginx.d/10-init.sh index 75a84a4eb..27b9776cc 100644 --- a/docker/php-nginx-dev/ubuntu-15.04/conf/bin/service.d/nginx.d/10-init.sh +++ b/docker/php-nginx-dev/ubuntu-15.04/conf/bin/service.d/nginx.d/10-init.sh @@ -8,15 +8,17 @@ fi ln -f -s /var/lib/nginx/logs /var/log/nginx # Replace markers -find /opt/docker/etc/nginx/ -iname '*.conf' -print0 | xargs -0 -r rpl --quiet "" "$WEB_DOCUMENT_INDEX" > /dev/null -find /opt/docker/etc/nginx/ -iname '*.conf' -print0 | xargs -0 -r rpl --quiet "" "$WEB_DOCUMENT_ROOT" > /dev/null -find /opt/docker/etc/nginx/ -iname '*.conf' -print0 | xargs -0 -r rpl --quiet "" "$WEB_ALIAS_DOMAIN" > /dev/null -find /opt/docker/etc/nginx/ -iname '*.conf' -print0 | xargs -0 -r rpl --quiet "" "$HOSTNAME" > /dev/null +go-replace \ + -s "" -r "$WEB_DOCUMENT_INDEX" \ + -s "" -r "$WEB_DOCUMENT_ROOT" \ + -s "" -r "$WEB_ALIAS_DOMAIN" \ + -s "" -r "$HOSTNAME" \ + -s "" -r "$WEB_PHP_SOCKET" \ + --path=/opt/docker/etc/nginx/ \ + --path-pattern='*.conf' \ + --ignore-empty -if [[ -n "${WEB_PHP_SOCKET+x}" ]]; then - ## WEB_PHP_SOCKET is set - find /opt/docker/etc/nginx/ -iname '*.conf' -print0 | xargs -0 -r rpl --quiet "" "$WEB_PHP_SOCKET" > /dev/null -else +if [[ -z "${WEB_PHP_SOCKET+x}" ]]; then ## WEB_PHP_SOCKET is not set, remove PHP files rm -f -- /opt/docker/etc/nginx/conf.d/10-php.conf rm -f -- /opt/docker/etc/nginx/vhost.common.d/10-php.conf diff --git a/docker/php-nginx-dev/ubuntu-15.04/conf/bin/service.d/nginx.d/12-development.sh b/docker/php-nginx-dev/ubuntu-15.04/conf/bin/service.d/nginx.d/12-development.sh index fa4b601a9..f4695f059 100644 --- a/docker/php-nginx-dev/ubuntu-15.04/conf/bin/service.d/nginx.d/12-development.sh +++ b/docker/php-nginx-dev/ubuntu-15.04/conf/bin/service.d/nginx.d/12-development.sh @@ -1 +1,7 @@ -find /opt/docker/etc/nginx/ -iname '*.conf' -print0 | xargs -0 -r rpl --quiet "" "$WEB_NO_CACHE_PATTERN" > /dev/null +go-replace \ + -s "" \ + -r "$WEB_NO_CACHE_PATTERN" \ + --path=/opt/docker/etc/nginx/ \ + --path-pattern='*.conf' \ + --ignore-empty + diff --git a/docker/php-nginx-dev/ubuntu-15.04/conf/etc/nginx/vhost.common.d/10-general.conf b/docker/php-nginx-dev/ubuntu-15.04/conf/etc/nginx/vhost.common.d/10-general.conf new file mode 100644 index 000000000..d3fd0aa5e --- /dev/null +++ b/docker/php-nginx-dev/ubuntu-15.04/conf/etc/nginx/vhost.common.d/10-general.conf @@ -0,0 +1 @@ +client_max_body_size 50m; diff --git a/docker/php-nginx-dev/ubuntu-15.04/conf/etc/nginx/vhost.common.d/10-log.conf b/docker/php-nginx-dev/ubuntu-15.04/conf/etc/nginx/vhost.common.d/10-log.conf new file mode 100644 index 000000000..a2cd929e7 --- /dev/null +++ b/docker/php-nginx-dev/ubuntu-15.04/conf/etc/nginx/vhost.common.d/10-log.conf @@ -0,0 +1,2 @@ +access_log /docker.stdout; +error_log /docker.stderr info; diff --git a/docker/php-nginx-dev/ubuntu-15.04/conf/etc/nginx/vhost.conf b/docker/php-nginx-dev/ubuntu-15.04/conf/etc/nginx/vhost.conf index d07e27094..8225f314a 100644 --- a/docker/php-nginx-dev/ubuntu-15.04/conf/etc/nginx/vhost.conf +++ b/docker/php-nginx-dev/ubuntu-15.04/conf/etc/nginx/vhost.conf @@ -1,17 +1,11 @@ server { - listen 80 default_server; - listen 8000 default_server; + listen 80 default_server; server_name _ docker; - access_log /docker.stdout; - error_log /docker.stdout info; - root ""; index ; - client_max_body_size 50m; - include /opt/docker/etc/nginx/vhost.common.d/*.conf; } @@ -20,19 +14,13 @@ server { ############## server { - listen 443 default_server; - listen 8443 default_server; + listen 443 default_server; server_name _ docker; - access_log /docker.stdout; - error_log /docker.stdout info; - root ""; index ; - client_max_body_size 50m; - include /opt/docker/etc/nginx/vhost.common.d/*.conf; include /opt/docker/etc/nginx/vhost.ssl.conf; } diff --git a/docker/php-nginx-dev/ubuntu-15.04/conf/provision/entrypoint.d/10-php-debugger.sh b/docker/php-nginx-dev/ubuntu-15.04/conf/provision/entrypoint.d/10-php-debugger.sh index 7156e28aa..b5985a9ef 100644 --- a/docker/php-nginx-dev/ubuntu-15.04/conf/provision/entrypoint.d/10-php-debugger.sh +++ b/docker/php-nginx-dev/ubuntu-15.04/conf/provision/entrypoint.d/10-php-debugger.sh @@ -15,7 +15,8 @@ PHP_CONF_PATHS=" /etc/php5/fpm/conf.d /etc/php/7.0/mods-available /etc/php/7.0/cli/conf.d -/etc/php/7.0/fpm/conf.d" +/etc/php/7.0/fpm/conf.d +/usr/local/etc/php/conf.d/" function phpModuleRemove() { if [ "$#" -ne 1 ]; then @@ -40,7 +41,7 @@ if [[ -n "${PHP_DEBUGGER+x}" ]]; then blackfire) echo "PHP-Debugger: Blackfire enabled" phpModuleRemove "xdebug" - /opt/docker/bin/control.sh service.enable blackfire-agent + docker-service-enable blackfire-agent ;; none) diff --git a/docker/php-nginx-dev/ubuntu-15.04/conf/provision/roles/webdevops-php-dev/tasks/bootstrap.yml b/docker/php-nginx-dev/ubuntu-15.04/conf/provision/roles/webdevops-php-dev/tasks/bootstrap.yml index 2c5d76e3d..ff02b05fc 100644 --- a/docker/php-nginx-dev/ubuntu-15.04/conf/provision/roles/webdevops-php-dev/tasks/bootstrap.yml +++ b/docker/php-nginx-dev/ubuntu-15.04/conf/provision/roles/webdevops-php-dev/tasks/bootstrap.yml @@ -1,6 +1,5 @@ --- -- include: bootstrap/tools.yml - include: bootstrap/php-fpm.yml - include: bootstrap/php-module.yml - include: bootstrap/php-module.opcache.yml diff --git a/docker/php-nginx-dev/ubuntu-15.04/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/php-module.blackfire.yml b/docker/php-nginx-dev/ubuntu-15.04/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/php-module.blackfire.yml index 1a3db9bac..faf05f8de 100644 --- a/docker/php-nginx-dev/ubuntu-15.04/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/php-module.blackfire.yml +++ b/docker/php-nginx-dev/ubuntu-15.04/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/php-module.blackfire.yml @@ -7,4 +7,4 @@ with_items: - /etc/php5/cli/conf.d/zz-blackfire.ini - /etc/php5/fpm/conf.d/zz-blackfire.ini - when: ansible_distribution == 'Debian' and ansible_lsb.major_release|int >= 7 + when: ansible_distribution == 'Debian' and docker_image_info_distribution_version|int >= 7 diff --git a/docker/php-nginx-dev/ubuntu-15.04/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/tools.yml b/docker/php-nginx-dev/ubuntu-15.04/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/tools.yml deleted file mode 100644 index c49cb0e34..000000000 --- a/docker/php-nginx-dev/ubuntu-15.04/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/tools.yml +++ /dev/null @@ -1,23 +0,0 @@ ---- - -- name: Downloading Tools - shell: curl -o "{{ item.dest }}" "{{ item.url }}" && chmod 755 "{{ item.dest }}" - with_items: - - { url: "https://phar.phpunit.de/phploc.phar", dest: /usr/local/bin/phploc } - - { url: "https://phar.phpunit.de/phpunit.phar", dest: /usr/local/bin/phpunit } - - { url: "http://static.pdepend.org/php/latest/pdepend.phar", dest: /usr/local/bin/pdepend } - - { url: "http://static.phpmd.org/php/latest/phpmd.phar", dest: /usr/local/bin/phpmd } - - { url: "https://squizlabs.github.io/PHP_CodeSniffer/phpcs.phar", dest: /usr/local/bin/phpcs } - - { url: "https://squizlabs.github.io/PHP_CodeSniffer/phpcbf.phar", dest: /usr/local/bin/phpcbf } - - { url: "https://phar.phpunit.de/phpcpd.phar", dest: /usr/local/bin/phpcpd } - - { url: "https://phar.phpunit.de/phpdcd.phar", dest: /usr/local/bin/phpdcd } - - { url: "https://github.com/Halleck45/PhpMetrics/raw/master/build/phpmetrics.phar", dest: /usr/local/bin/phpmetrics } - - { url: "http://get.sensiolabs.org/php-cs-fixer.phar", dest: /usr/local/bin/php-cs-fixer } - - { url: "https://github.com/sensiolabs-de/deprecation-detector/releases/download/0.1.0-alpha4/deprecation-detector.phar", dest: /usr/local/bin/deprecation-detector } - - { url: "https://github.com/sensiolabs-de/deprecation-detector/releases/download/0.1.0-alpha4/deprecation-detector.phar", dest: /usr/local/bin/deprecation-detector } - -- name: Install Tools via composer - raw: COMPOSER_HOME="/usr/local/composer" COMPOSER_BIN_DIR="/usr/local/bin" composer global require "{{ item.package }}" "{{ item.version }}" - with_items: - - { package: "sstalle/php7cc" , version: "*" } - - { package: "phpspec/phpspec" , version: "~2.0" } diff --git a/docker/php-nginx-dev/ubuntu-15.10/Dockerfile b/docker/php-nginx-dev/ubuntu-15.10/Dockerfile index 65bd93ede..ca9705709 100644 --- a/docker/php-nginx-dev/ubuntu-15.10/Dockerfile +++ b/docker/php-nginx-dev/ubuntu-15.10/Dockerfile @@ -5,16 +5,11 @@ FROM webdevops/php-dev:ubuntu-15.10 -MAINTAINER info@webdevops.io -LABEL vendor=WebDevOps.io -LABEL io.webdevops.layout=8 -LABEL io.webdevops.version=1.5.0 - -ENV WEB_DOCUMENT_ROOT /app -ENV WEB_DOCUMENT_INDEX index.php -ENV WEB_ALIAS_DOMAIN *.vm -ENV WEB_PHP_SOCKET 127.0.0.1:9000 -ENV WEB_NO_CACHE_PATTERN "\.(css|js|gif|png|jpg|svg|json|xml)$" +ENV WEB_DOCUMENT_ROOT=/app \ + WEB_DOCUMENT_INDEX=index.php \ + WEB_ALIAS_DOMAIN=*.vm +ENV WEB_PHP_SOCKET=127.0.0.1:9000 +ENV WEB_NO_CACHE_PATTERN="\.(css|js|gif|png|jpg|svg|json|xml)$" COPY conf/ /opt/docker/ @@ -22,7 +17,7 @@ COPY conf/ /opt/docker/ RUN /usr/local/bin/apt-install \ nginx \ && /opt/docker/bin/provision run --tag bootstrap --role webdevops-nginx --role webdevops-php-nginx --role webdevops-nginx-dev --role webdevops-php-dev \ - && /opt/docker/bin/bootstrap.sh - + && /opt/docker/bin/bootstrap.sh \ + && docker-image-cleanup EXPOSE 80 443 diff --git a/docker/php-nginx-dev/ubuntu-15.10/Dockerfile.jinja2 b/docker/php-nginx-dev/ubuntu-15.10/Dockerfile.jinja2 index 9229c120d..c50586369 100644 --- a/docker/php-nginx-dev/ubuntu-15.10/Dockerfile.jinja2 +++ b/docker/php-nginx-dev/ubuntu-15.10/Dockerfile.jinja2 @@ -1,7 +1,5 @@ {{ docker.from("php-dev", "ubuntu-15.10") }} -{{ docker.version() }} - {{ environment.web() }} {{ environment.webPhp() }} {{ environment.webDevelopment() }} diff --git a/docker/php-nginx-dev/ubuntu-15.10/conf/bin/service.d/nginx.d/10-init.sh b/docker/php-nginx-dev/ubuntu-15.10/conf/bin/service.d/nginx.d/10-init.sh index 75a84a4eb..27b9776cc 100644 --- a/docker/php-nginx-dev/ubuntu-15.10/conf/bin/service.d/nginx.d/10-init.sh +++ b/docker/php-nginx-dev/ubuntu-15.10/conf/bin/service.d/nginx.d/10-init.sh @@ -8,15 +8,17 @@ fi ln -f -s /var/lib/nginx/logs /var/log/nginx # Replace markers -find /opt/docker/etc/nginx/ -iname '*.conf' -print0 | xargs -0 -r rpl --quiet "" "$WEB_DOCUMENT_INDEX" > /dev/null -find /opt/docker/etc/nginx/ -iname '*.conf' -print0 | xargs -0 -r rpl --quiet "" "$WEB_DOCUMENT_ROOT" > /dev/null -find /opt/docker/etc/nginx/ -iname '*.conf' -print0 | xargs -0 -r rpl --quiet "" "$WEB_ALIAS_DOMAIN" > /dev/null -find /opt/docker/etc/nginx/ -iname '*.conf' -print0 | xargs -0 -r rpl --quiet "" "$HOSTNAME" > /dev/null +go-replace \ + -s "" -r "$WEB_DOCUMENT_INDEX" \ + -s "" -r "$WEB_DOCUMENT_ROOT" \ + -s "" -r "$WEB_ALIAS_DOMAIN" \ + -s "" -r "$HOSTNAME" \ + -s "" -r "$WEB_PHP_SOCKET" \ + --path=/opt/docker/etc/nginx/ \ + --path-pattern='*.conf' \ + --ignore-empty -if [[ -n "${WEB_PHP_SOCKET+x}" ]]; then - ## WEB_PHP_SOCKET is set - find /opt/docker/etc/nginx/ -iname '*.conf' -print0 | xargs -0 -r rpl --quiet "" "$WEB_PHP_SOCKET" > /dev/null -else +if [[ -z "${WEB_PHP_SOCKET+x}" ]]; then ## WEB_PHP_SOCKET is not set, remove PHP files rm -f -- /opt/docker/etc/nginx/conf.d/10-php.conf rm -f -- /opt/docker/etc/nginx/vhost.common.d/10-php.conf diff --git a/docker/php-nginx-dev/ubuntu-15.10/conf/bin/service.d/nginx.d/12-development.sh b/docker/php-nginx-dev/ubuntu-15.10/conf/bin/service.d/nginx.d/12-development.sh index fa4b601a9..f4695f059 100644 --- a/docker/php-nginx-dev/ubuntu-15.10/conf/bin/service.d/nginx.d/12-development.sh +++ b/docker/php-nginx-dev/ubuntu-15.10/conf/bin/service.d/nginx.d/12-development.sh @@ -1 +1,7 @@ -find /opt/docker/etc/nginx/ -iname '*.conf' -print0 | xargs -0 -r rpl --quiet "" "$WEB_NO_CACHE_PATTERN" > /dev/null +go-replace \ + -s "" \ + -r "$WEB_NO_CACHE_PATTERN" \ + --path=/opt/docker/etc/nginx/ \ + --path-pattern='*.conf' \ + --ignore-empty + diff --git a/docker/php-nginx-dev/ubuntu-15.10/conf/etc/nginx/vhost.common.d/10-general.conf b/docker/php-nginx-dev/ubuntu-15.10/conf/etc/nginx/vhost.common.d/10-general.conf new file mode 100644 index 000000000..d3fd0aa5e --- /dev/null +++ b/docker/php-nginx-dev/ubuntu-15.10/conf/etc/nginx/vhost.common.d/10-general.conf @@ -0,0 +1 @@ +client_max_body_size 50m; diff --git a/docker/php-nginx-dev/ubuntu-15.10/conf/etc/nginx/vhost.common.d/10-log.conf b/docker/php-nginx-dev/ubuntu-15.10/conf/etc/nginx/vhost.common.d/10-log.conf new file mode 100644 index 000000000..a2cd929e7 --- /dev/null +++ b/docker/php-nginx-dev/ubuntu-15.10/conf/etc/nginx/vhost.common.d/10-log.conf @@ -0,0 +1,2 @@ +access_log /docker.stdout; +error_log /docker.stderr info; diff --git a/docker/php-nginx-dev/ubuntu-15.10/conf/etc/nginx/vhost.conf b/docker/php-nginx-dev/ubuntu-15.10/conf/etc/nginx/vhost.conf index d07e27094..8225f314a 100644 --- a/docker/php-nginx-dev/ubuntu-15.10/conf/etc/nginx/vhost.conf +++ b/docker/php-nginx-dev/ubuntu-15.10/conf/etc/nginx/vhost.conf @@ -1,17 +1,11 @@ server { - listen 80 default_server; - listen 8000 default_server; + listen 80 default_server; server_name _ docker; - access_log /docker.stdout; - error_log /docker.stdout info; - root ""; index ; - client_max_body_size 50m; - include /opt/docker/etc/nginx/vhost.common.d/*.conf; } @@ -20,19 +14,13 @@ server { ############## server { - listen 443 default_server; - listen 8443 default_server; + listen 443 default_server; server_name _ docker; - access_log /docker.stdout; - error_log /docker.stdout info; - root ""; index ; - client_max_body_size 50m; - include /opt/docker/etc/nginx/vhost.common.d/*.conf; include /opt/docker/etc/nginx/vhost.ssl.conf; } diff --git a/docker/php-nginx-dev/ubuntu-15.10/conf/provision/entrypoint.d/10-php-debugger.sh b/docker/php-nginx-dev/ubuntu-15.10/conf/provision/entrypoint.d/10-php-debugger.sh index 7156e28aa..b5985a9ef 100644 --- a/docker/php-nginx-dev/ubuntu-15.10/conf/provision/entrypoint.d/10-php-debugger.sh +++ b/docker/php-nginx-dev/ubuntu-15.10/conf/provision/entrypoint.d/10-php-debugger.sh @@ -15,7 +15,8 @@ PHP_CONF_PATHS=" /etc/php5/fpm/conf.d /etc/php/7.0/mods-available /etc/php/7.0/cli/conf.d -/etc/php/7.0/fpm/conf.d" +/etc/php/7.0/fpm/conf.d +/usr/local/etc/php/conf.d/" function phpModuleRemove() { if [ "$#" -ne 1 ]; then @@ -40,7 +41,7 @@ if [[ -n "${PHP_DEBUGGER+x}" ]]; then blackfire) echo "PHP-Debugger: Blackfire enabled" phpModuleRemove "xdebug" - /opt/docker/bin/control.sh service.enable blackfire-agent + docker-service-enable blackfire-agent ;; none) diff --git a/docker/php-nginx-dev/ubuntu-15.10/conf/provision/roles/webdevops-php-dev/tasks/bootstrap.yml b/docker/php-nginx-dev/ubuntu-15.10/conf/provision/roles/webdevops-php-dev/tasks/bootstrap.yml index 2c5d76e3d..ff02b05fc 100644 --- a/docker/php-nginx-dev/ubuntu-15.10/conf/provision/roles/webdevops-php-dev/tasks/bootstrap.yml +++ b/docker/php-nginx-dev/ubuntu-15.10/conf/provision/roles/webdevops-php-dev/tasks/bootstrap.yml @@ -1,6 +1,5 @@ --- -- include: bootstrap/tools.yml - include: bootstrap/php-fpm.yml - include: bootstrap/php-module.yml - include: bootstrap/php-module.opcache.yml diff --git a/docker/php-nginx-dev/ubuntu-15.10/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/php-module.blackfire.yml b/docker/php-nginx-dev/ubuntu-15.10/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/php-module.blackfire.yml index 1a3db9bac..faf05f8de 100644 --- a/docker/php-nginx-dev/ubuntu-15.10/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/php-module.blackfire.yml +++ b/docker/php-nginx-dev/ubuntu-15.10/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/php-module.blackfire.yml @@ -7,4 +7,4 @@ with_items: - /etc/php5/cli/conf.d/zz-blackfire.ini - /etc/php5/fpm/conf.d/zz-blackfire.ini - when: ansible_distribution == 'Debian' and ansible_lsb.major_release|int >= 7 + when: ansible_distribution == 'Debian' and docker_image_info_distribution_version|int >= 7 diff --git a/docker/php-nginx-dev/ubuntu-15.10/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/tools.yml b/docker/php-nginx-dev/ubuntu-15.10/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/tools.yml deleted file mode 100644 index c49cb0e34..000000000 --- a/docker/php-nginx-dev/ubuntu-15.10/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/tools.yml +++ /dev/null @@ -1,23 +0,0 @@ ---- - -- name: Downloading Tools - shell: curl -o "{{ item.dest }}" "{{ item.url }}" && chmod 755 "{{ item.dest }}" - with_items: - - { url: "https://phar.phpunit.de/phploc.phar", dest: /usr/local/bin/phploc } - - { url: "https://phar.phpunit.de/phpunit.phar", dest: /usr/local/bin/phpunit } - - { url: "http://static.pdepend.org/php/latest/pdepend.phar", dest: /usr/local/bin/pdepend } - - { url: "http://static.phpmd.org/php/latest/phpmd.phar", dest: /usr/local/bin/phpmd } - - { url: "https://squizlabs.github.io/PHP_CodeSniffer/phpcs.phar", dest: /usr/local/bin/phpcs } - - { url: "https://squizlabs.github.io/PHP_CodeSniffer/phpcbf.phar", dest: /usr/local/bin/phpcbf } - - { url: "https://phar.phpunit.de/phpcpd.phar", dest: /usr/local/bin/phpcpd } - - { url: "https://phar.phpunit.de/phpdcd.phar", dest: /usr/local/bin/phpdcd } - - { url: "https://github.com/Halleck45/PhpMetrics/raw/master/build/phpmetrics.phar", dest: /usr/local/bin/phpmetrics } - - { url: "http://get.sensiolabs.org/php-cs-fixer.phar", dest: /usr/local/bin/php-cs-fixer } - - { url: "https://github.com/sensiolabs-de/deprecation-detector/releases/download/0.1.0-alpha4/deprecation-detector.phar", dest: /usr/local/bin/deprecation-detector } - - { url: "https://github.com/sensiolabs-de/deprecation-detector/releases/download/0.1.0-alpha4/deprecation-detector.phar", dest: /usr/local/bin/deprecation-detector } - -- name: Install Tools via composer - raw: COMPOSER_HOME="/usr/local/composer" COMPOSER_BIN_DIR="/usr/local/bin" composer global require "{{ item.package }}" "{{ item.version }}" - with_items: - - { package: "sstalle/php7cc" , version: "*" } - - { package: "phpspec/phpspec" , version: "~2.0" } diff --git a/docker/php-nginx-dev/ubuntu-16.04/Dockerfile b/docker/php-nginx-dev/ubuntu-16.04/Dockerfile index 8ea4bab8e..457ca1849 100644 --- a/docker/php-nginx-dev/ubuntu-16.04/Dockerfile +++ b/docker/php-nginx-dev/ubuntu-16.04/Dockerfile @@ -5,16 +5,11 @@ FROM webdevops/php-dev:ubuntu-16.04 -MAINTAINER info@webdevops.io -LABEL vendor=WebDevOps.io -LABEL io.webdevops.layout=8 -LABEL io.webdevops.version=1.5.0 - -ENV WEB_DOCUMENT_ROOT /app -ENV WEB_DOCUMENT_INDEX index.php -ENV WEB_ALIAS_DOMAIN *.vm -ENV WEB_PHP_SOCKET 127.0.0.1:9000 -ENV WEB_NO_CACHE_PATTERN "\.(css|js|gif|png|jpg|svg|json|xml)$" +ENV WEB_DOCUMENT_ROOT=/app \ + WEB_DOCUMENT_INDEX=index.php \ + WEB_ALIAS_DOMAIN=*.vm +ENV WEB_PHP_SOCKET=127.0.0.1:9000 +ENV WEB_NO_CACHE_PATTERN="\.(css|js|gif|png|jpg|svg|json|xml)$" COPY conf/ /opt/docker/ @@ -22,7 +17,7 @@ COPY conf/ /opt/docker/ RUN /usr/local/bin/apt-install \ nginx \ && /opt/docker/bin/provision run --tag bootstrap --role webdevops-nginx --role webdevops-php-nginx --role webdevops-nginx-dev --role webdevops-php-dev \ - && /opt/docker/bin/bootstrap.sh - + && /opt/docker/bin/bootstrap.sh \ + && docker-image-cleanup EXPOSE 80 443 diff --git a/docker/php-nginx-dev/ubuntu-16.04/Dockerfile.jinja2 b/docker/php-nginx-dev/ubuntu-16.04/Dockerfile.jinja2 index 36e19f31c..12159d9f1 100644 --- a/docker/php-nginx-dev/ubuntu-16.04/Dockerfile.jinja2 +++ b/docker/php-nginx-dev/ubuntu-16.04/Dockerfile.jinja2 @@ -1,7 +1,5 @@ {{ docker.from("php-dev", "ubuntu-16.04") }} -{{ docker.version() }} - {{ environment.web() }} {{ environment.webPhp() }} {{ environment.webDevelopment() }} diff --git a/docker/php-nginx-dev/ubuntu-16.04/conf/bin/service.d/nginx.d/10-init.sh b/docker/php-nginx-dev/ubuntu-16.04/conf/bin/service.d/nginx.d/10-init.sh index 75a84a4eb..27b9776cc 100644 --- a/docker/php-nginx-dev/ubuntu-16.04/conf/bin/service.d/nginx.d/10-init.sh +++ b/docker/php-nginx-dev/ubuntu-16.04/conf/bin/service.d/nginx.d/10-init.sh @@ -8,15 +8,17 @@ fi ln -f -s /var/lib/nginx/logs /var/log/nginx # Replace markers -find /opt/docker/etc/nginx/ -iname '*.conf' -print0 | xargs -0 -r rpl --quiet "" "$WEB_DOCUMENT_INDEX" > /dev/null -find /opt/docker/etc/nginx/ -iname '*.conf' -print0 | xargs -0 -r rpl --quiet "" "$WEB_DOCUMENT_ROOT" > /dev/null -find /opt/docker/etc/nginx/ -iname '*.conf' -print0 | xargs -0 -r rpl --quiet "" "$WEB_ALIAS_DOMAIN" > /dev/null -find /opt/docker/etc/nginx/ -iname '*.conf' -print0 | xargs -0 -r rpl --quiet "" "$HOSTNAME" > /dev/null +go-replace \ + -s "" -r "$WEB_DOCUMENT_INDEX" \ + -s "" -r "$WEB_DOCUMENT_ROOT" \ + -s "" -r "$WEB_ALIAS_DOMAIN" \ + -s "" -r "$HOSTNAME" \ + -s "" -r "$WEB_PHP_SOCKET" \ + --path=/opt/docker/etc/nginx/ \ + --path-pattern='*.conf' \ + --ignore-empty -if [[ -n "${WEB_PHP_SOCKET+x}" ]]; then - ## WEB_PHP_SOCKET is set - find /opt/docker/etc/nginx/ -iname '*.conf' -print0 | xargs -0 -r rpl --quiet "" "$WEB_PHP_SOCKET" > /dev/null -else +if [[ -z "${WEB_PHP_SOCKET+x}" ]]; then ## WEB_PHP_SOCKET is not set, remove PHP files rm -f -- /opt/docker/etc/nginx/conf.d/10-php.conf rm -f -- /opt/docker/etc/nginx/vhost.common.d/10-php.conf diff --git a/docker/php-nginx-dev/ubuntu-16.04/conf/bin/service.d/nginx.d/12-development.sh b/docker/php-nginx-dev/ubuntu-16.04/conf/bin/service.d/nginx.d/12-development.sh index fa4b601a9..f4695f059 100644 --- a/docker/php-nginx-dev/ubuntu-16.04/conf/bin/service.d/nginx.d/12-development.sh +++ b/docker/php-nginx-dev/ubuntu-16.04/conf/bin/service.d/nginx.d/12-development.sh @@ -1 +1,7 @@ -find /opt/docker/etc/nginx/ -iname '*.conf' -print0 | xargs -0 -r rpl --quiet "" "$WEB_NO_CACHE_PATTERN" > /dev/null +go-replace \ + -s "" \ + -r "$WEB_NO_CACHE_PATTERN" \ + --path=/opt/docker/etc/nginx/ \ + --path-pattern='*.conf' \ + --ignore-empty + diff --git a/docker/php-nginx-dev/ubuntu-16.04/conf/etc/nginx/vhost.common.d/10-general.conf b/docker/php-nginx-dev/ubuntu-16.04/conf/etc/nginx/vhost.common.d/10-general.conf new file mode 100644 index 000000000..d3fd0aa5e --- /dev/null +++ b/docker/php-nginx-dev/ubuntu-16.04/conf/etc/nginx/vhost.common.d/10-general.conf @@ -0,0 +1 @@ +client_max_body_size 50m; diff --git a/docker/php-nginx-dev/ubuntu-16.04/conf/etc/nginx/vhost.common.d/10-log.conf b/docker/php-nginx-dev/ubuntu-16.04/conf/etc/nginx/vhost.common.d/10-log.conf new file mode 100644 index 000000000..a2cd929e7 --- /dev/null +++ b/docker/php-nginx-dev/ubuntu-16.04/conf/etc/nginx/vhost.common.d/10-log.conf @@ -0,0 +1,2 @@ +access_log /docker.stdout; +error_log /docker.stderr info; diff --git a/docker/php-nginx-dev/ubuntu-16.04/conf/etc/nginx/vhost.conf b/docker/php-nginx-dev/ubuntu-16.04/conf/etc/nginx/vhost.conf index d07e27094..8225f314a 100644 --- a/docker/php-nginx-dev/ubuntu-16.04/conf/etc/nginx/vhost.conf +++ b/docker/php-nginx-dev/ubuntu-16.04/conf/etc/nginx/vhost.conf @@ -1,17 +1,11 @@ server { - listen 80 default_server; - listen 8000 default_server; + listen 80 default_server; server_name _ docker; - access_log /docker.stdout; - error_log /docker.stdout info; - root ""; index ; - client_max_body_size 50m; - include /opt/docker/etc/nginx/vhost.common.d/*.conf; } @@ -20,19 +14,13 @@ server { ############## server { - listen 443 default_server; - listen 8443 default_server; + listen 443 default_server; server_name _ docker; - access_log /docker.stdout; - error_log /docker.stdout info; - root ""; index ; - client_max_body_size 50m; - include /opt/docker/etc/nginx/vhost.common.d/*.conf; include /opt/docker/etc/nginx/vhost.ssl.conf; } diff --git a/docker/php-nginx-dev/ubuntu-16.04/conf/provision/entrypoint.d/10-php-debugger.sh b/docker/php-nginx-dev/ubuntu-16.04/conf/provision/entrypoint.d/10-php-debugger.sh index 7156e28aa..b5985a9ef 100644 --- a/docker/php-nginx-dev/ubuntu-16.04/conf/provision/entrypoint.d/10-php-debugger.sh +++ b/docker/php-nginx-dev/ubuntu-16.04/conf/provision/entrypoint.d/10-php-debugger.sh @@ -15,7 +15,8 @@ PHP_CONF_PATHS=" /etc/php5/fpm/conf.d /etc/php/7.0/mods-available /etc/php/7.0/cli/conf.d -/etc/php/7.0/fpm/conf.d" +/etc/php/7.0/fpm/conf.d +/usr/local/etc/php/conf.d/" function phpModuleRemove() { if [ "$#" -ne 1 ]; then @@ -40,7 +41,7 @@ if [[ -n "${PHP_DEBUGGER+x}" ]]; then blackfire) echo "PHP-Debugger: Blackfire enabled" phpModuleRemove "xdebug" - /opt/docker/bin/control.sh service.enable blackfire-agent + docker-service-enable blackfire-agent ;; none) diff --git a/docker/php-nginx-dev/ubuntu-16.04/conf/provision/roles/webdevops-php-dev/tasks/bootstrap.yml b/docker/php-nginx-dev/ubuntu-16.04/conf/provision/roles/webdevops-php-dev/tasks/bootstrap.yml index 2c5d76e3d..ff02b05fc 100644 --- a/docker/php-nginx-dev/ubuntu-16.04/conf/provision/roles/webdevops-php-dev/tasks/bootstrap.yml +++ b/docker/php-nginx-dev/ubuntu-16.04/conf/provision/roles/webdevops-php-dev/tasks/bootstrap.yml @@ -1,6 +1,5 @@ --- -- include: bootstrap/tools.yml - include: bootstrap/php-fpm.yml - include: bootstrap/php-module.yml - include: bootstrap/php-module.opcache.yml diff --git a/docker/php-nginx-dev/ubuntu-16.04/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/php-module.blackfire.yml b/docker/php-nginx-dev/ubuntu-16.04/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/php-module.blackfire.yml index 1a3db9bac..faf05f8de 100644 --- a/docker/php-nginx-dev/ubuntu-16.04/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/php-module.blackfire.yml +++ b/docker/php-nginx-dev/ubuntu-16.04/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/php-module.blackfire.yml @@ -7,4 +7,4 @@ with_items: - /etc/php5/cli/conf.d/zz-blackfire.ini - /etc/php5/fpm/conf.d/zz-blackfire.ini - when: ansible_distribution == 'Debian' and ansible_lsb.major_release|int >= 7 + when: ansible_distribution == 'Debian' and docker_image_info_distribution_version|int >= 7 diff --git a/docker/php-nginx-dev/ubuntu-16.04/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/tools.yml b/docker/php-nginx-dev/ubuntu-16.04/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/tools.yml deleted file mode 100644 index c49cb0e34..000000000 --- a/docker/php-nginx-dev/ubuntu-16.04/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/tools.yml +++ /dev/null @@ -1,23 +0,0 @@ ---- - -- name: Downloading Tools - shell: curl -o "{{ item.dest }}" "{{ item.url }}" && chmod 755 "{{ item.dest }}" - with_items: - - { url: "https://phar.phpunit.de/phploc.phar", dest: /usr/local/bin/phploc } - - { url: "https://phar.phpunit.de/phpunit.phar", dest: /usr/local/bin/phpunit } - - { url: "http://static.pdepend.org/php/latest/pdepend.phar", dest: /usr/local/bin/pdepend } - - { url: "http://static.phpmd.org/php/latest/phpmd.phar", dest: /usr/local/bin/phpmd } - - { url: "https://squizlabs.github.io/PHP_CodeSniffer/phpcs.phar", dest: /usr/local/bin/phpcs } - - { url: "https://squizlabs.github.io/PHP_CodeSniffer/phpcbf.phar", dest: /usr/local/bin/phpcbf } - - { url: "https://phar.phpunit.de/phpcpd.phar", dest: /usr/local/bin/phpcpd } - - { url: "https://phar.phpunit.de/phpdcd.phar", dest: /usr/local/bin/phpdcd } - - { url: "https://github.com/Halleck45/PhpMetrics/raw/master/build/phpmetrics.phar", dest: /usr/local/bin/phpmetrics } - - { url: "http://get.sensiolabs.org/php-cs-fixer.phar", dest: /usr/local/bin/php-cs-fixer } - - { url: "https://github.com/sensiolabs-de/deprecation-detector/releases/download/0.1.0-alpha4/deprecation-detector.phar", dest: /usr/local/bin/deprecation-detector } - - { url: "https://github.com/sensiolabs-de/deprecation-detector/releases/download/0.1.0-alpha4/deprecation-detector.phar", dest: /usr/local/bin/deprecation-detector } - -- name: Install Tools via composer - raw: COMPOSER_HOME="/usr/local/composer" COMPOSER_BIN_DIR="/usr/local/bin" composer global require "{{ item.package }}" "{{ item.version }}" - with_items: - - { package: "sstalle/php7cc" , version: "*" } - - { package: "phpspec/phpspec" , version: "~2.0" } diff --git a/docker/php-nginx-dev/ubuntu-16.10/Dockerfile b/docker/php-nginx-dev/ubuntu-16.10/Dockerfile index 12ce1c9a9..a4094fe84 100644 --- a/docker/php-nginx-dev/ubuntu-16.10/Dockerfile +++ b/docker/php-nginx-dev/ubuntu-16.10/Dockerfile @@ -5,16 +5,11 @@ FROM webdevops/php-dev:ubuntu-16.10 -MAINTAINER info@webdevops.io -LABEL vendor=WebDevOps.io -LABEL io.webdevops.layout=8 -LABEL io.webdevops.version=1.5.0 - -ENV WEB_DOCUMENT_ROOT /app -ENV WEB_DOCUMENT_INDEX index.php -ENV WEB_ALIAS_DOMAIN *.vm -ENV WEB_PHP_SOCKET 127.0.0.1:9000 -ENV WEB_NO_CACHE_PATTERN "\.(css|js|gif|png|jpg|svg|json|xml)$" +ENV WEB_DOCUMENT_ROOT=/app \ + WEB_DOCUMENT_INDEX=index.php \ + WEB_ALIAS_DOMAIN=*.vm +ENV WEB_PHP_SOCKET=127.0.0.1:9000 +ENV WEB_NO_CACHE_PATTERN="\.(css|js|gif|png|jpg|svg|json|xml)$" COPY conf/ /opt/docker/ @@ -22,7 +17,7 @@ COPY conf/ /opt/docker/ RUN /usr/local/bin/apt-install \ nginx \ && /opt/docker/bin/provision run --tag bootstrap --role webdevops-nginx --role webdevops-php-nginx --role webdevops-nginx-dev --role webdevops-php-dev \ - && /opt/docker/bin/bootstrap.sh - + && /opt/docker/bin/bootstrap.sh \ + && docker-image-cleanup EXPOSE 80 443 diff --git a/docker/php-nginx-dev/ubuntu-16.10/Dockerfile.jinja2 b/docker/php-nginx-dev/ubuntu-16.10/Dockerfile.jinja2 index d1d748ffd..1d3be3a9d 100644 --- a/docker/php-nginx-dev/ubuntu-16.10/Dockerfile.jinja2 +++ b/docker/php-nginx-dev/ubuntu-16.10/Dockerfile.jinja2 @@ -1,7 +1,5 @@ {{ docker.from("php-dev", "ubuntu-16.10") }} -{{ docker.version() }} - {{ environment.web() }} {{ environment.webPhp() }} {{ environment.webDevelopment() }} diff --git a/docker/php-nginx-dev/ubuntu-16.10/conf/bin/service.d/nginx.d/10-init.sh b/docker/php-nginx-dev/ubuntu-16.10/conf/bin/service.d/nginx.d/10-init.sh index 75a84a4eb..27b9776cc 100644 --- a/docker/php-nginx-dev/ubuntu-16.10/conf/bin/service.d/nginx.d/10-init.sh +++ b/docker/php-nginx-dev/ubuntu-16.10/conf/bin/service.d/nginx.d/10-init.sh @@ -8,15 +8,17 @@ fi ln -f -s /var/lib/nginx/logs /var/log/nginx # Replace markers -find /opt/docker/etc/nginx/ -iname '*.conf' -print0 | xargs -0 -r rpl --quiet "" "$WEB_DOCUMENT_INDEX" > /dev/null -find /opt/docker/etc/nginx/ -iname '*.conf' -print0 | xargs -0 -r rpl --quiet "" "$WEB_DOCUMENT_ROOT" > /dev/null -find /opt/docker/etc/nginx/ -iname '*.conf' -print0 | xargs -0 -r rpl --quiet "" "$WEB_ALIAS_DOMAIN" > /dev/null -find /opt/docker/etc/nginx/ -iname '*.conf' -print0 | xargs -0 -r rpl --quiet "" "$HOSTNAME" > /dev/null +go-replace \ + -s "" -r "$WEB_DOCUMENT_INDEX" \ + -s "" -r "$WEB_DOCUMENT_ROOT" \ + -s "" -r "$WEB_ALIAS_DOMAIN" \ + -s "" -r "$HOSTNAME" \ + -s "" -r "$WEB_PHP_SOCKET" \ + --path=/opt/docker/etc/nginx/ \ + --path-pattern='*.conf' \ + --ignore-empty -if [[ -n "${WEB_PHP_SOCKET+x}" ]]; then - ## WEB_PHP_SOCKET is set - find /opt/docker/etc/nginx/ -iname '*.conf' -print0 | xargs -0 -r rpl --quiet "" "$WEB_PHP_SOCKET" > /dev/null -else +if [[ -z "${WEB_PHP_SOCKET+x}" ]]; then ## WEB_PHP_SOCKET is not set, remove PHP files rm -f -- /opt/docker/etc/nginx/conf.d/10-php.conf rm -f -- /opt/docker/etc/nginx/vhost.common.d/10-php.conf diff --git a/docker/php-nginx-dev/ubuntu-16.10/conf/bin/service.d/nginx.d/12-development.sh b/docker/php-nginx-dev/ubuntu-16.10/conf/bin/service.d/nginx.d/12-development.sh index fa4b601a9..f4695f059 100644 --- a/docker/php-nginx-dev/ubuntu-16.10/conf/bin/service.d/nginx.d/12-development.sh +++ b/docker/php-nginx-dev/ubuntu-16.10/conf/bin/service.d/nginx.d/12-development.sh @@ -1 +1,7 @@ -find /opt/docker/etc/nginx/ -iname '*.conf' -print0 | xargs -0 -r rpl --quiet "" "$WEB_NO_CACHE_PATTERN" > /dev/null +go-replace \ + -s "" \ + -r "$WEB_NO_CACHE_PATTERN" \ + --path=/opt/docker/etc/nginx/ \ + --path-pattern='*.conf' \ + --ignore-empty + diff --git a/docker/php-nginx-dev/ubuntu-16.10/conf/etc/nginx/vhost.common.d/10-general.conf b/docker/php-nginx-dev/ubuntu-16.10/conf/etc/nginx/vhost.common.d/10-general.conf new file mode 100644 index 000000000..d3fd0aa5e --- /dev/null +++ b/docker/php-nginx-dev/ubuntu-16.10/conf/etc/nginx/vhost.common.d/10-general.conf @@ -0,0 +1 @@ +client_max_body_size 50m; diff --git a/docker/php-nginx-dev/ubuntu-16.10/conf/etc/nginx/vhost.common.d/10-log.conf b/docker/php-nginx-dev/ubuntu-16.10/conf/etc/nginx/vhost.common.d/10-log.conf new file mode 100644 index 000000000..a2cd929e7 --- /dev/null +++ b/docker/php-nginx-dev/ubuntu-16.10/conf/etc/nginx/vhost.common.d/10-log.conf @@ -0,0 +1,2 @@ +access_log /docker.stdout; +error_log /docker.stderr info; diff --git a/docker/php-nginx-dev/ubuntu-16.10/conf/etc/nginx/vhost.conf b/docker/php-nginx-dev/ubuntu-16.10/conf/etc/nginx/vhost.conf index d07e27094..8225f314a 100644 --- a/docker/php-nginx-dev/ubuntu-16.10/conf/etc/nginx/vhost.conf +++ b/docker/php-nginx-dev/ubuntu-16.10/conf/etc/nginx/vhost.conf @@ -1,17 +1,11 @@ server { - listen 80 default_server; - listen 8000 default_server; + listen 80 default_server; server_name _ docker; - access_log /docker.stdout; - error_log /docker.stdout info; - root ""; index ; - client_max_body_size 50m; - include /opt/docker/etc/nginx/vhost.common.d/*.conf; } @@ -20,19 +14,13 @@ server { ############## server { - listen 443 default_server; - listen 8443 default_server; + listen 443 default_server; server_name _ docker; - access_log /docker.stdout; - error_log /docker.stdout info; - root ""; index ; - client_max_body_size 50m; - include /opt/docker/etc/nginx/vhost.common.d/*.conf; include /opt/docker/etc/nginx/vhost.ssl.conf; } diff --git a/docker/php-nginx-dev/ubuntu-16.10/conf/provision/entrypoint.d/10-php-debugger.sh b/docker/php-nginx-dev/ubuntu-16.10/conf/provision/entrypoint.d/10-php-debugger.sh index 7156e28aa..b5985a9ef 100644 --- a/docker/php-nginx-dev/ubuntu-16.10/conf/provision/entrypoint.d/10-php-debugger.sh +++ b/docker/php-nginx-dev/ubuntu-16.10/conf/provision/entrypoint.d/10-php-debugger.sh @@ -15,7 +15,8 @@ PHP_CONF_PATHS=" /etc/php5/fpm/conf.d /etc/php/7.0/mods-available /etc/php/7.0/cli/conf.d -/etc/php/7.0/fpm/conf.d" +/etc/php/7.0/fpm/conf.d +/usr/local/etc/php/conf.d/" function phpModuleRemove() { if [ "$#" -ne 1 ]; then @@ -40,7 +41,7 @@ if [[ -n "${PHP_DEBUGGER+x}" ]]; then blackfire) echo "PHP-Debugger: Blackfire enabled" phpModuleRemove "xdebug" - /opt/docker/bin/control.sh service.enable blackfire-agent + docker-service-enable blackfire-agent ;; none) diff --git a/docker/php-nginx-dev/ubuntu-16.10/conf/provision/roles/webdevops-php-dev/tasks/bootstrap.yml b/docker/php-nginx-dev/ubuntu-16.10/conf/provision/roles/webdevops-php-dev/tasks/bootstrap.yml index 2c5d76e3d..ff02b05fc 100644 --- a/docker/php-nginx-dev/ubuntu-16.10/conf/provision/roles/webdevops-php-dev/tasks/bootstrap.yml +++ b/docker/php-nginx-dev/ubuntu-16.10/conf/provision/roles/webdevops-php-dev/tasks/bootstrap.yml @@ -1,6 +1,5 @@ --- -- include: bootstrap/tools.yml - include: bootstrap/php-fpm.yml - include: bootstrap/php-module.yml - include: bootstrap/php-module.opcache.yml diff --git a/docker/php-nginx-dev/ubuntu-16.10/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/php-module.blackfire.yml b/docker/php-nginx-dev/ubuntu-16.10/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/php-module.blackfire.yml index 1a3db9bac..faf05f8de 100644 --- a/docker/php-nginx-dev/ubuntu-16.10/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/php-module.blackfire.yml +++ b/docker/php-nginx-dev/ubuntu-16.10/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/php-module.blackfire.yml @@ -7,4 +7,4 @@ with_items: - /etc/php5/cli/conf.d/zz-blackfire.ini - /etc/php5/fpm/conf.d/zz-blackfire.ini - when: ansible_distribution == 'Debian' and ansible_lsb.major_release|int >= 7 + when: ansible_distribution == 'Debian' and docker_image_info_distribution_version|int >= 7 diff --git a/docker/php-nginx-dev/ubuntu-16.10/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/tools.yml b/docker/php-nginx-dev/ubuntu-16.10/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/tools.yml deleted file mode 100644 index c49cb0e34..000000000 --- a/docker/php-nginx-dev/ubuntu-16.10/conf/provision/roles/webdevops-php-dev/tasks/bootstrap/tools.yml +++ /dev/null @@ -1,23 +0,0 @@ ---- - -- name: Downloading Tools - shell: curl -o "{{ item.dest }}" "{{ item.url }}" && chmod 755 "{{ item.dest }}" - with_items: - - { url: "https://phar.phpunit.de/phploc.phar", dest: /usr/local/bin/phploc } - - { url: "https://phar.phpunit.de/phpunit.phar", dest: /usr/local/bin/phpunit } - - { url: "http://static.pdepend.org/php/latest/pdepend.phar", dest: /usr/local/bin/pdepend } - - { url: "http://static.phpmd.org/php/latest/phpmd.phar", dest: /usr/local/bin/phpmd } - - { url: "https://squizlabs.github.io/PHP_CodeSniffer/phpcs.phar", dest: /usr/local/bin/phpcs } - - { url: "https://squizlabs.github.io/PHP_CodeSniffer/phpcbf.phar", dest: /usr/local/bin/phpcbf } - - { url: "https://phar.phpunit.de/phpcpd.phar", dest: /usr/local/bin/phpcpd } - - { url: "https://phar.phpunit.de/phpdcd.phar", dest: /usr/local/bin/phpdcd } - - { url: "https://github.com/Halleck45/PhpMetrics/raw/master/build/phpmetrics.phar", dest: /usr/local/bin/phpmetrics } - - { url: "http://get.sensiolabs.org/php-cs-fixer.phar", dest: /usr/local/bin/php-cs-fixer } - - { url: "https://github.com/sensiolabs-de/deprecation-detector/releases/download/0.1.0-alpha4/deprecation-detector.phar", dest: /usr/local/bin/deprecation-detector } - - { url: "https://github.com/sensiolabs-de/deprecation-detector/releases/download/0.1.0-alpha4/deprecation-detector.phar", dest: /usr/local/bin/deprecation-detector } - -- name: Install Tools via composer - raw: COMPOSER_HOME="/usr/local/composer" COMPOSER_BIN_DIR="/usr/local/bin" composer global require "{{ item.package }}" "{{ item.version }}" - with_items: - - { package: "sstalle/php7cc" , version: "*" } - - { package: "phpspec/phpspec" , version: "~2.0" } diff --git a/docker/php-nginx/5.6/Dockerfile b/docker/php-nginx/5.6/Dockerfile new file mode 100644 index 000000000..c4f345681 --- /dev/null +++ b/docker/php-nginx/5.6/Dockerfile @@ -0,0 +1,22 @@ +#+++++++++++++++++++++++++++++++++++++++ +# Dockerfile for webdevops/php-nginx:5.6 +# -- automatically generated -- +#+++++++++++++++++++++++++++++++++++++++ + +FROM webdevops/php:5.6 + +ENV WEB_DOCUMENT_ROOT=/app \ + WEB_DOCUMENT_INDEX=index.php \ + WEB_ALIAS_DOMAIN=*.vm +ENV WEB_PHP_SOCKET=127.0.0.1:9000 + +COPY conf/ /opt/docker/ + +# Install nginx +RUN /usr/local/bin/apt-install \ + nginx \ + && /opt/docker/bin/provision run --tag bootstrap --role webdevops-nginx --role webdevops-php-nginx \ + && /opt/docker/bin/bootstrap.sh \ + && docker-image-cleanup + +EXPOSE 80 443 diff --git a/docker/php-nginx/5.6/Dockerfile.jinja2 b/docker/php-nginx/5.6/Dockerfile.jinja2 new file mode 100644 index 000000000..26aef0546 --- /dev/null +++ b/docker/php-nginx/5.6/Dockerfile.jinja2 @@ -0,0 +1,10 @@ +{{ docker.from("php", "5.6") }} + +{{ environment.web() }} +{{ environment.webPhp() }} + +{{ docker.copy('conf/', '/opt/docker/') }} + +{{ nginx.debian('php-nginx') }} + +{{ docker.expose('80 443') }} diff --git a/docker/php-nginx/5.6/conf/bin/service.d/nginx.d/10-init.sh b/docker/php-nginx/5.6/conf/bin/service.d/nginx.d/10-init.sh new file mode 100644 index 000000000..27b9776cc --- /dev/null +++ b/docker/php-nginx/5.6/conf/bin/service.d/nginx.d/10-init.sh @@ -0,0 +1,25 @@ +if [[ ! -e "$WEB_DOCUMENT_ROOT" ]]; then + echo "" + echo "[WARNING] WEB_DOCUMENT_ROOT does not exists with path \"$WEB_DOCUMENT_ROOT\"!" + echo "" +fi + +# Prevent startup of nginx (ubuntu 16.04 needs it) +ln -f -s /var/lib/nginx/logs /var/log/nginx + +# Replace markers +go-replace \ + -s "" -r "$WEB_DOCUMENT_INDEX" \ + -s "" -r "$WEB_DOCUMENT_ROOT" \ + -s "" -r "$WEB_ALIAS_DOMAIN" \ + -s "" -r "$HOSTNAME" \ + -s "" -r "$WEB_PHP_SOCKET" \ + --path=/opt/docker/etc/nginx/ \ + --path-pattern='*.conf' \ + --ignore-empty + +if [[ -z "${WEB_PHP_SOCKET+x}" ]]; then + ## WEB_PHP_SOCKET is not set, remove PHP files + rm -f -- /opt/docker/etc/nginx/conf.d/10-php.conf + rm -f -- /opt/docker/etc/nginx/vhost.common.d/10-php.conf +fi diff --git a/docker/php-nginx/5.6/conf/bin/service.d/nginx.sh b/docker/php-nginx/5.6/conf/bin/service.d/nginx.sh new file mode 100644 index 000000000..f5cd26167 --- /dev/null +++ b/docker/php-nginx/5.6/conf/bin/service.d/nginx.sh @@ -0,0 +1,7 @@ +#!/usr/bin/env bash + +source /opt/docker/bin/config.sh + +includeScriptDir "/opt/docker/bin/service.d/nginx.d/" + +exec /usr/sbin/nginx diff --git a/docker/php-nginx/5.6/conf/etc/nginx/conf.d/.gitkeep b/docker/php-nginx/5.6/conf/etc/nginx/conf.d/.gitkeep new file mode 100644 index 000000000..e69de29bb diff --git a/docker/php-nginx/5.6/conf/etc/nginx/conf.d/10-php.conf b/docker/php-nginx/5.6/conf/etc/nginx/conf.d/10-php.conf new file mode 100644 index 000000000..9abe45f0a --- /dev/null +++ b/docker/php-nginx/5.6/conf/etc/nginx/conf.d/10-php.conf @@ -0,0 +1,3 @@ +upstream php { + server ; +} diff --git a/docker/php-nginx/5.6/conf/etc/nginx/global.conf b/docker/php-nginx/5.6/conf/etc/nginx/global.conf new file mode 100644 index 000000000..b6141db09 --- /dev/null +++ b/docker/php-nginx/5.6/conf/etc/nginx/global.conf @@ -0,0 +1 @@ +# deprecated diff --git a/docker/php-nginx/5.6/conf/etc/nginx/main.conf b/docker/php-nginx/5.6/conf/etc/nginx/main.conf new file mode 100644 index 000000000..06de0651b --- /dev/null +++ b/docker/php-nginx/5.6/conf/etc/nginx/main.conf @@ -0,0 +1,4 @@ +include /opt/docker/etc/nginx/global.conf; +include /opt/docker/etc/nginx/php.conf; +include /opt/docker/etc/nginx/conf.d/*.conf; +include /opt/docker/etc/nginx/vhost.conf; diff --git a/docker/php-nginx/5.6/conf/etc/nginx/php.conf b/docker/php-nginx/5.6/conf/etc/nginx/php.conf new file mode 100644 index 000000000..b6141db09 --- /dev/null +++ b/docker/php-nginx/5.6/conf/etc/nginx/php.conf @@ -0,0 +1 @@ +# deprecated diff --git a/docker/php-nginx/5.6/conf/etc/nginx/ssl/server.crt b/docker/php-nginx/5.6/conf/etc/nginx/ssl/server.crt new file mode 100644 index 000000000..6b0694907 --- /dev/null +++ b/docker/php-nginx/5.6/conf/etc/nginx/ssl/server.crt @@ -0,0 +1,28 @@ +-----BEGIN CERTIFICATE----- +MIIE1DCCArwCCQDMMwGnSuK0tTANBgkqhkiG9w0BAQsFADAsMRswGQYDVQQKExJE +b2NrZXIgQm9pbGVycGxhdGUxDTALBgNVBAMUBCoudm0wHhcNMTUwNTA0MTcxNDQw +WhcNMjUwNTAxMTcxNDQwWjAsMRswGQYDVQQKExJEb2NrZXIgQm9pbGVycGxhdGUx +DTALBgNVBAMUBCoudm0wggIiMA0GCSqGSIb3DQEBAQUAA4ICDwAwggIKAoICAQDK +3TIUiyDvXelWeY9VXMrpjuZtYpVSDsACLpjFUhMnsP5/iKT0VbeZyqHvmwZjAg4G +Y10d+yZDdgv/xeu0HPOFbtR6pCp10d1tdLHZto5Cyuxu7IQsAVjnD6Ko7XFwtNk7 +9o6JZfAFaGL4w5MokrVmCtspnsMZH7/7zU4f96cbF39zLopnpuXGD6t6DA8Qj3gy +0duaTjs42bYRN+rwLzVKAev99iQ4kPMJn4vV6/Xk6rtoSzC67GQyVZYaFypicD1S +NtsRmgEVvjCBDbrLOneUiRwff6qxEsZi7Hxv7BKFj4iUWnII7K/nP7T6uBHQjHO+ +FpsGkU9lCMrCeVFBe8kKz/cbhd+yLUxXwAPr6gSOPmwn232Gy4tozvqZHpbUxsgx +7sT3ej9K66h1D7J+BjNFWYM1hbnC1r7H/xS7EBzBV8qRoQCVe08Juf5xsouXFakD +clLV4+L+1cxkpwsCQDly5g3tm/TBqA2O+ZJ+YHQDHKkzMyhLs6i0X/M5qvJBiLg1 +GLTCS20rpQ5gXTEGuINqHgwXQWkUO6bhgSYqdHGX3zbZ5+qWpI4eui3dHZ1Ll0VH +6Icpb7ORTQwhc6W8KBlybssYPSlGOEBGUjYGNheoz9FpoSkxCis+P8ZNKtrmpPoq +Su0eOOGFOFHG02eOgPVxSwrDeN9MVJo7BPysGMHJmQIDAQABMA0GCSqGSIb3DQEB +CwUAA4ICAQC63g6NHmQKbiy3G6iaDkpUSbr5Mq2YgU61XnvWVyREqDcy/BXCw9oY +SJ/KUvCpqPnACNOFqjadRAmPiA9nf2WduoCgwQGV/YRFGswSuVvh/3X2TX5NWvbS +t8MQDttQg1dxpiMUjlu3rqhfohBdWJvp2lVSdpDb/MOlXBc/+p7HfOHwhqB7wwPN +NNbSKUbZqZxmD8cOf1X0hASr1yfFPj+2vST3ESaON8S0T2p63YX/sD5jvOUiEuyw +I5WcvLmiRZA07SH8nWyckLY3qWL+OlhSZrlAnolWS00b+7h5LNuRYEjKzwVgntoA +aCopyQih6wIk0+AfJO4sfhJBmQhnIrAaP/zwBH5g9zVizLf5H7U+hNXrMwgw55Sq +vjMdkZHvPKUXTvVit/rYE9H+PY3brkRWzOl4V/i/ZLJJm5805H/NyTbz9kPMJw2Q +nn+KOpfXXySD39f8iuRgSKXsYNul38hxWgcZZ6g+sOOp2n/VUmf0eZUWNnJ8i7AP +4Qif7aDKMcibOwSwsB+DKZXDvZ5XSdnMphtuLS5rPSL81rVRmWC2DMfQ2eP8j0WN +VTroSk0xedQ7Qr+9TNooi9IyzX6n1a2S1UiciEZ3ZcDbXPl/P01m+IYZyPnLv0+9 +ZeioZYh1JLv3/OKsMrMLTfh2ZCj3aXwmc2Owi/wU2LS5QUOMcHH7CQ== +-----END CERTIFICATE----- \ No newline at end of file diff --git a/docker/php-nginx/5.6/conf/etc/nginx/ssl/server.csr b/docker/php-nginx/5.6/conf/etc/nginx/ssl/server.csr new file mode 100644 index 000000000..8a9909f77 --- /dev/null +++ b/docker/php-nginx/5.6/conf/etc/nginx/ssl/server.csr @@ -0,0 +1,26 @@ +-----BEGIN CERTIFICATE REQUEST----- +MIIEcTCCAlkCAQAwLDEbMBkGA1UEChMSRG9ja2VyIEJvaWxlcnBsYXRlMQ0wCwYD +VQQDFAQqLnZtMIICIjANBgkqhkiG9w0BAQEFAAOCAg8AMIICCgKCAgEAyt0yFIsg +713pVnmPVVzK6Y7mbWKVUg7AAi6YxVITJ7D+f4ik9FW3mcqh75sGYwIOBmNdHfsm +Q3YL/8XrtBzzhW7UeqQqddHdbXSx2baOQsrsbuyELAFY5w+iqO1xcLTZO/aOiWXw +BWhi+MOTKJK1ZgrbKZ7DGR+/+81OH/enGxd/cy6KZ6blxg+regwPEI94MtHbmk47 +ONm2ETfq8C81SgHr/fYkOJDzCZ+L1ev15Oq7aEswuuxkMlWWGhcqYnA9UjbbEZoB +Fb4wgQ26yzp3lIkcH3+qsRLGYux8b+wShY+IlFpyCOyv5z+0+rgR0IxzvhabBpFP +ZQjKwnlRQXvJCs/3G4Xfsi1MV8AD6+oEjj5sJ9t9hsuLaM76mR6W1MbIMe7E93o/ +SuuodQ+yfgYzRVmDNYW5wta+x/8UuxAcwVfKkaEAlXtPCbn+cbKLlxWpA3JS1ePi +/tXMZKcLAkA5cuYN7Zv0wagNjvmSfmB0AxypMzMoS7OotF/zOaryQYi4NRi0wktt +K6UOYF0xBriDah4MF0FpFDum4YEmKnRxl9822efqlqSOHrot3R2dS5dFR+iHKW+z +kU0MIXOlvCgZcm7LGD0pRjhARlI2BjYXqM/RaaEpMQorPj/GTSra5qT6KkrtHjjh +hThRxtNnjoD1cUsKw3jfTFSaOwT8rBjByZkCAwEAAaAAMA0GCSqGSIb3DQEBCwUA +A4ICAQBsEBgC2YepuZq/8UqvKMZKVy/etDKXj7BB+QPb+leNiKD7p4LDxHJsZSH8 +Ku9uMPeLfiQDn5jA41k5SlGttzvObd65RdEbO3yHpqsg05EGSDDLfaE1k2Al/qmX +/o8roPZF7+2kZthgMAgkcokS54LYqEYTGqOf3J9Ss0yRIZwhaOVebfFIbIOdpw0B +JNMIJPHTMdZrcuRVI+wR1uPLIlEJzBvxTGbTrvPU25WJFtu+EajKqXO0SHdy0yx8 +uH4ykRBJRc36+oYo7nZ5D56dh7pZn3+9J64FKAOV0Q3KqMFieGy053ezuhJd70eZ +UozTgfjs3WpMzoYmKETSyl3XZSdInRe+sUlKPruTsKyg69oYxjPlrGfAmmGcCFca +TnZinT18dI92zK7OtOVkmYeYKC1lwuhftVrNMXzZuHOGpS9NNYtc4nDqDMIEOfV3 +6rCdu03WjEgJ+Z67tJs16xOx9du4/EHxS2Ijn9DPfVJvYy0TgzDi1BUpjWx0KTLx +C4OQbEZ/QTWmHVbSch/hcZhzbf7SNh5RpnW4EtmcpDFjIKMfxJmoKeiTf7qnilx0 +7uRvsZFKoDKRDOFiPfgMg5AOtLHziYsd9m0tJjC2GHvFuPjzOtzhnUUjmmvht170 +2aqKakjST4amg7jzLcs871HX0/WjOtt29NpOz140blkKf1bisg== +-----END CERTIFICATE REQUEST----- \ No newline at end of file diff --git a/docker/php-nginx/5.6/conf/etc/nginx/ssl/server.key b/docker/php-nginx/5.6/conf/etc/nginx/ssl/server.key new file mode 100644 index 000000000..c9eec145f --- /dev/null +++ b/docker/php-nginx/5.6/conf/etc/nginx/ssl/server.key @@ -0,0 +1,51 @@ +-----BEGIN RSA PRIVATE KEY----- +MIIJKAIBAAKCAgEAyt0yFIsg713pVnmPVVzK6Y7mbWKVUg7AAi6YxVITJ7D+f4ik +9FW3mcqh75sGYwIOBmNdHfsmQ3YL/8XrtBzzhW7UeqQqddHdbXSx2baOQsrsbuyE +LAFY5w+iqO1xcLTZO/aOiWXwBWhi+MOTKJK1ZgrbKZ7DGR+/+81OH/enGxd/cy6K +Z6blxg+regwPEI94MtHbmk47ONm2ETfq8C81SgHr/fYkOJDzCZ+L1ev15Oq7aEsw +uuxkMlWWGhcqYnA9UjbbEZoBFb4wgQ26yzp3lIkcH3+qsRLGYux8b+wShY+IlFpy +COyv5z+0+rgR0IxzvhabBpFPZQjKwnlRQXvJCs/3G4Xfsi1MV8AD6+oEjj5sJ9t9 +hsuLaM76mR6W1MbIMe7E93o/SuuodQ+yfgYzRVmDNYW5wta+x/8UuxAcwVfKkaEA +lXtPCbn+cbKLlxWpA3JS1ePi/tXMZKcLAkA5cuYN7Zv0wagNjvmSfmB0AxypMzMo +S7OotF/zOaryQYi4NRi0wkttK6UOYF0xBriDah4MF0FpFDum4YEmKnRxl9822efq +lqSOHrot3R2dS5dFR+iHKW+zkU0MIXOlvCgZcm7LGD0pRjhARlI2BjYXqM/RaaEp +MQorPj/GTSra5qT6KkrtHjjhhThRxtNnjoD1cUsKw3jfTFSaOwT8rBjByZkCAwEA +AQKCAgAbZPdoUsllyZbC+LNkYZ19ILD5QIDNjfRb1xMGQmkXyQz1B+zOmeyrNfPc +OWEJabOfJTfj3pByN7SzG3US4333HNpQnW6mbmqqZ0HFFqPrXR/Ecuf+UUhCG5hp +m3bgM2vKbyccYsmg0VHcKfzrU7RvTTP/UNMjx2fThwvvwS+ttuSdF0HVcXJB5sfP +OWWnZNhkdHZlRf81VCED/jsZqCZYEh5eMyj9AoXvXL4zayPPf+tC0DSKaXW2Xlxg +tZQhqup8+a9nlxZia0Z9hu8clo6jXkiP8FuKgfCMV0cOjiCKLLHS5svTbLLsVWwJ +F2ZAdVcD6mWQ43qHOEK5NEzGvQKO14CaOLnVT2yAkMcyNohsEgoDP9oCBGDJQbBH +NmtZfpVjjtuTr9P9TEkU1FcBRo0x6Il/DkzamGbOeFAmgnaGElhJ5c/CAG7whaIf +mUfFOBGPH/wESY3gBOACDofeSh27RrlvbLaPiCGKivDUTBmhBsIuso6XqOKbvtfV +/HhhndpdRVfIj4DdE7gIrLIGN977JMVAXFCNz7KrvAWwcOXrCHCoWpklJ9repq8l +26ICY8K7VXktzDHQUmhd88ZWR+9ASURsJghUgZUOcMrEGyvci6Y8hpLhHiNVPHuQ ++ps7tpPsXSntBUqWBzhRZh74+nJlOOV6oYykl30JT2JzB6lwiQKCAQEA9ecn8N2z +20tR2UEiTv/MjVSepQtAAajegvcd1iasvvQKXnh3XLmoZHzH2tTa0lp5RIZpUQPl +lOTwko0lYTBnYblt65AJQ3FTgisNobIpoqE8BFXLm6wggz7CbabjmPGDe173lPGR +sI0YSKYvzrdn4zw8Fh6WULJyZHLi58zJYL3r0WBDiOoxpGaGA1GlmkuIWjhKHaX2 +OvF1vOuQDJ2eDyTc5TYFC0NKG76Mvanov5L/yrhNM/umbmp0SPspzHGZobAKUr20 +OazFT8S+2TA1OTxWNbiPbSimFoaZbEdqsNACGfVJWO8Sh8iqlt5RmEcSiSvGBj6L +QKprRO9Fsp2GawKCAQEA0zGhRsnux4JTNsdUSYsEJtITMj6eE+nl7CoZ9DAOwC5X +6/aSpUE4TT+pWNrt9iluXiGL0j89UJ7r/L1OcsiyzGb8ig9NU4zr1NIGTZ0DstHi +HPYINjeiBJEFIy17kOQn+9/I5c4hBUwz6ihwNoEomymVB/EsLJKAML0AudJGKg+Z +/f/qrS40eab5SAiaKgsh0MZnj+vIxyGBydt6r2HGmjfNITVbXIu6IpO+6NXDwM/e +7v10AAZ3j9+gb1RedLg2ghuIuYU90hmMhtVWsh9nVmaOkMW9/WFgOPYvt/mHH/hR +d4pePZ9kACGmqo/b9sHvHw1YEubtCt1VUiNuFxnJCwKCAQBWnxz0vkRTJY8phsY9 +KeK2jm5sGTBs5T2syLwb6ffENFdKvAjgAw6Mh2And/+1ReWd+/MxdLv03UjZdxsJ +x3FDfXx5FH4O4ebW3a+pnAcKoN1xcX+N0O6LDRqUYcue3sTAOs3gC9CUbr91KAWD +Phw8ccWAzTmKJ7IgLFA982ekyoI9eTmRC159WRgwJxy844qerWF+XC4GyXP+HsTZ +jNRW5Vdi7sqMEyIR7+fIEAhLI88zbATWIPmZv6pC4ybwO7wwtsCMMQNBpdjDprzL +6S12ggikV+U+QKlxGe0FtYqhykRTPJKf32eZqVheWOZJTA/9fgv9ux52oxGycM8O +gmsNAoIBAQC60m5uZnd5uYnPLWkcXYNgq/kbO1UvHHut/FhVMKX7z4MrU0XKNfWO +MECoP5K9bU0aq+Y6KIMe7FapjvT0iSHRu1Cu+HZY8JI2A0xcIAeDijLRl7sP6wrB +q1+2DKgANjRAlWfsEfoX658JBpitPngjOheBnRCMpVQMyUT5HE/BKWf5zwdUB0mY +S+K8nA90HcDeJIS8RcGolbVwUV0oBABhr/cf50lYhqozqCr7YQ33ZGs7Uq3oz8+4 +UARmN2YPLl3Znm3GX12em8c6B0LX8vvA7Jw06Rf2Ksup1+3Ce1PTLiEy9A4FyRf3 +Hc2HmBbnJAtZlr5QikMqlzzAmmLqwH6dAoIBAC+ryaQGJFsijCSuaDfRp/uy9xnd +DjgMdTwjl5WLBmyudChVMANl8eqCbvVO41CN84yORk03oQ4cx0eKxAZaLaSzgkb3 +W0X2nFQe7VJSYMQswCQ+1WfJvEFrIdkEKIa//uQdhqNrgUKSNVhhSTMbNEkDTIWn +ssbv2H9hvUaFt/J/vP9zCKuU5oYvNU7Oi6ZXRYezRn9atlJYanLFoJnHUBRzGms5 +K0vhdCPDXQq87z5Yudoh0jLUQF9Nx0GTWeBceQ9n5hZeRUNQWxP4AJThQX9KSPTS +mbL3Kh4XNRmAUJ2N+Njh+3dg91s+JkKvC1wcspLsmLPQe+9AxBSH9y5JE/8= +-----END RSA PRIVATE KEY----- \ No newline at end of file diff --git a/docker/php-nginx/5.6/conf/etc/nginx/vhost.common.conf b/docker/php-nginx/5.6/conf/etc/nginx/vhost.common.conf new file mode 100644 index 000000000..a5df62ef8 --- /dev/null +++ b/docker/php-nginx/5.6/conf/etc/nginx/vhost.common.conf @@ -0,0 +1,2 @@ +# compatibility for PHP and TYPO3 Docker Boilerplate +include /opt/docker/etc/nginx/vhost.common.d/*.conf; diff --git a/docker/php-nginx/5.6/conf/etc/nginx/vhost.common.d/.gitkeep b/docker/php-nginx/5.6/conf/etc/nginx/vhost.common.d/.gitkeep new file mode 100644 index 000000000..e69de29bb diff --git a/docker/php-nginx/5.6/conf/etc/nginx/vhost.common.d/10-general.conf b/docker/php-nginx/5.6/conf/etc/nginx/vhost.common.d/10-general.conf new file mode 100644 index 000000000..d3fd0aa5e --- /dev/null +++ b/docker/php-nginx/5.6/conf/etc/nginx/vhost.common.d/10-general.conf @@ -0,0 +1 @@ +client_max_body_size 50m; diff --git a/docker/php-nginx/5.6/conf/etc/nginx/vhost.common.d/10-location-root.conf b/docker/php-nginx/5.6/conf/etc/nginx/vhost.common.d/10-location-root.conf new file mode 100644 index 000000000..28fd811bc --- /dev/null +++ b/docker/php-nginx/5.6/conf/etc/nginx/vhost.common.d/10-location-root.conf @@ -0,0 +1,3 @@ +location / { + try_files $uri $uri/ /?$query_string; +} diff --git a/docker/php-nginx/5.6/conf/etc/nginx/vhost.common.d/10-log.conf b/docker/php-nginx/5.6/conf/etc/nginx/vhost.common.d/10-log.conf new file mode 100644 index 000000000..9646c6826 --- /dev/null +++ b/docker/php-nginx/5.6/conf/etc/nginx/vhost.common.d/10-log.conf @@ -0,0 +1,2 @@ +access_log /docker.stdout; +error_log /docker.stderr warn; diff --git a/docker/php-nginx/5.6/conf/etc/nginx/vhost.common.d/10-php.conf b/docker/php-nginx/5.6/conf/etc/nginx/vhost.common.d/10-php.conf new file mode 100644 index 000000000..274beac87 --- /dev/null +++ b/docker/php-nginx/5.6/conf/etc/nginx/vhost.common.d/10-php.conf @@ -0,0 +1,7 @@ +location ~ \.php$ { + fastcgi_split_path_info ^(.+\.php)(/.+)$; + fastcgi_pass php; + include fastcgi_params; + fastcgi_param SCRIPT_FILENAME $request_filename; + fastcgi_read_timeout 1000; +} diff --git a/docker/php-nginx/5.6/conf/etc/nginx/vhost.conf b/docker/php-nginx/5.6/conf/etc/nginx/vhost.conf new file mode 100644 index 000000000..8225f314a --- /dev/null +++ b/docker/php-nginx/5.6/conf/etc/nginx/vhost.conf @@ -0,0 +1,26 @@ +server { + listen 80 default_server; + + server_name _ docker; + + root ""; + index ; + + include /opt/docker/etc/nginx/vhost.common.d/*.conf; +} + +############## +# SSL +############## + +server { + listen 443 default_server; + + server_name _ docker; + + root ""; + index ; + + include /opt/docker/etc/nginx/vhost.common.d/*.conf; + include /opt/docker/etc/nginx/vhost.ssl.conf; +} diff --git a/docker/php-nginx/5.6/conf/etc/nginx/vhost.ssl.conf b/docker/php-nginx/5.6/conf/etc/nginx/vhost.ssl.conf new file mode 100644 index 000000000..4ddba251d --- /dev/null +++ b/docker/php-nginx/5.6/conf/etc/nginx/vhost.ssl.conf @@ -0,0 +1,7 @@ +ssl on; +ssl_protocols TLSv1 TLSv1.1 TLSv1.2; # not possible to do exclusive +ssl_ciphers 'EDH+CAMELLIA:EDH+aRSA:EECDH+aRSA+AESGCM:EECDH+aRSA+SHA384:EECDH+aRSA+SHA256:EECDH:+CAMELLIA256:+AES256:+CAMELLIA128:+AES128:+SSLv3:!aNULL:!eNULL:!LOW:!3DES:!MD5:!EXP:!PSK:!DSS:!RC4:!SEED:!ECDSA:CAMELLIA256-SHA:AES256-SHA:CAMELLIA128-SHA:AES128-SHA'; +ssl_prefer_server_ciphers on; + +ssl_certificate /opt/docker/etc/nginx/ssl/server.crt; +ssl_certificate_key /opt/docker/etc/nginx/ssl/server.key; diff --git a/docker/php-nginx/5.6/conf/etc/supervisor.d/nginx.conf b/docker/php-nginx/5.6/conf/etc/supervisor.d/nginx.conf new file mode 100644 index 000000000..657bf499b --- /dev/null +++ b/docker/php-nginx/5.6/conf/etc/supervisor.d/nginx.conf @@ -0,0 +1,14 @@ +[group:nginx] +programs=nginxd +priority=20 + +[program:nginxd] +command = /opt/docker/bin/service.d/nginx.sh +process_name=%(program_name)s +startsecs = 0 +autostart = true +autorestart = true +stdout_logfile=/dev/stdout +stdout_logfile_maxbytes=0 +stderr_logfile=/dev/stderr +stderr_logfile_maxbytes=0 diff --git a/docker/php-nginx/5.6/conf/provision/roles/webdevops-nginx/defaults/main.yml b/docker/php-nginx/5.6/conf/provision/roles/webdevops-nginx/defaults/main.yml new file mode 100644 index 000000000..69cba1cb4 --- /dev/null +++ b/docker/php-nginx/5.6/conf/provision/roles/webdevops-nginx/defaults/main.yml @@ -0,0 +1,3 @@ +--- + +DOCUMENT_ROOT: "{{ lookup('env','WEB_DOCUMENT_ROOT') }}" diff --git a/docker/php-nginx/5.6/conf/provision/roles/webdevops-nginx/tasks/bootstrap.yml b/docker/php-nginx/5.6/conf/provision/roles/webdevops-nginx/tasks/bootstrap.yml new file mode 100644 index 000000000..7edb04ee4 --- /dev/null +++ b/docker/php-nginx/5.6/conf/provision/roles/webdevops-nginx/tasks/bootstrap.yml @@ -0,0 +1,86 @@ +--- + +- name: Diable nginx demonize mode + lineinfile: + dest: /etc/nginx/nginx.conf + regexp: '[\s;]*{{ item.key }}[\s]*' + line: '{{ item.key }} {{ item.value }};' + with_items: + - { key: 'daemon', value: "off" } + +- name: Set access_log to stdout + replace: + dest: /etc/nginx/nginx.conf + regexp: '^([ \t]*access_log)[ \t]*([^\t ;]+)(.*;)$' + replace: '\1 /docker.stdout \3' + +- name: Set access_log to stdout + replace: + dest: /etc/nginx/nginx.conf + regexp: '^([ \t]*error_log)[ \t]*([^\t ;]+)(.*;)$' + replace: '\1 /docker.stdout \3' + +- name: Enable nginx main config + file: + src: '/opt/docker/etc/nginx/main.conf' + dest: '/etc/nginx/conf.d/10-docker.conf' + state: link + force: yes + +- name: Remove default vhost + file: + path: "{{ item }}" + state: absent + with_items: + # Debian family + - "/etc/nginx/sites-enabled/default" + # Alpine + - "/etc/nginx/conf.d/default.conf" + + +- name: Replace default nginx.conf [RedHat/Alpine family] + file: + src: '/opt/docker/etc/nginx/nginx.conf' + dest: '/etc/nginx/nginx.conf' + state: link + force: yes + when: ansible_os_family == 'RedHat' or ansible_os_family == 'Alpine' + +- name: Ensure document root is available + file: + path: "{{ DOCUMENT_ROOT }}" + state: directory + recurse: yes + +- name: Remove old log directory + file: + path: "/var/lib/nginx/logs" + state: absent + +- name: Create log directory + file: + path: "/var/lib/nginx/logs" + state: directory + +- name: Create stdout symlinks + file: + dest: "{{ item }}" + src: "/docker.stdout" + state: link + force: yes + with_items: + - "/var/lib/nginx/logs/access.log" + - "/var/lib/nginx/logs/error.log" + +- name: Fix rights of ssl files + file: + path: "{{ item.path }}" + state: "{{ item.state }}" + mode: "{{ item.mode }}" + owner: "root" + group: "root" + with_items: + - { path: '/opt/docker/etc/nginx/ssl', state: 'directory', mode: '0750' } + - { path: '/opt/docker/etc/nginx/ssl/server.crt', state: 'file', mode: '0640' } + - { path: '/opt/docker/etc/nginx/ssl/server.csr', state: 'file', mode: '0640' } + - { path: '/opt/docker/etc/nginx/ssl/server.key', state: 'file', mode: '0640' } diff --git a/docker/php-nginx/5.6/conf/provision/roles/webdevops-nginx/tasks/main.yml b/docker/php-nginx/5.6/conf/provision/roles/webdevops-nginx/tasks/main.yml new file mode 100644 index 000000000..1806c1a8c --- /dev/null +++ b/docker/php-nginx/5.6/conf/provision/roles/webdevops-nginx/tasks/main.yml @@ -0,0 +1,5 @@ +--- + +- include: bootstrap.yml + tags: + - bootstrap diff --git a/docker/php-nginx/5.6/conf/provision/roles/webdevops-php-nginx/defaults/main.yml b/docker/php-nginx/5.6/conf/provision/roles/webdevops-php-nginx/defaults/main.yml new file mode 100644 index 000000000..ed97d539c --- /dev/null +++ b/docker/php-nginx/5.6/conf/provision/roles/webdevops-php-nginx/defaults/main.yml @@ -0,0 +1 @@ +--- diff --git a/docker/php-nginx/5.6/conf/provision/roles/webdevops-php-nginx/tasks/bootstrap.yml b/docker/php-nginx/5.6/conf/provision/roles/webdevops-php-nginx/tasks/bootstrap.yml new file mode 100644 index 000000000..a2866e0d0 --- /dev/null +++ b/docker/php-nginx/5.6/conf/provision/roles/webdevops-php-nginx/tasks/bootstrap.yml @@ -0,0 +1,9 @@ +--- + +- name: Restrict php-fpm to local connection + lineinfile: + dest: '/opt/docker/etc/php/fpm/pool.d/application.conf' + regexp: '^[\s;]*{{ item.key }}[\s]*=' + line: '{{ item.key }} = {{ item.value }}' + with_items: + - { key: 'listen', value: "127.0.0.1:9000" } diff --git a/docker/php-nginx/5.6/conf/provision/roles/webdevops-php-nginx/tasks/entrypoint.yml b/docker/php-nginx/5.6/conf/provision/roles/webdevops-php-nginx/tasks/entrypoint.yml new file mode 100644 index 000000000..cd21505a4 --- /dev/null +++ b/docker/php-nginx/5.6/conf/provision/roles/webdevops-php-nginx/tasks/entrypoint.yml @@ -0,0 +1,2 @@ +--- + diff --git a/docker/php-nginx/5.6/conf/provision/roles/webdevops-php-nginx/tasks/main.yml b/docker/php-nginx/5.6/conf/provision/roles/webdevops-php-nginx/tasks/main.yml new file mode 100644 index 000000000..7895a52a9 --- /dev/null +++ b/docker/php-nginx/5.6/conf/provision/roles/webdevops-php-nginx/tasks/main.yml @@ -0,0 +1,9 @@ +--- + +- include: bootstrap.yml + tags: + - bootstrap + +- include: entrypoint.yml + tags: + - entrypoint diff --git a/docker/php-nginx/7.0/Dockerfile b/docker/php-nginx/7.0/Dockerfile new file mode 100644 index 000000000..dd2dff548 --- /dev/null +++ b/docker/php-nginx/7.0/Dockerfile @@ -0,0 +1,22 @@ +#+++++++++++++++++++++++++++++++++++++++ +# Dockerfile for webdevops/php-nginx:7.0 +# -- automatically generated -- +#+++++++++++++++++++++++++++++++++++++++ + +FROM webdevops/php:7.0 + +ENV WEB_DOCUMENT_ROOT=/app \ + WEB_DOCUMENT_INDEX=index.php \ + WEB_ALIAS_DOMAIN=*.vm +ENV WEB_PHP_SOCKET=127.0.0.1:9000 + +COPY conf/ /opt/docker/ + +# Install nginx +RUN /usr/local/bin/apt-install \ + nginx \ + && /opt/docker/bin/provision run --tag bootstrap --role webdevops-nginx --role webdevops-php-nginx \ + && /opt/docker/bin/bootstrap.sh \ + && docker-image-cleanup + +EXPOSE 80 443 diff --git a/docker/php-nginx/7.0/Dockerfile.jinja2 b/docker/php-nginx/7.0/Dockerfile.jinja2 new file mode 100644 index 000000000..b824eff56 --- /dev/null +++ b/docker/php-nginx/7.0/Dockerfile.jinja2 @@ -0,0 +1,10 @@ +{{ docker.from("php", "7.0") }} + +{{ environment.web() }} +{{ environment.webPhp() }} + +{{ docker.copy('conf/', '/opt/docker/') }} + +{{ nginx.debian('php-nginx') }} + +{{ docker.expose('80 443') }} diff --git a/docker/php-nginx/7.0/conf/bin/service.d/nginx.d/10-init.sh b/docker/php-nginx/7.0/conf/bin/service.d/nginx.d/10-init.sh new file mode 100644 index 000000000..27b9776cc --- /dev/null +++ b/docker/php-nginx/7.0/conf/bin/service.d/nginx.d/10-init.sh @@ -0,0 +1,25 @@ +if [[ ! -e "$WEB_DOCUMENT_ROOT" ]]; then + echo "" + echo "[WARNING] WEB_DOCUMENT_ROOT does not exists with path \"$WEB_DOCUMENT_ROOT\"!" + echo "" +fi + +# Prevent startup of nginx (ubuntu 16.04 needs it) +ln -f -s /var/lib/nginx/logs /var/log/nginx + +# Replace markers +go-replace \ + -s "" -r "$WEB_DOCUMENT_INDEX" \ + -s "" -r "$WEB_DOCUMENT_ROOT" \ + -s "" -r "$WEB_ALIAS_DOMAIN" \ + -s "" -r "$HOSTNAME" \ + -s "" -r "$WEB_PHP_SOCKET" \ + --path=/opt/docker/etc/nginx/ \ + --path-pattern='*.conf' \ + --ignore-empty + +if [[ -z "${WEB_PHP_SOCKET+x}" ]]; then + ## WEB_PHP_SOCKET is not set, remove PHP files + rm -f -- /opt/docker/etc/nginx/conf.d/10-php.conf + rm -f -- /opt/docker/etc/nginx/vhost.common.d/10-php.conf +fi diff --git a/docker/php-nginx/7.0/conf/bin/service.d/nginx.sh b/docker/php-nginx/7.0/conf/bin/service.d/nginx.sh new file mode 100644 index 000000000..f5cd26167 --- /dev/null +++ b/docker/php-nginx/7.0/conf/bin/service.d/nginx.sh @@ -0,0 +1,7 @@ +#!/usr/bin/env bash + +source /opt/docker/bin/config.sh + +includeScriptDir "/opt/docker/bin/service.d/nginx.d/" + +exec /usr/sbin/nginx diff --git a/docker/php-nginx/7.0/conf/etc/nginx/conf.d/.gitkeep b/docker/php-nginx/7.0/conf/etc/nginx/conf.d/.gitkeep new file mode 100644 index 000000000..e69de29bb diff --git a/docker/php-nginx/7.0/conf/etc/nginx/conf.d/10-php.conf b/docker/php-nginx/7.0/conf/etc/nginx/conf.d/10-php.conf new file mode 100644 index 000000000..9abe45f0a --- /dev/null +++ b/docker/php-nginx/7.0/conf/etc/nginx/conf.d/10-php.conf @@ -0,0 +1,3 @@ +upstream php { + server ; +} diff --git a/docker/php-nginx/7.0/conf/etc/nginx/global.conf b/docker/php-nginx/7.0/conf/etc/nginx/global.conf new file mode 100644 index 000000000..b6141db09 --- /dev/null +++ b/docker/php-nginx/7.0/conf/etc/nginx/global.conf @@ -0,0 +1 @@ +# deprecated diff --git a/docker/php-nginx/7.0/conf/etc/nginx/main.conf b/docker/php-nginx/7.0/conf/etc/nginx/main.conf new file mode 100644 index 000000000..06de0651b --- /dev/null +++ b/docker/php-nginx/7.0/conf/etc/nginx/main.conf @@ -0,0 +1,4 @@ +include /opt/docker/etc/nginx/global.conf; +include /opt/docker/etc/nginx/php.conf; +include /opt/docker/etc/nginx/conf.d/*.conf; +include /opt/docker/etc/nginx/vhost.conf; diff --git a/docker/php-nginx/7.0/conf/etc/nginx/php.conf b/docker/php-nginx/7.0/conf/etc/nginx/php.conf new file mode 100644 index 000000000..b6141db09 --- /dev/null +++ b/docker/php-nginx/7.0/conf/etc/nginx/php.conf @@ -0,0 +1 @@ +# deprecated diff --git a/docker/php-nginx/7.0/conf/etc/nginx/ssl/server.crt b/docker/php-nginx/7.0/conf/etc/nginx/ssl/server.crt new file mode 100644 index 000000000..6b0694907 --- /dev/null +++ b/docker/php-nginx/7.0/conf/etc/nginx/ssl/server.crt @@ -0,0 +1,28 @@ +-----BEGIN CERTIFICATE----- +MIIE1DCCArwCCQDMMwGnSuK0tTANBgkqhkiG9w0BAQsFADAsMRswGQYDVQQKExJE +b2NrZXIgQm9pbGVycGxhdGUxDTALBgNVBAMUBCoudm0wHhcNMTUwNTA0MTcxNDQw +WhcNMjUwNTAxMTcxNDQwWjAsMRswGQYDVQQKExJEb2NrZXIgQm9pbGVycGxhdGUx +DTALBgNVBAMUBCoudm0wggIiMA0GCSqGSIb3DQEBAQUAA4ICDwAwggIKAoICAQDK +3TIUiyDvXelWeY9VXMrpjuZtYpVSDsACLpjFUhMnsP5/iKT0VbeZyqHvmwZjAg4G +Y10d+yZDdgv/xeu0HPOFbtR6pCp10d1tdLHZto5Cyuxu7IQsAVjnD6Ko7XFwtNk7 +9o6JZfAFaGL4w5MokrVmCtspnsMZH7/7zU4f96cbF39zLopnpuXGD6t6DA8Qj3gy +0duaTjs42bYRN+rwLzVKAev99iQ4kPMJn4vV6/Xk6rtoSzC67GQyVZYaFypicD1S +NtsRmgEVvjCBDbrLOneUiRwff6qxEsZi7Hxv7BKFj4iUWnII7K/nP7T6uBHQjHO+ +FpsGkU9lCMrCeVFBe8kKz/cbhd+yLUxXwAPr6gSOPmwn232Gy4tozvqZHpbUxsgx +7sT3ej9K66h1D7J+BjNFWYM1hbnC1r7H/xS7EBzBV8qRoQCVe08Juf5xsouXFakD +clLV4+L+1cxkpwsCQDly5g3tm/TBqA2O+ZJ+YHQDHKkzMyhLs6i0X/M5qvJBiLg1 +GLTCS20rpQ5gXTEGuINqHgwXQWkUO6bhgSYqdHGX3zbZ5+qWpI4eui3dHZ1Ll0VH +6Icpb7ORTQwhc6W8KBlybssYPSlGOEBGUjYGNheoz9FpoSkxCis+P8ZNKtrmpPoq +Su0eOOGFOFHG02eOgPVxSwrDeN9MVJo7BPysGMHJmQIDAQABMA0GCSqGSIb3DQEB +CwUAA4ICAQC63g6NHmQKbiy3G6iaDkpUSbr5Mq2YgU61XnvWVyREqDcy/BXCw9oY +SJ/KUvCpqPnACNOFqjadRAmPiA9nf2WduoCgwQGV/YRFGswSuVvh/3X2TX5NWvbS +t8MQDttQg1dxpiMUjlu3rqhfohBdWJvp2lVSdpDb/MOlXBc/+p7HfOHwhqB7wwPN +NNbSKUbZqZxmD8cOf1X0hASr1yfFPj+2vST3ESaON8S0T2p63YX/sD5jvOUiEuyw +I5WcvLmiRZA07SH8nWyckLY3qWL+OlhSZrlAnolWS00b+7h5LNuRYEjKzwVgntoA +aCopyQih6wIk0+AfJO4sfhJBmQhnIrAaP/zwBH5g9zVizLf5H7U+hNXrMwgw55Sq +vjMdkZHvPKUXTvVit/rYE9H+PY3brkRWzOl4V/i/ZLJJm5805H/NyTbz9kPMJw2Q +nn+KOpfXXySD39f8iuRgSKXsYNul38hxWgcZZ6g+sOOp2n/VUmf0eZUWNnJ8i7AP +4Qif7aDKMcibOwSwsB+DKZXDvZ5XSdnMphtuLS5rPSL81rVRmWC2DMfQ2eP8j0WN +VTroSk0xedQ7Qr+9TNooi9IyzX6n1a2S1UiciEZ3ZcDbXPl/P01m+IYZyPnLv0+9 +ZeioZYh1JLv3/OKsMrMLTfh2ZCj3aXwmc2Owi/wU2LS5QUOMcHH7CQ== +-----END CERTIFICATE----- \ No newline at end of file diff --git a/docker/php-nginx/7.0/conf/etc/nginx/ssl/server.csr b/docker/php-nginx/7.0/conf/etc/nginx/ssl/server.csr new file mode 100644 index 000000000..8a9909f77 --- /dev/null +++ b/docker/php-nginx/7.0/conf/etc/nginx/ssl/server.csr @@ -0,0 +1,26 @@ +-----BEGIN CERTIFICATE REQUEST----- +MIIEcTCCAlkCAQAwLDEbMBkGA1UEChMSRG9ja2VyIEJvaWxlcnBsYXRlMQ0wCwYD +VQQDFAQqLnZtMIICIjANBgkqhkiG9w0BAQEFAAOCAg8AMIICCgKCAgEAyt0yFIsg +713pVnmPVVzK6Y7mbWKVUg7AAi6YxVITJ7D+f4ik9FW3mcqh75sGYwIOBmNdHfsm +Q3YL/8XrtBzzhW7UeqQqddHdbXSx2baOQsrsbuyELAFY5w+iqO1xcLTZO/aOiWXw +BWhi+MOTKJK1ZgrbKZ7DGR+/+81OH/enGxd/cy6KZ6blxg+regwPEI94MtHbmk47 +ONm2ETfq8C81SgHr/fYkOJDzCZ+L1ev15Oq7aEswuuxkMlWWGhcqYnA9UjbbEZoB +Fb4wgQ26yzp3lIkcH3+qsRLGYux8b+wShY+IlFpyCOyv5z+0+rgR0IxzvhabBpFP +ZQjKwnlRQXvJCs/3G4Xfsi1MV8AD6+oEjj5sJ9t9hsuLaM76mR6W1MbIMe7E93o/ +SuuodQ+yfgYzRVmDNYW5wta+x/8UuxAcwVfKkaEAlXtPCbn+cbKLlxWpA3JS1ePi +/tXMZKcLAkA5cuYN7Zv0wagNjvmSfmB0AxypMzMoS7OotF/zOaryQYi4NRi0wktt +K6UOYF0xBriDah4MF0FpFDum4YEmKnRxl9822efqlqSOHrot3R2dS5dFR+iHKW+z +kU0MIXOlvCgZcm7LGD0pRjhARlI2BjYXqM/RaaEpMQorPj/GTSra5qT6KkrtHjjh +hThRxtNnjoD1cUsKw3jfTFSaOwT8rBjByZkCAwEAAaAAMA0GCSqGSIb3DQEBCwUA +A4ICAQBsEBgC2YepuZq/8UqvKMZKVy/etDKXj7BB+QPb+leNiKD7p4LDxHJsZSH8 +Ku9uMPeLfiQDn5jA41k5SlGttzvObd65RdEbO3yHpqsg05EGSDDLfaE1k2Al/qmX +/o8roPZF7+2kZthgMAgkcokS54LYqEYTGqOf3J9Ss0yRIZwhaOVebfFIbIOdpw0B +JNMIJPHTMdZrcuRVI+wR1uPLIlEJzBvxTGbTrvPU25WJFtu+EajKqXO0SHdy0yx8 +uH4ykRBJRc36+oYo7nZ5D56dh7pZn3+9J64FKAOV0Q3KqMFieGy053ezuhJd70eZ +UozTgfjs3WpMzoYmKETSyl3XZSdInRe+sUlKPruTsKyg69oYxjPlrGfAmmGcCFca +TnZinT18dI92zK7OtOVkmYeYKC1lwuhftVrNMXzZuHOGpS9NNYtc4nDqDMIEOfV3 +6rCdu03WjEgJ+Z67tJs16xOx9du4/EHxS2Ijn9DPfVJvYy0TgzDi1BUpjWx0KTLx +C4OQbEZ/QTWmHVbSch/hcZhzbf7SNh5RpnW4EtmcpDFjIKMfxJmoKeiTf7qnilx0 +7uRvsZFKoDKRDOFiPfgMg5AOtLHziYsd9m0tJjC2GHvFuPjzOtzhnUUjmmvht170 +2aqKakjST4amg7jzLcs871HX0/WjOtt29NpOz140blkKf1bisg== +-----END CERTIFICATE REQUEST----- \ No newline at end of file diff --git a/docker/php-nginx/7.0/conf/etc/nginx/ssl/server.key b/docker/php-nginx/7.0/conf/etc/nginx/ssl/server.key new file mode 100644 index 000000000..c9eec145f --- /dev/null +++ b/docker/php-nginx/7.0/conf/etc/nginx/ssl/server.key @@ -0,0 +1,51 @@ +-----BEGIN RSA PRIVATE KEY----- +MIIJKAIBAAKCAgEAyt0yFIsg713pVnmPVVzK6Y7mbWKVUg7AAi6YxVITJ7D+f4ik +9FW3mcqh75sGYwIOBmNdHfsmQ3YL/8XrtBzzhW7UeqQqddHdbXSx2baOQsrsbuyE +LAFY5w+iqO1xcLTZO/aOiWXwBWhi+MOTKJK1ZgrbKZ7DGR+/+81OH/enGxd/cy6K +Z6blxg+regwPEI94MtHbmk47ONm2ETfq8C81SgHr/fYkOJDzCZ+L1ev15Oq7aEsw +uuxkMlWWGhcqYnA9UjbbEZoBFb4wgQ26yzp3lIkcH3+qsRLGYux8b+wShY+IlFpy +COyv5z+0+rgR0IxzvhabBpFPZQjKwnlRQXvJCs/3G4Xfsi1MV8AD6+oEjj5sJ9t9 +hsuLaM76mR6W1MbIMe7E93o/SuuodQ+yfgYzRVmDNYW5wta+x/8UuxAcwVfKkaEA +lXtPCbn+cbKLlxWpA3JS1ePi/tXMZKcLAkA5cuYN7Zv0wagNjvmSfmB0AxypMzMo +S7OotF/zOaryQYi4NRi0wkttK6UOYF0xBriDah4MF0FpFDum4YEmKnRxl9822efq +lqSOHrot3R2dS5dFR+iHKW+zkU0MIXOlvCgZcm7LGD0pRjhARlI2BjYXqM/RaaEp +MQorPj/GTSra5qT6KkrtHjjhhThRxtNnjoD1cUsKw3jfTFSaOwT8rBjByZkCAwEA +AQKCAgAbZPdoUsllyZbC+LNkYZ19ILD5QIDNjfRb1xMGQmkXyQz1B+zOmeyrNfPc +OWEJabOfJTfj3pByN7SzG3US4333HNpQnW6mbmqqZ0HFFqPrXR/Ecuf+UUhCG5hp +m3bgM2vKbyccYsmg0VHcKfzrU7RvTTP/UNMjx2fThwvvwS+ttuSdF0HVcXJB5sfP +OWWnZNhkdHZlRf81VCED/jsZqCZYEh5eMyj9AoXvXL4zayPPf+tC0DSKaXW2Xlxg +tZQhqup8+a9nlxZia0Z9hu8clo6jXkiP8FuKgfCMV0cOjiCKLLHS5svTbLLsVWwJ +F2ZAdVcD6mWQ43qHOEK5NEzGvQKO14CaOLnVT2yAkMcyNohsEgoDP9oCBGDJQbBH +NmtZfpVjjtuTr9P9TEkU1FcBRo0x6Il/DkzamGbOeFAmgnaGElhJ5c/CAG7whaIf +mUfFOBGPH/wESY3gBOACDofeSh27RrlvbLaPiCGKivDUTBmhBsIuso6XqOKbvtfV +/HhhndpdRVfIj4DdE7gIrLIGN977JMVAXFCNz7KrvAWwcOXrCHCoWpklJ9repq8l +26ICY8K7VXktzDHQUmhd88ZWR+9ASURsJghUgZUOcMrEGyvci6Y8hpLhHiNVPHuQ ++ps7tpPsXSntBUqWBzhRZh74+nJlOOV6oYykl30JT2JzB6lwiQKCAQEA9ecn8N2z +20tR2UEiTv/MjVSepQtAAajegvcd1iasvvQKXnh3XLmoZHzH2tTa0lp5RIZpUQPl +lOTwko0lYTBnYblt65AJQ3FTgisNobIpoqE8BFXLm6wggz7CbabjmPGDe173lPGR +sI0YSKYvzrdn4zw8Fh6WULJyZHLi58zJYL3r0WBDiOoxpGaGA1GlmkuIWjhKHaX2 +OvF1vOuQDJ2eDyTc5TYFC0NKG76Mvanov5L/yrhNM/umbmp0SPspzHGZobAKUr20 +OazFT8S+2TA1OTxWNbiPbSimFoaZbEdqsNACGfVJWO8Sh8iqlt5RmEcSiSvGBj6L +QKprRO9Fsp2GawKCAQEA0zGhRsnux4JTNsdUSYsEJtITMj6eE+nl7CoZ9DAOwC5X +6/aSpUE4TT+pWNrt9iluXiGL0j89UJ7r/L1OcsiyzGb8ig9NU4zr1NIGTZ0DstHi +HPYINjeiBJEFIy17kOQn+9/I5c4hBUwz6ihwNoEomymVB/EsLJKAML0AudJGKg+Z +/f/qrS40eab5SAiaKgsh0MZnj+vIxyGBydt6r2HGmjfNITVbXIu6IpO+6NXDwM/e +7v10AAZ3j9+gb1RedLg2ghuIuYU90hmMhtVWsh9nVmaOkMW9/WFgOPYvt/mHH/hR +d4pePZ9kACGmqo/b9sHvHw1YEubtCt1VUiNuFxnJCwKCAQBWnxz0vkRTJY8phsY9 +KeK2jm5sGTBs5T2syLwb6ffENFdKvAjgAw6Mh2And/+1ReWd+/MxdLv03UjZdxsJ +x3FDfXx5FH4O4ebW3a+pnAcKoN1xcX+N0O6LDRqUYcue3sTAOs3gC9CUbr91KAWD +Phw8ccWAzTmKJ7IgLFA982ekyoI9eTmRC159WRgwJxy844qerWF+XC4GyXP+HsTZ +jNRW5Vdi7sqMEyIR7+fIEAhLI88zbATWIPmZv6pC4ybwO7wwtsCMMQNBpdjDprzL +6S12ggikV+U+QKlxGe0FtYqhykRTPJKf32eZqVheWOZJTA/9fgv9ux52oxGycM8O +gmsNAoIBAQC60m5uZnd5uYnPLWkcXYNgq/kbO1UvHHut/FhVMKX7z4MrU0XKNfWO +MECoP5K9bU0aq+Y6KIMe7FapjvT0iSHRu1Cu+HZY8JI2A0xcIAeDijLRl7sP6wrB +q1+2DKgANjRAlWfsEfoX658JBpitPngjOheBnRCMpVQMyUT5HE/BKWf5zwdUB0mY +S+K8nA90HcDeJIS8RcGolbVwUV0oBABhr/cf50lYhqozqCr7YQ33ZGs7Uq3oz8+4 +UARmN2YPLl3Znm3GX12em8c6B0LX8vvA7Jw06Rf2Ksup1+3Ce1PTLiEy9A4FyRf3 +Hc2HmBbnJAtZlr5QikMqlzzAmmLqwH6dAoIBAC+ryaQGJFsijCSuaDfRp/uy9xnd +DjgMdTwjl5WLBmyudChVMANl8eqCbvVO41CN84yORk03oQ4cx0eKxAZaLaSzgkb3 +W0X2nFQe7VJSYMQswCQ+1WfJvEFrIdkEKIa//uQdhqNrgUKSNVhhSTMbNEkDTIWn +ssbv2H9hvUaFt/J/vP9zCKuU5oYvNU7Oi6ZXRYezRn9atlJYanLFoJnHUBRzGms5 +K0vhdCPDXQq87z5Yudoh0jLUQF9Nx0GTWeBceQ9n5hZeRUNQWxP4AJThQX9KSPTS +mbL3Kh4XNRmAUJ2N+Njh+3dg91s+JkKvC1wcspLsmLPQe+9AxBSH9y5JE/8= +-----END RSA PRIVATE KEY----- \ No newline at end of file diff --git a/docker/php-nginx/7.0/conf/etc/nginx/vhost.common.conf b/docker/php-nginx/7.0/conf/etc/nginx/vhost.common.conf new file mode 100644 index 000000000..a5df62ef8 --- /dev/null +++ b/docker/php-nginx/7.0/conf/etc/nginx/vhost.common.conf @@ -0,0 +1,2 @@ +# compatibility for PHP and TYPO3 Docker Boilerplate +include /opt/docker/etc/nginx/vhost.common.d/*.conf; diff --git a/docker/php-nginx/7.0/conf/etc/nginx/vhost.common.d/.gitkeep b/docker/php-nginx/7.0/conf/etc/nginx/vhost.common.d/.gitkeep new file mode 100644 index 000000000..e69de29bb diff --git a/docker/php-nginx/7.0/conf/etc/nginx/vhost.common.d/10-general.conf b/docker/php-nginx/7.0/conf/etc/nginx/vhost.common.d/10-general.conf new file mode 100644 index 000000000..d3fd0aa5e --- /dev/null +++ b/docker/php-nginx/7.0/conf/etc/nginx/vhost.common.d/10-general.conf @@ -0,0 +1 @@ +client_max_body_size 50m; diff --git a/docker/php-nginx/7.0/conf/etc/nginx/vhost.common.d/10-location-root.conf b/docker/php-nginx/7.0/conf/etc/nginx/vhost.common.d/10-location-root.conf new file mode 100644 index 000000000..28fd811bc --- /dev/null +++ b/docker/php-nginx/7.0/conf/etc/nginx/vhost.common.d/10-location-root.conf @@ -0,0 +1,3 @@ +location / { + try_files $uri $uri/ /?$query_string; +} diff --git a/docker/php-nginx/7.0/conf/etc/nginx/vhost.common.d/10-log.conf b/docker/php-nginx/7.0/conf/etc/nginx/vhost.common.d/10-log.conf new file mode 100644 index 000000000..9646c6826 --- /dev/null +++ b/docker/php-nginx/7.0/conf/etc/nginx/vhost.common.d/10-log.conf @@ -0,0 +1,2 @@ +access_log /docker.stdout; +error_log /docker.stderr warn; diff --git a/docker/php-nginx/7.0/conf/etc/nginx/vhost.common.d/10-php.conf b/docker/php-nginx/7.0/conf/etc/nginx/vhost.common.d/10-php.conf new file mode 100644 index 000000000..274beac87 --- /dev/null +++ b/docker/php-nginx/7.0/conf/etc/nginx/vhost.common.d/10-php.conf @@ -0,0 +1,7 @@ +location ~ \.php$ { + fastcgi_split_path_info ^(.+\.php)(/.+)$; + fastcgi_pass php; + include fastcgi_params; + fastcgi_param SCRIPT_FILENAME $request_filename; + fastcgi_read_timeout 1000; +} diff --git a/docker/php-nginx/7.0/conf/etc/nginx/vhost.conf b/docker/php-nginx/7.0/conf/etc/nginx/vhost.conf new file mode 100644 index 000000000..8225f314a --- /dev/null +++ b/docker/php-nginx/7.0/conf/etc/nginx/vhost.conf @@ -0,0 +1,26 @@ +server { + listen 80 default_server; + + server_name _ docker; + + root ""; + index ; + + include /opt/docker/etc/nginx/vhost.common.d/*.conf; +} + +############## +# SSL +############## + +server { + listen 443 default_server; + + server_name _ docker; + + root ""; + index ; + + include /opt/docker/etc/nginx/vhost.common.d/*.conf; + include /opt/docker/etc/nginx/vhost.ssl.conf; +} diff --git a/docker/php-nginx/7.0/conf/etc/nginx/vhost.ssl.conf b/docker/php-nginx/7.0/conf/etc/nginx/vhost.ssl.conf new file mode 100644 index 000000000..4ddba251d --- /dev/null +++ b/docker/php-nginx/7.0/conf/etc/nginx/vhost.ssl.conf @@ -0,0 +1,7 @@ +ssl on; +ssl_protocols TLSv1 TLSv1.1 TLSv1.2; # not possible to do exclusive +ssl_ciphers 'EDH+CAMELLIA:EDH+aRSA:EECDH+aRSA+AESGCM:EECDH+aRSA+SHA384:EECDH+aRSA+SHA256:EECDH:+CAMELLIA256:+AES256:+CAMELLIA128:+AES128:+SSLv3:!aNULL:!eNULL:!LOW:!3DES:!MD5:!EXP:!PSK:!DSS:!RC4:!SEED:!ECDSA:CAMELLIA256-SHA:AES256-SHA:CAMELLIA128-SHA:AES128-SHA'; +ssl_prefer_server_ciphers on; + +ssl_certificate /opt/docker/etc/nginx/ssl/server.crt; +ssl_certificate_key /opt/docker/etc/nginx/ssl/server.key; diff --git a/docker/php-nginx/7.0/conf/etc/supervisor.d/nginx.conf b/docker/php-nginx/7.0/conf/etc/supervisor.d/nginx.conf new file mode 100644 index 000000000..657bf499b --- /dev/null +++ b/docker/php-nginx/7.0/conf/etc/supervisor.d/nginx.conf @@ -0,0 +1,14 @@ +[group:nginx] +programs=nginxd +priority=20 + +[program:nginxd] +command = /opt/docker/bin/service.d/nginx.sh +process_name=%(program_name)s +startsecs = 0 +autostart = true +autorestart = true +stdout_logfile=/dev/stdout +stdout_logfile_maxbytes=0 +stderr_logfile=/dev/stderr +stderr_logfile_maxbytes=0 diff --git a/docker/php-nginx/7.0/conf/provision/roles/webdevops-nginx/defaults/main.yml b/docker/php-nginx/7.0/conf/provision/roles/webdevops-nginx/defaults/main.yml new file mode 100644 index 000000000..69cba1cb4 --- /dev/null +++ b/docker/php-nginx/7.0/conf/provision/roles/webdevops-nginx/defaults/main.yml @@ -0,0 +1,3 @@ +--- + +DOCUMENT_ROOT: "{{ lookup('env','WEB_DOCUMENT_ROOT') }}" diff --git a/docker/php-nginx/7.0/conf/provision/roles/webdevops-nginx/tasks/bootstrap.yml b/docker/php-nginx/7.0/conf/provision/roles/webdevops-nginx/tasks/bootstrap.yml new file mode 100644 index 000000000..7edb04ee4 --- /dev/null +++ b/docker/php-nginx/7.0/conf/provision/roles/webdevops-nginx/tasks/bootstrap.yml @@ -0,0 +1,86 @@ +--- + +- name: Diable nginx demonize mode + lineinfile: + dest: /etc/nginx/nginx.conf + regexp: '[\s;]*{{ item.key }}[\s]*' + line: '{{ item.key }} {{ item.value }};' + with_items: + - { key: 'daemon', value: "off" } + +- name: Set access_log to stdout + replace: + dest: /etc/nginx/nginx.conf + regexp: '^([ \t]*access_log)[ \t]*([^\t ;]+)(.*;)$' + replace: '\1 /docker.stdout \3' + +- name: Set access_log to stdout + replace: + dest: /etc/nginx/nginx.conf + regexp: '^([ \t]*error_log)[ \t]*([^\t ;]+)(.*;)$' + replace: '\1 /docker.stdout \3' + +- name: Enable nginx main config + file: + src: '/opt/docker/etc/nginx/main.conf' + dest: '/etc/nginx/conf.d/10-docker.conf' + state: link + force: yes + +- name: Remove default vhost + file: + path: "{{ item }}" + state: absent + with_items: + # Debian family + - "/etc/nginx/sites-enabled/default" + # Alpine + - "/etc/nginx/conf.d/default.conf" + + +- name: Replace default nginx.conf [RedHat/Alpine family] + file: + src: '/opt/docker/etc/nginx/nginx.conf' + dest: '/etc/nginx/nginx.conf' + state: link + force: yes + when: ansible_os_family == 'RedHat' or ansible_os_family == 'Alpine' + +- name: Ensure document root is available + file: + path: "{{ DOCUMENT_ROOT }}" + state: directory + recurse: yes + +- name: Remove old log directory + file: + path: "/var/lib/nginx/logs" + state: absent + +- name: Create log directory + file: + path: "/var/lib/nginx/logs" + state: directory + +- name: Create stdout symlinks + file: + dest: "{{ item }}" + src: "/docker.stdout" + state: link + force: yes + with_items: + - "/var/lib/nginx/logs/access.log" + - "/var/lib/nginx/logs/error.log" + +- name: Fix rights of ssl files + file: + path: "{{ item.path }}" + state: "{{ item.state }}" + mode: "{{ item.mode }}" + owner: "root" + group: "root" + with_items: + - { path: '/opt/docker/etc/nginx/ssl', state: 'directory', mode: '0750' } + - { path: '/opt/docker/etc/nginx/ssl/server.crt', state: 'file', mode: '0640' } + - { path: '/opt/docker/etc/nginx/ssl/server.csr', state: 'file', mode: '0640' } + - { path: '/opt/docker/etc/nginx/ssl/server.key', state: 'file', mode: '0640' } diff --git a/docker/php-nginx/7.0/conf/provision/roles/webdevops-nginx/tasks/main.yml b/docker/php-nginx/7.0/conf/provision/roles/webdevops-nginx/tasks/main.yml new file mode 100644 index 000000000..1806c1a8c --- /dev/null +++ b/docker/php-nginx/7.0/conf/provision/roles/webdevops-nginx/tasks/main.yml @@ -0,0 +1,5 @@ +--- + +- include: bootstrap.yml + tags: + - bootstrap diff --git a/docker/php-nginx/7.0/conf/provision/roles/webdevops-php-nginx/defaults/main.yml b/docker/php-nginx/7.0/conf/provision/roles/webdevops-php-nginx/defaults/main.yml new file mode 100644 index 000000000..ed97d539c --- /dev/null +++ b/docker/php-nginx/7.0/conf/provision/roles/webdevops-php-nginx/defaults/main.yml @@ -0,0 +1 @@ +--- diff --git a/docker/php-nginx/7.0/conf/provision/roles/webdevops-php-nginx/tasks/bootstrap.yml b/docker/php-nginx/7.0/conf/provision/roles/webdevops-php-nginx/tasks/bootstrap.yml new file mode 100644 index 000000000..a2866e0d0 --- /dev/null +++ b/docker/php-nginx/7.0/conf/provision/roles/webdevops-php-nginx/tasks/bootstrap.yml @@ -0,0 +1,9 @@ +--- + +- name: Restrict php-fpm to local connection + lineinfile: + dest: '/opt/docker/etc/php/fpm/pool.d/application.conf' + regexp: '^[\s;]*{{ item.key }}[\s]*=' + line: '{{ item.key }} = {{ item.value }}' + with_items: + - { key: 'listen', value: "127.0.0.1:9000" } diff --git a/docker/php-nginx/7.0/conf/provision/roles/webdevops-php-nginx/tasks/entrypoint.yml b/docker/php-nginx/7.0/conf/provision/roles/webdevops-php-nginx/tasks/entrypoint.yml new file mode 100644 index 000000000..cd21505a4 --- /dev/null +++ b/docker/php-nginx/7.0/conf/provision/roles/webdevops-php-nginx/tasks/entrypoint.yml @@ -0,0 +1,2 @@ +--- + diff --git a/docker/php-nginx/7.0/conf/provision/roles/webdevops-php-nginx/tasks/main.yml b/docker/php-nginx/7.0/conf/provision/roles/webdevops-php-nginx/tasks/main.yml new file mode 100644 index 000000000..7895a52a9 --- /dev/null +++ b/docker/php-nginx/7.0/conf/provision/roles/webdevops-php-nginx/tasks/main.yml @@ -0,0 +1,9 @@ +--- + +- include: bootstrap.yml + tags: + - bootstrap + +- include: entrypoint.yml + tags: + - entrypoint diff --git a/docker/php-nginx/7.1/Dockerfile b/docker/php-nginx/7.1/Dockerfile new file mode 100644 index 000000000..14b6a6841 --- /dev/null +++ b/docker/php-nginx/7.1/Dockerfile @@ -0,0 +1,22 @@ +#+++++++++++++++++++++++++++++++++++++++ +# Dockerfile for webdevops/php-nginx:7.1 +# -- automatically generated -- +#+++++++++++++++++++++++++++++++++++++++ + +FROM webdevops/php:7.1 + +ENV WEB_DOCUMENT_ROOT=/app \ + WEB_DOCUMENT_INDEX=index.php \ + WEB_ALIAS_DOMAIN=*.vm +ENV WEB_PHP_SOCKET=127.0.0.1:9000 + +COPY conf/ /opt/docker/ + +# Install nginx +RUN /usr/local/bin/apt-install \ + nginx \ + && /opt/docker/bin/provision run --tag bootstrap --role webdevops-nginx --role webdevops-php-nginx \ + && /opt/docker/bin/bootstrap.sh \ + && docker-image-cleanup + +EXPOSE 80 443 diff --git a/docker/php-nginx/7.1/Dockerfile.jinja2 b/docker/php-nginx/7.1/Dockerfile.jinja2 new file mode 100644 index 000000000..2bdee366d --- /dev/null +++ b/docker/php-nginx/7.1/Dockerfile.jinja2 @@ -0,0 +1,10 @@ +{{ docker.from("php", "7.1") }} + +{{ environment.web() }} +{{ environment.webPhp() }} + +{{ docker.copy('conf/', '/opt/docker/') }} + +{{ nginx.debian('php-nginx') }} + +{{ docker.expose('80 443') }} diff --git a/docker/php-nginx/7.1/conf/bin/service.d/nginx.d/10-init.sh b/docker/php-nginx/7.1/conf/bin/service.d/nginx.d/10-init.sh new file mode 100644 index 000000000..27b9776cc --- /dev/null +++ b/docker/php-nginx/7.1/conf/bin/service.d/nginx.d/10-init.sh @@ -0,0 +1,25 @@ +if [[ ! -e "$WEB_DOCUMENT_ROOT" ]]; then + echo "" + echo "[WARNING] WEB_DOCUMENT_ROOT does not exists with path \"$WEB_DOCUMENT_ROOT\"!" + echo "" +fi + +# Prevent startup of nginx (ubuntu 16.04 needs it) +ln -f -s /var/lib/nginx/logs /var/log/nginx + +# Replace markers +go-replace \ + -s "" -r "$WEB_DOCUMENT_INDEX" \ + -s "" -r "$WEB_DOCUMENT_ROOT" \ + -s "" -r "$WEB_ALIAS_DOMAIN" \ + -s "" -r "$HOSTNAME" \ + -s "" -r "$WEB_PHP_SOCKET" \ + --path=/opt/docker/etc/nginx/ \ + --path-pattern='*.conf' \ + --ignore-empty + +if [[ -z "${WEB_PHP_SOCKET+x}" ]]; then + ## WEB_PHP_SOCKET is not set, remove PHP files + rm -f -- /opt/docker/etc/nginx/conf.d/10-php.conf + rm -f -- /opt/docker/etc/nginx/vhost.common.d/10-php.conf +fi diff --git a/docker/php-nginx/7.1/conf/bin/service.d/nginx.sh b/docker/php-nginx/7.1/conf/bin/service.d/nginx.sh new file mode 100644 index 000000000..f5cd26167 --- /dev/null +++ b/docker/php-nginx/7.1/conf/bin/service.d/nginx.sh @@ -0,0 +1,7 @@ +#!/usr/bin/env bash + +source /opt/docker/bin/config.sh + +includeScriptDir "/opt/docker/bin/service.d/nginx.d/" + +exec /usr/sbin/nginx diff --git a/docker/php-nginx/7.1/conf/etc/nginx/conf.d/.gitkeep b/docker/php-nginx/7.1/conf/etc/nginx/conf.d/.gitkeep new file mode 100644 index 000000000..e69de29bb diff --git a/docker/php-nginx/7.1/conf/etc/nginx/conf.d/10-php.conf b/docker/php-nginx/7.1/conf/etc/nginx/conf.d/10-php.conf new file mode 100644 index 000000000..9abe45f0a --- /dev/null +++ b/docker/php-nginx/7.1/conf/etc/nginx/conf.d/10-php.conf @@ -0,0 +1,3 @@ +upstream php { + server ; +} diff --git a/docker/php-nginx/7.1/conf/etc/nginx/global.conf b/docker/php-nginx/7.1/conf/etc/nginx/global.conf new file mode 100644 index 000000000..b6141db09 --- /dev/null +++ b/docker/php-nginx/7.1/conf/etc/nginx/global.conf @@ -0,0 +1 @@ +# deprecated diff --git a/docker/php-nginx/7.1/conf/etc/nginx/main.conf b/docker/php-nginx/7.1/conf/etc/nginx/main.conf new file mode 100644 index 000000000..06de0651b --- /dev/null +++ b/docker/php-nginx/7.1/conf/etc/nginx/main.conf @@ -0,0 +1,4 @@ +include /opt/docker/etc/nginx/global.conf; +include /opt/docker/etc/nginx/php.conf; +include /opt/docker/etc/nginx/conf.d/*.conf; +include /opt/docker/etc/nginx/vhost.conf; diff --git a/docker/php-nginx/7.1/conf/etc/nginx/php.conf b/docker/php-nginx/7.1/conf/etc/nginx/php.conf new file mode 100644 index 000000000..b6141db09 --- /dev/null +++ b/docker/php-nginx/7.1/conf/etc/nginx/php.conf @@ -0,0 +1 @@ +# deprecated diff --git a/docker/php-nginx/7.1/conf/etc/nginx/ssl/server.crt b/docker/php-nginx/7.1/conf/etc/nginx/ssl/server.crt new file mode 100644 index 000000000..6b0694907 --- /dev/null +++ b/docker/php-nginx/7.1/conf/etc/nginx/ssl/server.crt @@ -0,0 +1,28 @@ +-----BEGIN CERTIFICATE----- +MIIE1DCCArwCCQDMMwGnSuK0tTANBgkqhkiG9w0BAQsFADAsMRswGQYDVQQKExJE +b2NrZXIgQm9pbGVycGxhdGUxDTALBgNVBAMUBCoudm0wHhcNMTUwNTA0MTcxNDQw +WhcNMjUwNTAxMTcxNDQwWjAsMRswGQYDVQQKExJEb2NrZXIgQm9pbGVycGxhdGUx +DTALBgNVBAMUBCoudm0wggIiMA0GCSqGSIb3DQEBAQUAA4ICDwAwggIKAoICAQDK +3TIUiyDvXelWeY9VXMrpjuZtYpVSDsACLpjFUhMnsP5/iKT0VbeZyqHvmwZjAg4G +Y10d+yZDdgv/xeu0HPOFbtR6pCp10d1tdLHZto5Cyuxu7IQsAVjnD6Ko7XFwtNk7 +9o6JZfAFaGL4w5MokrVmCtspnsMZH7/7zU4f96cbF39zLopnpuXGD6t6DA8Qj3gy +0duaTjs42bYRN+rwLzVKAev99iQ4kPMJn4vV6/Xk6rtoSzC67GQyVZYaFypicD1S +NtsRmgEVvjCBDbrLOneUiRwff6qxEsZi7Hxv7BKFj4iUWnII7K/nP7T6uBHQjHO+ +FpsGkU9lCMrCeVFBe8kKz/cbhd+yLUxXwAPr6gSOPmwn232Gy4tozvqZHpbUxsgx +7sT3ej9K66h1D7J+BjNFWYM1hbnC1r7H/xS7EBzBV8qRoQCVe08Juf5xsouXFakD +clLV4+L+1cxkpwsCQDly5g3tm/TBqA2O+ZJ+YHQDHKkzMyhLs6i0X/M5qvJBiLg1 +GLTCS20rpQ5gXTEGuINqHgwXQWkUO6bhgSYqdHGX3zbZ5+qWpI4eui3dHZ1Ll0VH +6Icpb7ORTQwhc6W8KBlybssYPSlGOEBGUjYGNheoz9FpoSkxCis+P8ZNKtrmpPoq +Su0eOOGFOFHG02eOgPVxSwrDeN9MVJo7BPysGMHJmQIDAQABMA0GCSqGSIb3DQEB +CwUAA4ICAQC63g6NHmQKbiy3G6iaDkpUSbr5Mq2YgU61XnvWVyREqDcy/BXCw9oY +SJ/KUvCpqPnACNOFqjadRAmPiA9nf2WduoCgwQGV/YRFGswSuVvh/3X2TX5NWvbS +t8MQDttQg1dxpiMUjlu3rqhfohBdWJvp2lVSdpDb/MOlXBc/+p7HfOHwhqB7wwPN +NNbSKUbZqZxmD8cOf1X0hASr1yfFPj+2vST3ESaON8S0T2p63YX/sD5jvOUiEuyw +I5WcvLmiRZA07SH8nWyckLY3qWL+OlhSZrlAnolWS00b+7h5LNuRYEjKzwVgntoA +aCopyQih6wIk0+AfJO4sfhJBmQhnIrAaP/zwBH5g9zVizLf5H7U+hNXrMwgw55Sq +vjMdkZHvPKUXTvVit/rYE9H+PY3brkRWzOl4V/i/ZLJJm5805H/NyTbz9kPMJw2Q +nn+KOpfXXySD39f8iuRgSKXsYNul38hxWgcZZ6g+sOOp2n/VUmf0eZUWNnJ8i7AP +4Qif7aDKMcibOwSwsB+DKZXDvZ5XSdnMphtuLS5rPSL81rVRmWC2DMfQ2eP8j0WN +VTroSk0xedQ7Qr+9TNooi9IyzX6n1a2S1UiciEZ3ZcDbXPl/P01m+IYZyPnLv0+9 +ZeioZYh1JLv3/OKsMrMLTfh2ZCj3aXwmc2Owi/wU2LS5QUOMcHH7CQ== +-----END CERTIFICATE----- \ No newline at end of file diff --git a/docker/php-nginx/7.1/conf/etc/nginx/ssl/server.csr b/docker/php-nginx/7.1/conf/etc/nginx/ssl/server.csr new file mode 100644 index 000000000..8a9909f77 --- /dev/null +++ b/docker/php-nginx/7.1/conf/etc/nginx/ssl/server.csr @@ -0,0 +1,26 @@ +-----BEGIN CERTIFICATE REQUEST----- +MIIEcTCCAlkCAQAwLDEbMBkGA1UEChMSRG9ja2VyIEJvaWxlcnBsYXRlMQ0wCwYD +VQQDFAQqLnZtMIICIjANBgkqhkiG9w0BAQEFAAOCAg8AMIICCgKCAgEAyt0yFIsg +713pVnmPVVzK6Y7mbWKVUg7AAi6YxVITJ7D+f4ik9FW3mcqh75sGYwIOBmNdHfsm +Q3YL/8XrtBzzhW7UeqQqddHdbXSx2baOQsrsbuyELAFY5w+iqO1xcLTZO/aOiWXw +BWhi+MOTKJK1ZgrbKZ7DGR+/+81OH/enGxd/cy6KZ6blxg+regwPEI94MtHbmk47 +ONm2ETfq8C81SgHr/fYkOJDzCZ+L1ev15Oq7aEswuuxkMlWWGhcqYnA9UjbbEZoB +Fb4wgQ26yzp3lIkcH3+qsRLGYux8b+wShY+IlFpyCOyv5z+0+rgR0IxzvhabBpFP +ZQjKwnlRQXvJCs/3G4Xfsi1MV8AD6+oEjj5sJ9t9hsuLaM76mR6W1MbIMe7E93o/ +SuuodQ+yfgYzRVmDNYW5wta+x/8UuxAcwVfKkaEAlXtPCbn+cbKLlxWpA3JS1ePi +/tXMZKcLAkA5cuYN7Zv0wagNjvmSfmB0AxypMzMoS7OotF/zOaryQYi4NRi0wktt +K6UOYF0xBriDah4MF0FpFDum4YEmKnRxl9822efqlqSOHrot3R2dS5dFR+iHKW+z +kU0MIXOlvCgZcm7LGD0pRjhARlI2BjYXqM/RaaEpMQorPj/GTSra5qT6KkrtHjjh +hThRxtNnjoD1cUsKw3jfTFSaOwT8rBjByZkCAwEAAaAAMA0GCSqGSIb3DQEBCwUA +A4ICAQBsEBgC2YepuZq/8UqvKMZKVy/etDKXj7BB+QPb+leNiKD7p4LDxHJsZSH8 +Ku9uMPeLfiQDn5jA41k5SlGttzvObd65RdEbO3yHpqsg05EGSDDLfaE1k2Al/qmX +/o8roPZF7+2kZthgMAgkcokS54LYqEYTGqOf3J9Ss0yRIZwhaOVebfFIbIOdpw0B +JNMIJPHTMdZrcuRVI+wR1uPLIlEJzBvxTGbTrvPU25WJFtu+EajKqXO0SHdy0yx8 +uH4ykRBJRc36+oYo7nZ5D56dh7pZn3+9J64FKAOV0Q3KqMFieGy053ezuhJd70eZ +UozTgfjs3WpMzoYmKETSyl3XZSdInRe+sUlKPruTsKyg69oYxjPlrGfAmmGcCFca +TnZinT18dI92zK7OtOVkmYeYKC1lwuhftVrNMXzZuHOGpS9NNYtc4nDqDMIEOfV3 +6rCdu03WjEgJ+Z67tJs16xOx9du4/EHxS2Ijn9DPfVJvYy0TgzDi1BUpjWx0KTLx +C4OQbEZ/QTWmHVbSch/hcZhzbf7SNh5RpnW4EtmcpDFjIKMfxJmoKeiTf7qnilx0 +7uRvsZFKoDKRDOFiPfgMg5AOtLHziYsd9m0tJjC2GHvFuPjzOtzhnUUjmmvht170 +2aqKakjST4amg7jzLcs871HX0/WjOtt29NpOz140blkKf1bisg== +-----END CERTIFICATE REQUEST----- \ No newline at end of file diff --git a/docker/php-nginx/7.1/conf/etc/nginx/ssl/server.key b/docker/php-nginx/7.1/conf/etc/nginx/ssl/server.key new file mode 100644 index 000000000..c9eec145f --- /dev/null +++ b/docker/php-nginx/7.1/conf/etc/nginx/ssl/server.key @@ -0,0 +1,51 @@ +-----BEGIN RSA PRIVATE KEY----- +MIIJKAIBAAKCAgEAyt0yFIsg713pVnmPVVzK6Y7mbWKVUg7AAi6YxVITJ7D+f4ik +9FW3mcqh75sGYwIOBmNdHfsmQ3YL/8XrtBzzhW7UeqQqddHdbXSx2baOQsrsbuyE +LAFY5w+iqO1xcLTZO/aOiWXwBWhi+MOTKJK1ZgrbKZ7DGR+/+81OH/enGxd/cy6K +Z6blxg+regwPEI94MtHbmk47ONm2ETfq8C81SgHr/fYkOJDzCZ+L1ev15Oq7aEsw +uuxkMlWWGhcqYnA9UjbbEZoBFb4wgQ26yzp3lIkcH3+qsRLGYux8b+wShY+IlFpy +COyv5z+0+rgR0IxzvhabBpFPZQjKwnlRQXvJCs/3G4Xfsi1MV8AD6+oEjj5sJ9t9 +hsuLaM76mR6W1MbIMe7E93o/SuuodQ+yfgYzRVmDNYW5wta+x/8UuxAcwVfKkaEA +lXtPCbn+cbKLlxWpA3JS1ePi/tXMZKcLAkA5cuYN7Zv0wagNjvmSfmB0AxypMzMo +S7OotF/zOaryQYi4NRi0wkttK6UOYF0xBriDah4MF0FpFDum4YEmKnRxl9822efq +lqSOHrot3R2dS5dFR+iHKW+zkU0MIXOlvCgZcm7LGD0pRjhARlI2BjYXqM/RaaEp +MQorPj/GTSra5qT6KkrtHjjhhThRxtNnjoD1cUsKw3jfTFSaOwT8rBjByZkCAwEA +AQKCAgAbZPdoUsllyZbC+LNkYZ19ILD5QIDNjfRb1xMGQmkXyQz1B+zOmeyrNfPc +OWEJabOfJTfj3pByN7SzG3US4333HNpQnW6mbmqqZ0HFFqPrXR/Ecuf+UUhCG5hp +m3bgM2vKbyccYsmg0VHcKfzrU7RvTTP/UNMjx2fThwvvwS+ttuSdF0HVcXJB5sfP +OWWnZNhkdHZlRf81VCED/jsZqCZYEh5eMyj9AoXvXL4zayPPf+tC0DSKaXW2Xlxg +tZQhqup8+a9nlxZia0Z9hu8clo6jXkiP8FuKgfCMV0cOjiCKLLHS5svTbLLsVWwJ +F2ZAdVcD6mWQ43qHOEK5NEzGvQKO14CaOLnVT2yAkMcyNohsEgoDP9oCBGDJQbBH +NmtZfpVjjtuTr9P9TEkU1FcBRo0x6Il/DkzamGbOeFAmgnaGElhJ5c/CAG7whaIf +mUfFOBGPH/wESY3gBOACDofeSh27RrlvbLaPiCGKivDUTBmhBsIuso6XqOKbvtfV +/HhhndpdRVfIj4DdE7gIrLIGN977JMVAXFCNz7KrvAWwcOXrCHCoWpklJ9repq8l +26ICY8K7VXktzDHQUmhd88ZWR+9ASURsJghUgZUOcMrEGyvci6Y8hpLhHiNVPHuQ ++ps7tpPsXSntBUqWBzhRZh74+nJlOOV6oYykl30JT2JzB6lwiQKCAQEA9ecn8N2z +20tR2UEiTv/MjVSepQtAAajegvcd1iasvvQKXnh3XLmoZHzH2tTa0lp5RIZpUQPl +lOTwko0lYTBnYblt65AJQ3FTgisNobIpoqE8BFXLm6wggz7CbabjmPGDe173lPGR +sI0YSKYvzrdn4zw8Fh6WULJyZHLi58zJYL3r0WBDiOoxpGaGA1GlmkuIWjhKHaX2 +OvF1vOuQDJ2eDyTc5TYFC0NKG76Mvanov5L/yrhNM/umbmp0SPspzHGZobAKUr20 +OazFT8S+2TA1OTxWNbiPbSimFoaZbEdqsNACGfVJWO8Sh8iqlt5RmEcSiSvGBj6L +QKprRO9Fsp2GawKCAQEA0zGhRsnux4JTNsdUSYsEJtITMj6eE+nl7CoZ9DAOwC5X +6/aSpUE4TT+pWNrt9iluXiGL0j89UJ7r/L1OcsiyzGb8ig9NU4zr1NIGTZ0DstHi +HPYINjeiBJEFIy17kOQn+9/I5c4hBUwz6ihwNoEomymVB/EsLJKAML0AudJGKg+Z +/f/qrS40eab5SAiaKgsh0MZnj+vIxyGBydt6r2HGmjfNITVbXIu6IpO+6NXDwM/e +7v10AAZ3j9+gb1RedLg2ghuIuYU90hmMhtVWsh9nVmaOkMW9/WFgOPYvt/mHH/hR +d4pePZ9kACGmqo/b9sHvHw1YEubtCt1VUiNuFxnJCwKCAQBWnxz0vkRTJY8phsY9 +KeK2jm5sGTBs5T2syLwb6ffENFdKvAjgAw6Mh2And/+1ReWd+/MxdLv03UjZdxsJ +x3FDfXx5FH4O4ebW3a+pnAcKoN1xcX+N0O6LDRqUYcue3sTAOs3gC9CUbr91KAWD +Phw8ccWAzTmKJ7IgLFA982ekyoI9eTmRC159WRgwJxy844qerWF+XC4GyXP+HsTZ +jNRW5Vdi7sqMEyIR7+fIEAhLI88zbATWIPmZv6pC4ybwO7wwtsCMMQNBpdjDprzL +6S12ggikV+U+QKlxGe0FtYqhykRTPJKf32eZqVheWOZJTA/9fgv9ux52oxGycM8O +gmsNAoIBAQC60m5uZnd5uYnPLWkcXYNgq/kbO1UvHHut/FhVMKX7z4MrU0XKNfWO +MECoP5K9bU0aq+Y6KIMe7FapjvT0iSHRu1Cu+HZY8JI2A0xcIAeDijLRl7sP6wrB +q1+2DKgANjRAlWfsEfoX658JBpitPngjOheBnRCMpVQMyUT5HE/BKWf5zwdUB0mY +S+K8nA90HcDeJIS8RcGolbVwUV0oBABhr/cf50lYhqozqCr7YQ33ZGs7Uq3oz8+4 +UARmN2YPLl3Znm3GX12em8c6B0LX8vvA7Jw06Rf2Ksup1+3Ce1PTLiEy9A4FyRf3 +Hc2HmBbnJAtZlr5QikMqlzzAmmLqwH6dAoIBAC+ryaQGJFsijCSuaDfRp/uy9xnd +DjgMdTwjl5WLBmyudChVMANl8eqCbvVO41CN84yORk03oQ4cx0eKxAZaLaSzgkb3 +W0X2nFQe7VJSYMQswCQ+1WfJvEFrIdkEKIa//uQdhqNrgUKSNVhhSTMbNEkDTIWn +ssbv2H9hvUaFt/J/vP9zCKuU5oYvNU7Oi6ZXRYezRn9atlJYanLFoJnHUBRzGms5 +K0vhdCPDXQq87z5Yudoh0jLUQF9Nx0GTWeBceQ9n5hZeRUNQWxP4AJThQX9KSPTS +mbL3Kh4XNRmAUJ2N+Njh+3dg91s+JkKvC1wcspLsmLPQe+9AxBSH9y5JE/8= +-----END RSA PRIVATE KEY----- \ No newline at end of file diff --git a/docker/php-nginx/7.1/conf/etc/nginx/vhost.common.conf b/docker/php-nginx/7.1/conf/etc/nginx/vhost.common.conf new file mode 100644 index 000000000..a5df62ef8 --- /dev/null +++ b/docker/php-nginx/7.1/conf/etc/nginx/vhost.common.conf @@ -0,0 +1,2 @@ +# compatibility for PHP and TYPO3 Docker Boilerplate +include /opt/docker/etc/nginx/vhost.common.d/*.conf; diff --git a/docker/php-nginx/7.1/conf/etc/nginx/vhost.common.d/.gitkeep b/docker/php-nginx/7.1/conf/etc/nginx/vhost.common.d/.gitkeep new file mode 100644 index 000000000..e69de29bb diff --git a/docker/php-nginx/7.1/conf/etc/nginx/vhost.common.d/10-general.conf b/docker/php-nginx/7.1/conf/etc/nginx/vhost.common.d/10-general.conf new file mode 100644 index 000000000..d3fd0aa5e --- /dev/null +++ b/docker/php-nginx/7.1/conf/etc/nginx/vhost.common.d/10-general.conf @@ -0,0 +1 @@ +client_max_body_size 50m; diff --git a/docker/php-nginx/7.1/conf/etc/nginx/vhost.common.d/10-location-root.conf b/docker/php-nginx/7.1/conf/etc/nginx/vhost.common.d/10-location-root.conf new file mode 100644 index 000000000..28fd811bc --- /dev/null +++ b/docker/php-nginx/7.1/conf/etc/nginx/vhost.common.d/10-location-root.conf @@ -0,0 +1,3 @@ +location / { + try_files $uri $uri/ /?$query_string; +} diff --git a/docker/php-nginx/7.1/conf/etc/nginx/vhost.common.d/10-log.conf b/docker/php-nginx/7.1/conf/etc/nginx/vhost.common.d/10-log.conf new file mode 100644 index 000000000..9646c6826 --- /dev/null +++ b/docker/php-nginx/7.1/conf/etc/nginx/vhost.common.d/10-log.conf @@ -0,0 +1,2 @@ +access_log /docker.stdout; +error_log /docker.stderr warn; diff --git a/docker/php-nginx/7.1/conf/etc/nginx/vhost.common.d/10-php.conf b/docker/php-nginx/7.1/conf/etc/nginx/vhost.common.d/10-php.conf new file mode 100644 index 000000000..274beac87 --- /dev/null +++ b/docker/php-nginx/7.1/conf/etc/nginx/vhost.common.d/10-php.conf @@ -0,0 +1,7 @@ +location ~ \.php$ { + fastcgi_split_path_info ^(.+\.php)(/.+)$; + fastcgi_pass php; + include fastcgi_params; + fastcgi_param SCRIPT_FILENAME $request_filename; + fastcgi_read_timeout 1000; +} diff --git a/docker/php-nginx/7.1/conf/etc/nginx/vhost.conf b/docker/php-nginx/7.1/conf/etc/nginx/vhost.conf new file mode 100644 index 000000000..8225f314a --- /dev/null +++ b/docker/php-nginx/7.1/conf/etc/nginx/vhost.conf @@ -0,0 +1,26 @@ +server { + listen 80 default_server; + + server_name _ docker; + + root ""; + index ; + + include /opt/docker/etc/nginx/vhost.common.d/*.conf; +} + +############## +# SSL +############## + +server { + listen 443 default_server; + + server_name _ docker; + + root ""; + index ; + + include /opt/docker/etc/nginx/vhost.common.d/*.conf; + include /opt/docker/etc/nginx/vhost.ssl.conf; +} diff --git a/docker/php-nginx/7.1/conf/etc/nginx/vhost.ssl.conf b/docker/php-nginx/7.1/conf/etc/nginx/vhost.ssl.conf new file mode 100644 index 000000000..4ddba251d --- /dev/null +++ b/docker/php-nginx/7.1/conf/etc/nginx/vhost.ssl.conf @@ -0,0 +1,7 @@ +ssl on; +ssl_protocols TLSv1 TLSv1.1 TLSv1.2; # not possible to do exclusive +ssl_ciphers 'EDH+CAMELLIA:EDH+aRSA:EECDH+aRSA+AESGCM:EECDH+aRSA+SHA384:EECDH+aRSA+SHA256:EECDH:+CAMELLIA256:+AES256:+CAMELLIA128:+AES128:+SSLv3:!aNULL:!eNULL:!LOW:!3DES:!MD5:!EXP:!PSK:!DSS:!RC4:!SEED:!ECDSA:CAMELLIA256-SHA:AES256-SHA:CAMELLIA128-SHA:AES128-SHA'; +ssl_prefer_server_ciphers on; + +ssl_certificate /opt/docker/etc/nginx/ssl/server.crt; +ssl_certificate_key /opt/docker/etc/nginx/ssl/server.key; diff --git a/docker/php-nginx/7.1/conf/etc/supervisor.d/nginx.conf b/docker/php-nginx/7.1/conf/etc/supervisor.d/nginx.conf new file mode 100644 index 000000000..657bf499b --- /dev/null +++ b/docker/php-nginx/7.1/conf/etc/supervisor.d/nginx.conf @@ -0,0 +1,14 @@ +[group:nginx] +programs=nginxd +priority=20 + +[program:nginxd] +command = /opt/docker/bin/service.d/nginx.sh +process_name=%(program_name)s +startsecs = 0 +autostart = true +autorestart = true +stdout_logfile=/dev/stdout +stdout_logfile_maxbytes=0 +stderr_logfile=/dev/stderr +stderr_logfile_maxbytes=0 diff --git a/docker/php-nginx/7.1/conf/provision/roles/webdevops-nginx/defaults/main.yml b/docker/php-nginx/7.1/conf/provision/roles/webdevops-nginx/defaults/main.yml new file mode 100644 index 000000000..69cba1cb4 --- /dev/null +++ b/docker/php-nginx/7.1/conf/provision/roles/webdevops-nginx/defaults/main.yml @@ -0,0 +1,3 @@ +--- + +DOCUMENT_ROOT: "{{ lookup('env','WEB_DOCUMENT_ROOT') }}" diff --git a/docker/php-nginx/7.1/conf/provision/roles/webdevops-nginx/tasks/bootstrap.yml b/docker/php-nginx/7.1/conf/provision/roles/webdevops-nginx/tasks/bootstrap.yml new file mode 100644 index 000000000..7edb04ee4 --- /dev/null +++ b/docker/php-nginx/7.1/conf/provision/roles/webdevops-nginx/tasks/bootstrap.yml @@ -0,0 +1,86 @@ +--- + +- name: Diable nginx demonize mode + lineinfile: + dest: /etc/nginx/nginx.conf + regexp: '[\s;]*{{ item.key }}[\s]*' + line: '{{ item.key }} {{ item.value }};' + with_items: + - { key: 'daemon', value: "off" } + +- name: Set access_log to stdout + replace: + dest: /etc/nginx/nginx.conf + regexp: '^([ \t]*access_log)[ \t]*([^\t ;]+)(.*;)$' + replace: '\1 /docker.stdout \3' + +- name: Set access_log to stdout + replace: + dest: /etc/nginx/nginx.conf + regexp: '^([ \t]*error_log)[ \t]*([^\t ;]+)(.*;)$' + replace: '\1 /docker.stdout \3' + +- name: Enable nginx main config + file: + src: '/opt/docker/etc/nginx/main.conf' + dest: '/etc/nginx/conf.d/10-docker.conf' + state: link + force: yes + +- name: Remove default vhost + file: + path: "{{ item }}" + state: absent + with_items: + # Debian family + - "/etc/nginx/sites-enabled/default" + # Alpine + - "/etc/nginx/conf.d/default.conf" + + +- name: Replace default nginx.conf [RedHat/Alpine family] + file: + src: '/opt/docker/etc/nginx/nginx.conf' + dest: '/etc/nginx/nginx.conf' + state: link + force: yes + when: ansible_os_family == 'RedHat' or ansible_os_family == 'Alpine' + +- name: Ensure document root is available + file: + path: "{{ DOCUMENT_ROOT }}" + state: directory + recurse: yes + +- name: Remove old log directory + file: + path: "/var/lib/nginx/logs" + state: absent + +- name: Create log directory + file: + path: "/var/lib/nginx/logs" + state: directory + +- name: Create stdout symlinks + file: + dest: "{{ item }}" + src: "/docker.stdout" + state: link + force: yes + with_items: + - "/var/lib/nginx/logs/access.log" + - "/var/lib/nginx/logs/error.log" + +- name: Fix rights of ssl files + file: + path: "{{ item.path }}" + state: "{{ item.state }}" + mode: "{{ item.mode }}" + owner: "root" + group: "root" + with_items: + - { path: '/opt/docker/etc/nginx/ssl', state: 'directory', mode: '0750' } + - { path: '/opt/docker/etc/nginx/ssl/server.crt', state: 'file', mode: '0640' } + - { path: '/opt/docker/etc/nginx/ssl/server.csr', state: 'file', mode: '0640' } + - { path: '/opt/docker/etc/nginx/ssl/server.key', state: 'file', mode: '0640' } diff --git a/docker/php-nginx/7.1/conf/provision/roles/webdevops-nginx/tasks/main.yml b/docker/php-nginx/7.1/conf/provision/roles/webdevops-nginx/tasks/main.yml new file mode 100644 index 000000000..1806c1a8c --- /dev/null +++ b/docker/php-nginx/7.1/conf/provision/roles/webdevops-nginx/tasks/main.yml @@ -0,0 +1,5 @@ +--- + +- include: bootstrap.yml + tags: + - bootstrap diff --git a/docker/php-nginx/7.1/conf/provision/roles/webdevops-php-nginx/defaults/main.yml b/docker/php-nginx/7.1/conf/provision/roles/webdevops-php-nginx/defaults/main.yml new file mode 100644 index 000000000..ed97d539c --- /dev/null +++ b/docker/php-nginx/7.1/conf/provision/roles/webdevops-php-nginx/defaults/main.yml @@ -0,0 +1 @@ +--- diff --git a/docker/php-nginx/7.1/conf/provision/roles/webdevops-php-nginx/tasks/bootstrap.yml b/docker/php-nginx/7.1/conf/provision/roles/webdevops-php-nginx/tasks/bootstrap.yml new file mode 100644 index 000000000..a2866e0d0 --- /dev/null +++ b/docker/php-nginx/7.1/conf/provision/roles/webdevops-php-nginx/tasks/bootstrap.yml @@ -0,0 +1,9 @@ +--- + +- name: Restrict php-fpm to local connection + lineinfile: + dest: '/opt/docker/etc/php/fpm/pool.d/application.conf' + regexp: '^[\s;]*{{ item.key }}[\s]*=' + line: '{{ item.key }} = {{ item.value }}' + with_items: + - { key: 'listen', value: "127.0.0.1:9000" } diff --git a/docker/php-nginx/7.1/conf/provision/roles/webdevops-php-nginx/tasks/entrypoint.yml b/docker/php-nginx/7.1/conf/provision/roles/webdevops-php-nginx/tasks/entrypoint.yml new file mode 100644 index 000000000..cd21505a4 --- /dev/null +++ b/docker/php-nginx/7.1/conf/provision/roles/webdevops-php-nginx/tasks/entrypoint.yml @@ -0,0 +1,2 @@ +--- + diff --git a/docker/php-nginx/7.1/conf/provision/roles/webdevops-php-nginx/tasks/main.yml b/docker/php-nginx/7.1/conf/provision/roles/webdevops-php-nginx/tasks/main.yml new file mode 100644 index 000000000..7895a52a9 --- /dev/null +++ b/docker/php-nginx/7.1/conf/provision/roles/webdevops-php-nginx/tasks/main.yml @@ -0,0 +1,9 @@ +--- + +- include: bootstrap.yml + tags: + - bootstrap + +- include: entrypoint.yml + tags: + - entrypoint diff --git a/docker/php-nginx/alpine b/docker/php-nginx/alpine new file mode 120000 index 000000000..a5e678cb6 --- /dev/null +++ b/docker/php-nginx/alpine @@ -0,0 +1 @@ +alpine-php7 \ No newline at end of file diff --git a/docker/php-nginx/alpine-3 b/docker/php-nginx/alpine-3 new file mode 120000 index 000000000..a84cfe247 --- /dev/null +++ b/docker/php-nginx/alpine-3 @@ -0,0 +1 @@ +alpine-php5 \ No newline at end of file diff --git a/docker/php-nginx/alpine-3-php7 b/docker/php-nginx/alpine-3-php7 new file mode 120000 index 000000000..a5e678cb6 --- /dev/null +++ b/docker/php-nginx/alpine-3-php7 @@ -0,0 +1 @@ +alpine-php7 \ No newline at end of file diff --git a/docker/php-nginx/alpine-3-php7/Dockerfile b/docker/php-nginx/alpine-3-php7/Dockerfile deleted file mode 100644 index e101f74c8..000000000 --- a/docker/php-nginx/alpine-3-php7/Dockerfile +++ /dev/null @@ -1,27 +0,0 @@ -#+++++++++++++++++++++++++++++++++++++++ -# Dockerfile for webdevops/php-nginx:alpine-3-php7 -# -- automatically generated -- -#+++++++++++++++++++++++++++++++++++++++ - -FROM webdevops/php:alpine-3-php7 - -MAINTAINER info@webdevops.io -LABEL vendor=WebDevOps.io -LABEL io.webdevops.layout=8 -LABEL io.webdevops.version=1.5.0 - -ENV WEB_DOCUMENT_ROOT /app -ENV WEB_DOCUMENT_INDEX index.php -ENV WEB_ALIAS_DOMAIN *.vm -ENV WEB_PHP_SOCKET 127.0.0.1:9000 - -COPY conf/ /opt/docker/ - -# Install nginx -RUN /usr/local/bin/apk-install \ - nginx \ - && /opt/docker/bin/provision run --tag bootstrap --role webdevops-nginx --role webdevops-php-nginx \ - && /opt/docker/bin/bootstrap.sh - - -EXPOSE 80 443 diff --git a/docker/php-nginx/alpine-3-php7/Dockerfile.jinja2 b/docker/php-nginx/alpine-3-php7/Dockerfile.jinja2 deleted file mode 100644 index 4aabcf874..000000000 --- a/docker/php-nginx/alpine-3-php7/Dockerfile.jinja2 +++ /dev/null @@ -1,12 +0,0 @@ -{{ docker.from("php", "alpine-3-php7") }} - -{{ docker.version() }} - -{{ environment.web() }} -{{ environment.webPhp() }} - -{{ docker.copy('conf/', '/opt/docker/') }} - -{{ nginx.alpine('php-nginx') }} - -{{ docker.expose('80 443') }} diff --git a/docker/php-nginx/alpine-3-php7/conf/bin/service.d/nginx.d/10-init.sh b/docker/php-nginx/alpine-3-php7/conf/bin/service.d/nginx.d/10-init.sh deleted file mode 100644 index 75a84a4eb..000000000 --- a/docker/php-nginx/alpine-3-php7/conf/bin/service.d/nginx.d/10-init.sh +++ /dev/null @@ -1,23 +0,0 @@ -if [[ ! -e "$WEB_DOCUMENT_ROOT" ]]; then - echo "" - echo "[WARNING] WEB_DOCUMENT_ROOT does not exists with path \"$WEB_DOCUMENT_ROOT\"!" - echo "" -fi - -# Prevent startup of nginx (ubuntu 16.04 needs it) -ln -f -s /var/lib/nginx/logs /var/log/nginx - -# Replace markers -find /opt/docker/etc/nginx/ -iname '*.conf' -print0 | xargs -0 -r rpl --quiet "" "$WEB_DOCUMENT_INDEX" > /dev/null -find /opt/docker/etc/nginx/ -iname '*.conf' -print0 | xargs -0 -r rpl --quiet "" "$WEB_DOCUMENT_ROOT" > /dev/null -find /opt/docker/etc/nginx/ -iname '*.conf' -print0 | xargs -0 -r rpl --quiet "" "$WEB_ALIAS_DOMAIN" > /dev/null -find /opt/docker/etc/nginx/ -iname '*.conf' -print0 | xargs -0 -r rpl --quiet "" "$HOSTNAME" > /dev/null - -if [[ -n "${WEB_PHP_SOCKET+x}" ]]; then - ## WEB_PHP_SOCKET is set - find /opt/docker/etc/nginx/ -iname '*.conf' -print0 | xargs -0 -r rpl --quiet "" "$WEB_PHP_SOCKET" > /dev/null -else - ## WEB_PHP_SOCKET is not set, remove PHP files - rm -f -- /opt/docker/etc/nginx/conf.d/10-php.conf - rm -f -- /opt/docker/etc/nginx/vhost.common.d/10-php.conf -fi diff --git a/docker/php-nginx/alpine-3-php7/conf/etc/nginx/vhost.conf b/docker/php-nginx/alpine-3-php7/conf/etc/nginx/vhost.conf deleted file mode 100644 index d07e27094..000000000 --- a/docker/php-nginx/alpine-3-php7/conf/etc/nginx/vhost.conf +++ /dev/null @@ -1,38 +0,0 @@ -server { - listen 80 default_server; - listen 8000 default_server; - - server_name _ docker; - - access_log /docker.stdout; - error_log /docker.stdout info; - - root ""; - index ; - - client_max_body_size 50m; - - include /opt/docker/etc/nginx/vhost.common.d/*.conf; -} - -############## -# SSL -############## - -server { - listen 443 default_server; - listen 8443 default_server; - - server_name _ docker; - - access_log /docker.stdout; - error_log /docker.stdout info; - - root ""; - index ; - - client_max_body_size 50m; - - include /opt/docker/etc/nginx/vhost.common.d/*.conf; - include /opt/docker/etc/nginx/vhost.ssl.conf; -} diff --git a/docker/php-nginx/alpine-3/Dockerfile b/docker/php-nginx/alpine-3/Dockerfile deleted file mode 100644 index 604bf6177..000000000 --- a/docker/php-nginx/alpine-3/Dockerfile +++ /dev/null @@ -1,27 +0,0 @@ -#+++++++++++++++++++++++++++++++++++++++ -# Dockerfile for webdevops/php-nginx:alpine-3 -# -- automatically generated -- -#+++++++++++++++++++++++++++++++++++++++ - -FROM webdevops/php:alpine-3 - -MAINTAINER info@webdevops.io -LABEL vendor=WebDevOps.io -LABEL io.webdevops.layout=8 -LABEL io.webdevops.version=1.5.0 - -ENV WEB_DOCUMENT_ROOT /app -ENV WEB_DOCUMENT_INDEX index.php -ENV WEB_ALIAS_DOMAIN *.vm -ENV WEB_PHP_SOCKET 127.0.0.1:9000 - -COPY conf/ /opt/docker/ - -# Install nginx -RUN /usr/local/bin/apk-install \ - nginx \ - && /opt/docker/bin/provision run --tag bootstrap --role webdevops-nginx --role webdevops-php-nginx \ - && /opt/docker/bin/bootstrap.sh - - -EXPOSE 80 443 diff --git a/docker/php-nginx/alpine-3/Dockerfile.jinja2 b/docker/php-nginx/alpine-3/Dockerfile.jinja2 deleted file mode 100644 index b6d43f583..000000000 --- a/docker/php-nginx/alpine-3/Dockerfile.jinja2 +++ /dev/null @@ -1,12 +0,0 @@ -{{ docker.from("php", "alpine-3") }} - -{{ docker.version() }} - -{{ environment.web() }} -{{ environment.webPhp() }} - -{{ docker.copy('conf/', '/opt/docker/') }} - -{{ nginx.alpine('php-nginx') }} - -{{ docker.expose('80 443') }} diff --git a/docker/php-nginx/alpine-3/conf/bin/service.d/nginx.d/10-init.sh b/docker/php-nginx/alpine-3/conf/bin/service.d/nginx.d/10-init.sh deleted file mode 100644 index 75a84a4eb..000000000 --- a/docker/php-nginx/alpine-3/conf/bin/service.d/nginx.d/10-init.sh +++ /dev/null @@ -1,23 +0,0 @@ -if [[ ! -e "$WEB_DOCUMENT_ROOT" ]]; then - echo "" - echo "[WARNING] WEB_DOCUMENT_ROOT does not exists with path \"$WEB_DOCUMENT_ROOT\"!" - echo "" -fi - -# Prevent startup of nginx (ubuntu 16.04 needs it) -ln -f -s /var/lib/nginx/logs /var/log/nginx - -# Replace markers -find /opt/docker/etc/nginx/ -iname '*.conf' -print0 | xargs -0 -r rpl --quiet "" "$WEB_DOCUMENT_INDEX" > /dev/null -find /opt/docker/etc/nginx/ -iname '*.conf' -print0 | xargs -0 -r rpl --quiet "" "$WEB_DOCUMENT_ROOT" > /dev/null -find /opt/docker/etc/nginx/ -iname '*.conf' -print0 | xargs -0 -r rpl --quiet "" "$WEB_ALIAS_DOMAIN" > /dev/null -find /opt/docker/etc/nginx/ -iname '*.conf' -print0 | xargs -0 -r rpl --quiet "" "$HOSTNAME" > /dev/null - -if [[ -n "${WEB_PHP_SOCKET+x}" ]]; then - ## WEB_PHP_SOCKET is set - find /opt/docker/etc/nginx/ -iname '*.conf' -print0 | xargs -0 -r rpl --quiet "" "$WEB_PHP_SOCKET" > /dev/null -else - ## WEB_PHP_SOCKET is not set, remove PHP files - rm -f -- /opt/docker/etc/nginx/conf.d/10-php.conf - rm -f -- /opt/docker/etc/nginx/vhost.common.d/10-php.conf -fi diff --git a/docker/php-nginx/alpine-3/conf/etc/nginx/vhost.conf b/docker/php-nginx/alpine-3/conf/etc/nginx/vhost.conf deleted file mode 100644 index d07e27094..000000000 --- a/docker/php-nginx/alpine-3/conf/etc/nginx/vhost.conf +++ /dev/null @@ -1,38 +0,0 @@ -server { - listen 80 default_server; - listen 8000 default_server; - - server_name _ docker; - - access_log /docker.stdout; - error_log /docker.stdout info; - - root ""; - index ; - - client_max_body_size 50m; - - include /opt/docker/etc/nginx/vhost.common.d/*.conf; -} - -############## -# SSL -############## - -server { - listen 443 default_server; - listen 8443 default_server; - - server_name _ docker; - - access_log /docker.stdout; - error_log /docker.stdout info; - - root ""; - index ; - - client_max_body_size 50m; - - include /opt/docker/etc/nginx/vhost.common.d/*.conf; - include /opt/docker/etc/nginx/vhost.ssl.conf; -} diff --git a/docker/php-nginx/alpine-php5/Dockerfile b/docker/php-nginx/alpine-php5/Dockerfile new file mode 100644 index 000000000..956482262 --- /dev/null +++ b/docker/php-nginx/alpine-php5/Dockerfile @@ -0,0 +1,22 @@ +#+++++++++++++++++++++++++++++++++++++++ +# Dockerfile for webdevops/php-nginx:alpine-php5 +# -- automatically generated -- +#+++++++++++++++++++++++++++++++++++++++ + +FROM webdevops/php:alpine-php5 + +ENV WEB_DOCUMENT_ROOT=/app \ + WEB_DOCUMENT_INDEX=index.php \ + WEB_ALIAS_DOMAIN=*.vm +ENV WEB_PHP_SOCKET=127.0.0.1:9000 + +COPY conf/ /opt/docker/ + +# Install nginx +RUN /usr/local/bin/apk-install \ + nginx \ + && /opt/docker/bin/provision run --tag bootstrap --role webdevops-nginx --role webdevops-php-nginx \ + && /opt/docker/bin/bootstrap.sh \ + && docker-image-cleanup + +EXPOSE 80 443 diff --git a/docker/php-nginx/alpine-php5/Dockerfile.jinja2 b/docker/php-nginx/alpine-php5/Dockerfile.jinja2 new file mode 100644 index 000000000..fffeb1d1b --- /dev/null +++ b/docker/php-nginx/alpine-php5/Dockerfile.jinja2 @@ -0,0 +1,10 @@ +{{ docker.from("php", "alpine-php5") }} + +{{ environment.web() }} +{{ environment.webPhp() }} + +{{ docker.copy('conf/', '/opt/docker/') }} + +{{ nginx.alpine('php-nginx') }} + +{{ docker.expose('80 443') }} diff --git a/docker/php-nginx/alpine-php5/conf/bin/service.d/nginx.d/10-init.sh b/docker/php-nginx/alpine-php5/conf/bin/service.d/nginx.d/10-init.sh new file mode 100644 index 000000000..27b9776cc --- /dev/null +++ b/docker/php-nginx/alpine-php5/conf/bin/service.d/nginx.d/10-init.sh @@ -0,0 +1,25 @@ +if [[ ! -e "$WEB_DOCUMENT_ROOT" ]]; then + echo "" + echo "[WARNING] WEB_DOCUMENT_ROOT does not exists with path \"$WEB_DOCUMENT_ROOT\"!" + echo "" +fi + +# Prevent startup of nginx (ubuntu 16.04 needs it) +ln -f -s /var/lib/nginx/logs /var/log/nginx + +# Replace markers +go-replace \ + -s "" -r "$WEB_DOCUMENT_INDEX" \ + -s "" -r "$WEB_DOCUMENT_ROOT" \ + -s "" -r "$WEB_ALIAS_DOMAIN" \ + -s "" -r "$HOSTNAME" \ + -s "" -r "$WEB_PHP_SOCKET" \ + --path=/opt/docker/etc/nginx/ \ + --path-pattern='*.conf' \ + --ignore-empty + +if [[ -z "${WEB_PHP_SOCKET+x}" ]]; then + ## WEB_PHP_SOCKET is not set, remove PHP files + rm -f -- /opt/docker/etc/nginx/conf.d/10-php.conf + rm -f -- /opt/docker/etc/nginx/vhost.common.d/10-php.conf +fi diff --git a/docker/php-nginx/alpine-php5/conf/bin/service.d/nginx.sh b/docker/php-nginx/alpine-php5/conf/bin/service.d/nginx.sh new file mode 100644 index 000000000..f5cd26167 --- /dev/null +++ b/docker/php-nginx/alpine-php5/conf/bin/service.d/nginx.sh @@ -0,0 +1,7 @@ +#!/usr/bin/env bash + +source /opt/docker/bin/config.sh + +includeScriptDir "/opt/docker/bin/service.d/nginx.d/" + +exec /usr/sbin/nginx diff --git a/docker/php-nginx/alpine-php5/conf/etc/nginx/conf.d/.gitkeep b/docker/php-nginx/alpine-php5/conf/etc/nginx/conf.d/.gitkeep new file mode 100644 index 000000000..e69de29bb diff --git a/docker/php-nginx/alpine-php5/conf/etc/nginx/conf.d/10-php.conf b/docker/php-nginx/alpine-php5/conf/etc/nginx/conf.d/10-php.conf new file mode 100644 index 000000000..9abe45f0a --- /dev/null +++ b/docker/php-nginx/alpine-php5/conf/etc/nginx/conf.d/10-php.conf @@ -0,0 +1,3 @@ +upstream php { + server ; +} diff --git a/docker/php-nginx/alpine-php5/conf/etc/nginx/global.conf b/docker/php-nginx/alpine-php5/conf/etc/nginx/global.conf new file mode 100644 index 000000000..b6141db09 --- /dev/null +++ b/docker/php-nginx/alpine-php5/conf/etc/nginx/global.conf @@ -0,0 +1 @@ +# deprecated diff --git a/docker/php-nginx/alpine-php5/conf/etc/nginx/main.conf b/docker/php-nginx/alpine-php5/conf/etc/nginx/main.conf new file mode 100644 index 000000000..06de0651b --- /dev/null +++ b/docker/php-nginx/alpine-php5/conf/etc/nginx/main.conf @@ -0,0 +1,4 @@ +include /opt/docker/etc/nginx/global.conf; +include /opt/docker/etc/nginx/php.conf; +include /opt/docker/etc/nginx/conf.d/*.conf; +include /opt/docker/etc/nginx/vhost.conf; diff --git a/docker/php-nginx/alpine-3-php7/conf/etc/nginx/nginx.conf b/docker/php-nginx/alpine-php5/conf/etc/nginx/nginx.conf similarity index 100% rename from docker/php-nginx/alpine-3-php7/conf/etc/nginx/nginx.conf rename to docker/php-nginx/alpine-php5/conf/etc/nginx/nginx.conf diff --git a/docker/php-nginx/alpine-php5/conf/etc/nginx/php.conf b/docker/php-nginx/alpine-php5/conf/etc/nginx/php.conf new file mode 100644 index 000000000..b6141db09 --- /dev/null +++ b/docker/php-nginx/alpine-php5/conf/etc/nginx/php.conf @@ -0,0 +1 @@ +# deprecated diff --git a/docker/php-nginx/alpine-php5/conf/etc/nginx/ssl/server.crt b/docker/php-nginx/alpine-php5/conf/etc/nginx/ssl/server.crt new file mode 100644 index 000000000..6b0694907 --- /dev/null +++ b/docker/php-nginx/alpine-php5/conf/etc/nginx/ssl/server.crt @@ -0,0 +1,28 @@ +-----BEGIN CERTIFICATE----- +MIIE1DCCArwCCQDMMwGnSuK0tTANBgkqhkiG9w0BAQsFADAsMRswGQYDVQQKExJE +b2NrZXIgQm9pbGVycGxhdGUxDTALBgNVBAMUBCoudm0wHhcNMTUwNTA0MTcxNDQw +WhcNMjUwNTAxMTcxNDQwWjAsMRswGQYDVQQKExJEb2NrZXIgQm9pbGVycGxhdGUx +DTALBgNVBAMUBCoudm0wggIiMA0GCSqGSIb3DQEBAQUAA4ICDwAwggIKAoICAQDK +3TIUiyDvXelWeY9VXMrpjuZtYpVSDsACLpjFUhMnsP5/iKT0VbeZyqHvmwZjAg4G +Y10d+yZDdgv/xeu0HPOFbtR6pCp10d1tdLHZto5Cyuxu7IQsAVjnD6Ko7XFwtNk7 +9o6JZfAFaGL4w5MokrVmCtspnsMZH7/7zU4f96cbF39zLopnpuXGD6t6DA8Qj3gy +0duaTjs42bYRN+rwLzVKAev99iQ4kPMJn4vV6/Xk6rtoSzC67GQyVZYaFypicD1S +NtsRmgEVvjCBDbrLOneUiRwff6qxEsZi7Hxv7BKFj4iUWnII7K/nP7T6uBHQjHO+ +FpsGkU9lCMrCeVFBe8kKz/cbhd+yLUxXwAPr6gSOPmwn232Gy4tozvqZHpbUxsgx +7sT3ej9K66h1D7J+BjNFWYM1hbnC1r7H/xS7EBzBV8qRoQCVe08Juf5xsouXFakD +clLV4+L+1cxkpwsCQDly5g3tm/TBqA2O+ZJ+YHQDHKkzMyhLs6i0X/M5qvJBiLg1 +GLTCS20rpQ5gXTEGuINqHgwXQWkUO6bhgSYqdHGX3zbZ5+qWpI4eui3dHZ1Ll0VH +6Icpb7ORTQwhc6W8KBlybssYPSlGOEBGUjYGNheoz9FpoSkxCis+P8ZNKtrmpPoq +Su0eOOGFOFHG02eOgPVxSwrDeN9MVJo7BPysGMHJmQIDAQABMA0GCSqGSIb3DQEB +CwUAA4ICAQC63g6NHmQKbiy3G6iaDkpUSbr5Mq2YgU61XnvWVyREqDcy/BXCw9oY +SJ/KUvCpqPnACNOFqjadRAmPiA9nf2WduoCgwQGV/YRFGswSuVvh/3X2TX5NWvbS +t8MQDttQg1dxpiMUjlu3rqhfohBdWJvp2lVSdpDb/MOlXBc/+p7HfOHwhqB7wwPN +NNbSKUbZqZxmD8cOf1X0hASr1yfFPj+2vST3ESaON8S0T2p63YX/sD5jvOUiEuyw +I5WcvLmiRZA07SH8nWyckLY3qWL+OlhSZrlAnolWS00b+7h5LNuRYEjKzwVgntoA +aCopyQih6wIk0+AfJO4sfhJBmQhnIrAaP/zwBH5g9zVizLf5H7U+hNXrMwgw55Sq +vjMdkZHvPKUXTvVit/rYE9H+PY3brkRWzOl4V/i/ZLJJm5805H/NyTbz9kPMJw2Q +nn+KOpfXXySD39f8iuRgSKXsYNul38hxWgcZZ6g+sOOp2n/VUmf0eZUWNnJ8i7AP +4Qif7aDKMcibOwSwsB+DKZXDvZ5XSdnMphtuLS5rPSL81rVRmWC2DMfQ2eP8j0WN +VTroSk0xedQ7Qr+9TNooi9IyzX6n1a2S1UiciEZ3ZcDbXPl/P01m+IYZyPnLv0+9 +ZeioZYh1JLv3/OKsMrMLTfh2ZCj3aXwmc2Owi/wU2LS5QUOMcHH7CQ== +-----END CERTIFICATE----- \ No newline at end of file diff --git a/docker/php-nginx/alpine-php5/conf/etc/nginx/ssl/server.csr b/docker/php-nginx/alpine-php5/conf/etc/nginx/ssl/server.csr new file mode 100644 index 000000000..8a9909f77 --- /dev/null +++ b/docker/php-nginx/alpine-php5/conf/etc/nginx/ssl/server.csr @@ -0,0 +1,26 @@ +-----BEGIN CERTIFICATE REQUEST----- +MIIEcTCCAlkCAQAwLDEbMBkGA1UEChMSRG9ja2VyIEJvaWxlcnBsYXRlMQ0wCwYD +VQQDFAQqLnZtMIICIjANBgkqhkiG9w0BAQEFAAOCAg8AMIICCgKCAgEAyt0yFIsg +713pVnmPVVzK6Y7mbWKVUg7AAi6YxVITJ7D+f4ik9FW3mcqh75sGYwIOBmNdHfsm +Q3YL/8XrtBzzhW7UeqQqddHdbXSx2baOQsrsbuyELAFY5w+iqO1xcLTZO/aOiWXw +BWhi+MOTKJK1ZgrbKZ7DGR+/+81OH/enGxd/cy6KZ6blxg+regwPEI94MtHbmk47 +ONm2ETfq8C81SgHr/fYkOJDzCZ+L1ev15Oq7aEswuuxkMlWWGhcqYnA9UjbbEZoB +Fb4wgQ26yzp3lIkcH3+qsRLGYux8b+wShY+IlFpyCOyv5z+0+rgR0IxzvhabBpFP +ZQjKwnlRQXvJCs/3G4Xfsi1MV8AD6+oEjj5sJ9t9hsuLaM76mR6W1MbIMe7E93o/ +SuuodQ+yfgYzRVmDNYW5wta+x/8UuxAcwVfKkaEAlXtPCbn+cbKLlxWpA3JS1ePi +/tXMZKcLAkA5cuYN7Zv0wagNjvmSfmB0AxypMzMoS7OotF/zOaryQYi4NRi0wktt +K6UOYF0xBriDah4MF0FpFDum4YEmKnRxl9822efqlqSOHrot3R2dS5dFR+iHKW+z +kU0MIXOlvCgZcm7LGD0pRjhARlI2BjYXqM/RaaEpMQorPj/GTSra5qT6KkrtHjjh +hThRxtNnjoD1cUsKw3jfTFSaOwT8rBjByZkCAwEAAaAAMA0GCSqGSIb3DQEBCwUA +A4ICAQBsEBgC2YepuZq/8UqvKMZKVy/etDKXj7BB+QPb+leNiKD7p4LDxHJsZSH8 +Ku9uMPeLfiQDn5jA41k5SlGttzvObd65RdEbO3yHpqsg05EGSDDLfaE1k2Al/qmX +/o8roPZF7+2kZthgMAgkcokS54LYqEYTGqOf3J9Ss0yRIZwhaOVebfFIbIOdpw0B +JNMIJPHTMdZrcuRVI+wR1uPLIlEJzBvxTGbTrvPU25WJFtu+EajKqXO0SHdy0yx8 +uH4ykRBJRc36+oYo7nZ5D56dh7pZn3+9J64FKAOV0Q3KqMFieGy053ezuhJd70eZ +UozTgfjs3WpMzoYmKETSyl3XZSdInRe+sUlKPruTsKyg69oYxjPlrGfAmmGcCFca +TnZinT18dI92zK7OtOVkmYeYKC1lwuhftVrNMXzZuHOGpS9NNYtc4nDqDMIEOfV3 +6rCdu03WjEgJ+Z67tJs16xOx9du4/EHxS2Ijn9DPfVJvYy0TgzDi1BUpjWx0KTLx +C4OQbEZ/QTWmHVbSch/hcZhzbf7SNh5RpnW4EtmcpDFjIKMfxJmoKeiTf7qnilx0 +7uRvsZFKoDKRDOFiPfgMg5AOtLHziYsd9m0tJjC2GHvFuPjzOtzhnUUjmmvht170 +2aqKakjST4amg7jzLcs871HX0/WjOtt29NpOz140blkKf1bisg== +-----END CERTIFICATE REQUEST----- \ No newline at end of file diff --git a/docker/php-nginx/alpine-php5/conf/etc/nginx/ssl/server.key b/docker/php-nginx/alpine-php5/conf/etc/nginx/ssl/server.key new file mode 100644 index 000000000..c9eec145f --- /dev/null +++ b/docker/php-nginx/alpine-php5/conf/etc/nginx/ssl/server.key @@ -0,0 +1,51 @@ +-----BEGIN RSA PRIVATE KEY----- +MIIJKAIBAAKCAgEAyt0yFIsg713pVnmPVVzK6Y7mbWKVUg7AAi6YxVITJ7D+f4ik +9FW3mcqh75sGYwIOBmNdHfsmQ3YL/8XrtBzzhW7UeqQqddHdbXSx2baOQsrsbuyE +LAFY5w+iqO1xcLTZO/aOiWXwBWhi+MOTKJK1ZgrbKZ7DGR+/+81OH/enGxd/cy6K +Z6blxg+regwPEI94MtHbmk47ONm2ETfq8C81SgHr/fYkOJDzCZ+L1ev15Oq7aEsw +uuxkMlWWGhcqYnA9UjbbEZoBFb4wgQ26yzp3lIkcH3+qsRLGYux8b+wShY+IlFpy +COyv5z+0+rgR0IxzvhabBpFPZQjKwnlRQXvJCs/3G4Xfsi1MV8AD6+oEjj5sJ9t9 +hsuLaM76mR6W1MbIMe7E93o/SuuodQ+yfgYzRVmDNYW5wta+x/8UuxAcwVfKkaEA +lXtPCbn+cbKLlxWpA3JS1ePi/tXMZKcLAkA5cuYN7Zv0wagNjvmSfmB0AxypMzMo +S7OotF/zOaryQYi4NRi0wkttK6UOYF0xBriDah4MF0FpFDum4YEmKnRxl9822efq +lqSOHrot3R2dS5dFR+iHKW+zkU0MIXOlvCgZcm7LGD0pRjhARlI2BjYXqM/RaaEp +MQorPj/GTSra5qT6KkrtHjjhhThRxtNnjoD1cUsKw3jfTFSaOwT8rBjByZkCAwEA +AQKCAgAbZPdoUsllyZbC+LNkYZ19ILD5QIDNjfRb1xMGQmkXyQz1B+zOmeyrNfPc +OWEJabOfJTfj3pByN7SzG3US4333HNpQnW6mbmqqZ0HFFqPrXR/Ecuf+UUhCG5hp +m3bgM2vKbyccYsmg0VHcKfzrU7RvTTP/UNMjx2fThwvvwS+ttuSdF0HVcXJB5sfP +OWWnZNhkdHZlRf81VCED/jsZqCZYEh5eMyj9AoXvXL4zayPPf+tC0DSKaXW2Xlxg +tZQhqup8+a9nlxZia0Z9hu8clo6jXkiP8FuKgfCMV0cOjiCKLLHS5svTbLLsVWwJ +F2ZAdVcD6mWQ43qHOEK5NEzGvQKO14CaOLnVT2yAkMcyNohsEgoDP9oCBGDJQbBH +NmtZfpVjjtuTr9P9TEkU1FcBRo0x6Il/DkzamGbOeFAmgnaGElhJ5c/CAG7whaIf +mUfFOBGPH/wESY3gBOACDofeSh27RrlvbLaPiCGKivDUTBmhBsIuso6XqOKbvtfV +/HhhndpdRVfIj4DdE7gIrLIGN977JMVAXFCNz7KrvAWwcOXrCHCoWpklJ9repq8l +26ICY8K7VXktzDHQUmhd88ZWR+9ASURsJghUgZUOcMrEGyvci6Y8hpLhHiNVPHuQ ++ps7tpPsXSntBUqWBzhRZh74+nJlOOV6oYykl30JT2JzB6lwiQKCAQEA9ecn8N2z +20tR2UEiTv/MjVSepQtAAajegvcd1iasvvQKXnh3XLmoZHzH2tTa0lp5RIZpUQPl +lOTwko0lYTBnYblt65AJQ3FTgisNobIpoqE8BFXLm6wggz7CbabjmPGDe173lPGR +sI0YSKYvzrdn4zw8Fh6WULJyZHLi58zJYL3r0WBDiOoxpGaGA1GlmkuIWjhKHaX2 +OvF1vOuQDJ2eDyTc5TYFC0NKG76Mvanov5L/yrhNM/umbmp0SPspzHGZobAKUr20 +OazFT8S+2TA1OTxWNbiPbSimFoaZbEdqsNACGfVJWO8Sh8iqlt5RmEcSiSvGBj6L +QKprRO9Fsp2GawKCAQEA0zGhRsnux4JTNsdUSYsEJtITMj6eE+nl7CoZ9DAOwC5X +6/aSpUE4TT+pWNrt9iluXiGL0j89UJ7r/L1OcsiyzGb8ig9NU4zr1NIGTZ0DstHi +HPYINjeiBJEFIy17kOQn+9/I5c4hBUwz6ihwNoEomymVB/EsLJKAML0AudJGKg+Z +/f/qrS40eab5SAiaKgsh0MZnj+vIxyGBydt6r2HGmjfNITVbXIu6IpO+6NXDwM/e +7v10AAZ3j9+gb1RedLg2ghuIuYU90hmMhtVWsh9nVmaOkMW9/WFgOPYvt/mHH/hR +d4pePZ9kACGmqo/b9sHvHw1YEubtCt1VUiNuFxnJCwKCAQBWnxz0vkRTJY8phsY9 +KeK2jm5sGTBs5T2syLwb6ffENFdKvAjgAw6Mh2And/+1ReWd+/MxdLv03UjZdxsJ +x3FDfXx5FH4O4ebW3a+pnAcKoN1xcX+N0O6LDRqUYcue3sTAOs3gC9CUbr91KAWD +Phw8ccWAzTmKJ7IgLFA982ekyoI9eTmRC159WRgwJxy844qerWF+XC4GyXP+HsTZ +jNRW5Vdi7sqMEyIR7+fIEAhLI88zbATWIPmZv6pC4ybwO7wwtsCMMQNBpdjDprzL +6S12ggikV+U+QKlxGe0FtYqhykRTPJKf32eZqVheWOZJTA/9fgv9ux52oxGycM8O +gmsNAoIBAQC60m5uZnd5uYnPLWkcXYNgq/kbO1UvHHut/FhVMKX7z4MrU0XKNfWO +MECoP5K9bU0aq+Y6KIMe7FapjvT0iSHRu1Cu+HZY8JI2A0xcIAeDijLRl7sP6wrB +q1+2DKgANjRAlWfsEfoX658JBpitPngjOheBnRCMpVQMyUT5HE/BKWf5zwdUB0mY +S+K8nA90HcDeJIS8RcGolbVwUV0oBABhr/cf50lYhqozqCr7YQ33ZGs7Uq3oz8+4 +UARmN2YPLl3Znm3GX12em8c6B0LX8vvA7Jw06Rf2Ksup1+3Ce1PTLiEy9A4FyRf3 +Hc2HmBbnJAtZlr5QikMqlzzAmmLqwH6dAoIBAC+ryaQGJFsijCSuaDfRp/uy9xnd +DjgMdTwjl5WLBmyudChVMANl8eqCbvVO41CN84yORk03oQ4cx0eKxAZaLaSzgkb3 +W0X2nFQe7VJSYMQswCQ+1WfJvEFrIdkEKIa//uQdhqNrgUKSNVhhSTMbNEkDTIWn +ssbv2H9hvUaFt/J/vP9zCKuU5oYvNU7Oi6ZXRYezRn9atlJYanLFoJnHUBRzGms5 +K0vhdCPDXQq87z5Yudoh0jLUQF9Nx0GTWeBceQ9n5hZeRUNQWxP4AJThQX9KSPTS +mbL3Kh4XNRmAUJ2N+Njh+3dg91s+JkKvC1wcspLsmLPQe+9AxBSH9y5JE/8= +-----END RSA PRIVATE KEY----- \ No newline at end of file diff --git a/docker/php-nginx/alpine-php5/conf/etc/nginx/vhost.common.conf b/docker/php-nginx/alpine-php5/conf/etc/nginx/vhost.common.conf new file mode 100644 index 000000000..a5df62ef8 --- /dev/null +++ b/docker/php-nginx/alpine-php5/conf/etc/nginx/vhost.common.conf @@ -0,0 +1,2 @@ +# compatibility for PHP and TYPO3 Docker Boilerplate +include /opt/docker/etc/nginx/vhost.common.d/*.conf; diff --git a/docker/php-nginx/alpine-php5/conf/etc/nginx/vhost.common.d/.gitkeep b/docker/php-nginx/alpine-php5/conf/etc/nginx/vhost.common.d/.gitkeep new file mode 100644 index 000000000..e69de29bb diff --git a/docker/php-nginx/alpine-php5/conf/etc/nginx/vhost.common.d/10-general.conf b/docker/php-nginx/alpine-php5/conf/etc/nginx/vhost.common.d/10-general.conf new file mode 100644 index 000000000..d3fd0aa5e --- /dev/null +++ b/docker/php-nginx/alpine-php5/conf/etc/nginx/vhost.common.d/10-general.conf @@ -0,0 +1 @@ +client_max_body_size 50m; diff --git a/docker/php-nginx/alpine-php5/conf/etc/nginx/vhost.common.d/10-location-root.conf b/docker/php-nginx/alpine-php5/conf/etc/nginx/vhost.common.d/10-location-root.conf new file mode 100644 index 000000000..28fd811bc --- /dev/null +++ b/docker/php-nginx/alpine-php5/conf/etc/nginx/vhost.common.d/10-location-root.conf @@ -0,0 +1,3 @@ +location / { + try_files $uri $uri/ /?$query_string; +} diff --git a/docker/php-nginx/alpine-php5/conf/etc/nginx/vhost.common.d/10-log.conf b/docker/php-nginx/alpine-php5/conf/etc/nginx/vhost.common.d/10-log.conf new file mode 100644 index 000000000..9646c6826 --- /dev/null +++ b/docker/php-nginx/alpine-php5/conf/etc/nginx/vhost.common.d/10-log.conf @@ -0,0 +1,2 @@ +access_log /docker.stdout; +error_log /docker.stderr warn; diff --git a/docker/php-nginx/alpine-php5/conf/etc/nginx/vhost.common.d/10-php.conf b/docker/php-nginx/alpine-php5/conf/etc/nginx/vhost.common.d/10-php.conf new file mode 100644 index 000000000..274beac87 --- /dev/null +++ b/docker/php-nginx/alpine-php5/conf/etc/nginx/vhost.common.d/10-php.conf @@ -0,0 +1,7 @@ +location ~ \.php$ { + fastcgi_split_path_info ^(.+\.php)(/.+)$; + fastcgi_pass php; + include fastcgi_params; + fastcgi_param SCRIPT_FILENAME $request_filename; + fastcgi_read_timeout 1000; +} diff --git a/docker/php-nginx/alpine-php5/conf/etc/nginx/vhost.conf b/docker/php-nginx/alpine-php5/conf/etc/nginx/vhost.conf new file mode 100644 index 000000000..8225f314a --- /dev/null +++ b/docker/php-nginx/alpine-php5/conf/etc/nginx/vhost.conf @@ -0,0 +1,26 @@ +server { + listen 80 default_server; + + server_name _ docker; + + root ""; + index ; + + include /opt/docker/etc/nginx/vhost.common.d/*.conf; +} + +############## +# SSL +############## + +server { + listen 443 default_server; + + server_name _ docker; + + root ""; + index ; + + include /opt/docker/etc/nginx/vhost.common.d/*.conf; + include /opt/docker/etc/nginx/vhost.ssl.conf; +} diff --git a/docker/php-nginx/alpine-php5/conf/etc/nginx/vhost.ssl.conf b/docker/php-nginx/alpine-php5/conf/etc/nginx/vhost.ssl.conf new file mode 100644 index 000000000..4ddba251d --- /dev/null +++ b/docker/php-nginx/alpine-php5/conf/etc/nginx/vhost.ssl.conf @@ -0,0 +1,7 @@ +ssl on; +ssl_protocols TLSv1 TLSv1.1 TLSv1.2; # not possible to do exclusive +ssl_ciphers 'EDH+CAMELLIA:EDH+aRSA:EECDH+aRSA+AESGCM:EECDH+aRSA+SHA384:EECDH+aRSA+SHA256:EECDH:+CAMELLIA256:+AES256:+CAMELLIA128:+AES128:+SSLv3:!aNULL:!eNULL:!LOW:!3DES:!MD5:!EXP:!PSK:!DSS:!RC4:!SEED:!ECDSA:CAMELLIA256-SHA:AES256-SHA:CAMELLIA128-SHA:AES128-SHA'; +ssl_prefer_server_ciphers on; + +ssl_certificate /opt/docker/etc/nginx/ssl/server.crt; +ssl_certificate_key /opt/docker/etc/nginx/ssl/server.key; diff --git a/docker/php-nginx/alpine-php5/conf/etc/supervisor.d/nginx.conf b/docker/php-nginx/alpine-php5/conf/etc/supervisor.d/nginx.conf new file mode 100644 index 000000000..657bf499b --- /dev/null +++ b/docker/php-nginx/alpine-php5/conf/etc/supervisor.d/nginx.conf @@ -0,0 +1,14 @@ +[group:nginx] +programs=nginxd +priority=20 + +[program:nginxd] +command = /opt/docker/bin/service.d/nginx.sh +process_name=%(program_name)s +startsecs = 0 +autostart = true +autorestart = true +stdout_logfile=/dev/stdout +stdout_logfile_maxbytes=0 +stderr_logfile=/dev/stderr +stderr_logfile_maxbytes=0 diff --git a/docker/php-nginx/alpine-php5/conf/provision/roles/webdevops-nginx/defaults/main.yml b/docker/php-nginx/alpine-php5/conf/provision/roles/webdevops-nginx/defaults/main.yml new file mode 100644 index 000000000..69cba1cb4 --- /dev/null +++ b/docker/php-nginx/alpine-php5/conf/provision/roles/webdevops-nginx/defaults/main.yml @@ -0,0 +1,3 @@ +--- + +DOCUMENT_ROOT: "{{ lookup('env','WEB_DOCUMENT_ROOT') }}" diff --git a/docker/php-nginx/alpine-php5/conf/provision/roles/webdevops-nginx/tasks/bootstrap.yml b/docker/php-nginx/alpine-php5/conf/provision/roles/webdevops-nginx/tasks/bootstrap.yml new file mode 100644 index 000000000..7edb04ee4 --- /dev/null +++ b/docker/php-nginx/alpine-php5/conf/provision/roles/webdevops-nginx/tasks/bootstrap.yml @@ -0,0 +1,86 @@ +--- + +- name: Diable nginx demonize mode + lineinfile: + dest: /etc/nginx/nginx.conf + regexp: '[\s;]*{{ item.key }}[\s]*' + line: '{{ item.key }} {{ item.value }};' + with_items: + - { key: 'daemon', value: "off" } + +- name: Set access_log to stdout + replace: + dest: /etc/nginx/nginx.conf + regexp: '^([ \t]*access_log)[ \t]*([^\t ;]+)(.*;)$' + replace: '\1 /docker.stdout \3' + +- name: Set access_log to stdout + replace: + dest: /etc/nginx/nginx.conf + regexp: '^([ \t]*error_log)[ \t]*([^\t ;]+)(.*;)$' + replace: '\1 /docker.stdout \3' + +- name: Enable nginx main config + file: + src: '/opt/docker/etc/nginx/main.conf' + dest: '/etc/nginx/conf.d/10-docker.conf' + state: link + force: yes + +- name: Remove default vhost + file: + path: "{{ item }}" + state: absent + with_items: + # Debian family + - "/etc/nginx/sites-enabled/default" + # Alpine + - "/etc/nginx/conf.d/default.conf" + + +- name: Replace default nginx.conf [RedHat/Alpine family] + file: + src: '/opt/docker/etc/nginx/nginx.conf' + dest: '/etc/nginx/nginx.conf' + state: link + force: yes + when: ansible_os_family == 'RedHat' or ansible_os_family == 'Alpine' + +- name: Ensure document root is available + file: + path: "{{ DOCUMENT_ROOT }}" + state: directory + recurse: yes + +- name: Remove old log directory + file: + path: "/var/lib/nginx/logs" + state: absent + +- name: Create log directory + file: + path: "/var/lib/nginx/logs" + state: directory + +- name: Create stdout symlinks + file: + dest: "{{ item }}" + src: "/docker.stdout" + state: link + force: yes + with_items: + - "/var/lib/nginx/logs/access.log" + - "/var/lib/nginx/logs/error.log" + +- name: Fix rights of ssl files + file: + path: "{{ item.path }}" + state: "{{ item.state }}" + mode: "{{ item.mode }}" + owner: "root" + group: "root" + with_items: + - { path: '/opt/docker/etc/nginx/ssl', state: 'directory', mode: '0750' } + - { path: '/opt/docker/etc/nginx/ssl/server.crt', state: 'file', mode: '0640' } + - { path: '/opt/docker/etc/nginx/ssl/server.csr', state: 'file', mode: '0640' } + - { path: '/opt/docker/etc/nginx/ssl/server.key', state: 'file', mode: '0640' } diff --git a/docker/php-nginx/alpine-php5/conf/provision/roles/webdevops-nginx/tasks/main.yml b/docker/php-nginx/alpine-php5/conf/provision/roles/webdevops-nginx/tasks/main.yml new file mode 100644 index 000000000..1806c1a8c --- /dev/null +++ b/docker/php-nginx/alpine-php5/conf/provision/roles/webdevops-nginx/tasks/main.yml @@ -0,0 +1,5 @@ +--- + +- include: bootstrap.yml + tags: + - bootstrap diff --git a/docker/php-nginx/alpine-php5/conf/provision/roles/webdevops-php-nginx/defaults/main.yml b/docker/php-nginx/alpine-php5/conf/provision/roles/webdevops-php-nginx/defaults/main.yml new file mode 100644 index 000000000..ed97d539c --- /dev/null +++ b/docker/php-nginx/alpine-php5/conf/provision/roles/webdevops-php-nginx/defaults/main.yml @@ -0,0 +1 @@ +--- diff --git a/docker/php-nginx/alpine-php5/conf/provision/roles/webdevops-php-nginx/tasks/bootstrap.yml b/docker/php-nginx/alpine-php5/conf/provision/roles/webdevops-php-nginx/tasks/bootstrap.yml new file mode 100644 index 000000000..a2866e0d0 --- /dev/null +++ b/docker/php-nginx/alpine-php5/conf/provision/roles/webdevops-php-nginx/tasks/bootstrap.yml @@ -0,0 +1,9 @@ +--- + +- name: Restrict php-fpm to local connection + lineinfile: + dest: '/opt/docker/etc/php/fpm/pool.d/application.conf' + regexp: '^[\s;]*{{ item.key }}[\s]*=' + line: '{{ item.key }} = {{ item.value }}' + with_items: + - { key: 'listen', value: "127.0.0.1:9000" } diff --git a/docker/php-nginx/alpine-php5/conf/provision/roles/webdevops-php-nginx/tasks/entrypoint.yml b/docker/php-nginx/alpine-php5/conf/provision/roles/webdevops-php-nginx/tasks/entrypoint.yml new file mode 100644 index 000000000..cd21505a4 --- /dev/null +++ b/docker/php-nginx/alpine-php5/conf/provision/roles/webdevops-php-nginx/tasks/entrypoint.yml @@ -0,0 +1,2 @@ +--- + diff --git a/docker/php-nginx/alpine-php5/conf/provision/roles/webdevops-php-nginx/tasks/main.yml b/docker/php-nginx/alpine-php5/conf/provision/roles/webdevops-php-nginx/tasks/main.yml new file mode 100644 index 000000000..7895a52a9 --- /dev/null +++ b/docker/php-nginx/alpine-php5/conf/provision/roles/webdevops-php-nginx/tasks/main.yml @@ -0,0 +1,9 @@ +--- + +- include: bootstrap.yml + tags: + - bootstrap + +- include: entrypoint.yml + tags: + - entrypoint diff --git a/docker/php-nginx/alpine-php7/Dockerfile b/docker/php-nginx/alpine-php7/Dockerfile new file mode 100644 index 000000000..5790b131f --- /dev/null +++ b/docker/php-nginx/alpine-php7/Dockerfile @@ -0,0 +1,22 @@ +#+++++++++++++++++++++++++++++++++++++++ +# Dockerfile for webdevops/php-nginx:alpine-php7 +# -- automatically generated -- +#+++++++++++++++++++++++++++++++++++++++ + +FROM webdevops/php:alpine-php7 + +ENV WEB_DOCUMENT_ROOT=/app \ + WEB_DOCUMENT_INDEX=index.php \ + WEB_ALIAS_DOMAIN=*.vm +ENV WEB_PHP_SOCKET=127.0.0.1:9000 + +COPY conf/ /opt/docker/ + +# Install nginx +RUN /usr/local/bin/apk-install \ + nginx \ + && /opt/docker/bin/provision run --tag bootstrap --role webdevops-nginx --role webdevops-php-nginx \ + && /opt/docker/bin/bootstrap.sh \ + && docker-image-cleanup + +EXPOSE 80 443 diff --git a/docker/php-nginx/alpine-php7/Dockerfile.jinja2 b/docker/php-nginx/alpine-php7/Dockerfile.jinja2 new file mode 100644 index 000000000..c67f6e7da --- /dev/null +++ b/docker/php-nginx/alpine-php7/Dockerfile.jinja2 @@ -0,0 +1,10 @@ +{{ docker.from("php", "alpine-php7") }} + +{{ environment.web() }} +{{ environment.webPhp() }} + +{{ docker.copy('conf/', '/opt/docker/') }} + +{{ nginx.alpine('php-nginx') }} + +{{ docker.expose('80 443') }} diff --git a/docker/php-nginx/alpine-php7/conf/bin/service.d/nginx.d/10-init.sh b/docker/php-nginx/alpine-php7/conf/bin/service.d/nginx.d/10-init.sh new file mode 100644 index 000000000..27b9776cc --- /dev/null +++ b/docker/php-nginx/alpine-php7/conf/bin/service.d/nginx.d/10-init.sh @@ -0,0 +1,25 @@ +if [[ ! -e "$WEB_DOCUMENT_ROOT" ]]; then + echo "" + echo "[WARNING] WEB_DOCUMENT_ROOT does not exists with path \"$WEB_DOCUMENT_ROOT\"!" + echo "" +fi + +# Prevent startup of nginx (ubuntu 16.04 needs it) +ln -f -s /var/lib/nginx/logs /var/log/nginx + +# Replace markers +go-replace \ + -s "" -r "$WEB_DOCUMENT_INDEX" \ + -s "" -r "$WEB_DOCUMENT_ROOT" \ + -s "" -r "$WEB_ALIAS_DOMAIN" \ + -s "" -r "$HOSTNAME" \ + -s "" -r "$WEB_PHP_SOCKET" \ + --path=/opt/docker/etc/nginx/ \ + --path-pattern='*.conf' \ + --ignore-empty + +if [[ -z "${WEB_PHP_SOCKET+x}" ]]; then + ## WEB_PHP_SOCKET is not set, remove PHP files + rm -f -- /opt/docker/etc/nginx/conf.d/10-php.conf + rm -f -- /opt/docker/etc/nginx/vhost.common.d/10-php.conf +fi diff --git a/docker/php-nginx/alpine-php7/conf/bin/service.d/nginx.sh b/docker/php-nginx/alpine-php7/conf/bin/service.d/nginx.sh new file mode 100644 index 000000000..f5cd26167 --- /dev/null +++ b/docker/php-nginx/alpine-php7/conf/bin/service.d/nginx.sh @@ -0,0 +1,7 @@ +#!/usr/bin/env bash + +source /opt/docker/bin/config.sh + +includeScriptDir "/opt/docker/bin/service.d/nginx.d/" + +exec /usr/sbin/nginx diff --git a/docker/php-nginx/alpine-php7/conf/etc/nginx/conf.d/.gitkeep b/docker/php-nginx/alpine-php7/conf/etc/nginx/conf.d/.gitkeep new file mode 100644 index 000000000..e69de29bb diff --git a/docker/php-nginx/alpine-php7/conf/etc/nginx/conf.d/10-php.conf b/docker/php-nginx/alpine-php7/conf/etc/nginx/conf.d/10-php.conf new file mode 100644 index 000000000..9abe45f0a --- /dev/null +++ b/docker/php-nginx/alpine-php7/conf/etc/nginx/conf.d/10-php.conf @@ -0,0 +1,3 @@ +upstream php { + server ; +} diff --git a/docker/php-nginx/alpine-php7/conf/etc/nginx/global.conf b/docker/php-nginx/alpine-php7/conf/etc/nginx/global.conf new file mode 100644 index 000000000..b6141db09 --- /dev/null +++ b/docker/php-nginx/alpine-php7/conf/etc/nginx/global.conf @@ -0,0 +1 @@ +# deprecated diff --git a/docker/php-nginx/alpine-php7/conf/etc/nginx/main.conf b/docker/php-nginx/alpine-php7/conf/etc/nginx/main.conf new file mode 100644 index 000000000..06de0651b --- /dev/null +++ b/docker/php-nginx/alpine-php7/conf/etc/nginx/main.conf @@ -0,0 +1,4 @@ +include /opt/docker/etc/nginx/global.conf; +include /opt/docker/etc/nginx/php.conf; +include /opt/docker/etc/nginx/conf.d/*.conf; +include /opt/docker/etc/nginx/vhost.conf; diff --git a/docker/php-nginx/alpine-3/conf/etc/nginx/nginx.conf b/docker/php-nginx/alpine-php7/conf/etc/nginx/nginx.conf similarity index 100% rename from docker/php-nginx/alpine-3/conf/etc/nginx/nginx.conf rename to docker/php-nginx/alpine-php7/conf/etc/nginx/nginx.conf diff --git a/docker/php-nginx/alpine-php7/conf/etc/nginx/php.conf b/docker/php-nginx/alpine-php7/conf/etc/nginx/php.conf new file mode 100644 index 000000000..b6141db09 --- /dev/null +++ b/docker/php-nginx/alpine-php7/conf/etc/nginx/php.conf @@ -0,0 +1 @@ +# deprecated diff --git a/docker/php-nginx/alpine-php7/conf/etc/nginx/ssl/server.crt b/docker/php-nginx/alpine-php7/conf/etc/nginx/ssl/server.crt new file mode 100644 index 000000000..6b0694907 --- /dev/null +++ b/docker/php-nginx/alpine-php7/conf/etc/nginx/ssl/server.crt @@ -0,0 +1,28 @@ +-----BEGIN CERTIFICATE----- +MIIE1DCCArwCCQDMMwGnSuK0tTANBgkqhkiG9w0BAQsFADAsMRswGQYDVQQKExJE +b2NrZXIgQm9pbGVycGxhdGUxDTALBgNVBAMUBCoudm0wHhcNMTUwNTA0MTcxNDQw +WhcNMjUwNTAxMTcxNDQwWjAsMRswGQYDVQQKExJEb2NrZXIgQm9pbGVycGxhdGUx +DTALBgNVBAMUBCoudm0wggIiMA0GCSqGSIb3DQEBAQUAA4ICDwAwggIKAoICAQDK +3TIUiyDvXelWeY9VXMrpjuZtYpVSDsACLpjFUhMnsP5/iKT0VbeZyqHvmwZjAg4G +Y10d+yZDdgv/xeu0HPOFbtR6pCp10d1tdLHZto5Cyuxu7IQsAVjnD6Ko7XFwtNk7 +9o6JZfAFaGL4w5MokrVmCtspnsMZH7/7zU4f96cbF39zLopnpuXGD6t6DA8Qj3gy +0duaTjs42bYRN+rwLzVKAev99iQ4kPMJn4vV6/Xk6rtoSzC67GQyVZYaFypicD1S +NtsRmgEVvjCBDbrLOneUiRwff6qxEsZi7Hxv7BKFj4iUWnII7K/nP7T6uBHQjHO+ +FpsGkU9lCMrCeVFBe8kKz/cbhd+yLUxXwAPr6gSOPmwn232Gy4tozvqZHpbUxsgx +7sT3ej9K66h1D7J+BjNFWYM1hbnC1r7H/xS7EBzBV8qRoQCVe08Juf5xsouXFakD +clLV4+L+1cxkpwsCQDly5g3tm/TBqA2O+ZJ+YHQDHKkzMyhLs6i0X/M5qvJBiLg1 +GLTCS20rpQ5gXTEGuINqHgwXQWkUO6bhgSYqdHGX3zbZ5+qWpI4eui3dHZ1Ll0VH +6Icpb7ORTQwhc6W8KBlybssYPSlGOEBGUjYGNheoz9FpoSkxCis+P8ZNKtrmpPoq +Su0eOOGFOFHG02eOgPVxSwrDeN9MVJo7BPysGMHJmQIDAQABMA0GCSqGSIb3DQEB +CwUAA4ICAQC63g6NHmQKbiy3G6iaDkpUSbr5Mq2YgU61XnvWVyREqDcy/BXCw9oY +SJ/KUvCpqPnACNOFqjadRAmPiA9nf2WduoCgwQGV/YRFGswSuVvh/3X2TX5NWvbS +t8MQDttQg1dxpiMUjlu3rqhfohBdWJvp2lVSdpDb/MOlXBc/+p7HfOHwhqB7wwPN +NNbSKUbZqZxmD8cOf1X0hASr1yfFPj+2vST3ESaON8S0T2p63YX/sD5jvOUiEuyw +I5WcvLmiRZA07SH8nWyckLY3qWL+OlhSZrlAnolWS00b+7h5LNuRYEjKzwVgntoA +aCopyQih6wIk0+AfJO4sfhJBmQhnIrAaP/zwBH5g9zVizLf5H7U+hNXrMwgw55Sq +vjMdkZHvPKUXTvVit/rYE9H+PY3brkRWzOl4V/i/ZLJJm5805H/NyTbz9kPMJw2Q +nn+KOpfXXySD39f8iuRgSKXsYNul38hxWgcZZ6g+sOOp2n/VUmf0eZUWNnJ8i7AP +4Qif7aDKMcibOwSwsB+DKZXDvZ5XSdnMphtuLS5rPSL81rVRmWC2DMfQ2eP8j0WN +VTroSk0xedQ7Qr+9TNooi9IyzX6n1a2S1UiciEZ3ZcDbXPl/P01m+IYZyPnLv0+9 +ZeioZYh1JLv3/OKsMrMLTfh2ZCj3aXwmc2Owi/wU2LS5QUOMcHH7CQ== +-----END CERTIFICATE----- \ No newline at end of file diff --git a/docker/php-nginx/alpine-php7/conf/etc/nginx/ssl/server.csr b/docker/php-nginx/alpine-php7/conf/etc/nginx/ssl/server.csr new file mode 100644 index 000000000..8a9909f77 --- /dev/null +++ b/docker/php-nginx/alpine-php7/conf/etc/nginx/ssl/server.csr @@ -0,0 +1,26 @@ +-----BEGIN CERTIFICATE REQUEST----- +MIIEcTCCAlkCAQAwLDEbMBkGA1UEChMSRG9ja2VyIEJvaWxlcnBsYXRlMQ0wCwYD +VQQDFAQqLnZtMIICIjANBgkqhkiG9w0BAQEFAAOCAg8AMIICCgKCAgEAyt0yFIsg +713pVnmPVVzK6Y7mbWKVUg7AAi6YxVITJ7D+f4ik9FW3mcqh75sGYwIOBmNdHfsm +Q3YL/8XrtBzzhW7UeqQqddHdbXSx2baOQsrsbuyELAFY5w+iqO1xcLTZO/aOiWXw +BWhi+MOTKJK1ZgrbKZ7DGR+/+81OH/enGxd/cy6KZ6blxg+regwPEI94MtHbmk47 +ONm2ETfq8C81SgHr/fYkOJDzCZ+L1ev15Oq7aEswuuxkMlWWGhcqYnA9UjbbEZoB +Fb4wgQ26yzp3lIkcH3+qsRLGYux8b+wShY+IlFpyCOyv5z+0+rgR0IxzvhabBpFP +ZQjKwnlRQXvJCs/3G4Xfsi1MV8AD6+oEjj5sJ9t9hsuLaM76mR6W1MbIMe7E93o/ +SuuodQ+yfgYzRVmDNYW5wta+x/8UuxAcwVfKkaEAlXtPCbn+cbKLlxWpA3JS1ePi +/tXMZKcLAkA5cuYN7Zv0wagNjvmSfmB0AxypMzMoS7OotF/zOaryQYi4NRi0wktt +K6UOYF0xBriDah4MF0FpFDum4YEmKnRxl9822efqlqSOHrot3R2dS5dFR+iHKW+z +kU0MIXOlvCgZcm7LGD0pRjhARlI2BjYXqM/RaaEpMQorPj/GTSra5qT6KkrtHjjh +hThRxtNnjoD1cUsKw3jfTFSaOwT8rBjByZkCAwEAAaAAMA0GCSqGSIb3DQEBCwUA +A4ICAQBsEBgC2YepuZq/8UqvKMZKVy/etDKXj7BB+QPb+leNiKD7p4LDxHJsZSH8 +Ku9uMPeLfiQDn5jA41k5SlGttzvObd65RdEbO3yHpqsg05EGSDDLfaE1k2Al/qmX +/o8roPZF7+2kZthgMAgkcokS54LYqEYTGqOf3J9Ss0yRIZwhaOVebfFIbIOdpw0B +JNMIJPHTMdZrcuRVI+wR1uPLIlEJzBvxTGbTrvPU25WJFtu+EajKqXO0SHdy0yx8 +uH4ykRBJRc36+oYo7nZ5D56dh7pZn3+9J64FKAOV0Q3KqMFieGy053ezuhJd70eZ +UozTgfjs3WpMzoYmKETSyl3XZSdInRe+sUlKPruTsKyg69oYxjPlrGfAmmGcCFca +TnZinT18dI92zK7OtOVkmYeYKC1lwuhftVrNMXzZuHOGpS9NNYtc4nDqDMIEOfV3 +6rCdu03WjEgJ+Z67tJs16xOx9du4/EHxS2Ijn9DPfVJvYy0TgzDi1BUpjWx0KTLx +C4OQbEZ/QTWmHVbSch/hcZhzbf7SNh5RpnW4EtmcpDFjIKMfxJmoKeiTf7qnilx0 +7uRvsZFKoDKRDOFiPfgMg5AOtLHziYsd9m0tJjC2GHvFuPjzOtzhnUUjmmvht170 +2aqKakjST4amg7jzLcs871HX0/WjOtt29NpOz140blkKf1bisg== +-----END CERTIFICATE REQUEST----- \ No newline at end of file diff --git a/docker/php-nginx/alpine-php7/conf/etc/nginx/ssl/server.key b/docker/php-nginx/alpine-php7/conf/etc/nginx/ssl/server.key new file mode 100644 index 000000000..c9eec145f --- /dev/null +++ b/docker/php-nginx/alpine-php7/conf/etc/nginx/ssl/server.key @@ -0,0 +1,51 @@ +-----BEGIN RSA PRIVATE KEY----- +MIIJKAIBAAKCAgEAyt0yFIsg713pVnmPVVzK6Y7mbWKVUg7AAi6YxVITJ7D+f4ik +9FW3mcqh75sGYwIOBmNdHfsmQ3YL/8XrtBzzhW7UeqQqddHdbXSx2baOQsrsbuyE +LAFY5w+iqO1xcLTZO/aOiWXwBWhi+MOTKJK1ZgrbKZ7DGR+/+81OH/enGxd/cy6K +Z6blxg+regwPEI94MtHbmk47ONm2ETfq8C81SgHr/fYkOJDzCZ+L1ev15Oq7aEsw +uuxkMlWWGhcqYnA9UjbbEZoBFb4wgQ26yzp3lIkcH3+qsRLGYux8b+wShY+IlFpy +COyv5z+0+rgR0IxzvhabBpFPZQjKwnlRQXvJCs/3G4Xfsi1MV8AD6+oEjj5sJ9t9 +hsuLaM76mR6W1MbIMe7E93o/SuuodQ+yfgYzRVmDNYW5wta+x/8UuxAcwVfKkaEA +lXtPCbn+cbKLlxWpA3JS1ePi/tXMZKcLAkA5cuYN7Zv0wagNjvmSfmB0AxypMzMo +S7OotF/zOaryQYi4NRi0wkttK6UOYF0xBriDah4MF0FpFDum4YEmKnRxl9822efq +lqSOHrot3R2dS5dFR+iHKW+zkU0MIXOlvCgZcm7LGD0pRjhARlI2BjYXqM/RaaEp +MQorPj/GTSra5qT6KkrtHjjhhThRxtNnjoD1cUsKw3jfTFSaOwT8rBjByZkCAwEA +AQKCAgAbZPdoUsllyZbC+LNkYZ19ILD5QIDNjfRb1xMGQmkXyQz1B+zOmeyrNfPc +OWEJabOfJTfj3pByN7SzG3US4333HNpQnW6mbmqqZ0HFFqPrXR/Ecuf+UUhCG5hp +m3bgM2vKbyccYsmg0VHcKfzrU7RvTTP/UNMjx2fThwvvwS+ttuSdF0HVcXJB5sfP +OWWnZNhkdHZlRf81VCED/jsZqCZYEh5eMyj9AoXvXL4zayPPf+tC0DSKaXW2Xlxg +tZQhqup8+a9nlxZia0Z9hu8clo6jXkiP8FuKgfCMV0cOjiCKLLHS5svTbLLsVWwJ +F2ZAdVcD6mWQ43qHOEK5NEzGvQKO14CaOLnVT2yAkMcyNohsEgoDP9oCBGDJQbBH +NmtZfpVjjtuTr9P9TEkU1FcBRo0x6Il/DkzamGbOeFAmgnaGElhJ5c/CAG7whaIf +mUfFOBGPH/wESY3gBOACDofeSh27RrlvbLaPiCGKivDUTBmhBsIuso6XqOKbvtfV +/HhhndpdRVfIj4DdE7gIrLIGN977JMVAXFCNz7KrvAWwcOXrCHCoWpklJ9repq8l +26ICY8K7VXktzDHQUmhd88ZWR+9ASURsJghUgZUOcMrEGyvci6Y8hpLhHiNVPHuQ ++ps7tpPsXSntBUqWBzhRZh74+nJlOOV6oYykl30JT2JzB6lwiQKCAQEA9ecn8N2z +20tR2UEiTv/MjVSepQtAAajegvcd1iasvvQKXnh3XLmoZHzH2tTa0lp5RIZpUQPl +lOTwko0lYTBnYblt65AJQ3FTgisNobIpoqE8BFXLm6wggz7CbabjmPGDe173lPGR +sI0YSKYvzrdn4zw8Fh6WULJyZHLi58zJYL3r0WBDiOoxpGaGA1GlmkuIWjhKHaX2 +OvF1vOuQDJ2eDyTc5TYFC0NKG76Mvanov5L/yrhNM/umbmp0SPspzHGZobAKUr20 +OazFT8S+2TA1OTxWNbiPbSimFoaZbEdqsNACGfVJWO8Sh8iqlt5RmEcSiSvGBj6L +QKprRO9Fsp2GawKCAQEA0zGhRsnux4JTNsdUSYsEJtITMj6eE+nl7CoZ9DAOwC5X +6/aSpUE4TT+pWNrt9iluXiGL0j89UJ7r/L1OcsiyzGb8ig9NU4zr1NIGTZ0DstHi +HPYINjeiBJEFIy17kOQn+9/I5c4hBUwz6ihwNoEomymVB/EsLJKAML0AudJGKg+Z +/f/qrS40eab5SAiaKgsh0MZnj+vIxyGBydt6r2HGmjfNITVbXIu6IpO+6NXDwM/e +7v10AAZ3j9+gb1RedLg2ghuIuYU90hmMhtVWsh9nVmaOkMW9/WFgOPYvt/mHH/hR +d4pePZ9kACGmqo/b9sHvHw1YEubtCt1VUiNuFxnJCwKCAQBWnxz0vkRTJY8phsY9 +KeK2jm5sGTBs5T2syLwb6ffENFdKvAjgAw6Mh2And/+1ReWd+/MxdLv03UjZdxsJ +x3FDfXx5FH4O4ebW3a+pnAcKoN1xcX+N0O6LDRqUYcue3sTAOs3gC9CUbr91KAWD +Phw8ccWAzTmKJ7IgLFA982ekyoI9eTmRC159WRgwJxy844qerWF+XC4GyXP+HsTZ +jNRW5Vdi7sqMEyIR7+fIEAhLI88zbATWIPmZv6pC4ybwO7wwtsCMMQNBpdjDprzL +6S12ggikV+U+QKlxGe0FtYqhykRTPJKf32eZqVheWOZJTA/9fgv9ux52oxGycM8O +gmsNAoIBAQC60m5uZnd5uYnPLWkcXYNgq/kbO1UvHHut/FhVMKX7z4MrU0XKNfWO +MECoP5K9bU0aq+Y6KIMe7FapjvT0iSHRu1Cu+HZY8JI2A0xcIAeDijLRl7sP6wrB +q1+2DKgANjRAlWfsEfoX658JBpitPngjOheBnRCMpVQMyUT5HE/BKWf5zwdUB0mY +S+K8nA90HcDeJIS8RcGolbVwUV0oBABhr/cf50lYhqozqCr7YQ33ZGs7Uq3oz8+4 +UARmN2YPLl3Znm3GX12em8c6B0LX8vvA7Jw06Rf2Ksup1+3Ce1PTLiEy9A4FyRf3 +Hc2HmBbnJAtZlr5QikMqlzzAmmLqwH6dAoIBAC+ryaQGJFsijCSuaDfRp/uy9xnd +DjgMdTwjl5WLBmyudChVMANl8eqCbvVO41CN84yORk03oQ4cx0eKxAZaLaSzgkb3 +W0X2nFQe7VJSYMQswCQ+1WfJvEFrIdkEKIa//uQdhqNrgUKSNVhhSTMbNEkDTIWn +ssbv2H9hvUaFt/J/vP9zCKuU5oYvNU7Oi6ZXRYezRn9atlJYanLFoJnHUBRzGms5 +K0vhdCPDXQq87z5Yudoh0jLUQF9Nx0GTWeBceQ9n5hZeRUNQWxP4AJThQX9KSPTS +mbL3Kh4XNRmAUJ2N+Njh+3dg91s+JkKvC1wcspLsmLPQe+9AxBSH9y5JE/8= +-----END RSA PRIVATE KEY----- \ No newline at end of file diff --git a/docker/php-nginx/alpine-php7/conf/etc/nginx/vhost.common.conf b/docker/php-nginx/alpine-php7/conf/etc/nginx/vhost.common.conf new file mode 100644 index 000000000..a5df62ef8 --- /dev/null +++ b/docker/php-nginx/alpine-php7/conf/etc/nginx/vhost.common.conf @@ -0,0 +1,2 @@ +# compatibility for PHP and TYPO3 Docker Boilerplate +include /opt/docker/etc/nginx/vhost.common.d/*.conf; diff --git a/docker/php-nginx/alpine-php7/conf/etc/nginx/vhost.common.d/.gitkeep b/docker/php-nginx/alpine-php7/conf/etc/nginx/vhost.common.d/.gitkeep new file mode 100644 index 000000000..e69de29bb diff --git a/docker/php-nginx/alpine-php7/conf/etc/nginx/vhost.common.d/10-general.conf b/docker/php-nginx/alpine-php7/conf/etc/nginx/vhost.common.d/10-general.conf new file mode 100644 index 000000000..d3fd0aa5e --- /dev/null +++ b/docker/php-nginx/alpine-php7/conf/etc/nginx/vhost.common.d/10-general.conf @@ -0,0 +1 @@ +client_max_body_size 50m; diff --git a/docker/php-nginx/alpine-php7/conf/etc/nginx/vhost.common.d/10-location-root.conf b/docker/php-nginx/alpine-php7/conf/etc/nginx/vhost.common.d/10-location-root.conf new file mode 100644 index 000000000..28fd811bc --- /dev/null +++ b/docker/php-nginx/alpine-php7/conf/etc/nginx/vhost.common.d/10-location-root.conf @@ -0,0 +1,3 @@ +location / { + try_files $uri $uri/ /?$query_string; +} diff --git a/docker/php-nginx/alpine-php7/conf/etc/nginx/vhost.common.d/10-log.conf b/docker/php-nginx/alpine-php7/conf/etc/nginx/vhost.common.d/10-log.conf new file mode 100644 index 000000000..9646c6826 --- /dev/null +++ b/docker/php-nginx/alpine-php7/conf/etc/nginx/vhost.common.d/10-log.conf @@ -0,0 +1,2 @@ +access_log /docker.stdout; +error_log /docker.stderr warn; diff --git a/docker/php-nginx/alpine-php7/conf/etc/nginx/vhost.common.d/10-php.conf b/docker/php-nginx/alpine-php7/conf/etc/nginx/vhost.common.d/10-php.conf new file mode 100644 index 000000000..274beac87 --- /dev/null +++ b/docker/php-nginx/alpine-php7/conf/etc/nginx/vhost.common.d/10-php.conf @@ -0,0 +1,7 @@ +location ~ \.php$ { + fastcgi_split_path_info ^(.+\.php)(/.+)$; + fastcgi_pass php; + include fastcgi_params; + fastcgi_param SCRIPT_FILENAME $request_filename; + fastcgi_read_timeout 1000; +} diff --git a/docker/php-nginx/alpine-php7/conf/etc/nginx/vhost.conf b/docker/php-nginx/alpine-php7/conf/etc/nginx/vhost.conf new file mode 100644 index 000000000..8225f314a --- /dev/null +++ b/docker/php-nginx/alpine-php7/conf/etc/nginx/vhost.conf @@ -0,0 +1,26 @@ +server { + listen 80 default_server; + + server_name _ docker; + + root ""; + index ; + + include /opt/docker/etc/nginx/vhost.common.d/*.conf; +} + +############## +# SSL +############## + +server { + listen 443 default_server; + + server_name _ docker; + + root ""; + index ; + + include /opt/docker/etc/nginx/vhost.common.d/*.conf; + include /opt/docker/etc/nginx/vhost.ssl.conf; +} diff --git a/docker/php-nginx/alpine-php7/conf/etc/nginx/vhost.ssl.conf b/docker/php-nginx/alpine-php7/conf/etc/nginx/vhost.ssl.conf new file mode 100644 index 000000000..4ddba251d --- /dev/null +++ b/docker/php-nginx/alpine-php7/conf/etc/nginx/vhost.ssl.conf @@ -0,0 +1,7 @@ +ssl on; +ssl_protocols TLSv1 TLSv1.1 TLSv1.2; # not possible to do exclusive +ssl_ciphers 'EDH+CAMELLIA:EDH+aRSA:EECDH+aRSA+AESGCM:EECDH+aRSA+SHA384:EECDH+aRSA+SHA256:EECDH:+CAMELLIA256:+AES256:+CAMELLIA128:+AES128:+SSLv3:!aNULL:!eNULL:!LOW:!3DES:!MD5:!EXP:!PSK:!DSS:!RC4:!SEED:!ECDSA:CAMELLIA256-SHA:AES256-SHA:CAMELLIA128-SHA:AES128-SHA'; +ssl_prefer_server_ciphers on; + +ssl_certificate /opt/docker/etc/nginx/ssl/server.crt; +ssl_certificate_key /opt/docker/etc/nginx/ssl/server.key; diff --git a/docker/php-nginx/alpine-php7/conf/etc/supervisor.d/nginx.conf b/docker/php-nginx/alpine-php7/conf/etc/supervisor.d/nginx.conf new file mode 100644 index 000000000..657bf499b --- /dev/null +++ b/docker/php-nginx/alpine-php7/conf/etc/supervisor.d/nginx.conf @@ -0,0 +1,14 @@ +[group:nginx] +programs=nginxd +priority=20 + +[program:nginxd] +command = /opt/docker/bin/service.d/nginx.sh +process_name=%(program_name)s +startsecs = 0 +autostart = true +autorestart = true +stdout_logfile=/dev/stdout +stdout_logfile_maxbytes=0 +stderr_logfile=/dev/stderr +stderr_logfile_maxbytes=0 diff --git a/docker/php-nginx/alpine-php7/conf/provision/roles/webdevops-nginx/defaults/main.yml b/docker/php-nginx/alpine-php7/conf/provision/roles/webdevops-nginx/defaults/main.yml new file mode 100644 index 000000000..69cba1cb4 --- /dev/null +++ b/docker/php-nginx/alpine-php7/conf/provision/roles/webdevops-nginx/defaults/main.yml @@ -0,0 +1,3 @@ +--- + +DOCUMENT_ROOT: "{{ lookup('env','WEB_DOCUMENT_ROOT') }}" diff --git a/docker/php-nginx/alpine-php7/conf/provision/roles/webdevops-nginx/tasks/bootstrap.yml b/docker/php-nginx/alpine-php7/conf/provision/roles/webdevops-nginx/tasks/bootstrap.yml new file mode 100644 index 000000000..7edb04ee4 --- /dev/null +++ b/docker/php-nginx/alpine-php7/conf/provision/roles/webdevops-nginx/tasks/bootstrap.yml @@ -0,0 +1,86 @@ +--- + +- name: Diable nginx demonize mode + lineinfile: + dest: /etc/nginx/nginx.conf + regexp: '[\s;]*{{ item.key }}[\s]*' + line: '{{ item.key }} {{ item.value }};' + with_items: + - { key: 'daemon', value: "off" } + +- name: Set access_log to stdout + replace: + dest: /etc/nginx/nginx.conf + regexp: '^([ \t]*access_log)[ \t]*([^\t ;]+)(.*;)$' + replace: '\1 /docker.stdout \3' + +- name: Set access_log to stdout + replace: + dest: /etc/nginx/nginx.conf + regexp: '^([ \t]*error_log)[ \t]*([^\t ;]+)(.*;)$' + replace: '\1 /docker.stdout \3' + +- name: Enable nginx main config + file: + src: '/opt/docker/etc/nginx/main.conf' + dest: '/etc/nginx/conf.d/10-docker.conf' + state: link + force: yes + +- name: Remove default vhost + file: + path: "{{ item }}" + state: absent + with_items: + # Debian family + - "/etc/nginx/sites-enabled/default" + # Alpine + - "/etc/nginx/conf.d/default.conf" + + +- name: Replace default nginx.conf [RedHat/Alpine family] + file: + src: '/opt/docker/etc/nginx/nginx.conf' + dest: '/etc/nginx/nginx.conf' + state: link + force: yes + when: ansible_os_family == 'RedHat' or ansible_os_family == 'Alpine' + +- name: Ensure document root is available + file: + path: "{{ DOCUMENT_ROOT }}" + state: directory + recurse: yes + +- name: Remove old log directory + file: + path: "/var/lib/nginx/logs" + state: absent + +- name: Create log directory + file: + path: "/var/lib/nginx/logs" + state: directory + +- name: Create stdout symlinks + file: + dest: "{{ item }}" + src: "/docker.stdout" + state: link + force: yes + with_items: + - "/var/lib/nginx/logs/access.log" + - "/var/lib/nginx/logs/error.log" + +- name: Fix rights of ssl files + file: + path: "{{ item.path }}" + state: "{{ item.state }}" + mode: "{{ item.mode }}" + owner: "root" + group: "root" + with_items: + - { path: '/opt/docker/etc/nginx/ssl', state: 'directory', mode: '0750' } + - { path: '/opt/docker/etc/nginx/ssl/server.crt', state: 'file', mode: '0640' } + - { path: '/opt/docker/etc/nginx/ssl/server.csr', state: 'file', mode: '0640' } + - { path: '/opt/docker/etc/nginx/ssl/server.key', state: 'file', mode: '0640' } diff --git a/docker/php-nginx/alpine-php7/conf/provision/roles/webdevops-nginx/tasks/main.yml b/docker/php-nginx/alpine-php7/conf/provision/roles/webdevops-nginx/tasks/main.yml new file mode 100644 index 000000000..1806c1a8c --- /dev/null +++ b/docker/php-nginx/alpine-php7/conf/provision/roles/webdevops-nginx/tasks/main.yml @@ -0,0 +1,5 @@ +--- + +- include: bootstrap.yml + tags: + - bootstrap diff --git a/docker/php-nginx/alpine-php7/conf/provision/roles/webdevops-php-nginx/defaults/main.yml b/docker/php-nginx/alpine-php7/conf/provision/roles/webdevops-php-nginx/defaults/main.yml new file mode 100644 index 000000000..ed97d539c --- /dev/null +++ b/docker/php-nginx/alpine-php7/conf/provision/roles/webdevops-php-nginx/defaults/main.yml @@ -0,0 +1 @@ +--- diff --git a/docker/php-nginx/alpine-php7/conf/provision/roles/webdevops-php-nginx/tasks/bootstrap.yml b/docker/php-nginx/alpine-php7/conf/provision/roles/webdevops-php-nginx/tasks/bootstrap.yml new file mode 100644 index 000000000..a2866e0d0 --- /dev/null +++ b/docker/php-nginx/alpine-php7/conf/provision/roles/webdevops-php-nginx/tasks/bootstrap.yml @@ -0,0 +1,9 @@ +--- + +- name: Restrict php-fpm to local connection + lineinfile: + dest: '/opt/docker/etc/php/fpm/pool.d/application.conf' + regexp: '^[\s;]*{{ item.key }}[\s]*=' + line: '{{ item.key }} = {{ item.value }}' + with_items: + - { key: 'listen', value: "127.0.0.1:9000" } diff --git a/docker/php-nginx/alpine-php7/conf/provision/roles/webdevops-php-nginx/tasks/entrypoint.yml b/docker/php-nginx/alpine-php7/conf/provision/roles/webdevops-php-nginx/tasks/entrypoint.yml new file mode 100644 index 000000000..cd21505a4 --- /dev/null +++ b/docker/php-nginx/alpine-php7/conf/provision/roles/webdevops-php-nginx/tasks/entrypoint.yml @@ -0,0 +1,2 @@ +--- + diff --git a/docker/php-nginx/alpine-php7/conf/provision/roles/webdevops-php-nginx/tasks/main.yml b/docker/php-nginx/alpine-php7/conf/provision/roles/webdevops-php-nginx/tasks/main.yml new file mode 100644 index 000000000..7895a52a9 --- /dev/null +++ b/docker/php-nginx/alpine-php7/conf/provision/roles/webdevops-php-nginx/tasks/main.yml @@ -0,0 +1,9 @@ +--- + +- include: bootstrap.yml + tags: + - bootstrap + +- include: entrypoint.yml + tags: + - entrypoint diff --git a/docker/php-nginx/centos-7-php56/Dockerfile b/docker/php-nginx/centos-7-php56/Dockerfile index d26ed0350..41a6f3e57 100644 --- a/docker/php-nginx/centos-7-php56/Dockerfile +++ b/docker/php-nginx/centos-7-php56/Dockerfile @@ -5,15 +5,10 @@ FROM webdevops/php:centos-7-php56 -MAINTAINER info@webdevops.io -LABEL vendor=WebDevOps.io -LABEL io.webdevops.layout=8 -LABEL io.webdevops.version=1.5.0 - -ENV WEB_DOCUMENT_ROOT /app -ENV WEB_DOCUMENT_INDEX index.php -ENV WEB_ALIAS_DOMAIN *.vm -ENV WEB_PHP_SOCKET 127.0.0.1:9000 +ENV WEB_DOCUMENT_ROOT=/app \ + WEB_DOCUMENT_INDEX=index.php \ + WEB_ALIAS_DOMAIN=*.vm +ENV WEB_PHP_SOCKET=127.0.0.1:9000 COPY conf/ /opt/docker/ @@ -21,7 +16,7 @@ COPY conf/ /opt/docker/ RUN /usr/local/bin/yum-install \ nginx \ && /opt/docker/bin/provision run --tag bootstrap --role webdevops-nginx --role webdevops-php-nginx \ - && /opt/docker/bin/bootstrap.sh - + && /opt/docker/bin/bootstrap.sh \ + && docker-image-cleanup EXPOSE 80 443 diff --git a/docker/php-nginx/centos-7-php56/Dockerfile.jinja2 b/docker/php-nginx/centos-7-php56/Dockerfile.jinja2 index f74b18914..50efcebb3 100644 --- a/docker/php-nginx/centos-7-php56/Dockerfile.jinja2 +++ b/docker/php-nginx/centos-7-php56/Dockerfile.jinja2 @@ -1,7 +1,5 @@ {{ docker.from("php", "centos-7-php56") }} -{{ docker.version() }} - {{ environment.web() }} {{ environment.webPhp() }} diff --git a/docker/php-nginx/centos-7-php56/conf/bin/service.d/nginx.d/10-init.sh b/docker/php-nginx/centos-7-php56/conf/bin/service.d/nginx.d/10-init.sh index 75a84a4eb..27b9776cc 100644 --- a/docker/php-nginx/centos-7-php56/conf/bin/service.d/nginx.d/10-init.sh +++ b/docker/php-nginx/centos-7-php56/conf/bin/service.d/nginx.d/10-init.sh @@ -8,15 +8,17 @@ fi ln -f -s /var/lib/nginx/logs /var/log/nginx # Replace markers -find /opt/docker/etc/nginx/ -iname '*.conf' -print0 | xargs -0 -r rpl --quiet "" "$WEB_DOCUMENT_INDEX" > /dev/null -find /opt/docker/etc/nginx/ -iname '*.conf' -print0 | xargs -0 -r rpl --quiet "" "$WEB_DOCUMENT_ROOT" > /dev/null -find /opt/docker/etc/nginx/ -iname '*.conf' -print0 | xargs -0 -r rpl --quiet "" "$WEB_ALIAS_DOMAIN" > /dev/null -find /opt/docker/etc/nginx/ -iname '*.conf' -print0 | xargs -0 -r rpl --quiet "" "$HOSTNAME" > /dev/null +go-replace \ + -s "" -r "$WEB_DOCUMENT_INDEX" \ + -s "" -r "$WEB_DOCUMENT_ROOT" \ + -s "" -r "$WEB_ALIAS_DOMAIN" \ + -s "" -r "$HOSTNAME" \ + -s "" -r "$WEB_PHP_SOCKET" \ + --path=/opt/docker/etc/nginx/ \ + --path-pattern='*.conf' \ + --ignore-empty -if [[ -n "${WEB_PHP_SOCKET+x}" ]]; then - ## WEB_PHP_SOCKET is set - find /opt/docker/etc/nginx/ -iname '*.conf' -print0 | xargs -0 -r rpl --quiet "" "$WEB_PHP_SOCKET" > /dev/null -else +if [[ -z "${WEB_PHP_SOCKET+x}" ]]; then ## WEB_PHP_SOCKET is not set, remove PHP files rm -f -- /opt/docker/etc/nginx/conf.d/10-php.conf rm -f -- /opt/docker/etc/nginx/vhost.common.d/10-php.conf diff --git a/docker/php-nginx/centos-7-php56/conf/etc/nginx/vhost.common.d/10-general.conf b/docker/php-nginx/centos-7-php56/conf/etc/nginx/vhost.common.d/10-general.conf new file mode 100644 index 000000000..d3fd0aa5e --- /dev/null +++ b/docker/php-nginx/centos-7-php56/conf/etc/nginx/vhost.common.d/10-general.conf @@ -0,0 +1 @@ +client_max_body_size 50m; diff --git a/docker/php-nginx/centos-7-php56/conf/etc/nginx/vhost.common.d/10-log.conf b/docker/php-nginx/centos-7-php56/conf/etc/nginx/vhost.common.d/10-log.conf new file mode 100644 index 000000000..9646c6826 --- /dev/null +++ b/docker/php-nginx/centos-7-php56/conf/etc/nginx/vhost.common.d/10-log.conf @@ -0,0 +1,2 @@ +access_log /docker.stdout; +error_log /docker.stderr warn; diff --git a/docker/php-nginx/centos-7-php56/conf/etc/nginx/vhost.conf b/docker/php-nginx/centos-7-php56/conf/etc/nginx/vhost.conf index d07e27094..8225f314a 100644 --- a/docker/php-nginx/centos-7-php56/conf/etc/nginx/vhost.conf +++ b/docker/php-nginx/centos-7-php56/conf/etc/nginx/vhost.conf @@ -1,17 +1,11 @@ server { - listen 80 default_server; - listen 8000 default_server; + listen 80 default_server; server_name _ docker; - access_log /docker.stdout; - error_log /docker.stdout info; - root ""; index ; - client_max_body_size 50m; - include /opt/docker/etc/nginx/vhost.common.d/*.conf; } @@ -20,19 +14,13 @@ server { ############## server { - listen 443 default_server; - listen 8443 default_server; + listen 443 default_server; server_name _ docker; - access_log /docker.stdout; - error_log /docker.stdout info; - root ""; index ; - client_max_body_size 50m; - include /opt/docker/etc/nginx/vhost.common.d/*.conf; include /opt/docker/etc/nginx/vhost.ssl.conf; } diff --git a/docker/php-nginx/centos-7-php7/Dockerfile b/docker/php-nginx/centos-7-php7/Dockerfile index 6a549ea5b..425cc44ca 100644 --- a/docker/php-nginx/centos-7-php7/Dockerfile +++ b/docker/php-nginx/centos-7-php7/Dockerfile @@ -5,15 +5,10 @@ FROM webdevops/php:centos-7-php7 -MAINTAINER info@webdevops.io -LABEL vendor=WebDevOps.io -LABEL io.webdevops.layout=8 -LABEL io.webdevops.version=1.5.0 - -ENV WEB_DOCUMENT_ROOT /app -ENV WEB_DOCUMENT_INDEX index.php -ENV WEB_ALIAS_DOMAIN *.vm -ENV WEB_PHP_SOCKET 127.0.0.1:9000 +ENV WEB_DOCUMENT_ROOT=/app \ + WEB_DOCUMENT_INDEX=index.php \ + WEB_ALIAS_DOMAIN=*.vm +ENV WEB_PHP_SOCKET=127.0.0.1:9000 COPY conf/ /opt/docker/ @@ -21,7 +16,7 @@ COPY conf/ /opt/docker/ RUN /usr/local/bin/yum-install \ nginx \ && /opt/docker/bin/provision run --tag bootstrap --role webdevops-nginx --role webdevops-php-nginx \ - && /opt/docker/bin/bootstrap.sh - + && /opt/docker/bin/bootstrap.sh \ + && docker-image-cleanup EXPOSE 80 443 diff --git a/docker/php-nginx/centos-7-php7/Dockerfile.jinja2 b/docker/php-nginx/centos-7-php7/Dockerfile.jinja2 index d965f3cf0..0369224d4 100644 --- a/docker/php-nginx/centos-7-php7/Dockerfile.jinja2 +++ b/docker/php-nginx/centos-7-php7/Dockerfile.jinja2 @@ -1,7 +1,5 @@ {{ docker.from("php", "centos-7-php7") }} -{{ docker.version() }} - {{ environment.web() }} {{ environment.webPhp() }} diff --git a/docker/php-nginx/centos-7-php7/conf/bin/service.d/nginx.d/10-init.sh b/docker/php-nginx/centos-7-php7/conf/bin/service.d/nginx.d/10-init.sh index 75a84a4eb..27b9776cc 100644 --- a/docker/php-nginx/centos-7-php7/conf/bin/service.d/nginx.d/10-init.sh +++ b/docker/php-nginx/centos-7-php7/conf/bin/service.d/nginx.d/10-init.sh @@ -8,15 +8,17 @@ fi ln -f -s /var/lib/nginx/logs /var/log/nginx # Replace markers -find /opt/docker/etc/nginx/ -iname '*.conf' -print0 | xargs -0 -r rpl --quiet "" "$WEB_DOCUMENT_INDEX" > /dev/null -find /opt/docker/etc/nginx/ -iname '*.conf' -print0 | xargs -0 -r rpl --quiet "" "$WEB_DOCUMENT_ROOT" > /dev/null -find /opt/docker/etc/nginx/ -iname '*.conf' -print0 | xargs -0 -r rpl --quiet "" "$WEB_ALIAS_DOMAIN" > /dev/null -find /opt/docker/etc/nginx/ -iname '*.conf' -print0 | xargs -0 -r rpl --quiet "" "$HOSTNAME" > /dev/null +go-replace \ + -s "" -r "$WEB_DOCUMENT_INDEX" \ + -s "" -r "$WEB_DOCUMENT_ROOT" \ + -s "" -r "$WEB_ALIAS_DOMAIN" \ + -s "" -r "$HOSTNAME" \ + -s "" -r "$WEB_PHP_SOCKET" \ + --path=/opt/docker/etc/nginx/ \ + --path-pattern='*.conf' \ + --ignore-empty -if [[ -n "${WEB_PHP_SOCKET+x}" ]]; then - ## WEB_PHP_SOCKET is set - find /opt/docker/etc/nginx/ -iname '*.conf' -print0 | xargs -0 -r rpl --quiet "" "$WEB_PHP_SOCKET" > /dev/null -else +if [[ -z "${WEB_PHP_SOCKET+x}" ]]; then ## WEB_PHP_SOCKET is not set, remove PHP files rm -f -- /opt/docker/etc/nginx/conf.d/10-php.conf rm -f -- /opt/docker/etc/nginx/vhost.common.d/10-php.conf diff --git a/docker/php-nginx/centos-7-php7/conf/etc/nginx/vhost.common.d/10-general.conf b/docker/php-nginx/centos-7-php7/conf/etc/nginx/vhost.common.d/10-general.conf new file mode 100644 index 000000000..d3fd0aa5e --- /dev/null +++ b/docker/php-nginx/centos-7-php7/conf/etc/nginx/vhost.common.d/10-general.conf @@ -0,0 +1 @@ +client_max_body_size 50m; diff --git a/docker/php-nginx/centos-7-php7/conf/etc/nginx/vhost.common.d/10-log.conf b/docker/php-nginx/centos-7-php7/conf/etc/nginx/vhost.common.d/10-log.conf new file mode 100644 index 000000000..9646c6826 --- /dev/null +++ b/docker/php-nginx/centos-7-php7/conf/etc/nginx/vhost.common.d/10-log.conf @@ -0,0 +1,2 @@ +access_log /docker.stdout; +error_log /docker.stderr warn; diff --git a/docker/php-nginx/centos-7-php7/conf/etc/nginx/vhost.conf b/docker/php-nginx/centos-7-php7/conf/etc/nginx/vhost.conf index d07e27094..8225f314a 100644 --- a/docker/php-nginx/centos-7-php7/conf/etc/nginx/vhost.conf +++ b/docker/php-nginx/centos-7-php7/conf/etc/nginx/vhost.conf @@ -1,17 +1,11 @@ server { - listen 80 default_server; - listen 8000 default_server; + listen 80 default_server; server_name _ docker; - access_log /docker.stdout; - error_log /docker.stdout info; - root ""; index ; - client_max_body_size 50m; - include /opt/docker/etc/nginx/vhost.common.d/*.conf; } @@ -20,19 +14,13 @@ server { ############## server { - listen 443 default_server; - listen 8443 default_server; + listen 443 default_server; server_name _ docker; - access_log /docker.stdout; - error_log /docker.stdout info; - root ""; index ; - client_max_body_size 50m; - include /opt/docker/etc/nginx/vhost.common.d/*.conf; include /opt/docker/etc/nginx/vhost.ssl.conf; } diff --git a/docker/php-nginx/centos-7/Dockerfile b/docker/php-nginx/centos-7/Dockerfile index 3b6c5c51a..4d23b17f3 100644 --- a/docker/php-nginx/centos-7/Dockerfile +++ b/docker/php-nginx/centos-7/Dockerfile @@ -5,15 +5,10 @@ FROM webdevops/php:centos-7 -MAINTAINER info@webdevops.io -LABEL vendor=WebDevOps.io -LABEL io.webdevops.layout=8 -LABEL io.webdevops.version=1.5.0 - -ENV WEB_DOCUMENT_ROOT /app -ENV WEB_DOCUMENT_INDEX index.php -ENV WEB_ALIAS_DOMAIN *.vm -ENV WEB_PHP_SOCKET 127.0.0.1:9000 +ENV WEB_DOCUMENT_ROOT=/app \ + WEB_DOCUMENT_INDEX=index.php \ + WEB_ALIAS_DOMAIN=*.vm +ENV WEB_PHP_SOCKET=127.0.0.1:9000 COPY conf/ /opt/docker/ @@ -21,7 +16,7 @@ COPY conf/ /opt/docker/ RUN /usr/local/bin/yum-install \ nginx \ && /opt/docker/bin/provision run --tag bootstrap --role webdevops-nginx --role webdevops-php-nginx \ - && /opt/docker/bin/bootstrap.sh - + && /opt/docker/bin/bootstrap.sh \ + && docker-image-cleanup EXPOSE 80 443 diff --git a/docker/php-nginx/centos-7/Dockerfile.jinja2 b/docker/php-nginx/centos-7/Dockerfile.jinja2 index 0d36fa890..218acb628 100644 --- a/docker/php-nginx/centos-7/Dockerfile.jinja2 +++ b/docker/php-nginx/centos-7/Dockerfile.jinja2 @@ -1,7 +1,5 @@ {{ docker.from("php", "centos-7") }} -{{ docker.version() }} - {{ environment.web() }} {{ environment.webPhp() }} diff --git a/docker/php-nginx/centos-7/conf/bin/service.d/nginx.d/10-init.sh b/docker/php-nginx/centos-7/conf/bin/service.d/nginx.d/10-init.sh index 75a84a4eb..27b9776cc 100644 --- a/docker/php-nginx/centos-7/conf/bin/service.d/nginx.d/10-init.sh +++ b/docker/php-nginx/centos-7/conf/bin/service.d/nginx.d/10-init.sh @@ -8,15 +8,17 @@ fi ln -f -s /var/lib/nginx/logs /var/log/nginx # Replace markers -find /opt/docker/etc/nginx/ -iname '*.conf' -print0 | xargs -0 -r rpl --quiet "" "$WEB_DOCUMENT_INDEX" > /dev/null -find /opt/docker/etc/nginx/ -iname '*.conf' -print0 | xargs -0 -r rpl --quiet "" "$WEB_DOCUMENT_ROOT" > /dev/null -find /opt/docker/etc/nginx/ -iname '*.conf' -print0 | xargs -0 -r rpl --quiet "" "$WEB_ALIAS_DOMAIN" > /dev/null -find /opt/docker/etc/nginx/ -iname '*.conf' -print0 | xargs -0 -r rpl --quiet "" "$HOSTNAME" > /dev/null +go-replace \ + -s "" -r "$WEB_DOCUMENT_INDEX" \ + -s "" -r "$WEB_DOCUMENT_ROOT" \ + -s "" -r "$WEB_ALIAS_DOMAIN" \ + -s "" -r "$HOSTNAME" \ + -s "" -r "$WEB_PHP_SOCKET" \ + --path=/opt/docker/etc/nginx/ \ + --path-pattern='*.conf' \ + --ignore-empty -if [[ -n "${WEB_PHP_SOCKET+x}" ]]; then - ## WEB_PHP_SOCKET is set - find /opt/docker/etc/nginx/ -iname '*.conf' -print0 | xargs -0 -r rpl --quiet "" "$WEB_PHP_SOCKET" > /dev/null -else +if [[ -z "${WEB_PHP_SOCKET+x}" ]]; then ## WEB_PHP_SOCKET is not set, remove PHP files rm -f -- /opt/docker/etc/nginx/conf.d/10-php.conf rm -f -- /opt/docker/etc/nginx/vhost.common.d/10-php.conf diff --git a/docker/php-nginx/centos-7/conf/etc/nginx/vhost.common.d/10-general.conf b/docker/php-nginx/centos-7/conf/etc/nginx/vhost.common.d/10-general.conf new file mode 100644 index 000000000..d3fd0aa5e --- /dev/null +++ b/docker/php-nginx/centos-7/conf/etc/nginx/vhost.common.d/10-general.conf @@ -0,0 +1 @@ +client_max_body_size 50m; diff --git a/docker/php-nginx/centos-7/conf/etc/nginx/vhost.common.d/10-log.conf b/docker/php-nginx/centos-7/conf/etc/nginx/vhost.common.d/10-log.conf new file mode 100644 index 000000000..9646c6826 --- /dev/null +++ b/docker/php-nginx/centos-7/conf/etc/nginx/vhost.common.d/10-log.conf @@ -0,0 +1,2 @@ +access_log /docker.stdout; +error_log /docker.stderr warn; diff --git a/docker/php-nginx/centos-7/conf/etc/nginx/vhost.conf b/docker/php-nginx/centos-7/conf/etc/nginx/vhost.conf index d07e27094..8225f314a 100644 --- a/docker/php-nginx/centos-7/conf/etc/nginx/vhost.conf +++ b/docker/php-nginx/centos-7/conf/etc/nginx/vhost.conf @@ -1,17 +1,11 @@ server { - listen 80 default_server; - listen 8000 default_server; + listen 80 default_server; server_name _ docker; - access_log /docker.stdout; - error_log /docker.stdout info; - root ""; index ; - client_max_body_size 50m; - include /opt/docker/etc/nginx/vhost.common.d/*.conf; } @@ -20,19 +14,13 @@ server { ############## server { - listen 443 default_server; - listen 8443 default_server; + listen 443 default_server; server_name _ docker; - access_log /docker.stdout; - error_log /docker.stdout info; - root ""; index ; - client_max_body_size 50m; - include /opt/docker/etc/nginx/vhost.common.d/*.conf; include /opt/docker/etc/nginx/vhost.ssl.conf; } diff --git a/docker/php-nginx/debian-7/Dockerfile b/docker/php-nginx/debian-7/Dockerfile index 8e6efc623..9a7eeb839 100644 --- a/docker/php-nginx/debian-7/Dockerfile +++ b/docker/php-nginx/debian-7/Dockerfile @@ -5,15 +5,10 @@ FROM webdevops/php:debian-7 -MAINTAINER info@webdevops.io -LABEL vendor=WebDevOps.io -LABEL io.webdevops.layout=8 -LABEL io.webdevops.version=1.5.0 - -ENV WEB_DOCUMENT_ROOT /app -ENV WEB_DOCUMENT_INDEX index.php -ENV WEB_ALIAS_DOMAIN *.vm -ENV WEB_PHP_SOCKET 127.0.0.1:9000 +ENV WEB_DOCUMENT_ROOT=/app \ + WEB_DOCUMENT_INDEX=index.php \ + WEB_ALIAS_DOMAIN=*.vm +ENV WEB_PHP_SOCKET=127.0.0.1:9000 COPY conf/ /opt/docker/ @@ -21,7 +16,7 @@ COPY conf/ /opt/docker/ RUN /usr/local/bin/apt-install \ nginx \ && /opt/docker/bin/provision run --tag bootstrap --role webdevops-nginx --role webdevops-php-nginx \ - && /opt/docker/bin/bootstrap.sh - + && /opt/docker/bin/bootstrap.sh \ + && docker-image-cleanup EXPOSE 80 443 diff --git a/docker/php-nginx/debian-7/Dockerfile.jinja2 b/docker/php-nginx/debian-7/Dockerfile.jinja2 index 35a8ff69a..56c960ffe 100644 --- a/docker/php-nginx/debian-7/Dockerfile.jinja2 +++ b/docker/php-nginx/debian-7/Dockerfile.jinja2 @@ -1,7 +1,5 @@ {{ docker.from("php", "debian-7") }} -{{ docker.version() }} - {{ environment.web() }} {{ environment.webPhp() }} diff --git a/docker/php-nginx/debian-7/conf/bin/service.d/nginx.d/10-init.sh b/docker/php-nginx/debian-7/conf/bin/service.d/nginx.d/10-init.sh index 75a84a4eb..27b9776cc 100644 --- a/docker/php-nginx/debian-7/conf/bin/service.d/nginx.d/10-init.sh +++ b/docker/php-nginx/debian-7/conf/bin/service.d/nginx.d/10-init.sh @@ -8,15 +8,17 @@ fi ln -f -s /var/lib/nginx/logs /var/log/nginx # Replace markers -find /opt/docker/etc/nginx/ -iname '*.conf' -print0 | xargs -0 -r rpl --quiet "" "$WEB_DOCUMENT_INDEX" > /dev/null -find /opt/docker/etc/nginx/ -iname '*.conf' -print0 | xargs -0 -r rpl --quiet "" "$WEB_DOCUMENT_ROOT" > /dev/null -find /opt/docker/etc/nginx/ -iname '*.conf' -print0 | xargs -0 -r rpl --quiet "" "$WEB_ALIAS_DOMAIN" > /dev/null -find /opt/docker/etc/nginx/ -iname '*.conf' -print0 | xargs -0 -r rpl --quiet "" "$HOSTNAME" > /dev/null +go-replace \ + -s "" -r "$WEB_DOCUMENT_INDEX" \ + -s "" -r "$WEB_DOCUMENT_ROOT" \ + -s "" -r "$WEB_ALIAS_DOMAIN" \ + -s "" -r "$HOSTNAME" \ + -s "" -r "$WEB_PHP_SOCKET" \ + --path=/opt/docker/etc/nginx/ \ + --path-pattern='*.conf' \ + --ignore-empty -if [[ -n "${WEB_PHP_SOCKET+x}" ]]; then - ## WEB_PHP_SOCKET is set - find /opt/docker/etc/nginx/ -iname '*.conf' -print0 | xargs -0 -r rpl --quiet "" "$WEB_PHP_SOCKET" > /dev/null -else +if [[ -z "${WEB_PHP_SOCKET+x}" ]]; then ## WEB_PHP_SOCKET is not set, remove PHP files rm -f -- /opt/docker/etc/nginx/conf.d/10-php.conf rm -f -- /opt/docker/etc/nginx/vhost.common.d/10-php.conf diff --git a/docker/php-nginx/debian-7/conf/etc/nginx/vhost.common.d/10-general.conf b/docker/php-nginx/debian-7/conf/etc/nginx/vhost.common.d/10-general.conf new file mode 100644 index 000000000..d3fd0aa5e --- /dev/null +++ b/docker/php-nginx/debian-7/conf/etc/nginx/vhost.common.d/10-general.conf @@ -0,0 +1 @@ +client_max_body_size 50m; diff --git a/docker/php-nginx/debian-7/conf/etc/nginx/vhost.common.d/10-log.conf b/docker/php-nginx/debian-7/conf/etc/nginx/vhost.common.d/10-log.conf new file mode 100644 index 000000000..9646c6826 --- /dev/null +++ b/docker/php-nginx/debian-7/conf/etc/nginx/vhost.common.d/10-log.conf @@ -0,0 +1,2 @@ +access_log /docker.stdout; +error_log /docker.stderr warn; diff --git a/docker/php-nginx/debian-7/conf/etc/nginx/vhost.conf b/docker/php-nginx/debian-7/conf/etc/nginx/vhost.conf index d07e27094..8225f314a 100644 --- a/docker/php-nginx/debian-7/conf/etc/nginx/vhost.conf +++ b/docker/php-nginx/debian-7/conf/etc/nginx/vhost.conf @@ -1,17 +1,11 @@ server { - listen 80 default_server; - listen 8000 default_server; + listen 80 default_server; server_name _ docker; - access_log /docker.stdout; - error_log /docker.stdout info; - root ""; index ; - client_max_body_size 50m; - include /opt/docker/etc/nginx/vhost.common.d/*.conf; } @@ -20,19 +14,13 @@ server { ############## server { - listen 443 default_server; - listen 8443 default_server; + listen 443 default_server; server_name _ docker; - access_log /docker.stdout; - error_log /docker.stdout info; - root ""; index ; - client_max_body_size 50m; - include /opt/docker/etc/nginx/vhost.common.d/*.conf; include /opt/docker/etc/nginx/vhost.ssl.conf; } diff --git a/docker/php-nginx/debian-8-php7/Dockerfile b/docker/php-nginx/debian-8-php7/Dockerfile index c8d6e1539..b1ac0a881 100644 --- a/docker/php-nginx/debian-8-php7/Dockerfile +++ b/docker/php-nginx/debian-8-php7/Dockerfile @@ -5,15 +5,10 @@ FROM webdevops/php:debian-8-php7 -MAINTAINER info@webdevops.io -LABEL vendor=WebDevOps.io -LABEL io.webdevops.layout=8 -LABEL io.webdevops.version=1.5.0 - -ENV WEB_DOCUMENT_ROOT /app -ENV WEB_DOCUMENT_INDEX index.php -ENV WEB_ALIAS_DOMAIN *.vm -ENV WEB_PHP_SOCKET 127.0.0.1:9000 +ENV WEB_DOCUMENT_ROOT=/app \ + WEB_DOCUMENT_INDEX=index.php \ + WEB_ALIAS_DOMAIN=*.vm +ENV WEB_PHP_SOCKET=127.0.0.1:9000 COPY conf/ /opt/docker/ @@ -21,7 +16,7 @@ COPY conf/ /opt/docker/ RUN /usr/local/bin/apt-install \ nginx \ && /opt/docker/bin/provision run --tag bootstrap --role webdevops-nginx --role webdevops-php-nginx \ - && /opt/docker/bin/bootstrap.sh - + && /opt/docker/bin/bootstrap.sh \ + && docker-image-cleanup EXPOSE 80 443 diff --git a/docker/php-nginx/debian-8-php7/Dockerfile.jinja2 b/docker/php-nginx/debian-8-php7/Dockerfile.jinja2 index bc8043deb..496b43765 100644 --- a/docker/php-nginx/debian-8-php7/Dockerfile.jinja2 +++ b/docker/php-nginx/debian-8-php7/Dockerfile.jinja2 @@ -1,7 +1,5 @@ {{ docker.from("php", "debian-8-php7") }} -{{ docker.version() }} - {{ environment.web() }} {{ environment.webPhp() }} diff --git a/docker/php-nginx/debian-8-php7/conf/bin/service.d/nginx.d/10-init.sh b/docker/php-nginx/debian-8-php7/conf/bin/service.d/nginx.d/10-init.sh index 75a84a4eb..27b9776cc 100644 --- a/docker/php-nginx/debian-8-php7/conf/bin/service.d/nginx.d/10-init.sh +++ b/docker/php-nginx/debian-8-php7/conf/bin/service.d/nginx.d/10-init.sh @@ -8,15 +8,17 @@ fi ln -f -s /var/lib/nginx/logs /var/log/nginx # Replace markers -find /opt/docker/etc/nginx/ -iname '*.conf' -print0 | xargs -0 -r rpl --quiet "" "$WEB_DOCUMENT_INDEX" > /dev/null -find /opt/docker/etc/nginx/ -iname '*.conf' -print0 | xargs -0 -r rpl --quiet "" "$WEB_DOCUMENT_ROOT" > /dev/null -find /opt/docker/etc/nginx/ -iname '*.conf' -print0 | xargs -0 -r rpl --quiet "" "$WEB_ALIAS_DOMAIN" > /dev/null -find /opt/docker/etc/nginx/ -iname '*.conf' -print0 | xargs -0 -r rpl --quiet "" "$HOSTNAME" > /dev/null +go-replace \ + -s "" -r "$WEB_DOCUMENT_INDEX" \ + -s "" -r "$WEB_DOCUMENT_ROOT" \ + -s "" -r "$WEB_ALIAS_DOMAIN" \ + -s "" -r "$HOSTNAME" \ + -s "" -r "$WEB_PHP_SOCKET" \ + --path=/opt/docker/etc/nginx/ \ + --path-pattern='*.conf' \ + --ignore-empty -if [[ -n "${WEB_PHP_SOCKET+x}" ]]; then - ## WEB_PHP_SOCKET is set - find /opt/docker/etc/nginx/ -iname '*.conf' -print0 | xargs -0 -r rpl --quiet "" "$WEB_PHP_SOCKET" > /dev/null -else +if [[ -z "${WEB_PHP_SOCKET+x}" ]]; then ## WEB_PHP_SOCKET is not set, remove PHP files rm -f -- /opt/docker/etc/nginx/conf.d/10-php.conf rm -f -- /opt/docker/etc/nginx/vhost.common.d/10-php.conf diff --git a/docker/php-nginx/debian-8-php7/conf/etc/nginx/vhost.common.d/10-general.conf b/docker/php-nginx/debian-8-php7/conf/etc/nginx/vhost.common.d/10-general.conf new file mode 100644 index 000000000..d3fd0aa5e --- /dev/null +++ b/docker/php-nginx/debian-8-php7/conf/etc/nginx/vhost.common.d/10-general.conf @@ -0,0 +1 @@ +client_max_body_size 50m; diff --git a/docker/php-nginx/debian-8-php7/conf/etc/nginx/vhost.common.d/10-log.conf b/docker/php-nginx/debian-8-php7/conf/etc/nginx/vhost.common.d/10-log.conf new file mode 100644 index 000000000..9646c6826 --- /dev/null +++ b/docker/php-nginx/debian-8-php7/conf/etc/nginx/vhost.common.d/10-log.conf @@ -0,0 +1,2 @@ +access_log /docker.stdout; +error_log /docker.stderr warn; diff --git a/docker/php-nginx/debian-8-php7/conf/etc/nginx/vhost.conf b/docker/php-nginx/debian-8-php7/conf/etc/nginx/vhost.conf index d07e27094..8225f314a 100644 --- a/docker/php-nginx/debian-8-php7/conf/etc/nginx/vhost.conf +++ b/docker/php-nginx/debian-8-php7/conf/etc/nginx/vhost.conf @@ -1,17 +1,11 @@ server { - listen 80 default_server; - listen 8000 default_server; + listen 80 default_server; server_name _ docker; - access_log /docker.stdout; - error_log /docker.stdout info; - root ""; index ; - client_max_body_size 50m; - include /opt/docker/etc/nginx/vhost.common.d/*.conf; } @@ -20,19 +14,13 @@ server { ############## server { - listen 443 default_server; - listen 8443 default_server; + listen 443 default_server; server_name _ docker; - access_log /docker.stdout; - error_log /docker.stdout info; - root ""; index ; - client_max_body_size 50m; - include /opt/docker/etc/nginx/vhost.common.d/*.conf; include /opt/docker/etc/nginx/vhost.ssl.conf; } diff --git a/docker/php-nginx/debian-8/Dockerfile b/docker/php-nginx/debian-8/Dockerfile index 7e449ef3c..6692d0b2c 100644 --- a/docker/php-nginx/debian-8/Dockerfile +++ b/docker/php-nginx/debian-8/Dockerfile @@ -5,15 +5,10 @@ FROM webdevops/php:debian-8 -MAINTAINER info@webdevops.io -LABEL vendor=WebDevOps.io -LABEL io.webdevops.layout=8 -LABEL io.webdevops.version=1.5.0 - -ENV WEB_DOCUMENT_ROOT /app -ENV WEB_DOCUMENT_INDEX index.php -ENV WEB_ALIAS_DOMAIN *.vm -ENV WEB_PHP_SOCKET 127.0.0.1:9000 +ENV WEB_DOCUMENT_ROOT=/app \ + WEB_DOCUMENT_INDEX=index.php \ + WEB_ALIAS_DOMAIN=*.vm +ENV WEB_PHP_SOCKET=127.0.0.1:9000 COPY conf/ /opt/docker/ @@ -21,7 +16,7 @@ COPY conf/ /opt/docker/ RUN /usr/local/bin/apt-install \ nginx \ && /opt/docker/bin/provision run --tag bootstrap --role webdevops-nginx --role webdevops-php-nginx \ - && /opt/docker/bin/bootstrap.sh - + && /opt/docker/bin/bootstrap.sh \ + && docker-image-cleanup EXPOSE 80 443 diff --git a/docker/php-nginx/debian-8/Dockerfile.jinja2 b/docker/php-nginx/debian-8/Dockerfile.jinja2 index 3737a4195..23a30f820 100644 --- a/docker/php-nginx/debian-8/Dockerfile.jinja2 +++ b/docker/php-nginx/debian-8/Dockerfile.jinja2 @@ -1,7 +1,5 @@ {{ docker.from("php", "debian-8") }} -{{ docker.version() }} - {{ environment.web() }} {{ environment.webPhp() }} diff --git a/docker/php-nginx/debian-8/conf/bin/service.d/nginx.d/10-init.sh b/docker/php-nginx/debian-8/conf/bin/service.d/nginx.d/10-init.sh index 75a84a4eb..27b9776cc 100644 --- a/docker/php-nginx/debian-8/conf/bin/service.d/nginx.d/10-init.sh +++ b/docker/php-nginx/debian-8/conf/bin/service.d/nginx.d/10-init.sh @@ -8,15 +8,17 @@ fi ln -f -s /var/lib/nginx/logs /var/log/nginx # Replace markers -find /opt/docker/etc/nginx/ -iname '*.conf' -print0 | xargs -0 -r rpl --quiet "" "$WEB_DOCUMENT_INDEX" > /dev/null -find /opt/docker/etc/nginx/ -iname '*.conf' -print0 | xargs -0 -r rpl --quiet "" "$WEB_DOCUMENT_ROOT" > /dev/null -find /opt/docker/etc/nginx/ -iname '*.conf' -print0 | xargs -0 -r rpl --quiet "" "$WEB_ALIAS_DOMAIN" > /dev/null -find /opt/docker/etc/nginx/ -iname '*.conf' -print0 | xargs -0 -r rpl --quiet "" "$HOSTNAME" > /dev/null +go-replace \ + -s "" -r "$WEB_DOCUMENT_INDEX" \ + -s "" -r "$WEB_DOCUMENT_ROOT" \ + -s "" -r "$WEB_ALIAS_DOMAIN" \ + -s "" -r "$HOSTNAME" \ + -s "" -r "$WEB_PHP_SOCKET" \ + --path=/opt/docker/etc/nginx/ \ + --path-pattern='*.conf' \ + --ignore-empty -if [[ -n "${WEB_PHP_SOCKET+x}" ]]; then - ## WEB_PHP_SOCKET is set - find /opt/docker/etc/nginx/ -iname '*.conf' -print0 | xargs -0 -r rpl --quiet "" "$WEB_PHP_SOCKET" > /dev/null -else +if [[ -z "${WEB_PHP_SOCKET+x}" ]]; then ## WEB_PHP_SOCKET is not set, remove PHP files rm -f -- /opt/docker/etc/nginx/conf.d/10-php.conf rm -f -- /opt/docker/etc/nginx/vhost.common.d/10-php.conf diff --git a/docker/php-nginx/debian-8/conf/etc/nginx/vhost.common.d/10-general.conf b/docker/php-nginx/debian-8/conf/etc/nginx/vhost.common.d/10-general.conf new file mode 100644 index 000000000..d3fd0aa5e --- /dev/null +++ b/docker/php-nginx/debian-8/conf/etc/nginx/vhost.common.d/10-general.conf @@ -0,0 +1 @@ +client_max_body_size 50m; diff --git a/docker/php-nginx/debian-8/conf/etc/nginx/vhost.common.d/10-log.conf b/docker/php-nginx/debian-8/conf/etc/nginx/vhost.common.d/10-log.conf new file mode 100644 index 000000000..9646c6826 --- /dev/null +++ b/docker/php-nginx/debian-8/conf/etc/nginx/vhost.common.d/10-log.conf @@ -0,0 +1,2 @@ +access_log /docker.stdout; +error_log /docker.stderr warn; diff --git a/docker/php-nginx/debian-8/conf/etc/nginx/vhost.conf b/docker/php-nginx/debian-8/conf/etc/nginx/vhost.conf index d07e27094..8225f314a 100644 --- a/docker/php-nginx/debian-8/conf/etc/nginx/vhost.conf +++ b/docker/php-nginx/debian-8/conf/etc/nginx/vhost.conf @@ -1,17 +1,11 @@ server { - listen 80 default_server; - listen 8000 default_server; + listen 80 default_server; server_name _ docker; - access_log /docker.stdout; - error_log /docker.stdout info; - root ""; index ; - client_max_body_size 50m; - include /opt/docker/etc/nginx/vhost.common.d/*.conf; } @@ -20,19 +14,13 @@ server { ############## server { - listen 443 default_server; - listen 8443 default_server; + listen 443 default_server; server_name _ docker; - access_log /docker.stdout; - error_log /docker.stdout info; - root ""; index ; - client_max_body_size 50m; - include /opt/docker/etc/nginx/vhost.common.d/*.conf; include /opt/docker/etc/nginx/vhost.ssl.conf; } diff --git a/docker/php-nginx/debian-9/Dockerfile b/docker/php-nginx/debian-9/Dockerfile index f578b3972..8f05b3f5d 100644 --- a/docker/php-nginx/debian-9/Dockerfile +++ b/docker/php-nginx/debian-9/Dockerfile @@ -5,15 +5,10 @@ FROM webdevops/php:debian-9 -MAINTAINER info@webdevops.io -LABEL vendor=WebDevOps.io -LABEL io.webdevops.layout=8 -LABEL io.webdevops.version=1.5.0 - -ENV WEB_DOCUMENT_ROOT /app -ENV WEB_DOCUMENT_INDEX index.php -ENV WEB_ALIAS_DOMAIN *.vm -ENV WEB_PHP_SOCKET 127.0.0.1:9000 +ENV WEB_DOCUMENT_ROOT=/app \ + WEB_DOCUMENT_INDEX=index.php \ + WEB_ALIAS_DOMAIN=*.vm +ENV WEB_PHP_SOCKET=127.0.0.1:9000 COPY conf/ /opt/docker/ @@ -21,7 +16,7 @@ COPY conf/ /opt/docker/ RUN /usr/local/bin/apt-install \ nginx \ && /opt/docker/bin/provision run --tag bootstrap --role webdevops-nginx --role webdevops-php-nginx \ - && /opt/docker/bin/bootstrap.sh - + && /opt/docker/bin/bootstrap.sh \ + && docker-image-cleanup EXPOSE 80 443 diff --git a/docker/php-nginx/debian-9/Dockerfile.jinja2 b/docker/php-nginx/debian-9/Dockerfile.jinja2 index 10aa7604d..928785005 100644 --- a/docker/php-nginx/debian-9/Dockerfile.jinja2 +++ b/docker/php-nginx/debian-9/Dockerfile.jinja2 @@ -1,7 +1,5 @@ {{ docker.from("php", "debian-9") }} -{{ docker.version() }} - {{ environment.web() }} {{ environment.webPhp() }} diff --git a/docker/php-nginx/debian-9/conf/bin/service.d/nginx.d/10-init.sh b/docker/php-nginx/debian-9/conf/bin/service.d/nginx.d/10-init.sh index 75a84a4eb..27b9776cc 100644 --- a/docker/php-nginx/debian-9/conf/bin/service.d/nginx.d/10-init.sh +++ b/docker/php-nginx/debian-9/conf/bin/service.d/nginx.d/10-init.sh @@ -8,15 +8,17 @@ fi ln -f -s /var/lib/nginx/logs /var/log/nginx # Replace markers -find /opt/docker/etc/nginx/ -iname '*.conf' -print0 | xargs -0 -r rpl --quiet "" "$WEB_DOCUMENT_INDEX" > /dev/null -find /opt/docker/etc/nginx/ -iname '*.conf' -print0 | xargs -0 -r rpl --quiet "" "$WEB_DOCUMENT_ROOT" > /dev/null -find /opt/docker/etc/nginx/ -iname '*.conf' -print0 | xargs -0 -r rpl --quiet "" "$WEB_ALIAS_DOMAIN" > /dev/null -find /opt/docker/etc/nginx/ -iname '*.conf' -print0 | xargs -0 -r rpl --quiet "" "$HOSTNAME" > /dev/null +go-replace \ + -s "" -r "$WEB_DOCUMENT_INDEX" \ + -s "" -r "$WEB_DOCUMENT_ROOT" \ + -s "" -r "$WEB_ALIAS_DOMAIN" \ + -s "" -r "$HOSTNAME" \ + -s "" -r "$WEB_PHP_SOCKET" \ + --path=/opt/docker/etc/nginx/ \ + --path-pattern='*.conf' \ + --ignore-empty -if [[ -n "${WEB_PHP_SOCKET+x}" ]]; then - ## WEB_PHP_SOCKET is set - find /opt/docker/etc/nginx/ -iname '*.conf' -print0 | xargs -0 -r rpl --quiet "" "$WEB_PHP_SOCKET" > /dev/null -else +if [[ -z "${WEB_PHP_SOCKET+x}" ]]; then ## WEB_PHP_SOCKET is not set, remove PHP files rm -f -- /opt/docker/etc/nginx/conf.d/10-php.conf rm -f -- /opt/docker/etc/nginx/vhost.common.d/10-php.conf diff --git a/docker/php-nginx/debian-9/conf/etc/nginx/vhost.common.d/10-general.conf b/docker/php-nginx/debian-9/conf/etc/nginx/vhost.common.d/10-general.conf new file mode 100644 index 000000000..d3fd0aa5e --- /dev/null +++ b/docker/php-nginx/debian-9/conf/etc/nginx/vhost.common.d/10-general.conf @@ -0,0 +1 @@ +client_max_body_size 50m; diff --git a/docker/php-nginx/debian-9/conf/etc/nginx/vhost.common.d/10-log.conf b/docker/php-nginx/debian-9/conf/etc/nginx/vhost.common.d/10-log.conf new file mode 100644 index 000000000..9646c6826 --- /dev/null +++ b/docker/php-nginx/debian-9/conf/etc/nginx/vhost.common.d/10-log.conf @@ -0,0 +1,2 @@ +access_log /docker.stdout; +error_log /docker.stderr warn; diff --git a/docker/php-nginx/debian-9/conf/etc/nginx/vhost.conf b/docker/php-nginx/debian-9/conf/etc/nginx/vhost.conf index d07e27094..8225f314a 100644 --- a/docker/php-nginx/debian-9/conf/etc/nginx/vhost.conf +++ b/docker/php-nginx/debian-9/conf/etc/nginx/vhost.conf @@ -1,17 +1,11 @@ server { - listen 80 default_server; - listen 8000 default_server; + listen 80 default_server; server_name _ docker; - access_log /docker.stdout; - error_log /docker.stdout info; - root ""; index ; - client_max_body_size 50m; - include /opt/docker/etc/nginx/vhost.common.d/*.conf; } @@ -20,19 +14,13 @@ server { ############## server { - listen 443 default_server; - listen 8443 default_server; + listen 443 default_server; server_name _ docker; - access_log /docker.stdout; - error_log /docker.stdout info; - root ""; index ; - client_max_body_size 50m; - include /opt/docker/etc/nginx/vhost.common.d/*.conf; include /opt/docker/etc/nginx/vhost.ssl.conf; } diff --git a/docker/php-nginx/ubuntu-12.04/Dockerfile b/docker/php-nginx/ubuntu-12.04/Dockerfile index c48274f8c..2f44211c6 100644 --- a/docker/php-nginx/ubuntu-12.04/Dockerfile +++ b/docker/php-nginx/ubuntu-12.04/Dockerfile @@ -5,15 +5,10 @@ FROM webdevops/php:ubuntu-12.04 -MAINTAINER info@webdevops.io -LABEL vendor=WebDevOps.io -LABEL io.webdevops.layout=8 -LABEL io.webdevops.version=1.5.0 - -ENV WEB_DOCUMENT_ROOT /app -ENV WEB_DOCUMENT_INDEX index.php -ENV WEB_ALIAS_DOMAIN *.vm -ENV WEB_PHP_SOCKET 127.0.0.1:9000 +ENV WEB_DOCUMENT_ROOT=/app \ + WEB_DOCUMENT_INDEX=index.php \ + WEB_ALIAS_DOMAIN=*.vm +ENV WEB_PHP_SOCKET=127.0.0.1:9000 COPY conf/ /opt/docker/ @@ -21,7 +16,7 @@ COPY conf/ /opt/docker/ RUN /usr/local/bin/apt-install \ nginx \ && /opt/docker/bin/provision run --tag bootstrap --role webdevops-nginx --role webdevops-php-nginx \ - && /opt/docker/bin/bootstrap.sh - + && /opt/docker/bin/bootstrap.sh \ + && docker-image-cleanup EXPOSE 80 443 diff --git a/docker/php-nginx/ubuntu-12.04/Dockerfile.jinja2 b/docker/php-nginx/ubuntu-12.04/Dockerfile.jinja2 index 84dbad02a..ed6f88c07 100644 --- a/docker/php-nginx/ubuntu-12.04/Dockerfile.jinja2 +++ b/docker/php-nginx/ubuntu-12.04/Dockerfile.jinja2 @@ -1,7 +1,5 @@ {{ docker.from("php", "ubuntu-12.04") }} -{{ docker.version() }} - {{ environment.web() }} {{ environment.webPhp() }} diff --git a/docker/php-nginx/ubuntu-12.04/conf/bin/service.d/nginx.d/10-init.sh b/docker/php-nginx/ubuntu-12.04/conf/bin/service.d/nginx.d/10-init.sh index 75a84a4eb..27b9776cc 100644 --- a/docker/php-nginx/ubuntu-12.04/conf/bin/service.d/nginx.d/10-init.sh +++ b/docker/php-nginx/ubuntu-12.04/conf/bin/service.d/nginx.d/10-init.sh @@ -8,15 +8,17 @@ fi ln -f -s /var/lib/nginx/logs /var/log/nginx # Replace markers -find /opt/docker/etc/nginx/ -iname '*.conf' -print0 | xargs -0 -r rpl --quiet "" "$WEB_DOCUMENT_INDEX" > /dev/null -find /opt/docker/etc/nginx/ -iname '*.conf' -print0 | xargs -0 -r rpl --quiet "" "$WEB_DOCUMENT_ROOT" > /dev/null -find /opt/docker/etc/nginx/ -iname '*.conf' -print0 | xargs -0 -r rpl --quiet "" "$WEB_ALIAS_DOMAIN" > /dev/null -find /opt/docker/etc/nginx/ -iname '*.conf' -print0 | xargs -0 -r rpl --quiet "" "$HOSTNAME" > /dev/null +go-replace \ + -s "" -r "$WEB_DOCUMENT_INDEX" \ + -s "" -r "$WEB_DOCUMENT_ROOT" \ + -s "" -r "$WEB_ALIAS_DOMAIN" \ + -s "" -r "$HOSTNAME" \ + -s "" -r "$WEB_PHP_SOCKET" \ + --path=/opt/docker/etc/nginx/ \ + --path-pattern='*.conf' \ + --ignore-empty -if [[ -n "${WEB_PHP_SOCKET+x}" ]]; then - ## WEB_PHP_SOCKET is set - find /opt/docker/etc/nginx/ -iname '*.conf' -print0 | xargs -0 -r rpl --quiet "" "$WEB_PHP_SOCKET" > /dev/null -else +if [[ -z "${WEB_PHP_SOCKET+x}" ]]; then ## WEB_PHP_SOCKET is not set, remove PHP files rm -f -- /opt/docker/etc/nginx/conf.d/10-php.conf rm -f -- /opt/docker/etc/nginx/vhost.common.d/10-php.conf diff --git a/docker/php-nginx/ubuntu-12.04/conf/etc/nginx/vhost.common.d/10-general.conf b/docker/php-nginx/ubuntu-12.04/conf/etc/nginx/vhost.common.d/10-general.conf new file mode 100644 index 000000000..d3fd0aa5e --- /dev/null +++ b/docker/php-nginx/ubuntu-12.04/conf/etc/nginx/vhost.common.d/10-general.conf @@ -0,0 +1 @@ +client_max_body_size 50m; diff --git a/docker/php-nginx/ubuntu-12.04/conf/etc/nginx/vhost.common.d/10-log.conf b/docker/php-nginx/ubuntu-12.04/conf/etc/nginx/vhost.common.d/10-log.conf new file mode 100644 index 000000000..9646c6826 --- /dev/null +++ b/docker/php-nginx/ubuntu-12.04/conf/etc/nginx/vhost.common.d/10-log.conf @@ -0,0 +1,2 @@ +access_log /docker.stdout; +error_log /docker.stderr warn; diff --git a/docker/php-nginx/ubuntu-12.04/conf/etc/nginx/vhost.conf b/docker/php-nginx/ubuntu-12.04/conf/etc/nginx/vhost.conf index d07e27094..8225f314a 100644 --- a/docker/php-nginx/ubuntu-12.04/conf/etc/nginx/vhost.conf +++ b/docker/php-nginx/ubuntu-12.04/conf/etc/nginx/vhost.conf @@ -1,17 +1,11 @@ server { - listen 80 default_server; - listen 8000 default_server; + listen 80 default_server; server_name _ docker; - access_log /docker.stdout; - error_log /docker.stdout info; - root ""; index ; - client_max_body_size 50m; - include /opt/docker/etc/nginx/vhost.common.d/*.conf; } @@ -20,19 +14,13 @@ server { ############## server { - listen 443 default_server; - listen 8443 default_server; + listen 443 default_server; server_name _ docker; - access_log /docker.stdout; - error_log /docker.stdout info; - root ""; index ; - client_max_body_size 50m; - include /opt/docker/etc/nginx/vhost.common.d/*.conf; include /opt/docker/etc/nginx/vhost.ssl.conf; } diff --git a/docker/php-nginx/ubuntu-14.04/Dockerfile b/docker/php-nginx/ubuntu-14.04/Dockerfile index 6172a41b5..4847da1a0 100644 --- a/docker/php-nginx/ubuntu-14.04/Dockerfile +++ b/docker/php-nginx/ubuntu-14.04/Dockerfile @@ -5,15 +5,10 @@ FROM webdevops/php:ubuntu-14.04 -MAINTAINER info@webdevops.io -LABEL vendor=WebDevOps.io -LABEL io.webdevops.layout=8 -LABEL io.webdevops.version=1.5.0 - -ENV WEB_DOCUMENT_ROOT /app -ENV WEB_DOCUMENT_INDEX index.php -ENV WEB_ALIAS_DOMAIN *.vm -ENV WEB_PHP_SOCKET 127.0.0.1:9000 +ENV WEB_DOCUMENT_ROOT=/app \ + WEB_DOCUMENT_INDEX=index.php \ + WEB_ALIAS_DOMAIN=*.vm +ENV WEB_PHP_SOCKET=127.0.0.1:9000 COPY conf/ /opt/docker/ @@ -21,7 +16,7 @@ COPY conf/ /opt/docker/ RUN /usr/local/bin/apt-install \ nginx \ && /opt/docker/bin/provision run --tag bootstrap --role webdevops-nginx --role webdevops-php-nginx \ - && /opt/docker/bin/bootstrap.sh - + && /opt/docker/bin/bootstrap.sh \ + && docker-image-cleanup EXPOSE 80 443 diff --git a/docker/php-nginx/ubuntu-14.04/Dockerfile.jinja2 b/docker/php-nginx/ubuntu-14.04/Dockerfile.jinja2 index b964dd07f..f33c49154 100644 --- a/docker/php-nginx/ubuntu-14.04/Dockerfile.jinja2 +++ b/docker/php-nginx/ubuntu-14.04/Dockerfile.jinja2 @@ -1,7 +1,5 @@ {{ docker.from("php", "ubuntu-14.04") }} -{{ docker.version() }} - {{ environment.web() }} {{ environment.webPhp() }} diff --git a/docker/php-nginx/ubuntu-14.04/conf/bin/service.d/nginx.d/10-init.sh b/docker/php-nginx/ubuntu-14.04/conf/bin/service.d/nginx.d/10-init.sh index 75a84a4eb..27b9776cc 100644 --- a/docker/php-nginx/ubuntu-14.04/conf/bin/service.d/nginx.d/10-init.sh +++ b/docker/php-nginx/ubuntu-14.04/conf/bin/service.d/nginx.d/10-init.sh @@ -8,15 +8,17 @@ fi ln -f -s /var/lib/nginx/logs /var/log/nginx # Replace markers -find /opt/docker/etc/nginx/ -iname '*.conf' -print0 | xargs -0 -r rpl --quiet "" "$WEB_DOCUMENT_INDEX" > /dev/null -find /opt/docker/etc/nginx/ -iname '*.conf' -print0 | xargs -0 -r rpl --quiet "" "$WEB_DOCUMENT_ROOT" > /dev/null -find /opt/docker/etc/nginx/ -iname '*.conf' -print0 | xargs -0 -r rpl --quiet "" "$WEB_ALIAS_DOMAIN" > /dev/null -find /opt/docker/etc/nginx/ -iname '*.conf' -print0 | xargs -0 -r rpl --quiet "" "$HOSTNAME" > /dev/null +go-replace \ + -s "" -r "$WEB_DOCUMENT_INDEX" \ + -s "" -r "$WEB_DOCUMENT_ROOT" \ + -s "" -r "$WEB_ALIAS_DOMAIN" \ + -s "" -r "$HOSTNAME" \ + -s "" -r "$WEB_PHP_SOCKET" \ + --path=/opt/docker/etc/nginx/ \ + --path-pattern='*.conf' \ + --ignore-empty -if [[ -n "${WEB_PHP_SOCKET+x}" ]]; then - ## WEB_PHP_SOCKET is set - find /opt/docker/etc/nginx/ -iname '*.conf' -print0 | xargs -0 -r rpl --quiet "" "$WEB_PHP_SOCKET" > /dev/null -else +if [[ -z "${WEB_PHP_SOCKET+x}" ]]; then ## WEB_PHP_SOCKET is not set, remove PHP files rm -f -- /opt/docker/etc/nginx/conf.d/10-php.conf rm -f -- /opt/docker/etc/nginx/vhost.common.d/10-php.conf diff --git a/docker/php-nginx/ubuntu-14.04/conf/etc/nginx/vhost.common.d/10-general.conf b/docker/php-nginx/ubuntu-14.04/conf/etc/nginx/vhost.common.d/10-general.conf new file mode 100644 index 000000000..d3fd0aa5e --- /dev/null +++ b/docker/php-nginx/ubuntu-14.04/conf/etc/nginx/vhost.common.d/10-general.conf @@ -0,0 +1 @@ +client_max_body_size 50m; diff --git a/docker/php-nginx/ubuntu-14.04/conf/etc/nginx/vhost.common.d/10-log.conf b/docker/php-nginx/ubuntu-14.04/conf/etc/nginx/vhost.common.d/10-log.conf new file mode 100644 index 000000000..9646c6826 --- /dev/null +++ b/docker/php-nginx/ubuntu-14.04/conf/etc/nginx/vhost.common.d/10-log.conf @@ -0,0 +1,2 @@ +access_log /docker.stdout; +error_log /docker.stderr warn; diff --git a/docker/php-nginx/ubuntu-14.04/conf/etc/nginx/vhost.conf b/docker/php-nginx/ubuntu-14.04/conf/etc/nginx/vhost.conf index d07e27094..8225f314a 100644 --- a/docker/php-nginx/ubuntu-14.04/conf/etc/nginx/vhost.conf +++ b/docker/php-nginx/ubuntu-14.04/conf/etc/nginx/vhost.conf @@ -1,17 +1,11 @@ server { - listen 80 default_server; - listen 8000 default_server; + listen 80 default_server; server_name _ docker; - access_log /docker.stdout; - error_log /docker.stdout info; - root ""; index ; - client_max_body_size 50m; - include /opt/docker/etc/nginx/vhost.common.d/*.conf; } @@ -20,19 +14,13 @@ server { ############## server { - listen 443 default_server; - listen 8443 default_server; + listen 443 default_server; server_name _ docker; - access_log /docker.stdout; - error_log /docker.stdout info; - root ""; index ; - client_max_body_size 50m; - include /opt/docker/etc/nginx/vhost.common.d/*.conf; include /opt/docker/etc/nginx/vhost.ssl.conf; } diff --git a/docker/php-nginx/ubuntu-15.04/Dockerfile b/docker/php-nginx/ubuntu-15.04/Dockerfile index a30ca71ac..457b2086f 100644 --- a/docker/php-nginx/ubuntu-15.04/Dockerfile +++ b/docker/php-nginx/ubuntu-15.04/Dockerfile @@ -5,15 +5,10 @@ FROM webdevops/php:ubuntu-15.04 -MAINTAINER info@webdevops.io -LABEL vendor=WebDevOps.io -LABEL io.webdevops.layout=8 -LABEL io.webdevops.version=1.5.0 - -ENV WEB_DOCUMENT_ROOT /app -ENV WEB_DOCUMENT_INDEX index.php -ENV WEB_ALIAS_DOMAIN *.vm -ENV WEB_PHP_SOCKET 127.0.0.1:9000 +ENV WEB_DOCUMENT_ROOT=/app \ + WEB_DOCUMENT_INDEX=index.php \ + WEB_ALIAS_DOMAIN=*.vm +ENV WEB_PHP_SOCKET=127.0.0.1:9000 COPY conf/ /opt/docker/ @@ -21,7 +16,7 @@ COPY conf/ /opt/docker/ RUN /usr/local/bin/apt-install \ nginx \ && /opt/docker/bin/provision run --tag bootstrap --role webdevops-nginx --role webdevops-php-nginx \ - && /opt/docker/bin/bootstrap.sh - + && /opt/docker/bin/bootstrap.sh \ + && docker-image-cleanup EXPOSE 80 443 diff --git a/docker/php-nginx/ubuntu-15.04/Dockerfile.jinja2 b/docker/php-nginx/ubuntu-15.04/Dockerfile.jinja2 index 706f38568..fac95f9ee 100644 --- a/docker/php-nginx/ubuntu-15.04/Dockerfile.jinja2 +++ b/docker/php-nginx/ubuntu-15.04/Dockerfile.jinja2 @@ -1,7 +1,5 @@ {{ docker.from("php", "ubuntu-15.04") }} -{{ docker.version() }} - {{ environment.web() }} {{ environment.webPhp() }} diff --git a/docker/php-nginx/ubuntu-15.04/conf/bin/service.d/nginx.d/10-init.sh b/docker/php-nginx/ubuntu-15.04/conf/bin/service.d/nginx.d/10-init.sh index 75a84a4eb..27b9776cc 100644 --- a/docker/php-nginx/ubuntu-15.04/conf/bin/service.d/nginx.d/10-init.sh +++ b/docker/php-nginx/ubuntu-15.04/conf/bin/service.d/nginx.d/10-init.sh @@ -8,15 +8,17 @@ fi ln -f -s /var/lib/nginx/logs /var/log/nginx # Replace markers -find /opt/docker/etc/nginx/ -iname '*.conf' -print0 | xargs -0 -r rpl --quiet "" "$WEB_DOCUMENT_INDEX" > /dev/null -find /opt/docker/etc/nginx/ -iname '*.conf' -print0 | xargs -0 -r rpl --quiet "" "$WEB_DOCUMENT_ROOT" > /dev/null -find /opt/docker/etc/nginx/ -iname '*.conf' -print0 | xargs -0 -r rpl --quiet "" "$WEB_ALIAS_DOMAIN" > /dev/null -find /opt/docker/etc/nginx/ -iname '*.conf' -print0 | xargs -0 -r rpl --quiet "" "$HOSTNAME" > /dev/null +go-replace \ + -s "" -r "$WEB_DOCUMENT_INDEX" \ + -s "" -r "$WEB_DOCUMENT_ROOT" \ + -s "" -r "$WEB_ALIAS_DOMAIN" \ + -s "" -r "$HOSTNAME" \ + -s "" -r "$WEB_PHP_SOCKET" \ + --path=/opt/docker/etc/nginx/ \ + --path-pattern='*.conf' \ + --ignore-empty -if [[ -n "${WEB_PHP_SOCKET+x}" ]]; then - ## WEB_PHP_SOCKET is set - find /opt/docker/etc/nginx/ -iname '*.conf' -print0 | xargs -0 -r rpl --quiet "" "$WEB_PHP_SOCKET" > /dev/null -else +if [[ -z "${WEB_PHP_SOCKET+x}" ]]; then ## WEB_PHP_SOCKET is not set, remove PHP files rm -f -- /opt/docker/etc/nginx/conf.d/10-php.conf rm -f -- /opt/docker/etc/nginx/vhost.common.d/10-php.conf diff --git a/docker/php-nginx/ubuntu-15.04/conf/etc/nginx/vhost.common.d/10-general.conf b/docker/php-nginx/ubuntu-15.04/conf/etc/nginx/vhost.common.d/10-general.conf new file mode 100644 index 000000000..d3fd0aa5e --- /dev/null +++ b/docker/php-nginx/ubuntu-15.04/conf/etc/nginx/vhost.common.d/10-general.conf @@ -0,0 +1 @@ +client_max_body_size 50m; diff --git a/docker/php-nginx/ubuntu-15.04/conf/etc/nginx/vhost.common.d/10-log.conf b/docker/php-nginx/ubuntu-15.04/conf/etc/nginx/vhost.common.d/10-log.conf new file mode 100644 index 000000000..9646c6826 --- /dev/null +++ b/docker/php-nginx/ubuntu-15.04/conf/etc/nginx/vhost.common.d/10-log.conf @@ -0,0 +1,2 @@ +access_log /docker.stdout; +error_log /docker.stderr warn; diff --git a/docker/php-nginx/ubuntu-15.04/conf/etc/nginx/vhost.conf b/docker/php-nginx/ubuntu-15.04/conf/etc/nginx/vhost.conf index d07e27094..8225f314a 100644 --- a/docker/php-nginx/ubuntu-15.04/conf/etc/nginx/vhost.conf +++ b/docker/php-nginx/ubuntu-15.04/conf/etc/nginx/vhost.conf @@ -1,17 +1,11 @@ server { - listen 80 default_server; - listen 8000 default_server; + listen 80 default_server; server_name _ docker; - access_log /docker.stdout; - error_log /docker.stdout info; - root ""; index ; - client_max_body_size 50m; - include /opt/docker/etc/nginx/vhost.common.d/*.conf; } @@ -20,19 +14,13 @@ server { ############## server { - listen 443 default_server; - listen 8443 default_server; + listen 443 default_server; server_name _ docker; - access_log /docker.stdout; - error_log /docker.stdout info; - root ""; index ; - client_max_body_size 50m; - include /opt/docker/etc/nginx/vhost.common.d/*.conf; include /opt/docker/etc/nginx/vhost.ssl.conf; } diff --git a/docker/php-nginx/ubuntu-15.10/Dockerfile b/docker/php-nginx/ubuntu-15.10/Dockerfile index 17e4b66ab..1e635689f 100644 --- a/docker/php-nginx/ubuntu-15.10/Dockerfile +++ b/docker/php-nginx/ubuntu-15.10/Dockerfile @@ -5,15 +5,10 @@ FROM webdevops/php:ubuntu-15.10 -MAINTAINER info@webdevops.io -LABEL vendor=WebDevOps.io -LABEL io.webdevops.layout=8 -LABEL io.webdevops.version=1.5.0 - -ENV WEB_DOCUMENT_ROOT /app -ENV WEB_DOCUMENT_INDEX index.php -ENV WEB_ALIAS_DOMAIN *.vm -ENV WEB_PHP_SOCKET 127.0.0.1:9000 +ENV WEB_DOCUMENT_ROOT=/app \ + WEB_DOCUMENT_INDEX=index.php \ + WEB_ALIAS_DOMAIN=*.vm +ENV WEB_PHP_SOCKET=127.0.0.1:9000 COPY conf/ /opt/docker/ @@ -21,7 +16,7 @@ COPY conf/ /opt/docker/ RUN /usr/local/bin/apt-install \ nginx \ && /opt/docker/bin/provision run --tag bootstrap --role webdevops-nginx --role webdevops-php-nginx \ - && /opt/docker/bin/bootstrap.sh - + && /opt/docker/bin/bootstrap.sh \ + && docker-image-cleanup EXPOSE 80 443 diff --git a/docker/php-nginx/ubuntu-15.10/Dockerfile.jinja2 b/docker/php-nginx/ubuntu-15.10/Dockerfile.jinja2 index 085cbd88a..54185e764 100644 --- a/docker/php-nginx/ubuntu-15.10/Dockerfile.jinja2 +++ b/docker/php-nginx/ubuntu-15.10/Dockerfile.jinja2 @@ -1,7 +1,5 @@ {{ docker.from("php", "ubuntu-15.10") }} -{{ docker.version() }} - {{ environment.web() }} {{ environment.webPhp() }} diff --git a/docker/php-nginx/ubuntu-15.10/conf/bin/service.d/nginx.d/10-init.sh b/docker/php-nginx/ubuntu-15.10/conf/bin/service.d/nginx.d/10-init.sh index 75a84a4eb..27b9776cc 100644 --- a/docker/php-nginx/ubuntu-15.10/conf/bin/service.d/nginx.d/10-init.sh +++ b/docker/php-nginx/ubuntu-15.10/conf/bin/service.d/nginx.d/10-init.sh @@ -8,15 +8,17 @@ fi ln -f -s /var/lib/nginx/logs /var/log/nginx # Replace markers -find /opt/docker/etc/nginx/ -iname '*.conf' -print0 | xargs -0 -r rpl --quiet "" "$WEB_DOCUMENT_INDEX" > /dev/null -find /opt/docker/etc/nginx/ -iname '*.conf' -print0 | xargs -0 -r rpl --quiet "" "$WEB_DOCUMENT_ROOT" > /dev/null -find /opt/docker/etc/nginx/ -iname '*.conf' -print0 | xargs -0 -r rpl --quiet "" "$WEB_ALIAS_DOMAIN" > /dev/null -find /opt/docker/etc/nginx/ -iname '*.conf' -print0 | xargs -0 -r rpl --quiet "" "$HOSTNAME" > /dev/null +go-replace \ + -s "" -r "$WEB_DOCUMENT_INDEX" \ + -s "" -r "$WEB_DOCUMENT_ROOT" \ + -s "" -r "$WEB_ALIAS_DOMAIN" \ + -s "" -r "$HOSTNAME" \ + -s "" -r "$WEB_PHP_SOCKET" \ + --path=/opt/docker/etc/nginx/ \ + --path-pattern='*.conf' \ + --ignore-empty -if [[ -n "${WEB_PHP_SOCKET+x}" ]]; then - ## WEB_PHP_SOCKET is set - find /opt/docker/etc/nginx/ -iname '*.conf' -print0 | xargs -0 -r rpl --quiet "" "$WEB_PHP_SOCKET" > /dev/null -else +if [[ -z "${WEB_PHP_SOCKET+x}" ]]; then ## WEB_PHP_SOCKET is not set, remove PHP files rm -f -- /opt/docker/etc/nginx/conf.d/10-php.conf rm -f -- /opt/docker/etc/nginx/vhost.common.d/10-php.conf diff --git a/docker/php-nginx/ubuntu-15.10/conf/etc/nginx/vhost.common.d/10-general.conf b/docker/php-nginx/ubuntu-15.10/conf/etc/nginx/vhost.common.d/10-general.conf new file mode 100644 index 000000000..d3fd0aa5e --- /dev/null +++ b/docker/php-nginx/ubuntu-15.10/conf/etc/nginx/vhost.common.d/10-general.conf @@ -0,0 +1 @@ +client_max_body_size 50m; diff --git a/docker/php-nginx/ubuntu-15.10/conf/etc/nginx/vhost.common.d/10-log.conf b/docker/php-nginx/ubuntu-15.10/conf/etc/nginx/vhost.common.d/10-log.conf new file mode 100644 index 000000000..9646c6826 --- /dev/null +++ b/docker/php-nginx/ubuntu-15.10/conf/etc/nginx/vhost.common.d/10-log.conf @@ -0,0 +1,2 @@ +access_log /docker.stdout; +error_log /docker.stderr warn; diff --git a/docker/php-nginx/ubuntu-15.10/conf/etc/nginx/vhost.conf b/docker/php-nginx/ubuntu-15.10/conf/etc/nginx/vhost.conf index d07e27094..8225f314a 100644 --- a/docker/php-nginx/ubuntu-15.10/conf/etc/nginx/vhost.conf +++ b/docker/php-nginx/ubuntu-15.10/conf/etc/nginx/vhost.conf @@ -1,17 +1,11 @@ server { - listen 80 default_server; - listen 8000 default_server; + listen 80 default_server; server_name _ docker; - access_log /docker.stdout; - error_log /docker.stdout info; - root ""; index ; - client_max_body_size 50m; - include /opt/docker/etc/nginx/vhost.common.d/*.conf; } @@ -20,19 +14,13 @@ server { ############## server { - listen 443 default_server; - listen 8443 default_server; + listen 443 default_server; server_name _ docker; - access_log /docker.stdout; - error_log /docker.stdout info; - root ""; index ; - client_max_body_size 50m; - include /opt/docker/etc/nginx/vhost.common.d/*.conf; include /opt/docker/etc/nginx/vhost.ssl.conf; } diff --git a/docker/php-nginx/ubuntu-16.04/Dockerfile b/docker/php-nginx/ubuntu-16.04/Dockerfile index bd1934b68..e059823fe 100644 --- a/docker/php-nginx/ubuntu-16.04/Dockerfile +++ b/docker/php-nginx/ubuntu-16.04/Dockerfile @@ -5,15 +5,10 @@ FROM webdevops/php:ubuntu-16.04 -MAINTAINER info@webdevops.io -LABEL vendor=WebDevOps.io -LABEL io.webdevops.layout=8 -LABEL io.webdevops.version=1.5.0 - -ENV WEB_DOCUMENT_ROOT /app -ENV WEB_DOCUMENT_INDEX index.php -ENV WEB_ALIAS_DOMAIN *.vm -ENV WEB_PHP_SOCKET 127.0.0.1:9000 +ENV WEB_DOCUMENT_ROOT=/app \ + WEB_DOCUMENT_INDEX=index.php \ + WEB_ALIAS_DOMAIN=*.vm +ENV WEB_PHP_SOCKET=127.0.0.1:9000 COPY conf/ /opt/docker/ @@ -21,7 +16,7 @@ COPY conf/ /opt/docker/ RUN /usr/local/bin/apt-install \ nginx \ && /opt/docker/bin/provision run --tag bootstrap --role webdevops-nginx --role webdevops-php-nginx \ - && /opt/docker/bin/bootstrap.sh - + && /opt/docker/bin/bootstrap.sh \ + && docker-image-cleanup EXPOSE 80 443 diff --git a/docker/php-nginx/ubuntu-16.04/Dockerfile.jinja2 b/docker/php-nginx/ubuntu-16.04/Dockerfile.jinja2 index 54e26bbee..14e9706f8 100644 --- a/docker/php-nginx/ubuntu-16.04/Dockerfile.jinja2 +++ b/docker/php-nginx/ubuntu-16.04/Dockerfile.jinja2 @@ -1,7 +1,5 @@ {{ docker.from("php", "ubuntu-16.04") }} -{{ docker.version() }} - {{ environment.web() }} {{ environment.webPhp() }} diff --git a/docker/php-nginx/ubuntu-16.04/conf/bin/service.d/nginx.d/10-init.sh b/docker/php-nginx/ubuntu-16.04/conf/bin/service.d/nginx.d/10-init.sh index 75a84a4eb..27b9776cc 100644 --- a/docker/php-nginx/ubuntu-16.04/conf/bin/service.d/nginx.d/10-init.sh +++ b/docker/php-nginx/ubuntu-16.04/conf/bin/service.d/nginx.d/10-init.sh @@ -8,15 +8,17 @@ fi ln -f -s /var/lib/nginx/logs /var/log/nginx # Replace markers -find /opt/docker/etc/nginx/ -iname '*.conf' -print0 | xargs -0 -r rpl --quiet "" "$WEB_DOCUMENT_INDEX" > /dev/null -find /opt/docker/etc/nginx/ -iname '*.conf' -print0 | xargs -0 -r rpl --quiet "" "$WEB_DOCUMENT_ROOT" > /dev/null -find /opt/docker/etc/nginx/ -iname '*.conf' -print0 | xargs -0 -r rpl --quiet "" "$WEB_ALIAS_DOMAIN" > /dev/null -find /opt/docker/etc/nginx/ -iname '*.conf' -print0 | xargs -0 -r rpl --quiet "" "$HOSTNAME" > /dev/null +go-replace \ + -s "" -r "$WEB_DOCUMENT_INDEX" \ + -s "" -r "$WEB_DOCUMENT_ROOT" \ + -s "" -r "$WEB_ALIAS_DOMAIN" \ + -s "" -r "$HOSTNAME" \ + -s "" -r "$WEB_PHP_SOCKET" \ + --path=/opt/docker/etc/nginx/ \ + --path-pattern='*.conf' \ + --ignore-empty -if [[ -n "${WEB_PHP_SOCKET+x}" ]]; then - ## WEB_PHP_SOCKET is set - find /opt/docker/etc/nginx/ -iname '*.conf' -print0 | xargs -0 -r rpl --quiet "" "$WEB_PHP_SOCKET" > /dev/null -else +if [[ -z "${WEB_PHP_SOCKET+x}" ]]; then ## WEB_PHP_SOCKET is not set, remove PHP files rm -f -- /opt/docker/etc/nginx/conf.d/10-php.conf rm -f -- /opt/docker/etc/nginx/vhost.common.d/10-php.conf diff --git a/docker/php-nginx/ubuntu-16.04/conf/etc/nginx/vhost.common.d/10-general.conf b/docker/php-nginx/ubuntu-16.04/conf/etc/nginx/vhost.common.d/10-general.conf new file mode 100644 index 000000000..d3fd0aa5e --- /dev/null +++ b/docker/php-nginx/ubuntu-16.04/conf/etc/nginx/vhost.common.d/10-general.conf @@ -0,0 +1 @@ +client_max_body_size 50m; diff --git a/docker/php-nginx/ubuntu-16.04/conf/etc/nginx/vhost.common.d/10-log.conf b/docker/php-nginx/ubuntu-16.04/conf/etc/nginx/vhost.common.d/10-log.conf new file mode 100644 index 000000000..9646c6826 --- /dev/null +++ b/docker/php-nginx/ubuntu-16.04/conf/etc/nginx/vhost.common.d/10-log.conf @@ -0,0 +1,2 @@ +access_log /docker.stdout; +error_log /docker.stderr warn; diff --git a/docker/php-nginx/ubuntu-16.04/conf/etc/nginx/vhost.conf b/docker/php-nginx/ubuntu-16.04/conf/etc/nginx/vhost.conf index d07e27094..8225f314a 100644 --- a/docker/php-nginx/ubuntu-16.04/conf/etc/nginx/vhost.conf +++ b/docker/php-nginx/ubuntu-16.04/conf/etc/nginx/vhost.conf @@ -1,17 +1,11 @@ server { - listen 80 default_server; - listen 8000 default_server; + listen 80 default_server; server_name _ docker; - access_log /docker.stdout; - error_log /docker.stdout info; - root ""; index ; - client_max_body_size 50m; - include /opt/docker/etc/nginx/vhost.common.d/*.conf; } @@ -20,19 +14,13 @@ server { ############## server { - listen 443 default_server; - listen 8443 default_server; + listen 443 default_server; server_name _ docker; - access_log /docker.stdout; - error_log /docker.stdout info; - root ""; index ; - client_max_body_size 50m; - include /opt/docker/etc/nginx/vhost.common.d/*.conf; include /opt/docker/etc/nginx/vhost.ssl.conf; } diff --git a/docker/php-nginx/ubuntu-16.10/Dockerfile b/docker/php-nginx/ubuntu-16.10/Dockerfile index f10b080db..22051484d 100644 --- a/docker/php-nginx/ubuntu-16.10/Dockerfile +++ b/docker/php-nginx/ubuntu-16.10/Dockerfile @@ -5,15 +5,10 @@ FROM webdevops/php:ubuntu-16.10 -MAINTAINER info@webdevops.io -LABEL vendor=WebDevOps.io -LABEL io.webdevops.layout=8 -LABEL io.webdevops.version=1.5.0 - -ENV WEB_DOCUMENT_ROOT /app -ENV WEB_DOCUMENT_INDEX index.php -ENV WEB_ALIAS_DOMAIN *.vm -ENV WEB_PHP_SOCKET 127.0.0.1:9000 +ENV WEB_DOCUMENT_ROOT=/app \ + WEB_DOCUMENT_INDEX=index.php \ + WEB_ALIAS_DOMAIN=*.vm +ENV WEB_PHP_SOCKET=127.0.0.1:9000 COPY conf/ /opt/docker/ @@ -21,7 +16,7 @@ COPY conf/ /opt/docker/ RUN /usr/local/bin/apt-install \ nginx \ && /opt/docker/bin/provision run --tag bootstrap --role webdevops-nginx --role webdevops-php-nginx \ - && /opt/docker/bin/bootstrap.sh - + && /opt/docker/bin/bootstrap.sh \ + && docker-image-cleanup EXPOSE 80 443 diff --git a/docker/php-nginx/ubuntu-16.10/Dockerfile.jinja2 b/docker/php-nginx/ubuntu-16.10/Dockerfile.jinja2 index a62d1fdcb..0260eda54 100644 --- a/docker/php-nginx/ubuntu-16.10/Dockerfile.jinja2 +++ b/docker/php-nginx/ubuntu-16.10/Dockerfile.jinja2 @@ -1,7 +1,5 @@ {{ docker.from("php", "ubuntu-16.10") }} -{{ docker.version() }} - {{ environment.web() }} {{ environment.webPhp() }} diff --git a/docker/php-nginx/ubuntu-16.10/conf/bin/service.d/nginx.d/10-init.sh b/docker/php-nginx/ubuntu-16.10/conf/bin/service.d/nginx.d/10-init.sh index 75a84a4eb..27b9776cc 100644 --- a/docker/php-nginx/ubuntu-16.10/conf/bin/service.d/nginx.d/10-init.sh +++ b/docker/php-nginx/ubuntu-16.10/conf/bin/service.d/nginx.d/10-init.sh @@ -8,15 +8,17 @@ fi ln -f -s /var/lib/nginx/logs /var/log/nginx # Replace markers -find /opt/docker/etc/nginx/ -iname '*.conf' -print0 | xargs -0 -r rpl --quiet "" "$WEB_DOCUMENT_INDEX" > /dev/null -find /opt/docker/etc/nginx/ -iname '*.conf' -print0 | xargs -0 -r rpl --quiet "" "$WEB_DOCUMENT_ROOT" > /dev/null -find /opt/docker/etc/nginx/ -iname '*.conf' -print0 | xargs -0 -r rpl --quiet "" "$WEB_ALIAS_DOMAIN" > /dev/null -find /opt/docker/etc/nginx/ -iname '*.conf' -print0 | xargs -0 -r rpl --quiet "" "$HOSTNAME" > /dev/null +go-replace \ + -s "" -r "$WEB_DOCUMENT_INDEX" \ + -s "" -r "$WEB_DOCUMENT_ROOT" \ + -s "" -r "$WEB_ALIAS_DOMAIN" \ + -s "" -r "$HOSTNAME" \ + -s "" -r "$WEB_PHP_SOCKET" \ + --path=/opt/docker/etc/nginx/ \ + --path-pattern='*.conf' \ + --ignore-empty -if [[ -n "${WEB_PHP_SOCKET+x}" ]]; then - ## WEB_PHP_SOCKET is set - find /opt/docker/etc/nginx/ -iname '*.conf' -print0 | xargs -0 -r rpl --quiet "" "$WEB_PHP_SOCKET" > /dev/null -else +if [[ -z "${WEB_PHP_SOCKET+x}" ]]; then ## WEB_PHP_SOCKET is not set, remove PHP files rm -f -- /opt/docker/etc/nginx/conf.d/10-php.conf rm -f -- /opt/docker/etc/nginx/vhost.common.d/10-php.conf diff --git a/docker/php-nginx/ubuntu-16.10/conf/etc/nginx/vhost.common.d/10-general.conf b/docker/php-nginx/ubuntu-16.10/conf/etc/nginx/vhost.common.d/10-general.conf new file mode 100644 index 000000000..d3fd0aa5e --- /dev/null +++ b/docker/php-nginx/ubuntu-16.10/conf/etc/nginx/vhost.common.d/10-general.conf @@ -0,0 +1 @@ +client_max_body_size 50m; diff --git a/docker/php-nginx/ubuntu-16.10/conf/etc/nginx/vhost.common.d/10-log.conf b/docker/php-nginx/ubuntu-16.10/conf/etc/nginx/vhost.common.d/10-log.conf new file mode 100644 index 000000000..9646c6826 --- /dev/null +++ b/docker/php-nginx/ubuntu-16.10/conf/etc/nginx/vhost.common.d/10-log.conf @@ -0,0 +1,2 @@ +access_log /docker.stdout; +error_log /docker.stderr warn; diff --git a/docker/php-nginx/ubuntu-16.10/conf/etc/nginx/vhost.conf b/docker/php-nginx/ubuntu-16.10/conf/etc/nginx/vhost.conf index d07e27094..8225f314a 100644 --- a/docker/php-nginx/ubuntu-16.10/conf/etc/nginx/vhost.conf +++ b/docker/php-nginx/ubuntu-16.10/conf/etc/nginx/vhost.conf @@ -1,17 +1,11 @@ server { - listen 80 default_server; - listen 8000 default_server; + listen 80 default_server; server_name _ docker; - access_log /docker.stdout; - error_log /docker.stdout info; - root ""; index ; - client_max_body_size 50m; - include /opt/docker/etc/nginx/vhost.common.d/*.conf; } @@ -20,19 +14,13 @@ server { ############## server { - listen 443 default_server; - listen 8443 default_server; + listen 443 default_server; server_name _ docker; - access_log /docker.stdout; - error_log /docker.stdout info; - root ""; index ; - client_max_body_size 50m; - include /opt/docker/etc/nginx/vhost.common.d/*.conf; include /opt/docker/etc/nginx/vhost.ssl.conf; } diff --git a/docker/php-official/5.6/Dockerfile b/docker/php-official/5.6/Dockerfile new file mode 100644 index 000000000..22afa0ef1 --- /dev/null +++ b/docker/php-official/5.6/Dockerfile @@ -0,0 +1,187 @@ +#+++++++++++++++++++++++++++++++++++++++ +# Dockerfile for webdevops/php-official:5.6 +# -- automatically generated -- +#+++++++++++++++++++++++++++++++++++++++ + +FROM php:5.6-fpm + +LABEL maintainer=info@webdevops.io \ + vendor=WebDevOps.io \ + io.webdevops.layout=8 \ + io.webdevops.version=1.5.0 + +ENV TERM="xterm" \ + LANG="C.UTF-8" \ + LC_ALL="C.UTF-8" +ENV DOCKER_CONF_HOME=/opt/docker/ \ + LOG_STDOUT="" \ + LOG_STDERR="" +ENV APPLICATION_USER=application \ + APPLICATION_GROUP=application \ + APPLICATION_PATH=/app \ + APPLICATION_UID=1000 \ + APPLICATION_GID=1000 + +ADD baselayout.tar / + +COPY conf/ /opt/docker/ + +# Init bootstrap +RUN set -x \ + && apt-update \ + && /usr/local/bin/generate-dockerimage-info \ + # Enable non-free + && sed -ri "s/(deb.*\/debian $(docker-image-info dist-codename) main)/\1 contrib non-free /" -- /etc/apt/sources.list \ + && apt-update \ + # System update + && /usr/local/bin/apt-upgrade \ + # Base stuff + && /usr/local/bin/apt-install \ + apt-transport-https \ + ca-certificates \ + locales \ + # Install gosu + && GOSU_VERSION=1.10 \ + && /usr/local/bin/apt-install wget gnupg dirmngr \ + && dpkgArch="amd64" \ + && wget -O /usr/local/bin/gosu "https://github.com/tianon/gosu/releases/download/$GOSU_VERSION/gosu-$dpkgArch" \ + && wget -O /usr/local/bin/gosu.asc "https://github.com/tianon/gosu/releases/download/$GOSU_VERSION/gosu-$dpkgArch.asc" \ + && export GNUPGHOME="$(mktemp -d)" \ + && gpg --keyserver ha.pool.sks-keyservers.net --recv-keys B42F6819007F00F88E364FD4036A9C25BF357DD4 \ + && gpg --batch --verify /usr/local/bin/gosu.asc /usr/local/bin/gosu \ + && rm -rf "$GNUPGHOME" /usr/local/bin/gosu.asc \ + && chmod +x /usr/local/bin/gosu \ + && gosu nobody true \ + ## Install go-replace + && GOREPLACE_VERSION=0.5.4 \ + && wget -O /usr/local/bin/go-replace https://github.com/webdevops/goreplace/releases/download/$GOREPLACE_VERSION/gr-64-linux \ + && chmod +x /usr/local/bin/go-replace \ + && apt-get purge -y -f --force-yes wget dirmngr \ + && docker-image-cleanup + +# Install ansible +RUN /usr/local/bin/apt-install \ + # Install ansible + python-minimal \ + python-setuptools \ + python-pip \ + python-paramiko \ + python-jinja2 \ + python-dev \ + libffi-dev \ + libssl-dev \ + build-essential \ + && pip install --upgrade pip \ + && hash -r \ + && pip install --no-cache-dir ansible \ + && chmod 750 /usr/local/bin/ansible* \ + # Cleanup + && apt-get purge -y -f --force-yes \ + python-dev \ + build-essential \ + libssl-dev \ + libffi-dev \ + && docker-image-cleanup + +# Install packages +RUN chmod +x /opt/docker/bin/* \ + && /usr/local/bin/apt-install \ + supervisor \ + wget \ + curl \ + net-tools \ + gnupg \ + && chmod +s /usr/local/bin/gosu \ + && /opt/docker/bin/provision run --tag bootstrap --role webdevops-base \ + && /opt/docker/bin/bootstrap.sh \ + && docker-image-cleanup + +# Install services +RUN /usr/local/bin/apt-install \ + # Install common tools + zip \ + unzip \ + bzip2 \ + wget \ + curl \ + net-tools \ + moreutils \ + dnsutils \ + openssh-client \ + rsync \ + git \ + && /usr/local/bin/generate-locales \ + && /opt/docker/bin/provision run --tag bootstrap --role webdevops-base-app \ + && /opt/docker/bin/bootstrap.sh \ + && docker-image-cleanup + +# Install php environment +RUN /usr/local/bin/apt-install \ + # Install tools + imagemagick \ + graphicsmagick \ + ghostscript \ + # Libraries + libldap-2.4-2 \ + libxslt1.1 \ + zlib1g \ + libpng12-0 \ + libmcrypt4 \ + # Dev and headers + libbz2-dev \ + libldap2-dev \ + libldb-dev \ + libmcrypt-dev \ + libxml2-dev \ + libxslt1-dev \ + zlib1g-dev \ + libpng12-dev \ + # Install extensions + && docker-php-ext-install \ + bcmath \ + bz2 \ + calendar \ + exif \ + gettext \ + mysqli \ + mcrypt \ + hash \ + pcntl \ + pdo_mysql \ + soap \ + sockets \ + tokenizer \ + sysvmsg \ + sysvsem \ + sysvshm \ + shmop \ + xsl \ + zip \ + gd \ + gettext \ + opcache \ + # Uninstall dev and header packages + && apt-get purge -y -f --force-yes \ + libbz2-dev \ + libldap2-dev \ + libldb-dev \ + libmcrypt-dev \ + libxml2-dev \ + libxslt1-dev \ + zlib1g-dev \ + libpng12-dev \ + # Install extensions for PHP 5.x + && pecl install apcu-4.0.11 redis \ + && echo extension=apcu.so > /usr/local/etc/php/conf.d/apcu.ini \ + && echo extension=redis.so > /usr/local/etc/php/conf.d/redis.ini \ + && rm -f /usr/local/etc/php-fpm.d/zz-docker.conf \ + && curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin/ --filename=composer \ + && /opt/docker/bin/provision run --tag bootstrap --role webdevops-php \ + && /opt/docker/bin/bootstrap.sh \ + && docker-image-cleanup + +WORKDIR / + +EXPOSE 9000 +ENTRYPOINT ["/opt/docker/bin/entrypoint.sh"] +CMD ["supervisord"] diff --git a/docker/php-official/5.6/Dockerfile.jinja2 b/docker/php-official/5.6/Dockerfile.jinja2 new file mode 100644 index 000000000..5bd80a9d2 --- /dev/null +++ b/docker/php-official/5.6/Dockerfile.jinja2 @@ -0,0 +1,25 @@ +{{ docker.fromOfficial("php", "5.6-fpm") }} + +{{ docker.version() }} + +{{ environment.general() }} +{{ environment.base() }} +{{ environment.baseApp() }} + +{{ docker.add('baselayout.tar', '/') }} + +{{ docker.copy('conf/', '/opt/docker/') }} + +{{ bootstrap.debian('jessie') }} + +{{ ansible.debian() }} + +{{ base.debian() }} + +{{ baseapp.debian() }} + +{{ php.official(version='5.6') }} + +{{ docker.expose('9000') }} +{{ docker.entrypoint("/opt/docker/bin/entrypoint.sh") }} +{{ docker.cmd("supervisord") }} diff --git a/docker/php-official/5.6/baselayout.tar b/docker/php-official/5.6/baselayout.tar new file mode 100644 index 000000000..dc5fbe08f Binary files /dev/null and b/docker/php-official/5.6/baselayout.tar differ diff --git a/docker/php-official/5.6/conf/VERSION b/docker/php-official/5.6/conf/VERSION new file mode 100644 index 000000000..301160a93 --- /dev/null +++ b/docker/php-official/5.6/conf/VERSION @@ -0,0 +1 @@ +8 \ No newline at end of file diff --git a/docker/php-official/5.6/conf/bin/bootstrap.sh b/docker/php-official/5.6/conf/bin/bootstrap.sh new file mode 100644 index 000000000..855c10782 --- /dev/null +++ b/docker/php-official/5.6/conf/bin/bootstrap.sh @@ -0,0 +1,72 @@ +#!/usr/bin/env bash + +BOOTSTRAP_MODE="bootstrap" + +if [ -n "$1" ]; then + BOOTSTRAP_MODE="$1" +fi + +set -o pipefail # trace ERR through pipes +set -o errtrace # trace ERR through 'time command' and other functions +set -o nounset ## set -u : exit the script if you try to use an uninitialised variable +set -o errexit ## set -e : exit the script if any statement returns a non-true return value + +source /opt/docker/bin/config.sh + +rootCheck "$0" + +# Save the buildtime +date +%s > /opt/docker/BUILDTIME +date +%s >/opt/docker/etc/.registry/image_info_buildtime + +# Make all scripts executable +find /opt/docker/bin/ -type f -iname '*.sh' -print0 | xargs --no-run-if-empty -0 chmod +x + +# Enable usr-bin executables +find /opt/docker/bin/usr-bin -type f | while read USR_BIN_FILE; do + chmod +x -- "$USR_BIN_FILE" + ln -n -f -- "$USR_BIN_FILE" "/usr/local/bin/$(basename "$USR_BIN_FILE")" +done + +case "$BOOTSTRAP_MODE" in + ################################### + # When container will be build next time + ################################### + "onbuild") + # Init and run bootstrap system + runProvisionOnBuild + ;; + + ################################### + # When container is build this time + ################################### + "bootstrap") + # Init and run bootstrap system + runProvisionBootstrap + runProvisionBuild + ;; + + *) + echo "[ERROR] Bootstrap mode '$BOOTSTRAP_MODE' not defined" + exit 1 + ;; +esac + + +###################### +# Check if entrypoint provisioning is available +###################### + +echo "Checking provision status..." +for PROVISION_TAG in onbuild build bootstrap entrypoint; do + ROLES=$(docker-provision list --tag "$PROVISION_TAG") + if [[ -n "$ROLES" ]]; then + PROVISION_ROLE_COUNT=$(echo "$ROLES" | wc -l) + echo " - found ${PROVISION_ROLE_COUNT} for provision tag ${PROVISION_TAG}, caching info for execution" + echo -n "$PROVISION_ROLE_COUNT" > "/opt/docker/etc/.registry/provision-availale.${PROVISION_TAG}" + else + echo " - no roles found for provision tag ${PROVISION_TAG}" + echo -n '' > "/opt/docker/etc/.registry/provision-availale.${PROVISION_TAG}" + fi +done + diff --git a/docker/php-official/5.6/conf/bin/config.sh b/docker/php-official/5.6/conf/bin/config.sh new file mode 100644 index 000000000..049756c26 --- /dev/null +++ b/docker/php-official/5.6/conf/bin/config.sh @@ -0,0 +1,151 @@ +#!/usr/bin/env bash + +shopt -s nullglob + +### + # Check if current user is root + # + ## +function rootCheck() { + # Root check + if [ "$(/usr/bin/whoami)" != "root" ]; then + echo "[ERROR] $* must be run as root" + exit 1 + fi +} + +### + # Create /docker.stdout and /docker.stderr + # + ## +function createDockerStdoutStderr() { + # link stdout from docker + if [[ -z "$LOG_STDOUT" ]]; then + LOG_STDOUT="/proc/$$/fd/1" + fi + + if [[ -z "$LOG_STDERR" ]]; then + LOG_STDERR="/proc/$$/fd/2" + fi + + ln -f -s "$LOG_STDOUT" /docker.stdout + ln -f -s "$LOG_STDERR" /docker.stderr + chmod 600 /docker.stdout /docker.stderr +} +### + # Include script directory text inside a file + # + # $1 -> path + # + ## +function includeScriptDir() { + if [[ -d "$1" ]]; then + for FILE in "$1"/*.sh; do + # run custom scripts, only once + . "$FILE" + done + fi +} + +### + # Show deprecation notice + # + ## +function deprecationNotice() { + echo "" + echo "###############################################################################" + echo "### THIS CALL IS DEPRECATED AND WILL BE REMOVED IN THE FUTURE" + echo "###" + echo "### $*" + echo "###" + echo "###############################################################################" + echo "" +} + +### + # Run "entrypoint" scripts + ## +function runEntrypoints() { + ############### + # Try to find entrypoint + ############### + + ENTRYPOINT_SCRIPT="/opt/docker/bin/entrypoint.d/${TASK}.sh" + + if [ -f "$ENTRYPOINT_SCRIPT" ]; then + . "$ENTRYPOINT_SCRIPT" + fi + + ############### + # Run default + ############### + if [ -f "/opt/docker/bin/entrypoint.d/default.sh" ]; then + . /opt/docker/bin/entrypoint.d/default.sh + fi + + exit 1 +} + +### + # Run "bootstrap" provisioning + ## +function runProvisionBootstrap() { + for FILE in /opt/docker/provision/bootstrap.d/*.sh; do + # run custom scripts, only once + . "$FILE" + rm -f -- "$FILE" + done + + runDockerProvision bootstrap +} + +### + # Run "build" provisioning + ## +function runProvisionBuild() { + for FILE in /opt/docker/provision/build.d/*.sh; do + # run custom scripts, only once + . "$FILE" + done + + runDockerProvision build +} + +### + # Run "onbuild" provisioning + ## +function runProvisionOnBuild() { + includeScriptDir "/opt/docker/provision/onbuild.d" + + runDockerProvision onbuild +} + +### + # Run "entrypoint" provisioning + ## +function runProvisionEntrypoint() { + includeScriptDir "/opt/docker/provision/entrypoint.d" + includeScriptDir "/entrypoint.d" + + runDockerProvision entrypoint +} + + +### + # Run docker provisioning with dyniamic playbook generation + # + # $1 -> playbook tag (bootstrap, onbuild, entrypoint) + # + ## +function runDockerProvision() { + ANSIBLE_TAG="$1" + + PROVISION_STATS_FILE="/opt/docker/etc/.registry/provision-stats.${ANSIBLE_TAG}" + + # run provision if stats file doesn't exists (unknown mode) + # or if stats file is not empty + if [[ ! -f "$PROVISION_STATS_FILE" ]] || [[ -s "$PROVISION_STATS_FILE" ]]; then + /opt/docker/bin/provision run --tag "${ANSIBLE_TAG}" --use-registry + fi +} + diff --git a/docker/php-official/5.6/conf/bin/control.sh b/docker/php-official/5.6/conf/bin/control.sh new file mode 100644 index 000000000..22d189745 --- /dev/null +++ b/docker/php-official/5.6/conf/bin/control.sh @@ -0,0 +1,160 @@ +#!/usr/bin/env bash + +set -o pipefail # trace ERR through pipes +set -o errtrace # trace ERR through 'time command' and other functions +set -o nounset ## set -u : exit the script if you try to use an uninitialised variable +set -o errexit ## set -e : exit the script if any statement returns a non-true return value + +source /opt/docker/bin/config.sh + +rootCheck "$0" + +CONTROL_COMMAND="$1" +shift + +case "$CONTROL_COMMAND" in + + ## ------------------------------------------ + ## PROVISION + ## ------------------------------------------ + + ## main roles + "provision.role") + deprecationNotice " Please use >>/opt/docker/bin/provision add --tag bootstrap --tag build --tag onbuild [role]<< for adding provision roles" + /opt/docker/bin/provision add --tag bootstrap --tag build --tag onbuild --tag entrypoint "$1" + ;; + + "provision.role.bootstrap") + deprecationNotice " Please use >>/opt/docker/bin/provision add --tag bootstrap [role]<< for adding provision roles" + /opt/docker/bin/provision add --tag bootstrap "$1" + ;; + + "provision.role.build") + deprecationNotice " Please use >>/opt/docker/bin/provision add --tag build [role]<< for adding provision roles" + /opt/docker/bin/provision add --tag build "$1" + ;; + + "provision.role.onbuild") + deprecationNotice " Please use >>/opt/docker/bin/provision add --tag onbuild [role]<< for adding provision roles" + /opt/docker/bin/provision add --tag onbuild "$1" + ;; + + "provision.role.entrypoint") + deprecationNotice " Please use >>/opt/docker/bin/provision add --tag entrypoint [role]<< for adding provision roles" + /opt/docker/bin/provision add --tag entrypoint "$1" + ;; + + ## startup roles + "provision.role.startup") + deprecationNotice " Please use >>/opt/docker/bin/provision add --tag bootstrap --tag build --tag onbuild --priority 50 [role]<< for adding provision roles" + /opt/docker/bin/provision add --tag bootstrap --tag build --tag onbuild --tag entrypoint --priority 50 "$1" + ;; + + "provision.role.startup.bootstrap") + deprecationNotice " Please use >>/opt/docker/bin/provision add --tag bootstrap --priority 50 [role]<< for adding provision roles" + /opt/docker/bin/provision add --tag bootstrap --priority 50 "$1" + ;; + + "provision.role.startup.build") + deprecationNotice " Please use >>/opt/docker/bin/provision add --tag build --priority 50 [role]<< for adding provision roles" + /opt/docker/bin/provision add --tag build --priority 50 "$1" + ;; + + "provision.role.startup.onbuild") + deprecationNotice " Please use >>/opt/docker/bin/provision add --tag onbuild --priority 50 [role]<< for adding provision roles" + /opt/docker/bin/provision add --tag onbuild --priority 50 "$1" + ;; + + "provision.role.startup.entrypoint") + deprecationNotice " Please use >>/opt/docker/bin/provision add --tag entrypoint --priority 50 [role]<< for adding provision roles" + /opt/docker/bin/provision add --tag entrypoint --priority 50 "$1" + ;; + + ## finish roles + "provision.role.finish") + deprecationNotice " Please use >>/opt/docker/bin/provision add --tag bootstrap --tag build --tag onbuild --priority 200 [role]<< for adding provision roles" + /opt/docker/bin/provision add --tag bootstrap --tag build --tag onbuild --tag entrypoint --priority 200 "$1" + ;; + + "provision.role.finish.bootstrap") + deprecationNotice " Please use >>/opt/docker/bin/provision add --tag bootstrap --priority 200 [role]<< for adding provision roles" + /opt/docker/bin/provision add --tag bootstrap --priority 200 "$1" + ;; + + "provision.role.finish.build") + deprecationNotice " Please use >>/opt/docker/bin/provision add --tag build --priority 200 [role]<< for adding provision roles" + /opt/docker/bin/provision add --tag build --priority 200 "$1" + ;; + + "provision.role.finish.onbuild") + deprecationNotice " Please use >>/opt/docker/bin/provision add --tag onbuild --priority 200 [role]<< for adding provision roles" + /opt/docker/bin/provision add --tag onbuild --priority 200 "$1" + ;; + + "provision.role.finish.entrypoint") + deprecationNotice " Please use >>/opt/docker/bin/provision add --tag entrypoint --priority 200 [role]<< for adding provision roles" + /opt/docker/bin/provision add --tag entrypoint --priority 200 "$1" + ;; + + ## ------------------------------------------ + ## Service + ## ------------------------------------------ + + "service.enable") + deprecationNotice " Please use >>docker-service-enable [service]<<" + docker-service-enable "$1" + ;; + + "service.disable") + deprecationNotice " Please use >>docker-service-disable [service]<<" + docker-service-disable "$1" + ;; + + ## ------------------------------------------ + ## Version + ## ------------------------------------------ + + "version.get") + cat /opt/docker/VERSION + ;; + + "version.require.min") + EXPECTED_VERSION="$1" + CURRENT_VERSION="$(cat /opt/docker/VERSION)" + if [ "$CURRENT_VERSION" -lt "$EXPECTED_VERSION" ]; then + echo "-----------------------------------------------------------" + echo "--- This docker image is not up2date!" + echo "--- " + echo "--- Version expected min: $EXPECTED_VERSION" + echo "--- Version current: $CURRENT_VERSION" + echo "--- " + echo "--- Run 'docker pull ' to update image" + echo "-----------------------------------------------------------" + exit 1 + fi + ;; + + "version.require.max") + EXPECTED_VERSION="$1" + CURRENT_VERSION="$(cat /opt/docker/VERSION)" + if [ "$CURRENT_VERSION" -gt "$EXPECTED_VERSION" ]; then + echo "-----------------------------------------------------------" + echo "--- This docker image is too new!" + echo "--- " + echo "--- Version expected max: $EXPECTED_VERSION" + echo "--- Version current: $CURRENT_VERSION" + echo "-----------------------------------------------------------" + exit 1 + fi + ;; + + + "buildtime.get") + cat /opt/docker/BUILDTIME + ;; + + *) + echo "[ERROR] Invalid controll command: \"${CONTROL_COMMAND}\"" + exit 1 + ;; +esac diff --git a/docker/php-official/5.6/conf/bin/entrypoint.d/cli.sh b/docker/php-official/5.6/conf/bin/entrypoint.d/cli.sh new file mode 100644 index 000000000..fe212a8ea --- /dev/null +++ b/docker/php-official/5.6/conf/bin/entrypoint.d/cli.sh @@ -0,0 +1,19 @@ +#!/usr/bin/env bash + +############################################# +## Run CLI_SCRIPT from environment variable +############################################# + +if [ -n "${CLI_SCRIPT}" ]; then + if [ -n "$APPLICATION_USER" ]; then + # Run as EFFECTIVE_USER + shift + exec gosu "${APPLICATION_USER}" ${CLI_SCRIPT} "$@" + else + # Run as root + exec ${CLI_SCRIPT} "$@" + fi +else + echo "[ERROR] No CLI_SCRIPT in in docker environment defined" + exit 1 +fi diff --git a/docker/php-official/5.6/conf/bin/entrypoint.d/default.sh b/docker/php-official/5.6/conf/bin/entrypoint.d/default.sh new file mode 100644 index 000000000..a1be715fe --- /dev/null +++ b/docker/php-official/5.6/conf/bin/entrypoint.d/default.sh @@ -0,0 +1,3 @@ +#!/usr/bin/env bash + +exec "$@" diff --git a/docker/php-official/5.6/conf/bin/entrypoint.d/noop.sh b/docker/php-official/5.6/conf/bin/entrypoint.d/noop.sh new file mode 100644 index 000000000..092d55d8b --- /dev/null +++ b/docker/php-official/5.6/conf/bin/entrypoint.d/noop.sh @@ -0,0 +1,7 @@ +#!/usr/bin/env bash + +############################################# +## NOOP (no operation) +############################################# + +exec tail -f /dev/null diff --git a/docker/php-official/5.6/conf/bin/entrypoint.d/root.sh b/docker/php-official/5.6/conf/bin/entrypoint.d/root.sh new file mode 100644 index 000000000..6fa0d063e --- /dev/null +++ b/docker/php-official/5.6/conf/bin/entrypoint.d/root.sh @@ -0,0 +1,14 @@ +#!/usr/bin/env bash + +############################################# +## Root shell +############################################# + +if [ "$#" -eq 1 ]; then + ## No command, fall back to interactive shell + exec bash +else + ## Exec root command + shift + exec "$@" +fi diff --git a/docker/php-official/5.6/conf/bin/entrypoint.d/supervisord.sh b/docker/php-official/5.6/conf/bin/entrypoint.d/supervisord.sh new file mode 100644 index 000000000..f21489667 --- /dev/null +++ b/docker/php-official/5.6/conf/bin/entrypoint.d/supervisord.sh @@ -0,0 +1,9 @@ +#!/usr/bin/env bash + +############################################# +## Supervisord (start daemons) +############################################# + +## Start services +exec /opt/docker/bin/service.d/supervisor.sh + diff --git a/docker/php-official/5.6/conf/bin/entrypoint.sh b/docker/php-official/5.6/conf/bin/entrypoint.sh new file mode 100644 index 000000000..01f59660c --- /dev/null +++ b/docker/php-official/5.6/conf/bin/entrypoint.sh @@ -0,0 +1,46 @@ +#!/usr/bin/env bash + +if [[ -z "$CONTAINER_UID" ]]; then + export CONTAINER_UID="application" +fi + +set -o pipefail # trace ERR through pipes +set -o errtrace # trace ERR through 'time command' and other functions +set -o nounset ## set -u : exit the script if you try to use an uninitialised variable +set -o errexit ## set -e : exit the script if any statement returns a non-true return value + +# auto elevate privileges (if container is not started as root) +if [[ "$UID" -ne 0 ]]; then + export CONTAINER_UID="$UID" + exec gosu root "$0" "$@" +fi +# remove suid bit on gosu +chmod -s /usr/local/bin/gosu + +trap 'echo sigterm ; exit' SIGTERM +trap 'echo sigkill ; exit' SIGKILL + +# sanitize input and set task +TASK="$(echo $1| sed 's/[^-_a-zA-Z0-9]*//g')" + +source /opt/docker/bin/config.sh + +createDockerStdoutStderr + +if [[ "$UID" -eq 0 ]]; then + # Only run provision if user is root + + if [ "$TASK" == "supervisord" -o "$TASK" == "noop" ]; then + # Visible provisioning + runProvisionEntrypoint + else + # Hidden provisioning + runProvisionEntrypoint > /dev/null + fi +fi + +############################# +## COMMAND +############################# + +runEntrypoints "$@" diff --git a/docker/php-official/5.6/conf/bin/provision b/docker/php-official/5.6/conf/bin/provision new file mode 100755 index 000000000..d367c2812 --- /dev/null +++ b/docker/php-official/5.6/conf/bin/provision @@ -0,0 +1,328 @@ +#!/usr/bin/env python + +import os +import argparse +import json +import sys +from string import Template +from subprocess import call +import tempfile +import time + +STORAGE = '/opt/docker/etc/.registry/provision.json' +PROVISION_DIR = '/opt/docker/provision/' + +PLAYBOOK_TAGS=['bootstrap', 'build', 'onbuild', 'entrypoint'] + +PLAYBOOK = Template( +"""--- + +- hosts: all + vars_files: + - ./variables-webdevops.yml + - ./variables.yml + roles: + - $roles +""") + + + +def readJson(): + ret = {} + + # create registry directory if it doesn't exists + if not os.path.exists(os.path.dirname(STORAGE)): + os.mkdir(os.path.dirname(STORAGE)) + + # try to read file + if os.path.isfile(STORAGE): + f=open(STORAGE).read() + ret = json.loads(f) + + return ret + + + +def saveJson(data): + with open(STORAGE, 'w') as f: + json.dump(data, f) + + + +def buildRoleList(tags): + json = readJson() + roleList = {} + + # fetch roles list for each tag + for tag in tags: + if tag in json: + for role in json[tag]: + roleRow = json[tag][role] + if role not in roleList: + roleList[role] = {} + + if 'tags' not in roleList[role]: + roleList[role]['tags'] = {} + + roleList[role]['role'] = role + roleList[role]['added'] = roleRow['added'] + roleList[role]['priority'] = roleRow['priority'] + roleList[role]['tags'][tag] = tag + + return roleList + + +def buildSortedRoleList(tags): + roleList = buildRoleList(tags) + + # sort list + roleList = sorted(roleList, key=lambda x: (roleList[x]['priority'], roleList[x]['added'])) + + return roleList + + + +def buildPlaybook(roleList): + ## build playbook + ret = PLAYBOOK.substitute( + roles = "\n - ".join(roleList) + ) + + return ret + + +def buildPlaybookFromArgs(args): + roleList = [] + + ## add roles from tag (if use registry is active) + if args.useRegistry and args.tags: + roleList.extend(buildSortedRoleList(args.tags)) + + ## add roles from command arguments + if args.roles: + for role in args.roles: + roleList.extend(role.split(',')) + + if roleList: + return buildPlaybook(roleList) + else: + return False + + + +def actionRun(args): + if args.playbook: + ## predefined playbook + playbook = args.playbook + else: + ## dynamic playbook + playbookContent = buildPlaybookFromArgs(args) + + if playbookContent: + f = tempfile.NamedTemporaryFile(dir=PROVISION_DIR, prefix='playbook.', suffix='.yml', delete=False) + f.write(playbookContent) + f.close() + playbook = f.name + else: + ## nothing to do + sys.exit(0) + + ## build ansible command with args + cmd = [ + 'ansible-playbook', + playbook, + '-i', 'localhost,', + '--connection=local', + ] + + if args.tags: + cmd.extend([ + '--tags=' + ','.join(args.tags) + ]) + + if args.args: + cmd.extend(args.args) + + ## run ansible + retval = call(cmd) + + ## cleanup dynamic playbook + if not args.playbook: + os.unlink(playbook) + + sys.exit(retval) + + + +def actionPlaybook(args): + playbook = buildPlaybookFromArgs(args) + + if playbook: + print playbook + else: + sys.exit(1) + + + +def actionList(args): + json = readJson() + list = {} + + for tag in args.tags: + if tag in json: + for role in json[tag]: + print role + + + +def actionAdd(args): + json = readJson() + + for tag in args.tags: + for role in args.role: + if tag not in json: + json[tag] = {} + + json[tag][role] = { + 'name': role, + 'added': int(time.time()), + 'priority': args.priority + } + + saveJson(json) + + + +def actionSummary(args): + # list all roles in each possible tag + for tag in PLAYBOOK_TAGS: + roleList = buildRoleList([tag]) + if roleList: + maxLength = len(max(roleList.keys(), key=len)) + + print "Roles in " + tag + ":" + for role in roleList: + print ' - ' + role.ljust(maxLength, ' ') + ' [priority: ' + str(roleList[role]['priority']) + ']' + print '' + + + +def main(args): + actions = { + 'list': actionList, + 'add': actionAdd, + 'summary': actionSummary, + 'playbook': actionPlaybook, + 'run': actionRun + } + + func = actions.get(args.action, lambda: "nothing") + return func(args) + + + + +if __name__ == '__main__': + parser = argparse.ArgumentParser() + subparsers = parser.add_subparsers( + title='subcommands', + dest='action' + ) + + ################################### + ## SUMMARY command + summary = subparsers.add_parser('summary') + + ################################### + ## RUN command + run = subparsers.add_parser('run') + run.add_argument( + '--tag', + dest='tags', + choices=PLAYBOOK_TAGS, + required=True, + action='append', + help='Ansible tag' + ) + run.add_argument( + '--playbook', + dest='playbook', + help='Ansible playbook' + ) + run.add_argument( + '--use-registry', + dest='useRegistry', + action='store_true', + help='Use registred roles' + ) + run.add_argument( + '--role', + dest='roles', + action='append', + help='Ansible role' + ) + run.add_argument('args', nargs=argparse.REMAINDER) + + ################################### + ## PLAYBOOK command + playbook = subparsers.add_parser('playbook') + playbook.add_argument( + '--tag', + dest='tags', + choices=PLAYBOOK_TAGS, + required=True, + action='append', + help='Ansible tag' + ) + playbook.add_argument( + '--use-registry', + dest='useRegistry', + action='store_true', + help='Use registred roles' + ) + playbook.add_argument( + '--role', + dest='roles', + action='append', + help='Ansible tag' + ) + playbook.add_argument('args', nargs=argparse.REMAINDER) + + ################################### + ## LIST command + list = subparsers.add_parser('list') + list.add_argument( + '--tag', + dest='tags', + choices=PLAYBOOK_TAGS, + required=True, + action='append', + help='Ansible tag' + ) + list.add_argument('args', nargs=argparse.REMAINDER) + + ################################### + ## ADD command + add = subparsers.add_parser('add') + add.add_argument( + '--tag', + dest='tags', + choices=PLAYBOOK_TAGS, + required=True, + action='append', + help='Ansible tag' + ) + add.add_argument( + '--priority', + type=int, + default=100, + dest='priority', + help='Priority for role [default 100, 1 is most important]' + ) + add.add_argument('role', metavar='roles', nargs='+', help='Ansible roles') + + add.add_argument('args', nargs=argparse.REMAINDER) + + ## Execute + args = parser.parse_args() + main(args) diff --git a/docker/php-official/5.6/conf/bin/service.d/cron.d/10-init.sh b/docker/php-official/5.6/conf/bin/service.d/cron.d/10-init.sh new file mode 100644 index 000000000..fdffa2a0f --- /dev/null +++ b/docker/php-official/5.6/conf/bin/service.d/cron.d/10-init.sh @@ -0,0 +1 @@ +# placeholder diff --git a/docker/php-official/5.6/conf/bin/service.d/cron.sh b/docker/php-official/5.6/conf/bin/service.d/cron.sh new file mode 100644 index 000000000..9bf7c10bf --- /dev/null +++ b/docker/php-official/5.6/conf/bin/service.d/cron.sh @@ -0,0 +1,7 @@ +#!/usr/bin/env bash + +source /opt/docker/bin/config.sh + +includeScriptDir "/opt/docker/bin/service.d/cron.d/" + +exec /usr/sbin/cron -f diff --git a/provisioning/base-app/general/bin/service.d/dnsmasq.d/10-init.sh b/docker/php-official/5.6/conf/bin/service.d/dnsmasq.d/10-init.sh similarity index 100% rename from provisioning/base-app/general/bin/service.d/dnsmasq.d/10-init.sh rename to docker/php-official/5.6/conf/bin/service.d/dnsmasq.d/10-init.sh diff --git a/provisioning/base-app/general/bin/service.d/dnsmasq.sh b/docker/php-official/5.6/conf/bin/service.d/dnsmasq.sh similarity index 100% rename from provisioning/base-app/general/bin/service.d/dnsmasq.sh rename to docker/php-official/5.6/conf/bin/service.d/dnsmasq.sh diff --git a/docker/php/alpine-3-php7/conf/bin/service.d/php-fpm.d/10-init.sh b/docker/php-official/5.6/conf/bin/service.d/php-fpm.d/10-init.sh similarity index 100% rename from docker/php/alpine-3-php7/conf/bin/service.d/php-fpm.d/10-init.sh rename to docker/php-official/5.6/conf/bin/service.d/php-fpm.d/10-init.sh diff --git a/docker/php-official/5.6/conf/bin/service.d/php-fpm.d/11-clear-env.sh b/docker/php-official/5.6/conf/bin/service.d/php-fpm.d/11-clear-env.sh new file mode 100644 index 000000000..ef6fd4016 --- /dev/null +++ b/docker/php-official/5.6/conf/bin/service.d/php-fpm.d/11-clear-env.sh @@ -0,0 +1,38 @@ +# +# Workaround for old php-fpm versions which don't have clear_env setting +# + +VARIABLE_LIST="; Workaround for missing clear_env feature in PHP-FPM" + +# For each exported variable +for envVariable in $(printenv|cut -f1 -d=); do + + case "$envVariable" in + "_"|"PATH"|"PWD") + ## ignore this variables + ;; + + *) + ## get content of variable + envVariableContent="${!envVariable}" + + ## php-fpm requires that env variable has to be filled with content + if [[ -n "$envVariableContent" ]]; then + ## quote quotes + envVariableContent=${envVariableContent//\"/\\\"} + + ## add to list + VARIABLE_LIST="${VARIABLE_LIST}"$'\n'"env[${envVariable}] = \"${envVariableContent}\"" + fi + ;; + esac + +done + +# Replace ;#CLEAR_ENV_WORKAROUND# with environment variable list for all php-fpm pool files +go-replace \ + -s ";#CLEAR_ENV_WORKAROUND#" -r "$VARIABLE_LIST" \ + --path=/opt/docker/etc/php/fpm/pool.d/ \ + --path-pattern='*.conf' \ + --ignore-empty + diff --git a/docker/php-official/5.6/conf/bin/service.d/php-fpm.sh b/docker/php-official/5.6/conf/bin/service.d/php-fpm.sh new file mode 100644 index 000000000..b25983bd3 --- /dev/null +++ b/docker/php-official/5.6/conf/bin/service.d/php-fpm.sh @@ -0,0 +1,7 @@ +#!/usr/bin/env bash + +source /opt/docker/bin/config.sh + +includeScriptDir "/opt/docker/bin/service.d/php-fpm.d/" + +exec /usr/local/bin/php-fpm --nodaemonize diff --git a/docker/php-official/5.6/conf/bin/service.d/postfix.d/10-init.sh b/docker/php-official/5.6/conf/bin/service.d/postfix.d/10-init.sh new file mode 100644 index 000000000..cfd876955 --- /dev/null +++ b/docker/php-official/5.6/conf/bin/service.d/postfix.d/10-init.sh @@ -0,0 +1,27 @@ +# force new copy of hosts there (otherwise links could be outdated) +mkdir -p /var/spool/postfix/etc +cp -f /etc/hosts /var/spool/postfix/etc/hosts +cp -f /etc/resolv.conf /var/spool/postfix/etc/resolv.conf +cp -f /etc/services /var/spool/postfix/etc/services + +## MYHOSTNAME +# replace line +sed -i '/myhostname[ ]* =/c\' main.cf +echo "myhostname = $(hostname)" >> /etc/postfix/main.cf + +## REPLAYHOST +if [[ -n "${POSTFIX_RELAYHOST+x}" ]]; then + # replace line + sed -i '/relayhost[ ]* =/c\' main.cf + echo "relayhost = $POSTFIX_RELAYHOST" >> /etc/postfix/main.cf +fi + +## MYNETWORKS +if [[ -n "${POSTFIX_MYNETWORKS+x}" ]]; then + # replace line + sed -i '/mynetworks[ ]* =/c\' main.cf + echo "mynetworks = $POSTFIX_MYNETWORKS" >> /etc/postfix/main.cf +fi + +# generate aliases db +newaliases || : diff --git a/provisioning/base-app/general/bin/service.d/postfix.sh b/docker/php-official/5.6/conf/bin/service.d/postfix.sh similarity index 100% rename from provisioning/base-app/general/bin/service.d/postfix.sh rename to docker/php-official/5.6/conf/bin/service.d/postfix.sh diff --git a/docker/php-official/5.6/conf/bin/service.d/ssh.d/10-init.sh b/docker/php-official/5.6/conf/bin/service.d/ssh.d/10-init.sh new file mode 100644 index 000000000..f2b600312 --- /dev/null +++ b/docker/php-official/5.6/conf/bin/service.d/ssh.d/10-init.sh @@ -0,0 +1,7 @@ +# Init ssh privilege separation directory +mkdir -p /var/run/sshd +chown root:root /var/run/sshd +chmod 755 /var/run/sshd + +# generate host keys +ssh-keygen -A diff --git a/provisioning/base-app/general/bin/service.d/ssh.sh b/docker/php-official/5.6/conf/bin/service.d/ssh.sh similarity index 100% rename from provisioning/base-app/general/bin/service.d/ssh.sh rename to docker/php-official/5.6/conf/bin/service.d/ssh.sh diff --git a/docker/php-official/5.6/conf/bin/service.d/supervisor.d/10-init.sh b/docker/php-official/5.6/conf/bin/service.d/supervisor.d/10-init.sh new file mode 100644 index 000000000..fdffa2a0f --- /dev/null +++ b/docker/php-official/5.6/conf/bin/service.d/supervisor.d/10-init.sh @@ -0,0 +1 @@ +# placeholder diff --git a/docker/php-official/5.6/conf/bin/service.d/supervisor.sh b/docker/php-official/5.6/conf/bin/service.d/supervisor.sh new file mode 100644 index 000000000..b1741955a --- /dev/null +++ b/docker/php-official/5.6/conf/bin/service.d/supervisor.sh @@ -0,0 +1,7 @@ +#!/usr/bin/env bash + +source /opt/docker/bin/config.sh + +includeScriptDir "/opt/docker/bin/service.d/supervisor.d/" + +exec supervisord -c /opt/docker/etc/supervisor.conf --logfile /dev/null --pidfile /dev/null --user root diff --git a/docker/php-official/5.6/conf/bin/service.d/syslog-ng.d/10-init.sh b/docker/php-official/5.6/conf/bin/service.d/syslog-ng.d/10-init.sh new file mode 100644 index 000000000..326207e52 --- /dev/null +++ b/docker/php-official/5.6/conf/bin/service.d/syslog-ng.d/10-init.sh @@ -0,0 +1,10 @@ +# If /dev/log is either a named pipe or it was placed there accidentally, +# e.g. because of the issue documented at https://github.com/phusion/baseimage-docker/pull/25, +# then we remove it. +if [ ! -S /dev/log ]; then rm -f /dev/log; fi +if [ ! -S /var/lib/syslog-ng/syslog-ng.ctl ]; then rm -f /var/lib/syslog-ng/syslog-ng.ctl; fi + +if [[ ! -p /docker.stdout ]]; then + # Switch to file (tty docker mode) + go-replace -s 'pipe("/docker.stdout")' -r 'file("/docker.stdout")' -- /opt/docker/etc/syslog-ng/syslog-ng.conf +fi diff --git a/docker/php-official/5.6/conf/bin/service.d/syslog-ng.sh b/docker/php-official/5.6/conf/bin/service.d/syslog-ng.sh new file mode 100644 index 000000000..09d1730ba --- /dev/null +++ b/docker/php-official/5.6/conf/bin/service.d/syslog-ng.sh @@ -0,0 +1,8 @@ +#!/usr/bin/env bash +set -e + +source /opt/docker/bin/config.sh + +includeScriptDir "/opt/docker/bin/service.d/syslog-ng.d/" + +exec syslog-ng -F --no-caps -p /var/run/syslog-ng.pid $SYSLOGNG_OPTS diff --git a/docker/php-official/5.6/conf/bin/usr-bin/docker-provision b/docker/php-official/5.6/conf/bin/usr-bin/docker-provision new file mode 100644 index 000000000..4ee715c64 --- /dev/null +++ b/docker/php-official/5.6/conf/bin/usr-bin/docker-provision @@ -0,0 +1,9 @@ +#!/usr/bin/env bash + +set -o pipefail # trace ERR through pipes +set -o errtrace # trace ERR through 'time command' and other functions +set -o nounset ## set -u : exit the script if you try to use an uninitialised variable +set -o errexit ## set -e : exit the script if any statement returns a non-true return value + +# wrapper +exec /opt/docker/bin/provision "$@" diff --git a/docker/php-official/5.6/conf/bin/usr-bin/docker-service-disable b/docker/php-official/5.6/conf/bin/usr-bin/docker-service-disable new file mode 100644 index 000000000..2b5b31bb4 --- /dev/null +++ b/docker/php-official/5.6/conf/bin/usr-bin/docker-service-disable @@ -0,0 +1,30 @@ +#!/usr/bin/env bash + +set -o pipefail # trace ERR through pipes +set -o errtrace # trace ERR through 'time command' and other functions +set -o nounset ## set -u : exit the script if you try to use an uninitialised variable +set -o errexit ## set -e : exit the script if any statement returns a non-true return value + +source /opt/docker/bin/config.sh + +rootCheck "$0" + +if [[ "$#" -eq 0 ]]; then + echo "Usage: $0 " + exit 1 +fi + +for SERVICE in "$@"; do + SERVICE_FILE="/opt/docker/etc/supervisor.d/${SERVICE}.conf" + + ## Disable service + if [[ -f "$SERVICE_FILE" ]]; then + go-replace --mode=lineinfile \ + -s 'autostart =' -r 'autostart = false' \ + -- "$SERVICE_FILE" + else + echo "[ERROR] Service '${SERVICE}' not found (tried ${SERVICE_FILE})" + exit 1 + fi +done + diff --git a/docker/php-official/5.6/conf/bin/usr-bin/docker-service-enable b/docker/php-official/5.6/conf/bin/usr-bin/docker-service-enable new file mode 100644 index 000000000..8d36a14a9 --- /dev/null +++ b/docker/php-official/5.6/conf/bin/usr-bin/docker-service-enable @@ -0,0 +1,41 @@ +#!/usr/bin/env bash + +set -o pipefail # trace ERR through pipes +set -o errtrace # trace ERR through 'time command' and other functions +set -o nounset ## set -u : exit the script if you try to use an uninitialised variable +set -o errexit ## set -e : exit the script if any statement returns a non-true return value + +source /opt/docker/bin/config.sh + +rootCheck "$0" + +if [[ "$#" -eq 0 ]]; then + echo "Usage: $0 " + exit 1 +fi + +for SERVICE in "$@"; do + SERVICE_FILE="/opt/docker/etc/supervisor.d/${SERVICE}.conf" + PROVISION_FILE="/opt/docker/provision/service.d/${SERVICE}.sh" + + # Run on demand installation/provisioning + if [[ -f "$PROVISION_FILE" ]]; then + echo "Running provisioning for ${SERVICE}, please wait..." + + ## execute scripts + . "$PROVISION_FILE" + + ## remove directory (one run time) + rm -f -- "$PROVISION_FILE" + fi + + ## Enable service + if [[ -f "$SERVICE_FILE" ]]; then + go-replace --mode=lineinfile \ + -s 'autostart =' -r 'autostart = true' \ + -- "$SERVICE_FILE" + else + echo "[ERROR] Service '${SERVICE}' not found (tried ${SERVICE_FILE})" + exit 1 + fi +done diff --git a/docker/php-official/5.6/conf/bin/usr-bin/service b/docker/php-official/5.6/conf/bin/usr-bin/service new file mode 100755 index 000000000..55ea12bf7 --- /dev/null +++ b/docker/php-official/5.6/conf/bin/usr-bin/service @@ -0,0 +1,86 @@ +#!/bin/bash + +set -o pipefail # trace ERR through pipes +set -o errtrace # trace ERR through 'time command' and other functions +set -o nounset ## set -u : exit the script if you try to use an uninitialised variable +set -o errexit ## set -e : exit the script if any statement returns a non-true return value + +# Root check +if [ "$(/usr/bin/whoami)" != "root" ]; then + echo "[ERROR] Must be run as root" + exit 1 +fi + +function serviceHelp() { + echo "Usage: $(basename "$0") " +} + +function getServicePid() { + local serviceName="$1" + local servicePid=$(supervisorctl pid "${serviceName}:${serviceName}d") + + if [[ -z "$servicePid" ]] || [[ "$servicePid" == "0" ]]; then + echo "not running" + exit 1 + fi + + echo $servicePid +} + +# Param check +if [ "$#" -lt 2 ]; then + echo "[ERROR] Missing parameters" + serviceHelp + exit 1 +fi + +############################# +# Param init +############################# + +SERVICENAME="$1" +ACTION="$2" + +############################# +# Service aliases +############################# +case "$SERVICENAME" in + apache2|httpd) + SERVICENAME="apache" + ;; +esac + +############################# +# Action runner +############################# +case "$ACTION" in + stop|start|restart|status) + exec supervisorctl "$ACTION" "${SERVICENAME}:${SERVICENAME}d" + ;; + + pid) + echo $(getServicePid "${SERVICENAME}") + ;; + + check) + FIRST_PID=$(getServicePid "${SERVICENAME}") + sleep 5 + SECOND_PID=$(getServicePid "${SERVICENAME}") + + if [[ "$FIRST_PID" == "$SECOND_PID" ]]; then + echo "ok" + exit 0 + else + echo "not running" + exit 1 + fi + ;; + + + *) + echo "[ERROR] Invalid action" + serviceHelp + exit 1 + ;; + +esac diff --git a/docker/php/alpine-3-php7/conf/etc/logrotate.d/php5-fpm b/docker/php-official/5.6/conf/etc/logrotate.d/php5-fpm similarity index 100% rename from docker/php/alpine-3-php7/conf/etc/logrotate.d/php5-fpm rename to docker/php-official/5.6/conf/etc/logrotate.d/php5-fpm diff --git a/docker/php-official/5.6/conf/etc/logrotate.d/syslog-ng b/docker/php-official/5.6/conf/etc/logrotate.d/syslog-ng new file mode 100644 index 000000000..4a6f9c54e --- /dev/null +++ b/docker/php-official/5.6/conf/etc/logrotate.d/syslog-ng @@ -0,0 +1,38 @@ +/var/log/syslog +{ + rotate 7 + daily + missingok + notifempty + delaycompress + compress + postrotate + /bin/kill -HUP `cat /var/run/syslog-ng.pid 2> /dev/null` > /dev/null + endscript +} + +/var/log/mail.info +/var/log/mail.warn +/var/log/mail.err +/var/log/mail.log +/var/log/daemon.log +/var/log/kern.log +/var/log/auth.log +/var/log/user.log +/var/log/lpr.log +/var/log/cron.log +/var/log/debug +/var/log/messages +{ + rotate 4 + weekly + missingok + notifempty + compress + delaycompress + sharedscripts + postrotate + /bin/kill -HUP `cat /var/run/syslog-ng.pid 2> /dev/null` > /dev/null + supervisorctl restart syslog-ng-stdout > /dev/null + endscript +} \ No newline at end of file diff --git a/docker/php-official/5.6/conf/etc/php/conf.d/.gitkeep b/docker/php-official/5.6/conf/etc/php/conf.d/.gitkeep new file mode 100644 index 000000000..e69de29bb diff --git a/docker/php/alpine-3-php7/conf/etc/php/php.ini b/docker/php-official/5.6/conf/etc/php/php.ini similarity index 100% rename from docker/php/alpine-3-php7/conf/etc/php/php.ini rename to docker/php-official/5.6/conf/etc/php/php.ini diff --git a/docker/php-official/5.6/conf/etc/php/php.webdevops.ini b/docker/php-official/5.6/conf/etc/php/php.webdevops.ini new file mode 100644 index 000000000..aa1545ab8 --- /dev/null +++ b/docker/php-official/5.6/conf/etc/php/php.webdevops.ini @@ -0,0 +1,34 @@ +; ------------------------------------- +; Docker Webdevops PHP configuration +; ------------------------------------- + +; this file will overwrite default php.ini settings + +display_errors = 0 +log_errors = 1 + +short_open_tag = Off +variables_order = 'GPCS' +request_order = 'GP' + +allow_url_fopen = On +allow_url_include = Off + +memory_limit = 512M +max_execution_time = 300 +max_input_time = 300 +post_max_size = 50M +upload_max_filesize = 50M +max_input_vars = 5000 + +expose_php = Off + +date.timezone = UTC + +mysql.default_host = mysql +mysqli.default_host = mysql + +opcache.memory_consumption = 256 +opcache.interned_strings_buffer = 16 +opcache.max_accelerated_files = 7963 +opcache.fast_shutdown = 1 diff --git a/docker/php-official/5.6/conf/etc/supervisor.conf b/docker/php-official/5.6/conf/etc/supervisor.conf new file mode 100644 index 000000000..479e0db08 --- /dev/null +++ b/docker/php-official/5.6/conf/etc/supervisor.conf @@ -0,0 +1,20 @@ +[supervisord] +nodaemon=true + +[unix_http_server] +file = /.supervisor.sock +chmod = 0700 +chown = root:root +username = root +password = {SHA}e982f17bcbe0f724063b708a4f76db211a999304 + +[supervisorctl] +serverurl = unix:///.supervisor.sock +username = root +password = docker + +[rpcinterface:supervisor] +supervisor.rpcinterface_factory = supervisor.rpcinterface:make_main_rpcinterface + +[include] +files = /opt/docker/etc/supervisor.d/*.conf diff --git a/docker/php-official/5.6/conf/etc/supervisor.d/.gitkeep b/docker/php-official/5.6/conf/etc/supervisor.d/.gitkeep new file mode 100644 index 000000000..e69de29bb diff --git a/docker/php-official/5.6/conf/etc/supervisor.d/cron.conf b/docker/php-official/5.6/conf/etc/supervisor.d/cron.conf new file mode 100644 index 000000000..ef0a71678 --- /dev/null +++ b/docker/php-official/5.6/conf/etc/supervisor.d/cron.conf @@ -0,0 +1,14 @@ +[group:cron] +programs=crond +priority=25 + +[program:crond] +command = /opt/docker/bin/service.d/cron.sh +process_name=%(program_name)s +startsecs = 0 +autostart = false +autorestart = true +stdout_logfile=/dev/stdout +stdout_logfile_maxbytes=0 +stderr_logfile=/dev/stderr +stderr_logfile_maxbytes=0 diff --git a/docker/php-official/5.6/conf/etc/supervisor.d/dnsmasq.conf b/docker/php-official/5.6/conf/etc/supervisor.d/dnsmasq.conf new file mode 100644 index 000000000..9832ffca7 --- /dev/null +++ b/docker/php-official/5.6/conf/etc/supervisor.d/dnsmasq.conf @@ -0,0 +1,14 @@ +[group:dnsmasq] +programs=dnsmasqd +priority=15 + +[program:dnsmasqd] +command = /opt/docker/bin/service.d/dnsmasq.sh +process_name=%(program_name)s +startsecs = 0 +autostart = false +autorestart = true +stdout_logfile=/dev/stdout +stdout_logfile_maxbytes=0 +stderr_logfile=/dev/stderr +stderr_logfile_maxbytes=0 diff --git a/docker/php/alpine-3-php7/conf/etc/supervisor.d/php-fpm.conf b/docker/php-official/5.6/conf/etc/supervisor.d/php-fpm.conf similarity index 100% rename from docker/php/alpine-3-php7/conf/etc/supervisor.d/php-fpm.conf rename to docker/php-official/5.6/conf/etc/supervisor.d/php-fpm.conf diff --git a/provisioning/base-app/general/etc/supervisor.d/postfix.conf b/docker/php-official/5.6/conf/etc/supervisor.d/postfix.conf similarity index 100% rename from provisioning/base-app/general/etc/supervisor.d/postfix.conf rename to docker/php-official/5.6/conf/etc/supervisor.d/postfix.conf diff --git a/provisioning/base-app/general/etc/supervisor.d/ssh.conf b/docker/php-official/5.6/conf/etc/supervisor.d/ssh.conf similarity index 100% rename from provisioning/base-app/general/etc/supervisor.d/ssh.conf rename to docker/php-official/5.6/conf/etc/supervisor.d/ssh.conf diff --git a/docker/php-official/5.6/conf/etc/supervisor.d/syslog.conf b/docker/php-official/5.6/conf/etc/supervisor.d/syslog.conf new file mode 100644 index 000000000..20d1e238c --- /dev/null +++ b/docker/php-official/5.6/conf/etc/supervisor.d/syslog.conf @@ -0,0 +1,13 @@ +[group:syslog] +programs=syslogd +priority=10 + +[program:syslogd] +command = /opt/docker/bin/service.d/syslog-ng.sh +process_name=%(program_name)s +autostart = false +autorestart = true +stdout_logfile=/dev/stdout +stdout_logfile_maxbytes=0 +stderr_logfile=/dev/stderr +stderr_logfile_maxbytes=0 diff --git a/docker/php-official/5.6/conf/etc/syslog-ng/syslog-ng.conf b/docker/php-official/5.6/conf/etc/syslog-ng/syslog-ng.conf new file mode 100644 index 000000000..c69841581 --- /dev/null +++ b/docker/php-official/5.6/conf/etc/syslog-ng/syslog-ng.conf @@ -0,0 +1,48 @@ +@version: 3.5 + +template t_isostamp { + # syslog-t_isostamp START + template("[SYSLOG] $MSGHDR$MSG\n"); + # syslog-t_isostamp END +}; + +options { + # syslog-options START + file-template(t_isostamp); + chain_hostnames(off); + flush_lines(0); + use-dns(no); + use_fqdn(no); + owner("root"); + group("adm"); + perm(0640); + stats_freq(0); + # syslog-options START +}; + +source s_src { + # syslog-s_src START + unix-stream("/dev/log"); + internal(); + # syslog-s_src END +}; + +filter f_filter { + # syslog-f_filter START + not facility(auth, authpriv); + # syslog-f_filter END +}; + +destination d_all { + # syslog-d_all START + pipe("/docker.stdout"); + # syslog-d_all END +}; + +log { + # syslog-log START + source(s_src); + filter(f_filter); + destination(d_all); + # syslog-log START +}; diff --git a/docker/php-official/5.6/conf/provision/ansible.cfg b/docker/php-official/5.6/conf/provision/ansible.cfg new file mode 100644 index 000000000..e69de29bb diff --git a/docker/php-official/5.6/conf/provision/bootstrap.d/.gitkeep b/docker/php-official/5.6/conf/provision/bootstrap.d/.gitkeep new file mode 100644 index 000000000..e69de29bb diff --git a/docker/php-official/5.6/conf/provision/build.d/.gitkeep b/docker/php-official/5.6/conf/provision/build.d/.gitkeep new file mode 100644 index 000000000..e69de29bb diff --git a/docker/php-official/5.6/conf/provision/build.d/10-cleanup.sh b/docker/php-official/5.6/conf/provision/build.d/10-cleanup.sh new file mode 100644 index 000000000..20fbdc841 --- /dev/null +++ b/docker/php-official/5.6/conf/provision/build.d/10-cleanup.sh @@ -0,0 +1,6 @@ +#!/usr/bin/env bash + +## remove logs (each bootstrap) +rm -rf -- /var/log/* +rm -rf -- /var/tmp/* +rm -rf -- /tmp/* diff --git a/docker/php-official/5.6/conf/provision/entrypoint.d/.gitkeep b/docker/php-official/5.6/conf/provision/entrypoint.d/.gitkeep new file mode 100644 index 000000000..e69de29bb diff --git a/docker/php-official/5.6/conf/provision/entrypoint.d/05-permissions.sh b/docker/php-official/5.6/conf/provision/entrypoint.d/05-permissions.sh new file mode 100644 index 000000000..6f77d8e40 --- /dev/null +++ b/docker/php-official/5.6/conf/provision/entrypoint.d/05-permissions.sh @@ -0,0 +1,2 @@ +# Fix rights of /tmp (can be a volume) +chmod 1777 /tmp diff --git a/docker/php-official/5.6/conf/provision/onbuild.d/.gitkeep b/docker/php-official/5.6/conf/provision/onbuild.d/.gitkeep new file mode 100644 index 000000000..e69de29bb diff --git a/docker/php-official/5.6/conf/provision/roles/webdevops-base-app/defaults/main.yml b/docker/php-official/5.6/conf/provision/roles/webdevops-base-app/defaults/main.yml new file mode 100644 index 000000000..e10ef7d38 --- /dev/null +++ b/docker/php-official/5.6/conf/provision/roles/webdevops-base-app/defaults/main.yml @@ -0,0 +1,7 @@ +--- + +APPLICATION_USER: "{{ lookup('env','APPLICATION_USER') }}" +APPLICATION_GROUP: "{{ lookup('env','APPLICATION_GROUP') }}" +APPLICATION_PATH: "{{ lookup('env','APPLICATION_PATH') }}" +APPLICATION_UID: "{{ lookup('env','APPLICATION_UID') }}" +APPLICATION_GID: "{{ lookup('env','APPLICATION_GID') }}" diff --git a/docker/php-official/5.6/conf/provision/roles/webdevops-base-app/tasks/bootstrap.yml b/docker/php-official/5.6/conf/provision/roles/webdevops-base-app/tasks/bootstrap.yml new file mode 100644 index 000000000..3fdce9a74 --- /dev/null +++ b/docker/php-official/5.6/conf/provision/roles/webdevops-base-app/tasks/bootstrap.yml @@ -0,0 +1,4 @@ +--- + +- include: bootstrap/user.yml +- include: bootstrap/application.yml diff --git a/docker/php-official/5.6/conf/provision/roles/webdevops-base-app/tasks/bootstrap/application.yml b/docker/php-official/5.6/conf/provision/roles/webdevops-base-app/tasks/bootstrap/application.yml new file mode 100644 index 000000000..faddb6027 --- /dev/null +++ b/docker/php-official/5.6/conf/provision/roles/webdevops-base-app/tasks/bootstrap/application.yml @@ -0,0 +1,10 @@ +--- + +- name: Init application directory + file: + path: "/{{ APPLICATION_PATH }}" + state: directory + mode: 0755 + owner: "{{ APPLICATION_USER }}" + group: "{{ APPLICATION_GROUP }}" + recurse: yes diff --git a/docker/php-official/5.6/conf/provision/roles/webdevops-base-app/tasks/bootstrap/user.yml b/docker/php-official/5.6/conf/provision/roles/webdevops-base-app/tasks/bootstrap/user.yml new file mode 100644 index 000000000..fd58b329f --- /dev/null +++ b/docker/php-official/5.6/conf/provision/roles/webdevops-base-app/tasks/bootstrap/user.yml @@ -0,0 +1,35 @@ +--- + +- name: Create application group + group: + name: "{{ APPLICATION_GROUP }}" + gid: "{{ APPLICATION_GID }}" + +- name: Create application user + user: + name: "{{ APPLICATION_USER }}" + uid: "{{ APPLICATION_UID }}" + group: "{{ APPLICATION_GROUP }}" + shell: "/bin/bash" + home: "/home/{{ APPLICATION_USER }}" + +- name: Init home directory + file: + path: "/home/{{ APPLICATION_USER }}" + state: directory + mode: 0755 + owner: "{{ APPLICATION_USER }}" + group: "{{ APPLICATION_GROUP }}" + recurse: yes + +- name: Init bashrc + lineinfile: + dest: "/home/{{ APPLICATION_USER }}/.bashrc" + mode: 0770 + owner: "{{ APPLICATION_USER }}" + group: "{{ APPLICATION_GROUP }}" + create: yes + regexp: "export TERM=xterm" + line: "export TERM=xterm" + +- action: setup diff --git a/docker/php-official/5.6/conf/provision/roles/webdevops-base-app/tasks/main.yml b/docker/php-official/5.6/conf/provision/roles/webdevops-base-app/tasks/main.yml new file mode 100644 index 000000000..1806c1a8c --- /dev/null +++ b/docker/php-official/5.6/conf/provision/roles/webdevops-base-app/tasks/main.yml @@ -0,0 +1,5 @@ +--- + +- include: bootstrap.yml + tags: + - bootstrap diff --git a/docker/php-official/5.6/conf/provision/roles/webdevops-base/defaults/main.yml b/docker/php-official/5.6/conf/provision/roles/webdevops-base/defaults/main.yml new file mode 100644 index 000000000..81f5b7efd --- /dev/null +++ b/docker/php-official/5.6/conf/provision/roles/webdevops-base/defaults/main.yml @@ -0,0 +1,6 @@ +--- + +APPLICATION_USER: "{{ lookup('env','APPLICATION_USER') }}" +APPLICATION_GROUP: "{{ lookup('env','APPLICATION_GROUP') }}" +APPLICATION_UID: "{{ lookup('env','APPLICATION_UID') }}" +APPLICATION_GID: "{{ lookup('env','APPLICATION_GID') }}" diff --git a/docker/php-official/5.6/conf/provision/roles/webdevops-base/tasks/bootstrap.yml b/docker/php-official/5.6/conf/provision/roles/webdevops-base/tasks/bootstrap.yml new file mode 100644 index 000000000..9f842336c --- /dev/null +++ b/docker/php-official/5.6/conf/provision/roles/webdevops-base/tasks/bootstrap.yml @@ -0,0 +1,8 @@ +--- + +- include: bootstrap/system.yml +- include: bootstrap/misc.yml +- include: bootstrap/root.yml +- include: bootstrap/supervisor.yml +- include: bootstrap/pam.yml +- include: bootstrap/entrypoint.yml diff --git a/docker/php-official/5.6/conf/provision/roles/webdevops-base/tasks/bootstrap/entrypoint.yml b/docker/php-official/5.6/conf/provision/roles/webdevops-base/tasks/bootstrap/entrypoint.yml new file mode 100644 index 000000000..d5d8809f4 --- /dev/null +++ b/docker/php-official/5.6/conf/provision/roles/webdevops-base/tasks/bootstrap/entrypoint.yml @@ -0,0 +1,8 @@ +--- + +- name: Create link for entrypoint + file: + src: '/opt/docker/bin/entrypoint.sh' + dest: '/entrypoint' + state: link + force: yes diff --git a/docker/php-official/5.6/conf/provision/roles/webdevops-base/tasks/bootstrap/misc.yml b/docker/php-official/5.6/conf/provision/roles/webdevops-base/tasks/bootstrap/misc.yml new file mode 100644 index 000000000..4eed695b1 --- /dev/null +++ b/docker/php-official/5.6/conf/provision/roles/webdevops-base/tasks/bootstrap/misc.yml @@ -0,0 +1,8 @@ +--- + +- file: + path: "/var/log/wtmp" + state: touch + mode: 0664 + owner: "root" + group: "root" diff --git a/docker/php-official/5.6/conf/provision/roles/webdevops-base/tasks/bootstrap/pam.yml b/docker/php-official/5.6/conf/provision/roles/webdevops-base/tasks/bootstrap/pam.yml new file mode 100644 index 000000000..a18b2412a --- /dev/null +++ b/docker/php-official/5.6/conf/provision/roles/webdevops-base/tasks/bootstrap/pam.yml @@ -0,0 +1,8 @@ +--- + +- name: Ensure su execution [Alpine family] + lineinfile: + dest: "/etc/pam.d/su" + line: "auth sufficient pam_rootok.so" + create: yes + when: ansible_os_family == "Alpine" diff --git a/docker/php-official/5.6/conf/provision/roles/webdevops-base/tasks/bootstrap/root.yml b/docker/php-official/5.6/conf/provision/roles/webdevops-base/tasks/bootstrap/root.yml new file mode 100644 index 000000000..29e955fa4 --- /dev/null +++ b/docker/php-official/5.6/conf/provision/roles/webdevops-base/tasks/bootstrap/root.yml @@ -0,0 +1,5 @@ +--- + +- file: + path: "/root/.profile" + state: absent diff --git a/docker/php-official/5.6/conf/provision/roles/webdevops-base/tasks/bootstrap/supervisor.yml b/docker/php-official/5.6/conf/provision/roles/webdevops-base/tasks/bootstrap/supervisor.yml new file mode 100644 index 000000000..2ce07ac26 --- /dev/null +++ b/docker/php-official/5.6/conf/provision/roles/webdevops-base/tasks/bootstrap/supervisor.yml @@ -0,0 +1,13 @@ +--- + +- name: Remove /usr/sbin/service + file: + path: '/usr/sbin/service' + state: absent + +- name: Create link for supervisor.conf + file: + src: '/opt/docker/etc/supervisor.conf' + dest: '/etc/supervisord.conf' + state: link + force: yes diff --git a/docker/php-official/5.6/conf/provision/roles/webdevops-base/tasks/bootstrap/system.yml b/docker/php-official/5.6/conf/provision/roles/webdevops-base/tasks/bootstrap/system.yml new file mode 100644 index 000000000..0741d7cae --- /dev/null +++ b/docker/php-official/5.6/conf/provision/roles/webdevops-base/tasks/bootstrap/system.yml @@ -0,0 +1,33 @@ +--- + +- name: Create /entrypoint.d + file: + path: "/entrypoint.d" + state: directory + owner: "root" + group: "root" + mode: 0700 + +- name: Create /entrypoint.cmd + file: + src: '/opt/docker/bin/entrypoint.d' + dest: '/entrypoint.cmd' + state: link + force: yes + +- name: Remove system logrotate and cronjobs (not needed) + file: + path: '{{ item }}' + state: absent + with_items: + # Debian/Ubuntu + - /etc/cron.daily/logrotate + - /etc/cron.daily/apt-compat + - /etc/cron.daily/dpkg + - /etc/cron.daily/passwd + # RedHat + - /etc/cron.daily/0yum-daily.cron + - /etc/cron.daily/logrotate + - /etc/cron.hourly/0yum-hourly.cron + # Alpine + - /etc/periodic/daily/logrotate diff --git a/docker/php-official/5.6/conf/provision/roles/webdevops-base/tasks/build.yml b/docker/php-official/5.6/conf/provision/roles/webdevops-base/tasks/build.yml new file mode 100644 index 000000000..cd21505a4 --- /dev/null +++ b/docker/php-official/5.6/conf/provision/roles/webdevops-base/tasks/build.yml @@ -0,0 +1,2 @@ +--- + diff --git a/docker/php-official/5.6/conf/provision/roles/webdevops-base/tasks/build/.gitkeep b/docker/php-official/5.6/conf/provision/roles/webdevops-base/tasks/build/.gitkeep new file mode 100644 index 000000000..e69de29bb diff --git a/docker/php-official/5.6/conf/provision/roles/webdevops-base/tasks/entrypoint.yml b/docker/php-official/5.6/conf/provision/roles/webdevops-base/tasks/entrypoint.yml new file mode 100644 index 000000000..ed97d539c --- /dev/null +++ b/docker/php-official/5.6/conf/provision/roles/webdevops-base/tasks/entrypoint.yml @@ -0,0 +1 @@ +--- diff --git a/docker/php-official/5.6/conf/provision/roles/webdevops-base/tasks/entrypoint/.gitkeep b/docker/php-official/5.6/conf/provision/roles/webdevops-base/tasks/entrypoint/.gitkeep new file mode 100644 index 000000000..e69de29bb diff --git a/docker/php-official/5.6/conf/provision/roles/webdevops-base/tasks/main.yml b/docker/php-official/5.6/conf/provision/roles/webdevops-base/tasks/main.yml new file mode 100644 index 000000000..66fb2e38b --- /dev/null +++ b/docker/php-official/5.6/conf/provision/roles/webdevops-base/tasks/main.yml @@ -0,0 +1,13 @@ +--- + +- include: bootstrap.yml + tags: + - bootstrap + +- include: build.yml + tags: + - build + +- include: entrypoint.yml + tags: + - entrypoint diff --git a/docker/php-official/5.6/conf/provision/roles/webdevops-cleanup/tasks/cleanup.yml b/docker/php-official/5.6/conf/provision/roles/webdevops-cleanup/tasks/cleanup.yml new file mode 100644 index 000000000..ddd0abbc4 --- /dev/null +++ b/docker/php-official/5.6/conf/provision/roles/webdevops-cleanup/tasks/cleanup.yml @@ -0,0 +1,16 @@ +--- + +- name: Filesystem cleanup [Debian family] + file: + path: "{{ item }}" + state: absent + with_fileglob: + - /var/cache/apt/archives/*.deb + - /var/cache/apt/archives/partial/* + - /var/cache/debconf/*-old + - /var/lib/apt/lists/* + when: ansible_os_family == "Debian" + +- name: Yum cleanup [RedHat family] + command: yum clean all + when: ansible_os_family == "RedHat" diff --git a/docker/php-official/5.6/conf/provision/roles/webdevops-cleanup/tasks/main.yml b/docker/php-official/5.6/conf/provision/roles/webdevops-cleanup/tasks/main.yml new file mode 100644 index 000000000..951b7fc67 --- /dev/null +++ b/docker/php-official/5.6/conf/provision/roles/webdevops-cleanup/tasks/main.yml @@ -0,0 +1,6 @@ +--- + +- include: cleanup.yml + tags: + - bootstrap + - onbuild diff --git a/docker/php-official/5.6/conf/provision/roles/webdevops-php/defaults/main.yml b/docker/php-official/5.6/conf/provision/roles/webdevops-php/defaults/main.yml new file mode 100644 index 000000000..81f5b7efd --- /dev/null +++ b/docker/php-official/5.6/conf/provision/roles/webdevops-php/defaults/main.yml @@ -0,0 +1,6 @@ +--- + +APPLICATION_USER: "{{ lookup('env','APPLICATION_USER') }}" +APPLICATION_GROUP: "{{ lookup('env','APPLICATION_GROUP') }}" +APPLICATION_UID: "{{ lookup('env','APPLICATION_UID') }}" +APPLICATION_GID: "{{ lookup('env','APPLICATION_GID') }}" diff --git a/docker/php-official/5.6/conf/provision/roles/webdevops-php/tasks/bootstrap.yml b/docker/php-official/5.6/conf/provision/roles/webdevops-php/tasks/bootstrap.yml new file mode 100644 index 000000000..99a2e5191 --- /dev/null +++ b/docker/php-official/5.6/conf/provision/roles/webdevops-php/tasks/bootstrap.yml @@ -0,0 +1,10 @@ +--- + +- include: bootstrap/init.yml +- include: bootstrap/php.yml +- include: bootstrap/php.debian.yml +- include: bootstrap/php.redhat.yml +- include: bootstrap/php.alpine.yml +- include: bootstrap/php-fpm.main.yml +- include: bootstrap/php-fpm.pool.yml +- include: bootstrap/php-fpm.yml diff --git a/docker/php-official/5.6/conf/provision/roles/webdevops-php/tasks/bootstrap/init.yml b/docker/php-official/5.6/conf/provision/roles/webdevops-php/tasks/bootstrap/init.yml new file mode 100644 index 000000000..df39e4bd4 --- /dev/null +++ b/docker/php-official/5.6/conf/provision/roles/webdevops-php/tasks/bootstrap/init.yml @@ -0,0 +1,23 @@ +--- + +- name: Get php version + command: "php -r 'echo phpversion();'" + changed_when: true + register: php_version_cmd + ignore_errors: true + +- name: Set php_version version + set_fact: + php_version: "{{php_version_cmd.stdout}}" + +############################# +# PHP +############################# + +- name: Set php main file (official) + set_fact: + php_etc_dir: /usr/local/etc/php + php_main_conf: /usr/local/etc/php-fpm.conf + php_pool_conf: www.conf + php_pool_dir: /usr/local/etc/php-fpm.d + php_fpm_bin: /usr/local/sbin/php-fpm diff --git a/docker/php-official/5.6/conf/provision/roles/webdevops-php/tasks/bootstrap/php-fpm.main.yml b/docker/php-official/5.6/conf/provision/roles/webdevops-php/tasks/bootstrap/php-fpm.main.yml new file mode 100644 index 000000000..c149d8728 --- /dev/null +++ b/docker/php-official/5.6/conf/provision/roles/webdevops-php/tasks/bootstrap/php-fpm.main.yml @@ -0,0 +1,49 @@ +--- + +- name: Create php directories + file: + path: "{{ item }}" + state: directory + mode: 0755 + owner: "root" + group: "root" + with_items: + - /opt/docker/etc/php/fpm/ + +- name: Move php-fpm main file to /opt/docker/etc/php/fpm/ + command: "mv {{ php_main_conf }} /opt/docker/etc/php/fpm/php-fpm.conf" + args: + creates: /opt/docker/etc/php/fpm/php-fpm.conf + +- name: Remove php-fpm main file + file: + path: "{{ php_main_conf }}" + state: absent + +- name: Symlink php-fpm main file + file: + path: "{{ php_main_conf }}" + src: "/opt/docker/etc/php/fpm/php-fpm.conf" + state: link + owner: "root" + group: "root" + +- name: Configure php-fpm main (all versions) + lineinfile: + dest: '/opt/docker/etc/php/fpm/php-fpm.conf' + regexp: '^[\s;]*{{ item.key }}[\s]*=' + line: '{{ item.key }} = {{ item.value }}' + insertafter: '\[global\]' + with_items: + - { key: 'error_log', value: "/docker.stderr" } + - { key: 'pid', value: "/var/run/php-fpm.pid" } + +- name: Configure php-fpm main (php 5.x) + lineinfile: + dest: '/opt/docker/etc/php/fpm/php-fpm.conf' + regexp: '^[\s;]*{{ item.key }}[\s]*=' + line: '{{ item.key }} = {{ item.value }}' + insertbefore: '[\s]*include[\s]*=' + with_items: + - { key: 'daemonize', value: 'no' } + when: ( php_version | version_compare('7.0.0', '<') ) diff --git a/docker/php-official/5.6/conf/provision/roles/webdevops-php/tasks/bootstrap/php-fpm.pool.yml b/docker/php-official/5.6/conf/provision/roles/webdevops-php/tasks/bootstrap/php-fpm.pool.yml new file mode 100644 index 000000000..ab0b7b02c --- /dev/null +++ b/docker/php-official/5.6/conf/provision/roles/webdevops-php/tasks/bootstrap/php-fpm.pool.yml @@ -0,0 +1,101 @@ +--- + +- set_fact: + php_clear_env_available: False + +- set_fact: + php_clear_env_available: True + when: ( php_version | version_compare('5.4', 'eq') and php_version | version_compare('5.4.27', 'ge') ) or + ( php_version | version_compare('5.5', 'eq') and php_version | version_compare('5.5.11', 'ge') ) or + ( php_version | version_compare('5.6', 'ge') ) + +- name: Create /opt/docker/etc/php/fpm directory + file: + path: "/opt/docker/etc/php/fpm" + state: directory + +- name: Move php-fpm pool directory file to /opt/docker/etc/php/ + command: "mv {{ php_pool_dir }} /opt/docker/etc/php/fpm/pool.d" + args: + creates: /opt/docker/etc/php/fpm/pool.d + +- name: Rename pool file file to application.conf" + command: "mv /opt/docker/etc/php/fpm/pool.d/{{ php_pool_conf }} /opt/docker/etc/php/fpm/pool.d/application.conf" + args: + creates: /opt/docker/etc/php/fpm/pool.d/application.conf + +- name: Remove php-fpm pool directory + file: + path: "{{ php_pool_dir }}" + state: absent + +- name: Symlink php-fpm pool file + file: + path: "{{ php_pool_dir }}" + src: "/opt/docker/etc/php/fpm/pool.d" + state: link + owner: "root" + group: "root" + +- name: Configure php-fpm pool user (application.conf) + lineinfile: + dest: '/opt/docker/etc/php/fpm/pool.d/application.conf' + regexp: '^[\s;]*{{ item.key }}[\s]*=' + line: '{{ item.key }} = {{ item.value }}' + with_items: + - { key: 'listen', value: "[::]:9000" } + - { key: 'catch_workers_output', value: "yes" } + - { key: 'access.format', value: '[php-fpm:access] %R - %u %t "%m %r%Q%q" %s %f %{mili}d %{kilo}M %C%%' } + - { key: 'access.log', value: "/docker.stdout" } + - { key: 'slowlog', value: "/docker.stderr" } + - { key: 'php_admin_value[error_log]', value: "/docker.stderr" } + - { key: 'php_admin_value[log_errors]', value: "on" } + - { key: 'user', value: "{{ APPLICATION_USER }}" } + - { key: 'group', value: "{{ APPLICATION_GROUP }}" } + +- name: Configure php-fpm pool user (application.conf) + lineinfile: + dest: '/opt/docker/etc/php/fpm/pool.d/application.conf' + regexp: '^[\s;]*{{ item.key }}[\s]*=' + line: '{{ item.key }} = {{ item.value }}' + with_items: + - { key: 'listen', value: "0.0.0.0:9000" } + when: php_version | version_compare('5.5.99', '<=') + +- name: Configure php-fpm pool user (application.conf) + lineinfile: + dest: '/opt/docker/etc/php/fpm/pool.d/application.conf' + regexp: '^[\s;]*{{ item.key }}[\s]*=' + line: ';{{ item.key }} = {{ item.value }}' + with_items: + - { key: 'access.log', value: "/docker.stdout" } + +- name: Disable clear env in php-fpm pool + lineinfile: + dest: '/opt/docker/etc/php/fpm/pool.d/application.conf' + regexp: '^[\s;]*{{ item.key }}[\s]*=' + line: '{{ item.key }} = {{ item.value }}' + with_items: + - { key: 'clear_env', value: "no" } + when: php_clear_env_available == True + +- name: Remove clear env workaround + file: + path: "/opt/docker/bin/service.d/php-fpm.d/11-clear-env.sh" + state: absent + when: php_clear_env_available == True + +- name: Append clear env workaround in php-fpm pool (old php-fpm versions) + lineinfile: + dest: '/opt/docker/etc/php/fpm/pool.d/application.conf' + line: ';#CLEAR_ENV_WORKAROUND#' + when: php_clear_env_available == False + +- name: Disable php-fpm connection limit + lineinfile: + dest: '/opt/docker/etc/php/fpm/pool.d/application.conf' + regexp: '^[\s;]*{{ item.key }}[\s]*=' + line: ';{{ item.key }}' + with_items: + - { key: 'listen.allowed_clients' } + diff --git a/docker/php-official/5.6/conf/provision/roles/webdevops-php/tasks/bootstrap/php-fpm.yml b/docker/php-official/5.6/conf/provision/roles/webdevops-php/tasks/bootstrap/php-fpm.yml new file mode 100644 index 000000000..41c1b33dc --- /dev/null +++ b/docker/php-official/5.6/conf/provision/roles/webdevops-php/tasks/bootstrap/php-fpm.yml @@ -0,0 +1,9 @@ +--- + +- name: Symlink php-fpm binary + file: + path: "/usr/local/bin/php-fpm" + src: "{{ php_fpm_bin }}" + state: link + owner: "root" + group: "root" diff --git a/docker/php-official/5.6/conf/provision/roles/webdevops-php/tasks/bootstrap/php.alpine.yml b/docker/php-official/5.6/conf/provision/roles/webdevops-php/tasks/bootstrap/php.alpine.yml new file mode 100644 index 000000000..4c16cdf0d --- /dev/null +++ b/docker/php-official/5.6/conf/provision/roles/webdevops-php/tasks/bootstrap/php.alpine.yml @@ -0,0 +1,12 @@ +--- + +- name: Create link for additional php.ini [Alpine family] + file: + src: '/opt/docker/etc/php/{{ item.file }}' + dest: '{{ php_etc_dir }}/conf.d/{{ item.target }}' + state: link + force: yes + with_items: + - { file: 'php.webdevops.ini', target: 'xzza-webdevops.ini'} + - { file: 'php.ini', target: 'xzzz-docker.ini'} + when: ansible_os_family == 'Alpine' diff --git a/docker/php-official/5.6/conf/provision/roles/webdevops-php/tasks/bootstrap/php.debian.yml b/docker/php-official/5.6/conf/provision/roles/webdevops-php/tasks/bootstrap/php.debian.yml new file mode 100644 index 000000000..411e736c8 --- /dev/null +++ b/docker/php-official/5.6/conf/provision/roles/webdevops-php/tasks/bootstrap/php.debian.yml @@ -0,0 +1,11 @@ +--- + +- name: Link php.ini for cli and fpm [Official PHP] + file: + src: '{{ item.file }}' + dest: '{{ php_etc_dir }}/conf.d/{{ item.target }}' + force: yes + state: link + with_items: + - { category: 'cli', file: '/opt/docker/etc/php/php.webdevops.ini', target: '98-webdevops.ini' } + - { category: 'cli', file: '/opt/docker/etc/php/php.ini', target: '99-docker.ini' } diff --git a/docker/php-official/5.6/conf/provision/roles/webdevops-php/tasks/bootstrap/php.redhat.yml b/docker/php-official/5.6/conf/provision/roles/webdevops-php/tasks/bootstrap/php.redhat.yml new file mode 100644 index 000000000..7e8810231 --- /dev/null +++ b/docker/php-official/5.6/conf/provision/roles/webdevops-php/tasks/bootstrap/php.redhat.yml @@ -0,0 +1,12 @@ +--- + +- name: Create link for additional php.ini [RedHat family] + file: + src: '/opt/docker/etc/php/{{ item.file }}' + dest: '/etc/php.d/{{ item.target }}' + state: link + force: yes + with_items: + - { file: 'php.webdevops.ini', target: 'zza-webdevops.ini'} + - { file: 'php.ini', target: 'zzz-docker.ini'} + when: ansible_os_family == 'RedHat' diff --git a/docker/php-official/5.6/conf/provision/roles/webdevops-php/tasks/bootstrap/php.yml b/docker/php-official/5.6/conf/provision/roles/webdevops-php/tasks/bootstrap/php.yml new file mode 100644 index 000000000..caac8f413 --- /dev/null +++ b/docker/php-official/5.6/conf/provision/roles/webdevops-php/tasks/bootstrap/php.yml @@ -0,0 +1,23 @@ +--- + +- name: Create php directories + file: + path: "{{ item }}" + state: directory + mode: 0755 + owner: "root" + group: "root" + with_items: + - /opt/docker/etc/php/ + - /opt/docker/etc/php/fpm/ + +- name: Create php.ini files + file: + path: "{{ item }}" + state: touch + mode: 0744 + owner: root + group: root + with_items: + - "/opt/docker/etc/php/php.webdevops.ini" + - "/opt/docker/etc/php/php.ini" diff --git a/docker/php-official/5.6/conf/provision/roles/webdevops-php/tasks/main.yml b/docker/php-official/5.6/conf/provision/roles/webdevops-php/tasks/main.yml new file mode 100644 index 000000000..1806c1a8c --- /dev/null +++ b/docker/php-official/5.6/conf/provision/roles/webdevops-php/tasks/main.yml @@ -0,0 +1,5 @@ +--- + +- include: bootstrap.yml + tags: + - bootstrap diff --git a/docker/php-official/5.6/conf/provision/service.d/.gitkeep b/docker/php-official/5.6/conf/provision/service.d/.gitkeep new file mode 100644 index 000000000..e69de29bb diff --git a/docker/php-official/5.6/conf/provision/service.d/cron.sh b/docker/php-official/5.6/conf/provision/service.d/cron.sh new file mode 100644 index 000000000..bd8a54781 --- /dev/null +++ b/docker/php-official/5.6/conf/provision/service.d/cron.sh @@ -0,0 +1,13 @@ +#!/usr/bin/env bash + +IMAGE_FAMILY=$(docker-image-info family) + +case "$IMAGE_FAMILY" in + Debian|Ubuntu) + apt-install cron + ;; + + RedHat) + yum-install cronie + ;; +esac diff --git a/docker/php-official/5.6/conf/provision/service.d/dnsmasq.sh b/docker/php-official/5.6/conf/provision/service.d/dnsmasq.sh new file mode 100644 index 000000000..9e5c3228c --- /dev/null +++ b/docker/php-official/5.6/conf/provision/service.d/dnsmasq.sh @@ -0,0 +1,24 @@ +#!/usr/bin/env bash + +IMAGE_FAMILY=$(docker-image-info family) + +# Installation +case "$IMAGE_FAMILY" in + Debian|Ubuntu) + apt-install dnsmasq + ;; + + RedHat) + yum-install dnsmasq + ;; + + Alpine) + apk-install dnsmasq + ;; +esac + +# Configuration +go-replace --mode=line \ + -s '^[\s]*user[\s]*=' -r 'user = root' \ + -s '^[\s]*conf-dir[\s]*=' -r 'conf-dir = /etc/dnsmasq.d' \ + -- /etc/dnsmasq.conf diff --git a/docker/php-official/5.6/conf/provision/service.d/postfix.sh b/docker/php-official/5.6/conf/provision/service.d/postfix.sh new file mode 100644 index 000000000..ff1879345 --- /dev/null +++ b/docker/php-official/5.6/conf/provision/service.d/postfix.sh @@ -0,0 +1,28 @@ +#!/usr/bin/env bash + +IMAGE_FAMILY=$(docker-image-info family) + +# Installation +case "$IMAGE_FAMILY" in + Debian|Ubuntu) + apt-install postfix + ;; + + RedHat) + yum-install postfix + ;; + + Alpine) + apk-install postfix + ln -s -f /etc/postfix/aliases /etc/aliases + ;; +esac + +# Configuration +go-replace --mode=line \ + -s '^[\s]*mydestination[\s]*=' -r 'mydestination = ' \ + -s '^[\s]*message_size_limit[\s]*=' -r 'message_size_limit = 15240000' \ + -s '^[\s]*smtp_use_tls[\s]*=' -r 'smtp_use_tls = yes' \ + -s '^[\s]*smtp_tls_security_level[\s]*=' -r 'smtp_tls_security_level = may' \ + -s '^[\s]*myhostname[\s]*=' -r '# myhostname' \ + -- /etc/postfix/main.cf diff --git a/docker/php-official/5.6/conf/provision/service.d/ssh.sh b/docker/php-official/5.6/conf/provision/service.d/ssh.sh new file mode 100644 index 000000000..63d7a9f3a --- /dev/null +++ b/docker/php-official/5.6/conf/provision/service.d/ssh.sh @@ -0,0 +1,17 @@ +#!/usr/bin/env bash + +IMAGE_FAMILY=$(docker-image-info family) + +case "$IMAGE_FAMILY" in + Debian|Ubuntu) + apt-install openssh-server + ;; + + RedHat) + yum-install openssh-server + ;; + + Alpine) + apk-install openssh + ;; +esac diff --git a/docker/php-official/5.6/conf/provision/service.d/syslog.sh b/docker/php-official/5.6/conf/provision/service.d/syslog.sh new file mode 100644 index 000000000..7e8b8e0a9 --- /dev/null +++ b/docker/php-official/5.6/conf/provision/service.d/syslog.sh @@ -0,0 +1,41 @@ +#!/usr/bin/env bash + +IMAGE_FAMILY=$(docker-image-info family) + +# Installation +case "$IMAGE_FAMILY" in + Debian|Ubuntu) + apt-install syslog-ng syslog-ng-core + ;; + + RedHat) + yum-install syslog-ng + + # remove logrotate (not needed for docker) + rm -f "/etc/cron.daily/logrotate" + ;; + + Alpine) + apk-install syslog-ng + ;; +esac + +## Configuration +SYSLOG_NG_VERSION=$(syslog-ng --version | grep -E -e '^syslog-ng[ ]+[0-9]+\.[0-9]+' | head -n 1 | awk '{print $2}' | cut -f 1,2 -d .) + +# Disable caps inside container +if [[ -f /etc/default/syslog-ng ]]; then + go-replace --mode=lineinfile \ + -s "SYSLOGNG_OPTS" -r "SYSLOGNG_OPTS = --no-caps" \ + -- /etc/default/syslog-ng +fi + +# Symlink configuration +ln -s -f /opt/docker/etc/syslog-ng/syslog-ng.conf /etc/syslog-ng/syslog-ng.conf + +go-replace --mode=lineinfile \ + -s "@version" -r "@version: ${SYSLOG_NG_VERSION}" \ + -- /etc/syslog-ng/syslog-ng.conf + +# Ensure /var/lib/syslog-ng exists +mkdir -p /var/lib/syslog-ng diff --git a/docker/php-official/5.6/conf/provision/variables-webdevops.yml b/docker/php-official/5.6/conf/provision/variables-webdevops.yml new file mode 100644 index 000000000..0b2a21a95 --- /dev/null +++ b/docker/php-official/5.6/conf/provision/variables-webdevops.yml @@ -0,0 +1,7 @@ +--- + +docker_image_info_family: "{{ lookup('pipe', 'docker-image-info family') }}" +docker_image_info_distribution: "{{ lookup('pipe', 'docker-image-info dist') }}" +docker_image_info_distribution_version: "{{ lookup('pipe', 'docker-image-info dist-version') }}" +docker_image_info_distribution_release: "{{ lookup('pipe', 'docker-image-info dist-release') }}" +docker_image_info_distribution_codename: "{{ lookup('pipe', 'docker-image-info dist-codename') }}" diff --git a/docker/php-official/5.6/conf/provision/variables.yml b/docker/php-official/5.6/conf/provision/variables.yml new file mode 100644 index 000000000..0b2a21a95 --- /dev/null +++ b/docker/php-official/5.6/conf/provision/variables.yml @@ -0,0 +1,7 @@ +--- + +docker_image_info_family: "{{ lookup('pipe', 'docker-image-info family') }}" +docker_image_info_distribution: "{{ lookup('pipe', 'docker-image-info dist') }}" +docker_image_info_distribution_version: "{{ lookup('pipe', 'docker-image-info dist-version') }}" +docker_image_info_distribution_release: "{{ lookup('pipe', 'docker-image-info dist-release') }}" +docker_image_info_distribution_codename: "{{ lookup('pipe', 'docker-image-info dist-codename') }}" diff --git a/docker/php-official/7.0/Dockerfile b/docker/php-official/7.0/Dockerfile new file mode 100644 index 000000000..b2a91f8bc --- /dev/null +++ b/docker/php-official/7.0/Dockerfile @@ -0,0 +1,187 @@ +#+++++++++++++++++++++++++++++++++++++++ +# Dockerfile for webdevops/php-official:7.0 +# -- automatically generated -- +#+++++++++++++++++++++++++++++++++++++++ + +FROM php:7.0-fpm + +LABEL maintainer=info@webdevops.io \ + vendor=WebDevOps.io \ + io.webdevops.layout=8 \ + io.webdevops.version=1.5.0 + +ENV TERM="xterm" \ + LANG="C.UTF-8" \ + LC_ALL="C.UTF-8" +ENV DOCKER_CONF_HOME=/opt/docker/ \ + LOG_STDOUT="" \ + LOG_STDERR="" +ENV APPLICATION_USER=application \ + APPLICATION_GROUP=application \ + APPLICATION_PATH=/app \ + APPLICATION_UID=1000 \ + APPLICATION_GID=1000 + +ADD baselayout.tar / + +COPY conf/ /opt/docker/ + +# Init bootstrap +RUN set -x \ + && apt-update \ + && /usr/local/bin/generate-dockerimage-info \ + # Enable non-free + && sed -ri "s/(deb.*\/debian $(docker-image-info dist-codename) main)/\1 contrib non-free /" -- /etc/apt/sources.list \ + && apt-update \ + # System update + && /usr/local/bin/apt-upgrade \ + # Base stuff + && /usr/local/bin/apt-install \ + apt-transport-https \ + ca-certificates \ + locales \ + # Install gosu + && GOSU_VERSION=1.10 \ + && /usr/local/bin/apt-install wget gnupg dirmngr \ + && dpkgArch="amd64" \ + && wget -O /usr/local/bin/gosu "https://github.com/tianon/gosu/releases/download/$GOSU_VERSION/gosu-$dpkgArch" \ + && wget -O /usr/local/bin/gosu.asc "https://github.com/tianon/gosu/releases/download/$GOSU_VERSION/gosu-$dpkgArch.asc" \ + && export GNUPGHOME="$(mktemp -d)" \ + && gpg --keyserver ha.pool.sks-keyservers.net --recv-keys B42F6819007F00F88E364FD4036A9C25BF357DD4 \ + && gpg --batch --verify /usr/local/bin/gosu.asc /usr/local/bin/gosu \ + && rm -rf "$GNUPGHOME" /usr/local/bin/gosu.asc \ + && chmod +x /usr/local/bin/gosu \ + && gosu nobody true \ + ## Install go-replace + && GOREPLACE_VERSION=0.5.4 \ + && wget -O /usr/local/bin/go-replace https://github.com/webdevops/goreplace/releases/download/$GOREPLACE_VERSION/gr-64-linux \ + && chmod +x /usr/local/bin/go-replace \ + && apt-get purge -y -f --force-yes wget dirmngr \ + && docker-image-cleanup + +# Install ansible +RUN /usr/local/bin/apt-install \ + # Install ansible + python-minimal \ + python-setuptools \ + python-pip \ + python-paramiko \ + python-jinja2 \ + python-dev \ + libffi-dev \ + libssl-dev \ + build-essential \ + && pip install --upgrade pip \ + && hash -r \ + && pip install --no-cache-dir ansible \ + && chmod 750 /usr/local/bin/ansible* \ + # Cleanup + && apt-get purge -y -f --force-yes \ + python-dev \ + build-essential \ + libssl-dev \ + libffi-dev \ + && docker-image-cleanup + +# Install packages +RUN chmod +x /opt/docker/bin/* \ + && /usr/local/bin/apt-install \ + supervisor \ + wget \ + curl \ + net-tools \ + gnupg \ + && chmod +s /usr/local/bin/gosu \ + && /opt/docker/bin/provision run --tag bootstrap --role webdevops-base \ + && /opt/docker/bin/bootstrap.sh \ + && docker-image-cleanup + +# Install services +RUN /usr/local/bin/apt-install \ + # Install common tools + zip \ + unzip \ + bzip2 \ + wget \ + curl \ + net-tools \ + moreutils \ + dnsutils \ + openssh-client \ + rsync \ + git \ + && /usr/local/bin/generate-locales \ + && /opt/docker/bin/provision run --tag bootstrap --role webdevops-base-app \ + && /opt/docker/bin/bootstrap.sh \ + && docker-image-cleanup + +# Install php environment +RUN /usr/local/bin/apt-install \ + # Install tools + imagemagick \ + graphicsmagick \ + ghostscript \ + # Libraries + libldap-2.4-2 \ + libxslt1.1 \ + zlib1g \ + libpng12-0 \ + libmcrypt4 \ + # Dev and headers + libbz2-dev \ + libldap2-dev \ + libldb-dev \ + libmcrypt-dev \ + libxml2-dev \ + libxslt1-dev \ + zlib1g-dev \ + libpng12-dev \ + # Install extensions + && docker-php-ext-install \ + bcmath \ + bz2 \ + calendar \ + exif \ + gettext \ + mysqli \ + mcrypt \ + hash \ + pcntl \ + pdo_mysql \ + soap \ + sockets \ + tokenizer \ + sysvmsg \ + sysvsem \ + sysvshm \ + shmop \ + xsl \ + zip \ + gd \ + gettext \ + opcache \ + # Uninstall dev and header packages + && apt-get purge -y -f --force-yes \ + libbz2-dev \ + libldap2-dev \ + libldb-dev \ + libmcrypt-dev \ + libxml2-dev \ + libxslt1-dev \ + zlib1g-dev \ + libpng12-dev \ + # Install extensions for PHP 7.x + && pecl install apcu redis \ + && echo extension=apcu.so > /usr/local/etc/php/conf.d/apcu.ini \ + && echo extension=redis.so > /usr/local/etc/php/conf.d/redis.ini \ + && rm -f /usr/local/etc/php-fpm.d/zz-docker.conf \ + && curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin/ --filename=composer \ + && /opt/docker/bin/provision run --tag bootstrap --role webdevops-php \ + && /opt/docker/bin/bootstrap.sh \ + && docker-image-cleanup + +WORKDIR / + +EXPOSE 9000 +ENTRYPOINT ["/opt/docker/bin/entrypoint.sh"] +CMD ["supervisord"] diff --git a/docker/php-official/7.0/Dockerfile.jinja2 b/docker/php-official/7.0/Dockerfile.jinja2 new file mode 100644 index 000000000..1292dab71 --- /dev/null +++ b/docker/php-official/7.0/Dockerfile.jinja2 @@ -0,0 +1,25 @@ +{{ docker.fromOfficial("php", "7.0-fpm") }} + +{{ docker.version() }} + +{{ environment.general() }} +{{ environment.base() }} +{{ environment.baseApp() }} + +{{ docker.add('baselayout.tar', '/') }} + +{{ docker.copy('conf/', '/opt/docker/') }} + +{{ bootstrap.debian('jessie') }} + +{{ ansible.debian() }} + +{{ base.debian() }} + +{{ baseapp.debian() }} + +{{ php.official(version='7.0') }} + +{{ docker.expose('9000') }} +{{ docker.entrypoint("/opt/docker/bin/entrypoint.sh") }} +{{ docker.cmd("supervisord") }} diff --git a/docker/php-official/7.0/baselayout.tar b/docker/php-official/7.0/baselayout.tar new file mode 100644 index 000000000..dc5fbe08f Binary files /dev/null and b/docker/php-official/7.0/baselayout.tar differ diff --git a/docker/php-official/7.0/conf/VERSION b/docker/php-official/7.0/conf/VERSION new file mode 100644 index 000000000..301160a93 --- /dev/null +++ b/docker/php-official/7.0/conf/VERSION @@ -0,0 +1 @@ +8 \ No newline at end of file diff --git a/docker/php-official/7.0/conf/bin/bootstrap.sh b/docker/php-official/7.0/conf/bin/bootstrap.sh new file mode 100644 index 000000000..855c10782 --- /dev/null +++ b/docker/php-official/7.0/conf/bin/bootstrap.sh @@ -0,0 +1,72 @@ +#!/usr/bin/env bash + +BOOTSTRAP_MODE="bootstrap" + +if [ -n "$1" ]; then + BOOTSTRAP_MODE="$1" +fi + +set -o pipefail # trace ERR through pipes +set -o errtrace # trace ERR through 'time command' and other functions +set -o nounset ## set -u : exit the script if you try to use an uninitialised variable +set -o errexit ## set -e : exit the script if any statement returns a non-true return value + +source /opt/docker/bin/config.sh + +rootCheck "$0" + +# Save the buildtime +date +%s > /opt/docker/BUILDTIME +date +%s >/opt/docker/etc/.registry/image_info_buildtime + +# Make all scripts executable +find /opt/docker/bin/ -type f -iname '*.sh' -print0 | xargs --no-run-if-empty -0 chmod +x + +# Enable usr-bin executables +find /opt/docker/bin/usr-bin -type f | while read USR_BIN_FILE; do + chmod +x -- "$USR_BIN_FILE" + ln -n -f -- "$USR_BIN_FILE" "/usr/local/bin/$(basename "$USR_BIN_FILE")" +done + +case "$BOOTSTRAP_MODE" in + ################################### + # When container will be build next time + ################################### + "onbuild") + # Init and run bootstrap system + runProvisionOnBuild + ;; + + ################################### + # When container is build this time + ################################### + "bootstrap") + # Init and run bootstrap system + runProvisionBootstrap + runProvisionBuild + ;; + + *) + echo "[ERROR] Bootstrap mode '$BOOTSTRAP_MODE' not defined" + exit 1 + ;; +esac + + +###################### +# Check if entrypoint provisioning is available +###################### + +echo "Checking provision status..." +for PROVISION_TAG in onbuild build bootstrap entrypoint; do + ROLES=$(docker-provision list --tag "$PROVISION_TAG") + if [[ -n "$ROLES" ]]; then + PROVISION_ROLE_COUNT=$(echo "$ROLES" | wc -l) + echo " - found ${PROVISION_ROLE_COUNT} for provision tag ${PROVISION_TAG}, caching info for execution" + echo -n "$PROVISION_ROLE_COUNT" > "/opt/docker/etc/.registry/provision-availale.${PROVISION_TAG}" + else + echo " - no roles found for provision tag ${PROVISION_TAG}" + echo -n '' > "/opt/docker/etc/.registry/provision-availale.${PROVISION_TAG}" + fi +done + diff --git a/docker/php-official/7.0/conf/bin/config.sh b/docker/php-official/7.0/conf/bin/config.sh new file mode 100644 index 000000000..049756c26 --- /dev/null +++ b/docker/php-official/7.0/conf/bin/config.sh @@ -0,0 +1,151 @@ +#!/usr/bin/env bash + +shopt -s nullglob + +### + # Check if current user is root + # + ## +function rootCheck() { + # Root check + if [ "$(/usr/bin/whoami)" != "root" ]; then + echo "[ERROR] $* must be run as root" + exit 1 + fi +} + +### + # Create /docker.stdout and /docker.stderr + # + ## +function createDockerStdoutStderr() { + # link stdout from docker + if [[ -z "$LOG_STDOUT" ]]; then + LOG_STDOUT="/proc/$$/fd/1" + fi + + if [[ -z "$LOG_STDERR" ]]; then + LOG_STDERR="/proc/$$/fd/2" + fi + + ln -f -s "$LOG_STDOUT" /docker.stdout + ln -f -s "$LOG_STDERR" /docker.stderr + chmod 600 /docker.stdout /docker.stderr +} +### + # Include script directory text inside a file + # + # $1 -> path + # + ## +function includeScriptDir() { + if [[ -d "$1" ]]; then + for FILE in "$1"/*.sh; do + # run custom scripts, only once + . "$FILE" + done + fi +} + +### + # Show deprecation notice + # + ## +function deprecationNotice() { + echo "" + echo "###############################################################################" + echo "### THIS CALL IS DEPRECATED AND WILL BE REMOVED IN THE FUTURE" + echo "###" + echo "### $*" + echo "###" + echo "###############################################################################" + echo "" +} + +### + # Run "entrypoint" scripts + ## +function runEntrypoints() { + ############### + # Try to find entrypoint + ############### + + ENTRYPOINT_SCRIPT="/opt/docker/bin/entrypoint.d/${TASK}.sh" + + if [ -f "$ENTRYPOINT_SCRIPT" ]; then + . "$ENTRYPOINT_SCRIPT" + fi + + ############### + # Run default + ############### + if [ -f "/opt/docker/bin/entrypoint.d/default.sh" ]; then + . /opt/docker/bin/entrypoint.d/default.sh + fi + + exit 1 +} + +### + # Run "bootstrap" provisioning + ## +function runProvisionBootstrap() { + for FILE in /opt/docker/provision/bootstrap.d/*.sh; do + # run custom scripts, only once + . "$FILE" + rm -f -- "$FILE" + done + + runDockerProvision bootstrap +} + +### + # Run "build" provisioning + ## +function runProvisionBuild() { + for FILE in /opt/docker/provision/build.d/*.sh; do + # run custom scripts, only once + . "$FILE" + done + + runDockerProvision build +} + +### + # Run "onbuild" provisioning + ## +function runProvisionOnBuild() { + includeScriptDir "/opt/docker/provision/onbuild.d" + + runDockerProvision onbuild +} + +### + # Run "entrypoint" provisioning + ## +function runProvisionEntrypoint() { + includeScriptDir "/opt/docker/provision/entrypoint.d" + includeScriptDir "/entrypoint.d" + + runDockerProvision entrypoint +} + + +### + # Run docker provisioning with dyniamic playbook generation + # + # $1 -> playbook tag (bootstrap, onbuild, entrypoint) + # + ## +function runDockerProvision() { + ANSIBLE_TAG="$1" + + PROVISION_STATS_FILE="/opt/docker/etc/.registry/provision-stats.${ANSIBLE_TAG}" + + # run provision if stats file doesn't exists (unknown mode) + # or if stats file is not empty + if [[ ! -f "$PROVISION_STATS_FILE" ]] || [[ -s "$PROVISION_STATS_FILE" ]]; then + /opt/docker/bin/provision run --tag "${ANSIBLE_TAG}" --use-registry + fi +} + diff --git a/docker/php-official/7.0/conf/bin/control.sh b/docker/php-official/7.0/conf/bin/control.sh new file mode 100644 index 000000000..22d189745 --- /dev/null +++ b/docker/php-official/7.0/conf/bin/control.sh @@ -0,0 +1,160 @@ +#!/usr/bin/env bash + +set -o pipefail # trace ERR through pipes +set -o errtrace # trace ERR through 'time command' and other functions +set -o nounset ## set -u : exit the script if you try to use an uninitialised variable +set -o errexit ## set -e : exit the script if any statement returns a non-true return value + +source /opt/docker/bin/config.sh + +rootCheck "$0" + +CONTROL_COMMAND="$1" +shift + +case "$CONTROL_COMMAND" in + + ## ------------------------------------------ + ## PROVISION + ## ------------------------------------------ + + ## main roles + "provision.role") + deprecationNotice " Please use >>/opt/docker/bin/provision add --tag bootstrap --tag build --tag onbuild [role]<< for adding provision roles" + /opt/docker/bin/provision add --tag bootstrap --tag build --tag onbuild --tag entrypoint "$1" + ;; + + "provision.role.bootstrap") + deprecationNotice " Please use >>/opt/docker/bin/provision add --tag bootstrap [role]<< for adding provision roles" + /opt/docker/bin/provision add --tag bootstrap "$1" + ;; + + "provision.role.build") + deprecationNotice " Please use >>/opt/docker/bin/provision add --tag build [role]<< for adding provision roles" + /opt/docker/bin/provision add --tag build "$1" + ;; + + "provision.role.onbuild") + deprecationNotice " Please use >>/opt/docker/bin/provision add --tag onbuild [role]<< for adding provision roles" + /opt/docker/bin/provision add --tag onbuild "$1" + ;; + + "provision.role.entrypoint") + deprecationNotice " Please use >>/opt/docker/bin/provision add --tag entrypoint [role]<< for adding provision roles" + /opt/docker/bin/provision add --tag entrypoint "$1" + ;; + + ## startup roles + "provision.role.startup") + deprecationNotice " Please use >>/opt/docker/bin/provision add --tag bootstrap --tag build --tag onbuild --priority 50 [role]<< for adding provision roles" + /opt/docker/bin/provision add --tag bootstrap --tag build --tag onbuild --tag entrypoint --priority 50 "$1" + ;; + + "provision.role.startup.bootstrap") + deprecationNotice " Please use >>/opt/docker/bin/provision add --tag bootstrap --priority 50 [role]<< for adding provision roles" + /opt/docker/bin/provision add --tag bootstrap --priority 50 "$1" + ;; + + "provision.role.startup.build") + deprecationNotice " Please use >>/opt/docker/bin/provision add --tag build --priority 50 [role]<< for adding provision roles" + /opt/docker/bin/provision add --tag build --priority 50 "$1" + ;; + + "provision.role.startup.onbuild") + deprecationNotice " Please use >>/opt/docker/bin/provision add --tag onbuild --priority 50 [role]<< for adding provision roles" + /opt/docker/bin/provision add --tag onbuild --priority 50 "$1" + ;; + + "provision.role.startup.entrypoint") + deprecationNotice " Please use >>/opt/docker/bin/provision add --tag entrypoint --priority 50 [role]<< for adding provision roles" + /opt/docker/bin/provision add --tag entrypoint --priority 50 "$1" + ;; + + ## finish roles + "provision.role.finish") + deprecationNotice " Please use >>/opt/docker/bin/provision add --tag bootstrap --tag build --tag onbuild --priority 200 [role]<< for adding provision roles" + /opt/docker/bin/provision add --tag bootstrap --tag build --tag onbuild --tag entrypoint --priority 200 "$1" + ;; + + "provision.role.finish.bootstrap") + deprecationNotice " Please use >>/opt/docker/bin/provision add --tag bootstrap --priority 200 [role]<< for adding provision roles" + /opt/docker/bin/provision add --tag bootstrap --priority 200 "$1" + ;; + + "provision.role.finish.build") + deprecationNotice " Please use >>/opt/docker/bin/provision add --tag build --priority 200 [role]<< for adding provision roles" + /opt/docker/bin/provision add --tag build --priority 200 "$1" + ;; + + "provision.role.finish.onbuild") + deprecationNotice " Please use >>/opt/docker/bin/provision add --tag onbuild --priority 200 [role]<< for adding provision roles" + /opt/docker/bin/provision add --tag onbuild --priority 200 "$1" + ;; + + "provision.role.finish.entrypoint") + deprecationNotice " Please use >>/opt/docker/bin/provision add --tag entrypoint --priority 200 [role]<< for adding provision roles" + /opt/docker/bin/provision add --tag entrypoint --priority 200 "$1" + ;; + + ## ------------------------------------------ + ## Service + ## ------------------------------------------ + + "service.enable") + deprecationNotice " Please use >>docker-service-enable [service]<<" + docker-service-enable "$1" + ;; + + "service.disable") + deprecationNotice " Please use >>docker-service-disable [service]<<" + docker-service-disable "$1" + ;; + + ## ------------------------------------------ + ## Version + ## ------------------------------------------ + + "version.get") + cat /opt/docker/VERSION + ;; + + "version.require.min") + EXPECTED_VERSION="$1" + CURRENT_VERSION="$(cat /opt/docker/VERSION)" + if [ "$CURRENT_VERSION" -lt "$EXPECTED_VERSION" ]; then + echo "-----------------------------------------------------------" + echo "--- This docker image is not up2date!" + echo "--- " + echo "--- Version expected min: $EXPECTED_VERSION" + echo "--- Version current: $CURRENT_VERSION" + echo "--- " + echo "--- Run 'docker pull ' to update image" + echo "-----------------------------------------------------------" + exit 1 + fi + ;; + + "version.require.max") + EXPECTED_VERSION="$1" + CURRENT_VERSION="$(cat /opt/docker/VERSION)" + if [ "$CURRENT_VERSION" -gt "$EXPECTED_VERSION" ]; then + echo "-----------------------------------------------------------" + echo "--- This docker image is too new!" + echo "--- " + echo "--- Version expected max: $EXPECTED_VERSION" + echo "--- Version current: $CURRENT_VERSION" + echo "-----------------------------------------------------------" + exit 1 + fi + ;; + + + "buildtime.get") + cat /opt/docker/BUILDTIME + ;; + + *) + echo "[ERROR] Invalid controll command: \"${CONTROL_COMMAND}\"" + exit 1 + ;; +esac diff --git a/docker/php-official/7.0/conf/bin/entrypoint.d/cli.sh b/docker/php-official/7.0/conf/bin/entrypoint.d/cli.sh new file mode 100644 index 000000000..fe212a8ea --- /dev/null +++ b/docker/php-official/7.0/conf/bin/entrypoint.d/cli.sh @@ -0,0 +1,19 @@ +#!/usr/bin/env bash + +############################################# +## Run CLI_SCRIPT from environment variable +############################################# + +if [ -n "${CLI_SCRIPT}" ]; then + if [ -n "$APPLICATION_USER" ]; then + # Run as EFFECTIVE_USER + shift + exec gosu "${APPLICATION_USER}" ${CLI_SCRIPT} "$@" + else + # Run as root + exec ${CLI_SCRIPT} "$@" + fi +else + echo "[ERROR] No CLI_SCRIPT in in docker environment defined" + exit 1 +fi diff --git a/docker/php-official/7.0/conf/bin/entrypoint.d/default.sh b/docker/php-official/7.0/conf/bin/entrypoint.d/default.sh new file mode 100644 index 000000000..a1be715fe --- /dev/null +++ b/docker/php-official/7.0/conf/bin/entrypoint.d/default.sh @@ -0,0 +1,3 @@ +#!/usr/bin/env bash + +exec "$@" diff --git a/docker/php-official/7.0/conf/bin/entrypoint.d/noop.sh b/docker/php-official/7.0/conf/bin/entrypoint.d/noop.sh new file mode 100644 index 000000000..092d55d8b --- /dev/null +++ b/docker/php-official/7.0/conf/bin/entrypoint.d/noop.sh @@ -0,0 +1,7 @@ +#!/usr/bin/env bash + +############################################# +## NOOP (no operation) +############################################# + +exec tail -f /dev/null diff --git a/docker/php-official/7.0/conf/bin/entrypoint.d/root.sh b/docker/php-official/7.0/conf/bin/entrypoint.d/root.sh new file mode 100644 index 000000000..6fa0d063e --- /dev/null +++ b/docker/php-official/7.0/conf/bin/entrypoint.d/root.sh @@ -0,0 +1,14 @@ +#!/usr/bin/env bash + +############################################# +## Root shell +############################################# + +if [ "$#" -eq 1 ]; then + ## No command, fall back to interactive shell + exec bash +else + ## Exec root command + shift + exec "$@" +fi diff --git a/docker/php-official/7.0/conf/bin/entrypoint.d/supervisord.sh b/docker/php-official/7.0/conf/bin/entrypoint.d/supervisord.sh new file mode 100644 index 000000000..f21489667 --- /dev/null +++ b/docker/php-official/7.0/conf/bin/entrypoint.d/supervisord.sh @@ -0,0 +1,9 @@ +#!/usr/bin/env bash + +############################################# +## Supervisord (start daemons) +############################################# + +## Start services +exec /opt/docker/bin/service.d/supervisor.sh + diff --git a/docker/php-official/7.0/conf/bin/entrypoint.sh b/docker/php-official/7.0/conf/bin/entrypoint.sh new file mode 100644 index 000000000..01f59660c --- /dev/null +++ b/docker/php-official/7.0/conf/bin/entrypoint.sh @@ -0,0 +1,46 @@ +#!/usr/bin/env bash + +if [[ -z "$CONTAINER_UID" ]]; then + export CONTAINER_UID="application" +fi + +set -o pipefail # trace ERR through pipes +set -o errtrace # trace ERR through 'time command' and other functions +set -o nounset ## set -u : exit the script if you try to use an uninitialised variable +set -o errexit ## set -e : exit the script if any statement returns a non-true return value + +# auto elevate privileges (if container is not started as root) +if [[ "$UID" -ne 0 ]]; then + export CONTAINER_UID="$UID" + exec gosu root "$0" "$@" +fi +# remove suid bit on gosu +chmod -s /usr/local/bin/gosu + +trap 'echo sigterm ; exit' SIGTERM +trap 'echo sigkill ; exit' SIGKILL + +# sanitize input and set task +TASK="$(echo $1| sed 's/[^-_a-zA-Z0-9]*//g')" + +source /opt/docker/bin/config.sh + +createDockerStdoutStderr + +if [[ "$UID" -eq 0 ]]; then + # Only run provision if user is root + + if [ "$TASK" == "supervisord" -o "$TASK" == "noop" ]; then + # Visible provisioning + runProvisionEntrypoint + else + # Hidden provisioning + runProvisionEntrypoint > /dev/null + fi +fi + +############################# +## COMMAND +############################# + +runEntrypoints "$@" diff --git a/docker/php-official/7.0/conf/bin/provision b/docker/php-official/7.0/conf/bin/provision new file mode 100755 index 000000000..d367c2812 --- /dev/null +++ b/docker/php-official/7.0/conf/bin/provision @@ -0,0 +1,328 @@ +#!/usr/bin/env python + +import os +import argparse +import json +import sys +from string import Template +from subprocess import call +import tempfile +import time + +STORAGE = '/opt/docker/etc/.registry/provision.json' +PROVISION_DIR = '/opt/docker/provision/' + +PLAYBOOK_TAGS=['bootstrap', 'build', 'onbuild', 'entrypoint'] + +PLAYBOOK = Template( +"""--- + +- hosts: all + vars_files: + - ./variables-webdevops.yml + - ./variables.yml + roles: + - $roles +""") + + + +def readJson(): + ret = {} + + # create registry directory if it doesn't exists + if not os.path.exists(os.path.dirname(STORAGE)): + os.mkdir(os.path.dirname(STORAGE)) + + # try to read file + if os.path.isfile(STORAGE): + f=open(STORAGE).read() + ret = json.loads(f) + + return ret + + + +def saveJson(data): + with open(STORAGE, 'w') as f: + json.dump(data, f) + + + +def buildRoleList(tags): + json = readJson() + roleList = {} + + # fetch roles list for each tag + for tag in tags: + if tag in json: + for role in json[tag]: + roleRow = json[tag][role] + if role not in roleList: + roleList[role] = {} + + if 'tags' not in roleList[role]: + roleList[role]['tags'] = {} + + roleList[role]['role'] = role + roleList[role]['added'] = roleRow['added'] + roleList[role]['priority'] = roleRow['priority'] + roleList[role]['tags'][tag] = tag + + return roleList + + +def buildSortedRoleList(tags): + roleList = buildRoleList(tags) + + # sort list + roleList = sorted(roleList, key=lambda x: (roleList[x]['priority'], roleList[x]['added'])) + + return roleList + + + +def buildPlaybook(roleList): + ## build playbook + ret = PLAYBOOK.substitute( + roles = "\n - ".join(roleList) + ) + + return ret + + +def buildPlaybookFromArgs(args): + roleList = [] + + ## add roles from tag (if use registry is active) + if args.useRegistry and args.tags: + roleList.extend(buildSortedRoleList(args.tags)) + + ## add roles from command arguments + if args.roles: + for role in args.roles: + roleList.extend(role.split(',')) + + if roleList: + return buildPlaybook(roleList) + else: + return False + + + +def actionRun(args): + if args.playbook: + ## predefined playbook + playbook = args.playbook + else: + ## dynamic playbook + playbookContent = buildPlaybookFromArgs(args) + + if playbookContent: + f = tempfile.NamedTemporaryFile(dir=PROVISION_DIR, prefix='playbook.', suffix='.yml', delete=False) + f.write(playbookContent) + f.close() + playbook = f.name + else: + ## nothing to do + sys.exit(0) + + ## build ansible command with args + cmd = [ + 'ansible-playbook', + playbook, + '-i', 'localhost,', + '--connection=local', + ] + + if args.tags: + cmd.extend([ + '--tags=' + ','.join(args.tags) + ]) + + if args.args: + cmd.extend(args.args) + + ## run ansible + retval = call(cmd) + + ## cleanup dynamic playbook + if not args.playbook: + os.unlink(playbook) + + sys.exit(retval) + + + +def actionPlaybook(args): + playbook = buildPlaybookFromArgs(args) + + if playbook: + print playbook + else: + sys.exit(1) + + + +def actionList(args): + json = readJson() + list = {} + + for tag in args.tags: + if tag in json: + for role in json[tag]: + print role + + + +def actionAdd(args): + json = readJson() + + for tag in args.tags: + for role in args.role: + if tag not in json: + json[tag] = {} + + json[tag][role] = { + 'name': role, + 'added': int(time.time()), + 'priority': args.priority + } + + saveJson(json) + + + +def actionSummary(args): + # list all roles in each possible tag + for tag in PLAYBOOK_TAGS: + roleList = buildRoleList([tag]) + if roleList: + maxLength = len(max(roleList.keys(), key=len)) + + print "Roles in " + tag + ":" + for role in roleList: + print ' - ' + role.ljust(maxLength, ' ') + ' [priority: ' + str(roleList[role]['priority']) + ']' + print '' + + + +def main(args): + actions = { + 'list': actionList, + 'add': actionAdd, + 'summary': actionSummary, + 'playbook': actionPlaybook, + 'run': actionRun + } + + func = actions.get(args.action, lambda: "nothing") + return func(args) + + + + +if __name__ == '__main__': + parser = argparse.ArgumentParser() + subparsers = parser.add_subparsers( + title='subcommands', + dest='action' + ) + + ################################### + ## SUMMARY command + summary = subparsers.add_parser('summary') + + ################################### + ## RUN command + run = subparsers.add_parser('run') + run.add_argument( + '--tag', + dest='tags', + choices=PLAYBOOK_TAGS, + required=True, + action='append', + help='Ansible tag' + ) + run.add_argument( + '--playbook', + dest='playbook', + help='Ansible playbook' + ) + run.add_argument( + '--use-registry', + dest='useRegistry', + action='store_true', + help='Use registred roles' + ) + run.add_argument( + '--role', + dest='roles', + action='append', + help='Ansible role' + ) + run.add_argument('args', nargs=argparse.REMAINDER) + + ################################### + ## PLAYBOOK command + playbook = subparsers.add_parser('playbook') + playbook.add_argument( + '--tag', + dest='tags', + choices=PLAYBOOK_TAGS, + required=True, + action='append', + help='Ansible tag' + ) + playbook.add_argument( + '--use-registry', + dest='useRegistry', + action='store_true', + help='Use registred roles' + ) + playbook.add_argument( + '--role', + dest='roles', + action='append', + help='Ansible tag' + ) + playbook.add_argument('args', nargs=argparse.REMAINDER) + + ################################### + ## LIST command + list = subparsers.add_parser('list') + list.add_argument( + '--tag', + dest='tags', + choices=PLAYBOOK_TAGS, + required=True, + action='append', + help='Ansible tag' + ) + list.add_argument('args', nargs=argparse.REMAINDER) + + ################################### + ## ADD command + add = subparsers.add_parser('add') + add.add_argument( + '--tag', + dest='tags', + choices=PLAYBOOK_TAGS, + required=True, + action='append', + help='Ansible tag' + ) + add.add_argument( + '--priority', + type=int, + default=100, + dest='priority', + help='Priority for role [default 100, 1 is most important]' + ) + add.add_argument('role', metavar='roles', nargs='+', help='Ansible roles') + + add.add_argument('args', nargs=argparse.REMAINDER) + + ## Execute + args = parser.parse_args() + main(args) diff --git a/docker/php-official/7.0/conf/bin/service.d/cron.d/10-init.sh b/docker/php-official/7.0/conf/bin/service.d/cron.d/10-init.sh new file mode 100644 index 000000000..fdffa2a0f --- /dev/null +++ b/docker/php-official/7.0/conf/bin/service.d/cron.d/10-init.sh @@ -0,0 +1 @@ +# placeholder diff --git a/docker/php-official/7.0/conf/bin/service.d/cron.sh b/docker/php-official/7.0/conf/bin/service.d/cron.sh new file mode 100644 index 000000000..9bf7c10bf --- /dev/null +++ b/docker/php-official/7.0/conf/bin/service.d/cron.sh @@ -0,0 +1,7 @@ +#!/usr/bin/env bash + +source /opt/docker/bin/config.sh + +includeScriptDir "/opt/docker/bin/service.d/cron.d/" + +exec /usr/sbin/cron -f diff --git a/docker/php-official/7.0/conf/bin/service.d/dnsmasq.d/10-init.sh b/docker/php-official/7.0/conf/bin/service.d/dnsmasq.d/10-init.sh new file mode 100644 index 000000000..03baba08f --- /dev/null +++ b/docker/php-official/7.0/conf/bin/service.d/dnsmasq.d/10-init.sh @@ -0,0 +1,32 @@ +# Create dnsmasq.d directory if not exists +mkdir -p -- /etc/dnsmasq.d/ + +## clear dns file +echo > /etc/dnsmasq.d/webdevops + +if [ ! -f /etc/resolv.conf.original ]; then + cp -a /etc/resolv.conf /etc/resolv.conf.original + + ## set forward servers + cat /etc/resolv.conf.original | grep nameserver | sed 's/nameserver /server=/' > /etc/dnsmasq.d/forward + + ## set dnsmasq to main nameserver + echo "nameserver 127.0.0.1" > /etc/resolv.conf +fi + + +# Add own VIRTUAL_HOST as loopback +if [[ -n "${VIRTUAL_HOST+x}" ]]; then + # split comma by space + VIRTUAL_HOST_LIST=${VIRTUAL_HOST//,/$'\n'} + + # replace *.domain for dns specific .domain wildcard + VIRTUAL_HOST_LIST=${VIRTUAL_HOST_LIST/\*./.} + + # no support for .* + VIRTUAL_HOST_LIST=${VIRTUAL_HOST_LIST/.\*/.} + + for DOMAIN in $VIRTUAL_HOST_LIST; do + echo "address=/${DOMAIN}/127.0.0.1" >> /etc/dnsmasq.d/webdevops + done +fi diff --git a/docker/php-official/7.0/conf/bin/service.d/dnsmasq.sh b/docker/php-official/7.0/conf/bin/service.d/dnsmasq.sh new file mode 100644 index 000000000..d16b1acbc --- /dev/null +++ b/docker/php-official/7.0/conf/bin/service.d/dnsmasq.sh @@ -0,0 +1,7 @@ +#!/usr/bin/env bash + +source /opt/docker/bin/config.sh + +includeScriptDir "/opt/docker/bin/service.d/dnsmasq.d/" + +exec dnsmasq --keep-in-foreground diff --git a/docker/php/alpine-3/conf/bin/service.d/php-fpm.d/10-init.sh b/docker/php-official/7.0/conf/bin/service.d/php-fpm.d/10-init.sh similarity index 100% rename from docker/php/alpine-3/conf/bin/service.d/php-fpm.d/10-init.sh rename to docker/php-official/7.0/conf/bin/service.d/php-fpm.d/10-init.sh diff --git a/docker/php-official/7.0/conf/bin/service.d/php-fpm.d/11-clear-env.sh b/docker/php-official/7.0/conf/bin/service.d/php-fpm.d/11-clear-env.sh new file mode 100644 index 000000000..ef6fd4016 --- /dev/null +++ b/docker/php-official/7.0/conf/bin/service.d/php-fpm.d/11-clear-env.sh @@ -0,0 +1,38 @@ +# +# Workaround for old php-fpm versions which don't have clear_env setting +# + +VARIABLE_LIST="; Workaround for missing clear_env feature in PHP-FPM" + +# For each exported variable +for envVariable in $(printenv|cut -f1 -d=); do + + case "$envVariable" in + "_"|"PATH"|"PWD") + ## ignore this variables + ;; + + *) + ## get content of variable + envVariableContent="${!envVariable}" + + ## php-fpm requires that env variable has to be filled with content + if [[ -n "$envVariableContent" ]]; then + ## quote quotes + envVariableContent=${envVariableContent//\"/\\\"} + + ## add to list + VARIABLE_LIST="${VARIABLE_LIST}"$'\n'"env[${envVariable}] = \"${envVariableContent}\"" + fi + ;; + esac + +done + +# Replace ;#CLEAR_ENV_WORKAROUND# with environment variable list for all php-fpm pool files +go-replace \ + -s ";#CLEAR_ENV_WORKAROUND#" -r "$VARIABLE_LIST" \ + --path=/opt/docker/etc/php/fpm/pool.d/ \ + --path-pattern='*.conf' \ + --ignore-empty + diff --git a/docker/php-official/7.0/conf/bin/service.d/php-fpm.sh b/docker/php-official/7.0/conf/bin/service.d/php-fpm.sh new file mode 100644 index 000000000..b25983bd3 --- /dev/null +++ b/docker/php-official/7.0/conf/bin/service.d/php-fpm.sh @@ -0,0 +1,7 @@ +#!/usr/bin/env bash + +source /opt/docker/bin/config.sh + +includeScriptDir "/opt/docker/bin/service.d/php-fpm.d/" + +exec /usr/local/bin/php-fpm --nodaemonize diff --git a/docker/php-official/7.0/conf/bin/service.d/postfix.d/10-init.sh b/docker/php-official/7.0/conf/bin/service.d/postfix.d/10-init.sh new file mode 100644 index 000000000..cfd876955 --- /dev/null +++ b/docker/php-official/7.0/conf/bin/service.d/postfix.d/10-init.sh @@ -0,0 +1,27 @@ +# force new copy of hosts there (otherwise links could be outdated) +mkdir -p /var/spool/postfix/etc +cp -f /etc/hosts /var/spool/postfix/etc/hosts +cp -f /etc/resolv.conf /var/spool/postfix/etc/resolv.conf +cp -f /etc/services /var/spool/postfix/etc/services + +## MYHOSTNAME +# replace line +sed -i '/myhostname[ ]* =/c\' main.cf +echo "myhostname = $(hostname)" >> /etc/postfix/main.cf + +## REPLAYHOST +if [[ -n "${POSTFIX_RELAYHOST+x}" ]]; then + # replace line + sed -i '/relayhost[ ]* =/c\' main.cf + echo "relayhost = $POSTFIX_RELAYHOST" >> /etc/postfix/main.cf +fi + +## MYNETWORKS +if [[ -n "${POSTFIX_MYNETWORKS+x}" ]]; then + # replace line + sed -i '/mynetworks[ ]* =/c\' main.cf + echo "mynetworks = $POSTFIX_MYNETWORKS" >> /etc/postfix/main.cf +fi + +# generate aliases db +newaliases || : diff --git a/docker/php-official/7.0/conf/bin/service.d/postfix.sh b/docker/php-official/7.0/conf/bin/service.d/postfix.sh new file mode 100644 index 000000000..3ab608679 --- /dev/null +++ b/docker/php-official/7.0/conf/bin/service.d/postfix.sh @@ -0,0 +1,37 @@ +#!/usr/bin/env bash +# postfix-wrapper.sh, version 0.1.0 +# +# You cannot start postfix in some foreground mode and +# it's more or less important that docker doesn't kill +# postfix and its chilren if you stop the container. +# +# Use this script with supervisord and it will take +# care about starting and stopping postfix correctly. +# +# supervisord config snippet for postfix-wrapper: +# +# [program:postfix] +# process_name = postfix +# command = /path/to/postfix-wrapper.sh +# startsecs = 0 +# autorestart = false +# + +source /opt/docker/bin/config.sh + +trap "postfix stop" SIGINT +trap "postfix stop" SIGTERM +trap "postfix reload" SIGHUP + +includeScriptDir "/opt/docker/bin/service.d/postfix.d/" + +# start postfix +postfix start + +# lets give postfix some time to start +sleep 3 + +# wait until postfix is dead (triggered by trap) +while kill -0 "$(cat /var/spool/postfix/pid/master.pid)"; do + sleep 5 +done diff --git a/docker/php-official/7.0/conf/bin/service.d/ssh.d/10-init.sh b/docker/php-official/7.0/conf/bin/service.d/ssh.d/10-init.sh new file mode 100644 index 000000000..f2b600312 --- /dev/null +++ b/docker/php-official/7.0/conf/bin/service.d/ssh.d/10-init.sh @@ -0,0 +1,7 @@ +# Init ssh privilege separation directory +mkdir -p /var/run/sshd +chown root:root /var/run/sshd +chmod 755 /var/run/sshd + +# generate host keys +ssh-keygen -A diff --git a/docker/php-official/7.0/conf/bin/service.d/ssh.sh b/docker/php-official/7.0/conf/bin/service.d/ssh.sh new file mode 100644 index 000000000..ad855563f --- /dev/null +++ b/docker/php-official/7.0/conf/bin/service.d/ssh.sh @@ -0,0 +1,7 @@ +#!/usr/bin/env bash + +source /opt/docker/bin/config.sh + +includeScriptDir "/opt/docker/bin/service.d/ssh.d/" + +exec /usr/sbin/sshd -D diff --git a/docker/php-official/7.0/conf/bin/service.d/supervisor.d/10-init.sh b/docker/php-official/7.0/conf/bin/service.d/supervisor.d/10-init.sh new file mode 100644 index 000000000..fdffa2a0f --- /dev/null +++ b/docker/php-official/7.0/conf/bin/service.d/supervisor.d/10-init.sh @@ -0,0 +1 @@ +# placeholder diff --git a/docker/php-official/7.0/conf/bin/service.d/supervisor.sh b/docker/php-official/7.0/conf/bin/service.d/supervisor.sh new file mode 100644 index 000000000..b1741955a --- /dev/null +++ b/docker/php-official/7.0/conf/bin/service.d/supervisor.sh @@ -0,0 +1,7 @@ +#!/usr/bin/env bash + +source /opt/docker/bin/config.sh + +includeScriptDir "/opt/docker/bin/service.d/supervisor.d/" + +exec supervisord -c /opt/docker/etc/supervisor.conf --logfile /dev/null --pidfile /dev/null --user root diff --git a/docker/php-official/7.0/conf/bin/service.d/syslog-ng.d/10-init.sh b/docker/php-official/7.0/conf/bin/service.d/syslog-ng.d/10-init.sh new file mode 100644 index 000000000..326207e52 --- /dev/null +++ b/docker/php-official/7.0/conf/bin/service.d/syslog-ng.d/10-init.sh @@ -0,0 +1,10 @@ +# If /dev/log is either a named pipe or it was placed there accidentally, +# e.g. because of the issue documented at https://github.com/phusion/baseimage-docker/pull/25, +# then we remove it. +if [ ! -S /dev/log ]; then rm -f /dev/log; fi +if [ ! -S /var/lib/syslog-ng/syslog-ng.ctl ]; then rm -f /var/lib/syslog-ng/syslog-ng.ctl; fi + +if [[ ! -p /docker.stdout ]]; then + # Switch to file (tty docker mode) + go-replace -s 'pipe("/docker.stdout")' -r 'file("/docker.stdout")' -- /opt/docker/etc/syslog-ng/syslog-ng.conf +fi diff --git a/docker/php-official/7.0/conf/bin/service.d/syslog-ng.sh b/docker/php-official/7.0/conf/bin/service.d/syslog-ng.sh new file mode 100644 index 000000000..09d1730ba --- /dev/null +++ b/docker/php-official/7.0/conf/bin/service.d/syslog-ng.sh @@ -0,0 +1,8 @@ +#!/usr/bin/env bash +set -e + +source /opt/docker/bin/config.sh + +includeScriptDir "/opt/docker/bin/service.d/syslog-ng.d/" + +exec syslog-ng -F --no-caps -p /var/run/syslog-ng.pid $SYSLOGNG_OPTS diff --git a/docker/php-official/7.0/conf/bin/usr-bin/docker-provision b/docker/php-official/7.0/conf/bin/usr-bin/docker-provision new file mode 100644 index 000000000..4ee715c64 --- /dev/null +++ b/docker/php-official/7.0/conf/bin/usr-bin/docker-provision @@ -0,0 +1,9 @@ +#!/usr/bin/env bash + +set -o pipefail # trace ERR through pipes +set -o errtrace # trace ERR through 'time command' and other functions +set -o nounset ## set -u : exit the script if you try to use an uninitialised variable +set -o errexit ## set -e : exit the script if any statement returns a non-true return value + +# wrapper +exec /opt/docker/bin/provision "$@" diff --git a/docker/php-official/7.0/conf/bin/usr-bin/docker-service-disable b/docker/php-official/7.0/conf/bin/usr-bin/docker-service-disable new file mode 100644 index 000000000..2b5b31bb4 --- /dev/null +++ b/docker/php-official/7.0/conf/bin/usr-bin/docker-service-disable @@ -0,0 +1,30 @@ +#!/usr/bin/env bash + +set -o pipefail # trace ERR through pipes +set -o errtrace # trace ERR through 'time command' and other functions +set -o nounset ## set -u : exit the script if you try to use an uninitialised variable +set -o errexit ## set -e : exit the script if any statement returns a non-true return value + +source /opt/docker/bin/config.sh + +rootCheck "$0" + +if [[ "$#" -eq 0 ]]; then + echo "Usage: $0 " + exit 1 +fi + +for SERVICE in "$@"; do + SERVICE_FILE="/opt/docker/etc/supervisor.d/${SERVICE}.conf" + + ## Disable service + if [[ -f "$SERVICE_FILE" ]]; then + go-replace --mode=lineinfile \ + -s 'autostart =' -r 'autostart = false' \ + -- "$SERVICE_FILE" + else + echo "[ERROR] Service '${SERVICE}' not found (tried ${SERVICE_FILE})" + exit 1 + fi +done + diff --git a/docker/php-official/7.0/conf/bin/usr-bin/docker-service-enable b/docker/php-official/7.0/conf/bin/usr-bin/docker-service-enable new file mode 100644 index 000000000..8d36a14a9 --- /dev/null +++ b/docker/php-official/7.0/conf/bin/usr-bin/docker-service-enable @@ -0,0 +1,41 @@ +#!/usr/bin/env bash + +set -o pipefail # trace ERR through pipes +set -o errtrace # trace ERR through 'time command' and other functions +set -o nounset ## set -u : exit the script if you try to use an uninitialised variable +set -o errexit ## set -e : exit the script if any statement returns a non-true return value + +source /opt/docker/bin/config.sh + +rootCheck "$0" + +if [[ "$#" -eq 0 ]]; then + echo "Usage: $0 " + exit 1 +fi + +for SERVICE in "$@"; do + SERVICE_FILE="/opt/docker/etc/supervisor.d/${SERVICE}.conf" + PROVISION_FILE="/opt/docker/provision/service.d/${SERVICE}.sh" + + # Run on demand installation/provisioning + if [[ -f "$PROVISION_FILE" ]]; then + echo "Running provisioning for ${SERVICE}, please wait..." + + ## execute scripts + . "$PROVISION_FILE" + + ## remove directory (one run time) + rm -f -- "$PROVISION_FILE" + fi + + ## Enable service + if [[ -f "$SERVICE_FILE" ]]; then + go-replace --mode=lineinfile \ + -s 'autostart =' -r 'autostart = true' \ + -- "$SERVICE_FILE" + else + echo "[ERROR] Service '${SERVICE}' not found (tried ${SERVICE_FILE})" + exit 1 + fi +done diff --git a/docker/php-official/7.0/conf/bin/usr-bin/service b/docker/php-official/7.0/conf/bin/usr-bin/service new file mode 100755 index 000000000..55ea12bf7 --- /dev/null +++ b/docker/php-official/7.0/conf/bin/usr-bin/service @@ -0,0 +1,86 @@ +#!/bin/bash + +set -o pipefail # trace ERR through pipes +set -o errtrace # trace ERR through 'time command' and other functions +set -o nounset ## set -u : exit the script if you try to use an uninitialised variable +set -o errexit ## set -e : exit the script if any statement returns a non-true return value + +# Root check +if [ "$(/usr/bin/whoami)" != "root" ]; then + echo "[ERROR] Must be run as root" + exit 1 +fi + +function serviceHelp() { + echo "Usage: $(basename "$0") " +} + +function getServicePid() { + local serviceName="$1" + local servicePid=$(supervisorctl pid "${serviceName}:${serviceName}d") + + if [[ -z "$servicePid" ]] || [[ "$servicePid" == "0" ]]; then + echo "not running" + exit 1 + fi + + echo $servicePid +} + +# Param check +if [ "$#" -lt 2 ]; then + echo "[ERROR] Missing parameters" + serviceHelp + exit 1 +fi + +############################# +# Param init +############################# + +SERVICENAME="$1" +ACTION="$2" + +############################# +# Service aliases +############################# +case "$SERVICENAME" in + apache2|httpd) + SERVICENAME="apache" + ;; +esac + +############################# +# Action runner +############################# +case "$ACTION" in + stop|start|restart|status) + exec supervisorctl "$ACTION" "${SERVICENAME}:${SERVICENAME}d" + ;; + + pid) + echo $(getServicePid "${SERVICENAME}") + ;; + + check) + FIRST_PID=$(getServicePid "${SERVICENAME}") + sleep 5 + SECOND_PID=$(getServicePid "${SERVICENAME}") + + if [[ "$FIRST_PID" == "$SECOND_PID" ]]; then + echo "ok" + exit 0 + else + echo "not running" + exit 1 + fi + ;; + + + *) + echo "[ERROR] Invalid action" + serviceHelp + exit 1 + ;; + +esac diff --git a/docker/php/alpine-3/conf/etc/logrotate.d/php5-fpm b/docker/php-official/7.0/conf/etc/logrotate.d/php5-fpm similarity index 100% rename from docker/php/alpine-3/conf/etc/logrotate.d/php5-fpm rename to docker/php-official/7.0/conf/etc/logrotate.d/php5-fpm diff --git a/docker/php-official/7.0/conf/etc/logrotate.d/syslog-ng b/docker/php-official/7.0/conf/etc/logrotate.d/syslog-ng new file mode 100644 index 000000000..4a6f9c54e --- /dev/null +++ b/docker/php-official/7.0/conf/etc/logrotate.d/syslog-ng @@ -0,0 +1,38 @@ +/var/log/syslog +{ + rotate 7 + daily + missingok + notifempty + delaycompress + compress + postrotate + /bin/kill -HUP `cat /var/run/syslog-ng.pid 2> /dev/null` > /dev/null + endscript +} + +/var/log/mail.info +/var/log/mail.warn +/var/log/mail.err +/var/log/mail.log +/var/log/daemon.log +/var/log/kern.log +/var/log/auth.log +/var/log/user.log +/var/log/lpr.log +/var/log/cron.log +/var/log/debug +/var/log/messages +{ + rotate 4 + weekly + missingok + notifempty + compress + delaycompress + sharedscripts + postrotate + /bin/kill -HUP `cat /var/run/syslog-ng.pid 2> /dev/null` > /dev/null + supervisorctl restart syslog-ng-stdout > /dev/null + endscript +} \ No newline at end of file diff --git a/docker/php-official/7.0/conf/etc/php/conf.d/.gitkeep b/docker/php-official/7.0/conf/etc/php/conf.d/.gitkeep new file mode 100644 index 000000000..e69de29bb diff --git a/docker/php/alpine-3/conf/etc/php/php.ini b/docker/php-official/7.0/conf/etc/php/php.ini similarity index 100% rename from docker/php/alpine-3/conf/etc/php/php.ini rename to docker/php-official/7.0/conf/etc/php/php.ini diff --git a/docker/php-official/7.0/conf/etc/php/php.webdevops.ini b/docker/php-official/7.0/conf/etc/php/php.webdevops.ini new file mode 100644 index 000000000..aa1545ab8 --- /dev/null +++ b/docker/php-official/7.0/conf/etc/php/php.webdevops.ini @@ -0,0 +1,34 @@ +; ------------------------------------- +; Docker Webdevops PHP configuration +; ------------------------------------- + +; this file will overwrite default php.ini settings + +display_errors = 0 +log_errors = 1 + +short_open_tag = Off +variables_order = 'GPCS' +request_order = 'GP' + +allow_url_fopen = On +allow_url_include = Off + +memory_limit = 512M +max_execution_time = 300 +max_input_time = 300 +post_max_size = 50M +upload_max_filesize = 50M +max_input_vars = 5000 + +expose_php = Off + +date.timezone = UTC + +mysql.default_host = mysql +mysqli.default_host = mysql + +opcache.memory_consumption = 256 +opcache.interned_strings_buffer = 16 +opcache.max_accelerated_files = 7963 +opcache.fast_shutdown = 1 diff --git a/docker/php-official/7.0/conf/etc/supervisor.conf b/docker/php-official/7.0/conf/etc/supervisor.conf new file mode 100644 index 000000000..479e0db08 --- /dev/null +++ b/docker/php-official/7.0/conf/etc/supervisor.conf @@ -0,0 +1,20 @@ +[supervisord] +nodaemon=true + +[unix_http_server] +file = /.supervisor.sock +chmod = 0700 +chown = root:root +username = root +password = {SHA}e982f17bcbe0f724063b708a4f76db211a999304 + +[supervisorctl] +serverurl = unix:///.supervisor.sock +username = root +password = docker + +[rpcinterface:supervisor] +supervisor.rpcinterface_factory = supervisor.rpcinterface:make_main_rpcinterface + +[include] +files = /opt/docker/etc/supervisor.d/*.conf diff --git a/docker/php-official/7.0/conf/etc/supervisor.d/.gitkeep b/docker/php-official/7.0/conf/etc/supervisor.d/.gitkeep new file mode 100644 index 000000000..e69de29bb diff --git a/docker/php-official/7.0/conf/etc/supervisor.d/cron.conf b/docker/php-official/7.0/conf/etc/supervisor.d/cron.conf new file mode 100644 index 000000000..ef0a71678 --- /dev/null +++ b/docker/php-official/7.0/conf/etc/supervisor.d/cron.conf @@ -0,0 +1,14 @@ +[group:cron] +programs=crond +priority=25 + +[program:crond] +command = /opt/docker/bin/service.d/cron.sh +process_name=%(program_name)s +startsecs = 0 +autostart = false +autorestart = true +stdout_logfile=/dev/stdout +stdout_logfile_maxbytes=0 +stderr_logfile=/dev/stderr +stderr_logfile_maxbytes=0 diff --git a/docker/php-official/7.0/conf/etc/supervisor.d/dnsmasq.conf b/docker/php-official/7.0/conf/etc/supervisor.d/dnsmasq.conf new file mode 100644 index 000000000..9832ffca7 --- /dev/null +++ b/docker/php-official/7.0/conf/etc/supervisor.d/dnsmasq.conf @@ -0,0 +1,14 @@ +[group:dnsmasq] +programs=dnsmasqd +priority=15 + +[program:dnsmasqd] +command = /opt/docker/bin/service.d/dnsmasq.sh +process_name=%(program_name)s +startsecs = 0 +autostart = false +autorestart = true +stdout_logfile=/dev/stdout +stdout_logfile_maxbytes=0 +stderr_logfile=/dev/stderr +stderr_logfile_maxbytes=0 diff --git a/docker/php/alpine-3/conf/etc/supervisor.d/php-fpm.conf b/docker/php-official/7.0/conf/etc/supervisor.d/php-fpm.conf similarity index 100% rename from docker/php/alpine-3/conf/etc/supervisor.d/php-fpm.conf rename to docker/php-official/7.0/conf/etc/supervisor.d/php-fpm.conf diff --git a/docker/php-official/7.0/conf/etc/supervisor.d/postfix.conf b/docker/php-official/7.0/conf/etc/supervisor.d/postfix.conf new file mode 100644 index 000000000..b8d70bb40 --- /dev/null +++ b/docker/php-official/7.0/conf/etc/supervisor.d/postfix.conf @@ -0,0 +1,15 @@ +[group:postfix] +programs=postfixd +priority=30 + +[program:postfixd] +directory = /etc/postfix +command = /opt/docker/bin/service.d/postfix.sh +process_name=%(program_name)s +startsecs = 0 +autostart = false +autorestart = true +stdout_logfile=/dev/stdout +stdout_logfile_maxbytes=0 +stderr_logfile=/dev/stderr +stderr_logfile_maxbytes=0 diff --git a/docker/php-official/7.0/conf/etc/supervisor.d/ssh.conf b/docker/php-official/7.0/conf/etc/supervisor.d/ssh.conf new file mode 100644 index 000000000..0ecd798d6 --- /dev/null +++ b/docker/php-official/7.0/conf/etc/supervisor.d/ssh.conf @@ -0,0 +1,14 @@ +[group:ssh] +programs=sshd +priority=30 + +[program:sshd] +command = /opt/docker/bin/service.d/ssh.sh +process_name=%(program_name)s +startsecs=0 +autostart = false +autorestart = true +stdout_logfile=/dev/stdout +stdout_logfile_maxbytes=0 +stderr_logfile=/dev/stderr +stderr_logfile_maxbytes=0 diff --git a/docker/php-official/7.0/conf/etc/supervisor.d/syslog.conf b/docker/php-official/7.0/conf/etc/supervisor.d/syslog.conf new file mode 100644 index 000000000..20d1e238c --- /dev/null +++ b/docker/php-official/7.0/conf/etc/supervisor.d/syslog.conf @@ -0,0 +1,13 @@ +[group:syslog] +programs=syslogd +priority=10 + +[program:syslogd] +command = /opt/docker/bin/service.d/syslog-ng.sh +process_name=%(program_name)s +autostart = false +autorestart = true +stdout_logfile=/dev/stdout +stdout_logfile_maxbytes=0 +stderr_logfile=/dev/stderr +stderr_logfile_maxbytes=0 diff --git a/docker/php-official/7.0/conf/etc/syslog-ng/syslog-ng.conf b/docker/php-official/7.0/conf/etc/syslog-ng/syslog-ng.conf new file mode 100644 index 000000000..c69841581 --- /dev/null +++ b/docker/php-official/7.0/conf/etc/syslog-ng/syslog-ng.conf @@ -0,0 +1,48 @@ +@version: 3.5 + +template t_isostamp { + # syslog-t_isostamp START + template("[SYSLOG] $MSGHDR$MSG\n"); + # syslog-t_isostamp END +}; + +options { + # syslog-options START + file-template(t_isostamp); + chain_hostnames(off); + flush_lines(0); + use-dns(no); + use_fqdn(no); + owner("root"); + group("adm"); + perm(0640); + stats_freq(0); + # syslog-options START +}; + +source s_src { + # syslog-s_src START + unix-stream("/dev/log"); + internal(); + # syslog-s_src END +}; + +filter f_filter { + # syslog-f_filter START + not facility(auth, authpriv); + # syslog-f_filter END +}; + +destination d_all { + # syslog-d_all START + pipe("/docker.stdout"); + # syslog-d_all END +}; + +log { + # syslog-log START + source(s_src); + filter(f_filter); + destination(d_all); + # syslog-log START +}; diff --git a/docker/php-official/7.0/conf/provision/ansible.cfg b/docker/php-official/7.0/conf/provision/ansible.cfg new file mode 100644 index 000000000..e69de29bb diff --git a/docker/php-official/7.0/conf/provision/bootstrap.d/.gitkeep b/docker/php-official/7.0/conf/provision/bootstrap.d/.gitkeep new file mode 100644 index 000000000..e69de29bb diff --git a/docker/php-official/7.0/conf/provision/build.d/.gitkeep b/docker/php-official/7.0/conf/provision/build.d/.gitkeep new file mode 100644 index 000000000..e69de29bb diff --git a/docker/php-official/7.0/conf/provision/build.d/10-cleanup.sh b/docker/php-official/7.0/conf/provision/build.d/10-cleanup.sh new file mode 100644 index 000000000..20fbdc841 --- /dev/null +++ b/docker/php-official/7.0/conf/provision/build.d/10-cleanup.sh @@ -0,0 +1,6 @@ +#!/usr/bin/env bash + +## remove logs (each bootstrap) +rm -rf -- /var/log/* +rm -rf -- /var/tmp/* +rm -rf -- /tmp/* diff --git a/docker/php-official/7.0/conf/provision/entrypoint.d/.gitkeep b/docker/php-official/7.0/conf/provision/entrypoint.d/.gitkeep new file mode 100644 index 000000000..e69de29bb diff --git a/docker/php-official/7.0/conf/provision/entrypoint.d/05-permissions.sh b/docker/php-official/7.0/conf/provision/entrypoint.d/05-permissions.sh new file mode 100644 index 000000000..6f77d8e40 --- /dev/null +++ b/docker/php-official/7.0/conf/provision/entrypoint.d/05-permissions.sh @@ -0,0 +1,2 @@ +# Fix rights of /tmp (can be a volume) +chmod 1777 /tmp diff --git a/docker/php-official/7.0/conf/provision/onbuild.d/.gitkeep b/docker/php-official/7.0/conf/provision/onbuild.d/.gitkeep new file mode 100644 index 000000000..e69de29bb diff --git a/docker/php-official/7.0/conf/provision/roles/webdevops-base-app/defaults/main.yml b/docker/php-official/7.0/conf/provision/roles/webdevops-base-app/defaults/main.yml new file mode 100644 index 000000000..e10ef7d38 --- /dev/null +++ b/docker/php-official/7.0/conf/provision/roles/webdevops-base-app/defaults/main.yml @@ -0,0 +1,7 @@ +--- + +APPLICATION_USER: "{{ lookup('env','APPLICATION_USER') }}" +APPLICATION_GROUP: "{{ lookup('env','APPLICATION_GROUP') }}" +APPLICATION_PATH: "{{ lookup('env','APPLICATION_PATH') }}" +APPLICATION_UID: "{{ lookup('env','APPLICATION_UID') }}" +APPLICATION_GID: "{{ lookup('env','APPLICATION_GID') }}" diff --git a/docker/php-official/7.0/conf/provision/roles/webdevops-base-app/tasks/bootstrap.yml b/docker/php-official/7.0/conf/provision/roles/webdevops-base-app/tasks/bootstrap.yml new file mode 100644 index 000000000..3fdce9a74 --- /dev/null +++ b/docker/php-official/7.0/conf/provision/roles/webdevops-base-app/tasks/bootstrap.yml @@ -0,0 +1,4 @@ +--- + +- include: bootstrap/user.yml +- include: bootstrap/application.yml diff --git a/docker/php-official/7.0/conf/provision/roles/webdevops-base-app/tasks/bootstrap/application.yml b/docker/php-official/7.0/conf/provision/roles/webdevops-base-app/tasks/bootstrap/application.yml new file mode 100644 index 000000000..faddb6027 --- /dev/null +++ b/docker/php-official/7.0/conf/provision/roles/webdevops-base-app/tasks/bootstrap/application.yml @@ -0,0 +1,10 @@ +--- + +- name: Init application directory + file: + path: "/{{ APPLICATION_PATH }}" + state: directory + mode: 0755 + owner: "{{ APPLICATION_USER }}" + group: "{{ APPLICATION_GROUP }}" + recurse: yes diff --git a/docker/php-official/7.0/conf/provision/roles/webdevops-base-app/tasks/bootstrap/user.yml b/docker/php-official/7.0/conf/provision/roles/webdevops-base-app/tasks/bootstrap/user.yml new file mode 100644 index 000000000..fd58b329f --- /dev/null +++ b/docker/php-official/7.0/conf/provision/roles/webdevops-base-app/tasks/bootstrap/user.yml @@ -0,0 +1,35 @@ +--- + +- name: Create application group + group: + name: "{{ APPLICATION_GROUP }}" + gid: "{{ APPLICATION_GID }}" + +- name: Create application user + user: + name: "{{ APPLICATION_USER }}" + uid: "{{ APPLICATION_UID }}" + group: "{{ APPLICATION_GROUP }}" + shell: "/bin/bash" + home: "/home/{{ APPLICATION_USER }}" + +- name: Init home directory + file: + path: "/home/{{ APPLICATION_USER }}" + state: directory + mode: 0755 + owner: "{{ APPLICATION_USER }}" + group: "{{ APPLICATION_GROUP }}" + recurse: yes + +- name: Init bashrc + lineinfile: + dest: "/home/{{ APPLICATION_USER }}/.bashrc" + mode: 0770 + owner: "{{ APPLICATION_USER }}" + group: "{{ APPLICATION_GROUP }}" + create: yes + regexp: "export TERM=xterm" + line: "export TERM=xterm" + +- action: setup diff --git a/docker/php-official/7.0/conf/provision/roles/webdevops-base-app/tasks/main.yml b/docker/php-official/7.0/conf/provision/roles/webdevops-base-app/tasks/main.yml new file mode 100644 index 000000000..1806c1a8c --- /dev/null +++ b/docker/php-official/7.0/conf/provision/roles/webdevops-base-app/tasks/main.yml @@ -0,0 +1,5 @@ +--- + +- include: bootstrap.yml + tags: + - bootstrap diff --git a/docker/php-official/7.0/conf/provision/roles/webdevops-base/defaults/main.yml b/docker/php-official/7.0/conf/provision/roles/webdevops-base/defaults/main.yml new file mode 100644 index 000000000..81f5b7efd --- /dev/null +++ b/docker/php-official/7.0/conf/provision/roles/webdevops-base/defaults/main.yml @@ -0,0 +1,6 @@ +--- + +APPLICATION_USER: "{{ lookup('env','APPLICATION_USER') }}" +APPLICATION_GROUP: "{{ lookup('env','APPLICATION_GROUP') }}" +APPLICATION_UID: "{{ lookup('env','APPLICATION_UID') }}" +APPLICATION_GID: "{{ lookup('env','APPLICATION_GID') }}" diff --git a/docker/php-official/7.0/conf/provision/roles/webdevops-base/tasks/bootstrap.yml b/docker/php-official/7.0/conf/provision/roles/webdevops-base/tasks/bootstrap.yml new file mode 100644 index 000000000..9f842336c --- /dev/null +++ b/docker/php-official/7.0/conf/provision/roles/webdevops-base/tasks/bootstrap.yml @@ -0,0 +1,8 @@ +--- + +- include: bootstrap/system.yml +- include: bootstrap/misc.yml +- include: bootstrap/root.yml +- include: bootstrap/supervisor.yml +- include: bootstrap/pam.yml +- include: bootstrap/entrypoint.yml diff --git a/docker/php-official/7.0/conf/provision/roles/webdevops-base/tasks/bootstrap/entrypoint.yml b/docker/php-official/7.0/conf/provision/roles/webdevops-base/tasks/bootstrap/entrypoint.yml new file mode 100644 index 000000000..d5d8809f4 --- /dev/null +++ b/docker/php-official/7.0/conf/provision/roles/webdevops-base/tasks/bootstrap/entrypoint.yml @@ -0,0 +1,8 @@ +--- + +- name: Create link for entrypoint + file: + src: '/opt/docker/bin/entrypoint.sh' + dest: '/entrypoint' + state: link + force: yes diff --git a/docker/php-official/7.0/conf/provision/roles/webdevops-base/tasks/bootstrap/misc.yml b/docker/php-official/7.0/conf/provision/roles/webdevops-base/tasks/bootstrap/misc.yml new file mode 100644 index 000000000..4eed695b1 --- /dev/null +++ b/docker/php-official/7.0/conf/provision/roles/webdevops-base/tasks/bootstrap/misc.yml @@ -0,0 +1,8 @@ +--- + +- file: + path: "/var/log/wtmp" + state: touch + mode: 0664 + owner: "root" + group: "root" diff --git a/docker/php-official/7.0/conf/provision/roles/webdevops-base/tasks/bootstrap/pam.yml b/docker/php-official/7.0/conf/provision/roles/webdevops-base/tasks/bootstrap/pam.yml new file mode 100644 index 000000000..a18b2412a --- /dev/null +++ b/docker/php-official/7.0/conf/provision/roles/webdevops-base/tasks/bootstrap/pam.yml @@ -0,0 +1,8 @@ +--- + +- name: Ensure su execution [Alpine family] + lineinfile: + dest: "/etc/pam.d/su" + line: "auth sufficient pam_rootok.so" + create: yes + when: ansible_os_family == "Alpine" diff --git a/docker/php-official/7.0/conf/provision/roles/webdevops-base/tasks/bootstrap/root.yml b/docker/php-official/7.0/conf/provision/roles/webdevops-base/tasks/bootstrap/root.yml new file mode 100644 index 000000000..29e955fa4 --- /dev/null +++ b/docker/php-official/7.0/conf/provision/roles/webdevops-base/tasks/bootstrap/root.yml @@ -0,0 +1,5 @@ +--- + +- file: + path: "/root/.profile" + state: absent diff --git a/docker/php-official/7.0/conf/provision/roles/webdevops-base/tasks/bootstrap/supervisor.yml b/docker/php-official/7.0/conf/provision/roles/webdevops-base/tasks/bootstrap/supervisor.yml new file mode 100644 index 000000000..2ce07ac26 --- /dev/null +++ b/docker/php-official/7.0/conf/provision/roles/webdevops-base/tasks/bootstrap/supervisor.yml @@ -0,0 +1,13 @@ +--- + +- name: Remove /usr/sbin/service + file: + path: '/usr/sbin/service' + state: absent + +- name: Create link for supervisor.conf + file: + src: '/opt/docker/etc/supervisor.conf' + dest: '/etc/supervisord.conf' + state: link + force: yes diff --git a/docker/php-official/7.0/conf/provision/roles/webdevops-base/tasks/bootstrap/system.yml b/docker/php-official/7.0/conf/provision/roles/webdevops-base/tasks/bootstrap/system.yml new file mode 100644 index 000000000..0741d7cae --- /dev/null +++ b/docker/php-official/7.0/conf/provision/roles/webdevops-base/tasks/bootstrap/system.yml @@ -0,0 +1,33 @@ +--- + +- name: Create /entrypoint.d + file: + path: "/entrypoint.d" + state: directory + owner: "root" + group: "root" + mode: 0700 + +- name: Create /entrypoint.cmd + file: + src: '/opt/docker/bin/entrypoint.d' + dest: '/entrypoint.cmd' + state: link + force: yes + +- name: Remove system logrotate and cronjobs (not needed) + file: + path: '{{ item }}' + state: absent + with_items: + # Debian/Ubuntu + - /etc/cron.daily/logrotate + - /etc/cron.daily/apt-compat + - /etc/cron.daily/dpkg + - /etc/cron.daily/passwd + # RedHat + - /etc/cron.daily/0yum-daily.cron + - /etc/cron.daily/logrotate + - /etc/cron.hourly/0yum-hourly.cron + # Alpine + - /etc/periodic/daily/logrotate diff --git a/docker/php-official/7.0/conf/provision/roles/webdevops-base/tasks/build.yml b/docker/php-official/7.0/conf/provision/roles/webdevops-base/tasks/build.yml new file mode 100644 index 000000000..cd21505a4 --- /dev/null +++ b/docker/php-official/7.0/conf/provision/roles/webdevops-base/tasks/build.yml @@ -0,0 +1,2 @@ +--- + diff --git a/docker/php-official/7.0/conf/provision/roles/webdevops-base/tasks/build/.gitkeep b/docker/php-official/7.0/conf/provision/roles/webdevops-base/tasks/build/.gitkeep new file mode 100644 index 000000000..e69de29bb diff --git a/docker/php-official/7.0/conf/provision/roles/webdevops-base/tasks/entrypoint.yml b/docker/php-official/7.0/conf/provision/roles/webdevops-base/tasks/entrypoint.yml new file mode 100644 index 000000000..ed97d539c --- /dev/null +++ b/docker/php-official/7.0/conf/provision/roles/webdevops-base/tasks/entrypoint.yml @@ -0,0 +1 @@ +--- diff --git a/docker/php-official/7.0/conf/provision/roles/webdevops-base/tasks/entrypoint/.gitkeep b/docker/php-official/7.0/conf/provision/roles/webdevops-base/tasks/entrypoint/.gitkeep new file mode 100644 index 000000000..e69de29bb diff --git a/docker/php-official/7.0/conf/provision/roles/webdevops-base/tasks/main.yml b/docker/php-official/7.0/conf/provision/roles/webdevops-base/tasks/main.yml new file mode 100644 index 000000000..66fb2e38b --- /dev/null +++ b/docker/php-official/7.0/conf/provision/roles/webdevops-base/tasks/main.yml @@ -0,0 +1,13 @@ +--- + +- include: bootstrap.yml + tags: + - bootstrap + +- include: build.yml + tags: + - build + +- include: entrypoint.yml + tags: + - entrypoint diff --git a/docker/php-official/7.0/conf/provision/roles/webdevops-cleanup/tasks/cleanup.yml b/docker/php-official/7.0/conf/provision/roles/webdevops-cleanup/tasks/cleanup.yml new file mode 100644 index 000000000..ddd0abbc4 --- /dev/null +++ b/docker/php-official/7.0/conf/provision/roles/webdevops-cleanup/tasks/cleanup.yml @@ -0,0 +1,16 @@ +--- + +- name: Filesystem cleanup [Debian family] + file: + path: "{{ item }}" + state: absent + with_fileglob: + - /var/cache/apt/archives/*.deb + - /var/cache/apt/archives/partial/* + - /var/cache/debconf/*-old + - /var/lib/apt/lists/* + when: ansible_os_family == "Debian" + +- name: Yum cleanup [RedHat family] + command: yum clean all + when: ansible_os_family == "RedHat" diff --git a/docker/php-official/7.0/conf/provision/roles/webdevops-cleanup/tasks/main.yml b/docker/php-official/7.0/conf/provision/roles/webdevops-cleanup/tasks/main.yml new file mode 100644 index 000000000..951b7fc67 --- /dev/null +++ b/docker/php-official/7.0/conf/provision/roles/webdevops-cleanup/tasks/main.yml @@ -0,0 +1,6 @@ +--- + +- include: cleanup.yml + tags: + - bootstrap + - onbuild diff --git a/docker/php-official/7.0/conf/provision/roles/webdevops-php/defaults/main.yml b/docker/php-official/7.0/conf/provision/roles/webdevops-php/defaults/main.yml new file mode 100644 index 000000000..81f5b7efd --- /dev/null +++ b/docker/php-official/7.0/conf/provision/roles/webdevops-php/defaults/main.yml @@ -0,0 +1,6 @@ +--- + +APPLICATION_USER: "{{ lookup('env','APPLICATION_USER') }}" +APPLICATION_GROUP: "{{ lookup('env','APPLICATION_GROUP') }}" +APPLICATION_UID: "{{ lookup('env','APPLICATION_UID') }}" +APPLICATION_GID: "{{ lookup('env','APPLICATION_GID') }}" diff --git a/docker/php-official/7.0/conf/provision/roles/webdevops-php/tasks/bootstrap.yml b/docker/php-official/7.0/conf/provision/roles/webdevops-php/tasks/bootstrap.yml new file mode 100644 index 000000000..99a2e5191 --- /dev/null +++ b/docker/php-official/7.0/conf/provision/roles/webdevops-php/tasks/bootstrap.yml @@ -0,0 +1,10 @@ +--- + +- include: bootstrap/init.yml +- include: bootstrap/php.yml +- include: bootstrap/php.debian.yml +- include: bootstrap/php.redhat.yml +- include: bootstrap/php.alpine.yml +- include: bootstrap/php-fpm.main.yml +- include: bootstrap/php-fpm.pool.yml +- include: bootstrap/php-fpm.yml diff --git a/docker/php-official/7.0/conf/provision/roles/webdevops-php/tasks/bootstrap/init.yml b/docker/php-official/7.0/conf/provision/roles/webdevops-php/tasks/bootstrap/init.yml new file mode 100644 index 000000000..df39e4bd4 --- /dev/null +++ b/docker/php-official/7.0/conf/provision/roles/webdevops-php/tasks/bootstrap/init.yml @@ -0,0 +1,23 @@ +--- + +- name: Get php version + command: "php -r 'echo phpversion();'" + changed_when: true + register: php_version_cmd + ignore_errors: true + +- name: Set php_version version + set_fact: + php_version: "{{php_version_cmd.stdout}}" + +############################# +# PHP +############################# + +- name: Set php main file (official) + set_fact: + php_etc_dir: /usr/local/etc/php + php_main_conf: /usr/local/etc/php-fpm.conf + php_pool_conf: www.conf + php_pool_dir: /usr/local/etc/php-fpm.d + php_fpm_bin: /usr/local/sbin/php-fpm diff --git a/docker/php-official/7.0/conf/provision/roles/webdevops-php/tasks/bootstrap/php-fpm.main.yml b/docker/php-official/7.0/conf/provision/roles/webdevops-php/tasks/bootstrap/php-fpm.main.yml new file mode 100644 index 000000000..c149d8728 --- /dev/null +++ b/docker/php-official/7.0/conf/provision/roles/webdevops-php/tasks/bootstrap/php-fpm.main.yml @@ -0,0 +1,49 @@ +--- + +- name: Create php directories + file: + path: "{{ item }}" + state: directory + mode: 0755 + owner: "root" + group: "root" + with_items: + - /opt/docker/etc/php/fpm/ + +- name: Move php-fpm main file to /opt/docker/etc/php/fpm/ + command: "mv {{ php_main_conf }} /opt/docker/etc/php/fpm/php-fpm.conf" + args: + creates: /opt/docker/etc/php/fpm/php-fpm.conf + +- name: Remove php-fpm main file + file: + path: "{{ php_main_conf }}" + state: absent + +- name: Symlink php-fpm main file + file: + path: "{{ php_main_conf }}" + src: "/opt/docker/etc/php/fpm/php-fpm.conf" + state: link + owner: "root" + group: "root" + +- name: Configure php-fpm main (all versions) + lineinfile: + dest: '/opt/docker/etc/php/fpm/php-fpm.conf' + regexp: '^[\s;]*{{ item.key }}[\s]*=' + line: '{{ item.key }} = {{ item.value }}' + insertafter: '\[global\]' + with_items: + - { key: 'error_log', value: "/docker.stderr" } + - { key: 'pid', value: "/var/run/php-fpm.pid" } + +- name: Configure php-fpm main (php 5.x) + lineinfile: + dest: '/opt/docker/etc/php/fpm/php-fpm.conf' + regexp: '^[\s;]*{{ item.key }}[\s]*=' + line: '{{ item.key }} = {{ item.value }}' + insertbefore: '[\s]*include[\s]*=' + with_items: + - { key: 'daemonize', value: 'no' } + when: ( php_version | version_compare('7.0.0', '<') ) diff --git a/docker/php-official/7.0/conf/provision/roles/webdevops-php/tasks/bootstrap/php-fpm.pool.yml b/docker/php-official/7.0/conf/provision/roles/webdevops-php/tasks/bootstrap/php-fpm.pool.yml new file mode 100644 index 000000000..ab0b7b02c --- /dev/null +++ b/docker/php-official/7.0/conf/provision/roles/webdevops-php/tasks/bootstrap/php-fpm.pool.yml @@ -0,0 +1,101 @@ +--- + +- set_fact: + php_clear_env_available: False + +- set_fact: + php_clear_env_available: True + when: ( php_version | version_compare('5.4', 'eq') and php_version | version_compare('5.4.27', 'ge') ) or + ( php_version | version_compare('5.5', 'eq') and php_version | version_compare('5.5.11', 'ge') ) or + ( php_version | version_compare('5.6', 'ge') ) + +- name: Create /opt/docker/etc/php/fpm directory + file: + path: "/opt/docker/etc/php/fpm" + state: directory + +- name: Move php-fpm pool directory file to /opt/docker/etc/php/ + command: "mv {{ php_pool_dir }} /opt/docker/etc/php/fpm/pool.d" + args: + creates: /opt/docker/etc/php/fpm/pool.d + +- name: Rename pool file file to application.conf" + command: "mv /opt/docker/etc/php/fpm/pool.d/{{ php_pool_conf }} /opt/docker/etc/php/fpm/pool.d/application.conf" + args: + creates: /opt/docker/etc/php/fpm/pool.d/application.conf + +- name: Remove php-fpm pool directory + file: + path: "{{ php_pool_dir }}" + state: absent + +- name: Symlink php-fpm pool file + file: + path: "{{ php_pool_dir }}" + src: "/opt/docker/etc/php/fpm/pool.d" + state: link + owner: "root" + group: "root" + +- name: Configure php-fpm pool user (application.conf) + lineinfile: + dest: '/opt/docker/etc/php/fpm/pool.d/application.conf' + regexp: '^[\s;]*{{ item.key }}[\s]*=' + line: '{{ item.key }} = {{ item.value }}' + with_items: + - { key: 'listen', value: "[::]:9000" } + - { key: 'catch_workers_output', value: "yes" } + - { key: 'access.format', value: '[php-fpm:access] %R - %u %t "%m %r%Q%q" %s %f %{mili}d %{kilo}M %C%%' } + - { key: 'access.log', value: "/docker.stdout" } + - { key: 'slowlog', value: "/docker.stderr" } + - { key: 'php_admin_value[error_log]', value: "/docker.stderr" } + - { key: 'php_admin_value[log_errors]', value: "on" } + - { key: 'user', value: "{{ APPLICATION_USER }}" } + - { key: 'group', value: "{{ APPLICATION_GROUP }}" } + +- name: Configure php-fpm pool user (application.conf) + lineinfile: + dest: '/opt/docker/etc/php/fpm/pool.d/application.conf' + regexp: '^[\s;]*{{ item.key }}[\s]*=' + line: '{{ item.key }} = {{ item.value }}' + with_items: + - { key: 'listen', value: "0.0.0.0:9000" } + when: php_version | version_compare('5.5.99', '<=') + +- name: Configure php-fpm pool user (application.conf) + lineinfile: + dest: '/opt/docker/etc/php/fpm/pool.d/application.conf' + regexp: '^[\s;]*{{ item.key }}[\s]*=' + line: ';{{ item.key }} = {{ item.value }}' + with_items: + - { key: 'access.log', value: "/docker.stdout" } + +- name: Disable clear env in php-fpm pool + lineinfile: + dest: '/opt/docker/etc/php/fpm/pool.d/application.conf' + regexp: '^[\s;]*{{ item.key }}[\s]*=' + line: '{{ item.key }} = {{ item.value }}' + with_items: + - { key: 'clear_env', value: "no" } + when: php_clear_env_available == True + +- name: Remove clear env workaround + file: + path: "/opt/docker/bin/service.d/php-fpm.d/11-clear-env.sh" + state: absent + when: php_clear_env_available == True + +- name: Append clear env workaround in php-fpm pool (old php-fpm versions) + lineinfile: + dest: '/opt/docker/etc/php/fpm/pool.d/application.conf' + line: ';#CLEAR_ENV_WORKAROUND#' + when: php_clear_env_available == False + +- name: Disable php-fpm connection limit + lineinfile: + dest: '/opt/docker/etc/php/fpm/pool.d/application.conf' + regexp: '^[\s;]*{{ item.key }}[\s]*=' + line: ';{{ item.key }}' + with_items: + - { key: 'listen.allowed_clients' } + diff --git a/docker/php-official/7.0/conf/provision/roles/webdevops-php/tasks/bootstrap/php-fpm.yml b/docker/php-official/7.0/conf/provision/roles/webdevops-php/tasks/bootstrap/php-fpm.yml new file mode 100644 index 000000000..41c1b33dc --- /dev/null +++ b/docker/php-official/7.0/conf/provision/roles/webdevops-php/tasks/bootstrap/php-fpm.yml @@ -0,0 +1,9 @@ +--- + +- name: Symlink php-fpm binary + file: + path: "/usr/local/bin/php-fpm" + src: "{{ php_fpm_bin }}" + state: link + owner: "root" + group: "root" diff --git a/docker/php-official/7.0/conf/provision/roles/webdevops-php/tasks/bootstrap/php.alpine.yml b/docker/php-official/7.0/conf/provision/roles/webdevops-php/tasks/bootstrap/php.alpine.yml new file mode 100644 index 000000000..4c16cdf0d --- /dev/null +++ b/docker/php-official/7.0/conf/provision/roles/webdevops-php/tasks/bootstrap/php.alpine.yml @@ -0,0 +1,12 @@ +--- + +- name: Create link for additional php.ini [Alpine family] + file: + src: '/opt/docker/etc/php/{{ item.file }}' + dest: '{{ php_etc_dir }}/conf.d/{{ item.target }}' + state: link + force: yes + with_items: + - { file: 'php.webdevops.ini', target: 'xzza-webdevops.ini'} + - { file: 'php.ini', target: 'xzzz-docker.ini'} + when: ansible_os_family == 'Alpine' diff --git a/docker/php-official/7.0/conf/provision/roles/webdevops-php/tasks/bootstrap/php.debian.yml b/docker/php-official/7.0/conf/provision/roles/webdevops-php/tasks/bootstrap/php.debian.yml new file mode 100644 index 000000000..411e736c8 --- /dev/null +++ b/docker/php-official/7.0/conf/provision/roles/webdevops-php/tasks/bootstrap/php.debian.yml @@ -0,0 +1,11 @@ +--- + +- name: Link php.ini for cli and fpm [Official PHP] + file: + src: '{{ item.file }}' + dest: '{{ php_etc_dir }}/conf.d/{{ item.target }}' + force: yes + state: link + with_items: + - { category: 'cli', file: '/opt/docker/etc/php/php.webdevops.ini', target: '98-webdevops.ini' } + - { category: 'cli', file: '/opt/docker/etc/php/php.ini', target: '99-docker.ini' } diff --git a/docker/php-official/7.0/conf/provision/roles/webdevops-php/tasks/bootstrap/php.redhat.yml b/docker/php-official/7.0/conf/provision/roles/webdevops-php/tasks/bootstrap/php.redhat.yml new file mode 100644 index 000000000..7e8810231 --- /dev/null +++ b/docker/php-official/7.0/conf/provision/roles/webdevops-php/tasks/bootstrap/php.redhat.yml @@ -0,0 +1,12 @@ +--- + +- name: Create link for additional php.ini [RedHat family] + file: + src: '/opt/docker/etc/php/{{ item.file }}' + dest: '/etc/php.d/{{ item.target }}' + state: link + force: yes + with_items: + - { file: 'php.webdevops.ini', target: 'zza-webdevops.ini'} + - { file: 'php.ini', target: 'zzz-docker.ini'} + when: ansible_os_family == 'RedHat' diff --git a/docker/php-official/7.0/conf/provision/roles/webdevops-php/tasks/bootstrap/php.yml b/docker/php-official/7.0/conf/provision/roles/webdevops-php/tasks/bootstrap/php.yml new file mode 100644 index 000000000..caac8f413 --- /dev/null +++ b/docker/php-official/7.0/conf/provision/roles/webdevops-php/tasks/bootstrap/php.yml @@ -0,0 +1,23 @@ +--- + +- name: Create php directories + file: + path: "{{ item }}" + state: directory + mode: 0755 + owner: "root" + group: "root" + with_items: + - /opt/docker/etc/php/ + - /opt/docker/etc/php/fpm/ + +- name: Create php.ini files + file: + path: "{{ item }}" + state: touch + mode: 0744 + owner: root + group: root + with_items: + - "/opt/docker/etc/php/php.webdevops.ini" + - "/opt/docker/etc/php/php.ini" diff --git a/docker/php-official/7.0/conf/provision/roles/webdevops-php/tasks/main.yml b/docker/php-official/7.0/conf/provision/roles/webdevops-php/tasks/main.yml new file mode 100644 index 000000000..1806c1a8c --- /dev/null +++ b/docker/php-official/7.0/conf/provision/roles/webdevops-php/tasks/main.yml @@ -0,0 +1,5 @@ +--- + +- include: bootstrap.yml + tags: + - bootstrap diff --git a/docker/php-official/7.0/conf/provision/service.d/.gitkeep b/docker/php-official/7.0/conf/provision/service.d/.gitkeep new file mode 100644 index 000000000..e69de29bb diff --git a/docker/php-official/7.0/conf/provision/service.d/cron.sh b/docker/php-official/7.0/conf/provision/service.d/cron.sh new file mode 100644 index 000000000..bd8a54781 --- /dev/null +++ b/docker/php-official/7.0/conf/provision/service.d/cron.sh @@ -0,0 +1,13 @@ +#!/usr/bin/env bash + +IMAGE_FAMILY=$(docker-image-info family) + +case "$IMAGE_FAMILY" in + Debian|Ubuntu) + apt-install cron + ;; + + RedHat) + yum-install cronie + ;; +esac diff --git a/docker/php-official/7.0/conf/provision/service.d/dnsmasq.sh b/docker/php-official/7.0/conf/provision/service.d/dnsmasq.sh new file mode 100644 index 000000000..9e5c3228c --- /dev/null +++ b/docker/php-official/7.0/conf/provision/service.d/dnsmasq.sh @@ -0,0 +1,24 @@ +#!/usr/bin/env bash + +IMAGE_FAMILY=$(docker-image-info family) + +# Installation +case "$IMAGE_FAMILY" in + Debian|Ubuntu) + apt-install dnsmasq + ;; + + RedHat) + yum-install dnsmasq + ;; + + Alpine) + apk-install dnsmasq + ;; +esac + +# Configuration +go-replace --mode=line \ + -s '^[\s]*user[\s]*=' -r 'user = root' \ + -s '^[\s]*conf-dir[\s]*=' -r 'conf-dir = /etc/dnsmasq.d' \ + -- /etc/dnsmasq.conf diff --git a/docker/php-official/7.0/conf/provision/service.d/postfix.sh b/docker/php-official/7.0/conf/provision/service.d/postfix.sh new file mode 100644 index 000000000..ff1879345 --- /dev/null +++ b/docker/php-official/7.0/conf/provision/service.d/postfix.sh @@ -0,0 +1,28 @@ +#!/usr/bin/env bash + +IMAGE_FAMILY=$(docker-image-info family) + +# Installation +case "$IMAGE_FAMILY" in + Debian|Ubuntu) + apt-install postfix + ;; + + RedHat) + yum-install postfix + ;; + + Alpine) + apk-install postfix + ln -s -f /etc/postfix/aliases /etc/aliases + ;; +esac + +# Configuration +go-replace --mode=line \ + -s '^[\s]*mydestination[\s]*=' -r 'mydestination = ' \ + -s '^[\s]*message_size_limit[\s]*=' -r 'message_size_limit = 15240000' \ + -s '^[\s]*smtp_use_tls[\s]*=' -r 'smtp_use_tls = yes' \ + -s '^[\s]*smtp_tls_security_level[\s]*=' -r 'smtp_tls_security_level = may' \ + -s '^[\s]*myhostname[\s]*=' -r '# myhostname' \ + -- /etc/postfix/main.cf diff --git a/docker/php-official/7.0/conf/provision/service.d/ssh.sh b/docker/php-official/7.0/conf/provision/service.d/ssh.sh new file mode 100644 index 000000000..63d7a9f3a --- /dev/null +++ b/docker/php-official/7.0/conf/provision/service.d/ssh.sh @@ -0,0 +1,17 @@ +#!/usr/bin/env bash + +IMAGE_FAMILY=$(docker-image-info family) + +case "$IMAGE_FAMILY" in + Debian|Ubuntu) + apt-install openssh-server + ;; + + RedHat) + yum-install openssh-server + ;; + + Alpine) + apk-install openssh + ;; +esac diff --git a/docker/php-official/7.0/conf/provision/service.d/syslog.sh b/docker/php-official/7.0/conf/provision/service.d/syslog.sh new file mode 100644 index 000000000..7e8b8e0a9 --- /dev/null +++ b/docker/php-official/7.0/conf/provision/service.d/syslog.sh @@ -0,0 +1,41 @@ +#!/usr/bin/env bash + +IMAGE_FAMILY=$(docker-image-info family) + +# Installation +case "$IMAGE_FAMILY" in + Debian|Ubuntu) + apt-install syslog-ng syslog-ng-core + ;; + + RedHat) + yum-install syslog-ng + + # remove logrotate (not needed for docker) + rm -f "/etc/cron.daily/logrotate" + ;; + + Alpine) + apk-install syslog-ng + ;; +esac + +## Configuration +SYSLOG_NG_VERSION=$(syslog-ng --version | grep -E -e '^syslog-ng[ ]+[0-9]+\.[0-9]+' | head -n 1 | awk '{print $2}' | cut -f 1,2 -d .) + +# Disable caps inside container +if [[ -f /etc/default/syslog-ng ]]; then + go-replace --mode=lineinfile \ + -s "SYSLOGNG_OPTS" -r "SYSLOGNG_OPTS = --no-caps" \ + -- /etc/default/syslog-ng +fi + +# Symlink configuration +ln -s -f /opt/docker/etc/syslog-ng/syslog-ng.conf /etc/syslog-ng/syslog-ng.conf + +go-replace --mode=lineinfile \ + -s "@version" -r "@version: ${SYSLOG_NG_VERSION}" \ + -- /etc/syslog-ng/syslog-ng.conf + +# Ensure /var/lib/syslog-ng exists +mkdir -p /var/lib/syslog-ng diff --git a/docker/php-official/7.0/conf/provision/variables-webdevops.yml b/docker/php-official/7.0/conf/provision/variables-webdevops.yml new file mode 100644 index 000000000..0b2a21a95 --- /dev/null +++ b/docker/php-official/7.0/conf/provision/variables-webdevops.yml @@ -0,0 +1,7 @@ +--- + +docker_image_info_family: "{{ lookup('pipe', 'docker-image-info family') }}" +docker_image_info_distribution: "{{ lookup('pipe', 'docker-image-info dist') }}" +docker_image_info_distribution_version: "{{ lookup('pipe', 'docker-image-info dist-version') }}" +docker_image_info_distribution_release: "{{ lookup('pipe', 'docker-image-info dist-release') }}" +docker_image_info_distribution_codename: "{{ lookup('pipe', 'docker-image-info dist-codename') }}" diff --git a/docker/php-official/7.0/conf/provision/variables.yml b/docker/php-official/7.0/conf/provision/variables.yml new file mode 100644 index 000000000..0b2a21a95 --- /dev/null +++ b/docker/php-official/7.0/conf/provision/variables.yml @@ -0,0 +1,7 @@ +--- + +docker_image_info_family: "{{ lookup('pipe', 'docker-image-info family') }}" +docker_image_info_distribution: "{{ lookup('pipe', 'docker-image-info dist') }}" +docker_image_info_distribution_version: "{{ lookup('pipe', 'docker-image-info dist-version') }}" +docker_image_info_distribution_release: "{{ lookup('pipe', 'docker-image-info dist-release') }}" +docker_image_info_distribution_codename: "{{ lookup('pipe', 'docker-image-info dist-codename') }}" diff --git a/docker/php-official/7.1/Dockerfile b/docker/php-official/7.1/Dockerfile new file mode 100644 index 000000000..3c82e941b --- /dev/null +++ b/docker/php-official/7.1/Dockerfile @@ -0,0 +1,187 @@ +#+++++++++++++++++++++++++++++++++++++++ +# Dockerfile for webdevops/php-official:7.1 +# -- automatically generated -- +#+++++++++++++++++++++++++++++++++++++++ + +FROM php:7.1-fpm + +LABEL maintainer=info@webdevops.io \ + vendor=WebDevOps.io \ + io.webdevops.layout=8 \ + io.webdevops.version=1.5.0 + +ENV TERM="xterm" \ + LANG="C.UTF-8" \ + LC_ALL="C.UTF-8" +ENV DOCKER_CONF_HOME=/opt/docker/ \ + LOG_STDOUT="" \ + LOG_STDERR="" +ENV APPLICATION_USER=application \ + APPLICATION_GROUP=application \ + APPLICATION_PATH=/app \ + APPLICATION_UID=1000 \ + APPLICATION_GID=1000 + +ADD baselayout.tar / + +COPY conf/ /opt/docker/ + +# Init bootstrap +RUN set -x \ + && apt-update \ + && /usr/local/bin/generate-dockerimage-info \ + # Enable non-free + && sed -ri "s/(deb.*\/debian $(docker-image-info dist-codename) main)/\1 contrib non-free /" -- /etc/apt/sources.list \ + && apt-update \ + # System update + && /usr/local/bin/apt-upgrade \ + # Base stuff + && /usr/local/bin/apt-install \ + apt-transport-https \ + ca-certificates \ + locales \ + # Install gosu + && GOSU_VERSION=1.10 \ + && /usr/local/bin/apt-install wget gnupg dirmngr \ + && dpkgArch="amd64" \ + && wget -O /usr/local/bin/gosu "https://github.com/tianon/gosu/releases/download/$GOSU_VERSION/gosu-$dpkgArch" \ + && wget -O /usr/local/bin/gosu.asc "https://github.com/tianon/gosu/releases/download/$GOSU_VERSION/gosu-$dpkgArch.asc" \ + && export GNUPGHOME="$(mktemp -d)" \ + && gpg --keyserver ha.pool.sks-keyservers.net --recv-keys B42F6819007F00F88E364FD4036A9C25BF357DD4 \ + && gpg --batch --verify /usr/local/bin/gosu.asc /usr/local/bin/gosu \ + && rm -rf "$GNUPGHOME" /usr/local/bin/gosu.asc \ + && chmod +x /usr/local/bin/gosu \ + && gosu nobody true \ + ## Install go-replace + && GOREPLACE_VERSION=0.5.4 \ + && wget -O /usr/local/bin/go-replace https://github.com/webdevops/goreplace/releases/download/$GOREPLACE_VERSION/gr-64-linux \ + && chmod +x /usr/local/bin/go-replace \ + && apt-get purge -y -f --force-yes wget dirmngr \ + && docker-image-cleanup + +# Install ansible +RUN /usr/local/bin/apt-install \ + # Install ansible + python-minimal \ + python-setuptools \ + python-pip \ + python-paramiko \ + python-jinja2 \ + python-dev \ + libffi-dev \ + libssl-dev \ + build-essential \ + && pip install --upgrade pip \ + && hash -r \ + && pip install --no-cache-dir ansible \ + && chmod 750 /usr/local/bin/ansible* \ + # Cleanup + && apt-get purge -y -f --force-yes \ + python-dev \ + build-essential \ + libssl-dev \ + libffi-dev \ + && docker-image-cleanup + +# Install packages +RUN chmod +x /opt/docker/bin/* \ + && /usr/local/bin/apt-install \ + supervisor \ + wget \ + curl \ + net-tools \ + gnupg \ + && chmod +s /usr/local/bin/gosu \ + && /opt/docker/bin/provision run --tag bootstrap --role webdevops-base \ + && /opt/docker/bin/bootstrap.sh \ + && docker-image-cleanup + +# Install services +RUN /usr/local/bin/apt-install \ + # Install common tools + zip \ + unzip \ + bzip2 \ + wget \ + curl \ + net-tools \ + moreutils \ + dnsutils \ + openssh-client \ + rsync \ + git \ + && /usr/local/bin/generate-locales \ + && /opt/docker/bin/provision run --tag bootstrap --role webdevops-base-app \ + && /opt/docker/bin/bootstrap.sh \ + && docker-image-cleanup + +# Install php environment +RUN /usr/local/bin/apt-install \ + # Install tools + imagemagick \ + graphicsmagick \ + ghostscript \ + # Libraries + libldap-2.4-2 \ + libxslt1.1 \ + zlib1g \ + libpng12-0 \ + libmcrypt4 \ + # Dev and headers + libbz2-dev \ + libldap2-dev \ + libldb-dev \ + libmcrypt-dev \ + libxml2-dev \ + libxslt1-dev \ + zlib1g-dev \ + libpng12-dev \ + # Install extensions + && docker-php-ext-install \ + bcmath \ + bz2 \ + calendar \ + exif \ + gettext \ + mysqli \ + mcrypt \ + hash \ + pcntl \ + pdo_mysql \ + soap \ + sockets \ + tokenizer \ + sysvmsg \ + sysvsem \ + sysvshm \ + shmop \ + xsl \ + zip \ + gd \ + gettext \ + opcache \ + # Uninstall dev and header packages + && apt-get purge -y -f --force-yes \ + libbz2-dev \ + libldap2-dev \ + libldb-dev \ + libmcrypt-dev \ + libxml2-dev \ + libxslt1-dev \ + zlib1g-dev \ + libpng12-dev \ + # Install extensions for PHP 7.x + && pecl install apcu redis \ + && echo extension=apcu.so > /usr/local/etc/php/conf.d/apcu.ini \ + && echo extension=redis.so > /usr/local/etc/php/conf.d/redis.ini \ + && rm -f /usr/local/etc/php-fpm.d/zz-docker.conf \ + && curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin/ --filename=composer \ + && /opt/docker/bin/provision run --tag bootstrap --role webdevops-php \ + && /opt/docker/bin/bootstrap.sh \ + && docker-image-cleanup + +WORKDIR / + +EXPOSE 9000 +ENTRYPOINT ["/opt/docker/bin/entrypoint.sh"] +CMD ["supervisord"] diff --git a/docker/php-official/7.1/Dockerfile.jinja2 b/docker/php-official/7.1/Dockerfile.jinja2 new file mode 100644 index 000000000..c2ca7614a --- /dev/null +++ b/docker/php-official/7.1/Dockerfile.jinja2 @@ -0,0 +1,25 @@ +{{ docker.fromOfficial("php", "7.1-fpm") }} + +{{ docker.version() }} + +{{ environment.general() }} +{{ environment.base() }} +{{ environment.baseApp() }} + +{{ docker.add('baselayout.tar', '/') }} + +{{ docker.copy('conf/', '/opt/docker/') }} + +{{ bootstrap.debian('jessie') }} + +{{ ansible.debian() }} + +{{ base.debian() }} + +{{ baseapp.debian() }} + +{{ php.official(version='7.1') }} + +{{ docker.expose('9000') }} +{{ docker.entrypoint("/opt/docker/bin/entrypoint.sh") }} +{{ docker.cmd("supervisord") }} diff --git a/docker/php-official/7.1/baselayout.tar b/docker/php-official/7.1/baselayout.tar new file mode 100644 index 000000000..dc5fbe08f Binary files /dev/null and b/docker/php-official/7.1/baselayout.tar differ diff --git a/docker/php-official/7.1/conf/VERSION b/docker/php-official/7.1/conf/VERSION new file mode 100644 index 000000000..301160a93 --- /dev/null +++ b/docker/php-official/7.1/conf/VERSION @@ -0,0 +1 @@ +8 \ No newline at end of file diff --git a/docker/php-official/7.1/conf/bin/bootstrap.sh b/docker/php-official/7.1/conf/bin/bootstrap.sh new file mode 100644 index 000000000..855c10782 --- /dev/null +++ b/docker/php-official/7.1/conf/bin/bootstrap.sh @@ -0,0 +1,72 @@ +#!/usr/bin/env bash + +BOOTSTRAP_MODE="bootstrap" + +if [ -n "$1" ]; then + BOOTSTRAP_MODE="$1" +fi + +set -o pipefail # trace ERR through pipes +set -o errtrace # trace ERR through 'time command' and other functions +set -o nounset ## set -u : exit the script if you try to use an uninitialised variable +set -o errexit ## set -e : exit the script if any statement returns a non-true return value + +source /opt/docker/bin/config.sh + +rootCheck "$0" + +# Save the buildtime +date +%s > /opt/docker/BUILDTIME +date +%s >/opt/docker/etc/.registry/image_info_buildtime + +# Make all scripts executable +find /opt/docker/bin/ -type f -iname '*.sh' -print0 | xargs --no-run-if-empty -0 chmod +x + +# Enable usr-bin executables +find /opt/docker/bin/usr-bin -type f | while read USR_BIN_FILE; do + chmod +x -- "$USR_BIN_FILE" + ln -n -f -- "$USR_BIN_FILE" "/usr/local/bin/$(basename "$USR_BIN_FILE")" +done + +case "$BOOTSTRAP_MODE" in + ################################### + # When container will be build next time + ################################### + "onbuild") + # Init and run bootstrap system + runProvisionOnBuild + ;; + + ################################### + # When container is build this time + ################################### + "bootstrap") + # Init and run bootstrap system + runProvisionBootstrap + runProvisionBuild + ;; + + *) + echo "[ERROR] Bootstrap mode '$BOOTSTRAP_MODE' not defined" + exit 1 + ;; +esac + + +###################### +# Check if entrypoint provisioning is available +###################### + +echo "Checking provision status..." +for PROVISION_TAG in onbuild build bootstrap entrypoint; do + ROLES=$(docker-provision list --tag "$PROVISION_TAG") + if [[ -n "$ROLES" ]]; then + PROVISION_ROLE_COUNT=$(echo "$ROLES" | wc -l) + echo " - found ${PROVISION_ROLE_COUNT} for provision tag ${PROVISION_TAG}, caching info for execution" + echo -n "$PROVISION_ROLE_COUNT" > "/opt/docker/etc/.registry/provision-availale.${PROVISION_TAG}" + else + echo " - no roles found for provision tag ${PROVISION_TAG}" + echo -n '' > "/opt/docker/etc/.registry/provision-availale.${PROVISION_TAG}" + fi +done + diff --git a/docker/php-official/7.1/conf/bin/config.sh b/docker/php-official/7.1/conf/bin/config.sh new file mode 100644 index 000000000..049756c26 --- /dev/null +++ b/docker/php-official/7.1/conf/bin/config.sh @@ -0,0 +1,151 @@ +#!/usr/bin/env bash + +shopt -s nullglob + +### + # Check if current user is root + # + ## +function rootCheck() { + # Root check + if [ "$(/usr/bin/whoami)" != "root" ]; then + echo "[ERROR] $* must be run as root" + exit 1 + fi +} + +### + # Create /docker.stdout and /docker.stderr + # + ## +function createDockerStdoutStderr() { + # link stdout from docker + if [[ -z "$LOG_STDOUT" ]]; then + LOG_STDOUT="/proc/$$/fd/1" + fi + + if [[ -z "$LOG_STDERR" ]]; then + LOG_STDERR="/proc/$$/fd/2" + fi + + ln -f -s "$LOG_STDOUT" /docker.stdout + ln -f -s "$LOG_STDERR" /docker.stderr + chmod 600 /docker.stdout /docker.stderr +} +### + # Include script directory text inside a file + # + # $1 -> path + # + ## +function includeScriptDir() { + if [[ -d "$1" ]]; then + for FILE in "$1"/*.sh; do + # run custom scripts, only once + . "$FILE" + done + fi +} + +### + # Show deprecation notice + # + ## +function deprecationNotice() { + echo "" + echo "###############################################################################" + echo "### THIS CALL IS DEPRECATED AND WILL BE REMOVED IN THE FUTURE" + echo "###" + echo "### $*" + echo "###" + echo "###############################################################################" + echo "" +} + +### + # Run "entrypoint" scripts + ## +function runEntrypoints() { + ############### + # Try to find entrypoint + ############### + + ENTRYPOINT_SCRIPT="/opt/docker/bin/entrypoint.d/${TASK}.sh" + + if [ -f "$ENTRYPOINT_SCRIPT" ]; then + . "$ENTRYPOINT_SCRIPT" + fi + + ############### + # Run default + ############### + if [ -f "/opt/docker/bin/entrypoint.d/default.sh" ]; then + . /opt/docker/bin/entrypoint.d/default.sh + fi + + exit 1 +} + +### + # Run "bootstrap" provisioning + ## +function runProvisionBootstrap() { + for FILE in /opt/docker/provision/bootstrap.d/*.sh; do + # run custom scripts, only once + . "$FILE" + rm -f -- "$FILE" + done + + runDockerProvision bootstrap +} + +### + # Run "build" provisioning + ## +function runProvisionBuild() { + for FILE in /opt/docker/provision/build.d/*.sh; do + # run custom scripts, only once + . "$FILE" + done + + runDockerProvision build +} + +### + # Run "onbuild" provisioning + ## +function runProvisionOnBuild() { + includeScriptDir "/opt/docker/provision/onbuild.d" + + runDockerProvision onbuild +} + +### + # Run "entrypoint" provisioning + ## +function runProvisionEntrypoint() { + includeScriptDir "/opt/docker/provision/entrypoint.d" + includeScriptDir "/entrypoint.d" + + runDockerProvision entrypoint +} + + +### + # Run docker provisioning with dyniamic playbook generation + # + # $1 -> playbook tag (bootstrap, onbuild, entrypoint) + # + ## +function runDockerProvision() { + ANSIBLE_TAG="$1" + + PROVISION_STATS_FILE="/opt/docker/etc/.registry/provision-stats.${ANSIBLE_TAG}" + + # run provision if stats file doesn't exists (unknown mode) + # or if stats file is not empty + if [[ ! -f "$PROVISION_STATS_FILE" ]] || [[ -s "$PROVISION_STATS_FILE" ]]; then + /opt/docker/bin/provision run --tag "${ANSIBLE_TAG}" --use-registry + fi +} + diff --git a/docker/php-official/7.1/conf/bin/control.sh b/docker/php-official/7.1/conf/bin/control.sh new file mode 100644 index 000000000..22d189745 --- /dev/null +++ b/docker/php-official/7.1/conf/bin/control.sh @@ -0,0 +1,160 @@ +#!/usr/bin/env bash + +set -o pipefail # trace ERR through pipes +set -o errtrace # trace ERR through 'time command' and other functions +set -o nounset ## set -u : exit the script if you try to use an uninitialised variable +set -o errexit ## set -e : exit the script if any statement returns a non-true return value + +source /opt/docker/bin/config.sh + +rootCheck "$0" + +CONTROL_COMMAND="$1" +shift + +case "$CONTROL_COMMAND" in + + ## ------------------------------------------ + ## PROVISION + ## ------------------------------------------ + + ## main roles + "provision.role") + deprecationNotice " Please use >>/opt/docker/bin/provision add --tag bootstrap --tag build --tag onbuild [role]<< for adding provision roles" + /opt/docker/bin/provision add --tag bootstrap --tag build --tag onbuild --tag entrypoint "$1" + ;; + + "provision.role.bootstrap") + deprecationNotice " Please use >>/opt/docker/bin/provision add --tag bootstrap [role]<< for adding provision roles" + /opt/docker/bin/provision add --tag bootstrap "$1" + ;; + + "provision.role.build") + deprecationNotice " Please use >>/opt/docker/bin/provision add --tag build [role]<< for adding provision roles" + /opt/docker/bin/provision add --tag build "$1" + ;; + + "provision.role.onbuild") + deprecationNotice " Please use >>/opt/docker/bin/provision add --tag onbuild [role]<< for adding provision roles" + /opt/docker/bin/provision add --tag onbuild "$1" + ;; + + "provision.role.entrypoint") + deprecationNotice " Please use >>/opt/docker/bin/provision add --tag entrypoint [role]<< for adding provision roles" + /opt/docker/bin/provision add --tag entrypoint "$1" + ;; + + ## startup roles + "provision.role.startup") + deprecationNotice " Please use >>/opt/docker/bin/provision add --tag bootstrap --tag build --tag onbuild --priority 50 [role]<< for adding provision roles" + /opt/docker/bin/provision add --tag bootstrap --tag build --tag onbuild --tag entrypoint --priority 50 "$1" + ;; + + "provision.role.startup.bootstrap") + deprecationNotice " Please use >>/opt/docker/bin/provision add --tag bootstrap --priority 50 [role]<< for adding provision roles" + /opt/docker/bin/provision add --tag bootstrap --priority 50 "$1" + ;; + + "provision.role.startup.build") + deprecationNotice " Please use >>/opt/docker/bin/provision add --tag build --priority 50 [role]<< for adding provision roles" + /opt/docker/bin/provision add --tag build --priority 50 "$1" + ;; + + "provision.role.startup.onbuild") + deprecationNotice " Please use >>/opt/docker/bin/provision add --tag onbuild --priority 50 [role]<< for adding provision roles" + /opt/docker/bin/provision add --tag onbuild --priority 50 "$1" + ;; + + "provision.role.startup.entrypoint") + deprecationNotice " Please use >>/opt/docker/bin/provision add --tag entrypoint --priority 50 [role]<< for adding provision roles" + /opt/docker/bin/provision add --tag entrypoint --priority 50 "$1" + ;; + + ## finish roles + "provision.role.finish") + deprecationNotice " Please use >>/opt/docker/bin/provision add --tag bootstrap --tag build --tag onbuild --priority 200 [role]<< for adding provision roles" + /opt/docker/bin/provision add --tag bootstrap --tag build --tag onbuild --tag entrypoint --priority 200 "$1" + ;; + + "provision.role.finish.bootstrap") + deprecationNotice " Please use >>/opt/docker/bin/provision add --tag bootstrap --priority 200 [role]<< for adding provision roles" + /opt/docker/bin/provision add --tag bootstrap --priority 200 "$1" + ;; + + "provision.role.finish.build") + deprecationNotice " Please use >>/opt/docker/bin/provision add --tag build --priority 200 [role]<< for adding provision roles" + /opt/docker/bin/provision add --tag build --priority 200 "$1" + ;; + + "provision.role.finish.onbuild") + deprecationNotice " Please use >>/opt/docker/bin/provision add --tag onbuild --priority 200 [role]<< for adding provision roles" + /opt/docker/bin/provision add --tag onbuild --priority 200 "$1" + ;; + + "provision.role.finish.entrypoint") + deprecationNotice " Please use >>/opt/docker/bin/provision add --tag entrypoint --priority 200 [role]<< for adding provision roles" + /opt/docker/bin/provision add --tag entrypoint --priority 200 "$1" + ;; + + ## ------------------------------------------ + ## Service + ## ------------------------------------------ + + "service.enable") + deprecationNotice " Please use >>docker-service-enable [service]<<" + docker-service-enable "$1" + ;; + + "service.disable") + deprecationNotice " Please use >>docker-service-disable [service]<<" + docker-service-disable "$1" + ;; + + ## ------------------------------------------ + ## Version + ## ------------------------------------------ + + "version.get") + cat /opt/docker/VERSION + ;; + + "version.require.min") + EXPECTED_VERSION="$1" + CURRENT_VERSION="$(cat /opt/docker/VERSION)" + if [ "$CURRENT_VERSION" -lt "$EXPECTED_VERSION" ]; then + echo "-----------------------------------------------------------" + echo "--- This docker image is not up2date!" + echo "--- " + echo "--- Version expected min: $EXPECTED_VERSION" + echo "--- Version current: $CURRENT_VERSION" + echo "--- " + echo "--- Run 'docker pull ' to update image" + echo "-----------------------------------------------------------" + exit 1 + fi + ;; + + "version.require.max") + EXPECTED_VERSION="$1" + CURRENT_VERSION="$(cat /opt/docker/VERSION)" + if [ "$CURRENT_VERSION" -gt "$EXPECTED_VERSION" ]; then + echo "-----------------------------------------------------------" + echo "--- This docker image is too new!" + echo "--- " + echo "--- Version expected max: $EXPECTED_VERSION" + echo "--- Version current: $CURRENT_VERSION" + echo "-----------------------------------------------------------" + exit 1 + fi + ;; + + + "buildtime.get") + cat /opt/docker/BUILDTIME + ;; + + *) + echo "[ERROR] Invalid controll command: \"${CONTROL_COMMAND}\"" + exit 1 + ;; +esac diff --git a/docker/php-official/7.1/conf/bin/entrypoint.d/cli.sh b/docker/php-official/7.1/conf/bin/entrypoint.d/cli.sh new file mode 100644 index 000000000..fe212a8ea --- /dev/null +++ b/docker/php-official/7.1/conf/bin/entrypoint.d/cli.sh @@ -0,0 +1,19 @@ +#!/usr/bin/env bash + +############################################# +## Run CLI_SCRIPT from environment variable +############################################# + +if [ -n "${CLI_SCRIPT}" ]; then + if [ -n "$APPLICATION_USER" ]; then + # Run as EFFECTIVE_USER + shift + exec gosu "${APPLICATION_USER}" ${CLI_SCRIPT} "$@" + else + # Run as root + exec ${CLI_SCRIPT} "$@" + fi +else + echo "[ERROR] No CLI_SCRIPT in in docker environment defined" + exit 1 +fi diff --git a/docker/php-official/7.1/conf/bin/entrypoint.d/default.sh b/docker/php-official/7.1/conf/bin/entrypoint.d/default.sh new file mode 100644 index 000000000..a1be715fe --- /dev/null +++ b/docker/php-official/7.1/conf/bin/entrypoint.d/default.sh @@ -0,0 +1,3 @@ +#!/usr/bin/env bash + +exec "$@" diff --git a/docker/php-official/7.1/conf/bin/entrypoint.d/noop.sh b/docker/php-official/7.1/conf/bin/entrypoint.d/noop.sh new file mode 100644 index 000000000..092d55d8b --- /dev/null +++ b/docker/php-official/7.1/conf/bin/entrypoint.d/noop.sh @@ -0,0 +1,7 @@ +#!/usr/bin/env bash + +############################################# +## NOOP (no operation) +############################################# + +exec tail -f /dev/null diff --git a/docker/php-official/7.1/conf/bin/entrypoint.d/root.sh b/docker/php-official/7.1/conf/bin/entrypoint.d/root.sh new file mode 100644 index 000000000..6fa0d063e --- /dev/null +++ b/docker/php-official/7.1/conf/bin/entrypoint.d/root.sh @@ -0,0 +1,14 @@ +#!/usr/bin/env bash + +############################################# +## Root shell +############################################# + +if [ "$#" -eq 1 ]; then + ## No command, fall back to interactive shell + exec bash +else + ## Exec root command + shift + exec "$@" +fi diff --git a/docker/php-official/7.1/conf/bin/entrypoint.d/supervisord.sh b/docker/php-official/7.1/conf/bin/entrypoint.d/supervisord.sh new file mode 100644 index 000000000..f21489667 --- /dev/null +++ b/docker/php-official/7.1/conf/bin/entrypoint.d/supervisord.sh @@ -0,0 +1,9 @@ +#!/usr/bin/env bash + +############################################# +## Supervisord (start daemons) +############################################# + +## Start services +exec /opt/docker/bin/service.d/supervisor.sh + diff --git a/docker/php-official/7.1/conf/bin/entrypoint.sh b/docker/php-official/7.1/conf/bin/entrypoint.sh new file mode 100644 index 000000000..01f59660c --- /dev/null +++ b/docker/php-official/7.1/conf/bin/entrypoint.sh @@ -0,0 +1,46 @@ +#!/usr/bin/env bash + +if [[ -z "$CONTAINER_UID" ]]; then + export CONTAINER_UID="application" +fi + +set -o pipefail # trace ERR through pipes +set -o errtrace # trace ERR through 'time command' and other functions +set -o nounset ## set -u : exit the script if you try to use an uninitialised variable +set -o errexit ## set -e : exit the script if any statement returns a non-true return value + +# auto elevate privileges (if container is not started as root) +if [[ "$UID" -ne 0 ]]; then + export CONTAINER_UID="$UID" + exec gosu root "$0" "$@" +fi +# remove suid bit on gosu +chmod -s /usr/local/bin/gosu + +trap 'echo sigterm ; exit' SIGTERM +trap 'echo sigkill ; exit' SIGKILL + +# sanitize input and set task +TASK="$(echo $1| sed 's/[^-_a-zA-Z0-9]*//g')" + +source /opt/docker/bin/config.sh + +createDockerStdoutStderr + +if [[ "$UID" -eq 0 ]]; then + # Only run provision if user is root + + if [ "$TASK" == "supervisord" -o "$TASK" == "noop" ]; then + # Visible provisioning + runProvisionEntrypoint + else + # Hidden provisioning + runProvisionEntrypoint > /dev/null + fi +fi + +############################# +## COMMAND +############################# + +runEntrypoints "$@" diff --git a/docker/php-official/7.1/conf/bin/provision b/docker/php-official/7.1/conf/bin/provision new file mode 100755 index 000000000..d367c2812 --- /dev/null +++ b/docker/php-official/7.1/conf/bin/provision @@ -0,0 +1,328 @@ +#!/usr/bin/env python + +import os +import argparse +import json +import sys +from string import Template +from subprocess import call +import tempfile +import time + +STORAGE = '/opt/docker/etc/.registry/provision.json' +PROVISION_DIR = '/opt/docker/provision/' + +PLAYBOOK_TAGS=['bootstrap', 'build', 'onbuild', 'entrypoint'] + +PLAYBOOK = Template( +"""--- + +- hosts: all + vars_files: + - ./variables-webdevops.yml + - ./variables.yml + roles: + - $roles +""") + + + +def readJson(): + ret = {} + + # create registry directory if it doesn't exists + if not os.path.exists(os.path.dirname(STORAGE)): + os.mkdir(os.path.dirname(STORAGE)) + + # try to read file + if os.path.isfile(STORAGE): + f=open(STORAGE).read() + ret = json.loads(f) + + return ret + + + +def saveJson(data): + with open(STORAGE, 'w') as f: + json.dump(data, f) + + + +def buildRoleList(tags): + json = readJson() + roleList = {} + + # fetch roles list for each tag + for tag in tags: + if tag in json: + for role in json[tag]: + roleRow = json[tag][role] + if role not in roleList: + roleList[role] = {} + + if 'tags' not in roleList[role]: + roleList[role]['tags'] = {} + + roleList[role]['role'] = role + roleList[role]['added'] = roleRow['added'] + roleList[role]['priority'] = roleRow['priority'] + roleList[role]['tags'][tag] = tag + + return roleList + + +def buildSortedRoleList(tags): + roleList = buildRoleList(tags) + + # sort list + roleList = sorted(roleList, key=lambda x: (roleList[x]['priority'], roleList[x]['added'])) + + return roleList + + + +def buildPlaybook(roleList): + ## build playbook + ret = PLAYBOOK.substitute( + roles = "\n - ".join(roleList) + ) + + return ret + + +def buildPlaybookFromArgs(args): + roleList = [] + + ## add roles from tag (if use registry is active) + if args.useRegistry and args.tags: + roleList.extend(buildSortedRoleList(args.tags)) + + ## add roles from command arguments + if args.roles: + for role in args.roles: + roleList.extend(role.split(',')) + + if roleList: + return buildPlaybook(roleList) + else: + return False + + + +def actionRun(args): + if args.playbook: + ## predefined playbook + playbook = args.playbook + else: + ## dynamic playbook + playbookContent = buildPlaybookFromArgs(args) + + if playbookContent: + f = tempfile.NamedTemporaryFile(dir=PROVISION_DIR, prefix='playbook.', suffix='.yml', delete=False) + f.write(playbookContent) + f.close() + playbook = f.name + else: + ## nothing to do + sys.exit(0) + + ## build ansible command with args + cmd = [ + 'ansible-playbook', + playbook, + '-i', 'localhost,', + '--connection=local', + ] + + if args.tags: + cmd.extend([ + '--tags=' + ','.join(args.tags) + ]) + + if args.args: + cmd.extend(args.args) + + ## run ansible + retval = call(cmd) + + ## cleanup dynamic playbook + if not args.playbook: + os.unlink(playbook) + + sys.exit(retval) + + + +def actionPlaybook(args): + playbook = buildPlaybookFromArgs(args) + + if playbook: + print playbook + else: + sys.exit(1) + + + +def actionList(args): + json = readJson() + list = {} + + for tag in args.tags: + if tag in json: + for role in json[tag]: + print role + + + +def actionAdd(args): + json = readJson() + + for tag in args.tags: + for role in args.role: + if tag not in json: + json[tag] = {} + + json[tag][role] = { + 'name': role, + 'added': int(time.time()), + 'priority': args.priority + } + + saveJson(json) + + + +def actionSummary(args): + # list all roles in each possible tag + for tag in PLAYBOOK_TAGS: + roleList = buildRoleList([tag]) + if roleList: + maxLength = len(max(roleList.keys(), key=len)) + + print "Roles in " + tag + ":" + for role in roleList: + print ' - ' + role.ljust(maxLength, ' ') + ' [priority: ' + str(roleList[role]['priority']) + ']' + print '' + + + +def main(args): + actions = { + 'list': actionList, + 'add': actionAdd, + 'summary': actionSummary, + 'playbook': actionPlaybook, + 'run': actionRun + } + + func = actions.get(args.action, lambda: "nothing") + return func(args) + + + + +if __name__ == '__main__': + parser = argparse.ArgumentParser() + subparsers = parser.add_subparsers( + title='subcommands', + dest='action' + ) + + ################################### + ## SUMMARY command + summary = subparsers.add_parser('summary') + + ################################### + ## RUN command + run = subparsers.add_parser('run') + run.add_argument( + '--tag', + dest='tags', + choices=PLAYBOOK_TAGS, + required=True, + action='append', + help='Ansible tag' + ) + run.add_argument( + '--playbook', + dest='playbook', + help='Ansible playbook' + ) + run.add_argument( + '--use-registry', + dest='useRegistry', + action='store_true', + help='Use registred roles' + ) + run.add_argument( + '--role', + dest='roles', + action='append', + help='Ansible role' + ) + run.add_argument('args', nargs=argparse.REMAINDER) + + ################################### + ## PLAYBOOK command + playbook = subparsers.add_parser('playbook') + playbook.add_argument( + '--tag', + dest='tags', + choices=PLAYBOOK_TAGS, + required=True, + action='append', + help='Ansible tag' + ) + playbook.add_argument( + '--use-registry', + dest='useRegistry', + action='store_true', + help='Use registred roles' + ) + playbook.add_argument( + '--role', + dest='roles', + action='append', + help='Ansible tag' + ) + playbook.add_argument('args', nargs=argparse.REMAINDER) + + ################################### + ## LIST command + list = subparsers.add_parser('list') + list.add_argument( + '--tag', + dest='tags', + choices=PLAYBOOK_TAGS, + required=True, + action='append', + help='Ansible tag' + ) + list.add_argument('args', nargs=argparse.REMAINDER) + + ################################### + ## ADD command + add = subparsers.add_parser('add') + add.add_argument( + '--tag', + dest='tags', + choices=PLAYBOOK_TAGS, + required=True, + action='append', + help='Ansible tag' + ) + add.add_argument( + '--priority', + type=int, + default=100, + dest='priority', + help='Priority for role [default 100, 1 is most important]' + ) + add.add_argument('role', metavar='roles', nargs='+', help='Ansible roles') + + add.add_argument('args', nargs=argparse.REMAINDER) + + ## Execute + args = parser.parse_args() + main(args) diff --git a/docker/php-official/7.1/conf/bin/service.d/cron.d/10-init.sh b/docker/php-official/7.1/conf/bin/service.d/cron.d/10-init.sh new file mode 100644 index 000000000..fdffa2a0f --- /dev/null +++ b/docker/php-official/7.1/conf/bin/service.d/cron.d/10-init.sh @@ -0,0 +1 @@ +# placeholder diff --git a/docker/php-official/7.1/conf/bin/service.d/cron.sh b/docker/php-official/7.1/conf/bin/service.d/cron.sh new file mode 100644 index 000000000..9bf7c10bf --- /dev/null +++ b/docker/php-official/7.1/conf/bin/service.d/cron.sh @@ -0,0 +1,7 @@ +#!/usr/bin/env bash + +source /opt/docker/bin/config.sh + +includeScriptDir "/opt/docker/bin/service.d/cron.d/" + +exec /usr/sbin/cron -f diff --git a/docker/php-official/7.1/conf/bin/service.d/dnsmasq.d/10-init.sh b/docker/php-official/7.1/conf/bin/service.d/dnsmasq.d/10-init.sh new file mode 100644 index 000000000..03baba08f --- /dev/null +++ b/docker/php-official/7.1/conf/bin/service.d/dnsmasq.d/10-init.sh @@ -0,0 +1,32 @@ +# Create dnsmasq.d directory if not exists +mkdir -p -- /etc/dnsmasq.d/ + +## clear dns file +echo > /etc/dnsmasq.d/webdevops + +if [ ! -f /etc/resolv.conf.original ]; then + cp -a /etc/resolv.conf /etc/resolv.conf.original + + ## set forward servers + cat /etc/resolv.conf.original | grep nameserver | sed 's/nameserver /server=/' > /etc/dnsmasq.d/forward + + ## set dnsmasq to main nameserver + echo "nameserver 127.0.0.1" > /etc/resolv.conf +fi + + +# Add own VIRTUAL_HOST as loopback +if [[ -n "${VIRTUAL_HOST+x}" ]]; then + # split comma by space + VIRTUAL_HOST_LIST=${VIRTUAL_HOST//,/$'\n'} + + # replace *.domain for dns specific .domain wildcard + VIRTUAL_HOST_LIST=${VIRTUAL_HOST_LIST/\*./.} + + # no support for .* + VIRTUAL_HOST_LIST=${VIRTUAL_HOST_LIST/.\*/.} + + for DOMAIN in $VIRTUAL_HOST_LIST; do + echo "address=/${DOMAIN}/127.0.0.1" >> /etc/dnsmasq.d/webdevops + done +fi diff --git a/docker/php-official/7.1/conf/bin/service.d/dnsmasq.sh b/docker/php-official/7.1/conf/bin/service.d/dnsmasq.sh new file mode 100644 index 000000000..d16b1acbc --- /dev/null +++ b/docker/php-official/7.1/conf/bin/service.d/dnsmasq.sh @@ -0,0 +1,7 @@ +#!/usr/bin/env bash + +source /opt/docker/bin/config.sh + +includeScriptDir "/opt/docker/bin/service.d/dnsmasq.d/" + +exec dnsmasq --keep-in-foreground diff --git a/docker/php-official/7.1/conf/bin/service.d/php-fpm.d/10-init.sh b/docker/php-official/7.1/conf/bin/service.d/php-fpm.d/10-init.sh new file mode 100644 index 000000000..312fcd043 --- /dev/null +++ b/docker/php-official/7.1/conf/bin/service.d/php-fpm.d/10-init.sh @@ -0,0 +1,8 @@ +# setup user env +FPM_POOL_CONF="/opt/docker/etc/php/fpm/pool.d/application.conf" + +## Setup container uid +if [[ -n "$CONTAINER_UID" ]]; then + sed -i "s/user[ ]*=.*/user = ${CONTAINER_UID}/g" "$FPM_POOL_CONF" + sed -i "s/group[ ]*=.*/group = ${CONTAINER_UID}/g" "$FPM_POOL_CONF" +fi diff --git a/docker/php-official/7.1/conf/bin/service.d/php-fpm.d/11-clear-env.sh b/docker/php-official/7.1/conf/bin/service.d/php-fpm.d/11-clear-env.sh new file mode 100644 index 000000000..ef6fd4016 --- /dev/null +++ b/docker/php-official/7.1/conf/bin/service.d/php-fpm.d/11-clear-env.sh @@ -0,0 +1,38 @@ +# +# Workaround for old php-fpm versions which don't have clear_env setting +# + +VARIABLE_LIST="; Workaround for missing clear_env feature in PHP-FPM" + +# For each exported variable +for envVariable in $(printenv|cut -f1 -d=); do + + case "$envVariable" in + "_"|"PATH"|"PWD") + ## ignore this variables + ;; + + *) + ## get content of variable + envVariableContent="${!envVariable}" + + ## php-fpm requires that env variable has to be filled with content + if [[ -n "$envVariableContent" ]]; then + ## quote quotes + envVariableContent=${envVariableContent//\"/\\\"} + + ## add to list + VARIABLE_LIST="${VARIABLE_LIST}"$'\n'"env[${envVariable}] = \"${envVariableContent}\"" + fi + ;; + esac + +done + +# Replace ;#CLEAR_ENV_WORKAROUND# with environment variable list for all php-fpm pool files +go-replace \ + -s ";#CLEAR_ENV_WORKAROUND#" -r "$VARIABLE_LIST" \ + --path=/opt/docker/etc/php/fpm/pool.d/ \ + --path-pattern='*.conf' \ + --ignore-empty + diff --git a/docker/php-official/7.1/conf/bin/service.d/php-fpm.sh b/docker/php-official/7.1/conf/bin/service.d/php-fpm.sh new file mode 100644 index 000000000..b25983bd3 --- /dev/null +++ b/docker/php-official/7.1/conf/bin/service.d/php-fpm.sh @@ -0,0 +1,7 @@ +#!/usr/bin/env bash + +source /opt/docker/bin/config.sh + +includeScriptDir "/opt/docker/bin/service.d/php-fpm.d/" + +exec /usr/local/bin/php-fpm --nodaemonize diff --git a/docker/php-official/7.1/conf/bin/service.d/postfix.d/10-init.sh b/docker/php-official/7.1/conf/bin/service.d/postfix.d/10-init.sh new file mode 100644 index 000000000..cfd876955 --- /dev/null +++ b/docker/php-official/7.1/conf/bin/service.d/postfix.d/10-init.sh @@ -0,0 +1,27 @@ +# force new copy of hosts there (otherwise links could be outdated) +mkdir -p /var/spool/postfix/etc +cp -f /etc/hosts /var/spool/postfix/etc/hosts +cp -f /etc/resolv.conf /var/spool/postfix/etc/resolv.conf +cp -f /etc/services /var/spool/postfix/etc/services + +## MYHOSTNAME +# replace line +sed -i '/myhostname[ ]* =/c\' main.cf +echo "myhostname = $(hostname)" >> /etc/postfix/main.cf + +## REPLAYHOST +if [[ -n "${POSTFIX_RELAYHOST+x}" ]]; then + # replace line + sed -i '/relayhost[ ]* =/c\' main.cf + echo "relayhost = $POSTFIX_RELAYHOST" >> /etc/postfix/main.cf +fi + +## MYNETWORKS +if [[ -n "${POSTFIX_MYNETWORKS+x}" ]]; then + # replace line + sed -i '/mynetworks[ ]* =/c\' main.cf + echo "mynetworks = $POSTFIX_MYNETWORKS" >> /etc/postfix/main.cf +fi + +# generate aliases db +newaliases || : diff --git a/docker/php-official/7.1/conf/bin/service.d/postfix.sh b/docker/php-official/7.1/conf/bin/service.d/postfix.sh new file mode 100644 index 000000000..3ab608679 --- /dev/null +++ b/docker/php-official/7.1/conf/bin/service.d/postfix.sh @@ -0,0 +1,37 @@ +#!/usr/bin/env bash +# postfix-wrapper.sh, version 0.1.0 +# +# You cannot start postfix in some foreground mode and +# it's more or less important that docker doesn't kill +# postfix and its chilren if you stop the container. +# +# Use this script with supervisord and it will take +# care about starting and stopping postfix correctly. +# +# supervisord config snippet for postfix-wrapper: +# +# [program:postfix] +# process_name = postfix +# command = /path/to/postfix-wrapper.sh +# startsecs = 0 +# autorestart = false +# + +source /opt/docker/bin/config.sh + +trap "postfix stop" SIGINT +trap "postfix stop" SIGTERM +trap "postfix reload" SIGHUP + +includeScriptDir "/opt/docker/bin/service.d/postfix.d/" + +# start postfix +postfix start + +# lets give postfix some time to start +sleep 3 + +# wait until postfix is dead (triggered by trap) +while kill -0 "$(cat /var/spool/postfix/pid/master.pid)"; do + sleep 5 +done diff --git a/docker/php-official/7.1/conf/bin/service.d/ssh.d/10-init.sh b/docker/php-official/7.1/conf/bin/service.d/ssh.d/10-init.sh new file mode 100644 index 000000000..f2b600312 --- /dev/null +++ b/docker/php-official/7.1/conf/bin/service.d/ssh.d/10-init.sh @@ -0,0 +1,7 @@ +# Init ssh privilege separation directory +mkdir -p /var/run/sshd +chown root:root /var/run/sshd +chmod 755 /var/run/sshd + +# generate host keys +ssh-keygen -A diff --git a/docker/php-official/7.1/conf/bin/service.d/ssh.sh b/docker/php-official/7.1/conf/bin/service.d/ssh.sh new file mode 100644 index 000000000..ad855563f --- /dev/null +++ b/docker/php-official/7.1/conf/bin/service.d/ssh.sh @@ -0,0 +1,7 @@ +#!/usr/bin/env bash + +source /opt/docker/bin/config.sh + +includeScriptDir "/opt/docker/bin/service.d/ssh.d/" + +exec /usr/sbin/sshd -D diff --git a/docker/php-official/7.1/conf/bin/service.d/supervisor.d/10-init.sh b/docker/php-official/7.1/conf/bin/service.d/supervisor.d/10-init.sh new file mode 100644 index 000000000..fdffa2a0f --- /dev/null +++ b/docker/php-official/7.1/conf/bin/service.d/supervisor.d/10-init.sh @@ -0,0 +1 @@ +# placeholder diff --git a/docker/php-official/7.1/conf/bin/service.d/supervisor.sh b/docker/php-official/7.1/conf/bin/service.d/supervisor.sh new file mode 100644 index 000000000..b1741955a --- /dev/null +++ b/docker/php-official/7.1/conf/bin/service.d/supervisor.sh @@ -0,0 +1,7 @@ +#!/usr/bin/env bash + +source /opt/docker/bin/config.sh + +includeScriptDir "/opt/docker/bin/service.d/supervisor.d/" + +exec supervisord -c /opt/docker/etc/supervisor.conf --logfile /dev/null --pidfile /dev/null --user root diff --git a/docker/php-official/7.1/conf/bin/service.d/syslog-ng.d/10-init.sh b/docker/php-official/7.1/conf/bin/service.d/syslog-ng.d/10-init.sh new file mode 100644 index 000000000..326207e52 --- /dev/null +++ b/docker/php-official/7.1/conf/bin/service.d/syslog-ng.d/10-init.sh @@ -0,0 +1,10 @@ +# If /dev/log is either a named pipe or it was placed there accidentally, +# e.g. because of the issue documented at https://github.com/phusion/baseimage-docker/pull/25, +# then we remove it. +if [ ! -S /dev/log ]; then rm -f /dev/log; fi +if [ ! -S /var/lib/syslog-ng/syslog-ng.ctl ]; then rm -f /var/lib/syslog-ng/syslog-ng.ctl; fi + +if [[ ! -p /docker.stdout ]]; then + # Switch to file (tty docker mode) + go-replace -s 'pipe("/docker.stdout")' -r 'file("/docker.stdout")' -- /opt/docker/etc/syslog-ng/syslog-ng.conf +fi diff --git a/docker/php-official/7.1/conf/bin/service.d/syslog-ng.sh b/docker/php-official/7.1/conf/bin/service.d/syslog-ng.sh new file mode 100644 index 000000000..09d1730ba --- /dev/null +++ b/docker/php-official/7.1/conf/bin/service.d/syslog-ng.sh @@ -0,0 +1,8 @@ +#!/usr/bin/env bash +set -e + +source /opt/docker/bin/config.sh + +includeScriptDir "/opt/docker/bin/service.d/syslog-ng.d/" + +exec syslog-ng -F --no-caps -p /var/run/syslog-ng.pid $SYSLOGNG_OPTS diff --git a/docker/php-official/7.1/conf/bin/usr-bin/docker-provision b/docker/php-official/7.1/conf/bin/usr-bin/docker-provision new file mode 100644 index 000000000..4ee715c64 --- /dev/null +++ b/docker/php-official/7.1/conf/bin/usr-bin/docker-provision @@ -0,0 +1,9 @@ +#!/usr/bin/env bash + +set -o pipefail # trace ERR through pipes +set -o errtrace # trace ERR through 'time command' and other functions +set -o nounset ## set -u : exit the script if you try to use an uninitialised variable +set -o errexit ## set -e : exit the script if any statement returns a non-true return value + +# wrapper +exec /opt/docker/bin/provision "$@" diff --git a/docker/php-official/7.1/conf/bin/usr-bin/docker-service-disable b/docker/php-official/7.1/conf/bin/usr-bin/docker-service-disable new file mode 100644 index 000000000..2b5b31bb4 --- /dev/null +++ b/docker/php-official/7.1/conf/bin/usr-bin/docker-service-disable @@ -0,0 +1,30 @@ +#!/usr/bin/env bash + +set -o pipefail # trace ERR through pipes +set -o errtrace # trace ERR through 'time command' and other functions +set -o nounset ## set -u : exit the script if you try to use an uninitialised variable +set -o errexit ## set -e : exit the script if any statement returns a non-true return value + +source /opt/docker/bin/config.sh + +rootCheck "$0" + +if [[ "$#" -eq 0 ]]; then + echo "Usage: $0 " + exit 1 +fi + +for SERVICE in "$@"; do + SERVICE_FILE="/opt/docker/etc/supervisor.d/${SERVICE}.conf" + + ## Disable service + if [[ -f "$SERVICE_FILE" ]]; then + go-replace --mode=lineinfile \ + -s 'autostart =' -r 'autostart = false' \ + -- "$SERVICE_FILE" + else + echo "[ERROR] Service '${SERVICE}' not found (tried ${SERVICE_FILE})" + exit 1 + fi +done + diff --git a/docker/php-official/7.1/conf/bin/usr-bin/docker-service-enable b/docker/php-official/7.1/conf/bin/usr-bin/docker-service-enable new file mode 100644 index 000000000..8d36a14a9 --- /dev/null +++ b/docker/php-official/7.1/conf/bin/usr-bin/docker-service-enable @@ -0,0 +1,41 @@ +#!/usr/bin/env bash + +set -o pipefail # trace ERR through pipes +set -o errtrace # trace ERR through 'time command' and other functions +set -o nounset ## set -u : exit the script if you try to use an uninitialised variable +set -o errexit ## set -e : exit the script if any statement returns a non-true return value + +source /opt/docker/bin/config.sh + +rootCheck "$0" + +if [[ "$#" -eq 0 ]]; then + echo "Usage: $0 " + exit 1 +fi + +for SERVICE in "$@"; do + SERVICE_FILE="/opt/docker/etc/supervisor.d/${SERVICE}.conf" + PROVISION_FILE="/opt/docker/provision/service.d/${SERVICE}.sh" + + # Run on demand installation/provisioning + if [[ -f "$PROVISION_FILE" ]]; then + echo "Running provisioning for ${SERVICE}, please wait..." + + ## execute scripts + . "$PROVISION_FILE" + + ## remove directory (one run time) + rm -f -- "$PROVISION_FILE" + fi + + ## Enable service + if [[ -f "$SERVICE_FILE" ]]; then + go-replace --mode=lineinfile \ + -s 'autostart =' -r 'autostart = true' \ + -- "$SERVICE_FILE" + else + echo "[ERROR] Service '${SERVICE}' not found (tried ${SERVICE_FILE})" + exit 1 + fi +done diff --git a/docker/php-official/7.1/conf/bin/usr-bin/service b/docker/php-official/7.1/conf/bin/usr-bin/service new file mode 100755 index 000000000..55ea12bf7 --- /dev/null +++ b/docker/php-official/7.1/conf/bin/usr-bin/service @@ -0,0 +1,86 @@ +#!/bin/bash + +set -o pipefail # trace ERR through pipes +set -o errtrace # trace ERR through 'time command' and other functions +set -o nounset ## set -u : exit the script if you try to use an uninitialised variable +set -o errexit ## set -e : exit the script if any statement returns a non-true return value + +# Root check +if [ "$(/usr/bin/whoami)" != "root" ]; then + echo "[ERROR] Must be run as root" + exit 1 +fi + +function serviceHelp() { + echo "Usage: $(basename "$0") " +} + +function getServicePid() { + local serviceName="$1" + local servicePid=$(supervisorctl pid "${serviceName}:${serviceName}d") + + if [[ -z "$servicePid" ]] || [[ "$servicePid" == "0" ]]; then + echo "not running" + exit 1 + fi + + echo $servicePid +} + +# Param check +if [ "$#" -lt 2 ]; then + echo "[ERROR] Missing parameters" + serviceHelp + exit 1 +fi + +############################# +# Param init +############################# + +SERVICENAME="$1" +ACTION="$2" + +############################# +# Service aliases +############################# +case "$SERVICENAME" in + apache2|httpd) + SERVICENAME="apache" + ;; +esac + +############################# +# Action runner +############################# +case "$ACTION" in + stop|start|restart|status) + exec supervisorctl "$ACTION" "${SERVICENAME}:${SERVICENAME}d" + ;; + + pid) + echo $(getServicePid "${SERVICENAME}") + ;; + + check) + FIRST_PID=$(getServicePid "${SERVICENAME}") + sleep 5 + SECOND_PID=$(getServicePid "${SERVICENAME}") + + if [[ "$FIRST_PID" == "$SECOND_PID" ]]; then + echo "ok" + exit 0 + else + echo "not running" + exit 1 + fi + ;; + + + *) + echo "[ERROR] Invalid action" + serviceHelp + exit 1 + ;; + +esac diff --git a/docker/php-official/7.1/conf/etc/logrotate.d/php5-fpm b/docker/php-official/7.1/conf/etc/logrotate.d/php5-fpm new file mode 100644 index 000000000..e6ef4b123 --- /dev/null +++ b/docker/php-official/7.1/conf/etc/logrotate.d/php5-fpm @@ -0,0 +1,12 @@ +/var/log/php5-fpm/fpm.log +/var/log/php5-fpm/access.log +/var/log/php5-fpm/slow.log +/var/log/php5-fpm/error.log { + missingok + notifempty + sharedscripts + delaycompress + postrotate + /bin/kill -SIGUSR1 `cat /var/run/php5-fpm.pid` 2>/dev/null || true + endscript +} diff --git a/docker/php-official/7.1/conf/etc/logrotate.d/syslog-ng b/docker/php-official/7.1/conf/etc/logrotate.d/syslog-ng new file mode 100644 index 000000000..4a6f9c54e --- /dev/null +++ b/docker/php-official/7.1/conf/etc/logrotate.d/syslog-ng @@ -0,0 +1,38 @@ +/var/log/syslog +{ + rotate 7 + daily + missingok + notifempty + delaycompress + compress + postrotate + /bin/kill -HUP `cat /var/run/syslog-ng.pid 2> /dev/null` > /dev/null + endscript +} + +/var/log/mail.info +/var/log/mail.warn +/var/log/mail.err +/var/log/mail.log +/var/log/daemon.log +/var/log/kern.log +/var/log/auth.log +/var/log/user.log +/var/log/lpr.log +/var/log/cron.log +/var/log/debug +/var/log/messages +{ + rotate 4 + weekly + missingok + notifempty + compress + delaycompress + sharedscripts + postrotate + /bin/kill -HUP `cat /var/run/syslog-ng.pid 2> /dev/null` > /dev/null + supervisorctl restart syslog-ng-stdout > /dev/null + endscript +} \ No newline at end of file diff --git a/docker/php-official/7.1/conf/etc/php/conf.d/.gitkeep b/docker/php-official/7.1/conf/etc/php/conf.d/.gitkeep new file mode 100644 index 000000000..e69de29bb diff --git a/docker/php-official/7.1/conf/etc/php/php.ini b/docker/php-official/7.1/conf/etc/php/php.ini new file mode 100644 index 000000000..447212118 --- /dev/null +++ b/docker/php-official/7.1/conf/etc/php/php.ini @@ -0,0 +1 @@ +; placeholder diff --git a/docker/php-official/7.1/conf/etc/php/php.webdevops.ini b/docker/php-official/7.1/conf/etc/php/php.webdevops.ini new file mode 100644 index 000000000..aa1545ab8 --- /dev/null +++ b/docker/php-official/7.1/conf/etc/php/php.webdevops.ini @@ -0,0 +1,34 @@ +; ------------------------------------- +; Docker Webdevops PHP configuration +; ------------------------------------- + +; this file will overwrite default php.ini settings + +display_errors = 0 +log_errors = 1 + +short_open_tag = Off +variables_order = 'GPCS' +request_order = 'GP' + +allow_url_fopen = On +allow_url_include = Off + +memory_limit = 512M +max_execution_time = 300 +max_input_time = 300 +post_max_size = 50M +upload_max_filesize = 50M +max_input_vars = 5000 + +expose_php = Off + +date.timezone = UTC + +mysql.default_host = mysql +mysqli.default_host = mysql + +opcache.memory_consumption = 256 +opcache.interned_strings_buffer = 16 +opcache.max_accelerated_files = 7963 +opcache.fast_shutdown = 1 diff --git a/docker/php-official/7.1/conf/etc/supervisor.conf b/docker/php-official/7.1/conf/etc/supervisor.conf new file mode 100644 index 000000000..479e0db08 --- /dev/null +++ b/docker/php-official/7.1/conf/etc/supervisor.conf @@ -0,0 +1,20 @@ +[supervisord] +nodaemon=true + +[unix_http_server] +file = /.supervisor.sock +chmod = 0700 +chown = root:root +username = root +password = {SHA}e982f17bcbe0f724063b708a4f76db211a999304 + +[supervisorctl] +serverurl = unix:///.supervisor.sock +username = root +password = docker + +[rpcinterface:supervisor] +supervisor.rpcinterface_factory = supervisor.rpcinterface:make_main_rpcinterface + +[include] +files = /opt/docker/etc/supervisor.d/*.conf diff --git a/docker/php-official/7.1/conf/etc/supervisor.d/.gitkeep b/docker/php-official/7.1/conf/etc/supervisor.d/.gitkeep new file mode 100644 index 000000000..e69de29bb diff --git a/docker/php-official/7.1/conf/etc/supervisor.d/cron.conf b/docker/php-official/7.1/conf/etc/supervisor.d/cron.conf new file mode 100644 index 000000000..ef0a71678 --- /dev/null +++ b/docker/php-official/7.1/conf/etc/supervisor.d/cron.conf @@ -0,0 +1,14 @@ +[group:cron] +programs=crond +priority=25 + +[program:crond] +command = /opt/docker/bin/service.d/cron.sh +process_name=%(program_name)s +startsecs = 0 +autostart = false +autorestart = true +stdout_logfile=/dev/stdout +stdout_logfile_maxbytes=0 +stderr_logfile=/dev/stderr +stderr_logfile_maxbytes=0 diff --git a/docker/php-official/7.1/conf/etc/supervisor.d/dnsmasq.conf b/docker/php-official/7.1/conf/etc/supervisor.d/dnsmasq.conf new file mode 100644 index 000000000..9832ffca7 --- /dev/null +++ b/docker/php-official/7.1/conf/etc/supervisor.d/dnsmasq.conf @@ -0,0 +1,14 @@ +[group:dnsmasq] +programs=dnsmasqd +priority=15 + +[program:dnsmasqd] +command = /opt/docker/bin/service.d/dnsmasq.sh +process_name=%(program_name)s +startsecs = 0 +autostart = false +autorestart = true +stdout_logfile=/dev/stdout +stdout_logfile_maxbytes=0 +stderr_logfile=/dev/stderr +stderr_logfile_maxbytes=0 diff --git a/docker/php-official/7.1/conf/etc/supervisor.d/php-fpm.conf b/docker/php-official/7.1/conf/etc/supervisor.d/php-fpm.conf new file mode 100644 index 000000000..5781f5b0a --- /dev/null +++ b/docker/php-official/7.1/conf/etc/supervisor.d/php-fpm.conf @@ -0,0 +1,15 @@ +[group:php-fpm] +programs=php-fpmd +priority=20 + +[program:php-fpmd] +command = /opt/docker/bin/service.d/php-fpm.sh +process_name=%(program_name)s +startsecs = 0 +autostart = true +autorestart = true +stdout_logfile=/dev/stdout +stdout_logfile_maxbytes=0 +stderr_logfile=/dev/stderr +stderr_logfile_maxbytes=0 + diff --git a/docker/php-official/7.1/conf/etc/supervisor.d/postfix.conf b/docker/php-official/7.1/conf/etc/supervisor.d/postfix.conf new file mode 100644 index 000000000..b8d70bb40 --- /dev/null +++ b/docker/php-official/7.1/conf/etc/supervisor.d/postfix.conf @@ -0,0 +1,15 @@ +[group:postfix] +programs=postfixd +priority=30 + +[program:postfixd] +directory = /etc/postfix +command = /opt/docker/bin/service.d/postfix.sh +process_name=%(program_name)s +startsecs = 0 +autostart = false +autorestart = true +stdout_logfile=/dev/stdout +stdout_logfile_maxbytes=0 +stderr_logfile=/dev/stderr +stderr_logfile_maxbytes=0 diff --git a/docker/php-official/7.1/conf/etc/supervisor.d/ssh.conf b/docker/php-official/7.1/conf/etc/supervisor.d/ssh.conf new file mode 100644 index 000000000..0ecd798d6 --- /dev/null +++ b/docker/php-official/7.1/conf/etc/supervisor.d/ssh.conf @@ -0,0 +1,14 @@ +[group:ssh] +programs=sshd +priority=30 + +[program:sshd] +command = /opt/docker/bin/service.d/ssh.sh +process_name=%(program_name)s +startsecs=0 +autostart = false +autorestart = true +stdout_logfile=/dev/stdout +stdout_logfile_maxbytes=0 +stderr_logfile=/dev/stderr +stderr_logfile_maxbytes=0 diff --git a/docker/php-official/7.1/conf/etc/supervisor.d/syslog.conf b/docker/php-official/7.1/conf/etc/supervisor.d/syslog.conf new file mode 100644 index 000000000..20d1e238c --- /dev/null +++ b/docker/php-official/7.1/conf/etc/supervisor.d/syslog.conf @@ -0,0 +1,13 @@ +[group:syslog] +programs=syslogd +priority=10 + +[program:syslogd] +command = /opt/docker/bin/service.d/syslog-ng.sh +process_name=%(program_name)s +autostart = false +autorestart = true +stdout_logfile=/dev/stdout +stdout_logfile_maxbytes=0 +stderr_logfile=/dev/stderr +stderr_logfile_maxbytes=0 diff --git a/docker/php-official/7.1/conf/etc/syslog-ng/syslog-ng.conf b/docker/php-official/7.1/conf/etc/syslog-ng/syslog-ng.conf new file mode 100644 index 000000000..c69841581 --- /dev/null +++ b/docker/php-official/7.1/conf/etc/syslog-ng/syslog-ng.conf @@ -0,0 +1,48 @@ +@version: 3.5 + +template t_isostamp { + # syslog-t_isostamp START + template("[SYSLOG] $MSGHDR$MSG\n"); + # syslog-t_isostamp END +}; + +options { + # syslog-options START + file-template(t_isostamp); + chain_hostnames(off); + flush_lines(0); + use-dns(no); + use_fqdn(no); + owner("root"); + group("adm"); + perm(0640); + stats_freq(0); + # syslog-options START +}; + +source s_src { + # syslog-s_src START + unix-stream("/dev/log"); + internal(); + # syslog-s_src END +}; + +filter f_filter { + # syslog-f_filter START + not facility(auth, authpriv); + # syslog-f_filter END +}; + +destination d_all { + # syslog-d_all START + pipe("/docker.stdout"); + # syslog-d_all END +}; + +log { + # syslog-log START + source(s_src); + filter(f_filter); + destination(d_all); + # syslog-log START +}; diff --git a/docker/php-official/7.1/conf/provision/ansible.cfg b/docker/php-official/7.1/conf/provision/ansible.cfg new file mode 100644 index 000000000..e69de29bb diff --git a/docker/php-official/7.1/conf/provision/bootstrap.d/.gitkeep b/docker/php-official/7.1/conf/provision/bootstrap.d/.gitkeep new file mode 100644 index 000000000..e69de29bb diff --git a/docker/php-official/7.1/conf/provision/build.d/.gitkeep b/docker/php-official/7.1/conf/provision/build.d/.gitkeep new file mode 100644 index 000000000..e69de29bb diff --git a/docker/php-official/7.1/conf/provision/build.d/10-cleanup.sh b/docker/php-official/7.1/conf/provision/build.d/10-cleanup.sh new file mode 100644 index 000000000..20fbdc841 --- /dev/null +++ b/docker/php-official/7.1/conf/provision/build.d/10-cleanup.sh @@ -0,0 +1,6 @@ +#!/usr/bin/env bash + +## remove logs (each bootstrap) +rm -rf -- /var/log/* +rm -rf -- /var/tmp/* +rm -rf -- /tmp/* diff --git a/docker/php-official/7.1/conf/provision/entrypoint.d/.gitkeep b/docker/php-official/7.1/conf/provision/entrypoint.d/.gitkeep new file mode 100644 index 000000000..e69de29bb diff --git a/docker/php-official/7.1/conf/provision/entrypoint.d/05-permissions.sh b/docker/php-official/7.1/conf/provision/entrypoint.d/05-permissions.sh new file mode 100644 index 000000000..6f77d8e40 --- /dev/null +++ b/docker/php-official/7.1/conf/provision/entrypoint.d/05-permissions.sh @@ -0,0 +1,2 @@ +# Fix rights of /tmp (can be a volume) +chmod 1777 /tmp diff --git a/docker/php-official/7.1/conf/provision/onbuild.d/.gitkeep b/docker/php-official/7.1/conf/provision/onbuild.d/.gitkeep new file mode 100644 index 000000000..e69de29bb diff --git a/docker/php-official/7.1/conf/provision/roles/webdevops-base-app/defaults/main.yml b/docker/php-official/7.1/conf/provision/roles/webdevops-base-app/defaults/main.yml new file mode 100644 index 000000000..e10ef7d38 --- /dev/null +++ b/docker/php-official/7.1/conf/provision/roles/webdevops-base-app/defaults/main.yml @@ -0,0 +1,7 @@ +--- + +APPLICATION_USER: "{{ lookup('env','APPLICATION_USER') }}" +APPLICATION_GROUP: "{{ lookup('env','APPLICATION_GROUP') }}" +APPLICATION_PATH: "{{ lookup('env','APPLICATION_PATH') }}" +APPLICATION_UID: "{{ lookup('env','APPLICATION_UID') }}" +APPLICATION_GID: "{{ lookup('env','APPLICATION_GID') }}" diff --git a/docker/php-official/7.1/conf/provision/roles/webdevops-base-app/tasks/bootstrap.yml b/docker/php-official/7.1/conf/provision/roles/webdevops-base-app/tasks/bootstrap.yml new file mode 100644 index 000000000..3fdce9a74 --- /dev/null +++ b/docker/php-official/7.1/conf/provision/roles/webdevops-base-app/tasks/bootstrap.yml @@ -0,0 +1,4 @@ +--- + +- include: bootstrap/user.yml +- include: bootstrap/application.yml diff --git a/docker/php-official/7.1/conf/provision/roles/webdevops-base-app/tasks/bootstrap/application.yml b/docker/php-official/7.1/conf/provision/roles/webdevops-base-app/tasks/bootstrap/application.yml new file mode 100644 index 000000000..faddb6027 --- /dev/null +++ b/docker/php-official/7.1/conf/provision/roles/webdevops-base-app/tasks/bootstrap/application.yml @@ -0,0 +1,10 @@ +--- + +- name: Init application directory + file: + path: "/{{ APPLICATION_PATH }}" + state: directory + mode: 0755 + owner: "{{ APPLICATION_USER }}" + group: "{{ APPLICATION_GROUP }}" + recurse: yes diff --git a/docker/php-official/7.1/conf/provision/roles/webdevops-base-app/tasks/bootstrap/user.yml b/docker/php-official/7.1/conf/provision/roles/webdevops-base-app/tasks/bootstrap/user.yml new file mode 100644 index 000000000..fd58b329f --- /dev/null +++ b/docker/php-official/7.1/conf/provision/roles/webdevops-base-app/tasks/bootstrap/user.yml @@ -0,0 +1,35 @@ +--- + +- name: Create application group + group: + name: "{{ APPLICATION_GROUP }}" + gid: "{{ APPLICATION_GID }}" + +- name: Create application user + user: + name: "{{ APPLICATION_USER }}" + uid: "{{ APPLICATION_UID }}" + group: "{{ APPLICATION_GROUP }}" + shell: "/bin/bash" + home: "/home/{{ APPLICATION_USER }}" + +- name: Init home directory + file: + path: "/home/{{ APPLICATION_USER }}" + state: directory + mode: 0755 + owner: "{{ APPLICATION_USER }}" + group: "{{ APPLICATION_GROUP }}" + recurse: yes + +- name: Init bashrc + lineinfile: + dest: "/home/{{ APPLICATION_USER }}/.bashrc" + mode: 0770 + owner: "{{ APPLICATION_USER }}" + group: "{{ APPLICATION_GROUP }}" + create: yes + regexp: "export TERM=xterm" + line: "export TERM=xterm" + +- action: setup diff --git a/docker/php-official/7.1/conf/provision/roles/webdevops-base-app/tasks/main.yml b/docker/php-official/7.1/conf/provision/roles/webdevops-base-app/tasks/main.yml new file mode 100644 index 000000000..1806c1a8c --- /dev/null +++ b/docker/php-official/7.1/conf/provision/roles/webdevops-base-app/tasks/main.yml @@ -0,0 +1,5 @@ +--- + +- include: bootstrap.yml + tags: + - bootstrap diff --git a/docker/php-official/7.1/conf/provision/roles/webdevops-base/defaults/main.yml b/docker/php-official/7.1/conf/provision/roles/webdevops-base/defaults/main.yml new file mode 100644 index 000000000..81f5b7efd --- /dev/null +++ b/docker/php-official/7.1/conf/provision/roles/webdevops-base/defaults/main.yml @@ -0,0 +1,6 @@ +--- + +APPLICATION_USER: "{{ lookup('env','APPLICATION_USER') }}" +APPLICATION_GROUP: "{{ lookup('env','APPLICATION_GROUP') }}" +APPLICATION_UID: "{{ lookup('env','APPLICATION_UID') }}" +APPLICATION_GID: "{{ lookup('env','APPLICATION_GID') }}" diff --git a/docker/php-official/7.1/conf/provision/roles/webdevops-base/tasks/bootstrap.yml b/docker/php-official/7.1/conf/provision/roles/webdevops-base/tasks/bootstrap.yml new file mode 100644 index 000000000..9f842336c --- /dev/null +++ b/docker/php-official/7.1/conf/provision/roles/webdevops-base/tasks/bootstrap.yml @@ -0,0 +1,8 @@ +--- + +- include: bootstrap/system.yml +- include: bootstrap/misc.yml +- include: bootstrap/root.yml +- include: bootstrap/supervisor.yml +- include: bootstrap/pam.yml +- include: bootstrap/entrypoint.yml diff --git a/docker/php-official/7.1/conf/provision/roles/webdevops-base/tasks/bootstrap/entrypoint.yml b/docker/php-official/7.1/conf/provision/roles/webdevops-base/tasks/bootstrap/entrypoint.yml new file mode 100644 index 000000000..d5d8809f4 --- /dev/null +++ b/docker/php-official/7.1/conf/provision/roles/webdevops-base/tasks/bootstrap/entrypoint.yml @@ -0,0 +1,8 @@ +--- + +- name: Create link for entrypoint + file: + src: '/opt/docker/bin/entrypoint.sh' + dest: '/entrypoint' + state: link + force: yes diff --git a/docker/php-official/7.1/conf/provision/roles/webdevops-base/tasks/bootstrap/misc.yml b/docker/php-official/7.1/conf/provision/roles/webdevops-base/tasks/bootstrap/misc.yml new file mode 100644 index 000000000..4eed695b1 --- /dev/null +++ b/docker/php-official/7.1/conf/provision/roles/webdevops-base/tasks/bootstrap/misc.yml @@ -0,0 +1,8 @@ +--- + +- file: + path: "/var/log/wtmp" + state: touch + mode: 0664 + owner: "root" + group: "root" diff --git a/docker/php-official/7.1/conf/provision/roles/webdevops-base/tasks/bootstrap/pam.yml b/docker/php-official/7.1/conf/provision/roles/webdevops-base/tasks/bootstrap/pam.yml new file mode 100644 index 000000000..a18b2412a --- /dev/null +++ b/docker/php-official/7.1/conf/provision/roles/webdevops-base/tasks/bootstrap/pam.yml @@ -0,0 +1,8 @@ +--- + +- name: Ensure su execution [Alpine family] + lineinfile: + dest: "/etc/pam.d/su" + line: "auth sufficient pam_rootok.so" + create: yes + when: ansible_os_family == "Alpine" diff --git a/docker/php-official/7.1/conf/provision/roles/webdevops-base/tasks/bootstrap/root.yml b/docker/php-official/7.1/conf/provision/roles/webdevops-base/tasks/bootstrap/root.yml new file mode 100644 index 000000000..29e955fa4 --- /dev/null +++ b/docker/php-official/7.1/conf/provision/roles/webdevops-base/tasks/bootstrap/root.yml @@ -0,0 +1,5 @@ +--- + +- file: + path: "/root/.profile" + state: absent diff --git a/docker/php-official/7.1/conf/provision/roles/webdevops-base/tasks/bootstrap/supervisor.yml b/docker/php-official/7.1/conf/provision/roles/webdevops-base/tasks/bootstrap/supervisor.yml new file mode 100644 index 000000000..2ce07ac26 --- /dev/null +++ b/docker/php-official/7.1/conf/provision/roles/webdevops-base/tasks/bootstrap/supervisor.yml @@ -0,0 +1,13 @@ +--- + +- name: Remove /usr/sbin/service + file: + path: '/usr/sbin/service' + state: absent + +- name: Create link for supervisor.conf + file: + src: '/opt/docker/etc/supervisor.conf' + dest: '/etc/supervisord.conf' + state: link + force: yes diff --git a/docker/php-official/7.1/conf/provision/roles/webdevops-base/tasks/bootstrap/system.yml b/docker/php-official/7.1/conf/provision/roles/webdevops-base/tasks/bootstrap/system.yml new file mode 100644 index 000000000..0741d7cae --- /dev/null +++ b/docker/php-official/7.1/conf/provision/roles/webdevops-base/tasks/bootstrap/system.yml @@ -0,0 +1,33 @@ +--- + +- name: Create /entrypoint.d + file: + path: "/entrypoint.d" + state: directory + owner: "root" + group: "root" + mode: 0700 + +- name: Create /entrypoint.cmd + file: + src: '/opt/docker/bin/entrypoint.d' + dest: '/entrypoint.cmd' + state: link + force: yes + +- name: Remove system logrotate and cronjobs (not needed) + file: + path: '{{ item }}' + state: absent + with_items: + # Debian/Ubuntu + - /etc/cron.daily/logrotate + - /etc/cron.daily/apt-compat + - /etc/cron.daily/dpkg + - /etc/cron.daily/passwd + # RedHat + - /etc/cron.daily/0yum-daily.cron + - /etc/cron.daily/logrotate + - /etc/cron.hourly/0yum-hourly.cron + # Alpine + - /etc/periodic/daily/logrotate diff --git a/docker/php-official/7.1/conf/provision/roles/webdevops-base/tasks/build.yml b/docker/php-official/7.1/conf/provision/roles/webdevops-base/tasks/build.yml new file mode 100644 index 000000000..cd21505a4 --- /dev/null +++ b/docker/php-official/7.1/conf/provision/roles/webdevops-base/tasks/build.yml @@ -0,0 +1,2 @@ +--- + diff --git a/docker/php-official/7.1/conf/provision/roles/webdevops-base/tasks/build/.gitkeep b/docker/php-official/7.1/conf/provision/roles/webdevops-base/tasks/build/.gitkeep new file mode 100644 index 000000000..e69de29bb diff --git a/docker/php-official/7.1/conf/provision/roles/webdevops-base/tasks/entrypoint.yml b/docker/php-official/7.1/conf/provision/roles/webdevops-base/tasks/entrypoint.yml new file mode 100644 index 000000000..ed97d539c --- /dev/null +++ b/docker/php-official/7.1/conf/provision/roles/webdevops-base/tasks/entrypoint.yml @@ -0,0 +1 @@ +--- diff --git a/docker/php-official/7.1/conf/provision/roles/webdevops-base/tasks/entrypoint/.gitkeep b/docker/php-official/7.1/conf/provision/roles/webdevops-base/tasks/entrypoint/.gitkeep new file mode 100644 index 000000000..e69de29bb diff --git a/docker/php-official/7.1/conf/provision/roles/webdevops-base/tasks/main.yml b/docker/php-official/7.1/conf/provision/roles/webdevops-base/tasks/main.yml new file mode 100644 index 000000000..66fb2e38b --- /dev/null +++ b/docker/php-official/7.1/conf/provision/roles/webdevops-base/tasks/main.yml @@ -0,0 +1,13 @@ +--- + +- include: bootstrap.yml + tags: + - bootstrap + +- include: build.yml + tags: + - build + +- include: entrypoint.yml + tags: + - entrypoint diff --git a/docker/php-official/7.1/conf/provision/roles/webdevops-cleanup/tasks/cleanup.yml b/docker/php-official/7.1/conf/provision/roles/webdevops-cleanup/tasks/cleanup.yml new file mode 100644 index 000000000..ddd0abbc4 --- /dev/null +++ b/docker/php-official/7.1/conf/provision/roles/webdevops-cleanup/tasks/cleanup.yml @@ -0,0 +1,16 @@ +--- + +- name: Filesystem cleanup [Debian family] + file: + path: "{{ item }}" + state: absent + with_fileglob: + - /var/cache/apt/archives/*.deb + - /var/cache/apt/archives/partial/* + - /var/cache/debconf/*-old + - /var/lib/apt/lists/* + when: ansible_os_family == "Debian" + +- name: Yum cleanup [RedHat family] + command: yum clean all + when: ansible_os_family == "RedHat" diff --git a/docker/php-official/7.1/conf/provision/roles/webdevops-cleanup/tasks/main.yml b/docker/php-official/7.1/conf/provision/roles/webdevops-cleanup/tasks/main.yml new file mode 100644 index 000000000..951b7fc67 --- /dev/null +++ b/docker/php-official/7.1/conf/provision/roles/webdevops-cleanup/tasks/main.yml @@ -0,0 +1,6 @@ +--- + +- include: cleanup.yml + tags: + - bootstrap + - onbuild diff --git a/docker/php-official/7.1/conf/provision/roles/webdevops-php/defaults/main.yml b/docker/php-official/7.1/conf/provision/roles/webdevops-php/defaults/main.yml new file mode 100644 index 000000000..81f5b7efd --- /dev/null +++ b/docker/php-official/7.1/conf/provision/roles/webdevops-php/defaults/main.yml @@ -0,0 +1,6 @@ +--- + +APPLICATION_USER: "{{ lookup('env','APPLICATION_USER') }}" +APPLICATION_GROUP: "{{ lookup('env','APPLICATION_GROUP') }}" +APPLICATION_UID: "{{ lookup('env','APPLICATION_UID') }}" +APPLICATION_GID: "{{ lookup('env','APPLICATION_GID') }}" diff --git a/docker/php-official/7.1/conf/provision/roles/webdevops-php/tasks/bootstrap.yml b/docker/php-official/7.1/conf/provision/roles/webdevops-php/tasks/bootstrap.yml new file mode 100644 index 000000000..99a2e5191 --- /dev/null +++ b/docker/php-official/7.1/conf/provision/roles/webdevops-php/tasks/bootstrap.yml @@ -0,0 +1,10 @@ +--- + +- include: bootstrap/init.yml +- include: bootstrap/php.yml +- include: bootstrap/php.debian.yml +- include: bootstrap/php.redhat.yml +- include: bootstrap/php.alpine.yml +- include: bootstrap/php-fpm.main.yml +- include: bootstrap/php-fpm.pool.yml +- include: bootstrap/php-fpm.yml diff --git a/docker/php-official/7.1/conf/provision/roles/webdevops-php/tasks/bootstrap/init.yml b/docker/php-official/7.1/conf/provision/roles/webdevops-php/tasks/bootstrap/init.yml new file mode 100644 index 000000000..df39e4bd4 --- /dev/null +++ b/docker/php-official/7.1/conf/provision/roles/webdevops-php/tasks/bootstrap/init.yml @@ -0,0 +1,23 @@ +--- + +- name: Get php version + command: "php -r 'echo phpversion();'" + changed_when: true + register: php_version_cmd + ignore_errors: true + +- name: Set php_version version + set_fact: + php_version: "{{php_version_cmd.stdout}}" + +############################# +# PHP +############################# + +- name: Set php main file (official) + set_fact: + php_etc_dir: /usr/local/etc/php + php_main_conf: /usr/local/etc/php-fpm.conf + php_pool_conf: www.conf + php_pool_dir: /usr/local/etc/php-fpm.d + php_fpm_bin: /usr/local/sbin/php-fpm diff --git a/docker/php-official/7.1/conf/provision/roles/webdevops-php/tasks/bootstrap/php-fpm.main.yml b/docker/php-official/7.1/conf/provision/roles/webdevops-php/tasks/bootstrap/php-fpm.main.yml new file mode 100644 index 000000000..c149d8728 --- /dev/null +++ b/docker/php-official/7.1/conf/provision/roles/webdevops-php/tasks/bootstrap/php-fpm.main.yml @@ -0,0 +1,49 @@ +--- + +- name: Create php directories + file: + path: "{{ item }}" + state: directory + mode: 0755 + owner: "root" + group: "root" + with_items: + - /opt/docker/etc/php/fpm/ + +- name: Move php-fpm main file to /opt/docker/etc/php/fpm/ + command: "mv {{ php_main_conf }} /opt/docker/etc/php/fpm/php-fpm.conf" + args: + creates: /opt/docker/etc/php/fpm/php-fpm.conf + +- name: Remove php-fpm main file + file: + path: "{{ php_main_conf }}" + state: absent + +- name: Symlink php-fpm main file + file: + path: "{{ php_main_conf }}" + src: "/opt/docker/etc/php/fpm/php-fpm.conf" + state: link + owner: "root" + group: "root" + +- name: Configure php-fpm main (all versions) + lineinfile: + dest: '/opt/docker/etc/php/fpm/php-fpm.conf' + regexp: '^[\s;]*{{ item.key }}[\s]*=' + line: '{{ item.key }} = {{ item.value }}' + insertafter: '\[global\]' + with_items: + - { key: 'error_log', value: "/docker.stderr" } + - { key: 'pid', value: "/var/run/php-fpm.pid" } + +- name: Configure php-fpm main (php 5.x) + lineinfile: + dest: '/opt/docker/etc/php/fpm/php-fpm.conf' + regexp: '^[\s;]*{{ item.key }}[\s]*=' + line: '{{ item.key }} = {{ item.value }}' + insertbefore: '[\s]*include[\s]*=' + with_items: + - { key: 'daemonize', value: 'no' } + when: ( php_version | version_compare('7.0.0', '<') ) diff --git a/docker/php-official/7.1/conf/provision/roles/webdevops-php/tasks/bootstrap/php-fpm.pool.yml b/docker/php-official/7.1/conf/provision/roles/webdevops-php/tasks/bootstrap/php-fpm.pool.yml new file mode 100644 index 000000000..ab0b7b02c --- /dev/null +++ b/docker/php-official/7.1/conf/provision/roles/webdevops-php/tasks/bootstrap/php-fpm.pool.yml @@ -0,0 +1,101 @@ +--- + +- set_fact: + php_clear_env_available: False + +- set_fact: + php_clear_env_available: True + when: ( php_version | version_compare('5.4', 'eq') and php_version | version_compare('5.4.27', 'ge') ) or + ( php_version | version_compare('5.5', 'eq') and php_version | version_compare('5.5.11', 'ge') ) or + ( php_version | version_compare('5.6', 'ge') ) + +- name: Create /opt/docker/etc/php/fpm directory + file: + path: "/opt/docker/etc/php/fpm" + state: directory + +- name: Move php-fpm pool directory file to /opt/docker/etc/php/ + command: "mv {{ php_pool_dir }} /opt/docker/etc/php/fpm/pool.d" + args: + creates: /opt/docker/etc/php/fpm/pool.d + +- name: Rename pool file file to application.conf" + command: "mv /opt/docker/etc/php/fpm/pool.d/{{ php_pool_conf }} /opt/docker/etc/php/fpm/pool.d/application.conf" + args: + creates: /opt/docker/etc/php/fpm/pool.d/application.conf + +- name: Remove php-fpm pool directory + file: + path: "{{ php_pool_dir }}" + state: absent + +- name: Symlink php-fpm pool file + file: + path: "{{ php_pool_dir }}" + src: "/opt/docker/etc/php/fpm/pool.d" + state: link + owner: "root" + group: "root" + +- name: Configure php-fpm pool user (application.conf) + lineinfile: + dest: '/opt/docker/etc/php/fpm/pool.d/application.conf' + regexp: '^[\s;]*{{ item.key }}[\s]*=' + line: '{{ item.key }} = {{ item.value }}' + with_items: + - { key: 'listen', value: "[::]:9000" } + - { key: 'catch_workers_output', value: "yes" } + - { key: 'access.format', value: '[php-fpm:access] %R - %u %t "%m %r%Q%q" %s %f %{mili}d %{kilo}M %C%%' } + - { key: 'access.log', value: "/docker.stdout" } + - { key: 'slowlog', value: "/docker.stderr" } + - { key: 'php_admin_value[error_log]', value: "/docker.stderr" } + - { key: 'php_admin_value[log_errors]', value: "on" } + - { key: 'user', value: "{{ APPLICATION_USER }}" } + - { key: 'group', value: "{{ APPLICATION_GROUP }}" } + +- name: Configure php-fpm pool user (application.conf) + lineinfile: + dest: '/opt/docker/etc/php/fpm/pool.d/application.conf' + regexp: '^[\s;]*{{ item.key }}[\s]*=' + line: '{{ item.key }} = {{ item.value }}' + with_items: + - { key: 'listen', value: "0.0.0.0:9000" } + when: php_version | version_compare('5.5.99', '<=') + +- name: Configure php-fpm pool user (application.conf) + lineinfile: + dest: '/opt/docker/etc/php/fpm/pool.d/application.conf' + regexp: '^[\s;]*{{ item.key }}[\s]*=' + line: ';{{ item.key }} = {{ item.value }}' + with_items: + - { key: 'access.log', value: "/docker.stdout" } + +- name: Disable clear env in php-fpm pool + lineinfile: + dest: '/opt/docker/etc/php/fpm/pool.d/application.conf' + regexp: '^[\s;]*{{ item.key }}[\s]*=' + line: '{{ item.key }} = {{ item.value }}' + with_items: + - { key: 'clear_env', value: "no" } + when: php_clear_env_available == True + +- name: Remove clear env workaround + file: + path: "/opt/docker/bin/service.d/php-fpm.d/11-clear-env.sh" + state: absent + when: php_clear_env_available == True + +- name: Append clear env workaround in php-fpm pool (old php-fpm versions) + lineinfile: + dest: '/opt/docker/etc/php/fpm/pool.d/application.conf' + line: ';#CLEAR_ENV_WORKAROUND#' + when: php_clear_env_available == False + +- name: Disable php-fpm connection limit + lineinfile: + dest: '/opt/docker/etc/php/fpm/pool.d/application.conf' + regexp: '^[\s;]*{{ item.key }}[\s]*=' + line: ';{{ item.key }}' + with_items: + - { key: 'listen.allowed_clients' } + diff --git a/docker/php-official/7.1/conf/provision/roles/webdevops-php/tasks/bootstrap/php-fpm.yml b/docker/php-official/7.1/conf/provision/roles/webdevops-php/tasks/bootstrap/php-fpm.yml new file mode 100644 index 000000000..41c1b33dc --- /dev/null +++ b/docker/php-official/7.1/conf/provision/roles/webdevops-php/tasks/bootstrap/php-fpm.yml @@ -0,0 +1,9 @@ +--- + +- name: Symlink php-fpm binary + file: + path: "/usr/local/bin/php-fpm" + src: "{{ php_fpm_bin }}" + state: link + owner: "root" + group: "root" diff --git a/docker/php-official/7.1/conf/provision/roles/webdevops-php/tasks/bootstrap/php.alpine.yml b/docker/php-official/7.1/conf/provision/roles/webdevops-php/tasks/bootstrap/php.alpine.yml new file mode 100644 index 000000000..4c16cdf0d --- /dev/null +++ b/docker/php-official/7.1/conf/provision/roles/webdevops-php/tasks/bootstrap/php.alpine.yml @@ -0,0 +1,12 @@ +--- + +- name: Create link for additional php.ini [Alpine family] + file: + src: '/opt/docker/etc/php/{{ item.file }}' + dest: '{{ php_etc_dir }}/conf.d/{{ item.target }}' + state: link + force: yes + with_items: + - { file: 'php.webdevops.ini', target: 'xzza-webdevops.ini'} + - { file: 'php.ini', target: 'xzzz-docker.ini'} + when: ansible_os_family == 'Alpine' diff --git a/docker/php-official/7.1/conf/provision/roles/webdevops-php/tasks/bootstrap/php.debian.yml b/docker/php-official/7.1/conf/provision/roles/webdevops-php/tasks/bootstrap/php.debian.yml new file mode 100644 index 000000000..411e736c8 --- /dev/null +++ b/docker/php-official/7.1/conf/provision/roles/webdevops-php/tasks/bootstrap/php.debian.yml @@ -0,0 +1,11 @@ +--- + +- name: Link php.ini for cli and fpm [Official PHP] + file: + src: '{{ item.file }}' + dest: '{{ php_etc_dir }}/conf.d/{{ item.target }}' + force: yes + state: link + with_items: + - { category: 'cli', file: '/opt/docker/etc/php/php.webdevops.ini', target: '98-webdevops.ini' } + - { category: 'cli', file: '/opt/docker/etc/php/php.ini', target: '99-docker.ini' } diff --git a/docker/php-official/7.1/conf/provision/roles/webdevops-php/tasks/bootstrap/php.redhat.yml b/docker/php-official/7.1/conf/provision/roles/webdevops-php/tasks/bootstrap/php.redhat.yml new file mode 100644 index 000000000..7e8810231 --- /dev/null +++ b/docker/php-official/7.1/conf/provision/roles/webdevops-php/tasks/bootstrap/php.redhat.yml @@ -0,0 +1,12 @@ +--- + +- name: Create link for additional php.ini [RedHat family] + file: + src: '/opt/docker/etc/php/{{ item.file }}' + dest: '/etc/php.d/{{ item.target }}' + state: link + force: yes + with_items: + - { file: 'php.webdevops.ini', target: 'zza-webdevops.ini'} + - { file: 'php.ini', target: 'zzz-docker.ini'} + when: ansible_os_family == 'RedHat' diff --git a/docker/php-official/7.1/conf/provision/roles/webdevops-php/tasks/bootstrap/php.yml b/docker/php-official/7.1/conf/provision/roles/webdevops-php/tasks/bootstrap/php.yml new file mode 100644 index 000000000..caac8f413 --- /dev/null +++ b/docker/php-official/7.1/conf/provision/roles/webdevops-php/tasks/bootstrap/php.yml @@ -0,0 +1,23 @@ +--- + +- name: Create php directories + file: + path: "{{ item }}" + state: directory + mode: 0755 + owner: "root" + group: "root" + with_items: + - /opt/docker/etc/php/ + - /opt/docker/etc/php/fpm/ + +- name: Create php.ini files + file: + path: "{{ item }}" + state: touch + mode: 0744 + owner: root + group: root + with_items: + - "/opt/docker/etc/php/php.webdevops.ini" + - "/opt/docker/etc/php/php.ini" diff --git a/docker/php-official/7.1/conf/provision/roles/webdevops-php/tasks/main.yml b/docker/php-official/7.1/conf/provision/roles/webdevops-php/tasks/main.yml new file mode 100644 index 000000000..1806c1a8c --- /dev/null +++ b/docker/php-official/7.1/conf/provision/roles/webdevops-php/tasks/main.yml @@ -0,0 +1,5 @@ +--- + +- include: bootstrap.yml + tags: + - bootstrap diff --git a/docker/php-official/7.1/conf/provision/service.d/.gitkeep b/docker/php-official/7.1/conf/provision/service.d/.gitkeep new file mode 100644 index 000000000..e69de29bb diff --git a/docker/php-official/7.1/conf/provision/service.d/cron.sh b/docker/php-official/7.1/conf/provision/service.d/cron.sh new file mode 100644 index 000000000..bd8a54781 --- /dev/null +++ b/docker/php-official/7.1/conf/provision/service.d/cron.sh @@ -0,0 +1,13 @@ +#!/usr/bin/env bash + +IMAGE_FAMILY=$(docker-image-info family) + +case "$IMAGE_FAMILY" in + Debian|Ubuntu) + apt-install cron + ;; + + RedHat) + yum-install cronie + ;; +esac diff --git a/docker/php-official/7.1/conf/provision/service.d/dnsmasq.sh b/docker/php-official/7.1/conf/provision/service.d/dnsmasq.sh new file mode 100644 index 000000000..9e5c3228c --- /dev/null +++ b/docker/php-official/7.1/conf/provision/service.d/dnsmasq.sh @@ -0,0 +1,24 @@ +#!/usr/bin/env bash + +IMAGE_FAMILY=$(docker-image-info family) + +# Installation +case "$IMAGE_FAMILY" in + Debian|Ubuntu) + apt-install dnsmasq + ;; + + RedHat) + yum-install dnsmasq + ;; + + Alpine) + apk-install dnsmasq + ;; +esac + +# Configuration +go-replace --mode=line \ + -s '^[\s]*user[\s]*=' -r 'user = root' \ + -s '^[\s]*conf-dir[\s]*=' -r 'conf-dir = /etc/dnsmasq.d' \ + -- /etc/dnsmasq.conf diff --git a/docker/php-official/7.1/conf/provision/service.d/postfix.sh b/docker/php-official/7.1/conf/provision/service.d/postfix.sh new file mode 100644 index 000000000..ff1879345 --- /dev/null +++ b/docker/php-official/7.1/conf/provision/service.d/postfix.sh @@ -0,0 +1,28 @@ +#!/usr/bin/env bash + +IMAGE_FAMILY=$(docker-image-info family) + +# Installation +case "$IMAGE_FAMILY" in + Debian|Ubuntu) + apt-install postfix + ;; + + RedHat) + yum-install postfix + ;; + + Alpine) + apk-install postfix + ln -s -f /etc/postfix/aliases /etc/aliases + ;; +esac + +# Configuration +go-replace --mode=line \ + -s '^[\s]*mydestination[\s]*=' -r 'mydestination = ' \ + -s '^[\s]*message_size_limit[\s]*=' -r 'message_size_limit = 15240000' \ + -s '^[\s]*smtp_use_tls[\s]*=' -r 'smtp_use_tls = yes' \ + -s '^[\s]*smtp_tls_security_level[\s]*=' -r 'smtp_tls_security_level = may' \ + -s '^[\s]*myhostname[\s]*=' -r '# myhostname' \ + -- /etc/postfix/main.cf diff --git a/docker/php-official/7.1/conf/provision/service.d/ssh.sh b/docker/php-official/7.1/conf/provision/service.d/ssh.sh new file mode 100644 index 000000000..63d7a9f3a --- /dev/null +++ b/docker/php-official/7.1/conf/provision/service.d/ssh.sh @@ -0,0 +1,17 @@ +#!/usr/bin/env bash + +IMAGE_FAMILY=$(docker-image-info family) + +case "$IMAGE_FAMILY" in + Debian|Ubuntu) + apt-install openssh-server + ;; + + RedHat) + yum-install openssh-server + ;; + + Alpine) + apk-install openssh + ;; +esac diff --git a/docker/php-official/7.1/conf/provision/service.d/syslog.sh b/docker/php-official/7.1/conf/provision/service.d/syslog.sh new file mode 100644 index 000000000..7e8b8e0a9 --- /dev/null +++ b/docker/php-official/7.1/conf/provision/service.d/syslog.sh @@ -0,0 +1,41 @@ +#!/usr/bin/env bash + +IMAGE_FAMILY=$(docker-image-info family) + +# Installation +case "$IMAGE_FAMILY" in + Debian|Ubuntu) + apt-install syslog-ng syslog-ng-core + ;; + + RedHat) + yum-install syslog-ng + + # remove logrotate (not needed for docker) + rm -f "/etc/cron.daily/logrotate" + ;; + + Alpine) + apk-install syslog-ng + ;; +esac + +## Configuration +SYSLOG_NG_VERSION=$(syslog-ng --version | grep -E -e '^syslog-ng[ ]+[0-9]+\.[0-9]+' | head -n 1 | awk '{print $2}' | cut -f 1,2 -d .) + +# Disable caps inside container +if [[ -f /etc/default/syslog-ng ]]; then + go-replace --mode=lineinfile \ + -s "SYSLOGNG_OPTS" -r "SYSLOGNG_OPTS = --no-caps" \ + -- /etc/default/syslog-ng +fi + +# Symlink configuration +ln -s -f /opt/docker/etc/syslog-ng/syslog-ng.conf /etc/syslog-ng/syslog-ng.conf + +go-replace --mode=lineinfile \ + -s "@version" -r "@version: ${SYSLOG_NG_VERSION}" \ + -- /etc/syslog-ng/syslog-ng.conf + +# Ensure /var/lib/syslog-ng exists +mkdir -p /var/lib/syslog-ng diff --git a/docker/php-official/7.1/conf/provision/variables-webdevops.yml b/docker/php-official/7.1/conf/provision/variables-webdevops.yml new file mode 100644 index 000000000..0b2a21a95 --- /dev/null +++ b/docker/php-official/7.1/conf/provision/variables-webdevops.yml @@ -0,0 +1,7 @@ +--- + +docker_image_info_family: "{{ lookup('pipe', 'docker-image-info family') }}" +docker_image_info_distribution: "{{ lookup('pipe', 'docker-image-info dist') }}" +docker_image_info_distribution_version: "{{ lookup('pipe', 'docker-image-info dist-version') }}" +docker_image_info_distribution_release: "{{ lookup('pipe', 'docker-image-info dist-release') }}" +docker_image_info_distribution_codename: "{{ lookup('pipe', 'docker-image-info dist-codename') }}" diff --git a/docker/php-official/7.1/conf/provision/variables.yml b/docker/php-official/7.1/conf/provision/variables.yml new file mode 100644 index 000000000..0b2a21a95 --- /dev/null +++ b/docker/php-official/7.1/conf/provision/variables.yml @@ -0,0 +1,7 @@ +--- + +docker_image_info_family: "{{ lookup('pipe', 'docker-image-info family') }}" +docker_image_info_distribution: "{{ lookup('pipe', 'docker-image-info dist') }}" +docker_image_info_distribution_version: "{{ lookup('pipe', 'docker-image-info dist-version') }}" +docker_image_info_distribution_release: "{{ lookup('pipe', 'docker-image-info dist-release') }}" +docker_image_info_distribution_codename: "{{ lookup('pipe', 'docker-image-info dist-codename') }}" diff --git a/docker/php/5.6 b/docker/php/5.6 new file mode 120000 index 000000000..a857368d6 --- /dev/null +++ b/docker/php/5.6 @@ -0,0 +1 @@ +../php-official/5.6 \ No newline at end of file diff --git a/docker/php/7.0 b/docker/php/7.0 new file mode 120000 index 000000000..92dcdb94d --- /dev/null +++ b/docker/php/7.0 @@ -0,0 +1 @@ +../php-official/7.0 \ No newline at end of file diff --git a/docker/php/7.1 b/docker/php/7.1 new file mode 120000 index 000000000..0105923f0 --- /dev/null +++ b/docker/php/7.1 @@ -0,0 +1 @@ +../php-official/7.1 \ No newline at end of file diff --git a/docker/php/alpine b/docker/php/alpine new file mode 120000 index 000000000..a5e678cb6 --- /dev/null +++ b/docker/php/alpine @@ -0,0 +1 @@ +alpine-php7 \ No newline at end of file diff --git a/docker/php/alpine-3 b/docker/php/alpine-3 new file mode 120000 index 000000000..a84cfe247 --- /dev/null +++ b/docker/php/alpine-3 @@ -0,0 +1 @@ +alpine-php5 \ No newline at end of file diff --git a/docker/php/alpine-3-php7 b/docker/php/alpine-3-php7 new file mode 120000 index 000000000..a5e678cb6 --- /dev/null +++ b/docker/php/alpine-3-php7 @@ -0,0 +1 @@ +alpine-php7 \ No newline at end of file diff --git a/docker/php/alpine-3-php7/Dockerfile b/docker/php/alpine-3-php7/Dockerfile deleted file mode 100644 index 43adcaa97..000000000 --- a/docker/php/alpine-3-php7/Dockerfile +++ /dev/null @@ -1,84 +0,0 @@ -#+++++++++++++++++++++++++++++++++++++++ -# Dockerfile for webdevops/php:alpine-3-php7 -# -- automatically generated -- -#+++++++++++++++++++++++++++++++++++++++ - -FROM webdevops/base-app:alpine-3 - -MAINTAINER info@webdevops.io -LABEL vendor=WebDevOps.io -LABEL io.webdevops.layout=8 -LABEL io.webdevops.version=1.5.0 - -ENV WEB_DOCUMENT_ROOT /app -ENV WEB_DOCUMENT_INDEX index.php -ENV WEB_ALIAS_DOMAIN *.vm - -COPY conf/ /opt/docker/ - -# Install php environment -RUN /usr/local/bin/apk-install \ - # Install tools - imagemagick \ - graphicsmagick \ - ghostscript \ - # Install php (cli/fpm) - php7-fpm \ - php7-json \ - php7-intl \ - php7-curl \ - php7-mysqli \ - php7-mysqlnd \ - php7-pdo_mysql \ - php7-pdo_sqlite \ - php7-mcrypt \ - php7-gd \ - php7-bcmath \ - php7-soap \ - php7-sqlite3 \ - php7-bz2 \ - php7-calendar \ - php7-ctype \ - php7-pcntl \ - php7-posix \ - php7-sockets \ - php7-sysvmsg \ - php7-sysvsem \ - php7-sysvshm \ - php7-xmlreader \ - php7-exif \ - php7-ftp \ - php7-gettext \ - php7-iconv \ - php7-zip \ - php7-zlib \ - php7-shmop \ - php7-wddx \ - sqlite \ - php7-xmlrpc \ - php7-xsl \ - geoip \ - php7-ldap \ - # php7-memcache \ - # php7-redis \ - php7-pear \ - php7-phar \ - php7-openssl \ - php7-session \ - php7-opcache \ - php7-mbstring \ - php7-iconv \ - php7-apcu \ - && ln -s /usr/bin/php7 /usr/bin/php \ - && ln -s /usr/sbin/php-fpm7 /usr/sbin/php-fpm \ - && pear channel-update pear.php.net \ - && pear upgrade-all \ - && pear config-set auto_discover 1 \ - && curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin/ --filename=composer \ - # PECL workaround, see webdevops/Dockerfile#78 - && sed -i "s/ -n / /" $(which pecl) \ - && /opt/docker/bin/provision run --tag bootstrap --role webdevops-php \ - && /opt/docker/bin/bootstrap.sh - - -EXPOSE 9000 diff --git a/docker/php/alpine-3-php7/Dockerfile.jinja2 b/docker/php/alpine-3-php7/Dockerfile.jinja2 deleted file mode 100644 index 99e5e3b70..000000000 --- a/docker/php/alpine-3-php7/Dockerfile.jinja2 +++ /dev/null @@ -1,11 +0,0 @@ -{{ docker.from("base-app", "alpine-3") }} - -{{ docker.version() }} - -{{ environment.web() }} - -{{ docker.copy('conf/', '/opt/docker/') }} - -{{ php7.alpine() }} - -{{ docker.expose('9000') }} diff --git a/docker/php/alpine-3-php7/conf/bin/service.d/php-fpm.d/11-clear-env.sh b/docker/php/alpine-3-php7/conf/bin/service.d/php-fpm.d/11-clear-env.sh deleted file mode 100644 index b17280ce6..000000000 --- a/docker/php/alpine-3-php7/conf/bin/service.d/php-fpm.d/11-clear-env.sh +++ /dev/null @@ -1,34 +0,0 @@ -# -# Workaround for old php-fpm versions which don't have clear_env setting -# - -VARIABLE_LIST="; Workaround for missing clear_env feature in PHP-FPM" - -# For each exported variable -for envVariable in $(printenv|cut -f1 -d=); do - - case "$envVariable" in - "_"|"PATH"|"PWD") - ## ignore this variables - ;; - - *) - ## get content of variable - envVariableContent="${!envVariable}" - - ## php-fpm requires that env variable has to be filled with content - if [[ -n "$envVariableContent" ]]; then - ## quote quotes - envVariableContent=${envVariableContent//\"/\\\"} - - ## add to list - VARIABLE_LIST="${VARIABLE_LIST}"$'\n'"env[${envVariable}] = \"${envVariableContent}\"" - fi - ;; - esac - -done - -# Replace ;#CLEAR_ENV_WORKAROUND# with environment variable list for all php-fpm pool files -find /opt/docker/etc/php/fpm/pool.d/ -iname '*.conf' -print0 | xargs -0 -r rpl --quiet ";#CLEAR_ENV_WORKAROUND#" "$VARIABLE_LIST" > /dev/null - diff --git a/docker/php/alpine-3-php7/conf/bin/service.d/php-fpm.sh b/docker/php/alpine-3-php7/conf/bin/service.d/php-fpm.sh deleted file mode 100644 index 571f248d2..000000000 --- a/docker/php/alpine-3-php7/conf/bin/service.d/php-fpm.sh +++ /dev/null @@ -1,7 +0,0 @@ -#!/usr/bin/env bash - -source /opt/docker/bin/config.sh - -includeScriptDir "/opt/docker/bin/service.d/php-fpm.d/" - -exec /usr/sbin/php-fpm --nodaemonize diff --git a/docker/php/alpine-3-php7/conf/etc/logrotate.d/php7-fpm b/docker/php/alpine-3-php7/conf/etc/logrotate.d/php7-fpm deleted file mode 100644 index 668f2545f..000000000 --- a/docker/php/alpine-3-php7/conf/etc/logrotate.d/php7-fpm +++ /dev/null @@ -1,12 +0,0 @@ -/var/log/php7-fpm/fpm.log -/var/log/php7-fpm/access.log -/var/log/php7-fpm/slow.log -/var/log/php7-fpm/error.log { - missingok - notifempty - sharedscripts - delaycompress - postrotate - /bin/kill -SIGUSR1 `cat /var/run/php7-fpm.pid` 2>/dev/null || true - endscript -} diff --git a/docker/php/alpine-3-php7/conf/etc/php/php.webdevops.ini b/docker/php/alpine-3-php7/conf/etc/php/php.webdevops.ini deleted file mode 100644 index 562b8d7e2..000000000 --- a/docker/php/alpine-3-php7/conf/etc/php/php.webdevops.ini +++ /dev/null @@ -1,33 +0,0 @@ -; ------------------------------------- -; Docker Webdevops PHP configuration -; ------------------------------------- - -; this file will overwrite default php.ini settings - -display_errors = 0 - -short_open_tag = Off -variables_order = 'GPCS' -request_order = 'GP' - -allow_url_fopen = On -allow_url_include = Off - -memory_limit = 512M -max_execution_time = 300 -max_input_time = 300 -post_max_size = 50M -upload_max_filesize = 50M -max_input_vars = 5000 - -expose_php = Off - -date.timezone = UTC - -mysql.default_host = mysql -mysqli.default_host = mysql - -opcache.memory_consumption = 256 -opcache.interned_strings_buffer = 16 -opcache.max_accelerated_files = 7963 -opcache.fast_shutdown = 1 diff --git a/docker/php/alpine-3-php7/conf/provision/roles/webdevops-php/tasks/bootstrap.yml b/docker/php/alpine-3-php7/conf/provision/roles/webdevops-php/tasks/bootstrap.yml deleted file mode 100644 index 5883fa1fe..000000000 --- a/docker/php/alpine-3-php7/conf/provision/roles/webdevops-php/tasks/bootstrap.yml +++ /dev/null @@ -1,6 +0,0 @@ ---- - -- include: bootstrap/php.yml -- include: bootstrap/php-fpm.main.yml -- include: bootstrap/php-fpm.pool.yml -- include: bootstrap/php-fpm.yml diff --git a/docker/php/alpine-3-php7/conf/provision/roles/webdevops-php/tasks/bootstrap/php-fpm.main.yml b/docker/php/alpine-3-php7/conf/provision/roles/webdevops-php/tasks/bootstrap/php-fpm.main.yml deleted file mode 100644 index 36143a96f..000000000 --- a/docker/php/alpine-3-php7/conf/provision/roles/webdevops-php/tasks/bootstrap/php-fpm.main.yml +++ /dev/null @@ -1,53 +0,0 @@ ---- - -- name: Set php main file - set_fact: - php_main_conf: /etc/php-fpm.conf - when: ansible_os_family == 'RedHat' - -- name: Set php main file - set_fact: - php_main_conf: /etc/php/7.0/fpm/php-fpm.conf - when: ansible_os_family == 'Debian' - -- name: Set php main file - set_fact: - php_main_conf: /etc/php7/php-fpm.conf - when: ansible_os_family == 'Alpine' - -- name: Create php directories - file: - path: "{{ item }}" - state: directory - mode: 0755 - owner: "root" - group: "root" - with_items: - - /opt/docker/etc/php/fpm/ - -- name: Move php-fpm main file to /opt/docker/etc/php/fpm/ - command: "mv {{ php_main_conf }} /opt/docker/etc/php/fpm/php-fpm.conf" - args: - creates: /opt/docker/etc/php/fpm/php-fpm.conf - -- name: Remove php-fpm main file - file: - path: "{{ php_main_conf }}" - state: absent - -- name: Symlink php-fpm main file - file: - path: "{{ php_main_conf }}" - src: "/opt/docker/etc/php/fpm/php-fpm.conf" - state: link - owner: "root" - group: "root" - -- name: Configure php-fpm main - lineinfile: - dest: '/opt/docker/etc/php/fpm/php-fpm.conf' - regexp: '^[\s;]*{{ item.key }}[\s]*=' - line: '{{ item.key }} = {{ item.value }}' - with_items: - - { key: 'error_log', value: "syslog" } - - { key: 'pid', value: "/var/run/php-fpm.pid" } diff --git a/docker/php/alpine-3-php7/conf/provision/roles/webdevops-php/tasks/bootstrap/php-fpm.pool.yml b/docker/php/alpine-3-php7/conf/provision/roles/webdevops-php/tasks/bootstrap/php-fpm.pool.yml deleted file mode 100644 index d91ecab7f..000000000 --- a/docker/php/alpine-3-php7/conf/provision/roles/webdevops-php/tasks/bootstrap/php-fpm.pool.yml +++ /dev/null @@ -1,91 +0,0 @@ ---- -- name: Get php version - command: "php -r 'echo phpversion();'" - changed_when: true - register: php_version_cmd - ignore_errors: true - -- name: Set php_version version - set_fact: - php_version: "{{php_version_cmd.stdout}}" - -- debug: - msg: "PHP-Version: {{php_version}}" - -- name: Set php pool file - set_fact: - php_pool_conf: www.conf - php_pool_dir: /etc/php-fpm.d - when: ansible_os_family == 'RedHat' - -- name: Set php pool file - set_fact: - php_pool_conf: www.conf - php_pool_dir: /etc/php/7.0/fpm/pool.d - when: ansible_os_family == 'Debian' - -- name: Set php pool file - set_fact: - php_pool_conf: www.conf - php_pool_dir: /etc/php7/php-fpm.d - when: ansible_os_family == 'Alpine' - -- name: Create php directories - file: - path: "{{ item }}" - state: directory - mode: 0755 - owner: "root" - group: "root" - with_items: - - /opt/docker/etc/php/fpm/ - -- name: Move php-fpm pool directory file to /opt/docker/etc/php/ - command: "mv {{ php_pool_dir }} /opt/docker/etc/php/fpm/pool.d" - args: - creates: /opt/docker/etc/php/fpm/pool.d - -- name: Rename pool file file to application.conf" - command: "mv /opt/docker/etc/php/fpm/pool.d/{{ php_pool_conf }} /opt/docker/etc/php/fpm/pool.d/application.conf" - args: - creates: /opt/docker/etc/php/fpm/pool.d/application.conf - -- name: Remove php-fpm pool directory - file: - path: "{{ php_pool_dir }}" - state: absent - -- name: Symlink php-fpm main file - file: - path: "{{ php_pool_dir }}" - src: "/opt/docker/etc/php/fpm/pool.d" - state: link - owner: "root" - group: "root" - - -- name: Configure php-fpm pool user (www.conf) - lineinfile: - dest: '/opt/docker/etc/php/fpm/pool.d/application.conf' - regexp: '^[\s;]*{{ item.key }}[\s]*=' - line: '{{ item.key }} = {{ item.value }}' - with_items: - - { key: 'listen', value: "0.0.0.0:9000" } - - { key: 'catch_workers_output', value: "yes" } - - { key: 'access.format', value: '[php-fpm:access] %R - %u %t "%m %r%Q%q" %s %f %{mili}d %{kilo}M %C%%' } - - { key: 'access.log', value: "/docker.stdout" } - - { key: 'slowlog', value: "/docker.stderr" } - - { key: 'php_admin_value[error_log]', value: "/docker.stderr" } - - { key: 'php_admin_value[log_errors]', value: "on" } - - { key: 'clear_env', value: "no" } - - { key: 'user', value: "{{ APPLICATION_USER }}" } - - { key: 'group', value: "{{ APPLICATION_GROUP }}" } - -- name: Disable php-fpm connection limit - lineinfile: - dest: '/opt/docker/etc/php/fpm/pool.d/application.conf' - regexp: '^[\s;]*{{ item.key }}[\s]*=' - line: ';{{ item.key }}' - with_items: - - { key: 'listen.allowed_clients' } - diff --git a/docker/php/alpine-3-php7/conf/provision/roles/webdevops-php/tasks/bootstrap/php-fpm.yml b/docker/php/alpine-3-php7/conf/provision/roles/webdevops-php/tasks/bootstrap/php-fpm.yml deleted file mode 100644 index 130542f53..000000000 --- a/docker/php/alpine-3-php7/conf/provision/roles/webdevops-php/tasks/bootstrap/php-fpm.yml +++ /dev/null @@ -1,54 +0,0 @@ ---- - -- name: Symlink php-fpm binary [RedHat family] - file: - path: "/usr/sbin/php-fpm7.0" - src: "/usr/sbin/php-fpm" - state: link - owner: "root" - group: "root" - when: ansible_os_family == 'RedHat' - -- name: Symlink php-fpm binary [Alpine family] - file: - path: "/usr/sbin/php-fpm" - src: "/usr/sbin/php-fpm7" - state: link - owner: "root" - group: "root" - when: ansible_os_family == 'Alpine' - -- name: Symlink php-fpm binary [Debian family] - file: - path: "/usr/sbin/php-fpm" - src: "/usr/sbin/php-fpm7.0" - state: link - owner: "root" - group: "root" - when: ansible_os_family == 'Debian' - -- name: Remove default php-fpm logrotate - file: - path: "/etc/logrotate.d/php-fpm" - state: absent - when: ansible_os_family == 'RedHat' - -- name: Create php-fpm log directory - file: - path: "/var/log/php7-fpm/" - state: directory - owner: "root" - group: "root" - -- name: Create php-fpm log files - file: - path: "/var/log/php7-fpm/{{ item }}" - state: touch - owner: "root" - group: "root" - mode: 0600 - with_items: - - slow.log - - access.log - - error.log - - fpm.log diff --git a/docker/php/alpine-3-php7/conf/provision/roles/webdevops-php/tasks/bootstrap/php.yml b/docker/php/alpine-3-php7/conf/provision/roles/webdevops-php/tasks/bootstrap/php.yml deleted file mode 100644 index 97f02eec3..000000000 --- a/docker/php/alpine-3-php7/conf/provision/roles/webdevops-php/tasks/bootstrap/php.yml +++ /dev/null @@ -1,60 +0,0 @@ ---- - -- name: Create php directories - file: - path: "{{ item }}" - state: directory - mode: 0755 - owner: "root" - group: "root" - with_items: - - /opt/docker/etc/php/ - - /opt/docker/etc/php/fpm/ - -- name: Create /opt/docker/etc/php/php.ini" - file: - path: "{{ item }}" - state: touch - mode: 0744 - owner: root - group: root - with_items: - - "/opt/docker/etc/php/php.webdevops.ini" - - "/opt/docker/etc/php/php.ini" - -- name: Link php.ini for cli and fpm - file: - src: '{{ item.file }}' - dest: '/etc/php/7.0/{{ item.category }}/conf.d/{{ item.target }}' - force: yes - state: link - with_items: - # PHP cli - - { category: 'cli', file: '/opt/docker/etc/php/php.webdevops.ini', target: '98-webdevops.ini' } - - { category: 'cli', file: '/opt/docker/etc/php/php.ini', target: '99-docker.ini' } - # PHP fpm - - { category: 'fpm', file: '/opt/docker/etc/php/php.webdevops.ini', target: '98-webdevops.ini' } - - { category: 'fpm', file: '/opt/docker/etc/php/php.ini', target: '99-docker.ini' } - when: ansible_os_family == 'Debian' - -- name: Create link for additional php.ini [RedHat family] - file: - src: '/opt/docker/etc/php/{{ item.file }}' - dest: '/etc/php.d/{{ item.target }}' - state: link - force: yes - with_items: - - { file: 'php.webdevops.ini', target: 'zza-webdevops.ini'} - - { file: 'php.ini', target: 'zzz-docker.ini'} - when: ansible_os_family == 'RedHat' - -- name: Link php.ini - file: - src: '/opt/docker/etc/php/{{ item.file }}' - dest: '/etc/php7/conf.d/{{ item.target }}' - force: yes - state: link - with_items: - - { file: 'php.webdevops.ini', target: 'xzza-webdevops.ini'} - - { file: 'php.ini', target: 'xzzz-docker.ini'} - when: ansible_os_family == 'Alpine' diff --git a/docker/php/alpine-3/Dockerfile b/docker/php/alpine-3/Dockerfile deleted file mode 100644 index 3db15f23b..000000000 --- a/docker/php/alpine-3/Dockerfile +++ /dev/null @@ -1,79 +0,0 @@ -#+++++++++++++++++++++++++++++++++++++++ -# Dockerfile for webdevops/php:alpine-3 -# -- automatically generated -- -#+++++++++++++++++++++++++++++++++++++++ - -FROM webdevops/base-app:alpine-3 - -MAINTAINER info@webdevops.io -LABEL vendor=WebDevOps.io -LABEL io.webdevops.layout=8 -LABEL io.webdevops.version=1.5.0 - -ENV WEB_DOCUMENT_ROOT /app -ENV WEB_DOCUMENT_INDEX index.php -ENV WEB_ALIAS_DOMAIN *.vm - -COPY conf/ /opt/docker/ - -# Install php environment -RUN /usr/local/bin/apk-install \ - # Install tools - imagemagick \ - graphicsmagick \ - ghostscript \ - # Install php (cli/fpm) - php5-cli \ - php5-fpm \ - php5-json \ - php5-intl \ - php5-curl \ - php5-mysql \ - php5-mysqli \ - php5-pdo_mysql \ - php5-pdo_sqlite \ - php5-mcrypt \ - php5-gd \ - php5-bcmath \ - php5-soap \ - php5-sqlite3 \ - php5-bz2 \ - php5-calendar \ - php5-ctype \ - php5-pcntl \ - php5-posix \ - php5-sockets \ - php5-sysvmsg \ - php5-sysvsem \ - php5-sysvshm \ - php5-xmlreader \ - php5-exif \ - php5-ftp \ - php5-gettext \ - php5-iconv \ - php5-zip \ - php5-zlib \ - php5-shmop \ - php5-wddx \ - sqlite \ - php5-xmlrpc \ - php5-xsl \ - geoip \ - php5-ldap \ - php5-memcache \ - # php5-redis \ - php5-pear \ - php5-phar \ - php5-openssl \ - php5-apcu \ - && pear channel-update pear.php.net \ - && pear upgrade-all \ - && pear config-set auto_discover 1 \ - && curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin/ --filename=composer \ - # PECL workaround, see webdevops/Dockerfile#78 - && sed -i "s/ -n / /" $(which pecl) \ - && /opt/docker/bin/provision run --tag bootstrap --role webdevops-php \ - && /opt/docker/bin/bootstrap.sh - - -EXPOSE 9000 diff --git a/docker/php/alpine-3/Dockerfile.jinja2 b/docker/php/alpine-3/Dockerfile.jinja2 deleted file mode 100644 index 0656e234e..000000000 --- a/docker/php/alpine-3/Dockerfile.jinja2 +++ /dev/null @@ -1,11 +0,0 @@ -{{ docker.from("base-app", "alpine-3") }} - -{{ docker.version() }} - -{{ environment.web() }} - -{{ docker.copy('conf/', '/opt/docker/') }} - -{{ php5.alpine() }} - -{{ docker.expose('9000') }} diff --git a/docker/php/alpine-3/conf/bin/service.d/php-fpm.d/11-clear-env.sh b/docker/php/alpine-3/conf/bin/service.d/php-fpm.d/11-clear-env.sh deleted file mode 100644 index b17280ce6..000000000 --- a/docker/php/alpine-3/conf/bin/service.d/php-fpm.d/11-clear-env.sh +++ /dev/null @@ -1,34 +0,0 @@ -# -# Workaround for old php-fpm versions which don't have clear_env setting -# - -VARIABLE_LIST="; Workaround for missing clear_env feature in PHP-FPM" - -# For each exported variable -for envVariable in $(printenv|cut -f1 -d=); do - - case "$envVariable" in - "_"|"PATH"|"PWD") - ## ignore this variables - ;; - - *) - ## get content of variable - envVariableContent="${!envVariable}" - - ## php-fpm requires that env variable has to be filled with content - if [[ -n "$envVariableContent" ]]; then - ## quote quotes - envVariableContent=${envVariableContent//\"/\\\"} - - ## add to list - VARIABLE_LIST="${VARIABLE_LIST}"$'\n'"env[${envVariable}] = \"${envVariableContent}\"" - fi - ;; - esac - -done - -# Replace ;#CLEAR_ENV_WORKAROUND# with environment variable list for all php-fpm pool files -find /opt/docker/etc/php/fpm/pool.d/ -iname '*.conf' -print0 | xargs -0 -r rpl --quiet ";#CLEAR_ENV_WORKAROUND#" "$VARIABLE_LIST" > /dev/null - diff --git a/docker/php/alpine-3/conf/bin/service.d/php-fpm.sh b/docker/php/alpine-3/conf/bin/service.d/php-fpm.sh deleted file mode 100644 index 571f248d2..000000000 --- a/docker/php/alpine-3/conf/bin/service.d/php-fpm.sh +++ /dev/null @@ -1,7 +0,0 @@ -#!/usr/bin/env bash - -source /opt/docker/bin/config.sh - -includeScriptDir "/opt/docker/bin/service.d/php-fpm.d/" - -exec /usr/sbin/php-fpm --nodaemonize diff --git a/docker/php/alpine-3/conf/etc/php/php.webdevops.ini b/docker/php/alpine-3/conf/etc/php/php.webdevops.ini deleted file mode 100644 index 562b8d7e2..000000000 --- a/docker/php/alpine-3/conf/etc/php/php.webdevops.ini +++ /dev/null @@ -1,33 +0,0 @@ -; ------------------------------------- -; Docker Webdevops PHP configuration -; ------------------------------------- - -; this file will overwrite default php.ini settings - -display_errors = 0 - -short_open_tag = Off -variables_order = 'GPCS' -request_order = 'GP' - -allow_url_fopen = On -allow_url_include = Off - -memory_limit = 512M -max_execution_time = 300 -max_input_time = 300 -post_max_size = 50M -upload_max_filesize = 50M -max_input_vars = 5000 - -expose_php = Off - -date.timezone = UTC - -mysql.default_host = mysql -mysqli.default_host = mysql - -opcache.memory_consumption = 256 -opcache.interned_strings_buffer = 16 -opcache.max_accelerated_files = 7963 -opcache.fast_shutdown = 1 diff --git a/docker/php/alpine-3/conf/provision/roles/webdevops-php/tasks/bootstrap.yml b/docker/php/alpine-3/conf/provision/roles/webdevops-php/tasks/bootstrap.yml deleted file mode 100644 index 5883fa1fe..000000000 --- a/docker/php/alpine-3/conf/provision/roles/webdevops-php/tasks/bootstrap.yml +++ /dev/null @@ -1,6 +0,0 @@ ---- - -- include: bootstrap/php.yml -- include: bootstrap/php-fpm.main.yml -- include: bootstrap/php-fpm.pool.yml -- include: bootstrap/php-fpm.yml diff --git a/docker/php/alpine-3/conf/provision/roles/webdevops-php/tasks/bootstrap/php-fpm.main.yml b/docker/php/alpine-3/conf/provision/roles/webdevops-php/tasks/bootstrap/php-fpm.main.yml deleted file mode 100644 index 1a2c7861f..000000000 --- a/docker/php/alpine-3/conf/provision/roles/webdevops-php/tasks/bootstrap/php-fpm.main.yml +++ /dev/null @@ -1,44 +0,0 @@ ---- - -- name: Set php main file - set_fact: - php_main_conf: /etc/php-fpm.conf - when: ansible_os_family == 'RedHat' - -- name: Set php main file - set_fact: - php_main_conf: /etc/php5/fpm/php-fpm.conf - when: ansible_os_family == 'Debian' - -- name: Set php main file - set_fact: - php_main_conf: /etc/php5/php-fpm.conf - when: ansible_os_family == 'Alpine' - -- name: Move php-fpm main file to /opt/docker/etc/php/fpm/ - command: "mv {{ php_main_conf }} /opt/docker/etc/php/fpm/php-fpm.conf" - args: - creates: /opt/docker/etc/php/fpm/php-fpm.conf - -- name: Remove php-fpm main file - file: - path: "{{ php_main_conf }}" - state: absent - -- name: Symlink php-fpm main file - file: - path: "{{ php_main_conf }}" - src: "/opt/docker/etc/php/fpm/php-fpm.conf" - state: link - owner: "root" - group: "root" - -- name: Configure php-fpm main - lineinfile: - dest: '/opt/docker/etc/php/fpm/php-fpm.conf' - regexp: '^[\s;]*{{ item.key }}[\s]*=' - line: '{{ item.key }} = {{ item.value }}' - with_items: - - { key: 'error_log', value: "syslog" } - - { key: 'pid', value: "/var/run/php-fpm.pid" } - - { key: 'daemonize', value: 'no' } diff --git a/docker/php/alpine-3/conf/provision/roles/webdevops-php/tasks/bootstrap/php-fpm.pool.yml b/docker/php/alpine-3/conf/provision/roles/webdevops-php/tasks/bootstrap/php-fpm.pool.yml deleted file mode 100644 index 53ee9dfe1..000000000 --- a/docker/php/alpine-3/conf/provision/roles/webdevops-php/tasks/bootstrap/php-fpm.pool.yml +++ /dev/null @@ -1,117 +0,0 @@ ---- - -- name: Get php version - command: "php -r 'echo phpversion();'" - changed_when: true - register: php_version_cmd - ignore_errors: true - -- name: Set php_version version - set_fact: - php_version: "{{php_version_cmd.stdout}}" - -- debug: - msg: "PHP-Version: {{php_version}}" - -- set_fact: - php_clear_env_available: False - -- set_fact: - php_clear_env_available: True - when: ( php_version | version_compare('5.4', 'eq') and php_version | version_compare('5.4.27', 'ge') ) or - ( php_version | version_compare('5.5', 'eq') and php_version | version_compare('5.5.11', 'ge') ) or - ( php_version | version_compare('5.6', 'ge') ) - -- name: Set php pool file - set_fact: - php_pool_conf: www.conf - php_pool_dir: /etc/php-fpm.d - when: ansible_os_family == 'RedHat' - -- name: Set php pool file - set_fact: - php_pool_conf: www.conf - php_pool_dir: /etc/php5/fpm/pool.d - when: ansible_os_family == 'Debian' - -- name: Set php pool file - set_fact: - php_pool_conf: www.conf - php_pool_dir: /etc/php5/fpm.d - when: ansible_os_family == 'Alpine' - -- name: Move php-fpm pool directory file to /opt/docker/etc/php/ - command: "mv {{ php_pool_dir }} /opt/docker/etc/php/fpm/pool.d" - args: - creates: /opt/docker/etc/php/fpm/pool.d - -- name: Rename pool file file to application.conf" - command: "mv /opt/docker/etc/php/fpm/pool.d/{{ php_pool_conf }} /opt/docker/etc/php/fpm/pool.d/application.conf" - args: - creates: /opt/docker/etc/php/fpm/pool.d/application.conf - -- name: Remove php-fpm pool directory - file: - path: "{{ php_pool_dir }}" - state: absent - -- name: Symlink php-fpm main file - file: - path: "{{ php_pool_dir }}" - src: "/opt/docker/etc/php/fpm/pool.d" - state: link - owner: "root" - group: "root" - -- name: Configure php-fpm pool user (application.conf) - lineinfile: - dest: '/opt/docker/etc/php/fpm/pool.d/application.conf' - regexp: '^[\s;]*{{ item.key }}[\s]*=' - line: '{{ item.key }} = {{ item.value }}' - with_items: - - { key: 'listen', value: "0.0.0.0:9000" } - - { key: 'catch_workers_output', value: "yes" } - - { key: 'access.format', value: '[php-fpm:access] %R - %u %t "%m %r%Q%q" %s %f %{mili}d %{kilo}M %C%%' } - - { key: 'slowlog', value: "/docker.stderr" } - - { key: 'php_admin_value[error_log]', value: "/docker.stderr" } - - { key: 'php_admin_value[log_errors]', value: "on" } - - { key: 'user', value: "{{ APPLICATION_USER }}" } - - { key: 'group', value: "{{ APPLICATION_GROUP }}" } - -- name: Configure php-fpm pool user (application.conf) - lineinfile: - dest: '/opt/docker/etc/php/fpm/pool.d/application.conf' - regexp: '^[\s;]*{{ item.key }}[\s]*=' - line: ';{{ item.key }} = {{ item.value }}' - with_items: - - { key: 'access.log', value: "/docker.stdout" } - -- name: Disable clear env in php-fpm pool - lineinfile: - dest: '/opt/docker/etc/php/fpm/pool.d/application.conf' - regexp: '^[\s;]*{{ item.key }}[\s]*=' - line: '{{ item.key }} = {{ item.value }}' - with_items: - - { key: 'clear_env', value: "no" } - when: php_clear_env_available == True - -- name: Remove clear env workaround - file: - path: "/opt/docker/bin/service.d/php-fpm.d/11-clear-env.sh" - state: absent - when: php_clear_env_available == True - -- name: Append clear env workaround in php-fpm pool (old php-fpm versions) - lineinfile: - dest: '/opt/docker/etc/php/fpm/pool.d/application.conf' - line: ';#CLEAR_ENV_WORKAROUND#' - when: php_clear_env_available == False - -- name: Disable php-fpm connection limit - lineinfile: - dest: '/opt/docker/etc/php/fpm/pool.d/application.conf' - regexp: '^[\s;]*{{ item.key }}[\s]*=' - line: ';{{ item.key }}' - with_items: - - { key: 'listen.allowed_clients' } - diff --git a/docker/php/alpine-3/conf/provision/roles/webdevops-php/tasks/bootstrap/php-fpm.yml b/docker/php/alpine-3/conf/provision/roles/webdevops-php/tasks/bootstrap/php-fpm.yml deleted file mode 100644 index d83edb3ae..000000000 --- a/docker/php/alpine-3/conf/provision/roles/webdevops-php/tasks/bootstrap/php-fpm.yml +++ /dev/null @@ -1,45 +0,0 @@ ---- - -- name: Symlink php-fpm binary [Alpine family] - file: - path: "/usr/sbin/php-fpm" - src: "/usr/bin/php-fpm" - state: link - owner: "root" - group: "root" - when: ansible_os_family == 'Alpine' - -- name: Symlink php-fpm binary [Debian family] - file: - path: "/usr/sbin/php-fpm" - src: "/usr/sbin/php5-fpm" - state: link - owner: "root" - group: "root" - when: ansible_os_family == 'Debian' - -- name: Remove default php-fpm logrotate - file: - path: "/etc/logrotate.d/php-fpm" - state: absent - when: ansible_os_family == 'RedHat' - -- name: Create php-fpm log directory - file: - path: "/var/log/php5-fpm/" - state: directory - owner: "root" - group: "root" - -- name: Create php-fpm log files - file: - path: "/var/log/php5-fpm/{{ item }}" - state: touch - owner: "root" - group: "root" - mode: 0600 - with_items: - - slow.log - - access.log - - error.log - - fpm.log diff --git a/docker/php/alpine-3/conf/provision/roles/webdevops-php/tasks/bootstrap/php.yml b/docker/php/alpine-3/conf/provision/roles/webdevops-php/tasks/bootstrap/php.yml deleted file mode 100644 index 9816b2538..000000000 --- a/docker/php/alpine-3/conf/provision/roles/webdevops-php/tasks/bootstrap/php.yml +++ /dev/null @@ -1,62 +0,0 @@ ---- - -- name: Create php directories - file: - path: "{{ item }}" - state: directory - mode: 0755 - owner: "root" - group: "root" - with_items: - - /opt/docker/etc/php/ - - /opt/docker/etc/php/fpm/ - -- name: Create php.ini files - file: - path: "{{ item }}" - state: touch - mode: 0744 - owner: root - group: root - with_items: - - "/opt/docker/etc/php/php.webdevops.ini" - - "/opt/docker/etc/php/php.ini" - -- name: Link php.ini for cli and fpm [Debian family] - file: - src: '{{ item.file }}' - dest: '/etc/php5/{{ item.category }}/conf.d/{{ item.target }}' - force: yes - state: link - with_items: - # PHP cli - - { category: 'cli', file: '/etc/php5/mods-available/mcrypt.ini', target: '20-mcrypt.ini' } - - { category: 'cli', file: '/opt/docker/etc/php/php.webdevops.ini', target: '98-webdevops.ini' } - - { category: 'cli', file: '/opt/docker/etc/php/php.ini', target: '99-docker.ini' } - # PHP fpm - - { category: 'fpm', file: '/etc/php5/mods-available/mcrypt.ini', target: '20-mcrypt.ini' } - - { category: 'fpm', file: '/opt/docker/etc/php/php.webdevops.ini', target: '98-webdevops.ini' } - - { category: 'fpm', file: '/opt/docker/etc/php/php.ini', target: '99-docker.ini' } - when: ansible_os_family == 'Debian' - -- name: Create link for additional php.ini [RedHat family] - file: - src: '/opt/docker/etc/php/{{ item.file }}' - dest: '/etc/php.d/{{ item.target }}' - state: link - force: yes - with_items: - - { file: 'php.webdevops.ini', target: 'zza-webdevops.ini'} - - { file: 'php.ini', target: 'zzz-docker.ini'} - when: ansible_os_family == 'RedHat' - -- name: Create link for additional php.ini [Alpine family] - file: - src: '/opt/docker/etc/php/{{ item.file }}' - dest: '/etc/php5/conf.d/{{ item.target }}' - state: link - force: yes - with_items: - - { file: 'php.webdevops.ini', target: 'xzza-webdevops.ini'} - - { file: 'php.ini', target: 'xzzz-docker.ini'} - when: ansible_os_family == 'Alpine' diff --git a/docker/php/alpine-php5/Dockerfile b/docker/php/alpine-php5/Dockerfile new file mode 100644 index 000000000..a5a9b9f8d --- /dev/null +++ b/docker/php/alpine-php5/Dockerfile @@ -0,0 +1,76 @@ +#+++++++++++++++++++++++++++++++++++++++ +# Dockerfile for webdevops/php:alpine-php5 +# -- automatically generated -- +#+++++++++++++++++++++++++++++++++++++++ + +FROM webdevops/base-app:alpine + +ENV WEB_DOCUMENT_ROOT=/app \ + WEB_DOCUMENT_INDEX=index.php \ + WEB_ALIAS_DOMAIN=*.vm + +COPY conf/ /opt/docker/ + +# Install php environment +RUN /usr/local/bin/apk-install \ + # Install tools + imagemagick \ + graphicsmagick \ + ghostscript \ + # Install php (cli/fpm) + php5-cli \ + php5-fpm \ + php5-json \ + php5-intl \ + php5-curl \ + php5-mysql \ + php5-mysqli \ + php5-pdo_mysql \ + php5-pdo_sqlite \ + php5-mcrypt \ + php5-gd \ + php5-bcmath \ + php5-soap \ + php5-sqlite3 \ + php5-bz2 \ + php5-calendar \ + php5-ctype \ + php5-pcntl \ + php5-posix \ + php5-sockets \ + php5-sysvmsg \ + php5-sysvsem \ + php5-sysvshm \ + php5-xmlreader \ + php5-exif \ + php5-ftp \ + php5-gettext \ + php5-iconv \ + php5-zip \ + php5-zlib \ + php5-shmop \ + php5-wddx \ + sqlite \ + php5-xmlrpc \ + php5-xsl \ + geoip \ + php5-ldap \ + php5-memcache \ + # php5-redis \ + php5-pear \ + php5-phar \ + php5-openssl \ + php5-apcu \ + && pear channel-update pear.php.net \ + && pear upgrade-all \ + && pear config-set auto_discover 1 \ + && curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin/ --filename=composer \ + # PECL workaround, see webdevops/Dockerfile#78 + && sed -i "s/ -n / /" $(which pecl) \ + # Enable php services + && docker-service-enable syslog cron \ + && /opt/docker/bin/provision run --tag bootstrap --role webdevops-php \ + && /opt/docker/bin/bootstrap.sh \ + && docker-image-cleanup + +EXPOSE 9000 diff --git a/docker/php/alpine-php5/Dockerfile.jinja2 b/docker/php/alpine-php5/Dockerfile.jinja2 new file mode 100644 index 000000000..48ad3cce1 --- /dev/null +++ b/docker/php/alpine-php5/Dockerfile.jinja2 @@ -0,0 +1,9 @@ +{{ docker.from("base-app", "alpine") }} + +{{ environment.web() }} + +{{ docker.copy('conf/', '/opt/docker/') }} + +{{ php5.alpine() }} + +{{ docker.expose('9000') }} diff --git a/docker/php/alpine-php5/conf/bin/service.d/php-fpm.d/10-init.sh b/docker/php/alpine-php5/conf/bin/service.d/php-fpm.d/10-init.sh new file mode 100644 index 000000000..312fcd043 --- /dev/null +++ b/docker/php/alpine-php5/conf/bin/service.d/php-fpm.d/10-init.sh @@ -0,0 +1,8 @@ +# setup user env +FPM_POOL_CONF="/opt/docker/etc/php/fpm/pool.d/application.conf" + +## Setup container uid +if [[ -n "$CONTAINER_UID" ]]; then + sed -i "s/user[ ]*=.*/user = ${CONTAINER_UID}/g" "$FPM_POOL_CONF" + sed -i "s/group[ ]*=.*/group = ${CONTAINER_UID}/g" "$FPM_POOL_CONF" +fi diff --git a/docker/php/alpine-php5/conf/bin/service.d/php-fpm.d/11-clear-env.sh b/docker/php/alpine-php5/conf/bin/service.d/php-fpm.d/11-clear-env.sh new file mode 100644 index 000000000..ef6fd4016 --- /dev/null +++ b/docker/php/alpine-php5/conf/bin/service.d/php-fpm.d/11-clear-env.sh @@ -0,0 +1,38 @@ +# +# Workaround for old php-fpm versions which don't have clear_env setting +# + +VARIABLE_LIST="; Workaround for missing clear_env feature in PHP-FPM" + +# For each exported variable +for envVariable in $(printenv|cut -f1 -d=); do + + case "$envVariable" in + "_"|"PATH"|"PWD") + ## ignore this variables + ;; + + *) + ## get content of variable + envVariableContent="${!envVariable}" + + ## php-fpm requires that env variable has to be filled with content + if [[ -n "$envVariableContent" ]]; then + ## quote quotes + envVariableContent=${envVariableContent//\"/\\\"} + + ## add to list + VARIABLE_LIST="${VARIABLE_LIST}"$'\n'"env[${envVariable}] = \"${envVariableContent}\"" + fi + ;; + esac + +done + +# Replace ;#CLEAR_ENV_WORKAROUND# with environment variable list for all php-fpm pool files +go-replace \ + -s ";#CLEAR_ENV_WORKAROUND#" -r "$VARIABLE_LIST" \ + --path=/opt/docker/etc/php/fpm/pool.d/ \ + --path-pattern='*.conf' \ + --ignore-empty + diff --git a/docker/php/alpine-php5/conf/bin/service.d/php-fpm.sh b/docker/php/alpine-php5/conf/bin/service.d/php-fpm.sh new file mode 100644 index 000000000..b25983bd3 --- /dev/null +++ b/docker/php/alpine-php5/conf/bin/service.d/php-fpm.sh @@ -0,0 +1,7 @@ +#!/usr/bin/env bash + +source /opt/docker/bin/config.sh + +includeScriptDir "/opt/docker/bin/service.d/php-fpm.d/" + +exec /usr/local/bin/php-fpm --nodaemonize diff --git a/docker/php/alpine-php5/conf/etc/logrotate.d/php5-fpm b/docker/php/alpine-php5/conf/etc/logrotate.d/php5-fpm new file mode 100644 index 000000000..e6ef4b123 --- /dev/null +++ b/docker/php/alpine-php5/conf/etc/logrotate.d/php5-fpm @@ -0,0 +1,12 @@ +/var/log/php5-fpm/fpm.log +/var/log/php5-fpm/access.log +/var/log/php5-fpm/slow.log +/var/log/php5-fpm/error.log { + missingok + notifempty + sharedscripts + delaycompress + postrotate + /bin/kill -SIGUSR1 `cat /var/run/php5-fpm.pid` 2>/dev/null || true + endscript +} diff --git a/docker/php/alpine-php5/conf/etc/php/conf.d/.gitkeep b/docker/php/alpine-php5/conf/etc/php/conf.d/.gitkeep new file mode 100644 index 000000000..e69de29bb diff --git a/docker/php/alpine-3-php7/conf/etc/php/fpm/php-fpm.conf b/docker/php/alpine-php5/conf/etc/php/fpm/php-fpm.conf similarity index 100% rename from docker/php/alpine-3-php7/conf/etc/php/fpm/php-fpm.conf rename to docker/php/alpine-php5/conf/etc/php/fpm/php-fpm.conf diff --git a/docker/php/alpine-3-php7/conf/etc/php/fpm/pool.d/application.conf b/docker/php/alpine-php5/conf/etc/php/fpm/pool.d/application.conf similarity index 100% rename from docker/php/alpine-3-php7/conf/etc/php/fpm/pool.d/application.conf rename to docker/php/alpine-php5/conf/etc/php/fpm/pool.d/application.conf diff --git a/docker/php/alpine-php5/conf/etc/php/php.ini b/docker/php/alpine-php5/conf/etc/php/php.ini new file mode 100644 index 000000000..447212118 --- /dev/null +++ b/docker/php/alpine-php5/conf/etc/php/php.ini @@ -0,0 +1 @@ +; placeholder diff --git a/docker/php/alpine-php5/conf/etc/php/php.webdevops.ini b/docker/php/alpine-php5/conf/etc/php/php.webdevops.ini new file mode 100644 index 000000000..aa1545ab8 --- /dev/null +++ b/docker/php/alpine-php5/conf/etc/php/php.webdevops.ini @@ -0,0 +1,34 @@ +; ------------------------------------- +; Docker Webdevops PHP configuration +; ------------------------------------- + +; this file will overwrite default php.ini settings + +display_errors = 0 +log_errors = 1 + +short_open_tag = Off +variables_order = 'GPCS' +request_order = 'GP' + +allow_url_fopen = On +allow_url_include = Off + +memory_limit = 512M +max_execution_time = 300 +max_input_time = 300 +post_max_size = 50M +upload_max_filesize = 50M +max_input_vars = 5000 + +expose_php = Off + +date.timezone = UTC + +mysql.default_host = mysql +mysqli.default_host = mysql + +opcache.memory_consumption = 256 +opcache.interned_strings_buffer = 16 +opcache.max_accelerated_files = 7963 +opcache.fast_shutdown = 1 diff --git a/docker/php/alpine-php5/conf/etc/supervisor.d/php-fpm.conf b/docker/php/alpine-php5/conf/etc/supervisor.d/php-fpm.conf new file mode 100644 index 000000000..5781f5b0a --- /dev/null +++ b/docker/php/alpine-php5/conf/etc/supervisor.d/php-fpm.conf @@ -0,0 +1,15 @@ +[group:php-fpm] +programs=php-fpmd +priority=20 + +[program:php-fpmd] +command = /opt/docker/bin/service.d/php-fpm.sh +process_name=%(program_name)s +startsecs = 0 +autostart = true +autorestart = true +stdout_logfile=/dev/stdout +stdout_logfile_maxbytes=0 +stderr_logfile=/dev/stderr +stderr_logfile_maxbytes=0 + diff --git a/docker/php/alpine-php5/conf/provision/roles/webdevops-php/defaults/main.yml b/docker/php/alpine-php5/conf/provision/roles/webdevops-php/defaults/main.yml new file mode 100644 index 000000000..81f5b7efd --- /dev/null +++ b/docker/php/alpine-php5/conf/provision/roles/webdevops-php/defaults/main.yml @@ -0,0 +1,6 @@ +--- + +APPLICATION_USER: "{{ lookup('env','APPLICATION_USER') }}" +APPLICATION_GROUP: "{{ lookup('env','APPLICATION_GROUP') }}" +APPLICATION_UID: "{{ lookup('env','APPLICATION_UID') }}" +APPLICATION_GID: "{{ lookup('env','APPLICATION_GID') }}" diff --git a/docker/php/alpine-php5/conf/provision/roles/webdevops-php/tasks/bootstrap.yml b/docker/php/alpine-php5/conf/provision/roles/webdevops-php/tasks/bootstrap.yml new file mode 100644 index 000000000..99a2e5191 --- /dev/null +++ b/docker/php/alpine-php5/conf/provision/roles/webdevops-php/tasks/bootstrap.yml @@ -0,0 +1,10 @@ +--- + +- include: bootstrap/init.yml +- include: bootstrap/php.yml +- include: bootstrap/php.debian.yml +- include: bootstrap/php.redhat.yml +- include: bootstrap/php.alpine.yml +- include: bootstrap/php-fpm.main.yml +- include: bootstrap/php-fpm.pool.yml +- include: bootstrap/php-fpm.yml diff --git a/docker/php/alpine-php5/conf/provision/roles/webdevops-php/tasks/bootstrap/init.yml b/docker/php/alpine-php5/conf/provision/roles/webdevops-php/tasks/bootstrap/init.yml new file mode 100644 index 000000000..a48bec675 --- /dev/null +++ b/docker/php/alpine-php5/conf/provision/roles/webdevops-php/tasks/bootstrap/init.yml @@ -0,0 +1,71 @@ +--- + +- name: Get php version + command: "php -r 'echo phpversion();'" + changed_when: true + register: php_version_cmd + ignore_errors: true + +- name: Set php_version version + set_fact: + php_version: "{{php_version_cmd.stdout}}" + +############################# +# PHP 5.x +############################# + +- name: Set php main file (RedHat, PHP 5.x) + set_fact: + php_main_conf: /etc/php-fpm.conf + php_pool_conf: www.conf + php_pool_dir: /etc/php-fpm.d + php_fpm_bin: /usr/sbin/php-fpm + when: ansible_os_family == 'RedHat' and ( php_version | version_compare('7.0.0', '<') ) + +- name: Set php main file (Debian, PHP 5.x) + set_fact: + php_etc_dir: /etc/php5 + php_main_conf: /etc/php5/fpm/php-fpm.conf + php_pool_conf: www.conf + php_pool_dir: /etc/php5/fpm/pool.d + php_fpm_bin: /usr/sbin/php5-fpm + when: ansible_os_family == 'Debian' and ( php_version | version_compare('7.0.0', '<') ) + +- name: Set php main file (Alpine, PHP 5.x) + set_fact: + php_etc_dir: /etc/php5 + php_main_conf: /etc/php5/php-fpm.conf + php_pool_conf: www.conf + php_pool_dir: /etc/php5/fpm.d + php_fpm_bin: /usr/bin/php-fpm5 + when: ansible_os_family == 'Alpine' and ( php_version | version_compare('7.0.0', '<') ) + +############################# +# PHP 7.x +############################# + +- name: Set php main file (RedHat, PHP 7.x) + set_fact: + php_main_conf: /etc/php-fpm.conf + php_pool_conf: www.conf + php_pool_dir: /etc/php-fpm.d + php_fpm_bin: /usr/sbin/php-fpm + when: ansible_os_family == 'RedHat' and ( php_version | version_compare('7.0.0', '>=') ) and ( php_version | version_compare('8.0.0', '<') ) + +- name: Set php main file (Debian, PHP 7.x) + set_fact: + php_etc_dir: /etc/php/7.0 + php_main_conf: /etc/php/7.0/fpm/php-fpm.conf + php_pool_conf: www.conf + php_pool_dir: /etc/php/7.0/fpm/pool.d + php_fpm_bin: /usr/sbin/php-fpm7.0 + when: ansible_os_family == 'Debian' and ( php_version | version_compare('7.0.0', '>=') ) and ( php_version | version_compare('8.0.0', '<') ) + +- name: Set php main file (Alpine, PHP 7.x) + set_fact: + php_etc_dir: /etc/php7 + php_main_conf: /etc/php7/php-fpm.conf + php_pool_conf: www.conf + php_pool_dir: /etc/php7/php-fpm.d + php_fpm_bin: /usr/sbin/php-fpm7 + when: ansible_os_family == 'Alpine' and ( php_version | version_compare('7.0.0', '>=') ) and ( php_version | version_compare('8.0.0', '<') ) diff --git a/docker/php/alpine-php5/conf/provision/roles/webdevops-php/tasks/bootstrap/php-fpm.main.yml b/docker/php/alpine-php5/conf/provision/roles/webdevops-php/tasks/bootstrap/php-fpm.main.yml new file mode 100644 index 000000000..c149d8728 --- /dev/null +++ b/docker/php/alpine-php5/conf/provision/roles/webdevops-php/tasks/bootstrap/php-fpm.main.yml @@ -0,0 +1,49 @@ +--- + +- name: Create php directories + file: + path: "{{ item }}" + state: directory + mode: 0755 + owner: "root" + group: "root" + with_items: + - /opt/docker/etc/php/fpm/ + +- name: Move php-fpm main file to /opt/docker/etc/php/fpm/ + command: "mv {{ php_main_conf }} /opt/docker/etc/php/fpm/php-fpm.conf" + args: + creates: /opt/docker/etc/php/fpm/php-fpm.conf + +- name: Remove php-fpm main file + file: + path: "{{ php_main_conf }}" + state: absent + +- name: Symlink php-fpm main file + file: + path: "{{ php_main_conf }}" + src: "/opt/docker/etc/php/fpm/php-fpm.conf" + state: link + owner: "root" + group: "root" + +- name: Configure php-fpm main (all versions) + lineinfile: + dest: '/opt/docker/etc/php/fpm/php-fpm.conf' + regexp: '^[\s;]*{{ item.key }}[\s]*=' + line: '{{ item.key }} = {{ item.value }}' + insertafter: '\[global\]' + with_items: + - { key: 'error_log', value: "/docker.stderr" } + - { key: 'pid', value: "/var/run/php-fpm.pid" } + +- name: Configure php-fpm main (php 5.x) + lineinfile: + dest: '/opt/docker/etc/php/fpm/php-fpm.conf' + regexp: '^[\s;]*{{ item.key }}[\s]*=' + line: '{{ item.key }} = {{ item.value }}' + insertbefore: '[\s]*include[\s]*=' + with_items: + - { key: 'daemonize', value: 'no' } + when: ( php_version | version_compare('7.0.0', '<') ) diff --git a/docker/php/alpine-php5/conf/provision/roles/webdevops-php/tasks/bootstrap/php-fpm.pool.yml b/docker/php/alpine-php5/conf/provision/roles/webdevops-php/tasks/bootstrap/php-fpm.pool.yml new file mode 100644 index 000000000..ab0b7b02c --- /dev/null +++ b/docker/php/alpine-php5/conf/provision/roles/webdevops-php/tasks/bootstrap/php-fpm.pool.yml @@ -0,0 +1,101 @@ +--- + +- set_fact: + php_clear_env_available: False + +- set_fact: + php_clear_env_available: True + when: ( php_version | version_compare('5.4', 'eq') and php_version | version_compare('5.4.27', 'ge') ) or + ( php_version | version_compare('5.5', 'eq') and php_version | version_compare('5.5.11', 'ge') ) or + ( php_version | version_compare('5.6', 'ge') ) + +- name: Create /opt/docker/etc/php/fpm directory + file: + path: "/opt/docker/etc/php/fpm" + state: directory + +- name: Move php-fpm pool directory file to /opt/docker/etc/php/ + command: "mv {{ php_pool_dir }} /opt/docker/etc/php/fpm/pool.d" + args: + creates: /opt/docker/etc/php/fpm/pool.d + +- name: Rename pool file file to application.conf" + command: "mv /opt/docker/etc/php/fpm/pool.d/{{ php_pool_conf }} /opt/docker/etc/php/fpm/pool.d/application.conf" + args: + creates: /opt/docker/etc/php/fpm/pool.d/application.conf + +- name: Remove php-fpm pool directory + file: + path: "{{ php_pool_dir }}" + state: absent + +- name: Symlink php-fpm pool file + file: + path: "{{ php_pool_dir }}" + src: "/opt/docker/etc/php/fpm/pool.d" + state: link + owner: "root" + group: "root" + +- name: Configure php-fpm pool user (application.conf) + lineinfile: + dest: '/opt/docker/etc/php/fpm/pool.d/application.conf' + regexp: '^[\s;]*{{ item.key }}[\s]*=' + line: '{{ item.key }} = {{ item.value }}' + with_items: + - { key: 'listen', value: "[::]:9000" } + - { key: 'catch_workers_output', value: "yes" } + - { key: 'access.format', value: '[php-fpm:access] %R - %u %t "%m %r%Q%q" %s %f %{mili}d %{kilo}M %C%%' } + - { key: 'access.log', value: "/docker.stdout" } + - { key: 'slowlog', value: "/docker.stderr" } + - { key: 'php_admin_value[error_log]', value: "/docker.stderr" } + - { key: 'php_admin_value[log_errors]', value: "on" } + - { key: 'user', value: "{{ APPLICATION_USER }}" } + - { key: 'group', value: "{{ APPLICATION_GROUP }}" } + +- name: Configure php-fpm pool user (application.conf) + lineinfile: + dest: '/opt/docker/etc/php/fpm/pool.d/application.conf' + regexp: '^[\s;]*{{ item.key }}[\s]*=' + line: '{{ item.key }} = {{ item.value }}' + with_items: + - { key: 'listen', value: "0.0.0.0:9000" } + when: php_version | version_compare('5.5.99', '<=') + +- name: Configure php-fpm pool user (application.conf) + lineinfile: + dest: '/opt/docker/etc/php/fpm/pool.d/application.conf' + regexp: '^[\s;]*{{ item.key }}[\s]*=' + line: ';{{ item.key }} = {{ item.value }}' + with_items: + - { key: 'access.log', value: "/docker.stdout" } + +- name: Disable clear env in php-fpm pool + lineinfile: + dest: '/opt/docker/etc/php/fpm/pool.d/application.conf' + regexp: '^[\s;]*{{ item.key }}[\s]*=' + line: '{{ item.key }} = {{ item.value }}' + with_items: + - { key: 'clear_env', value: "no" } + when: php_clear_env_available == True + +- name: Remove clear env workaround + file: + path: "/opt/docker/bin/service.d/php-fpm.d/11-clear-env.sh" + state: absent + when: php_clear_env_available == True + +- name: Append clear env workaround in php-fpm pool (old php-fpm versions) + lineinfile: + dest: '/opt/docker/etc/php/fpm/pool.d/application.conf' + line: ';#CLEAR_ENV_WORKAROUND#' + when: php_clear_env_available == False + +- name: Disable php-fpm connection limit + lineinfile: + dest: '/opt/docker/etc/php/fpm/pool.d/application.conf' + regexp: '^[\s;]*{{ item.key }}[\s]*=' + line: ';{{ item.key }}' + with_items: + - { key: 'listen.allowed_clients' } + diff --git a/docker/php/alpine-php5/conf/provision/roles/webdevops-php/tasks/bootstrap/php-fpm.yml b/docker/php/alpine-php5/conf/provision/roles/webdevops-php/tasks/bootstrap/php-fpm.yml new file mode 100644 index 000000000..41c1b33dc --- /dev/null +++ b/docker/php/alpine-php5/conf/provision/roles/webdevops-php/tasks/bootstrap/php-fpm.yml @@ -0,0 +1,9 @@ +--- + +- name: Symlink php-fpm binary + file: + path: "/usr/local/bin/php-fpm" + src: "{{ php_fpm_bin }}" + state: link + owner: "root" + group: "root" diff --git a/docker/php/alpine-php5/conf/provision/roles/webdevops-php/tasks/bootstrap/php.alpine.yml b/docker/php/alpine-php5/conf/provision/roles/webdevops-php/tasks/bootstrap/php.alpine.yml new file mode 100644 index 000000000..4c16cdf0d --- /dev/null +++ b/docker/php/alpine-php5/conf/provision/roles/webdevops-php/tasks/bootstrap/php.alpine.yml @@ -0,0 +1,12 @@ +--- + +- name: Create link for additional php.ini [Alpine family] + file: + src: '/opt/docker/etc/php/{{ item.file }}' + dest: '{{ php_etc_dir }}/conf.d/{{ item.target }}' + state: link + force: yes + with_items: + - { file: 'php.webdevops.ini', target: 'xzza-webdevops.ini'} + - { file: 'php.ini', target: 'xzzz-docker.ini'} + when: ansible_os_family == 'Alpine' diff --git a/docker/php/alpine-php5/conf/provision/roles/webdevops-php/tasks/bootstrap/php.debian.yml b/docker/php/alpine-php5/conf/provision/roles/webdevops-php/tasks/bootstrap/php.debian.yml new file mode 100644 index 000000000..d27037e33 --- /dev/null +++ b/docker/php/alpine-php5/conf/provision/roles/webdevops-php/tasks/bootstrap/php.debian.yml @@ -0,0 +1,18 @@ +--- + +- name: Link php.ini for cli and fpm [Debian family] + file: + src: '{{ item.file }}' + dest: '{{ php_etc_dir }}/{{ item.category }}/conf.d/{{ item.target }}' + force: yes + state: link + with_items: + # PHP cli + - { category: 'cli', file: '{{ php_etc_dir }}/mods-available/mcrypt.ini', target: '20-mcrypt.ini' } + - { category: 'cli', file: '/opt/docker/etc/php/php.webdevops.ini', target: '98-webdevops.ini' } + - { category: 'cli', file: '/opt/docker/etc/php/php.ini', target: '99-docker.ini' } + # PHP fpm + - { category: 'fpm', file: '{{ php_etc_dir }}/mods-available/mcrypt.ini', target: '20-mcrypt.ini' } + - { category: 'fpm', file: '/opt/docker/etc/php/php.webdevops.ini', target: '98-webdevops.ini' } + - { category: 'fpm', file: '/opt/docker/etc/php/php.ini', target: '99-docker.ini' } + when: ansible_os_family == 'Debian' diff --git a/docker/php/alpine-php5/conf/provision/roles/webdevops-php/tasks/bootstrap/php.redhat.yml b/docker/php/alpine-php5/conf/provision/roles/webdevops-php/tasks/bootstrap/php.redhat.yml new file mode 100644 index 000000000..7e8810231 --- /dev/null +++ b/docker/php/alpine-php5/conf/provision/roles/webdevops-php/tasks/bootstrap/php.redhat.yml @@ -0,0 +1,12 @@ +--- + +- name: Create link for additional php.ini [RedHat family] + file: + src: '/opt/docker/etc/php/{{ item.file }}' + dest: '/etc/php.d/{{ item.target }}' + state: link + force: yes + with_items: + - { file: 'php.webdevops.ini', target: 'zza-webdevops.ini'} + - { file: 'php.ini', target: 'zzz-docker.ini'} + when: ansible_os_family == 'RedHat' diff --git a/docker/php/alpine-php5/conf/provision/roles/webdevops-php/tasks/bootstrap/php.yml b/docker/php/alpine-php5/conf/provision/roles/webdevops-php/tasks/bootstrap/php.yml new file mode 100644 index 000000000..caac8f413 --- /dev/null +++ b/docker/php/alpine-php5/conf/provision/roles/webdevops-php/tasks/bootstrap/php.yml @@ -0,0 +1,23 @@ +--- + +- name: Create php directories + file: + path: "{{ item }}" + state: directory + mode: 0755 + owner: "root" + group: "root" + with_items: + - /opt/docker/etc/php/ + - /opt/docker/etc/php/fpm/ + +- name: Create php.ini files + file: + path: "{{ item }}" + state: touch + mode: 0744 + owner: root + group: root + with_items: + - "/opt/docker/etc/php/php.webdevops.ini" + - "/opt/docker/etc/php/php.ini" diff --git a/docker/php/alpine-php5/conf/provision/roles/webdevops-php/tasks/main.yml b/docker/php/alpine-php5/conf/provision/roles/webdevops-php/tasks/main.yml new file mode 100644 index 000000000..1806c1a8c --- /dev/null +++ b/docker/php/alpine-php5/conf/provision/roles/webdevops-php/tasks/main.yml @@ -0,0 +1,5 @@ +--- + +- include: bootstrap.yml + tags: + - bootstrap diff --git a/docker/php/alpine-php7/Dockerfile b/docker/php/alpine-php7/Dockerfile new file mode 100644 index 000000000..3fc98cffd --- /dev/null +++ b/docker/php/alpine-php7/Dockerfile @@ -0,0 +1,81 @@ +#+++++++++++++++++++++++++++++++++++++++ +# Dockerfile for webdevops/php:alpine-php7 +# -- automatically generated -- +#+++++++++++++++++++++++++++++++++++++++ + +FROM webdevops/base-app:alpine + +ENV WEB_DOCUMENT_ROOT=/app \ + WEB_DOCUMENT_INDEX=index.php \ + WEB_ALIAS_DOMAIN=*.vm + +COPY conf/ /opt/docker/ + +# Install php environment +RUN /usr/local/bin/apk-install \ + # Install tools + imagemagick \ + graphicsmagick \ + ghostscript \ + # Install php (cli/fpm) + php7-fpm \ + php7-json \ + php7-intl \ + php7-curl \ + php7-mysqli \ + php7-mysqlnd \ + php7-pdo_mysql \ + php7-pdo_sqlite \ + php7-mcrypt \ + php7-gd \ + php7-bcmath \ + php7-soap \ + php7-sqlite3 \ + php7-bz2 \ + php7-calendar \ + php7-ctype \ + php7-pcntl \ + php7-posix \ + php7-sockets \ + php7-sysvmsg \ + php7-sysvsem \ + php7-sysvshm \ + php7-xmlreader \ + php7-exif \ + php7-ftp \ + php7-gettext \ + php7-iconv \ + php7-zip \ + php7-zlib \ + php7-shmop \ + php7-wddx \ + sqlite \ + php7-xmlrpc \ + php7-xsl \ + geoip \ + php7-ldap \ + # php7-memcache \ + # php7-redis \ + php7-pear \ + php7-phar \ + php7-openssl \ + php7-session \ + php7-opcache \ + php7-mbstring \ + php7-iconv \ + php7-apcu \ + && ln -s /usr/bin/php7 /usr/bin/php \ + && ln -s /usr/sbin/php-fpm7 /usr/sbin/php-fpm \ + && pear channel-update pear.php.net \ + && pear upgrade-all \ + && pear config-set auto_discover 1 \ + && curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin/ --filename=composer \ + # PECL workaround, see webdevops/Dockerfile#78 + && sed -i "s/ -n / /" $(which pecl) \ + # Enable php services + && docker-service-enable syslog cron \ + && /opt/docker/bin/provision run --tag bootstrap --role webdevops-php \ + && /opt/docker/bin/bootstrap.sh \ + && docker-image-cleanup + +EXPOSE 9000 diff --git a/docker/php/alpine-php7/Dockerfile.jinja2 b/docker/php/alpine-php7/Dockerfile.jinja2 new file mode 100644 index 000000000..808076d12 --- /dev/null +++ b/docker/php/alpine-php7/Dockerfile.jinja2 @@ -0,0 +1,9 @@ +{{ docker.from("base-app", "alpine") }} + +{{ environment.web() }} + +{{ docker.copy('conf/', '/opt/docker/') }} + +{{ php7.alpine() }} + +{{ docker.expose('9000') }} diff --git a/docker/php/alpine-php7/conf/bin/service.d/php-fpm.d/10-init.sh b/docker/php/alpine-php7/conf/bin/service.d/php-fpm.d/10-init.sh new file mode 100644 index 000000000..312fcd043 --- /dev/null +++ b/docker/php/alpine-php7/conf/bin/service.d/php-fpm.d/10-init.sh @@ -0,0 +1,8 @@ +# setup user env +FPM_POOL_CONF="/opt/docker/etc/php/fpm/pool.d/application.conf" + +## Setup container uid +if [[ -n "$CONTAINER_UID" ]]; then + sed -i "s/user[ ]*=.*/user = ${CONTAINER_UID}/g" "$FPM_POOL_CONF" + sed -i "s/group[ ]*=.*/group = ${CONTAINER_UID}/g" "$FPM_POOL_CONF" +fi diff --git a/docker/php/alpine-php7/conf/bin/service.d/php-fpm.d/11-clear-env.sh b/docker/php/alpine-php7/conf/bin/service.d/php-fpm.d/11-clear-env.sh new file mode 100644 index 000000000..ef6fd4016 --- /dev/null +++ b/docker/php/alpine-php7/conf/bin/service.d/php-fpm.d/11-clear-env.sh @@ -0,0 +1,38 @@ +# +# Workaround for old php-fpm versions which don't have clear_env setting +# + +VARIABLE_LIST="; Workaround for missing clear_env feature in PHP-FPM" + +# For each exported variable +for envVariable in $(printenv|cut -f1 -d=); do + + case "$envVariable" in + "_"|"PATH"|"PWD") + ## ignore this variables + ;; + + *) + ## get content of variable + envVariableContent="${!envVariable}" + + ## php-fpm requires that env variable has to be filled with content + if [[ -n "$envVariableContent" ]]; then + ## quote quotes + envVariableContent=${envVariableContent//\"/\\\"} + + ## add to list + VARIABLE_LIST="${VARIABLE_LIST}"$'\n'"env[${envVariable}] = \"${envVariableContent}\"" + fi + ;; + esac + +done + +# Replace ;#CLEAR_ENV_WORKAROUND# with environment variable list for all php-fpm pool files +go-replace \ + -s ";#CLEAR_ENV_WORKAROUND#" -r "$VARIABLE_LIST" \ + --path=/opt/docker/etc/php/fpm/pool.d/ \ + --path-pattern='*.conf' \ + --ignore-empty + diff --git a/docker/php/alpine-php7/conf/bin/service.d/php-fpm.sh b/docker/php/alpine-php7/conf/bin/service.d/php-fpm.sh new file mode 100644 index 000000000..b25983bd3 --- /dev/null +++ b/docker/php/alpine-php7/conf/bin/service.d/php-fpm.sh @@ -0,0 +1,7 @@ +#!/usr/bin/env bash + +source /opt/docker/bin/config.sh + +includeScriptDir "/opt/docker/bin/service.d/php-fpm.d/" + +exec /usr/local/bin/php-fpm --nodaemonize diff --git a/docker/php/alpine-php7/conf/etc/logrotate.d/php5-fpm b/docker/php/alpine-php7/conf/etc/logrotate.d/php5-fpm new file mode 100644 index 000000000..e6ef4b123 --- /dev/null +++ b/docker/php/alpine-php7/conf/etc/logrotate.d/php5-fpm @@ -0,0 +1,12 @@ +/var/log/php5-fpm/fpm.log +/var/log/php5-fpm/access.log +/var/log/php5-fpm/slow.log +/var/log/php5-fpm/error.log { + missingok + notifempty + sharedscripts + delaycompress + postrotate + /bin/kill -SIGUSR1 `cat /var/run/php5-fpm.pid` 2>/dev/null || true + endscript +} diff --git a/docker/php/alpine-php7/conf/etc/php/conf.d/.gitkeep b/docker/php/alpine-php7/conf/etc/php/conf.d/.gitkeep new file mode 100644 index 000000000..e69de29bb diff --git a/docker/php/alpine-3/conf/etc/php/fpm/php-fpm.conf b/docker/php/alpine-php7/conf/etc/php/fpm/php-fpm.conf similarity index 100% rename from docker/php/alpine-3/conf/etc/php/fpm/php-fpm.conf rename to docker/php/alpine-php7/conf/etc/php/fpm/php-fpm.conf diff --git a/docker/php/alpine-3/conf/etc/php/fpm/pool.d/application.conf b/docker/php/alpine-php7/conf/etc/php/fpm/pool.d/application.conf similarity index 100% rename from docker/php/alpine-3/conf/etc/php/fpm/pool.d/application.conf rename to docker/php/alpine-php7/conf/etc/php/fpm/pool.d/application.conf diff --git a/docker/php/alpine-php7/conf/etc/php/php.ini b/docker/php/alpine-php7/conf/etc/php/php.ini new file mode 100644 index 000000000..447212118 --- /dev/null +++ b/docker/php/alpine-php7/conf/etc/php/php.ini @@ -0,0 +1 @@ +; placeholder diff --git a/docker/php/alpine-php7/conf/etc/php/php.webdevops.ini b/docker/php/alpine-php7/conf/etc/php/php.webdevops.ini new file mode 100644 index 000000000..aa1545ab8 --- /dev/null +++ b/docker/php/alpine-php7/conf/etc/php/php.webdevops.ini @@ -0,0 +1,34 @@ +; ------------------------------------- +; Docker Webdevops PHP configuration +; ------------------------------------- + +; this file will overwrite default php.ini settings + +display_errors = 0 +log_errors = 1 + +short_open_tag = Off +variables_order = 'GPCS' +request_order = 'GP' + +allow_url_fopen = On +allow_url_include = Off + +memory_limit = 512M +max_execution_time = 300 +max_input_time = 300 +post_max_size = 50M +upload_max_filesize = 50M +max_input_vars = 5000 + +expose_php = Off + +date.timezone = UTC + +mysql.default_host = mysql +mysqli.default_host = mysql + +opcache.memory_consumption = 256 +opcache.interned_strings_buffer = 16 +opcache.max_accelerated_files = 7963 +opcache.fast_shutdown = 1 diff --git a/docker/php/alpine-php7/conf/etc/supervisor.d/php-fpm.conf b/docker/php/alpine-php7/conf/etc/supervisor.d/php-fpm.conf new file mode 100644 index 000000000..5781f5b0a --- /dev/null +++ b/docker/php/alpine-php7/conf/etc/supervisor.d/php-fpm.conf @@ -0,0 +1,15 @@ +[group:php-fpm] +programs=php-fpmd +priority=20 + +[program:php-fpmd] +command = /opt/docker/bin/service.d/php-fpm.sh +process_name=%(program_name)s +startsecs = 0 +autostart = true +autorestart = true +stdout_logfile=/dev/stdout +stdout_logfile_maxbytes=0 +stderr_logfile=/dev/stderr +stderr_logfile_maxbytes=0 + diff --git a/docker/php/alpine-php7/conf/provision/roles/webdevops-php/defaults/main.yml b/docker/php/alpine-php7/conf/provision/roles/webdevops-php/defaults/main.yml new file mode 100644 index 000000000..81f5b7efd --- /dev/null +++ b/docker/php/alpine-php7/conf/provision/roles/webdevops-php/defaults/main.yml @@ -0,0 +1,6 @@ +--- + +APPLICATION_USER: "{{ lookup('env','APPLICATION_USER') }}" +APPLICATION_GROUP: "{{ lookup('env','APPLICATION_GROUP') }}" +APPLICATION_UID: "{{ lookup('env','APPLICATION_UID') }}" +APPLICATION_GID: "{{ lookup('env','APPLICATION_GID') }}" diff --git a/docker/php/alpine-php7/conf/provision/roles/webdevops-php/tasks/bootstrap.yml b/docker/php/alpine-php7/conf/provision/roles/webdevops-php/tasks/bootstrap.yml new file mode 100644 index 000000000..99a2e5191 --- /dev/null +++ b/docker/php/alpine-php7/conf/provision/roles/webdevops-php/tasks/bootstrap.yml @@ -0,0 +1,10 @@ +--- + +- include: bootstrap/init.yml +- include: bootstrap/php.yml +- include: bootstrap/php.debian.yml +- include: bootstrap/php.redhat.yml +- include: bootstrap/php.alpine.yml +- include: bootstrap/php-fpm.main.yml +- include: bootstrap/php-fpm.pool.yml +- include: bootstrap/php-fpm.yml diff --git a/docker/php/alpine-php7/conf/provision/roles/webdevops-php/tasks/bootstrap/init.yml b/docker/php/alpine-php7/conf/provision/roles/webdevops-php/tasks/bootstrap/init.yml new file mode 100644 index 000000000..a48bec675 --- /dev/null +++ b/docker/php/alpine-php7/conf/provision/roles/webdevops-php/tasks/bootstrap/init.yml @@ -0,0 +1,71 @@ +--- + +- name: Get php version + command: "php -r 'echo phpversion();'" + changed_when: true + register: php_version_cmd + ignore_errors: true + +- name: Set php_version version + set_fact: + php_version: "{{php_version_cmd.stdout}}" + +############################# +# PHP 5.x +############################# + +- name: Set php main file (RedHat, PHP 5.x) + set_fact: + php_main_conf: /etc/php-fpm.conf + php_pool_conf: www.conf + php_pool_dir: /etc/php-fpm.d + php_fpm_bin: /usr/sbin/php-fpm + when: ansible_os_family == 'RedHat' and ( php_version | version_compare('7.0.0', '<') ) + +- name: Set php main file (Debian, PHP 5.x) + set_fact: + php_etc_dir: /etc/php5 + php_main_conf: /etc/php5/fpm/php-fpm.conf + php_pool_conf: www.conf + php_pool_dir: /etc/php5/fpm/pool.d + php_fpm_bin: /usr/sbin/php5-fpm + when: ansible_os_family == 'Debian' and ( php_version | version_compare('7.0.0', '<') ) + +- name: Set php main file (Alpine, PHP 5.x) + set_fact: + php_etc_dir: /etc/php5 + php_main_conf: /etc/php5/php-fpm.conf + php_pool_conf: www.conf + php_pool_dir: /etc/php5/fpm.d + php_fpm_bin: /usr/bin/php-fpm5 + when: ansible_os_family == 'Alpine' and ( php_version | version_compare('7.0.0', '<') ) + +############################# +# PHP 7.x +############################# + +- name: Set php main file (RedHat, PHP 7.x) + set_fact: + php_main_conf: /etc/php-fpm.conf + php_pool_conf: www.conf + php_pool_dir: /etc/php-fpm.d + php_fpm_bin: /usr/sbin/php-fpm + when: ansible_os_family == 'RedHat' and ( php_version | version_compare('7.0.0', '>=') ) and ( php_version | version_compare('8.0.0', '<') ) + +- name: Set php main file (Debian, PHP 7.x) + set_fact: + php_etc_dir: /etc/php/7.0 + php_main_conf: /etc/php/7.0/fpm/php-fpm.conf + php_pool_conf: www.conf + php_pool_dir: /etc/php/7.0/fpm/pool.d + php_fpm_bin: /usr/sbin/php-fpm7.0 + when: ansible_os_family == 'Debian' and ( php_version | version_compare('7.0.0', '>=') ) and ( php_version | version_compare('8.0.0', '<') ) + +- name: Set php main file (Alpine, PHP 7.x) + set_fact: + php_etc_dir: /etc/php7 + php_main_conf: /etc/php7/php-fpm.conf + php_pool_conf: www.conf + php_pool_dir: /etc/php7/php-fpm.d + php_fpm_bin: /usr/sbin/php-fpm7 + when: ansible_os_family == 'Alpine' and ( php_version | version_compare('7.0.0', '>=') ) and ( php_version | version_compare('8.0.0', '<') ) diff --git a/docker/php/alpine-php7/conf/provision/roles/webdevops-php/tasks/bootstrap/php-fpm.main.yml b/docker/php/alpine-php7/conf/provision/roles/webdevops-php/tasks/bootstrap/php-fpm.main.yml new file mode 100644 index 000000000..c149d8728 --- /dev/null +++ b/docker/php/alpine-php7/conf/provision/roles/webdevops-php/tasks/bootstrap/php-fpm.main.yml @@ -0,0 +1,49 @@ +--- + +- name: Create php directories + file: + path: "{{ item }}" + state: directory + mode: 0755 + owner: "root" + group: "root" + with_items: + - /opt/docker/etc/php/fpm/ + +- name: Move php-fpm main file to /opt/docker/etc/php/fpm/ + command: "mv {{ php_main_conf }} /opt/docker/etc/php/fpm/php-fpm.conf" + args: + creates: /opt/docker/etc/php/fpm/php-fpm.conf + +- name: Remove php-fpm main file + file: + path: "{{ php_main_conf }}" + state: absent + +- name: Symlink php-fpm main file + file: + path: "{{ php_main_conf }}" + src: "/opt/docker/etc/php/fpm/php-fpm.conf" + state: link + owner: "root" + group: "root" + +- name: Configure php-fpm main (all versions) + lineinfile: + dest: '/opt/docker/etc/php/fpm/php-fpm.conf' + regexp: '^[\s;]*{{ item.key }}[\s]*=' + line: '{{ item.key }} = {{ item.value }}' + insertafter: '\[global\]' + with_items: + - { key: 'error_log', value: "/docker.stderr" } + - { key: 'pid', value: "/var/run/php-fpm.pid" } + +- name: Configure php-fpm main (php 5.x) + lineinfile: + dest: '/opt/docker/etc/php/fpm/php-fpm.conf' + regexp: '^[\s;]*{{ item.key }}[\s]*=' + line: '{{ item.key }} = {{ item.value }}' + insertbefore: '[\s]*include[\s]*=' + with_items: + - { key: 'daemonize', value: 'no' } + when: ( php_version | version_compare('7.0.0', '<') ) diff --git a/docker/php/alpine-php7/conf/provision/roles/webdevops-php/tasks/bootstrap/php-fpm.pool.yml b/docker/php/alpine-php7/conf/provision/roles/webdevops-php/tasks/bootstrap/php-fpm.pool.yml new file mode 100644 index 000000000..ab0b7b02c --- /dev/null +++ b/docker/php/alpine-php7/conf/provision/roles/webdevops-php/tasks/bootstrap/php-fpm.pool.yml @@ -0,0 +1,101 @@ +--- + +- set_fact: + php_clear_env_available: False + +- set_fact: + php_clear_env_available: True + when: ( php_version | version_compare('5.4', 'eq') and php_version | version_compare('5.4.27', 'ge') ) or + ( php_version | version_compare('5.5', 'eq') and php_version | version_compare('5.5.11', 'ge') ) or + ( php_version | version_compare('5.6', 'ge') ) + +- name: Create /opt/docker/etc/php/fpm directory + file: + path: "/opt/docker/etc/php/fpm" + state: directory + +- name: Move php-fpm pool directory file to /opt/docker/etc/php/ + command: "mv {{ php_pool_dir }} /opt/docker/etc/php/fpm/pool.d" + args: + creates: /opt/docker/etc/php/fpm/pool.d + +- name: Rename pool file file to application.conf" + command: "mv /opt/docker/etc/php/fpm/pool.d/{{ php_pool_conf }} /opt/docker/etc/php/fpm/pool.d/application.conf" + args: + creates: /opt/docker/etc/php/fpm/pool.d/application.conf + +- name: Remove php-fpm pool directory + file: + path: "{{ php_pool_dir }}" + state: absent + +- name: Symlink php-fpm pool file + file: + path: "{{ php_pool_dir }}" + src: "/opt/docker/etc/php/fpm/pool.d" + state: link + owner: "root" + group: "root" + +- name: Configure php-fpm pool user (application.conf) + lineinfile: + dest: '/opt/docker/etc/php/fpm/pool.d/application.conf' + regexp: '^[\s;]*{{ item.key }}[\s]*=' + line: '{{ item.key }} = {{ item.value }}' + with_items: + - { key: 'listen', value: "[::]:9000" } + - { key: 'catch_workers_output', value: "yes" } + - { key: 'access.format', value: '[php-fpm:access] %R - %u %t "%m %r%Q%q" %s %f %{mili}d %{kilo}M %C%%' } + - { key: 'access.log', value: "/docker.stdout" } + - { key: 'slowlog', value: "/docker.stderr" } + - { key: 'php_admin_value[error_log]', value: "/docker.stderr" } + - { key: 'php_admin_value[log_errors]', value: "on" } + - { key: 'user', value: "{{ APPLICATION_USER }}" } + - { key: 'group', value: "{{ APPLICATION_GROUP }}" } + +- name: Configure php-fpm pool user (application.conf) + lineinfile: + dest: '/opt/docker/etc/php/fpm/pool.d/application.conf' + regexp: '^[\s;]*{{ item.key }}[\s]*=' + line: '{{ item.key }} = {{ item.value }}' + with_items: + - { key: 'listen', value: "0.0.0.0:9000" } + when: php_version | version_compare('5.5.99', '<=') + +- name: Configure php-fpm pool user (application.conf) + lineinfile: + dest: '/opt/docker/etc/php/fpm/pool.d/application.conf' + regexp: '^[\s;]*{{ item.key }}[\s]*=' + line: ';{{ item.key }} = {{ item.value }}' + with_items: + - { key: 'access.log', value: "/docker.stdout" } + +- name: Disable clear env in php-fpm pool + lineinfile: + dest: '/opt/docker/etc/php/fpm/pool.d/application.conf' + regexp: '^[\s;]*{{ item.key }}[\s]*=' + line: '{{ item.key }} = {{ item.value }}' + with_items: + - { key: 'clear_env', value: "no" } + when: php_clear_env_available == True + +- name: Remove clear env workaround + file: + path: "/opt/docker/bin/service.d/php-fpm.d/11-clear-env.sh" + state: absent + when: php_clear_env_available == True + +- name: Append clear env workaround in php-fpm pool (old php-fpm versions) + lineinfile: + dest: '/opt/docker/etc/php/fpm/pool.d/application.conf' + line: ';#CLEAR_ENV_WORKAROUND#' + when: php_clear_env_available == False + +- name: Disable php-fpm connection limit + lineinfile: + dest: '/opt/docker/etc/php/fpm/pool.d/application.conf' + regexp: '^[\s;]*{{ item.key }}[\s]*=' + line: ';{{ item.key }}' + with_items: + - { key: 'listen.allowed_clients' } + diff --git a/docker/php/alpine-php7/conf/provision/roles/webdevops-php/tasks/bootstrap/php-fpm.yml b/docker/php/alpine-php7/conf/provision/roles/webdevops-php/tasks/bootstrap/php-fpm.yml new file mode 100644 index 000000000..41c1b33dc --- /dev/null +++ b/docker/php/alpine-php7/conf/provision/roles/webdevops-php/tasks/bootstrap/php-fpm.yml @@ -0,0 +1,9 @@ +--- + +- name: Symlink php-fpm binary + file: + path: "/usr/local/bin/php-fpm" + src: "{{ php_fpm_bin }}" + state: link + owner: "root" + group: "root" diff --git a/docker/php/alpine-php7/conf/provision/roles/webdevops-php/tasks/bootstrap/php.alpine.yml b/docker/php/alpine-php7/conf/provision/roles/webdevops-php/tasks/bootstrap/php.alpine.yml new file mode 100644 index 000000000..4c16cdf0d --- /dev/null +++ b/docker/php/alpine-php7/conf/provision/roles/webdevops-php/tasks/bootstrap/php.alpine.yml @@ -0,0 +1,12 @@ +--- + +- name: Create link for additional php.ini [Alpine family] + file: + src: '/opt/docker/etc/php/{{ item.file }}' + dest: '{{ php_etc_dir }}/conf.d/{{ item.target }}' + state: link + force: yes + with_items: + - { file: 'php.webdevops.ini', target: 'xzza-webdevops.ini'} + - { file: 'php.ini', target: 'xzzz-docker.ini'} + when: ansible_os_family == 'Alpine' diff --git a/docker/php/alpine-php7/conf/provision/roles/webdevops-php/tasks/bootstrap/php.debian.yml b/docker/php/alpine-php7/conf/provision/roles/webdevops-php/tasks/bootstrap/php.debian.yml new file mode 100644 index 000000000..d27037e33 --- /dev/null +++ b/docker/php/alpine-php7/conf/provision/roles/webdevops-php/tasks/bootstrap/php.debian.yml @@ -0,0 +1,18 @@ +--- + +- name: Link php.ini for cli and fpm [Debian family] + file: + src: '{{ item.file }}' + dest: '{{ php_etc_dir }}/{{ item.category }}/conf.d/{{ item.target }}' + force: yes + state: link + with_items: + # PHP cli + - { category: 'cli', file: '{{ php_etc_dir }}/mods-available/mcrypt.ini', target: '20-mcrypt.ini' } + - { category: 'cli', file: '/opt/docker/etc/php/php.webdevops.ini', target: '98-webdevops.ini' } + - { category: 'cli', file: '/opt/docker/etc/php/php.ini', target: '99-docker.ini' } + # PHP fpm + - { category: 'fpm', file: '{{ php_etc_dir }}/mods-available/mcrypt.ini', target: '20-mcrypt.ini' } + - { category: 'fpm', file: '/opt/docker/etc/php/php.webdevops.ini', target: '98-webdevops.ini' } + - { category: 'fpm', file: '/opt/docker/etc/php/php.ini', target: '99-docker.ini' } + when: ansible_os_family == 'Debian' diff --git a/docker/php/alpine-php7/conf/provision/roles/webdevops-php/tasks/bootstrap/php.redhat.yml b/docker/php/alpine-php7/conf/provision/roles/webdevops-php/tasks/bootstrap/php.redhat.yml new file mode 100644 index 000000000..7e8810231 --- /dev/null +++ b/docker/php/alpine-php7/conf/provision/roles/webdevops-php/tasks/bootstrap/php.redhat.yml @@ -0,0 +1,12 @@ +--- + +- name: Create link for additional php.ini [RedHat family] + file: + src: '/opt/docker/etc/php/{{ item.file }}' + dest: '/etc/php.d/{{ item.target }}' + state: link + force: yes + with_items: + - { file: 'php.webdevops.ini', target: 'zza-webdevops.ini'} + - { file: 'php.ini', target: 'zzz-docker.ini'} + when: ansible_os_family == 'RedHat' diff --git a/docker/php/alpine-php7/conf/provision/roles/webdevops-php/tasks/bootstrap/php.yml b/docker/php/alpine-php7/conf/provision/roles/webdevops-php/tasks/bootstrap/php.yml new file mode 100644 index 000000000..caac8f413 --- /dev/null +++ b/docker/php/alpine-php7/conf/provision/roles/webdevops-php/tasks/bootstrap/php.yml @@ -0,0 +1,23 @@ +--- + +- name: Create php directories + file: + path: "{{ item }}" + state: directory + mode: 0755 + owner: "root" + group: "root" + with_items: + - /opt/docker/etc/php/ + - /opt/docker/etc/php/fpm/ + +- name: Create php.ini files + file: + path: "{{ item }}" + state: touch + mode: 0744 + owner: root + group: root + with_items: + - "/opt/docker/etc/php/php.webdevops.ini" + - "/opt/docker/etc/php/php.ini" diff --git a/docker/php/alpine-php7/conf/provision/roles/webdevops-php/tasks/main.yml b/docker/php/alpine-php7/conf/provision/roles/webdevops-php/tasks/main.yml new file mode 100644 index 000000000..1806c1a8c --- /dev/null +++ b/docker/php/alpine-php7/conf/provision/roles/webdevops-php/tasks/main.yml @@ -0,0 +1,5 @@ +--- + +- include: bootstrap.yml + tags: + - bootstrap diff --git a/docker/php/centos-7-php56/Dockerfile b/docker/php/centos-7-php56/Dockerfile index f5422aeff..0295235c0 100644 --- a/docker/php/centos-7-php56/Dockerfile +++ b/docker/php/centos-7-php56/Dockerfile @@ -5,14 +5,9 @@ FROM webdevops/base-app:centos-7 -MAINTAINER info@webdevops.io -LABEL vendor=WebDevOps.io -LABEL io.webdevops.layout=8 -LABEL io.webdevops.version=1.5.0 - -ENV WEB_DOCUMENT_ROOT /app -ENV WEB_DOCUMENT_INDEX index.php -ENV WEB_ALIAS_DOMAIN *.vm +ENV WEB_DOCUMENT_ROOT=/app \ + WEB_DOCUMENT_INDEX=index.php \ + WEB_ALIAS_DOMAIN=*.vm COPY conf/ /opt/docker/ @@ -53,9 +48,10 @@ RUN rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm \ && curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin/ --filename=composer \ # Cleanup && yum erase -y php-devel gcc \ - && yum clean all \ + # Enable php services + && docker-service-enable syslog cron \ && /opt/docker/bin/provision run --tag bootstrap --role webdevops-php \ - && /opt/docker/bin/bootstrap.sh - + && /opt/docker/bin/bootstrap.sh \ + && docker-image-cleanup EXPOSE 9000 diff --git a/docker/php/centos-7-php56/Dockerfile.jinja2 b/docker/php/centos-7-php56/Dockerfile.jinja2 index 4246d1bb0..9b34de366 100644 --- a/docker/php/centos-7-php56/Dockerfile.jinja2 +++ b/docker/php/centos-7-php56/Dockerfile.jinja2 @@ -1,7 +1,5 @@ {{ docker.from("base-app", "centos-7") }} -{{ docker.version() }} - {{ environment.web() }} {{ docker.copy('conf/', '/opt/docker/') }} diff --git a/docker/php/centos-7-php56/conf/bin/service.d/php-fpm.d/11-clear-env.sh b/docker/php/centos-7-php56/conf/bin/service.d/php-fpm.d/11-clear-env.sh index b17280ce6..ef6fd4016 100644 --- a/docker/php/centos-7-php56/conf/bin/service.d/php-fpm.d/11-clear-env.sh +++ b/docker/php/centos-7-php56/conf/bin/service.d/php-fpm.d/11-clear-env.sh @@ -30,5 +30,9 @@ for envVariable in $(printenv|cut -f1 -d=); do done # Replace ;#CLEAR_ENV_WORKAROUND# with environment variable list for all php-fpm pool files -find /opt/docker/etc/php/fpm/pool.d/ -iname '*.conf' -print0 | xargs -0 -r rpl --quiet ";#CLEAR_ENV_WORKAROUND#" "$VARIABLE_LIST" > /dev/null +go-replace \ + -s ";#CLEAR_ENV_WORKAROUND#" -r "$VARIABLE_LIST" \ + --path=/opt/docker/etc/php/fpm/pool.d/ \ + --path-pattern='*.conf' \ + --ignore-empty diff --git a/docker/php/centos-7-php56/conf/bin/service.d/php-fpm.sh b/docker/php/centos-7-php56/conf/bin/service.d/php-fpm.sh index 571f248d2..b25983bd3 100644 --- a/docker/php/centos-7-php56/conf/bin/service.d/php-fpm.sh +++ b/docker/php/centos-7-php56/conf/bin/service.d/php-fpm.sh @@ -4,4 +4,4 @@ source /opt/docker/bin/config.sh includeScriptDir "/opt/docker/bin/service.d/php-fpm.d/" -exec /usr/sbin/php-fpm --nodaemonize +exec /usr/local/bin/php-fpm --nodaemonize diff --git a/docker/php/centos-7-php56/conf/etc/php/php.webdevops.ini b/docker/php/centos-7-php56/conf/etc/php/php.webdevops.ini index 562b8d7e2..aa1545ab8 100644 --- a/docker/php/centos-7-php56/conf/etc/php/php.webdevops.ini +++ b/docker/php/centos-7-php56/conf/etc/php/php.webdevops.ini @@ -5,6 +5,7 @@ ; this file will overwrite default php.ini settings display_errors = 0 +log_errors = 1 short_open_tag = Off variables_order = 'GPCS' diff --git a/docker/php/centos-7-php56/conf/provision/roles/webdevops-php/tasks/bootstrap.yml b/docker/php/centos-7-php56/conf/provision/roles/webdevops-php/tasks/bootstrap.yml index 5883fa1fe..99a2e5191 100644 --- a/docker/php/centos-7-php56/conf/provision/roles/webdevops-php/tasks/bootstrap.yml +++ b/docker/php/centos-7-php56/conf/provision/roles/webdevops-php/tasks/bootstrap.yml @@ -1,6 +1,10 @@ --- +- include: bootstrap/init.yml - include: bootstrap/php.yml +- include: bootstrap/php.debian.yml +- include: bootstrap/php.redhat.yml +- include: bootstrap/php.alpine.yml - include: bootstrap/php-fpm.main.yml - include: bootstrap/php-fpm.pool.yml - include: bootstrap/php-fpm.yml diff --git a/docker/php/centos-7-php56/conf/provision/roles/webdevops-php/tasks/bootstrap/init.yml b/docker/php/centos-7-php56/conf/provision/roles/webdevops-php/tasks/bootstrap/init.yml new file mode 100644 index 000000000..a48bec675 --- /dev/null +++ b/docker/php/centos-7-php56/conf/provision/roles/webdevops-php/tasks/bootstrap/init.yml @@ -0,0 +1,71 @@ +--- + +- name: Get php version + command: "php -r 'echo phpversion();'" + changed_when: true + register: php_version_cmd + ignore_errors: true + +- name: Set php_version version + set_fact: + php_version: "{{php_version_cmd.stdout}}" + +############################# +# PHP 5.x +############################# + +- name: Set php main file (RedHat, PHP 5.x) + set_fact: + php_main_conf: /etc/php-fpm.conf + php_pool_conf: www.conf + php_pool_dir: /etc/php-fpm.d + php_fpm_bin: /usr/sbin/php-fpm + when: ansible_os_family == 'RedHat' and ( php_version | version_compare('7.0.0', '<') ) + +- name: Set php main file (Debian, PHP 5.x) + set_fact: + php_etc_dir: /etc/php5 + php_main_conf: /etc/php5/fpm/php-fpm.conf + php_pool_conf: www.conf + php_pool_dir: /etc/php5/fpm/pool.d + php_fpm_bin: /usr/sbin/php5-fpm + when: ansible_os_family == 'Debian' and ( php_version | version_compare('7.0.0', '<') ) + +- name: Set php main file (Alpine, PHP 5.x) + set_fact: + php_etc_dir: /etc/php5 + php_main_conf: /etc/php5/php-fpm.conf + php_pool_conf: www.conf + php_pool_dir: /etc/php5/fpm.d + php_fpm_bin: /usr/bin/php-fpm5 + when: ansible_os_family == 'Alpine' and ( php_version | version_compare('7.0.0', '<') ) + +############################# +# PHP 7.x +############################# + +- name: Set php main file (RedHat, PHP 7.x) + set_fact: + php_main_conf: /etc/php-fpm.conf + php_pool_conf: www.conf + php_pool_dir: /etc/php-fpm.d + php_fpm_bin: /usr/sbin/php-fpm + when: ansible_os_family == 'RedHat' and ( php_version | version_compare('7.0.0', '>=') ) and ( php_version | version_compare('8.0.0', '<') ) + +- name: Set php main file (Debian, PHP 7.x) + set_fact: + php_etc_dir: /etc/php/7.0 + php_main_conf: /etc/php/7.0/fpm/php-fpm.conf + php_pool_conf: www.conf + php_pool_dir: /etc/php/7.0/fpm/pool.d + php_fpm_bin: /usr/sbin/php-fpm7.0 + when: ansible_os_family == 'Debian' and ( php_version | version_compare('7.0.0', '>=') ) and ( php_version | version_compare('8.0.0', '<') ) + +- name: Set php main file (Alpine, PHP 7.x) + set_fact: + php_etc_dir: /etc/php7 + php_main_conf: /etc/php7/php-fpm.conf + php_pool_conf: www.conf + php_pool_dir: /etc/php7/php-fpm.d + php_fpm_bin: /usr/sbin/php-fpm7 + when: ansible_os_family == 'Alpine' and ( php_version | version_compare('7.0.0', '>=') ) and ( php_version | version_compare('8.0.0', '<') ) diff --git a/docker/php/centos-7-php56/conf/provision/roles/webdevops-php/tasks/bootstrap/php-fpm.main.yml b/docker/php/centos-7-php56/conf/provision/roles/webdevops-php/tasks/bootstrap/php-fpm.main.yml index 1a2c7861f..c149d8728 100644 --- a/docker/php/centos-7-php56/conf/provision/roles/webdevops-php/tasks/bootstrap/php-fpm.main.yml +++ b/docker/php/centos-7-php56/conf/provision/roles/webdevops-php/tasks/bootstrap/php-fpm.main.yml @@ -1,19 +1,14 @@ --- -- name: Set php main file - set_fact: - php_main_conf: /etc/php-fpm.conf - when: ansible_os_family == 'RedHat' - -- name: Set php main file - set_fact: - php_main_conf: /etc/php5/fpm/php-fpm.conf - when: ansible_os_family == 'Debian' - -- name: Set php main file - set_fact: - php_main_conf: /etc/php5/php-fpm.conf - when: ansible_os_family == 'Alpine' +- name: Create php directories + file: + path: "{{ item }}" + state: directory + mode: 0755 + owner: "root" + group: "root" + with_items: + - /opt/docker/etc/php/fpm/ - name: Move php-fpm main file to /opt/docker/etc/php/fpm/ command: "mv {{ php_main_conf }} /opt/docker/etc/php/fpm/php-fpm.conf" @@ -33,12 +28,22 @@ owner: "root" group: "root" -- name: Configure php-fpm main +- name: Configure php-fpm main (all versions) lineinfile: dest: '/opt/docker/etc/php/fpm/php-fpm.conf' regexp: '^[\s;]*{{ item.key }}[\s]*=' line: '{{ item.key }} = {{ item.value }}' + insertafter: '\[global\]' with_items: - - { key: 'error_log', value: "syslog" } + - { key: 'error_log', value: "/docker.stderr" } - { key: 'pid', value: "/var/run/php-fpm.pid" } + +- name: Configure php-fpm main (php 5.x) + lineinfile: + dest: '/opt/docker/etc/php/fpm/php-fpm.conf' + regexp: '^[\s;]*{{ item.key }}[\s]*=' + line: '{{ item.key }} = {{ item.value }}' + insertbefore: '[\s]*include[\s]*=' + with_items: - { key: 'daemonize', value: 'no' } + when: ( php_version | version_compare('7.0.0', '<') ) diff --git a/docker/php/centos-7-php56/conf/provision/roles/webdevops-php/tasks/bootstrap/php-fpm.pool.yml b/docker/php/centos-7-php56/conf/provision/roles/webdevops-php/tasks/bootstrap/php-fpm.pool.yml index 53ee9dfe1..ab0b7b02c 100644 --- a/docker/php/centos-7-php56/conf/provision/roles/webdevops-php/tasks/bootstrap/php-fpm.pool.yml +++ b/docker/php/centos-7-php56/conf/provision/roles/webdevops-php/tasks/bootstrap/php-fpm.pool.yml @@ -1,18 +1,5 @@ --- -- name: Get php version - command: "php -r 'echo phpversion();'" - changed_when: true - register: php_version_cmd - ignore_errors: true - -- name: Set php_version version - set_fact: - php_version: "{{php_version_cmd.stdout}}" - -- debug: - msg: "PHP-Version: {{php_version}}" - - set_fact: php_clear_env_available: False @@ -22,23 +9,10 @@ ( php_version | version_compare('5.5', 'eq') and php_version | version_compare('5.5.11', 'ge') ) or ( php_version | version_compare('5.6', 'ge') ) -- name: Set php pool file - set_fact: - php_pool_conf: www.conf - php_pool_dir: /etc/php-fpm.d - when: ansible_os_family == 'RedHat' - -- name: Set php pool file - set_fact: - php_pool_conf: www.conf - php_pool_dir: /etc/php5/fpm/pool.d - when: ansible_os_family == 'Debian' - -- name: Set php pool file - set_fact: - php_pool_conf: www.conf - php_pool_dir: /etc/php5/fpm.d - when: ansible_os_family == 'Alpine' +- name: Create /opt/docker/etc/php/fpm directory + file: + path: "/opt/docker/etc/php/fpm" + state: directory - name: Move php-fpm pool directory file to /opt/docker/etc/php/ command: "mv {{ php_pool_dir }} /opt/docker/etc/php/fpm/pool.d" @@ -55,7 +29,7 @@ path: "{{ php_pool_dir }}" state: absent -- name: Symlink php-fpm main file +- name: Symlink php-fpm pool file file: path: "{{ php_pool_dir }}" src: "/opt/docker/etc/php/fpm/pool.d" @@ -69,15 +43,25 @@ regexp: '^[\s;]*{{ item.key }}[\s]*=' line: '{{ item.key }} = {{ item.value }}' with_items: - - { key: 'listen', value: "0.0.0.0:9000" } + - { key: 'listen', value: "[::]:9000" } - { key: 'catch_workers_output', value: "yes" } - { key: 'access.format', value: '[php-fpm:access] %R - %u %t "%m %r%Q%q" %s %f %{mili}d %{kilo}M %C%%' } + - { key: 'access.log', value: "/docker.stdout" } - { key: 'slowlog', value: "/docker.stderr" } - { key: 'php_admin_value[error_log]', value: "/docker.stderr" } - { key: 'php_admin_value[log_errors]', value: "on" } - { key: 'user', value: "{{ APPLICATION_USER }}" } - { key: 'group', value: "{{ APPLICATION_GROUP }}" } +- name: Configure php-fpm pool user (application.conf) + lineinfile: + dest: '/opt/docker/etc/php/fpm/pool.d/application.conf' + regexp: '^[\s;]*{{ item.key }}[\s]*=' + line: '{{ item.key }} = {{ item.value }}' + with_items: + - { key: 'listen', value: "0.0.0.0:9000" } + when: php_version | version_compare('5.5.99', '<=') + - name: Configure php-fpm pool user (application.conf) lineinfile: dest: '/opt/docker/etc/php/fpm/pool.d/application.conf' diff --git a/docker/php/centos-7-php56/conf/provision/roles/webdevops-php/tasks/bootstrap/php-fpm.yml b/docker/php/centos-7-php56/conf/provision/roles/webdevops-php/tasks/bootstrap/php-fpm.yml index d83edb3ae..41c1b33dc 100644 --- a/docker/php/centos-7-php56/conf/provision/roles/webdevops-php/tasks/bootstrap/php-fpm.yml +++ b/docker/php/centos-7-php56/conf/provision/roles/webdevops-php/tasks/bootstrap/php-fpm.yml @@ -1,45 +1,9 @@ --- -- name: Symlink php-fpm binary [Alpine family] +- name: Symlink php-fpm binary file: - path: "/usr/sbin/php-fpm" - src: "/usr/bin/php-fpm" + path: "/usr/local/bin/php-fpm" + src: "{{ php_fpm_bin }}" state: link owner: "root" group: "root" - when: ansible_os_family == 'Alpine' - -- name: Symlink php-fpm binary [Debian family] - file: - path: "/usr/sbin/php-fpm" - src: "/usr/sbin/php5-fpm" - state: link - owner: "root" - group: "root" - when: ansible_os_family == 'Debian' - -- name: Remove default php-fpm logrotate - file: - path: "/etc/logrotate.d/php-fpm" - state: absent - when: ansible_os_family == 'RedHat' - -- name: Create php-fpm log directory - file: - path: "/var/log/php5-fpm/" - state: directory - owner: "root" - group: "root" - -- name: Create php-fpm log files - file: - path: "/var/log/php5-fpm/{{ item }}" - state: touch - owner: "root" - group: "root" - mode: 0600 - with_items: - - slow.log - - access.log - - error.log - - fpm.log diff --git a/docker/php/centos-7-php56/conf/provision/roles/webdevops-php/tasks/bootstrap/php.alpine.yml b/docker/php/centos-7-php56/conf/provision/roles/webdevops-php/tasks/bootstrap/php.alpine.yml new file mode 100644 index 000000000..4c16cdf0d --- /dev/null +++ b/docker/php/centos-7-php56/conf/provision/roles/webdevops-php/tasks/bootstrap/php.alpine.yml @@ -0,0 +1,12 @@ +--- + +- name: Create link for additional php.ini [Alpine family] + file: + src: '/opt/docker/etc/php/{{ item.file }}' + dest: '{{ php_etc_dir }}/conf.d/{{ item.target }}' + state: link + force: yes + with_items: + - { file: 'php.webdevops.ini', target: 'xzza-webdevops.ini'} + - { file: 'php.ini', target: 'xzzz-docker.ini'} + when: ansible_os_family == 'Alpine' diff --git a/docker/php/centos-7-php56/conf/provision/roles/webdevops-php/tasks/bootstrap/php.debian.yml b/docker/php/centos-7-php56/conf/provision/roles/webdevops-php/tasks/bootstrap/php.debian.yml new file mode 100644 index 000000000..d27037e33 --- /dev/null +++ b/docker/php/centos-7-php56/conf/provision/roles/webdevops-php/tasks/bootstrap/php.debian.yml @@ -0,0 +1,18 @@ +--- + +- name: Link php.ini for cli and fpm [Debian family] + file: + src: '{{ item.file }}' + dest: '{{ php_etc_dir }}/{{ item.category }}/conf.d/{{ item.target }}' + force: yes + state: link + with_items: + # PHP cli + - { category: 'cli', file: '{{ php_etc_dir }}/mods-available/mcrypt.ini', target: '20-mcrypt.ini' } + - { category: 'cli', file: '/opt/docker/etc/php/php.webdevops.ini', target: '98-webdevops.ini' } + - { category: 'cli', file: '/opt/docker/etc/php/php.ini', target: '99-docker.ini' } + # PHP fpm + - { category: 'fpm', file: '{{ php_etc_dir }}/mods-available/mcrypt.ini', target: '20-mcrypt.ini' } + - { category: 'fpm', file: '/opt/docker/etc/php/php.webdevops.ini', target: '98-webdevops.ini' } + - { category: 'fpm', file: '/opt/docker/etc/php/php.ini', target: '99-docker.ini' } + when: ansible_os_family == 'Debian' diff --git a/docker/php/centos-7-php56/conf/provision/roles/webdevops-php/tasks/bootstrap/php.redhat.yml b/docker/php/centos-7-php56/conf/provision/roles/webdevops-php/tasks/bootstrap/php.redhat.yml new file mode 100644 index 000000000..7e8810231 --- /dev/null +++ b/docker/php/centos-7-php56/conf/provision/roles/webdevops-php/tasks/bootstrap/php.redhat.yml @@ -0,0 +1,12 @@ +--- + +- name: Create link for additional php.ini [RedHat family] + file: + src: '/opt/docker/etc/php/{{ item.file }}' + dest: '/etc/php.d/{{ item.target }}' + state: link + force: yes + with_items: + - { file: 'php.webdevops.ini', target: 'zza-webdevops.ini'} + - { file: 'php.ini', target: 'zzz-docker.ini'} + when: ansible_os_family == 'RedHat' diff --git a/docker/php/centos-7-php56/conf/provision/roles/webdevops-php/tasks/bootstrap/php.yml b/docker/php/centos-7-php56/conf/provision/roles/webdevops-php/tasks/bootstrap/php.yml index 9816b2538..caac8f413 100644 --- a/docker/php/centos-7-php56/conf/provision/roles/webdevops-php/tasks/bootstrap/php.yml +++ b/docker/php/centos-7-php56/conf/provision/roles/webdevops-php/tasks/bootstrap/php.yml @@ -21,42 +21,3 @@ with_items: - "/opt/docker/etc/php/php.webdevops.ini" - "/opt/docker/etc/php/php.ini" - -- name: Link php.ini for cli and fpm [Debian family] - file: - src: '{{ item.file }}' - dest: '/etc/php5/{{ item.category }}/conf.d/{{ item.target }}' - force: yes - state: link - with_items: - # PHP cli - - { category: 'cli', file: '/etc/php5/mods-available/mcrypt.ini', target: '20-mcrypt.ini' } - - { category: 'cli', file: '/opt/docker/etc/php/php.webdevops.ini', target: '98-webdevops.ini' } - - { category: 'cli', file: '/opt/docker/etc/php/php.ini', target: '99-docker.ini' } - # PHP fpm - - { category: 'fpm', file: '/etc/php5/mods-available/mcrypt.ini', target: '20-mcrypt.ini' } - - { category: 'fpm', file: '/opt/docker/etc/php/php.webdevops.ini', target: '98-webdevops.ini' } - - { category: 'fpm', file: '/opt/docker/etc/php/php.ini', target: '99-docker.ini' } - when: ansible_os_family == 'Debian' - -- name: Create link for additional php.ini [RedHat family] - file: - src: '/opt/docker/etc/php/{{ item.file }}' - dest: '/etc/php.d/{{ item.target }}' - state: link - force: yes - with_items: - - { file: 'php.webdevops.ini', target: 'zza-webdevops.ini'} - - { file: 'php.ini', target: 'zzz-docker.ini'} - when: ansible_os_family == 'RedHat' - -- name: Create link for additional php.ini [Alpine family] - file: - src: '/opt/docker/etc/php/{{ item.file }}' - dest: '/etc/php5/conf.d/{{ item.target }}' - state: link - force: yes - with_items: - - { file: 'php.webdevops.ini', target: 'xzza-webdevops.ini'} - - { file: 'php.ini', target: 'xzzz-docker.ini'} - when: ansible_os_family == 'Alpine' diff --git a/docker/php/centos-7-php7/Dockerfile b/docker/php/centos-7-php7/Dockerfile index 6b8cde054..2ea44b4cc 100644 --- a/docker/php/centos-7-php7/Dockerfile +++ b/docker/php/centos-7-php7/Dockerfile @@ -5,14 +5,9 @@ FROM webdevops/base-app:centos-7 -MAINTAINER info@webdevops.io -LABEL vendor=WebDevOps.io -LABEL io.webdevops.layout=8 -LABEL io.webdevops.version=1.5.0 - -ENV WEB_DOCUMENT_ROOT /app -ENV WEB_DOCUMENT_INDEX index.php -ENV WEB_ALIAS_DOMAIN *.vm +ENV WEB_DOCUMENT_ROOT=/app \ + WEB_DOCUMENT_INDEX=index.php \ + WEB_ALIAS_DOMAIN=*.vm COPY conf/ /opt/docker/ @@ -60,8 +55,10 @@ RUN rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm \ && rm -rf /tmp/* \ && echo "extension=redis.so" > /etc/php.d/redis.ini \ && yum remove -y ImageMagick-devel php70w-devel gcc make \ + # Enable php services + && docker-service-enable syslog cron \ && /opt/docker/bin/provision run --tag bootstrap --role webdevops-php \ - && /opt/docker/bin/bootstrap.sh - + && /opt/docker/bin/bootstrap.sh \ + && docker-image-cleanup EXPOSE 9000 diff --git a/docker/php/centos-7-php7/Dockerfile.jinja2 b/docker/php/centos-7-php7/Dockerfile.jinja2 index 64ee19053..1f9d630b0 100644 --- a/docker/php/centos-7-php7/Dockerfile.jinja2 +++ b/docker/php/centos-7-php7/Dockerfile.jinja2 @@ -1,7 +1,5 @@ {{ docker.from("base-app", "centos-7") }} -{{ docker.version() }} - {{ environment.web() }} {{ docker.copy('conf/', '/opt/docker/') }} diff --git a/docker/php/centos-7-php7/conf/bin/service.d/php-fpm.d/11-clear-env.sh b/docker/php/centos-7-php7/conf/bin/service.d/php-fpm.d/11-clear-env.sh index b17280ce6..ef6fd4016 100644 --- a/docker/php/centos-7-php7/conf/bin/service.d/php-fpm.d/11-clear-env.sh +++ b/docker/php/centos-7-php7/conf/bin/service.d/php-fpm.d/11-clear-env.sh @@ -30,5 +30,9 @@ for envVariable in $(printenv|cut -f1 -d=); do done # Replace ;#CLEAR_ENV_WORKAROUND# with environment variable list for all php-fpm pool files -find /opt/docker/etc/php/fpm/pool.d/ -iname '*.conf' -print0 | xargs -0 -r rpl --quiet ";#CLEAR_ENV_WORKAROUND#" "$VARIABLE_LIST" > /dev/null +go-replace \ + -s ";#CLEAR_ENV_WORKAROUND#" -r "$VARIABLE_LIST" \ + --path=/opt/docker/etc/php/fpm/pool.d/ \ + --path-pattern='*.conf' \ + --ignore-empty diff --git a/docker/php/centos-7-php7/conf/bin/service.d/php-fpm.sh b/docker/php/centos-7-php7/conf/bin/service.d/php-fpm.sh index 571f248d2..b25983bd3 100644 --- a/docker/php/centos-7-php7/conf/bin/service.d/php-fpm.sh +++ b/docker/php/centos-7-php7/conf/bin/service.d/php-fpm.sh @@ -4,4 +4,4 @@ source /opt/docker/bin/config.sh includeScriptDir "/opt/docker/bin/service.d/php-fpm.d/" -exec /usr/sbin/php-fpm --nodaemonize +exec /usr/local/bin/php-fpm --nodaemonize diff --git a/docker/php/centos-7-php7/conf/etc/logrotate.d/php7-fpm b/docker/php/centos-7-php7/conf/etc/logrotate.d/php7-fpm deleted file mode 100644 index 668f2545f..000000000 --- a/docker/php/centos-7-php7/conf/etc/logrotate.d/php7-fpm +++ /dev/null @@ -1,12 +0,0 @@ -/var/log/php7-fpm/fpm.log -/var/log/php7-fpm/access.log -/var/log/php7-fpm/slow.log -/var/log/php7-fpm/error.log { - missingok - notifempty - sharedscripts - delaycompress - postrotate - /bin/kill -SIGUSR1 `cat /var/run/php7-fpm.pid` 2>/dev/null || true - endscript -} diff --git a/docker/php/centos-7-php7/conf/etc/php/php.webdevops.ini b/docker/php/centos-7-php7/conf/etc/php/php.webdevops.ini index 562b8d7e2..aa1545ab8 100644 --- a/docker/php/centos-7-php7/conf/etc/php/php.webdevops.ini +++ b/docker/php/centos-7-php7/conf/etc/php/php.webdevops.ini @@ -5,6 +5,7 @@ ; this file will overwrite default php.ini settings display_errors = 0 +log_errors = 1 short_open_tag = Off variables_order = 'GPCS' diff --git a/docker/php/centos-7-php7/conf/provision/roles/webdevops-php/tasks/bootstrap.yml b/docker/php/centos-7-php7/conf/provision/roles/webdevops-php/tasks/bootstrap.yml index 5883fa1fe..99a2e5191 100644 --- a/docker/php/centos-7-php7/conf/provision/roles/webdevops-php/tasks/bootstrap.yml +++ b/docker/php/centos-7-php7/conf/provision/roles/webdevops-php/tasks/bootstrap.yml @@ -1,6 +1,10 @@ --- +- include: bootstrap/init.yml - include: bootstrap/php.yml +- include: bootstrap/php.debian.yml +- include: bootstrap/php.redhat.yml +- include: bootstrap/php.alpine.yml - include: bootstrap/php-fpm.main.yml - include: bootstrap/php-fpm.pool.yml - include: bootstrap/php-fpm.yml diff --git a/docker/php/centos-7-php7/conf/provision/roles/webdevops-php/tasks/bootstrap/init.yml b/docker/php/centos-7-php7/conf/provision/roles/webdevops-php/tasks/bootstrap/init.yml new file mode 100644 index 000000000..a48bec675 --- /dev/null +++ b/docker/php/centos-7-php7/conf/provision/roles/webdevops-php/tasks/bootstrap/init.yml @@ -0,0 +1,71 @@ +--- + +- name: Get php version + command: "php -r 'echo phpversion();'" + changed_when: true + register: php_version_cmd + ignore_errors: true + +- name: Set php_version version + set_fact: + php_version: "{{php_version_cmd.stdout}}" + +############################# +# PHP 5.x +############################# + +- name: Set php main file (RedHat, PHP 5.x) + set_fact: + php_main_conf: /etc/php-fpm.conf + php_pool_conf: www.conf + php_pool_dir: /etc/php-fpm.d + php_fpm_bin: /usr/sbin/php-fpm + when: ansible_os_family == 'RedHat' and ( php_version | version_compare('7.0.0', '<') ) + +- name: Set php main file (Debian, PHP 5.x) + set_fact: + php_etc_dir: /etc/php5 + php_main_conf: /etc/php5/fpm/php-fpm.conf + php_pool_conf: www.conf + php_pool_dir: /etc/php5/fpm/pool.d + php_fpm_bin: /usr/sbin/php5-fpm + when: ansible_os_family == 'Debian' and ( php_version | version_compare('7.0.0', '<') ) + +- name: Set php main file (Alpine, PHP 5.x) + set_fact: + php_etc_dir: /etc/php5 + php_main_conf: /etc/php5/php-fpm.conf + php_pool_conf: www.conf + php_pool_dir: /etc/php5/fpm.d + php_fpm_bin: /usr/bin/php-fpm5 + when: ansible_os_family == 'Alpine' and ( php_version | version_compare('7.0.0', '<') ) + +############################# +# PHP 7.x +############################# + +- name: Set php main file (RedHat, PHP 7.x) + set_fact: + php_main_conf: /etc/php-fpm.conf + php_pool_conf: www.conf + php_pool_dir: /etc/php-fpm.d + php_fpm_bin: /usr/sbin/php-fpm + when: ansible_os_family == 'RedHat' and ( php_version | version_compare('7.0.0', '>=') ) and ( php_version | version_compare('8.0.0', '<') ) + +- name: Set php main file (Debian, PHP 7.x) + set_fact: + php_etc_dir: /etc/php/7.0 + php_main_conf: /etc/php/7.0/fpm/php-fpm.conf + php_pool_conf: www.conf + php_pool_dir: /etc/php/7.0/fpm/pool.d + php_fpm_bin: /usr/sbin/php-fpm7.0 + when: ansible_os_family == 'Debian' and ( php_version | version_compare('7.0.0', '>=') ) and ( php_version | version_compare('8.0.0', '<') ) + +- name: Set php main file (Alpine, PHP 7.x) + set_fact: + php_etc_dir: /etc/php7 + php_main_conf: /etc/php7/php-fpm.conf + php_pool_conf: www.conf + php_pool_dir: /etc/php7/php-fpm.d + php_fpm_bin: /usr/sbin/php-fpm7 + when: ansible_os_family == 'Alpine' and ( php_version | version_compare('7.0.0', '>=') ) and ( php_version | version_compare('8.0.0', '<') ) diff --git a/docker/php/centos-7-php7/conf/provision/roles/webdevops-php/tasks/bootstrap/php-fpm.main.yml b/docker/php/centos-7-php7/conf/provision/roles/webdevops-php/tasks/bootstrap/php-fpm.main.yml index 36143a96f..c149d8728 100644 --- a/docker/php/centos-7-php7/conf/provision/roles/webdevops-php/tasks/bootstrap/php-fpm.main.yml +++ b/docker/php/centos-7-php7/conf/provision/roles/webdevops-php/tasks/bootstrap/php-fpm.main.yml @@ -1,20 +1,5 @@ --- -- name: Set php main file - set_fact: - php_main_conf: /etc/php-fpm.conf - when: ansible_os_family == 'RedHat' - -- name: Set php main file - set_fact: - php_main_conf: /etc/php/7.0/fpm/php-fpm.conf - when: ansible_os_family == 'Debian' - -- name: Set php main file - set_fact: - php_main_conf: /etc/php7/php-fpm.conf - when: ansible_os_family == 'Alpine' - - name: Create php directories file: path: "{{ item }}" @@ -43,11 +28,22 @@ owner: "root" group: "root" -- name: Configure php-fpm main +- name: Configure php-fpm main (all versions) + lineinfile: + dest: '/opt/docker/etc/php/fpm/php-fpm.conf' + regexp: '^[\s;]*{{ item.key }}[\s]*=' + line: '{{ item.key }} = {{ item.value }}' + insertafter: '\[global\]' + with_items: + - { key: 'error_log', value: "/docker.stderr" } + - { key: 'pid', value: "/var/run/php-fpm.pid" } + +- name: Configure php-fpm main (php 5.x) lineinfile: dest: '/opt/docker/etc/php/fpm/php-fpm.conf' regexp: '^[\s;]*{{ item.key }}[\s]*=' line: '{{ item.key }} = {{ item.value }}' + insertbefore: '[\s]*include[\s]*=' with_items: - - { key: 'error_log', value: "syslog" } - - { key: 'pid', value: "/var/run/php-fpm.pid" } + - { key: 'daemonize', value: 'no' } + when: ( php_version | version_compare('7.0.0', '<') ) diff --git a/docker/php/centos-7-php7/conf/provision/roles/webdevops-php/tasks/bootstrap/php-fpm.pool.yml b/docker/php/centos-7-php7/conf/provision/roles/webdevops-php/tasks/bootstrap/php-fpm.pool.yml index d91ecab7f..ab0b7b02c 100644 --- a/docker/php/centos-7-php7/conf/provision/roles/webdevops-php/tasks/bootstrap/php-fpm.pool.yml +++ b/docker/php/centos-7-php7/conf/provision/roles/webdevops-php/tasks/bootstrap/php-fpm.pool.yml @@ -1,44 +1,18 @@ --- -- name: Get php version - command: "php -r 'echo phpversion();'" - changed_when: true - register: php_version_cmd - ignore_errors: true -- name: Set php_version version - set_fact: - php_version: "{{php_version_cmd.stdout}}" +- set_fact: + php_clear_env_available: False -- debug: - msg: "PHP-Version: {{php_version}}" +- set_fact: + php_clear_env_available: True + when: ( php_version | version_compare('5.4', 'eq') and php_version | version_compare('5.4.27', 'ge') ) or + ( php_version | version_compare('5.5', 'eq') and php_version | version_compare('5.5.11', 'ge') ) or + ( php_version | version_compare('5.6', 'ge') ) -- name: Set php pool file - set_fact: - php_pool_conf: www.conf - php_pool_dir: /etc/php-fpm.d - when: ansible_os_family == 'RedHat' - -- name: Set php pool file - set_fact: - php_pool_conf: www.conf - php_pool_dir: /etc/php/7.0/fpm/pool.d - when: ansible_os_family == 'Debian' - -- name: Set php pool file - set_fact: - php_pool_conf: www.conf - php_pool_dir: /etc/php7/php-fpm.d - when: ansible_os_family == 'Alpine' - -- name: Create php directories +- name: Create /opt/docker/etc/php/fpm directory file: - path: "{{ item }}" + path: "/opt/docker/etc/php/fpm" state: directory - mode: 0755 - owner: "root" - group: "root" - with_items: - - /opt/docker/etc/php/fpm/ - name: Move php-fpm pool directory file to /opt/docker/etc/php/ command: "mv {{ php_pool_dir }} /opt/docker/etc/php/fpm/pool.d" @@ -55,7 +29,7 @@ path: "{{ php_pool_dir }}" state: absent -- name: Symlink php-fpm main file +- name: Symlink php-fpm pool file file: path: "{{ php_pool_dir }}" src: "/opt/docker/etc/php/fpm/pool.d" @@ -63,24 +37,60 @@ owner: "root" group: "root" - -- name: Configure php-fpm pool user (www.conf) +- name: Configure php-fpm pool user (application.conf) lineinfile: dest: '/opt/docker/etc/php/fpm/pool.d/application.conf' regexp: '^[\s;]*{{ item.key }}[\s]*=' line: '{{ item.key }} = {{ item.value }}' with_items: - - { key: 'listen', value: "0.0.0.0:9000" } + - { key: 'listen', value: "[::]:9000" } - { key: 'catch_workers_output', value: "yes" } - { key: 'access.format', value: '[php-fpm:access] %R - %u %t "%m %r%Q%q" %s %f %{mili}d %{kilo}M %C%%' } - { key: 'access.log', value: "/docker.stdout" } - { key: 'slowlog', value: "/docker.stderr" } - { key: 'php_admin_value[error_log]', value: "/docker.stderr" } - { key: 'php_admin_value[log_errors]', value: "on" } - - { key: 'clear_env', value: "no" } - { key: 'user', value: "{{ APPLICATION_USER }}" } - { key: 'group', value: "{{ APPLICATION_GROUP }}" } +- name: Configure php-fpm pool user (application.conf) + lineinfile: + dest: '/opt/docker/etc/php/fpm/pool.d/application.conf' + regexp: '^[\s;]*{{ item.key }}[\s]*=' + line: '{{ item.key }} = {{ item.value }}' + with_items: + - { key: 'listen', value: "0.0.0.0:9000" } + when: php_version | version_compare('5.5.99', '<=') + +- name: Configure php-fpm pool user (application.conf) + lineinfile: + dest: '/opt/docker/etc/php/fpm/pool.d/application.conf' + regexp: '^[\s;]*{{ item.key }}[\s]*=' + line: ';{{ item.key }} = {{ item.value }}' + with_items: + - { key: 'access.log', value: "/docker.stdout" } + +- name: Disable clear env in php-fpm pool + lineinfile: + dest: '/opt/docker/etc/php/fpm/pool.d/application.conf' + regexp: '^[\s;]*{{ item.key }}[\s]*=' + line: '{{ item.key }} = {{ item.value }}' + with_items: + - { key: 'clear_env', value: "no" } + when: php_clear_env_available == True + +- name: Remove clear env workaround + file: + path: "/opt/docker/bin/service.d/php-fpm.d/11-clear-env.sh" + state: absent + when: php_clear_env_available == True + +- name: Append clear env workaround in php-fpm pool (old php-fpm versions) + lineinfile: + dest: '/opt/docker/etc/php/fpm/pool.d/application.conf' + line: ';#CLEAR_ENV_WORKAROUND#' + when: php_clear_env_available == False + - name: Disable php-fpm connection limit lineinfile: dest: '/opt/docker/etc/php/fpm/pool.d/application.conf' diff --git a/docker/php/centos-7-php7/conf/provision/roles/webdevops-php/tasks/bootstrap/php-fpm.yml b/docker/php/centos-7-php7/conf/provision/roles/webdevops-php/tasks/bootstrap/php-fpm.yml index 130542f53..41c1b33dc 100644 --- a/docker/php/centos-7-php7/conf/provision/roles/webdevops-php/tasks/bootstrap/php-fpm.yml +++ b/docker/php/centos-7-php7/conf/provision/roles/webdevops-php/tasks/bootstrap/php-fpm.yml @@ -1,54 +1,9 @@ --- -- name: Symlink php-fpm binary [RedHat family] +- name: Symlink php-fpm binary file: - path: "/usr/sbin/php-fpm7.0" - src: "/usr/sbin/php-fpm" + path: "/usr/local/bin/php-fpm" + src: "{{ php_fpm_bin }}" state: link owner: "root" group: "root" - when: ansible_os_family == 'RedHat' - -- name: Symlink php-fpm binary [Alpine family] - file: - path: "/usr/sbin/php-fpm" - src: "/usr/sbin/php-fpm7" - state: link - owner: "root" - group: "root" - when: ansible_os_family == 'Alpine' - -- name: Symlink php-fpm binary [Debian family] - file: - path: "/usr/sbin/php-fpm" - src: "/usr/sbin/php-fpm7.0" - state: link - owner: "root" - group: "root" - when: ansible_os_family == 'Debian' - -- name: Remove default php-fpm logrotate - file: - path: "/etc/logrotate.d/php-fpm" - state: absent - when: ansible_os_family == 'RedHat' - -- name: Create php-fpm log directory - file: - path: "/var/log/php7-fpm/" - state: directory - owner: "root" - group: "root" - -- name: Create php-fpm log files - file: - path: "/var/log/php7-fpm/{{ item }}" - state: touch - owner: "root" - group: "root" - mode: 0600 - with_items: - - slow.log - - access.log - - error.log - - fpm.log diff --git a/docker/php/centos-7-php7/conf/provision/roles/webdevops-php/tasks/bootstrap/php.alpine.yml b/docker/php/centos-7-php7/conf/provision/roles/webdevops-php/tasks/bootstrap/php.alpine.yml new file mode 100644 index 000000000..4c16cdf0d --- /dev/null +++ b/docker/php/centos-7-php7/conf/provision/roles/webdevops-php/tasks/bootstrap/php.alpine.yml @@ -0,0 +1,12 @@ +--- + +- name: Create link for additional php.ini [Alpine family] + file: + src: '/opt/docker/etc/php/{{ item.file }}' + dest: '{{ php_etc_dir }}/conf.d/{{ item.target }}' + state: link + force: yes + with_items: + - { file: 'php.webdevops.ini', target: 'xzza-webdevops.ini'} + - { file: 'php.ini', target: 'xzzz-docker.ini'} + when: ansible_os_family == 'Alpine' diff --git a/docker/php/centos-7-php7/conf/provision/roles/webdevops-php/tasks/bootstrap/php.debian.yml b/docker/php/centos-7-php7/conf/provision/roles/webdevops-php/tasks/bootstrap/php.debian.yml new file mode 100644 index 000000000..d27037e33 --- /dev/null +++ b/docker/php/centos-7-php7/conf/provision/roles/webdevops-php/tasks/bootstrap/php.debian.yml @@ -0,0 +1,18 @@ +--- + +- name: Link php.ini for cli and fpm [Debian family] + file: + src: '{{ item.file }}' + dest: '{{ php_etc_dir }}/{{ item.category }}/conf.d/{{ item.target }}' + force: yes + state: link + with_items: + # PHP cli + - { category: 'cli', file: '{{ php_etc_dir }}/mods-available/mcrypt.ini', target: '20-mcrypt.ini' } + - { category: 'cli', file: '/opt/docker/etc/php/php.webdevops.ini', target: '98-webdevops.ini' } + - { category: 'cli', file: '/opt/docker/etc/php/php.ini', target: '99-docker.ini' } + # PHP fpm + - { category: 'fpm', file: '{{ php_etc_dir }}/mods-available/mcrypt.ini', target: '20-mcrypt.ini' } + - { category: 'fpm', file: '/opt/docker/etc/php/php.webdevops.ini', target: '98-webdevops.ini' } + - { category: 'fpm', file: '/opt/docker/etc/php/php.ini', target: '99-docker.ini' } + when: ansible_os_family == 'Debian' diff --git a/docker/php/centos-7-php7/conf/provision/roles/webdevops-php/tasks/bootstrap/php.redhat.yml b/docker/php/centos-7-php7/conf/provision/roles/webdevops-php/tasks/bootstrap/php.redhat.yml new file mode 100644 index 000000000..7e8810231 --- /dev/null +++ b/docker/php/centos-7-php7/conf/provision/roles/webdevops-php/tasks/bootstrap/php.redhat.yml @@ -0,0 +1,12 @@ +--- + +- name: Create link for additional php.ini [RedHat family] + file: + src: '/opt/docker/etc/php/{{ item.file }}' + dest: '/etc/php.d/{{ item.target }}' + state: link + force: yes + with_items: + - { file: 'php.webdevops.ini', target: 'zza-webdevops.ini'} + - { file: 'php.ini', target: 'zzz-docker.ini'} + when: ansible_os_family == 'RedHat' diff --git a/docker/php/centos-7-php7/conf/provision/roles/webdevops-php/tasks/bootstrap/php.yml b/docker/php/centos-7-php7/conf/provision/roles/webdevops-php/tasks/bootstrap/php.yml index 97f02eec3..caac8f413 100644 --- a/docker/php/centos-7-php7/conf/provision/roles/webdevops-php/tasks/bootstrap/php.yml +++ b/docker/php/centos-7-php7/conf/provision/roles/webdevops-php/tasks/bootstrap/php.yml @@ -11,7 +11,7 @@ - /opt/docker/etc/php/ - /opt/docker/etc/php/fpm/ -- name: Create /opt/docker/etc/php/php.ini" +- name: Create php.ini files file: path: "{{ item }}" state: touch @@ -21,40 +21,3 @@ with_items: - "/opt/docker/etc/php/php.webdevops.ini" - "/opt/docker/etc/php/php.ini" - -- name: Link php.ini for cli and fpm - file: - src: '{{ item.file }}' - dest: '/etc/php/7.0/{{ item.category }}/conf.d/{{ item.target }}' - force: yes - state: link - with_items: - # PHP cli - - { category: 'cli', file: '/opt/docker/etc/php/php.webdevops.ini', target: '98-webdevops.ini' } - - { category: 'cli', file: '/opt/docker/etc/php/php.ini', target: '99-docker.ini' } - # PHP fpm - - { category: 'fpm', file: '/opt/docker/etc/php/php.webdevops.ini', target: '98-webdevops.ini' } - - { category: 'fpm', file: '/opt/docker/etc/php/php.ini', target: '99-docker.ini' } - when: ansible_os_family == 'Debian' - -- name: Create link for additional php.ini [RedHat family] - file: - src: '/opt/docker/etc/php/{{ item.file }}' - dest: '/etc/php.d/{{ item.target }}' - state: link - force: yes - with_items: - - { file: 'php.webdevops.ini', target: 'zza-webdevops.ini'} - - { file: 'php.ini', target: 'zzz-docker.ini'} - when: ansible_os_family == 'RedHat' - -- name: Link php.ini - file: - src: '/opt/docker/etc/php/{{ item.file }}' - dest: '/etc/php7/conf.d/{{ item.target }}' - force: yes - state: link - with_items: - - { file: 'php.webdevops.ini', target: 'xzza-webdevops.ini'} - - { file: 'php.ini', target: 'xzzz-docker.ini'} - when: ansible_os_family == 'Alpine' diff --git a/docker/php/centos-7/Dockerfile b/docker/php/centos-7/Dockerfile index a6a12590b..c31b362e0 100644 --- a/docker/php/centos-7/Dockerfile +++ b/docker/php/centos-7/Dockerfile @@ -5,14 +5,9 @@ FROM webdevops/base-app:centos-7 -MAINTAINER info@webdevops.io -LABEL vendor=WebDevOps.io -LABEL io.webdevops.layout=8 -LABEL io.webdevops.version=1.5.0 - -ENV WEB_DOCUMENT_ROOT /app -ENV WEB_DOCUMENT_INDEX index.php -ENV WEB_ALIAS_DOMAIN *.vm +ENV WEB_DOCUMENT_ROOT=/app \ + WEB_DOCUMENT_INDEX=index.php \ + WEB_ALIAS_DOMAIN=*.vm COPY conf/ /opt/docker/ @@ -57,9 +52,10 @@ RUN /usr/local/bin/yum-install \ && curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin/ --filename=composer \ # Cleanup && yum erase -y php-devel gcc \ - && yum clean all \ + # Enable php services + && docker-service-enable syslog cron \ && /opt/docker/bin/provision run --tag bootstrap --role webdevops-php \ - && /opt/docker/bin/bootstrap.sh - + && /opt/docker/bin/bootstrap.sh \ + && docker-image-cleanup EXPOSE 9000 diff --git a/docker/php/centos-7/Dockerfile.jinja2 b/docker/php/centos-7/Dockerfile.jinja2 index ccb3165ee..1f0cb6b72 100644 --- a/docker/php/centos-7/Dockerfile.jinja2 +++ b/docker/php/centos-7/Dockerfile.jinja2 @@ -1,7 +1,5 @@ {{ docker.from("base-app", "centos-7") }} -{{ docker.version() }} - {{ environment.web() }} {{ docker.copy('conf/', '/opt/docker/') }} diff --git a/docker/php/centos-7/conf/bin/service.d/php-fpm.d/11-clear-env.sh b/docker/php/centos-7/conf/bin/service.d/php-fpm.d/11-clear-env.sh index b17280ce6..ef6fd4016 100644 --- a/docker/php/centos-7/conf/bin/service.d/php-fpm.d/11-clear-env.sh +++ b/docker/php/centos-7/conf/bin/service.d/php-fpm.d/11-clear-env.sh @@ -30,5 +30,9 @@ for envVariable in $(printenv|cut -f1 -d=); do done # Replace ;#CLEAR_ENV_WORKAROUND# with environment variable list for all php-fpm pool files -find /opt/docker/etc/php/fpm/pool.d/ -iname '*.conf' -print0 | xargs -0 -r rpl --quiet ";#CLEAR_ENV_WORKAROUND#" "$VARIABLE_LIST" > /dev/null +go-replace \ + -s ";#CLEAR_ENV_WORKAROUND#" -r "$VARIABLE_LIST" \ + --path=/opt/docker/etc/php/fpm/pool.d/ \ + --path-pattern='*.conf' \ + --ignore-empty diff --git a/docker/php/centos-7/conf/bin/service.d/php-fpm.sh b/docker/php/centos-7/conf/bin/service.d/php-fpm.sh index 571f248d2..b25983bd3 100644 --- a/docker/php/centos-7/conf/bin/service.d/php-fpm.sh +++ b/docker/php/centos-7/conf/bin/service.d/php-fpm.sh @@ -4,4 +4,4 @@ source /opt/docker/bin/config.sh includeScriptDir "/opt/docker/bin/service.d/php-fpm.d/" -exec /usr/sbin/php-fpm --nodaemonize +exec /usr/local/bin/php-fpm --nodaemonize diff --git a/docker/php/centos-7/conf/etc/php/php.webdevops.ini b/docker/php/centos-7/conf/etc/php/php.webdevops.ini index 562b8d7e2..aa1545ab8 100644 --- a/docker/php/centos-7/conf/etc/php/php.webdevops.ini +++ b/docker/php/centos-7/conf/etc/php/php.webdevops.ini @@ -5,6 +5,7 @@ ; this file will overwrite default php.ini settings display_errors = 0 +log_errors = 1 short_open_tag = Off variables_order = 'GPCS' diff --git a/docker/php/centos-7/conf/provision/roles/webdevops-php/tasks/bootstrap.yml b/docker/php/centos-7/conf/provision/roles/webdevops-php/tasks/bootstrap.yml index 5883fa1fe..99a2e5191 100644 --- a/docker/php/centos-7/conf/provision/roles/webdevops-php/tasks/bootstrap.yml +++ b/docker/php/centos-7/conf/provision/roles/webdevops-php/tasks/bootstrap.yml @@ -1,6 +1,10 @@ --- +- include: bootstrap/init.yml - include: bootstrap/php.yml +- include: bootstrap/php.debian.yml +- include: bootstrap/php.redhat.yml +- include: bootstrap/php.alpine.yml - include: bootstrap/php-fpm.main.yml - include: bootstrap/php-fpm.pool.yml - include: bootstrap/php-fpm.yml diff --git a/docker/php/centos-7/conf/provision/roles/webdevops-php/tasks/bootstrap/init.yml b/docker/php/centos-7/conf/provision/roles/webdevops-php/tasks/bootstrap/init.yml new file mode 100644 index 000000000..a48bec675 --- /dev/null +++ b/docker/php/centos-7/conf/provision/roles/webdevops-php/tasks/bootstrap/init.yml @@ -0,0 +1,71 @@ +--- + +- name: Get php version + command: "php -r 'echo phpversion();'" + changed_when: true + register: php_version_cmd + ignore_errors: true + +- name: Set php_version version + set_fact: + php_version: "{{php_version_cmd.stdout}}" + +############################# +# PHP 5.x +############################# + +- name: Set php main file (RedHat, PHP 5.x) + set_fact: + php_main_conf: /etc/php-fpm.conf + php_pool_conf: www.conf + php_pool_dir: /etc/php-fpm.d + php_fpm_bin: /usr/sbin/php-fpm + when: ansible_os_family == 'RedHat' and ( php_version | version_compare('7.0.0', '<') ) + +- name: Set php main file (Debian, PHP 5.x) + set_fact: + php_etc_dir: /etc/php5 + php_main_conf: /etc/php5/fpm/php-fpm.conf + php_pool_conf: www.conf + php_pool_dir: /etc/php5/fpm/pool.d + php_fpm_bin: /usr/sbin/php5-fpm + when: ansible_os_family == 'Debian' and ( php_version | version_compare('7.0.0', '<') ) + +- name: Set php main file (Alpine, PHP 5.x) + set_fact: + php_etc_dir: /etc/php5 + php_main_conf: /etc/php5/php-fpm.conf + php_pool_conf: www.conf + php_pool_dir: /etc/php5/fpm.d + php_fpm_bin: /usr/bin/php-fpm5 + when: ansible_os_family == 'Alpine' and ( php_version | version_compare('7.0.0', '<') ) + +############################# +# PHP 7.x +############################# + +- name: Set php main file (RedHat, PHP 7.x) + set_fact: + php_main_conf: /etc/php-fpm.conf + php_pool_conf: www.conf + php_pool_dir: /etc/php-fpm.d + php_fpm_bin: /usr/sbin/php-fpm + when: ansible_os_family == 'RedHat' and ( php_version | version_compare('7.0.0', '>=') ) and ( php_version | version_compare('8.0.0', '<') ) + +- name: Set php main file (Debian, PHP 7.x) + set_fact: + php_etc_dir: /etc/php/7.0 + php_main_conf: /etc/php/7.0/fpm/php-fpm.conf + php_pool_conf: www.conf + php_pool_dir: /etc/php/7.0/fpm/pool.d + php_fpm_bin: /usr/sbin/php-fpm7.0 + when: ansible_os_family == 'Debian' and ( php_version | version_compare('7.0.0', '>=') ) and ( php_version | version_compare('8.0.0', '<') ) + +- name: Set php main file (Alpine, PHP 7.x) + set_fact: + php_etc_dir: /etc/php7 + php_main_conf: /etc/php7/php-fpm.conf + php_pool_conf: www.conf + php_pool_dir: /etc/php7/php-fpm.d + php_fpm_bin: /usr/sbin/php-fpm7 + when: ansible_os_family == 'Alpine' and ( php_version | version_compare('7.0.0', '>=') ) and ( php_version | version_compare('8.0.0', '<') ) diff --git a/docker/php/centos-7/conf/provision/roles/webdevops-php/tasks/bootstrap/php-fpm.main.yml b/docker/php/centos-7/conf/provision/roles/webdevops-php/tasks/bootstrap/php-fpm.main.yml index 1a2c7861f..c149d8728 100644 --- a/docker/php/centos-7/conf/provision/roles/webdevops-php/tasks/bootstrap/php-fpm.main.yml +++ b/docker/php/centos-7/conf/provision/roles/webdevops-php/tasks/bootstrap/php-fpm.main.yml @@ -1,19 +1,14 @@ --- -- name: Set php main file - set_fact: - php_main_conf: /etc/php-fpm.conf - when: ansible_os_family == 'RedHat' - -- name: Set php main file - set_fact: - php_main_conf: /etc/php5/fpm/php-fpm.conf - when: ansible_os_family == 'Debian' - -- name: Set php main file - set_fact: - php_main_conf: /etc/php5/php-fpm.conf - when: ansible_os_family == 'Alpine' +- name: Create php directories + file: + path: "{{ item }}" + state: directory + mode: 0755 + owner: "root" + group: "root" + with_items: + - /opt/docker/etc/php/fpm/ - name: Move php-fpm main file to /opt/docker/etc/php/fpm/ command: "mv {{ php_main_conf }} /opt/docker/etc/php/fpm/php-fpm.conf" @@ -33,12 +28,22 @@ owner: "root" group: "root" -- name: Configure php-fpm main +- name: Configure php-fpm main (all versions) lineinfile: dest: '/opt/docker/etc/php/fpm/php-fpm.conf' regexp: '^[\s;]*{{ item.key }}[\s]*=' line: '{{ item.key }} = {{ item.value }}' + insertafter: '\[global\]' with_items: - - { key: 'error_log', value: "syslog" } + - { key: 'error_log', value: "/docker.stderr" } - { key: 'pid', value: "/var/run/php-fpm.pid" } + +- name: Configure php-fpm main (php 5.x) + lineinfile: + dest: '/opt/docker/etc/php/fpm/php-fpm.conf' + regexp: '^[\s;]*{{ item.key }}[\s]*=' + line: '{{ item.key }} = {{ item.value }}' + insertbefore: '[\s]*include[\s]*=' + with_items: - { key: 'daemonize', value: 'no' } + when: ( php_version | version_compare('7.0.0', '<') ) diff --git a/docker/php/centos-7/conf/provision/roles/webdevops-php/tasks/bootstrap/php-fpm.pool.yml b/docker/php/centos-7/conf/provision/roles/webdevops-php/tasks/bootstrap/php-fpm.pool.yml index 53ee9dfe1..ab0b7b02c 100644 --- a/docker/php/centos-7/conf/provision/roles/webdevops-php/tasks/bootstrap/php-fpm.pool.yml +++ b/docker/php/centos-7/conf/provision/roles/webdevops-php/tasks/bootstrap/php-fpm.pool.yml @@ -1,18 +1,5 @@ --- -- name: Get php version - command: "php -r 'echo phpversion();'" - changed_when: true - register: php_version_cmd - ignore_errors: true - -- name: Set php_version version - set_fact: - php_version: "{{php_version_cmd.stdout}}" - -- debug: - msg: "PHP-Version: {{php_version}}" - - set_fact: php_clear_env_available: False @@ -22,23 +9,10 @@ ( php_version | version_compare('5.5', 'eq') and php_version | version_compare('5.5.11', 'ge') ) or ( php_version | version_compare('5.6', 'ge') ) -- name: Set php pool file - set_fact: - php_pool_conf: www.conf - php_pool_dir: /etc/php-fpm.d - when: ansible_os_family == 'RedHat' - -- name: Set php pool file - set_fact: - php_pool_conf: www.conf - php_pool_dir: /etc/php5/fpm/pool.d - when: ansible_os_family == 'Debian' - -- name: Set php pool file - set_fact: - php_pool_conf: www.conf - php_pool_dir: /etc/php5/fpm.d - when: ansible_os_family == 'Alpine' +- name: Create /opt/docker/etc/php/fpm directory + file: + path: "/opt/docker/etc/php/fpm" + state: directory - name: Move php-fpm pool directory file to /opt/docker/etc/php/ command: "mv {{ php_pool_dir }} /opt/docker/etc/php/fpm/pool.d" @@ -55,7 +29,7 @@ path: "{{ php_pool_dir }}" state: absent -- name: Symlink php-fpm main file +- name: Symlink php-fpm pool file file: path: "{{ php_pool_dir }}" src: "/opt/docker/etc/php/fpm/pool.d" @@ -69,15 +43,25 @@ regexp: '^[\s;]*{{ item.key }}[\s]*=' line: '{{ item.key }} = {{ item.value }}' with_items: - - { key: 'listen', value: "0.0.0.0:9000" } + - { key: 'listen', value: "[::]:9000" } - { key: 'catch_workers_output', value: "yes" } - { key: 'access.format', value: '[php-fpm:access] %R - %u %t "%m %r%Q%q" %s %f %{mili}d %{kilo}M %C%%' } + - { key: 'access.log', value: "/docker.stdout" } - { key: 'slowlog', value: "/docker.stderr" } - { key: 'php_admin_value[error_log]', value: "/docker.stderr" } - { key: 'php_admin_value[log_errors]', value: "on" } - { key: 'user', value: "{{ APPLICATION_USER }}" } - { key: 'group', value: "{{ APPLICATION_GROUP }}" } +- name: Configure php-fpm pool user (application.conf) + lineinfile: + dest: '/opt/docker/etc/php/fpm/pool.d/application.conf' + regexp: '^[\s;]*{{ item.key }}[\s]*=' + line: '{{ item.key }} = {{ item.value }}' + with_items: + - { key: 'listen', value: "0.0.0.0:9000" } + when: php_version | version_compare('5.5.99', '<=') + - name: Configure php-fpm pool user (application.conf) lineinfile: dest: '/opt/docker/etc/php/fpm/pool.d/application.conf' diff --git a/docker/php/centos-7/conf/provision/roles/webdevops-php/tasks/bootstrap/php-fpm.yml b/docker/php/centos-7/conf/provision/roles/webdevops-php/tasks/bootstrap/php-fpm.yml index d83edb3ae..41c1b33dc 100644 --- a/docker/php/centos-7/conf/provision/roles/webdevops-php/tasks/bootstrap/php-fpm.yml +++ b/docker/php/centos-7/conf/provision/roles/webdevops-php/tasks/bootstrap/php-fpm.yml @@ -1,45 +1,9 @@ --- -- name: Symlink php-fpm binary [Alpine family] +- name: Symlink php-fpm binary file: - path: "/usr/sbin/php-fpm" - src: "/usr/bin/php-fpm" + path: "/usr/local/bin/php-fpm" + src: "{{ php_fpm_bin }}" state: link owner: "root" group: "root" - when: ansible_os_family == 'Alpine' - -- name: Symlink php-fpm binary [Debian family] - file: - path: "/usr/sbin/php-fpm" - src: "/usr/sbin/php5-fpm" - state: link - owner: "root" - group: "root" - when: ansible_os_family == 'Debian' - -- name: Remove default php-fpm logrotate - file: - path: "/etc/logrotate.d/php-fpm" - state: absent - when: ansible_os_family == 'RedHat' - -- name: Create php-fpm log directory - file: - path: "/var/log/php5-fpm/" - state: directory - owner: "root" - group: "root" - -- name: Create php-fpm log files - file: - path: "/var/log/php5-fpm/{{ item }}" - state: touch - owner: "root" - group: "root" - mode: 0600 - with_items: - - slow.log - - access.log - - error.log - - fpm.log diff --git a/docker/php/centos-7/conf/provision/roles/webdevops-php/tasks/bootstrap/php.alpine.yml b/docker/php/centos-7/conf/provision/roles/webdevops-php/tasks/bootstrap/php.alpine.yml new file mode 100644 index 000000000..4c16cdf0d --- /dev/null +++ b/docker/php/centos-7/conf/provision/roles/webdevops-php/tasks/bootstrap/php.alpine.yml @@ -0,0 +1,12 @@ +--- + +- name: Create link for additional php.ini [Alpine family] + file: + src: '/opt/docker/etc/php/{{ item.file }}' + dest: '{{ php_etc_dir }}/conf.d/{{ item.target }}' + state: link + force: yes + with_items: + - { file: 'php.webdevops.ini', target: 'xzza-webdevops.ini'} + - { file: 'php.ini', target: 'xzzz-docker.ini'} + when: ansible_os_family == 'Alpine' diff --git a/docker/php/centos-7/conf/provision/roles/webdevops-php/tasks/bootstrap/php.debian.yml b/docker/php/centos-7/conf/provision/roles/webdevops-php/tasks/bootstrap/php.debian.yml new file mode 100644 index 000000000..d27037e33 --- /dev/null +++ b/docker/php/centos-7/conf/provision/roles/webdevops-php/tasks/bootstrap/php.debian.yml @@ -0,0 +1,18 @@ +--- + +- name: Link php.ini for cli and fpm [Debian family] + file: + src: '{{ item.file }}' + dest: '{{ php_etc_dir }}/{{ item.category }}/conf.d/{{ item.target }}' + force: yes + state: link + with_items: + # PHP cli + - { category: 'cli', file: '{{ php_etc_dir }}/mods-available/mcrypt.ini', target: '20-mcrypt.ini' } + - { category: 'cli', file: '/opt/docker/etc/php/php.webdevops.ini', target: '98-webdevops.ini' } + - { category: 'cli', file: '/opt/docker/etc/php/php.ini', target: '99-docker.ini' } + # PHP fpm + - { category: 'fpm', file: '{{ php_etc_dir }}/mods-available/mcrypt.ini', target: '20-mcrypt.ini' } + - { category: 'fpm', file: '/opt/docker/etc/php/php.webdevops.ini', target: '98-webdevops.ini' } + - { category: 'fpm', file: '/opt/docker/etc/php/php.ini', target: '99-docker.ini' } + when: ansible_os_family == 'Debian' diff --git a/docker/php/centos-7/conf/provision/roles/webdevops-php/tasks/bootstrap/php.redhat.yml b/docker/php/centos-7/conf/provision/roles/webdevops-php/tasks/bootstrap/php.redhat.yml new file mode 100644 index 000000000..7e8810231 --- /dev/null +++ b/docker/php/centos-7/conf/provision/roles/webdevops-php/tasks/bootstrap/php.redhat.yml @@ -0,0 +1,12 @@ +--- + +- name: Create link for additional php.ini [RedHat family] + file: + src: '/opt/docker/etc/php/{{ item.file }}' + dest: '/etc/php.d/{{ item.target }}' + state: link + force: yes + with_items: + - { file: 'php.webdevops.ini', target: 'zza-webdevops.ini'} + - { file: 'php.ini', target: 'zzz-docker.ini'} + when: ansible_os_family == 'RedHat' diff --git a/docker/php/centos-7/conf/provision/roles/webdevops-php/tasks/bootstrap/php.yml b/docker/php/centos-7/conf/provision/roles/webdevops-php/tasks/bootstrap/php.yml index 9816b2538..caac8f413 100644 --- a/docker/php/centos-7/conf/provision/roles/webdevops-php/tasks/bootstrap/php.yml +++ b/docker/php/centos-7/conf/provision/roles/webdevops-php/tasks/bootstrap/php.yml @@ -21,42 +21,3 @@ with_items: - "/opt/docker/etc/php/php.webdevops.ini" - "/opt/docker/etc/php/php.ini" - -- name: Link php.ini for cli and fpm [Debian family] - file: - src: '{{ item.file }}' - dest: '/etc/php5/{{ item.category }}/conf.d/{{ item.target }}' - force: yes - state: link - with_items: - # PHP cli - - { category: 'cli', file: '/etc/php5/mods-available/mcrypt.ini', target: '20-mcrypt.ini' } - - { category: 'cli', file: '/opt/docker/etc/php/php.webdevops.ini', target: '98-webdevops.ini' } - - { category: 'cli', file: '/opt/docker/etc/php/php.ini', target: '99-docker.ini' } - # PHP fpm - - { category: 'fpm', file: '/etc/php5/mods-available/mcrypt.ini', target: '20-mcrypt.ini' } - - { category: 'fpm', file: '/opt/docker/etc/php/php.webdevops.ini', target: '98-webdevops.ini' } - - { category: 'fpm', file: '/opt/docker/etc/php/php.ini', target: '99-docker.ini' } - when: ansible_os_family == 'Debian' - -- name: Create link for additional php.ini [RedHat family] - file: - src: '/opt/docker/etc/php/{{ item.file }}' - dest: '/etc/php.d/{{ item.target }}' - state: link - force: yes - with_items: - - { file: 'php.webdevops.ini', target: 'zza-webdevops.ini'} - - { file: 'php.ini', target: 'zzz-docker.ini'} - when: ansible_os_family == 'RedHat' - -- name: Create link for additional php.ini [Alpine family] - file: - src: '/opt/docker/etc/php/{{ item.file }}' - dest: '/etc/php5/conf.d/{{ item.target }}' - state: link - force: yes - with_items: - - { file: 'php.webdevops.ini', target: 'xzza-webdevops.ini'} - - { file: 'php.ini', target: 'xzzz-docker.ini'} - when: ansible_os_family == 'Alpine' diff --git a/docker/php/debian-7-php7/Dockerfile.disabled b/docker/php/debian-7-php7/Dockerfile.disabled deleted file mode 100644 index 5e830f3e6..000000000 --- a/docker/php/debian-7-php7/Dockerfile.disabled +++ /dev/null @@ -1,47 +0,0 @@ -#++++++++++++++++++++++++++++++++++++++ -# Debian 7 PHP Docker container -#++++++++++++++++++++++++++++++++++++++ - -FROM webdevops/base:debian-7 -# - -# - -# Install dotdeb -RUN echo "deb http://packages.dotdeb.org wheezy all" >> /etc/apt/sources.list \ - && echo "deb-src http://packages.dotdeb.org wheezy all" >> /etc/apt/sources.list \ - && wget wget -O- https://www.dotdeb.org/dotdeb.gpg | apt-key add - - -# Install tools -RUN /usr/local/bin/apt-install \ - imagemagick \ - graphicsmagick \ - ghostscript - -# Install php -RUN /usr/local/bin/apt-install \ - php7.0-cli \ - php7.0-fpm \ - php7.0-json \ - php7.0-intl \ - php7.0-curl \ - php7.0-mysql \ - php7.0-mcrypt \ - php7.0-gd \ - php7.0-sqlite3 \ - php7.0-ldap \ - php7.0-opcache \ - php7.0-xmlrpc \ - php7.0-xsl \ - php7.0-bz2 \ - php7.0-redis \ - && curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin/ --filename=composer - -# Deploy scripts/configurations -COPY conf/ /opt/docker/ -RUN bash /opt/docker/bin/control.sh provision.role.bootstrap webdevops-php \ - && bash /opt/docker/bin/bootstrap.sh - -EXPOSE 9000 - -CMD ["supervisord"] diff --git a/docker/php/debian-7-php7/conf/etc/logrotate.d/php7-fpm b/docker/php/debian-7-php7/conf/etc/logrotate.d/php7-fpm deleted file mode 100644 index 668f2545f..000000000 --- a/docker/php/debian-7-php7/conf/etc/logrotate.d/php7-fpm +++ /dev/null @@ -1,12 +0,0 @@ -/var/log/php7-fpm/fpm.log -/var/log/php7-fpm/access.log -/var/log/php7-fpm/slow.log -/var/log/php7-fpm/error.log { - missingok - notifempty - sharedscripts - delaycompress - postrotate - /bin/kill -SIGUSR1 `cat /var/run/php7-fpm.pid` 2>/dev/null || true - endscript -} diff --git a/docker/php/debian-7-php7/conf/etc/supervisor.d/log-php-access.conf b/docker/php/debian-7-php7/conf/etc/supervisor.d/log-php-access.conf deleted file mode 100644 index b70effa7a..000000000 --- a/docker/php/debian-7-php7/conf/etc/supervisor.d/log-php-access.conf +++ /dev/null @@ -1,8 +0,0 @@ -[program:log-php-access] -command = bash /opt/docker/bin/logwatch.sh php:access /var/log/php7-fpm/access.log -autostart = true -autorestart = true -stdout_logfile=/dev/stdout -stdout_logfile_maxbytes=0 -stderr_logfile=/dev/stderr -stderr_logfile_maxbytes=0 diff --git a/docker/php/debian-7-php7/conf/etc/supervisor.d/log-php-error.conf b/docker/php/debian-7-php7/conf/etc/supervisor.d/log-php-error.conf deleted file mode 100644 index 707ba2196..000000000 --- a/docker/php/debian-7-php7/conf/etc/supervisor.d/log-php-error.conf +++ /dev/null @@ -1,8 +0,0 @@ -[program:log-php-error] -command = bash /opt/docker/bin/logwatch.sh php:error /var/log/php7-fpm/error.log -autostart = true -autorestart = true -stdout_logfile=/dev/stdout -stdout_logfile_maxbytes=0 -stderr_logfile=/dev/stderr -stderr_logfile_maxbytes=0 diff --git a/docker/php/debian-7-php7/conf/etc/supervisor.d/log-php-fpm.conf b/docker/php/debian-7-php7/conf/etc/supervisor.d/log-php-fpm.conf deleted file mode 100644 index 81c631cde..000000000 --- a/docker/php/debian-7-php7/conf/etc/supervisor.d/log-php-fpm.conf +++ /dev/null @@ -1,8 +0,0 @@ -[program:log-php-fpm] -command = bash /opt/docker/bin/logwatch.sh php:fpm /var/log/php7-fpm/fpm.log -autostart = true -autorestart = true -stdout_logfile=/dev/stdout -stdout_logfile_maxbytes=0 -stderr_logfile=/dev/stderr -stderr_logfile_maxbytes=0 diff --git a/docker/php/debian-7-php7/conf/etc/supervisor.d/log-php-slow.conf b/docker/php/debian-7-php7/conf/etc/supervisor.d/log-php-slow.conf deleted file mode 100644 index c3ea37aa6..000000000 --- a/docker/php/debian-7-php7/conf/etc/supervisor.d/log-php-slow.conf +++ /dev/null @@ -1,8 +0,0 @@ -[program:log-php-slow] -command = bash /opt/docker/bin/logwatch.sh php:slow /var/log/php7-fpm/slow.log -autostart = true -autorestart = true -stdout_logfile=/dev/stdout -stdout_logfile_maxbytes=0 -stderr_logfile=/dev/stderr -stderr_logfile_maxbytes=0 diff --git a/docker/php/debian-7-php7/conf/etc/supervisor.d/php-fpm.conf b/docker/php/debian-7-php7/conf/etc/supervisor.d/php-fpm.conf deleted file mode 100644 index 4725c5e49..000000000 --- a/docker/php/debian-7-php7/conf/etc/supervisor.d/php-fpm.conf +++ /dev/null @@ -1,8 +0,0 @@ -[program:php-fpm] -command = /usr/sbin/php-fpm7.0 --nodaemonize -autostart = true -autorestart = true -stdout_logfile=/dev/stdout -stdout_logfile_maxbytes=0 -stderr_logfile=/dev/stderr -stderr_logfile_maxbytes=0 diff --git a/docker/php/debian-7-php7/conf/provision/roles/webdevops-php/tasks/bootstrap.yml b/docker/php/debian-7-php7/conf/provision/roles/webdevops-php/tasks/bootstrap.yml deleted file mode 100644 index 4523e5a35..000000000 --- a/docker/php/debian-7-php7/conf/provision/roles/webdevops-php/tasks/bootstrap.yml +++ /dev/null @@ -1,89 +0,0 @@ ---- - -- name: Set php main file - set_fact: - php_main_conf: /etc/php-fpm.conf - when: ansible_distribution == 'CentOS' - -- name: Set php main file - set_fact: - php_main_conf: /etc/php/7.0/fpm/php-fpm.conf - when: ansible_distribution == 'Ubuntu' or ansible_distribution == 'Debian' - -- name: Set php pool file - set_fact: - php_pool_conf: /etc/php-fpm.d/www.conf - when: ansible_distribution == 'CentOS' - -- name: Set php pool file - set_fact: - php_pool_conf: /etc/php/7.0/fpm/pool.d/www.conf - when: ansible_distribution == 'Ubuntu' or ansible_distribution == 'Debian' - -- name: Symlink php-fpm binary - file: - path: "/usr/sbin/php-fpm7.0" - src: "/sbin/php-fpm" - state: link - owner: "root" - group: "root" - when: ansible_distribution == 'CentOS' - -- name: Remove default php-fpm logrotate - file: - path: "/etc/logrotate.d/php-fpm" - state: absent - when: ansible_distribution == 'CentOS' - -- name: Create php-fpm log directory - file: - path: "/var/log/php7-fpm/" - state: directory - owner: "root" - group: "root" - -- name: Create php-fpm log files - file: - path: "/var/log/php7-fpm/{{ item }}" - state: touch - owner: "root" - group: "root" - mode: 0600 - with_items: - - slow.log - - access.log - - error.log - - fpm.log - - -- name: Configure php-fpm main - lineinfile: - dest: '{{ php_main_conf }}' - regexp: '^[\s;]*{{ item.key }}[\s]*=' - line: '{{ item.key }} = {{ item.value }}' - with_items: - - { key: 'error_log', value: "/var/log/php7-fpm/fpm.log" } - - { key: 'pid', value: "/var/run/php7-fpm.pid" } - -- name: Configure php-fpm pool user (www.conf) - lineinfile: - dest: '{{ php_pool_conf }}' - regexp: '^[\s;]*{{ item.key }}[\s]*=' - line: '{{ item.key }} = {{ item.value }}' - with_items: - - { key: 'listen', value: "0.0.0.0:9000" } - - { key: 'catch_workers_output', value: "yes" } - - { key: 'access.log', value: "/var/log/php7-fpm/access.log" } - - { key: 'slowlog', value: "/var/log/php7-fpm/slow.log" } - - { key: 'php_admin_value[error_log]', value: "/var/log/php7-fpm/error.log" } - - { key: 'php_admin_value[log_errors]', value: "on" } - - { key: 'user', value: "{{ APPLICATION_USER }}" } - - { key: 'group', value: "{{ APPLICATION_GROUP }}" } - -- name: Enable php-fpm connection limit - lineinfile: - dest: '{{ php_pool_conf }}' - regexp: '^[\s;]*{{ item.key }}[\s]*=' - line: ';{{ item.key }}' - with_items: - - { key: 'listen.allowed_clients' } diff --git a/docker/php/debian-7/Dockerfile b/docker/php/debian-7/Dockerfile index efb4d49c3..0a4e5622e 100644 --- a/docker/php/debian-7/Dockerfile +++ b/docker/php/debian-7/Dockerfile @@ -5,14 +5,9 @@ FROM webdevops/base-app:debian-7 -MAINTAINER info@webdevops.io -LABEL vendor=WebDevOps.io -LABEL io.webdevops.layout=8 -LABEL io.webdevops.version=1.5.0 - -ENV WEB_DOCUMENT_ROOT /app -ENV WEB_DOCUMENT_INDEX index.php -ENV WEB_ALIAS_DOMAIN *.vm +ENV WEB_DOCUMENT_ROOT=/app \ + WEB_DOCUMENT_INDEX=index.php \ + WEB_ALIAS_DOMAIN=*.vm COPY conf/ /opt/docker/ @@ -46,8 +41,10 @@ RUN /usr/local/bin/apt-install \ && ln -sf /etc/php5/mods-available/mcrypt.in /etc/php5/cli/conf.d/20-mcrypt.ini \ && ln -sf /etc/php5/mods-available/mcrypt.in /etc/php5/fpm/conf.d/20-mcrypt.ini \ && curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin/ --filename=composer \ + # Enable php services + && docker-service-enable syslog cron \ && /opt/docker/bin/provision run --tag bootstrap --role webdevops-php \ - && /opt/docker/bin/bootstrap.sh - + && /opt/docker/bin/bootstrap.sh \ + && docker-image-cleanup EXPOSE 9000 diff --git a/docker/php/debian-7/Dockerfile.jinja2 b/docker/php/debian-7/Dockerfile.jinja2 index 2dde687bd..91eea7c92 100644 --- a/docker/php/debian-7/Dockerfile.jinja2 +++ b/docker/php/debian-7/Dockerfile.jinja2 @@ -1,7 +1,5 @@ {{ docker.from("base-app", "debian-7") }} -{{ docker.version() }} - {{ environment.web() }} {{ docker.copy('conf/', '/opt/docker/') }} diff --git a/docker/php/debian-7/conf/bin/service.d/php-fpm.d/11-clear-env.sh b/docker/php/debian-7/conf/bin/service.d/php-fpm.d/11-clear-env.sh index b17280ce6..ef6fd4016 100644 --- a/docker/php/debian-7/conf/bin/service.d/php-fpm.d/11-clear-env.sh +++ b/docker/php/debian-7/conf/bin/service.d/php-fpm.d/11-clear-env.sh @@ -30,5 +30,9 @@ for envVariable in $(printenv|cut -f1 -d=); do done # Replace ;#CLEAR_ENV_WORKAROUND# with environment variable list for all php-fpm pool files -find /opt/docker/etc/php/fpm/pool.d/ -iname '*.conf' -print0 | xargs -0 -r rpl --quiet ";#CLEAR_ENV_WORKAROUND#" "$VARIABLE_LIST" > /dev/null +go-replace \ + -s ";#CLEAR_ENV_WORKAROUND#" -r "$VARIABLE_LIST" \ + --path=/opt/docker/etc/php/fpm/pool.d/ \ + --path-pattern='*.conf' \ + --ignore-empty diff --git a/docker/php/debian-7/conf/bin/service.d/php-fpm.sh b/docker/php/debian-7/conf/bin/service.d/php-fpm.sh index 571f248d2..b25983bd3 100644 --- a/docker/php/debian-7/conf/bin/service.d/php-fpm.sh +++ b/docker/php/debian-7/conf/bin/service.d/php-fpm.sh @@ -4,4 +4,4 @@ source /opt/docker/bin/config.sh includeScriptDir "/opt/docker/bin/service.d/php-fpm.d/" -exec /usr/sbin/php-fpm --nodaemonize +exec /usr/local/bin/php-fpm --nodaemonize diff --git a/docker/php/debian-7/conf/etc/php/php.webdevops.ini b/docker/php/debian-7/conf/etc/php/php.webdevops.ini index 562b8d7e2..aa1545ab8 100644 --- a/docker/php/debian-7/conf/etc/php/php.webdevops.ini +++ b/docker/php/debian-7/conf/etc/php/php.webdevops.ini @@ -5,6 +5,7 @@ ; this file will overwrite default php.ini settings display_errors = 0 +log_errors = 1 short_open_tag = Off variables_order = 'GPCS' diff --git a/docker/php/debian-7/conf/provision/roles/webdevops-php/tasks/bootstrap.yml b/docker/php/debian-7/conf/provision/roles/webdevops-php/tasks/bootstrap.yml index 5883fa1fe..99a2e5191 100644 --- a/docker/php/debian-7/conf/provision/roles/webdevops-php/tasks/bootstrap.yml +++ b/docker/php/debian-7/conf/provision/roles/webdevops-php/tasks/bootstrap.yml @@ -1,6 +1,10 @@ --- +- include: bootstrap/init.yml - include: bootstrap/php.yml +- include: bootstrap/php.debian.yml +- include: bootstrap/php.redhat.yml +- include: bootstrap/php.alpine.yml - include: bootstrap/php-fpm.main.yml - include: bootstrap/php-fpm.pool.yml - include: bootstrap/php-fpm.yml diff --git a/docker/php/debian-7/conf/provision/roles/webdevops-php/tasks/bootstrap/init.yml b/docker/php/debian-7/conf/provision/roles/webdevops-php/tasks/bootstrap/init.yml new file mode 100644 index 000000000..a48bec675 --- /dev/null +++ b/docker/php/debian-7/conf/provision/roles/webdevops-php/tasks/bootstrap/init.yml @@ -0,0 +1,71 @@ +--- + +- name: Get php version + command: "php -r 'echo phpversion();'" + changed_when: true + register: php_version_cmd + ignore_errors: true + +- name: Set php_version version + set_fact: + php_version: "{{php_version_cmd.stdout}}" + +############################# +# PHP 5.x +############################# + +- name: Set php main file (RedHat, PHP 5.x) + set_fact: + php_main_conf: /etc/php-fpm.conf + php_pool_conf: www.conf + php_pool_dir: /etc/php-fpm.d + php_fpm_bin: /usr/sbin/php-fpm + when: ansible_os_family == 'RedHat' and ( php_version | version_compare('7.0.0', '<') ) + +- name: Set php main file (Debian, PHP 5.x) + set_fact: + php_etc_dir: /etc/php5 + php_main_conf: /etc/php5/fpm/php-fpm.conf + php_pool_conf: www.conf + php_pool_dir: /etc/php5/fpm/pool.d + php_fpm_bin: /usr/sbin/php5-fpm + when: ansible_os_family == 'Debian' and ( php_version | version_compare('7.0.0', '<') ) + +- name: Set php main file (Alpine, PHP 5.x) + set_fact: + php_etc_dir: /etc/php5 + php_main_conf: /etc/php5/php-fpm.conf + php_pool_conf: www.conf + php_pool_dir: /etc/php5/fpm.d + php_fpm_bin: /usr/bin/php-fpm5 + when: ansible_os_family == 'Alpine' and ( php_version | version_compare('7.0.0', '<') ) + +############################# +# PHP 7.x +############################# + +- name: Set php main file (RedHat, PHP 7.x) + set_fact: + php_main_conf: /etc/php-fpm.conf + php_pool_conf: www.conf + php_pool_dir: /etc/php-fpm.d + php_fpm_bin: /usr/sbin/php-fpm + when: ansible_os_family == 'RedHat' and ( php_version | version_compare('7.0.0', '>=') ) and ( php_version | version_compare('8.0.0', '<') ) + +- name: Set php main file (Debian, PHP 7.x) + set_fact: + php_etc_dir: /etc/php/7.0 + php_main_conf: /etc/php/7.0/fpm/php-fpm.conf + php_pool_conf: www.conf + php_pool_dir: /etc/php/7.0/fpm/pool.d + php_fpm_bin: /usr/sbin/php-fpm7.0 + when: ansible_os_family == 'Debian' and ( php_version | version_compare('7.0.0', '>=') ) and ( php_version | version_compare('8.0.0', '<') ) + +- name: Set php main file (Alpine, PHP 7.x) + set_fact: + php_etc_dir: /etc/php7 + php_main_conf: /etc/php7/php-fpm.conf + php_pool_conf: www.conf + php_pool_dir: /etc/php7/php-fpm.d + php_fpm_bin: /usr/sbin/php-fpm7 + when: ansible_os_family == 'Alpine' and ( php_version | version_compare('7.0.0', '>=') ) and ( php_version | version_compare('8.0.0', '<') ) diff --git a/docker/php/debian-7/conf/provision/roles/webdevops-php/tasks/bootstrap/php-fpm.main.yml b/docker/php/debian-7/conf/provision/roles/webdevops-php/tasks/bootstrap/php-fpm.main.yml index 1a2c7861f..c149d8728 100644 --- a/docker/php/debian-7/conf/provision/roles/webdevops-php/tasks/bootstrap/php-fpm.main.yml +++ b/docker/php/debian-7/conf/provision/roles/webdevops-php/tasks/bootstrap/php-fpm.main.yml @@ -1,19 +1,14 @@ --- -- name: Set php main file - set_fact: - php_main_conf: /etc/php-fpm.conf - when: ansible_os_family == 'RedHat' - -- name: Set php main file - set_fact: - php_main_conf: /etc/php5/fpm/php-fpm.conf - when: ansible_os_family == 'Debian' - -- name: Set php main file - set_fact: - php_main_conf: /etc/php5/php-fpm.conf - when: ansible_os_family == 'Alpine' +- name: Create php directories + file: + path: "{{ item }}" + state: directory + mode: 0755 + owner: "root" + group: "root" + with_items: + - /opt/docker/etc/php/fpm/ - name: Move php-fpm main file to /opt/docker/etc/php/fpm/ command: "mv {{ php_main_conf }} /opt/docker/etc/php/fpm/php-fpm.conf" @@ -33,12 +28,22 @@ owner: "root" group: "root" -- name: Configure php-fpm main +- name: Configure php-fpm main (all versions) lineinfile: dest: '/opt/docker/etc/php/fpm/php-fpm.conf' regexp: '^[\s;]*{{ item.key }}[\s]*=' line: '{{ item.key }} = {{ item.value }}' + insertafter: '\[global\]' with_items: - - { key: 'error_log', value: "syslog" } + - { key: 'error_log', value: "/docker.stderr" } - { key: 'pid', value: "/var/run/php-fpm.pid" } + +- name: Configure php-fpm main (php 5.x) + lineinfile: + dest: '/opt/docker/etc/php/fpm/php-fpm.conf' + regexp: '^[\s;]*{{ item.key }}[\s]*=' + line: '{{ item.key }} = {{ item.value }}' + insertbefore: '[\s]*include[\s]*=' + with_items: - { key: 'daemonize', value: 'no' } + when: ( php_version | version_compare('7.0.0', '<') ) diff --git a/docker/php/debian-7/conf/provision/roles/webdevops-php/tasks/bootstrap/php-fpm.pool.yml b/docker/php/debian-7/conf/provision/roles/webdevops-php/tasks/bootstrap/php-fpm.pool.yml index 53ee9dfe1..ab0b7b02c 100644 --- a/docker/php/debian-7/conf/provision/roles/webdevops-php/tasks/bootstrap/php-fpm.pool.yml +++ b/docker/php/debian-7/conf/provision/roles/webdevops-php/tasks/bootstrap/php-fpm.pool.yml @@ -1,18 +1,5 @@ --- -- name: Get php version - command: "php -r 'echo phpversion();'" - changed_when: true - register: php_version_cmd - ignore_errors: true - -- name: Set php_version version - set_fact: - php_version: "{{php_version_cmd.stdout}}" - -- debug: - msg: "PHP-Version: {{php_version}}" - - set_fact: php_clear_env_available: False @@ -22,23 +9,10 @@ ( php_version | version_compare('5.5', 'eq') and php_version | version_compare('5.5.11', 'ge') ) or ( php_version | version_compare('5.6', 'ge') ) -- name: Set php pool file - set_fact: - php_pool_conf: www.conf - php_pool_dir: /etc/php-fpm.d - when: ansible_os_family == 'RedHat' - -- name: Set php pool file - set_fact: - php_pool_conf: www.conf - php_pool_dir: /etc/php5/fpm/pool.d - when: ansible_os_family == 'Debian' - -- name: Set php pool file - set_fact: - php_pool_conf: www.conf - php_pool_dir: /etc/php5/fpm.d - when: ansible_os_family == 'Alpine' +- name: Create /opt/docker/etc/php/fpm directory + file: + path: "/opt/docker/etc/php/fpm" + state: directory - name: Move php-fpm pool directory file to /opt/docker/etc/php/ command: "mv {{ php_pool_dir }} /opt/docker/etc/php/fpm/pool.d" @@ -55,7 +29,7 @@ path: "{{ php_pool_dir }}" state: absent -- name: Symlink php-fpm main file +- name: Symlink php-fpm pool file file: path: "{{ php_pool_dir }}" src: "/opt/docker/etc/php/fpm/pool.d" @@ -69,15 +43,25 @@ regexp: '^[\s;]*{{ item.key }}[\s]*=' line: '{{ item.key }} = {{ item.value }}' with_items: - - { key: 'listen', value: "0.0.0.0:9000" } + - { key: 'listen', value: "[::]:9000" } - { key: 'catch_workers_output', value: "yes" } - { key: 'access.format', value: '[php-fpm:access] %R - %u %t "%m %r%Q%q" %s %f %{mili}d %{kilo}M %C%%' } + - { key: 'access.log', value: "/docker.stdout" } - { key: 'slowlog', value: "/docker.stderr" } - { key: 'php_admin_value[error_log]', value: "/docker.stderr" } - { key: 'php_admin_value[log_errors]', value: "on" } - { key: 'user', value: "{{ APPLICATION_USER }}" } - { key: 'group', value: "{{ APPLICATION_GROUP }}" } +- name: Configure php-fpm pool user (application.conf) + lineinfile: + dest: '/opt/docker/etc/php/fpm/pool.d/application.conf' + regexp: '^[\s;]*{{ item.key }}[\s]*=' + line: '{{ item.key }} = {{ item.value }}' + with_items: + - { key: 'listen', value: "0.0.0.0:9000" } + when: php_version | version_compare('5.5.99', '<=') + - name: Configure php-fpm pool user (application.conf) lineinfile: dest: '/opt/docker/etc/php/fpm/pool.d/application.conf' diff --git a/docker/php/debian-7/conf/provision/roles/webdevops-php/tasks/bootstrap/php-fpm.yml b/docker/php/debian-7/conf/provision/roles/webdevops-php/tasks/bootstrap/php-fpm.yml index d83edb3ae..41c1b33dc 100644 --- a/docker/php/debian-7/conf/provision/roles/webdevops-php/tasks/bootstrap/php-fpm.yml +++ b/docker/php/debian-7/conf/provision/roles/webdevops-php/tasks/bootstrap/php-fpm.yml @@ -1,45 +1,9 @@ --- -- name: Symlink php-fpm binary [Alpine family] +- name: Symlink php-fpm binary file: - path: "/usr/sbin/php-fpm" - src: "/usr/bin/php-fpm" + path: "/usr/local/bin/php-fpm" + src: "{{ php_fpm_bin }}" state: link owner: "root" group: "root" - when: ansible_os_family == 'Alpine' - -- name: Symlink php-fpm binary [Debian family] - file: - path: "/usr/sbin/php-fpm" - src: "/usr/sbin/php5-fpm" - state: link - owner: "root" - group: "root" - when: ansible_os_family == 'Debian' - -- name: Remove default php-fpm logrotate - file: - path: "/etc/logrotate.d/php-fpm" - state: absent - when: ansible_os_family == 'RedHat' - -- name: Create php-fpm log directory - file: - path: "/var/log/php5-fpm/" - state: directory - owner: "root" - group: "root" - -- name: Create php-fpm log files - file: - path: "/var/log/php5-fpm/{{ item }}" - state: touch - owner: "root" - group: "root" - mode: 0600 - with_items: - - slow.log - - access.log - - error.log - - fpm.log diff --git a/docker/php/debian-7/conf/provision/roles/webdevops-php/tasks/bootstrap/php.alpine.yml b/docker/php/debian-7/conf/provision/roles/webdevops-php/tasks/bootstrap/php.alpine.yml new file mode 100644 index 000000000..4c16cdf0d --- /dev/null +++ b/docker/php/debian-7/conf/provision/roles/webdevops-php/tasks/bootstrap/php.alpine.yml @@ -0,0 +1,12 @@ +--- + +- name: Create link for additional php.ini [Alpine family] + file: + src: '/opt/docker/etc/php/{{ item.file }}' + dest: '{{ php_etc_dir }}/conf.d/{{ item.target }}' + state: link + force: yes + with_items: + - { file: 'php.webdevops.ini', target: 'xzza-webdevops.ini'} + - { file: 'php.ini', target: 'xzzz-docker.ini'} + when: ansible_os_family == 'Alpine' diff --git a/docker/php/debian-7/conf/provision/roles/webdevops-php/tasks/bootstrap/php.debian.yml b/docker/php/debian-7/conf/provision/roles/webdevops-php/tasks/bootstrap/php.debian.yml new file mode 100644 index 000000000..d27037e33 --- /dev/null +++ b/docker/php/debian-7/conf/provision/roles/webdevops-php/tasks/bootstrap/php.debian.yml @@ -0,0 +1,18 @@ +--- + +- name: Link php.ini for cli and fpm [Debian family] + file: + src: '{{ item.file }}' + dest: '{{ php_etc_dir }}/{{ item.category }}/conf.d/{{ item.target }}' + force: yes + state: link + with_items: + # PHP cli + - { category: 'cli', file: '{{ php_etc_dir }}/mods-available/mcrypt.ini', target: '20-mcrypt.ini' } + - { category: 'cli', file: '/opt/docker/etc/php/php.webdevops.ini', target: '98-webdevops.ini' } + - { category: 'cli', file: '/opt/docker/etc/php/php.ini', target: '99-docker.ini' } + # PHP fpm + - { category: 'fpm', file: '{{ php_etc_dir }}/mods-available/mcrypt.ini', target: '20-mcrypt.ini' } + - { category: 'fpm', file: '/opt/docker/etc/php/php.webdevops.ini', target: '98-webdevops.ini' } + - { category: 'fpm', file: '/opt/docker/etc/php/php.ini', target: '99-docker.ini' } + when: ansible_os_family == 'Debian' diff --git a/docker/php/debian-7/conf/provision/roles/webdevops-php/tasks/bootstrap/php.redhat.yml b/docker/php/debian-7/conf/provision/roles/webdevops-php/tasks/bootstrap/php.redhat.yml new file mode 100644 index 000000000..7e8810231 --- /dev/null +++ b/docker/php/debian-7/conf/provision/roles/webdevops-php/tasks/bootstrap/php.redhat.yml @@ -0,0 +1,12 @@ +--- + +- name: Create link for additional php.ini [RedHat family] + file: + src: '/opt/docker/etc/php/{{ item.file }}' + dest: '/etc/php.d/{{ item.target }}' + state: link + force: yes + with_items: + - { file: 'php.webdevops.ini', target: 'zza-webdevops.ini'} + - { file: 'php.ini', target: 'zzz-docker.ini'} + when: ansible_os_family == 'RedHat' diff --git a/docker/php/debian-7/conf/provision/roles/webdevops-php/tasks/bootstrap/php.yml b/docker/php/debian-7/conf/provision/roles/webdevops-php/tasks/bootstrap/php.yml index 9816b2538..caac8f413 100644 --- a/docker/php/debian-7/conf/provision/roles/webdevops-php/tasks/bootstrap/php.yml +++ b/docker/php/debian-7/conf/provision/roles/webdevops-php/tasks/bootstrap/php.yml @@ -21,42 +21,3 @@ with_items: - "/opt/docker/etc/php/php.webdevops.ini" - "/opt/docker/etc/php/php.ini" - -- name: Link php.ini for cli and fpm [Debian family] - file: - src: '{{ item.file }}' - dest: '/etc/php5/{{ item.category }}/conf.d/{{ item.target }}' - force: yes - state: link - with_items: - # PHP cli - - { category: 'cli', file: '/etc/php5/mods-available/mcrypt.ini', target: '20-mcrypt.ini' } - - { category: 'cli', file: '/opt/docker/etc/php/php.webdevops.ini', target: '98-webdevops.ini' } - - { category: 'cli', file: '/opt/docker/etc/php/php.ini', target: '99-docker.ini' } - # PHP fpm - - { category: 'fpm', file: '/etc/php5/mods-available/mcrypt.ini', target: '20-mcrypt.ini' } - - { category: 'fpm', file: '/opt/docker/etc/php/php.webdevops.ini', target: '98-webdevops.ini' } - - { category: 'fpm', file: '/opt/docker/etc/php/php.ini', target: '99-docker.ini' } - when: ansible_os_family == 'Debian' - -- name: Create link for additional php.ini [RedHat family] - file: - src: '/opt/docker/etc/php/{{ item.file }}' - dest: '/etc/php.d/{{ item.target }}' - state: link - force: yes - with_items: - - { file: 'php.webdevops.ini', target: 'zza-webdevops.ini'} - - { file: 'php.ini', target: 'zzz-docker.ini'} - when: ansible_os_family == 'RedHat' - -- name: Create link for additional php.ini [Alpine family] - file: - src: '/opt/docker/etc/php/{{ item.file }}' - dest: '/etc/php5/conf.d/{{ item.target }}' - state: link - force: yes - with_items: - - { file: 'php.webdevops.ini', target: 'xzza-webdevops.ini'} - - { file: 'php.ini', target: 'xzzz-docker.ini'} - when: ansible_os_family == 'Alpine' diff --git a/docker/php/debian-8-php7/Dockerfile b/docker/php/debian-8-php7/Dockerfile index 48a8a215c..19e33fc43 100644 --- a/docker/php/debian-8-php7/Dockerfile +++ b/docker/php/debian-8-php7/Dockerfile @@ -5,14 +5,9 @@ FROM webdevops/base-app:debian-8 -MAINTAINER info@webdevops.io -LABEL vendor=WebDevOps.io -LABEL io.webdevops.layout=8 -LABEL io.webdevops.version=1.5.0 - -ENV WEB_DOCUMENT_ROOT /app -ENV WEB_DOCUMENT_INDEX index.php -ENV WEB_ALIAS_DOMAIN *.vm +ENV WEB_DOCUMENT_ROOT=/app \ + WEB_DOCUMENT_INDEX=index.php \ + WEB_ALIAS_DOMAIN=*.vm COPY conf/ /opt/docker/ @@ -57,8 +52,10 @@ RUN /usr/local/bin/apt-install apt-transport-https lsb-release \ php7.0-mbstring \ php-apcu \ && curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin/ --filename=composer \ + # Enable php services + && docker-service-enable syslog cron \ && /opt/docker/bin/provision run --tag bootstrap --role webdevops-php \ - && /opt/docker/bin/bootstrap.sh - + && /opt/docker/bin/bootstrap.sh \ + && docker-image-cleanup EXPOSE 9000 diff --git a/docker/php/debian-8-php7/Dockerfile.jinja2 b/docker/php/debian-8-php7/Dockerfile.jinja2 index 248924e90..e6fd2199b 100644 --- a/docker/php/debian-8-php7/Dockerfile.jinja2 +++ b/docker/php/debian-8-php7/Dockerfile.jinja2 @@ -1,7 +1,5 @@ {{ docker.from("base-app", "debian-8") }} -{{ docker.version() }} - {{ environment.web() }} {{ docker.copy('conf/', '/opt/docker/') }} diff --git a/docker/php/debian-8-php7/conf/bin/service.d/php-fpm.d/11-clear-env.sh b/docker/php/debian-8-php7/conf/bin/service.d/php-fpm.d/11-clear-env.sh index b17280ce6..ef6fd4016 100644 --- a/docker/php/debian-8-php7/conf/bin/service.d/php-fpm.d/11-clear-env.sh +++ b/docker/php/debian-8-php7/conf/bin/service.d/php-fpm.d/11-clear-env.sh @@ -30,5 +30,9 @@ for envVariable in $(printenv|cut -f1 -d=); do done # Replace ;#CLEAR_ENV_WORKAROUND# with environment variable list for all php-fpm pool files -find /opt/docker/etc/php/fpm/pool.d/ -iname '*.conf' -print0 | xargs -0 -r rpl --quiet ";#CLEAR_ENV_WORKAROUND#" "$VARIABLE_LIST" > /dev/null +go-replace \ + -s ";#CLEAR_ENV_WORKAROUND#" -r "$VARIABLE_LIST" \ + --path=/opt/docker/etc/php/fpm/pool.d/ \ + --path-pattern='*.conf' \ + --ignore-empty diff --git a/docker/php/debian-8-php7/conf/bin/service.d/php-fpm.sh b/docker/php/debian-8-php7/conf/bin/service.d/php-fpm.sh index 571f248d2..b25983bd3 100644 --- a/docker/php/debian-8-php7/conf/bin/service.d/php-fpm.sh +++ b/docker/php/debian-8-php7/conf/bin/service.d/php-fpm.sh @@ -4,4 +4,4 @@ source /opt/docker/bin/config.sh includeScriptDir "/opt/docker/bin/service.d/php-fpm.d/" -exec /usr/sbin/php-fpm --nodaemonize +exec /usr/local/bin/php-fpm --nodaemonize diff --git a/docker/php/debian-8-php7/conf/etc/logrotate.d/php7-fpm b/docker/php/debian-8-php7/conf/etc/logrotate.d/php7-fpm deleted file mode 100644 index 668f2545f..000000000 --- a/docker/php/debian-8-php7/conf/etc/logrotate.d/php7-fpm +++ /dev/null @@ -1,12 +0,0 @@ -/var/log/php7-fpm/fpm.log -/var/log/php7-fpm/access.log -/var/log/php7-fpm/slow.log -/var/log/php7-fpm/error.log { - missingok - notifempty - sharedscripts - delaycompress - postrotate - /bin/kill -SIGUSR1 `cat /var/run/php7-fpm.pid` 2>/dev/null || true - endscript -} diff --git a/docker/php/debian-8-php7/conf/etc/php/php.webdevops.ini b/docker/php/debian-8-php7/conf/etc/php/php.webdevops.ini index 562b8d7e2..aa1545ab8 100644 --- a/docker/php/debian-8-php7/conf/etc/php/php.webdevops.ini +++ b/docker/php/debian-8-php7/conf/etc/php/php.webdevops.ini @@ -5,6 +5,7 @@ ; this file will overwrite default php.ini settings display_errors = 0 +log_errors = 1 short_open_tag = Off variables_order = 'GPCS' diff --git a/docker/php/debian-8-php7/conf/provision/roles/webdevops-php/tasks/bootstrap.yml b/docker/php/debian-8-php7/conf/provision/roles/webdevops-php/tasks/bootstrap.yml index 5883fa1fe..99a2e5191 100644 --- a/docker/php/debian-8-php7/conf/provision/roles/webdevops-php/tasks/bootstrap.yml +++ b/docker/php/debian-8-php7/conf/provision/roles/webdevops-php/tasks/bootstrap.yml @@ -1,6 +1,10 @@ --- +- include: bootstrap/init.yml - include: bootstrap/php.yml +- include: bootstrap/php.debian.yml +- include: bootstrap/php.redhat.yml +- include: bootstrap/php.alpine.yml - include: bootstrap/php-fpm.main.yml - include: bootstrap/php-fpm.pool.yml - include: bootstrap/php-fpm.yml diff --git a/docker/php/debian-8-php7/conf/provision/roles/webdevops-php/tasks/bootstrap/init.yml b/docker/php/debian-8-php7/conf/provision/roles/webdevops-php/tasks/bootstrap/init.yml new file mode 100644 index 000000000..a48bec675 --- /dev/null +++ b/docker/php/debian-8-php7/conf/provision/roles/webdevops-php/tasks/bootstrap/init.yml @@ -0,0 +1,71 @@ +--- + +- name: Get php version + command: "php -r 'echo phpversion();'" + changed_when: true + register: php_version_cmd + ignore_errors: true + +- name: Set php_version version + set_fact: + php_version: "{{php_version_cmd.stdout}}" + +############################# +# PHP 5.x +############################# + +- name: Set php main file (RedHat, PHP 5.x) + set_fact: + php_main_conf: /etc/php-fpm.conf + php_pool_conf: www.conf + php_pool_dir: /etc/php-fpm.d + php_fpm_bin: /usr/sbin/php-fpm + when: ansible_os_family == 'RedHat' and ( php_version | version_compare('7.0.0', '<') ) + +- name: Set php main file (Debian, PHP 5.x) + set_fact: + php_etc_dir: /etc/php5 + php_main_conf: /etc/php5/fpm/php-fpm.conf + php_pool_conf: www.conf + php_pool_dir: /etc/php5/fpm/pool.d + php_fpm_bin: /usr/sbin/php5-fpm + when: ansible_os_family == 'Debian' and ( php_version | version_compare('7.0.0', '<') ) + +- name: Set php main file (Alpine, PHP 5.x) + set_fact: + php_etc_dir: /etc/php5 + php_main_conf: /etc/php5/php-fpm.conf + php_pool_conf: www.conf + php_pool_dir: /etc/php5/fpm.d + php_fpm_bin: /usr/bin/php-fpm5 + when: ansible_os_family == 'Alpine' and ( php_version | version_compare('7.0.0', '<') ) + +############################# +# PHP 7.x +############################# + +- name: Set php main file (RedHat, PHP 7.x) + set_fact: + php_main_conf: /etc/php-fpm.conf + php_pool_conf: www.conf + php_pool_dir: /etc/php-fpm.d + php_fpm_bin: /usr/sbin/php-fpm + when: ansible_os_family == 'RedHat' and ( php_version | version_compare('7.0.0', '>=') ) and ( php_version | version_compare('8.0.0', '<') ) + +- name: Set php main file (Debian, PHP 7.x) + set_fact: + php_etc_dir: /etc/php/7.0 + php_main_conf: /etc/php/7.0/fpm/php-fpm.conf + php_pool_conf: www.conf + php_pool_dir: /etc/php/7.0/fpm/pool.d + php_fpm_bin: /usr/sbin/php-fpm7.0 + when: ansible_os_family == 'Debian' and ( php_version | version_compare('7.0.0', '>=') ) and ( php_version | version_compare('8.0.0', '<') ) + +- name: Set php main file (Alpine, PHP 7.x) + set_fact: + php_etc_dir: /etc/php7 + php_main_conf: /etc/php7/php-fpm.conf + php_pool_conf: www.conf + php_pool_dir: /etc/php7/php-fpm.d + php_fpm_bin: /usr/sbin/php-fpm7 + when: ansible_os_family == 'Alpine' and ( php_version | version_compare('7.0.0', '>=') ) and ( php_version | version_compare('8.0.0', '<') ) diff --git a/docker/php/debian-8-php7/conf/provision/roles/webdevops-php/tasks/bootstrap/php-fpm.main.yml b/docker/php/debian-8-php7/conf/provision/roles/webdevops-php/tasks/bootstrap/php-fpm.main.yml index 36143a96f..c149d8728 100644 --- a/docker/php/debian-8-php7/conf/provision/roles/webdevops-php/tasks/bootstrap/php-fpm.main.yml +++ b/docker/php/debian-8-php7/conf/provision/roles/webdevops-php/tasks/bootstrap/php-fpm.main.yml @@ -1,20 +1,5 @@ --- -- name: Set php main file - set_fact: - php_main_conf: /etc/php-fpm.conf - when: ansible_os_family == 'RedHat' - -- name: Set php main file - set_fact: - php_main_conf: /etc/php/7.0/fpm/php-fpm.conf - when: ansible_os_family == 'Debian' - -- name: Set php main file - set_fact: - php_main_conf: /etc/php7/php-fpm.conf - when: ansible_os_family == 'Alpine' - - name: Create php directories file: path: "{{ item }}" @@ -43,11 +28,22 @@ owner: "root" group: "root" -- name: Configure php-fpm main +- name: Configure php-fpm main (all versions) + lineinfile: + dest: '/opt/docker/etc/php/fpm/php-fpm.conf' + regexp: '^[\s;]*{{ item.key }}[\s]*=' + line: '{{ item.key }} = {{ item.value }}' + insertafter: '\[global\]' + with_items: + - { key: 'error_log', value: "/docker.stderr" } + - { key: 'pid', value: "/var/run/php-fpm.pid" } + +- name: Configure php-fpm main (php 5.x) lineinfile: dest: '/opt/docker/etc/php/fpm/php-fpm.conf' regexp: '^[\s;]*{{ item.key }}[\s]*=' line: '{{ item.key }} = {{ item.value }}' + insertbefore: '[\s]*include[\s]*=' with_items: - - { key: 'error_log', value: "syslog" } - - { key: 'pid', value: "/var/run/php-fpm.pid" } + - { key: 'daemonize', value: 'no' } + when: ( php_version | version_compare('7.0.0', '<') ) diff --git a/docker/php/debian-8-php7/conf/provision/roles/webdevops-php/tasks/bootstrap/php-fpm.pool.yml b/docker/php/debian-8-php7/conf/provision/roles/webdevops-php/tasks/bootstrap/php-fpm.pool.yml index d91ecab7f..ab0b7b02c 100644 --- a/docker/php/debian-8-php7/conf/provision/roles/webdevops-php/tasks/bootstrap/php-fpm.pool.yml +++ b/docker/php/debian-8-php7/conf/provision/roles/webdevops-php/tasks/bootstrap/php-fpm.pool.yml @@ -1,44 +1,18 @@ --- -- name: Get php version - command: "php -r 'echo phpversion();'" - changed_when: true - register: php_version_cmd - ignore_errors: true -- name: Set php_version version - set_fact: - php_version: "{{php_version_cmd.stdout}}" +- set_fact: + php_clear_env_available: False -- debug: - msg: "PHP-Version: {{php_version}}" +- set_fact: + php_clear_env_available: True + when: ( php_version | version_compare('5.4', 'eq') and php_version | version_compare('5.4.27', 'ge') ) or + ( php_version | version_compare('5.5', 'eq') and php_version | version_compare('5.5.11', 'ge') ) or + ( php_version | version_compare('5.6', 'ge') ) -- name: Set php pool file - set_fact: - php_pool_conf: www.conf - php_pool_dir: /etc/php-fpm.d - when: ansible_os_family == 'RedHat' - -- name: Set php pool file - set_fact: - php_pool_conf: www.conf - php_pool_dir: /etc/php/7.0/fpm/pool.d - when: ansible_os_family == 'Debian' - -- name: Set php pool file - set_fact: - php_pool_conf: www.conf - php_pool_dir: /etc/php7/php-fpm.d - when: ansible_os_family == 'Alpine' - -- name: Create php directories +- name: Create /opt/docker/etc/php/fpm directory file: - path: "{{ item }}" + path: "/opt/docker/etc/php/fpm" state: directory - mode: 0755 - owner: "root" - group: "root" - with_items: - - /opt/docker/etc/php/fpm/ - name: Move php-fpm pool directory file to /opt/docker/etc/php/ command: "mv {{ php_pool_dir }} /opt/docker/etc/php/fpm/pool.d" @@ -55,7 +29,7 @@ path: "{{ php_pool_dir }}" state: absent -- name: Symlink php-fpm main file +- name: Symlink php-fpm pool file file: path: "{{ php_pool_dir }}" src: "/opt/docker/etc/php/fpm/pool.d" @@ -63,24 +37,60 @@ owner: "root" group: "root" - -- name: Configure php-fpm pool user (www.conf) +- name: Configure php-fpm pool user (application.conf) lineinfile: dest: '/opt/docker/etc/php/fpm/pool.d/application.conf' regexp: '^[\s;]*{{ item.key }}[\s]*=' line: '{{ item.key }} = {{ item.value }}' with_items: - - { key: 'listen', value: "0.0.0.0:9000" } + - { key: 'listen', value: "[::]:9000" } - { key: 'catch_workers_output', value: "yes" } - { key: 'access.format', value: '[php-fpm:access] %R - %u %t "%m %r%Q%q" %s %f %{mili}d %{kilo}M %C%%' } - { key: 'access.log', value: "/docker.stdout" } - { key: 'slowlog', value: "/docker.stderr" } - { key: 'php_admin_value[error_log]', value: "/docker.stderr" } - { key: 'php_admin_value[log_errors]', value: "on" } - - { key: 'clear_env', value: "no" } - { key: 'user', value: "{{ APPLICATION_USER }}" } - { key: 'group', value: "{{ APPLICATION_GROUP }}" } +- name: Configure php-fpm pool user (application.conf) + lineinfile: + dest: '/opt/docker/etc/php/fpm/pool.d/application.conf' + regexp: '^[\s;]*{{ item.key }}[\s]*=' + line: '{{ item.key }} = {{ item.value }}' + with_items: + - { key: 'listen', value: "0.0.0.0:9000" } + when: php_version | version_compare('5.5.99', '<=') + +- name: Configure php-fpm pool user (application.conf) + lineinfile: + dest: '/opt/docker/etc/php/fpm/pool.d/application.conf' + regexp: '^[\s;]*{{ item.key }}[\s]*=' + line: ';{{ item.key }} = {{ item.value }}' + with_items: + - { key: 'access.log', value: "/docker.stdout" } + +- name: Disable clear env in php-fpm pool + lineinfile: + dest: '/opt/docker/etc/php/fpm/pool.d/application.conf' + regexp: '^[\s;]*{{ item.key }}[\s]*=' + line: '{{ item.key }} = {{ item.value }}' + with_items: + - { key: 'clear_env', value: "no" } + when: php_clear_env_available == True + +- name: Remove clear env workaround + file: + path: "/opt/docker/bin/service.d/php-fpm.d/11-clear-env.sh" + state: absent + when: php_clear_env_available == True + +- name: Append clear env workaround in php-fpm pool (old php-fpm versions) + lineinfile: + dest: '/opt/docker/etc/php/fpm/pool.d/application.conf' + line: ';#CLEAR_ENV_WORKAROUND#' + when: php_clear_env_available == False + - name: Disable php-fpm connection limit lineinfile: dest: '/opt/docker/etc/php/fpm/pool.d/application.conf' diff --git a/docker/php/debian-8-php7/conf/provision/roles/webdevops-php/tasks/bootstrap/php-fpm.yml b/docker/php/debian-8-php7/conf/provision/roles/webdevops-php/tasks/bootstrap/php-fpm.yml index 130542f53..41c1b33dc 100644 --- a/docker/php/debian-8-php7/conf/provision/roles/webdevops-php/tasks/bootstrap/php-fpm.yml +++ b/docker/php/debian-8-php7/conf/provision/roles/webdevops-php/tasks/bootstrap/php-fpm.yml @@ -1,54 +1,9 @@ --- -- name: Symlink php-fpm binary [RedHat family] +- name: Symlink php-fpm binary file: - path: "/usr/sbin/php-fpm7.0" - src: "/usr/sbin/php-fpm" + path: "/usr/local/bin/php-fpm" + src: "{{ php_fpm_bin }}" state: link owner: "root" group: "root" - when: ansible_os_family == 'RedHat' - -- name: Symlink php-fpm binary [Alpine family] - file: - path: "/usr/sbin/php-fpm" - src: "/usr/sbin/php-fpm7" - state: link - owner: "root" - group: "root" - when: ansible_os_family == 'Alpine' - -- name: Symlink php-fpm binary [Debian family] - file: - path: "/usr/sbin/php-fpm" - src: "/usr/sbin/php-fpm7.0" - state: link - owner: "root" - group: "root" - when: ansible_os_family == 'Debian' - -- name: Remove default php-fpm logrotate - file: - path: "/etc/logrotate.d/php-fpm" - state: absent - when: ansible_os_family == 'RedHat' - -- name: Create php-fpm log directory - file: - path: "/var/log/php7-fpm/" - state: directory - owner: "root" - group: "root" - -- name: Create php-fpm log files - file: - path: "/var/log/php7-fpm/{{ item }}" - state: touch - owner: "root" - group: "root" - mode: 0600 - with_items: - - slow.log - - access.log - - error.log - - fpm.log diff --git a/docker/php/debian-8-php7/conf/provision/roles/webdevops-php/tasks/bootstrap/php.alpine.yml b/docker/php/debian-8-php7/conf/provision/roles/webdevops-php/tasks/bootstrap/php.alpine.yml new file mode 100644 index 000000000..4c16cdf0d --- /dev/null +++ b/docker/php/debian-8-php7/conf/provision/roles/webdevops-php/tasks/bootstrap/php.alpine.yml @@ -0,0 +1,12 @@ +--- + +- name: Create link for additional php.ini [Alpine family] + file: + src: '/opt/docker/etc/php/{{ item.file }}' + dest: '{{ php_etc_dir }}/conf.d/{{ item.target }}' + state: link + force: yes + with_items: + - { file: 'php.webdevops.ini', target: 'xzza-webdevops.ini'} + - { file: 'php.ini', target: 'xzzz-docker.ini'} + when: ansible_os_family == 'Alpine' diff --git a/docker/php/debian-8-php7/conf/provision/roles/webdevops-php/tasks/bootstrap/php.debian.yml b/docker/php/debian-8-php7/conf/provision/roles/webdevops-php/tasks/bootstrap/php.debian.yml new file mode 100644 index 000000000..d27037e33 --- /dev/null +++ b/docker/php/debian-8-php7/conf/provision/roles/webdevops-php/tasks/bootstrap/php.debian.yml @@ -0,0 +1,18 @@ +--- + +- name: Link php.ini for cli and fpm [Debian family] + file: + src: '{{ item.file }}' + dest: '{{ php_etc_dir }}/{{ item.category }}/conf.d/{{ item.target }}' + force: yes + state: link + with_items: + # PHP cli + - { category: 'cli', file: '{{ php_etc_dir }}/mods-available/mcrypt.ini', target: '20-mcrypt.ini' } + - { category: 'cli', file: '/opt/docker/etc/php/php.webdevops.ini', target: '98-webdevops.ini' } + - { category: 'cli', file: '/opt/docker/etc/php/php.ini', target: '99-docker.ini' } + # PHP fpm + - { category: 'fpm', file: '{{ php_etc_dir }}/mods-available/mcrypt.ini', target: '20-mcrypt.ini' } + - { category: 'fpm', file: '/opt/docker/etc/php/php.webdevops.ini', target: '98-webdevops.ini' } + - { category: 'fpm', file: '/opt/docker/etc/php/php.ini', target: '99-docker.ini' } + when: ansible_os_family == 'Debian' diff --git a/docker/php/debian-8-php7/conf/provision/roles/webdevops-php/tasks/bootstrap/php.redhat.yml b/docker/php/debian-8-php7/conf/provision/roles/webdevops-php/tasks/bootstrap/php.redhat.yml new file mode 100644 index 000000000..7e8810231 --- /dev/null +++ b/docker/php/debian-8-php7/conf/provision/roles/webdevops-php/tasks/bootstrap/php.redhat.yml @@ -0,0 +1,12 @@ +--- + +- name: Create link for additional php.ini [RedHat family] + file: + src: '/opt/docker/etc/php/{{ item.file }}' + dest: '/etc/php.d/{{ item.target }}' + state: link + force: yes + with_items: + - { file: 'php.webdevops.ini', target: 'zza-webdevops.ini'} + - { file: 'php.ini', target: 'zzz-docker.ini'} + when: ansible_os_family == 'RedHat' diff --git a/docker/php/debian-8-php7/conf/provision/roles/webdevops-php/tasks/bootstrap/php.yml b/docker/php/debian-8-php7/conf/provision/roles/webdevops-php/tasks/bootstrap/php.yml index 97f02eec3..caac8f413 100644 --- a/docker/php/debian-8-php7/conf/provision/roles/webdevops-php/tasks/bootstrap/php.yml +++ b/docker/php/debian-8-php7/conf/provision/roles/webdevops-php/tasks/bootstrap/php.yml @@ -11,7 +11,7 @@ - /opt/docker/etc/php/ - /opt/docker/etc/php/fpm/ -- name: Create /opt/docker/etc/php/php.ini" +- name: Create php.ini files file: path: "{{ item }}" state: touch @@ -21,40 +21,3 @@ with_items: - "/opt/docker/etc/php/php.webdevops.ini" - "/opt/docker/etc/php/php.ini" - -- name: Link php.ini for cli and fpm - file: - src: '{{ item.file }}' - dest: '/etc/php/7.0/{{ item.category }}/conf.d/{{ item.target }}' - force: yes - state: link - with_items: - # PHP cli - - { category: 'cli', file: '/opt/docker/etc/php/php.webdevops.ini', target: '98-webdevops.ini' } - - { category: 'cli', file: '/opt/docker/etc/php/php.ini', target: '99-docker.ini' } - # PHP fpm - - { category: 'fpm', file: '/opt/docker/etc/php/php.webdevops.ini', target: '98-webdevops.ini' } - - { category: 'fpm', file: '/opt/docker/etc/php/php.ini', target: '99-docker.ini' } - when: ansible_os_family == 'Debian' - -- name: Create link for additional php.ini [RedHat family] - file: - src: '/opt/docker/etc/php/{{ item.file }}' - dest: '/etc/php.d/{{ item.target }}' - state: link - force: yes - with_items: - - { file: 'php.webdevops.ini', target: 'zza-webdevops.ini'} - - { file: 'php.ini', target: 'zzz-docker.ini'} - when: ansible_os_family == 'RedHat' - -- name: Link php.ini - file: - src: '/opt/docker/etc/php/{{ item.file }}' - dest: '/etc/php7/conf.d/{{ item.target }}' - force: yes - state: link - with_items: - - { file: 'php.webdevops.ini', target: 'xzza-webdevops.ini'} - - { file: 'php.ini', target: 'xzzz-docker.ini'} - when: ansible_os_family == 'Alpine' diff --git a/docker/php/debian-8/Dockerfile b/docker/php/debian-8/Dockerfile index 142fd95b3..a28b2e17f 100644 --- a/docker/php/debian-8/Dockerfile +++ b/docker/php/debian-8/Dockerfile @@ -5,14 +5,9 @@ FROM webdevops/base-app:debian-8 -MAINTAINER info@webdevops.io -LABEL vendor=WebDevOps.io -LABEL io.webdevops.layout=8 -LABEL io.webdevops.version=1.5.0 - -ENV WEB_DOCUMENT_ROOT /app -ENV WEB_DOCUMENT_INDEX index.php -ENV WEB_ALIAS_DOMAIN *.vm +ENV WEB_DOCUMENT_ROOT=/app \ + WEB_DOCUMENT_INDEX=index.php \ + WEB_ALIAS_DOMAIN=*.vm COPY conf/ /opt/docker/ @@ -48,8 +43,10 @@ RUN /usr/local/bin/apt-install \ && ln -sf /etc/php5/mods-available/mcrypt.in /etc/php5/cli/conf.d/20-mcrypt.ini \ && ln -sf /etc/php5/mods-available/mcrypt.in /etc/php5/fpm/conf.d/20-mcrypt.ini \ && curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin/ --filename=composer \ + # Enable php services + && docker-service-enable syslog cron \ && /opt/docker/bin/provision run --tag bootstrap --role webdevops-php \ - && /opt/docker/bin/bootstrap.sh - + && /opt/docker/bin/bootstrap.sh \ + && docker-image-cleanup EXPOSE 9000 diff --git a/docker/php/debian-8/Dockerfile.jinja2 b/docker/php/debian-8/Dockerfile.jinja2 index 27a370861..03dacf80e 100644 --- a/docker/php/debian-8/Dockerfile.jinja2 +++ b/docker/php/debian-8/Dockerfile.jinja2 @@ -1,7 +1,5 @@ {{ docker.from("base-app", "debian-8") }} -{{ docker.version() }} - {{ environment.web() }} {{ docker.copy('conf/', '/opt/docker/') }} diff --git a/docker/php/debian-8/conf/bin/service.d/php-fpm.d/11-clear-env.sh b/docker/php/debian-8/conf/bin/service.d/php-fpm.d/11-clear-env.sh index b17280ce6..ef6fd4016 100644 --- a/docker/php/debian-8/conf/bin/service.d/php-fpm.d/11-clear-env.sh +++ b/docker/php/debian-8/conf/bin/service.d/php-fpm.d/11-clear-env.sh @@ -30,5 +30,9 @@ for envVariable in $(printenv|cut -f1 -d=); do done # Replace ;#CLEAR_ENV_WORKAROUND# with environment variable list for all php-fpm pool files -find /opt/docker/etc/php/fpm/pool.d/ -iname '*.conf' -print0 | xargs -0 -r rpl --quiet ";#CLEAR_ENV_WORKAROUND#" "$VARIABLE_LIST" > /dev/null +go-replace \ + -s ";#CLEAR_ENV_WORKAROUND#" -r "$VARIABLE_LIST" \ + --path=/opt/docker/etc/php/fpm/pool.d/ \ + --path-pattern='*.conf' \ + --ignore-empty diff --git a/docker/php/debian-8/conf/bin/service.d/php-fpm.sh b/docker/php/debian-8/conf/bin/service.d/php-fpm.sh index 571f248d2..b25983bd3 100644 --- a/docker/php/debian-8/conf/bin/service.d/php-fpm.sh +++ b/docker/php/debian-8/conf/bin/service.d/php-fpm.sh @@ -4,4 +4,4 @@ source /opt/docker/bin/config.sh includeScriptDir "/opt/docker/bin/service.d/php-fpm.d/" -exec /usr/sbin/php-fpm --nodaemonize +exec /usr/local/bin/php-fpm --nodaemonize diff --git a/docker/php/debian-8/conf/etc/php/php.webdevops.ini b/docker/php/debian-8/conf/etc/php/php.webdevops.ini index 562b8d7e2..aa1545ab8 100644 --- a/docker/php/debian-8/conf/etc/php/php.webdevops.ini +++ b/docker/php/debian-8/conf/etc/php/php.webdevops.ini @@ -5,6 +5,7 @@ ; this file will overwrite default php.ini settings display_errors = 0 +log_errors = 1 short_open_tag = Off variables_order = 'GPCS' diff --git a/docker/php/debian-8/conf/provision/roles/webdevops-php/tasks/bootstrap.yml b/docker/php/debian-8/conf/provision/roles/webdevops-php/tasks/bootstrap.yml index 5883fa1fe..99a2e5191 100644 --- a/docker/php/debian-8/conf/provision/roles/webdevops-php/tasks/bootstrap.yml +++ b/docker/php/debian-8/conf/provision/roles/webdevops-php/tasks/bootstrap.yml @@ -1,6 +1,10 @@ --- +- include: bootstrap/init.yml - include: bootstrap/php.yml +- include: bootstrap/php.debian.yml +- include: bootstrap/php.redhat.yml +- include: bootstrap/php.alpine.yml - include: bootstrap/php-fpm.main.yml - include: bootstrap/php-fpm.pool.yml - include: bootstrap/php-fpm.yml diff --git a/docker/php/debian-8/conf/provision/roles/webdevops-php/tasks/bootstrap/init.yml b/docker/php/debian-8/conf/provision/roles/webdevops-php/tasks/bootstrap/init.yml new file mode 100644 index 000000000..a48bec675 --- /dev/null +++ b/docker/php/debian-8/conf/provision/roles/webdevops-php/tasks/bootstrap/init.yml @@ -0,0 +1,71 @@ +--- + +- name: Get php version + command: "php -r 'echo phpversion();'" + changed_when: true + register: php_version_cmd + ignore_errors: true + +- name: Set php_version version + set_fact: + php_version: "{{php_version_cmd.stdout}}" + +############################# +# PHP 5.x +############################# + +- name: Set php main file (RedHat, PHP 5.x) + set_fact: + php_main_conf: /etc/php-fpm.conf + php_pool_conf: www.conf + php_pool_dir: /etc/php-fpm.d + php_fpm_bin: /usr/sbin/php-fpm + when: ansible_os_family == 'RedHat' and ( php_version | version_compare('7.0.0', '<') ) + +- name: Set php main file (Debian, PHP 5.x) + set_fact: + php_etc_dir: /etc/php5 + php_main_conf: /etc/php5/fpm/php-fpm.conf + php_pool_conf: www.conf + php_pool_dir: /etc/php5/fpm/pool.d + php_fpm_bin: /usr/sbin/php5-fpm + when: ansible_os_family == 'Debian' and ( php_version | version_compare('7.0.0', '<') ) + +- name: Set php main file (Alpine, PHP 5.x) + set_fact: + php_etc_dir: /etc/php5 + php_main_conf: /etc/php5/php-fpm.conf + php_pool_conf: www.conf + php_pool_dir: /etc/php5/fpm.d + php_fpm_bin: /usr/bin/php-fpm5 + when: ansible_os_family == 'Alpine' and ( php_version | version_compare('7.0.0', '<') ) + +############################# +# PHP 7.x +############################# + +- name: Set php main file (RedHat, PHP 7.x) + set_fact: + php_main_conf: /etc/php-fpm.conf + php_pool_conf: www.conf + php_pool_dir: /etc/php-fpm.d + php_fpm_bin: /usr/sbin/php-fpm + when: ansible_os_family == 'RedHat' and ( php_version | version_compare('7.0.0', '>=') ) and ( php_version | version_compare('8.0.0', '<') ) + +- name: Set php main file (Debian, PHP 7.x) + set_fact: + php_etc_dir: /etc/php/7.0 + php_main_conf: /etc/php/7.0/fpm/php-fpm.conf + php_pool_conf: www.conf + php_pool_dir: /etc/php/7.0/fpm/pool.d + php_fpm_bin: /usr/sbin/php-fpm7.0 + when: ansible_os_family == 'Debian' and ( php_version | version_compare('7.0.0', '>=') ) and ( php_version | version_compare('8.0.0', '<') ) + +- name: Set php main file (Alpine, PHP 7.x) + set_fact: + php_etc_dir: /etc/php7 + php_main_conf: /etc/php7/php-fpm.conf + php_pool_conf: www.conf + php_pool_dir: /etc/php7/php-fpm.d + php_fpm_bin: /usr/sbin/php-fpm7 + when: ansible_os_family == 'Alpine' and ( php_version | version_compare('7.0.0', '>=') ) and ( php_version | version_compare('8.0.0', '<') ) diff --git a/docker/php/debian-8/conf/provision/roles/webdevops-php/tasks/bootstrap/php-fpm.main.yml b/docker/php/debian-8/conf/provision/roles/webdevops-php/tasks/bootstrap/php-fpm.main.yml index 1a2c7861f..c149d8728 100644 --- a/docker/php/debian-8/conf/provision/roles/webdevops-php/tasks/bootstrap/php-fpm.main.yml +++ b/docker/php/debian-8/conf/provision/roles/webdevops-php/tasks/bootstrap/php-fpm.main.yml @@ -1,19 +1,14 @@ --- -- name: Set php main file - set_fact: - php_main_conf: /etc/php-fpm.conf - when: ansible_os_family == 'RedHat' - -- name: Set php main file - set_fact: - php_main_conf: /etc/php5/fpm/php-fpm.conf - when: ansible_os_family == 'Debian' - -- name: Set php main file - set_fact: - php_main_conf: /etc/php5/php-fpm.conf - when: ansible_os_family == 'Alpine' +- name: Create php directories + file: + path: "{{ item }}" + state: directory + mode: 0755 + owner: "root" + group: "root" + with_items: + - /opt/docker/etc/php/fpm/ - name: Move php-fpm main file to /opt/docker/etc/php/fpm/ command: "mv {{ php_main_conf }} /opt/docker/etc/php/fpm/php-fpm.conf" @@ -33,12 +28,22 @@ owner: "root" group: "root" -- name: Configure php-fpm main +- name: Configure php-fpm main (all versions) lineinfile: dest: '/opt/docker/etc/php/fpm/php-fpm.conf' regexp: '^[\s;]*{{ item.key }}[\s]*=' line: '{{ item.key }} = {{ item.value }}' + insertafter: '\[global\]' with_items: - - { key: 'error_log', value: "syslog" } + - { key: 'error_log', value: "/docker.stderr" } - { key: 'pid', value: "/var/run/php-fpm.pid" } + +- name: Configure php-fpm main (php 5.x) + lineinfile: + dest: '/opt/docker/etc/php/fpm/php-fpm.conf' + regexp: '^[\s;]*{{ item.key }}[\s]*=' + line: '{{ item.key }} = {{ item.value }}' + insertbefore: '[\s]*include[\s]*=' + with_items: - { key: 'daemonize', value: 'no' } + when: ( php_version | version_compare('7.0.0', '<') ) diff --git a/docker/php/debian-8/conf/provision/roles/webdevops-php/tasks/bootstrap/php-fpm.pool.yml b/docker/php/debian-8/conf/provision/roles/webdevops-php/tasks/bootstrap/php-fpm.pool.yml index 53ee9dfe1..ab0b7b02c 100644 --- a/docker/php/debian-8/conf/provision/roles/webdevops-php/tasks/bootstrap/php-fpm.pool.yml +++ b/docker/php/debian-8/conf/provision/roles/webdevops-php/tasks/bootstrap/php-fpm.pool.yml @@ -1,18 +1,5 @@ --- -- name: Get php version - command: "php -r 'echo phpversion();'" - changed_when: true - register: php_version_cmd - ignore_errors: true - -- name: Set php_version version - set_fact: - php_version: "{{php_version_cmd.stdout}}" - -- debug: - msg: "PHP-Version: {{php_version}}" - - set_fact: php_clear_env_available: False @@ -22,23 +9,10 @@ ( php_version | version_compare('5.5', 'eq') and php_version | version_compare('5.5.11', 'ge') ) or ( php_version | version_compare('5.6', 'ge') ) -- name: Set php pool file - set_fact: - php_pool_conf: www.conf - php_pool_dir: /etc/php-fpm.d - when: ansible_os_family == 'RedHat' - -- name: Set php pool file - set_fact: - php_pool_conf: www.conf - php_pool_dir: /etc/php5/fpm/pool.d - when: ansible_os_family == 'Debian' - -- name: Set php pool file - set_fact: - php_pool_conf: www.conf - php_pool_dir: /etc/php5/fpm.d - when: ansible_os_family == 'Alpine' +- name: Create /opt/docker/etc/php/fpm directory + file: + path: "/opt/docker/etc/php/fpm" + state: directory - name: Move php-fpm pool directory file to /opt/docker/etc/php/ command: "mv {{ php_pool_dir }} /opt/docker/etc/php/fpm/pool.d" @@ -55,7 +29,7 @@ path: "{{ php_pool_dir }}" state: absent -- name: Symlink php-fpm main file +- name: Symlink php-fpm pool file file: path: "{{ php_pool_dir }}" src: "/opt/docker/etc/php/fpm/pool.d" @@ -69,15 +43,25 @@ regexp: '^[\s;]*{{ item.key }}[\s]*=' line: '{{ item.key }} = {{ item.value }}' with_items: - - { key: 'listen', value: "0.0.0.0:9000" } + - { key: 'listen', value: "[::]:9000" } - { key: 'catch_workers_output', value: "yes" } - { key: 'access.format', value: '[php-fpm:access] %R - %u %t "%m %r%Q%q" %s %f %{mili}d %{kilo}M %C%%' } + - { key: 'access.log', value: "/docker.stdout" } - { key: 'slowlog', value: "/docker.stderr" } - { key: 'php_admin_value[error_log]', value: "/docker.stderr" } - { key: 'php_admin_value[log_errors]', value: "on" } - { key: 'user', value: "{{ APPLICATION_USER }}" } - { key: 'group', value: "{{ APPLICATION_GROUP }}" } +- name: Configure php-fpm pool user (application.conf) + lineinfile: + dest: '/opt/docker/etc/php/fpm/pool.d/application.conf' + regexp: '^[\s;]*{{ item.key }}[\s]*=' + line: '{{ item.key }} = {{ item.value }}' + with_items: + - { key: 'listen', value: "0.0.0.0:9000" } + when: php_version | version_compare('5.5.99', '<=') + - name: Configure php-fpm pool user (application.conf) lineinfile: dest: '/opt/docker/etc/php/fpm/pool.d/application.conf' diff --git a/docker/php/debian-8/conf/provision/roles/webdevops-php/tasks/bootstrap/php-fpm.yml b/docker/php/debian-8/conf/provision/roles/webdevops-php/tasks/bootstrap/php-fpm.yml index d83edb3ae..41c1b33dc 100644 --- a/docker/php/debian-8/conf/provision/roles/webdevops-php/tasks/bootstrap/php-fpm.yml +++ b/docker/php/debian-8/conf/provision/roles/webdevops-php/tasks/bootstrap/php-fpm.yml @@ -1,45 +1,9 @@ --- -- name: Symlink php-fpm binary [Alpine family] +- name: Symlink php-fpm binary file: - path: "/usr/sbin/php-fpm" - src: "/usr/bin/php-fpm" + path: "/usr/local/bin/php-fpm" + src: "{{ php_fpm_bin }}" state: link owner: "root" group: "root" - when: ansible_os_family == 'Alpine' - -- name: Symlink php-fpm binary [Debian family] - file: - path: "/usr/sbin/php-fpm" - src: "/usr/sbin/php5-fpm" - state: link - owner: "root" - group: "root" - when: ansible_os_family == 'Debian' - -- name: Remove default php-fpm logrotate - file: - path: "/etc/logrotate.d/php-fpm" - state: absent - when: ansible_os_family == 'RedHat' - -- name: Create php-fpm log directory - file: - path: "/var/log/php5-fpm/" - state: directory - owner: "root" - group: "root" - -- name: Create php-fpm log files - file: - path: "/var/log/php5-fpm/{{ item }}" - state: touch - owner: "root" - group: "root" - mode: 0600 - with_items: - - slow.log - - access.log - - error.log - - fpm.log diff --git a/docker/php/debian-8/conf/provision/roles/webdevops-php/tasks/bootstrap/php.alpine.yml b/docker/php/debian-8/conf/provision/roles/webdevops-php/tasks/bootstrap/php.alpine.yml new file mode 100644 index 000000000..4c16cdf0d --- /dev/null +++ b/docker/php/debian-8/conf/provision/roles/webdevops-php/tasks/bootstrap/php.alpine.yml @@ -0,0 +1,12 @@ +--- + +- name: Create link for additional php.ini [Alpine family] + file: + src: '/opt/docker/etc/php/{{ item.file }}' + dest: '{{ php_etc_dir }}/conf.d/{{ item.target }}' + state: link + force: yes + with_items: + - { file: 'php.webdevops.ini', target: 'xzza-webdevops.ini'} + - { file: 'php.ini', target: 'xzzz-docker.ini'} + when: ansible_os_family == 'Alpine' diff --git a/docker/php/debian-8/conf/provision/roles/webdevops-php/tasks/bootstrap/php.debian.yml b/docker/php/debian-8/conf/provision/roles/webdevops-php/tasks/bootstrap/php.debian.yml new file mode 100644 index 000000000..d27037e33 --- /dev/null +++ b/docker/php/debian-8/conf/provision/roles/webdevops-php/tasks/bootstrap/php.debian.yml @@ -0,0 +1,18 @@ +--- + +- name: Link php.ini for cli and fpm [Debian family] + file: + src: '{{ item.file }}' + dest: '{{ php_etc_dir }}/{{ item.category }}/conf.d/{{ item.target }}' + force: yes + state: link + with_items: + # PHP cli + - { category: 'cli', file: '{{ php_etc_dir }}/mods-available/mcrypt.ini', target: '20-mcrypt.ini' } + - { category: 'cli', file: '/opt/docker/etc/php/php.webdevops.ini', target: '98-webdevops.ini' } + - { category: 'cli', file: '/opt/docker/etc/php/php.ini', target: '99-docker.ini' } + # PHP fpm + - { category: 'fpm', file: '{{ php_etc_dir }}/mods-available/mcrypt.ini', target: '20-mcrypt.ini' } + - { category: 'fpm', file: '/opt/docker/etc/php/php.webdevops.ini', target: '98-webdevops.ini' } + - { category: 'fpm', file: '/opt/docker/etc/php/php.ini', target: '99-docker.ini' } + when: ansible_os_family == 'Debian' diff --git a/docker/php/debian-8/conf/provision/roles/webdevops-php/tasks/bootstrap/php.redhat.yml b/docker/php/debian-8/conf/provision/roles/webdevops-php/tasks/bootstrap/php.redhat.yml new file mode 100644 index 000000000..7e8810231 --- /dev/null +++ b/docker/php/debian-8/conf/provision/roles/webdevops-php/tasks/bootstrap/php.redhat.yml @@ -0,0 +1,12 @@ +--- + +- name: Create link for additional php.ini [RedHat family] + file: + src: '/opt/docker/etc/php/{{ item.file }}' + dest: '/etc/php.d/{{ item.target }}' + state: link + force: yes + with_items: + - { file: 'php.webdevops.ini', target: 'zza-webdevops.ini'} + - { file: 'php.ini', target: 'zzz-docker.ini'} + when: ansible_os_family == 'RedHat' diff --git a/docker/php/debian-8/conf/provision/roles/webdevops-php/tasks/bootstrap/php.yml b/docker/php/debian-8/conf/provision/roles/webdevops-php/tasks/bootstrap/php.yml index 9816b2538..caac8f413 100644 --- a/docker/php/debian-8/conf/provision/roles/webdevops-php/tasks/bootstrap/php.yml +++ b/docker/php/debian-8/conf/provision/roles/webdevops-php/tasks/bootstrap/php.yml @@ -21,42 +21,3 @@ with_items: - "/opt/docker/etc/php/php.webdevops.ini" - "/opt/docker/etc/php/php.ini" - -- name: Link php.ini for cli and fpm [Debian family] - file: - src: '{{ item.file }}' - dest: '/etc/php5/{{ item.category }}/conf.d/{{ item.target }}' - force: yes - state: link - with_items: - # PHP cli - - { category: 'cli', file: '/etc/php5/mods-available/mcrypt.ini', target: '20-mcrypt.ini' } - - { category: 'cli', file: '/opt/docker/etc/php/php.webdevops.ini', target: '98-webdevops.ini' } - - { category: 'cli', file: '/opt/docker/etc/php/php.ini', target: '99-docker.ini' } - # PHP fpm - - { category: 'fpm', file: '/etc/php5/mods-available/mcrypt.ini', target: '20-mcrypt.ini' } - - { category: 'fpm', file: '/opt/docker/etc/php/php.webdevops.ini', target: '98-webdevops.ini' } - - { category: 'fpm', file: '/opt/docker/etc/php/php.ini', target: '99-docker.ini' } - when: ansible_os_family == 'Debian' - -- name: Create link for additional php.ini [RedHat family] - file: - src: '/opt/docker/etc/php/{{ item.file }}' - dest: '/etc/php.d/{{ item.target }}' - state: link - force: yes - with_items: - - { file: 'php.webdevops.ini', target: 'zza-webdevops.ini'} - - { file: 'php.ini', target: 'zzz-docker.ini'} - when: ansible_os_family == 'RedHat' - -- name: Create link for additional php.ini [Alpine family] - file: - src: '/opt/docker/etc/php/{{ item.file }}' - dest: '/etc/php5/conf.d/{{ item.target }}' - state: link - force: yes - with_items: - - { file: 'php.webdevops.ini', target: 'xzza-webdevops.ini'} - - { file: 'php.ini', target: 'xzzz-docker.ini'} - when: ansible_os_family == 'Alpine' diff --git a/docker/php/debian-9/Dockerfile b/docker/php/debian-9/Dockerfile index 570de67be..515c2546e 100644 --- a/docker/php/debian-9/Dockerfile +++ b/docker/php/debian-9/Dockerfile @@ -5,14 +5,9 @@ FROM webdevops/base-app:debian-9 -MAINTAINER info@webdevops.io -LABEL vendor=WebDevOps.io -LABEL io.webdevops.layout=8 -LABEL io.webdevops.version=1.5.0 - -ENV WEB_DOCUMENT_ROOT /app -ENV WEB_DOCUMENT_INDEX index.php -ENV WEB_ALIAS_DOMAIN *.vm +ENV WEB_DOCUMENT_ROOT=/app \ + WEB_DOCUMENT_INDEX=index.php \ + WEB_ALIAS_DOMAIN=*.vm COPY conf/ /opt/docker/ @@ -46,8 +41,10 @@ RUN /usr/local/bin/apt-install \ php-memcache \ php-memcached \ && curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin/ --filename=composer \ + # Enable php services + && docker-service-enable syslog cron \ && /opt/docker/bin/provision run --tag bootstrap --role webdevops-php \ - && /opt/docker/bin/bootstrap.sh - + && /opt/docker/bin/bootstrap.sh \ + && docker-image-cleanup EXPOSE 9000 diff --git a/docker/php/debian-9/Dockerfile.jinja2 b/docker/php/debian-9/Dockerfile.jinja2 index 43a1866d3..0e9ea8c0a 100644 --- a/docker/php/debian-9/Dockerfile.jinja2 +++ b/docker/php/debian-9/Dockerfile.jinja2 @@ -1,7 +1,5 @@ {{ docker.from("base-app", "debian-9") }} -{{ docker.version() }} - {{ environment.web() }} {{ docker.copy('conf/', '/opt/docker/') }} diff --git a/docker/php/debian-9/conf/bin/service.d/php-fpm.d/11-clear-env.sh b/docker/php/debian-9/conf/bin/service.d/php-fpm.d/11-clear-env.sh index b17280ce6..ef6fd4016 100644 --- a/docker/php/debian-9/conf/bin/service.d/php-fpm.d/11-clear-env.sh +++ b/docker/php/debian-9/conf/bin/service.d/php-fpm.d/11-clear-env.sh @@ -30,5 +30,9 @@ for envVariable in $(printenv|cut -f1 -d=); do done # Replace ;#CLEAR_ENV_WORKAROUND# with environment variable list for all php-fpm pool files -find /opt/docker/etc/php/fpm/pool.d/ -iname '*.conf' -print0 | xargs -0 -r rpl --quiet ";#CLEAR_ENV_WORKAROUND#" "$VARIABLE_LIST" > /dev/null +go-replace \ + -s ";#CLEAR_ENV_WORKAROUND#" -r "$VARIABLE_LIST" \ + --path=/opt/docker/etc/php/fpm/pool.d/ \ + --path-pattern='*.conf' \ + --ignore-empty diff --git a/docker/php/debian-9/conf/bin/service.d/php-fpm.sh b/docker/php/debian-9/conf/bin/service.d/php-fpm.sh index 571f248d2..b25983bd3 100644 --- a/docker/php/debian-9/conf/bin/service.d/php-fpm.sh +++ b/docker/php/debian-9/conf/bin/service.d/php-fpm.sh @@ -4,4 +4,4 @@ source /opt/docker/bin/config.sh includeScriptDir "/opt/docker/bin/service.d/php-fpm.d/" -exec /usr/sbin/php-fpm --nodaemonize +exec /usr/local/bin/php-fpm --nodaemonize diff --git a/docker/php/debian-9/conf/etc/logrotate.d/php7-fpm b/docker/php/debian-9/conf/etc/logrotate.d/php7-fpm deleted file mode 100644 index 668f2545f..000000000 --- a/docker/php/debian-9/conf/etc/logrotate.d/php7-fpm +++ /dev/null @@ -1,12 +0,0 @@ -/var/log/php7-fpm/fpm.log -/var/log/php7-fpm/access.log -/var/log/php7-fpm/slow.log -/var/log/php7-fpm/error.log { - missingok - notifempty - sharedscripts - delaycompress - postrotate - /bin/kill -SIGUSR1 `cat /var/run/php7-fpm.pid` 2>/dev/null || true - endscript -} diff --git a/docker/php/debian-9/conf/etc/php/php.webdevops.ini b/docker/php/debian-9/conf/etc/php/php.webdevops.ini index 562b8d7e2..aa1545ab8 100644 --- a/docker/php/debian-9/conf/etc/php/php.webdevops.ini +++ b/docker/php/debian-9/conf/etc/php/php.webdevops.ini @@ -5,6 +5,7 @@ ; this file will overwrite default php.ini settings display_errors = 0 +log_errors = 1 short_open_tag = Off variables_order = 'GPCS' diff --git a/docker/php/debian-9/conf/provision/roles/webdevops-php/tasks/bootstrap.yml b/docker/php/debian-9/conf/provision/roles/webdevops-php/tasks/bootstrap.yml index 5883fa1fe..99a2e5191 100644 --- a/docker/php/debian-9/conf/provision/roles/webdevops-php/tasks/bootstrap.yml +++ b/docker/php/debian-9/conf/provision/roles/webdevops-php/tasks/bootstrap.yml @@ -1,6 +1,10 @@ --- +- include: bootstrap/init.yml - include: bootstrap/php.yml +- include: bootstrap/php.debian.yml +- include: bootstrap/php.redhat.yml +- include: bootstrap/php.alpine.yml - include: bootstrap/php-fpm.main.yml - include: bootstrap/php-fpm.pool.yml - include: bootstrap/php-fpm.yml diff --git a/docker/php/debian-9/conf/provision/roles/webdevops-php/tasks/bootstrap/init.yml b/docker/php/debian-9/conf/provision/roles/webdevops-php/tasks/bootstrap/init.yml new file mode 100644 index 000000000..a48bec675 --- /dev/null +++ b/docker/php/debian-9/conf/provision/roles/webdevops-php/tasks/bootstrap/init.yml @@ -0,0 +1,71 @@ +--- + +- name: Get php version + command: "php -r 'echo phpversion();'" + changed_when: true + register: php_version_cmd + ignore_errors: true + +- name: Set php_version version + set_fact: + php_version: "{{php_version_cmd.stdout}}" + +############################# +# PHP 5.x +############################# + +- name: Set php main file (RedHat, PHP 5.x) + set_fact: + php_main_conf: /etc/php-fpm.conf + php_pool_conf: www.conf + php_pool_dir: /etc/php-fpm.d + php_fpm_bin: /usr/sbin/php-fpm + when: ansible_os_family == 'RedHat' and ( php_version | version_compare('7.0.0', '<') ) + +- name: Set php main file (Debian, PHP 5.x) + set_fact: + php_etc_dir: /etc/php5 + php_main_conf: /etc/php5/fpm/php-fpm.conf + php_pool_conf: www.conf + php_pool_dir: /etc/php5/fpm/pool.d + php_fpm_bin: /usr/sbin/php5-fpm + when: ansible_os_family == 'Debian' and ( php_version | version_compare('7.0.0', '<') ) + +- name: Set php main file (Alpine, PHP 5.x) + set_fact: + php_etc_dir: /etc/php5 + php_main_conf: /etc/php5/php-fpm.conf + php_pool_conf: www.conf + php_pool_dir: /etc/php5/fpm.d + php_fpm_bin: /usr/bin/php-fpm5 + when: ansible_os_family == 'Alpine' and ( php_version | version_compare('7.0.0', '<') ) + +############################# +# PHP 7.x +############################# + +- name: Set php main file (RedHat, PHP 7.x) + set_fact: + php_main_conf: /etc/php-fpm.conf + php_pool_conf: www.conf + php_pool_dir: /etc/php-fpm.d + php_fpm_bin: /usr/sbin/php-fpm + when: ansible_os_family == 'RedHat' and ( php_version | version_compare('7.0.0', '>=') ) and ( php_version | version_compare('8.0.0', '<') ) + +- name: Set php main file (Debian, PHP 7.x) + set_fact: + php_etc_dir: /etc/php/7.0 + php_main_conf: /etc/php/7.0/fpm/php-fpm.conf + php_pool_conf: www.conf + php_pool_dir: /etc/php/7.0/fpm/pool.d + php_fpm_bin: /usr/sbin/php-fpm7.0 + when: ansible_os_family == 'Debian' and ( php_version | version_compare('7.0.0', '>=') ) and ( php_version | version_compare('8.0.0', '<') ) + +- name: Set php main file (Alpine, PHP 7.x) + set_fact: + php_etc_dir: /etc/php7 + php_main_conf: /etc/php7/php-fpm.conf + php_pool_conf: www.conf + php_pool_dir: /etc/php7/php-fpm.d + php_fpm_bin: /usr/sbin/php-fpm7 + when: ansible_os_family == 'Alpine' and ( php_version | version_compare('7.0.0', '>=') ) and ( php_version | version_compare('8.0.0', '<') ) diff --git a/docker/php/debian-9/conf/provision/roles/webdevops-php/tasks/bootstrap/php-fpm.main.yml b/docker/php/debian-9/conf/provision/roles/webdevops-php/tasks/bootstrap/php-fpm.main.yml index 36143a96f..c149d8728 100644 --- a/docker/php/debian-9/conf/provision/roles/webdevops-php/tasks/bootstrap/php-fpm.main.yml +++ b/docker/php/debian-9/conf/provision/roles/webdevops-php/tasks/bootstrap/php-fpm.main.yml @@ -1,20 +1,5 @@ --- -- name: Set php main file - set_fact: - php_main_conf: /etc/php-fpm.conf - when: ansible_os_family == 'RedHat' - -- name: Set php main file - set_fact: - php_main_conf: /etc/php/7.0/fpm/php-fpm.conf - when: ansible_os_family == 'Debian' - -- name: Set php main file - set_fact: - php_main_conf: /etc/php7/php-fpm.conf - when: ansible_os_family == 'Alpine' - - name: Create php directories file: path: "{{ item }}" @@ -43,11 +28,22 @@ owner: "root" group: "root" -- name: Configure php-fpm main +- name: Configure php-fpm main (all versions) + lineinfile: + dest: '/opt/docker/etc/php/fpm/php-fpm.conf' + regexp: '^[\s;]*{{ item.key }}[\s]*=' + line: '{{ item.key }} = {{ item.value }}' + insertafter: '\[global\]' + with_items: + - { key: 'error_log', value: "/docker.stderr" } + - { key: 'pid', value: "/var/run/php-fpm.pid" } + +- name: Configure php-fpm main (php 5.x) lineinfile: dest: '/opt/docker/etc/php/fpm/php-fpm.conf' regexp: '^[\s;]*{{ item.key }}[\s]*=' line: '{{ item.key }} = {{ item.value }}' + insertbefore: '[\s]*include[\s]*=' with_items: - - { key: 'error_log', value: "syslog" } - - { key: 'pid', value: "/var/run/php-fpm.pid" } + - { key: 'daemonize', value: 'no' } + when: ( php_version | version_compare('7.0.0', '<') ) diff --git a/docker/php/debian-9/conf/provision/roles/webdevops-php/tasks/bootstrap/php-fpm.pool.yml b/docker/php/debian-9/conf/provision/roles/webdevops-php/tasks/bootstrap/php-fpm.pool.yml index d91ecab7f..ab0b7b02c 100644 --- a/docker/php/debian-9/conf/provision/roles/webdevops-php/tasks/bootstrap/php-fpm.pool.yml +++ b/docker/php/debian-9/conf/provision/roles/webdevops-php/tasks/bootstrap/php-fpm.pool.yml @@ -1,44 +1,18 @@ --- -- name: Get php version - command: "php -r 'echo phpversion();'" - changed_when: true - register: php_version_cmd - ignore_errors: true -- name: Set php_version version - set_fact: - php_version: "{{php_version_cmd.stdout}}" +- set_fact: + php_clear_env_available: False -- debug: - msg: "PHP-Version: {{php_version}}" +- set_fact: + php_clear_env_available: True + when: ( php_version | version_compare('5.4', 'eq') and php_version | version_compare('5.4.27', 'ge') ) or + ( php_version | version_compare('5.5', 'eq') and php_version | version_compare('5.5.11', 'ge') ) or + ( php_version | version_compare('5.6', 'ge') ) -- name: Set php pool file - set_fact: - php_pool_conf: www.conf - php_pool_dir: /etc/php-fpm.d - when: ansible_os_family == 'RedHat' - -- name: Set php pool file - set_fact: - php_pool_conf: www.conf - php_pool_dir: /etc/php/7.0/fpm/pool.d - when: ansible_os_family == 'Debian' - -- name: Set php pool file - set_fact: - php_pool_conf: www.conf - php_pool_dir: /etc/php7/php-fpm.d - when: ansible_os_family == 'Alpine' - -- name: Create php directories +- name: Create /opt/docker/etc/php/fpm directory file: - path: "{{ item }}" + path: "/opt/docker/etc/php/fpm" state: directory - mode: 0755 - owner: "root" - group: "root" - with_items: - - /opt/docker/etc/php/fpm/ - name: Move php-fpm pool directory file to /opt/docker/etc/php/ command: "mv {{ php_pool_dir }} /opt/docker/etc/php/fpm/pool.d" @@ -55,7 +29,7 @@ path: "{{ php_pool_dir }}" state: absent -- name: Symlink php-fpm main file +- name: Symlink php-fpm pool file file: path: "{{ php_pool_dir }}" src: "/opt/docker/etc/php/fpm/pool.d" @@ -63,24 +37,60 @@ owner: "root" group: "root" - -- name: Configure php-fpm pool user (www.conf) +- name: Configure php-fpm pool user (application.conf) lineinfile: dest: '/opt/docker/etc/php/fpm/pool.d/application.conf' regexp: '^[\s;]*{{ item.key }}[\s]*=' line: '{{ item.key }} = {{ item.value }}' with_items: - - { key: 'listen', value: "0.0.0.0:9000" } + - { key: 'listen', value: "[::]:9000" } - { key: 'catch_workers_output', value: "yes" } - { key: 'access.format', value: '[php-fpm:access] %R - %u %t "%m %r%Q%q" %s %f %{mili}d %{kilo}M %C%%' } - { key: 'access.log', value: "/docker.stdout" } - { key: 'slowlog', value: "/docker.stderr" } - { key: 'php_admin_value[error_log]', value: "/docker.stderr" } - { key: 'php_admin_value[log_errors]', value: "on" } - - { key: 'clear_env', value: "no" } - { key: 'user', value: "{{ APPLICATION_USER }}" } - { key: 'group', value: "{{ APPLICATION_GROUP }}" } +- name: Configure php-fpm pool user (application.conf) + lineinfile: + dest: '/opt/docker/etc/php/fpm/pool.d/application.conf' + regexp: '^[\s;]*{{ item.key }}[\s]*=' + line: '{{ item.key }} = {{ item.value }}' + with_items: + - { key: 'listen', value: "0.0.0.0:9000" } + when: php_version | version_compare('5.5.99', '<=') + +- name: Configure php-fpm pool user (application.conf) + lineinfile: + dest: '/opt/docker/etc/php/fpm/pool.d/application.conf' + regexp: '^[\s;]*{{ item.key }}[\s]*=' + line: ';{{ item.key }} = {{ item.value }}' + with_items: + - { key: 'access.log', value: "/docker.stdout" } + +- name: Disable clear env in php-fpm pool + lineinfile: + dest: '/opt/docker/etc/php/fpm/pool.d/application.conf' + regexp: '^[\s;]*{{ item.key }}[\s]*=' + line: '{{ item.key }} = {{ item.value }}' + with_items: + - { key: 'clear_env', value: "no" } + when: php_clear_env_available == True + +- name: Remove clear env workaround + file: + path: "/opt/docker/bin/service.d/php-fpm.d/11-clear-env.sh" + state: absent + when: php_clear_env_available == True + +- name: Append clear env workaround in php-fpm pool (old php-fpm versions) + lineinfile: + dest: '/opt/docker/etc/php/fpm/pool.d/application.conf' + line: ';#CLEAR_ENV_WORKAROUND#' + when: php_clear_env_available == False + - name: Disable php-fpm connection limit lineinfile: dest: '/opt/docker/etc/php/fpm/pool.d/application.conf' diff --git a/docker/php/debian-9/conf/provision/roles/webdevops-php/tasks/bootstrap/php-fpm.yml b/docker/php/debian-9/conf/provision/roles/webdevops-php/tasks/bootstrap/php-fpm.yml index 130542f53..41c1b33dc 100644 --- a/docker/php/debian-9/conf/provision/roles/webdevops-php/tasks/bootstrap/php-fpm.yml +++ b/docker/php/debian-9/conf/provision/roles/webdevops-php/tasks/bootstrap/php-fpm.yml @@ -1,54 +1,9 @@ --- -- name: Symlink php-fpm binary [RedHat family] +- name: Symlink php-fpm binary file: - path: "/usr/sbin/php-fpm7.0" - src: "/usr/sbin/php-fpm" + path: "/usr/local/bin/php-fpm" + src: "{{ php_fpm_bin }}" state: link owner: "root" group: "root" - when: ansible_os_family == 'RedHat' - -- name: Symlink php-fpm binary [Alpine family] - file: - path: "/usr/sbin/php-fpm" - src: "/usr/sbin/php-fpm7" - state: link - owner: "root" - group: "root" - when: ansible_os_family == 'Alpine' - -- name: Symlink php-fpm binary [Debian family] - file: - path: "/usr/sbin/php-fpm" - src: "/usr/sbin/php-fpm7.0" - state: link - owner: "root" - group: "root" - when: ansible_os_family == 'Debian' - -- name: Remove default php-fpm logrotate - file: - path: "/etc/logrotate.d/php-fpm" - state: absent - when: ansible_os_family == 'RedHat' - -- name: Create php-fpm log directory - file: - path: "/var/log/php7-fpm/" - state: directory - owner: "root" - group: "root" - -- name: Create php-fpm log files - file: - path: "/var/log/php7-fpm/{{ item }}" - state: touch - owner: "root" - group: "root" - mode: 0600 - with_items: - - slow.log - - access.log - - error.log - - fpm.log diff --git a/docker/php/debian-9/conf/provision/roles/webdevops-php/tasks/bootstrap/php.alpine.yml b/docker/php/debian-9/conf/provision/roles/webdevops-php/tasks/bootstrap/php.alpine.yml new file mode 100644 index 000000000..4c16cdf0d --- /dev/null +++ b/docker/php/debian-9/conf/provision/roles/webdevops-php/tasks/bootstrap/php.alpine.yml @@ -0,0 +1,12 @@ +--- + +- name: Create link for additional php.ini [Alpine family] + file: + src: '/opt/docker/etc/php/{{ item.file }}' + dest: '{{ php_etc_dir }}/conf.d/{{ item.target }}' + state: link + force: yes + with_items: + - { file: 'php.webdevops.ini', target: 'xzza-webdevops.ini'} + - { file: 'php.ini', target: 'xzzz-docker.ini'} + when: ansible_os_family == 'Alpine' diff --git a/docker/php/debian-9/conf/provision/roles/webdevops-php/tasks/bootstrap/php.debian.yml b/docker/php/debian-9/conf/provision/roles/webdevops-php/tasks/bootstrap/php.debian.yml new file mode 100644 index 000000000..d27037e33 --- /dev/null +++ b/docker/php/debian-9/conf/provision/roles/webdevops-php/tasks/bootstrap/php.debian.yml @@ -0,0 +1,18 @@ +--- + +- name: Link php.ini for cli and fpm [Debian family] + file: + src: '{{ item.file }}' + dest: '{{ php_etc_dir }}/{{ item.category }}/conf.d/{{ item.target }}' + force: yes + state: link + with_items: + # PHP cli + - { category: 'cli', file: '{{ php_etc_dir }}/mods-available/mcrypt.ini', target: '20-mcrypt.ini' } + - { category: 'cli', file: '/opt/docker/etc/php/php.webdevops.ini', target: '98-webdevops.ini' } + - { category: 'cli', file: '/opt/docker/etc/php/php.ini', target: '99-docker.ini' } + # PHP fpm + - { category: 'fpm', file: '{{ php_etc_dir }}/mods-available/mcrypt.ini', target: '20-mcrypt.ini' } + - { category: 'fpm', file: '/opt/docker/etc/php/php.webdevops.ini', target: '98-webdevops.ini' } + - { category: 'fpm', file: '/opt/docker/etc/php/php.ini', target: '99-docker.ini' } + when: ansible_os_family == 'Debian' diff --git a/docker/php/debian-9/conf/provision/roles/webdevops-php/tasks/bootstrap/php.redhat.yml b/docker/php/debian-9/conf/provision/roles/webdevops-php/tasks/bootstrap/php.redhat.yml new file mode 100644 index 000000000..7e8810231 --- /dev/null +++ b/docker/php/debian-9/conf/provision/roles/webdevops-php/tasks/bootstrap/php.redhat.yml @@ -0,0 +1,12 @@ +--- + +- name: Create link for additional php.ini [RedHat family] + file: + src: '/opt/docker/etc/php/{{ item.file }}' + dest: '/etc/php.d/{{ item.target }}' + state: link + force: yes + with_items: + - { file: 'php.webdevops.ini', target: 'zza-webdevops.ini'} + - { file: 'php.ini', target: 'zzz-docker.ini'} + when: ansible_os_family == 'RedHat' diff --git a/docker/php/debian-9/conf/provision/roles/webdevops-php/tasks/bootstrap/php.yml b/docker/php/debian-9/conf/provision/roles/webdevops-php/tasks/bootstrap/php.yml index 97f02eec3..caac8f413 100644 --- a/docker/php/debian-9/conf/provision/roles/webdevops-php/tasks/bootstrap/php.yml +++ b/docker/php/debian-9/conf/provision/roles/webdevops-php/tasks/bootstrap/php.yml @@ -11,7 +11,7 @@ - /opt/docker/etc/php/ - /opt/docker/etc/php/fpm/ -- name: Create /opt/docker/etc/php/php.ini" +- name: Create php.ini files file: path: "{{ item }}" state: touch @@ -21,40 +21,3 @@ with_items: - "/opt/docker/etc/php/php.webdevops.ini" - "/opt/docker/etc/php/php.ini" - -- name: Link php.ini for cli and fpm - file: - src: '{{ item.file }}' - dest: '/etc/php/7.0/{{ item.category }}/conf.d/{{ item.target }}' - force: yes - state: link - with_items: - # PHP cli - - { category: 'cli', file: '/opt/docker/etc/php/php.webdevops.ini', target: '98-webdevops.ini' } - - { category: 'cli', file: '/opt/docker/etc/php/php.ini', target: '99-docker.ini' } - # PHP fpm - - { category: 'fpm', file: '/opt/docker/etc/php/php.webdevops.ini', target: '98-webdevops.ini' } - - { category: 'fpm', file: '/opt/docker/etc/php/php.ini', target: '99-docker.ini' } - when: ansible_os_family == 'Debian' - -- name: Create link for additional php.ini [RedHat family] - file: - src: '/opt/docker/etc/php/{{ item.file }}' - dest: '/etc/php.d/{{ item.target }}' - state: link - force: yes - with_items: - - { file: 'php.webdevops.ini', target: 'zza-webdevops.ini'} - - { file: 'php.ini', target: 'zzz-docker.ini'} - when: ansible_os_family == 'RedHat' - -- name: Link php.ini - file: - src: '/opt/docker/etc/php/{{ item.file }}' - dest: '/etc/php7/conf.d/{{ item.target }}' - force: yes - state: link - with_items: - - { file: 'php.webdevops.ini', target: 'xzza-webdevops.ini'} - - { file: 'php.ini', target: 'xzzz-docker.ini'} - when: ansible_os_family == 'Alpine' diff --git a/docker/php/ubuntu-12.04/Dockerfile b/docker/php/ubuntu-12.04/Dockerfile index eda86919f..c18fb39ea 100644 --- a/docker/php/ubuntu-12.04/Dockerfile +++ b/docker/php/ubuntu-12.04/Dockerfile @@ -5,14 +5,9 @@ FROM webdevops/base-app:ubuntu-12.04 -MAINTAINER info@webdevops.io -LABEL vendor=WebDevOps.io -LABEL io.webdevops.layout=8 -LABEL io.webdevops.version=1.5.0 - -ENV WEB_DOCUMENT_ROOT /app -ENV WEB_DOCUMENT_INDEX index.php -ENV WEB_ALIAS_DOMAIN *.vm +ENV WEB_DOCUMENT_ROOT=/app \ + WEB_DOCUMENT_INDEX=index.php \ + WEB_ALIAS_DOMAIN=*.vm COPY conf/ /opt/docker/ @@ -47,8 +42,10 @@ RUN /usr/local/bin/apt-install \ && ln -sf /etc/php5/mods-available/mcrypt.in /etc/php5/cli/conf.d/20-mcrypt.ini \ && ln -sf /etc/php5/mods-available/mcrypt.in /etc/php5/fpm/conf.d/20-mcrypt.ini \ && curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin/ --filename=composer \ + # Enable php services + && docker-service-enable syslog cron \ && /opt/docker/bin/provision run --tag bootstrap --role webdevops-php \ - && /opt/docker/bin/bootstrap.sh - + && /opt/docker/bin/bootstrap.sh \ + && docker-image-cleanup EXPOSE 9000 diff --git a/docker/php/ubuntu-12.04/Dockerfile.jinja2 b/docker/php/ubuntu-12.04/Dockerfile.jinja2 index 3cbd23ec1..03c92ad75 100644 --- a/docker/php/ubuntu-12.04/Dockerfile.jinja2 +++ b/docker/php/ubuntu-12.04/Dockerfile.jinja2 @@ -1,7 +1,5 @@ {{ docker.from("base-app", "ubuntu-12.04") }} -{{ docker.version() }} - {{ environment.web() }} {{ docker.copy('conf/', '/opt/docker/') }} diff --git a/docker/php/ubuntu-12.04/conf/bin/service.d/php-fpm.d/11-clear-env.sh b/docker/php/ubuntu-12.04/conf/bin/service.d/php-fpm.d/11-clear-env.sh index b17280ce6..ef6fd4016 100644 --- a/docker/php/ubuntu-12.04/conf/bin/service.d/php-fpm.d/11-clear-env.sh +++ b/docker/php/ubuntu-12.04/conf/bin/service.d/php-fpm.d/11-clear-env.sh @@ -30,5 +30,9 @@ for envVariable in $(printenv|cut -f1 -d=); do done # Replace ;#CLEAR_ENV_WORKAROUND# with environment variable list for all php-fpm pool files -find /opt/docker/etc/php/fpm/pool.d/ -iname '*.conf' -print0 | xargs -0 -r rpl --quiet ";#CLEAR_ENV_WORKAROUND#" "$VARIABLE_LIST" > /dev/null +go-replace \ + -s ";#CLEAR_ENV_WORKAROUND#" -r "$VARIABLE_LIST" \ + --path=/opt/docker/etc/php/fpm/pool.d/ \ + --path-pattern='*.conf' \ + --ignore-empty diff --git a/docker/php/ubuntu-12.04/conf/bin/service.d/php-fpm.sh b/docker/php/ubuntu-12.04/conf/bin/service.d/php-fpm.sh index 1653587a5..e5b667d49 100644 --- a/docker/php/ubuntu-12.04/conf/bin/service.d/php-fpm.sh +++ b/docker/php/ubuntu-12.04/conf/bin/service.d/php-fpm.sh @@ -4,4 +4,4 @@ source /opt/docker/bin/config.sh includeScriptDir "/opt/docker/bin/service.d/php-fpm.d/" -exec /usr/sbin/php5-fpm +exec /usr/local/bin/php-fpm diff --git a/docker/php/ubuntu-12.04/conf/etc/php/php.webdevops.ini b/docker/php/ubuntu-12.04/conf/etc/php/php.webdevops.ini index 562b8d7e2..aa1545ab8 100644 --- a/docker/php/ubuntu-12.04/conf/etc/php/php.webdevops.ini +++ b/docker/php/ubuntu-12.04/conf/etc/php/php.webdevops.ini @@ -5,6 +5,7 @@ ; this file will overwrite default php.ini settings display_errors = 0 +log_errors = 1 short_open_tag = Off variables_order = 'GPCS' diff --git a/docker/php/ubuntu-12.04/conf/provision/roles/webdevops-php/tasks/bootstrap.yml b/docker/php/ubuntu-12.04/conf/provision/roles/webdevops-php/tasks/bootstrap.yml index 5883fa1fe..99a2e5191 100644 --- a/docker/php/ubuntu-12.04/conf/provision/roles/webdevops-php/tasks/bootstrap.yml +++ b/docker/php/ubuntu-12.04/conf/provision/roles/webdevops-php/tasks/bootstrap.yml @@ -1,6 +1,10 @@ --- +- include: bootstrap/init.yml - include: bootstrap/php.yml +- include: bootstrap/php.debian.yml +- include: bootstrap/php.redhat.yml +- include: bootstrap/php.alpine.yml - include: bootstrap/php-fpm.main.yml - include: bootstrap/php-fpm.pool.yml - include: bootstrap/php-fpm.yml diff --git a/docker/php/ubuntu-12.04/conf/provision/roles/webdevops-php/tasks/bootstrap/init.yml b/docker/php/ubuntu-12.04/conf/provision/roles/webdevops-php/tasks/bootstrap/init.yml new file mode 100644 index 000000000..a48bec675 --- /dev/null +++ b/docker/php/ubuntu-12.04/conf/provision/roles/webdevops-php/tasks/bootstrap/init.yml @@ -0,0 +1,71 @@ +--- + +- name: Get php version + command: "php -r 'echo phpversion();'" + changed_when: true + register: php_version_cmd + ignore_errors: true + +- name: Set php_version version + set_fact: + php_version: "{{php_version_cmd.stdout}}" + +############################# +# PHP 5.x +############################# + +- name: Set php main file (RedHat, PHP 5.x) + set_fact: + php_main_conf: /etc/php-fpm.conf + php_pool_conf: www.conf + php_pool_dir: /etc/php-fpm.d + php_fpm_bin: /usr/sbin/php-fpm + when: ansible_os_family == 'RedHat' and ( php_version | version_compare('7.0.0', '<') ) + +- name: Set php main file (Debian, PHP 5.x) + set_fact: + php_etc_dir: /etc/php5 + php_main_conf: /etc/php5/fpm/php-fpm.conf + php_pool_conf: www.conf + php_pool_dir: /etc/php5/fpm/pool.d + php_fpm_bin: /usr/sbin/php5-fpm + when: ansible_os_family == 'Debian' and ( php_version | version_compare('7.0.0', '<') ) + +- name: Set php main file (Alpine, PHP 5.x) + set_fact: + php_etc_dir: /etc/php5 + php_main_conf: /etc/php5/php-fpm.conf + php_pool_conf: www.conf + php_pool_dir: /etc/php5/fpm.d + php_fpm_bin: /usr/bin/php-fpm5 + when: ansible_os_family == 'Alpine' and ( php_version | version_compare('7.0.0', '<') ) + +############################# +# PHP 7.x +############################# + +- name: Set php main file (RedHat, PHP 7.x) + set_fact: + php_main_conf: /etc/php-fpm.conf + php_pool_conf: www.conf + php_pool_dir: /etc/php-fpm.d + php_fpm_bin: /usr/sbin/php-fpm + when: ansible_os_family == 'RedHat' and ( php_version | version_compare('7.0.0', '>=') ) and ( php_version | version_compare('8.0.0', '<') ) + +- name: Set php main file (Debian, PHP 7.x) + set_fact: + php_etc_dir: /etc/php/7.0 + php_main_conf: /etc/php/7.0/fpm/php-fpm.conf + php_pool_conf: www.conf + php_pool_dir: /etc/php/7.0/fpm/pool.d + php_fpm_bin: /usr/sbin/php-fpm7.0 + when: ansible_os_family == 'Debian' and ( php_version | version_compare('7.0.0', '>=') ) and ( php_version | version_compare('8.0.0', '<') ) + +- name: Set php main file (Alpine, PHP 7.x) + set_fact: + php_etc_dir: /etc/php7 + php_main_conf: /etc/php7/php-fpm.conf + php_pool_conf: www.conf + php_pool_dir: /etc/php7/php-fpm.d + php_fpm_bin: /usr/sbin/php-fpm7 + when: ansible_os_family == 'Alpine' and ( php_version | version_compare('7.0.0', '>=') ) and ( php_version | version_compare('8.0.0', '<') ) diff --git a/docker/php/ubuntu-12.04/conf/provision/roles/webdevops-php/tasks/bootstrap/php-fpm.main.yml b/docker/php/ubuntu-12.04/conf/provision/roles/webdevops-php/tasks/bootstrap/php-fpm.main.yml index 1a2c7861f..c149d8728 100644 --- a/docker/php/ubuntu-12.04/conf/provision/roles/webdevops-php/tasks/bootstrap/php-fpm.main.yml +++ b/docker/php/ubuntu-12.04/conf/provision/roles/webdevops-php/tasks/bootstrap/php-fpm.main.yml @@ -1,19 +1,14 @@ --- -- name: Set php main file - set_fact: - php_main_conf: /etc/php-fpm.conf - when: ansible_os_family == 'RedHat' - -- name: Set php main file - set_fact: - php_main_conf: /etc/php5/fpm/php-fpm.conf - when: ansible_os_family == 'Debian' - -- name: Set php main file - set_fact: - php_main_conf: /etc/php5/php-fpm.conf - when: ansible_os_family == 'Alpine' +- name: Create php directories + file: + path: "{{ item }}" + state: directory + mode: 0755 + owner: "root" + group: "root" + with_items: + - /opt/docker/etc/php/fpm/ - name: Move php-fpm main file to /opt/docker/etc/php/fpm/ command: "mv {{ php_main_conf }} /opt/docker/etc/php/fpm/php-fpm.conf" @@ -33,12 +28,22 @@ owner: "root" group: "root" -- name: Configure php-fpm main +- name: Configure php-fpm main (all versions) lineinfile: dest: '/opt/docker/etc/php/fpm/php-fpm.conf' regexp: '^[\s;]*{{ item.key }}[\s]*=' line: '{{ item.key }} = {{ item.value }}' + insertafter: '\[global\]' with_items: - - { key: 'error_log', value: "syslog" } + - { key: 'error_log', value: "/docker.stderr" } - { key: 'pid', value: "/var/run/php-fpm.pid" } + +- name: Configure php-fpm main (php 5.x) + lineinfile: + dest: '/opt/docker/etc/php/fpm/php-fpm.conf' + regexp: '^[\s;]*{{ item.key }}[\s]*=' + line: '{{ item.key }} = {{ item.value }}' + insertbefore: '[\s]*include[\s]*=' + with_items: - { key: 'daemonize', value: 'no' } + when: ( php_version | version_compare('7.0.0', '<') ) diff --git a/docker/php/ubuntu-12.04/conf/provision/roles/webdevops-php/tasks/bootstrap/php-fpm.pool.yml b/docker/php/ubuntu-12.04/conf/provision/roles/webdevops-php/tasks/bootstrap/php-fpm.pool.yml index 53ee9dfe1..ab0b7b02c 100644 --- a/docker/php/ubuntu-12.04/conf/provision/roles/webdevops-php/tasks/bootstrap/php-fpm.pool.yml +++ b/docker/php/ubuntu-12.04/conf/provision/roles/webdevops-php/tasks/bootstrap/php-fpm.pool.yml @@ -1,18 +1,5 @@ --- -- name: Get php version - command: "php -r 'echo phpversion();'" - changed_when: true - register: php_version_cmd - ignore_errors: true - -- name: Set php_version version - set_fact: - php_version: "{{php_version_cmd.stdout}}" - -- debug: - msg: "PHP-Version: {{php_version}}" - - set_fact: php_clear_env_available: False @@ -22,23 +9,10 @@ ( php_version | version_compare('5.5', 'eq') and php_version | version_compare('5.5.11', 'ge') ) or ( php_version | version_compare('5.6', 'ge') ) -- name: Set php pool file - set_fact: - php_pool_conf: www.conf - php_pool_dir: /etc/php-fpm.d - when: ansible_os_family == 'RedHat' - -- name: Set php pool file - set_fact: - php_pool_conf: www.conf - php_pool_dir: /etc/php5/fpm/pool.d - when: ansible_os_family == 'Debian' - -- name: Set php pool file - set_fact: - php_pool_conf: www.conf - php_pool_dir: /etc/php5/fpm.d - when: ansible_os_family == 'Alpine' +- name: Create /opt/docker/etc/php/fpm directory + file: + path: "/opt/docker/etc/php/fpm" + state: directory - name: Move php-fpm pool directory file to /opt/docker/etc/php/ command: "mv {{ php_pool_dir }} /opt/docker/etc/php/fpm/pool.d" @@ -55,7 +29,7 @@ path: "{{ php_pool_dir }}" state: absent -- name: Symlink php-fpm main file +- name: Symlink php-fpm pool file file: path: "{{ php_pool_dir }}" src: "/opt/docker/etc/php/fpm/pool.d" @@ -69,15 +43,25 @@ regexp: '^[\s;]*{{ item.key }}[\s]*=' line: '{{ item.key }} = {{ item.value }}' with_items: - - { key: 'listen', value: "0.0.0.0:9000" } + - { key: 'listen', value: "[::]:9000" } - { key: 'catch_workers_output', value: "yes" } - { key: 'access.format', value: '[php-fpm:access] %R - %u %t "%m %r%Q%q" %s %f %{mili}d %{kilo}M %C%%' } + - { key: 'access.log', value: "/docker.stdout" } - { key: 'slowlog', value: "/docker.stderr" } - { key: 'php_admin_value[error_log]', value: "/docker.stderr" } - { key: 'php_admin_value[log_errors]', value: "on" } - { key: 'user', value: "{{ APPLICATION_USER }}" } - { key: 'group', value: "{{ APPLICATION_GROUP }}" } +- name: Configure php-fpm pool user (application.conf) + lineinfile: + dest: '/opt/docker/etc/php/fpm/pool.d/application.conf' + regexp: '^[\s;]*{{ item.key }}[\s]*=' + line: '{{ item.key }} = {{ item.value }}' + with_items: + - { key: 'listen', value: "0.0.0.0:9000" } + when: php_version | version_compare('5.5.99', '<=') + - name: Configure php-fpm pool user (application.conf) lineinfile: dest: '/opt/docker/etc/php/fpm/pool.d/application.conf' diff --git a/docker/php/ubuntu-12.04/conf/provision/roles/webdevops-php/tasks/bootstrap/php-fpm.yml b/docker/php/ubuntu-12.04/conf/provision/roles/webdevops-php/tasks/bootstrap/php-fpm.yml index d83edb3ae..41c1b33dc 100644 --- a/docker/php/ubuntu-12.04/conf/provision/roles/webdevops-php/tasks/bootstrap/php-fpm.yml +++ b/docker/php/ubuntu-12.04/conf/provision/roles/webdevops-php/tasks/bootstrap/php-fpm.yml @@ -1,45 +1,9 @@ --- -- name: Symlink php-fpm binary [Alpine family] +- name: Symlink php-fpm binary file: - path: "/usr/sbin/php-fpm" - src: "/usr/bin/php-fpm" + path: "/usr/local/bin/php-fpm" + src: "{{ php_fpm_bin }}" state: link owner: "root" group: "root" - when: ansible_os_family == 'Alpine' - -- name: Symlink php-fpm binary [Debian family] - file: - path: "/usr/sbin/php-fpm" - src: "/usr/sbin/php5-fpm" - state: link - owner: "root" - group: "root" - when: ansible_os_family == 'Debian' - -- name: Remove default php-fpm logrotate - file: - path: "/etc/logrotate.d/php-fpm" - state: absent - when: ansible_os_family == 'RedHat' - -- name: Create php-fpm log directory - file: - path: "/var/log/php5-fpm/" - state: directory - owner: "root" - group: "root" - -- name: Create php-fpm log files - file: - path: "/var/log/php5-fpm/{{ item }}" - state: touch - owner: "root" - group: "root" - mode: 0600 - with_items: - - slow.log - - access.log - - error.log - - fpm.log diff --git a/docker/php/ubuntu-12.04/conf/provision/roles/webdevops-php/tasks/bootstrap/php.alpine.yml b/docker/php/ubuntu-12.04/conf/provision/roles/webdevops-php/tasks/bootstrap/php.alpine.yml new file mode 100644 index 000000000..4c16cdf0d --- /dev/null +++ b/docker/php/ubuntu-12.04/conf/provision/roles/webdevops-php/tasks/bootstrap/php.alpine.yml @@ -0,0 +1,12 @@ +--- + +- name: Create link for additional php.ini [Alpine family] + file: + src: '/opt/docker/etc/php/{{ item.file }}' + dest: '{{ php_etc_dir }}/conf.d/{{ item.target }}' + state: link + force: yes + with_items: + - { file: 'php.webdevops.ini', target: 'xzza-webdevops.ini'} + - { file: 'php.ini', target: 'xzzz-docker.ini'} + when: ansible_os_family == 'Alpine' diff --git a/docker/php/ubuntu-12.04/conf/provision/roles/webdevops-php/tasks/bootstrap/php.debian.yml b/docker/php/ubuntu-12.04/conf/provision/roles/webdevops-php/tasks/bootstrap/php.debian.yml new file mode 100644 index 000000000..d27037e33 --- /dev/null +++ b/docker/php/ubuntu-12.04/conf/provision/roles/webdevops-php/tasks/bootstrap/php.debian.yml @@ -0,0 +1,18 @@ +--- + +- name: Link php.ini for cli and fpm [Debian family] + file: + src: '{{ item.file }}' + dest: '{{ php_etc_dir }}/{{ item.category }}/conf.d/{{ item.target }}' + force: yes + state: link + with_items: + # PHP cli + - { category: 'cli', file: '{{ php_etc_dir }}/mods-available/mcrypt.ini', target: '20-mcrypt.ini' } + - { category: 'cli', file: '/opt/docker/etc/php/php.webdevops.ini', target: '98-webdevops.ini' } + - { category: 'cli', file: '/opt/docker/etc/php/php.ini', target: '99-docker.ini' } + # PHP fpm + - { category: 'fpm', file: '{{ php_etc_dir }}/mods-available/mcrypt.ini', target: '20-mcrypt.ini' } + - { category: 'fpm', file: '/opt/docker/etc/php/php.webdevops.ini', target: '98-webdevops.ini' } + - { category: 'fpm', file: '/opt/docker/etc/php/php.ini', target: '99-docker.ini' } + when: ansible_os_family == 'Debian' diff --git a/docker/php/ubuntu-12.04/conf/provision/roles/webdevops-php/tasks/bootstrap/php.redhat.yml b/docker/php/ubuntu-12.04/conf/provision/roles/webdevops-php/tasks/bootstrap/php.redhat.yml new file mode 100644 index 000000000..7e8810231 --- /dev/null +++ b/docker/php/ubuntu-12.04/conf/provision/roles/webdevops-php/tasks/bootstrap/php.redhat.yml @@ -0,0 +1,12 @@ +--- + +- name: Create link for additional php.ini [RedHat family] + file: + src: '/opt/docker/etc/php/{{ item.file }}' + dest: '/etc/php.d/{{ item.target }}' + state: link + force: yes + with_items: + - { file: 'php.webdevops.ini', target: 'zza-webdevops.ini'} + - { file: 'php.ini', target: 'zzz-docker.ini'} + when: ansible_os_family == 'RedHat' diff --git a/docker/php/ubuntu-12.04/conf/provision/roles/webdevops-php/tasks/bootstrap/php.yml b/docker/php/ubuntu-12.04/conf/provision/roles/webdevops-php/tasks/bootstrap/php.yml index 9816b2538..caac8f413 100644 --- a/docker/php/ubuntu-12.04/conf/provision/roles/webdevops-php/tasks/bootstrap/php.yml +++ b/docker/php/ubuntu-12.04/conf/provision/roles/webdevops-php/tasks/bootstrap/php.yml @@ -21,42 +21,3 @@ with_items: - "/opt/docker/etc/php/php.webdevops.ini" - "/opt/docker/etc/php/php.ini" - -- name: Link php.ini for cli and fpm [Debian family] - file: - src: '{{ item.file }}' - dest: '/etc/php5/{{ item.category }}/conf.d/{{ item.target }}' - force: yes - state: link - with_items: - # PHP cli - - { category: 'cli', file: '/etc/php5/mods-available/mcrypt.ini', target: '20-mcrypt.ini' } - - { category: 'cli', file: '/opt/docker/etc/php/php.webdevops.ini', target: '98-webdevops.ini' } - - { category: 'cli', file: '/opt/docker/etc/php/php.ini', target: '99-docker.ini' } - # PHP fpm - - { category: 'fpm', file: '/etc/php5/mods-available/mcrypt.ini', target: '20-mcrypt.ini' } - - { category: 'fpm', file: '/opt/docker/etc/php/php.webdevops.ini', target: '98-webdevops.ini' } - - { category: 'fpm', file: '/opt/docker/etc/php/php.ini', target: '99-docker.ini' } - when: ansible_os_family == 'Debian' - -- name: Create link for additional php.ini [RedHat family] - file: - src: '/opt/docker/etc/php/{{ item.file }}' - dest: '/etc/php.d/{{ item.target }}' - state: link - force: yes - with_items: - - { file: 'php.webdevops.ini', target: 'zza-webdevops.ini'} - - { file: 'php.ini', target: 'zzz-docker.ini'} - when: ansible_os_family == 'RedHat' - -- name: Create link for additional php.ini [Alpine family] - file: - src: '/opt/docker/etc/php/{{ item.file }}' - dest: '/etc/php5/conf.d/{{ item.target }}' - state: link - force: yes - with_items: - - { file: 'php.webdevops.ini', target: 'xzza-webdevops.ini'} - - { file: 'php.ini', target: 'xzzz-docker.ini'} - when: ansible_os_family == 'Alpine' diff --git a/docker/php/ubuntu-14.04/Dockerfile b/docker/php/ubuntu-14.04/Dockerfile index 48b66770a..f8db10ecb 100644 --- a/docker/php/ubuntu-14.04/Dockerfile +++ b/docker/php/ubuntu-14.04/Dockerfile @@ -5,14 +5,9 @@ FROM webdevops/base-app:ubuntu-14.04 -MAINTAINER info@webdevops.io -LABEL vendor=WebDevOps.io -LABEL io.webdevops.layout=8 -LABEL io.webdevops.version=1.5.0 - -ENV WEB_DOCUMENT_ROOT /app -ENV WEB_DOCUMENT_INDEX index.php -ENV WEB_ALIAS_DOMAIN *.vm +ENV WEB_DOCUMENT_ROOT=/app \ + WEB_DOCUMENT_INDEX=index.php \ + WEB_ALIAS_DOMAIN=*.vm COPY conf/ /opt/docker/ @@ -48,8 +43,10 @@ RUN /usr/local/bin/apt-install \ && ln -sf /etc/php5/mods-available/mcrypt.in /etc/php5/cli/conf.d/20-mcrypt.ini \ && ln -sf /etc/php5/mods-available/mcrypt.in /etc/php5/fpm/conf.d/20-mcrypt.ini \ && curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin/ --filename=composer \ + # Enable php services + && docker-service-enable syslog cron \ && /opt/docker/bin/provision run --tag bootstrap --role webdevops-php \ - && /opt/docker/bin/bootstrap.sh - + && /opt/docker/bin/bootstrap.sh \ + && docker-image-cleanup EXPOSE 9000 diff --git a/docker/php/ubuntu-14.04/Dockerfile.jinja2 b/docker/php/ubuntu-14.04/Dockerfile.jinja2 index 6a5876d83..002b201a8 100644 --- a/docker/php/ubuntu-14.04/Dockerfile.jinja2 +++ b/docker/php/ubuntu-14.04/Dockerfile.jinja2 @@ -1,7 +1,5 @@ {{ docker.from("base-app", "ubuntu-14.04") }} -{{ docker.version() }} - {{ environment.web() }} {{ docker.copy('conf/', '/opt/docker/') }} diff --git a/docker/php/ubuntu-14.04/conf/bin/service.d/php-fpm.d/11-clear-env.sh b/docker/php/ubuntu-14.04/conf/bin/service.d/php-fpm.d/11-clear-env.sh index b17280ce6..ef6fd4016 100644 --- a/docker/php/ubuntu-14.04/conf/bin/service.d/php-fpm.d/11-clear-env.sh +++ b/docker/php/ubuntu-14.04/conf/bin/service.d/php-fpm.d/11-clear-env.sh @@ -30,5 +30,9 @@ for envVariable in $(printenv|cut -f1 -d=); do done # Replace ;#CLEAR_ENV_WORKAROUND# with environment variable list for all php-fpm pool files -find /opt/docker/etc/php/fpm/pool.d/ -iname '*.conf' -print0 | xargs -0 -r rpl --quiet ";#CLEAR_ENV_WORKAROUND#" "$VARIABLE_LIST" > /dev/null +go-replace \ + -s ";#CLEAR_ENV_WORKAROUND#" -r "$VARIABLE_LIST" \ + --path=/opt/docker/etc/php/fpm/pool.d/ \ + --path-pattern='*.conf' \ + --ignore-empty diff --git a/docker/php/ubuntu-14.04/conf/bin/service.d/php-fpm.sh b/docker/php/ubuntu-14.04/conf/bin/service.d/php-fpm.sh index 571f248d2..b25983bd3 100644 --- a/docker/php/ubuntu-14.04/conf/bin/service.d/php-fpm.sh +++ b/docker/php/ubuntu-14.04/conf/bin/service.d/php-fpm.sh @@ -4,4 +4,4 @@ source /opt/docker/bin/config.sh includeScriptDir "/opt/docker/bin/service.d/php-fpm.d/" -exec /usr/sbin/php-fpm --nodaemonize +exec /usr/local/bin/php-fpm --nodaemonize diff --git a/docker/php/ubuntu-14.04/conf/etc/php/php.webdevops.ini b/docker/php/ubuntu-14.04/conf/etc/php/php.webdevops.ini index 562b8d7e2..aa1545ab8 100644 --- a/docker/php/ubuntu-14.04/conf/etc/php/php.webdevops.ini +++ b/docker/php/ubuntu-14.04/conf/etc/php/php.webdevops.ini @@ -5,6 +5,7 @@ ; this file will overwrite default php.ini settings display_errors = 0 +log_errors = 1 short_open_tag = Off variables_order = 'GPCS' diff --git a/docker/php/ubuntu-14.04/conf/provision/roles/webdevops-php/tasks/bootstrap.yml b/docker/php/ubuntu-14.04/conf/provision/roles/webdevops-php/tasks/bootstrap.yml index 5883fa1fe..99a2e5191 100644 --- a/docker/php/ubuntu-14.04/conf/provision/roles/webdevops-php/tasks/bootstrap.yml +++ b/docker/php/ubuntu-14.04/conf/provision/roles/webdevops-php/tasks/bootstrap.yml @@ -1,6 +1,10 @@ --- +- include: bootstrap/init.yml - include: bootstrap/php.yml +- include: bootstrap/php.debian.yml +- include: bootstrap/php.redhat.yml +- include: bootstrap/php.alpine.yml - include: bootstrap/php-fpm.main.yml - include: bootstrap/php-fpm.pool.yml - include: bootstrap/php-fpm.yml diff --git a/docker/php/ubuntu-14.04/conf/provision/roles/webdevops-php/tasks/bootstrap/init.yml b/docker/php/ubuntu-14.04/conf/provision/roles/webdevops-php/tasks/bootstrap/init.yml new file mode 100644 index 000000000..a48bec675 --- /dev/null +++ b/docker/php/ubuntu-14.04/conf/provision/roles/webdevops-php/tasks/bootstrap/init.yml @@ -0,0 +1,71 @@ +--- + +- name: Get php version + command: "php -r 'echo phpversion();'" + changed_when: true + register: php_version_cmd + ignore_errors: true + +- name: Set php_version version + set_fact: + php_version: "{{php_version_cmd.stdout}}" + +############################# +# PHP 5.x +############################# + +- name: Set php main file (RedHat, PHP 5.x) + set_fact: + php_main_conf: /etc/php-fpm.conf + php_pool_conf: www.conf + php_pool_dir: /etc/php-fpm.d + php_fpm_bin: /usr/sbin/php-fpm + when: ansible_os_family == 'RedHat' and ( php_version | version_compare('7.0.0', '<') ) + +- name: Set php main file (Debian, PHP 5.x) + set_fact: + php_etc_dir: /etc/php5 + php_main_conf: /etc/php5/fpm/php-fpm.conf + php_pool_conf: www.conf + php_pool_dir: /etc/php5/fpm/pool.d + php_fpm_bin: /usr/sbin/php5-fpm + when: ansible_os_family == 'Debian' and ( php_version | version_compare('7.0.0', '<') ) + +- name: Set php main file (Alpine, PHP 5.x) + set_fact: + php_etc_dir: /etc/php5 + php_main_conf: /etc/php5/php-fpm.conf + php_pool_conf: www.conf + php_pool_dir: /etc/php5/fpm.d + php_fpm_bin: /usr/bin/php-fpm5 + when: ansible_os_family == 'Alpine' and ( php_version | version_compare('7.0.0', '<') ) + +############################# +# PHP 7.x +############################# + +- name: Set php main file (RedHat, PHP 7.x) + set_fact: + php_main_conf: /etc/php-fpm.conf + php_pool_conf: www.conf + php_pool_dir: /etc/php-fpm.d + php_fpm_bin: /usr/sbin/php-fpm + when: ansible_os_family == 'RedHat' and ( php_version | version_compare('7.0.0', '>=') ) and ( php_version | version_compare('8.0.0', '<') ) + +- name: Set php main file (Debian, PHP 7.x) + set_fact: + php_etc_dir: /etc/php/7.0 + php_main_conf: /etc/php/7.0/fpm/php-fpm.conf + php_pool_conf: www.conf + php_pool_dir: /etc/php/7.0/fpm/pool.d + php_fpm_bin: /usr/sbin/php-fpm7.0 + when: ansible_os_family == 'Debian' and ( php_version | version_compare('7.0.0', '>=') ) and ( php_version | version_compare('8.0.0', '<') ) + +- name: Set php main file (Alpine, PHP 7.x) + set_fact: + php_etc_dir: /etc/php7 + php_main_conf: /etc/php7/php-fpm.conf + php_pool_conf: www.conf + php_pool_dir: /etc/php7/php-fpm.d + php_fpm_bin: /usr/sbin/php-fpm7 + when: ansible_os_family == 'Alpine' and ( php_version | version_compare('7.0.0', '>=') ) and ( php_version | version_compare('8.0.0', '<') ) diff --git a/docker/php/ubuntu-14.04/conf/provision/roles/webdevops-php/tasks/bootstrap/php-fpm.main.yml b/docker/php/ubuntu-14.04/conf/provision/roles/webdevops-php/tasks/bootstrap/php-fpm.main.yml index 1a2c7861f..c149d8728 100644 --- a/docker/php/ubuntu-14.04/conf/provision/roles/webdevops-php/tasks/bootstrap/php-fpm.main.yml +++ b/docker/php/ubuntu-14.04/conf/provision/roles/webdevops-php/tasks/bootstrap/php-fpm.main.yml @@ -1,19 +1,14 @@ --- -- name: Set php main file - set_fact: - php_main_conf: /etc/php-fpm.conf - when: ansible_os_family == 'RedHat' - -- name: Set php main file - set_fact: - php_main_conf: /etc/php5/fpm/php-fpm.conf - when: ansible_os_family == 'Debian' - -- name: Set php main file - set_fact: - php_main_conf: /etc/php5/php-fpm.conf - when: ansible_os_family == 'Alpine' +- name: Create php directories + file: + path: "{{ item }}" + state: directory + mode: 0755 + owner: "root" + group: "root" + with_items: + - /opt/docker/etc/php/fpm/ - name: Move php-fpm main file to /opt/docker/etc/php/fpm/ command: "mv {{ php_main_conf }} /opt/docker/etc/php/fpm/php-fpm.conf" @@ -33,12 +28,22 @@ owner: "root" group: "root" -- name: Configure php-fpm main +- name: Configure php-fpm main (all versions) lineinfile: dest: '/opt/docker/etc/php/fpm/php-fpm.conf' regexp: '^[\s;]*{{ item.key }}[\s]*=' line: '{{ item.key }} = {{ item.value }}' + insertafter: '\[global\]' with_items: - - { key: 'error_log', value: "syslog" } + - { key: 'error_log', value: "/docker.stderr" } - { key: 'pid', value: "/var/run/php-fpm.pid" } + +- name: Configure php-fpm main (php 5.x) + lineinfile: + dest: '/opt/docker/etc/php/fpm/php-fpm.conf' + regexp: '^[\s;]*{{ item.key }}[\s]*=' + line: '{{ item.key }} = {{ item.value }}' + insertbefore: '[\s]*include[\s]*=' + with_items: - { key: 'daemonize', value: 'no' } + when: ( php_version | version_compare('7.0.0', '<') ) diff --git a/docker/php/ubuntu-14.04/conf/provision/roles/webdevops-php/tasks/bootstrap/php-fpm.pool.yml b/docker/php/ubuntu-14.04/conf/provision/roles/webdevops-php/tasks/bootstrap/php-fpm.pool.yml index 53ee9dfe1..ab0b7b02c 100644 --- a/docker/php/ubuntu-14.04/conf/provision/roles/webdevops-php/tasks/bootstrap/php-fpm.pool.yml +++ b/docker/php/ubuntu-14.04/conf/provision/roles/webdevops-php/tasks/bootstrap/php-fpm.pool.yml @@ -1,18 +1,5 @@ --- -- name: Get php version - command: "php -r 'echo phpversion();'" - changed_when: true - register: php_version_cmd - ignore_errors: true - -- name: Set php_version version - set_fact: - php_version: "{{php_version_cmd.stdout}}" - -- debug: - msg: "PHP-Version: {{php_version}}" - - set_fact: php_clear_env_available: False @@ -22,23 +9,10 @@ ( php_version | version_compare('5.5', 'eq') and php_version | version_compare('5.5.11', 'ge') ) or ( php_version | version_compare('5.6', 'ge') ) -- name: Set php pool file - set_fact: - php_pool_conf: www.conf - php_pool_dir: /etc/php-fpm.d - when: ansible_os_family == 'RedHat' - -- name: Set php pool file - set_fact: - php_pool_conf: www.conf - php_pool_dir: /etc/php5/fpm/pool.d - when: ansible_os_family == 'Debian' - -- name: Set php pool file - set_fact: - php_pool_conf: www.conf - php_pool_dir: /etc/php5/fpm.d - when: ansible_os_family == 'Alpine' +- name: Create /opt/docker/etc/php/fpm directory + file: + path: "/opt/docker/etc/php/fpm" + state: directory - name: Move php-fpm pool directory file to /opt/docker/etc/php/ command: "mv {{ php_pool_dir }} /opt/docker/etc/php/fpm/pool.d" @@ -55,7 +29,7 @@ path: "{{ php_pool_dir }}" state: absent -- name: Symlink php-fpm main file +- name: Symlink php-fpm pool file file: path: "{{ php_pool_dir }}" src: "/opt/docker/etc/php/fpm/pool.d" @@ -69,15 +43,25 @@ regexp: '^[\s;]*{{ item.key }}[\s]*=' line: '{{ item.key }} = {{ item.value }}' with_items: - - { key: 'listen', value: "0.0.0.0:9000" } + - { key: 'listen', value: "[::]:9000" } - { key: 'catch_workers_output', value: "yes" } - { key: 'access.format', value: '[php-fpm:access] %R - %u %t "%m %r%Q%q" %s %f %{mili}d %{kilo}M %C%%' } + - { key: 'access.log', value: "/docker.stdout" } - { key: 'slowlog', value: "/docker.stderr" } - { key: 'php_admin_value[error_log]', value: "/docker.stderr" } - { key: 'php_admin_value[log_errors]', value: "on" } - { key: 'user', value: "{{ APPLICATION_USER }}" } - { key: 'group', value: "{{ APPLICATION_GROUP }}" } +- name: Configure php-fpm pool user (application.conf) + lineinfile: + dest: '/opt/docker/etc/php/fpm/pool.d/application.conf' + regexp: '^[\s;]*{{ item.key }}[\s]*=' + line: '{{ item.key }} = {{ item.value }}' + with_items: + - { key: 'listen', value: "0.0.0.0:9000" } + when: php_version | version_compare('5.5.99', '<=') + - name: Configure php-fpm pool user (application.conf) lineinfile: dest: '/opt/docker/etc/php/fpm/pool.d/application.conf' diff --git a/docker/php/ubuntu-14.04/conf/provision/roles/webdevops-php/tasks/bootstrap/php-fpm.yml b/docker/php/ubuntu-14.04/conf/provision/roles/webdevops-php/tasks/bootstrap/php-fpm.yml index d83edb3ae..41c1b33dc 100644 --- a/docker/php/ubuntu-14.04/conf/provision/roles/webdevops-php/tasks/bootstrap/php-fpm.yml +++ b/docker/php/ubuntu-14.04/conf/provision/roles/webdevops-php/tasks/bootstrap/php-fpm.yml @@ -1,45 +1,9 @@ --- -- name: Symlink php-fpm binary [Alpine family] +- name: Symlink php-fpm binary file: - path: "/usr/sbin/php-fpm" - src: "/usr/bin/php-fpm" + path: "/usr/local/bin/php-fpm" + src: "{{ php_fpm_bin }}" state: link owner: "root" group: "root" - when: ansible_os_family == 'Alpine' - -- name: Symlink php-fpm binary [Debian family] - file: - path: "/usr/sbin/php-fpm" - src: "/usr/sbin/php5-fpm" - state: link - owner: "root" - group: "root" - when: ansible_os_family == 'Debian' - -- name: Remove default php-fpm logrotate - file: - path: "/etc/logrotate.d/php-fpm" - state: absent - when: ansible_os_family == 'RedHat' - -- name: Create php-fpm log directory - file: - path: "/var/log/php5-fpm/" - state: directory - owner: "root" - group: "root" - -- name: Create php-fpm log files - file: - path: "/var/log/php5-fpm/{{ item }}" - state: touch - owner: "root" - group: "root" - mode: 0600 - with_items: - - slow.log - - access.log - - error.log - - fpm.log diff --git a/docker/php/ubuntu-14.04/conf/provision/roles/webdevops-php/tasks/bootstrap/php.alpine.yml b/docker/php/ubuntu-14.04/conf/provision/roles/webdevops-php/tasks/bootstrap/php.alpine.yml new file mode 100644 index 000000000..4c16cdf0d --- /dev/null +++ b/docker/php/ubuntu-14.04/conf/provision/roles/webdevops-php/tasks/bootstrap/php.alpine.yml @@ -0,0 +1,12 @@ +--- + +- name: Create link for additional php.ini [Alpine family] + file: + src: '/opt/docker/etc/php/{{ item.file }}' + dest: '{{ php_etc_dir }}/conf.d/{{ item.target }}' + state: link + force: yes + with_items: + - { file: 'php.webdevops.ini', target: 'xzza-webdevops.ini'} + - { file: 'php.ini', target: 'xzzz-docker.ini'} + when: ansible_os_family == 'Alpine' diff --git a/docker/php/ubuntu-14.04/conf/provision/roles/webdevops-php/tasks/bootstrap/php.debian.yml b/docker/php/ubuntu-14.04/conf/provision/roles/webdevops-php/tasks/bootstrap/php.debian.yml new file mode 100644 index 000000000..d27037e33 --- /dev/null +++ b/docker/php/ubuntu-14.04/conf/provision/roles/webdevops-php/tasks/bootstrap/php.debian.yml @@ -0,0 +1,18 @@ +--- + +- name: Link php.ini for cli and fpm [Debian family] + file: + src: '{{ item.file }}' + dest: '{{ php_etc_dir }}/{{ item.category }}/conf.d/{{ item.target }}' + force: yes + state: link + with_items: + # PHP cli + - { category: 'cli', file: '{{ php_etc_dir }}/mods-available/mcrypt.ini', target: '20-mcrypt.ini' } + - { category: 'cli', file: '/opt/docker/etc/php/php.webdevops.ini', target: '98-webdevops.ini' } + - { category: 'cli', file: '/opt/docker/etc/php/php.ini', target: '99-docker.ini' } + # PHP fpm + - { category: 'fpm', file: '{{ php_etc_dir }}/mods-available/mcrypt.ini', target: '20-mcrypt.ini' } + - { category: 'fpm', file: '/opt/docker/etc/php/php.webdevops.ini', target: '98-webdevops.ini' } + - { category: 'fpm', file: '/opt/docker/etc/php/php.ini', target: '99-docker.ini' } + when: ansible_os_family == 'Debian' diff --git a/docker/php/ubuntu-14.04/conf/provision/roles/webdevops-php/tasks/bootstrap/php.redhat.yml b/docker/php/ubuntu-14.04/conf/provision/roles/webdevops-php/tasks/bootstrap/php.redhat.yml new file mode 100644 index 000000000..7e8810231 --- /dev/null +++ b/docker/php/ubuntu-14.04/conf/provision/roles/webdevops-php/tasks/bootstrap/php.redhat.yml @@ -0,0 +1,12 @@ +--- + +- name: Create link for additional php.ini [RedHat family] + file: + src: '/opt/docker/etc/php/{{ item.file }}' + dest: '/etc/php.d/{{ item.target }}' + state: link + force: yes + with_items: + - { file: 'php.webdevops.ini', target: 'zza-webdevops.ini'} + - { file: 'php.ini', target: 'zzz-docker.ini'} + when: ansible_os_family == 'RedHat' diff --git a/docker/php/ubuntu-14.04/conf/provision/roles/webdevops-php/tasks/bootstrap/php.yml b/docker/php/ubuntu-14.04/conf/provision/roles/webdevops-php/tasks/bootstrap/php.yml index 9816b2538..caac8f413 100644 --- a/docker/php/ubuntu-14.04/conf/provision/roles/webdevops-php/tasks/bootstrap/php.yml +++ b/docker/php/ubuntu-14.04/conf/provision/roles/webdevops-php/tasks/bootstrap/php.yml @@ -21,42 +21,3 @@ with_items: - "/opt/docker/etc/php/php.webdevops.ini" - "/opt/docker/etc/php/php.ini" - -- name: Link php.ini for cli and fpm [Debian family] - file: - src: '{{ item.file }}' - dest: '/etc/php5/{{ item.category }}/conf.d/{{ item.target }}' - force: yes - state: link - with_items: - # PHP cli - - { category: 'cli', file: '/etc/php5/mods-available/mcrypt.ini', target: '20-mcrypt.ini' } - - { category: 'cli', file: '/opt/docker/etc/php/php.webdevops.ini', target: '98-webdevops.ini' } - - { category: 'cli', file: '/opt/docker/etc/php/php.ini', target: '99-docker.ini' } - # PHP fpm - - { category: 'fpm', file: '/etc/php5/mods-available/mcrypt.ini', target: '20-mcrypt.ini' } - - { category: 'fpm', file: '/opt/docker/etc/php/php.webdevops.ini', target: '98-webdevops.ini' } - - { category: 'fpm', file: '/opt/docker/etc/php/php.ini', target: '99-docker.ini' } - when: ansible_os_family == 'Debian' - -- name: Create link for additional php.ini [RedHat family] - file: - src: '/opt/docker/etc/php/{{ item.file }}' - dest: '/etc/php.d/{{ item.target }}' - state: link - force: yes - with_items: - - { file: 'php.webdevops.ini', target: 'zza-webdevops.ini'} - - { file: 'php.ini', target: 'zzz-docker.ini'} - when: ansible_os_family == 'RedHat' - -- name: Create link for additional php.ini [Alpine family] - file: - src: '/opt/docker/etc/php/{{ item.file }}' - dest: '/etc/php5/conf.d/{{ item.target }}' - state: link - force: yes - with_items: - - { file: 'php.webdevops.ini', target: 'xzza-webdevops.ini'} - - { file: 'php.ini', target: 'xzzz-docker.ini'} - when: ansible_os_family == 'Alpine' diff --git a/docker/php/ubuntu-15.04/Dockerfile b/docker/php/ubuntu-15.04/Dockerfile index 918037e36..62491719a 100644 --- a/docker/php/ubuntu-15.04/Dockerfile +++ b/docker/php/ubuntu-15.04/Dockerfile @@ -5,14 +5,9 @@ FROM webdevops/base-app:ubuntu-15.04 -MAINTAINER info@webdevops.io -LABEL vendor=WebDevOps.io -LABEL io.webdevops.layout=8 -LABEL io.webdevops.version=1.5.0 - -ENV WEB_DOCUMENT_ROOT /app -ENV WEB_DOCUMENT_INDEX index.php -ENV WEB_ALIAS_DOMAIN *.vm +ENV WEB_DOCUMENT_ROOT=/app \ + WEB_DOCUMENT_INDEX=index.php \ + WEB_ALIAS_DOMAIN=*.vm COPY conf/ /opt/docker/ @@ -48,8 +43,10 @@ RUN /usr/local/bin/apt-install \ && ln -sf /etc/php5/mods-available/mcrypt.in /etc/php5/cli/conf.d/20-mcrypt.ini \ && ln -sf /etc/php5/mods-available/mcrypt.in /etc/php5/fpm/conf.d/20-mcrypt.ini \ && curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin/ --filename=composer \ + # Enable php services + && docker-service-enable syslog cron \ && /opt/docker/bin/provision run --tag bootstrap --role webdevops-php \ - && /opt/docker/bin/bootstrap.sh - + && /opt/docker/bin/bootstrap.sh \ + && docker-image-cleanup EXPOSE 9000 diff --git a/docker/php/ubuntu-15.04/Dockerfile.jinja2 b/docker/php/ubuntu-15.04/Dockerfile.jinja2 index 647f7ee45..24d9a71be 100644 --- a/docker/php/ubuntu-15.04/Dockerfile.jinja2 +++ b/docker/php/ubuntu-15.04/Dockerfile.jinja2 @@ -1,7 +1,5 @@ {{ docker.from("base-app", "ubuntu-15.04") }} -{{ docker.version() }} - {{ environment.web() }} {{ docker.copy('conf/', '/opt/docker/') }} diff --git a/docker/php/ubuntu-15.04/conf/bin/service.d/php-fpm.d/11-clear-env.sh b/docker/php/ubuntu-15.04/conf/bin/service.d/php-fpm.d/11-clear-env.sh index b17280ce6..ef6fd4016 100644 --- a/docker/php/ubuntu-15.04/conf/bin/service.d/php-fpm.d/11-clear-env.sh +++ b/docker/php/ubuntu-15.04/conf/bin/service.d/php-fpm.d/11-clear-env.sh @@ -30,5 +30,9 @@ for envVariable in $(printenv|cut -f1 -d=); do done # Replace ;#CLEAR_ENV_WORKAROUND# with environment variable list for all php-fpm pool files -find /opt/docker/etc/php/fpm/pool.d/ -iname '*.conf' -print0 | xargs -0 -r rpl --quiet ";#CLEAR_ENV_WORKAROUND#" "$VARIABLE_LIST" > /dev/null +go-replace \ + -s ";#CLEAR_ENV_WORKAROUND#" -r "$VARIABLE_LIST" \ + --path=/opt/docker/etc/php/fpm/pool.d/ \ + --path-pattern='*.conf' \ + --ignore-empty diff --git a/docker/php/ubuntu-15.04/conf/bin/service.d/php-fpm.sh b/docker/php/ubuntu-15.04/conf/bin/service.d/php-fpm.sh index 571f248d2..b25983bd3 100644 --- a/docker/php/ubuntu-15.04/conf/bin/service.d/php-fpm.sh +++ b/docker/php/ubuntu-15.04/conf/bin/service.d/php-fpm.sh @@ -4,4 +4,4 @@ source /opt/docker/bin/config.sh includeScriptDir "/opt/docker/bin/service.d/php-fpm.d/" -exec /usr/sbin/php-fpm --nodaemonize +exec /usr/local/bin/php-fpm --nodaemonize diff --git a/docker/php/ubuntu-15.04/conf/etc/php/php.webdevops.ini b/docker/php/ubuntu-15.04/conf/etc/php/php.webdevops.ini index 562b8d7e2..aa1545ab8 100644 --- a/docker/php/ubuntu-15.04/conf/etc/php/php.webdevops.ini +++ b/docker/php/ubuntu-15.04/conf/etc/php/php.webdevops.ini @@ -5,6 +5,7 @@ ; this file will overwrite default php.ini settings display_errors = 0 +log_errors = 1 short_open_tag = Off variables_order = 'GPCS' diff --git a/docker/php/ubuntu-15.04/conf/provision/roles/webdevops-php/tasks/bootstrap.yml b/docker/php/ubuntu-15.04/conf/provision/roles/webdevops-php/tasks/bootstrap.yml index 5883fa1fe..99a2e5191 100644 --- a/docker/php/ubuntu-15.04/conf/provision/roles/webdevops-php/tasks/bootstrap.yml +++ b/docker/php/ubuntu-15.04/conf/provision/roles/webdevops-php/tasks/bootstrap.yml @@ -1,6 +1,10 @@ --- +- include: bootstrap/init.yml - include: bootstrap/php.yml +- include: bootstrap/php.debian.yml +- include: bootstrap/php.redhat.yml +- include: bootstrap/php.alpine.yml - include: bootstrap/php-fpm.main.yml - include: bootstrap/php-fpm.pool.yml - include: bootstrap/php-fpm.yml diff --git a/docker/php/ubuntu-15.04/conf/provision/roles/webdevops-php/tasks/bootstrap/init.yml b/docker/php/ubuntu-15.04/conf/provision/roles/webdevops-php/tasks/bootstrap/init.yml new file mode 100644 index 000000000..a48bec675 --- /dev/null +++ b/docker/php/ubuntu-15.04/conf/provision/roles/webdevops-php/tasks/bootstrap/init.yml @@ -0,0 +1,71 @@ +--- + +- name: Get php version + command: "php -r 'echo phpversion();'" + changed_when: true + register: php_version_cmd + ignore_errors: true + +- name: Set php_version version + set_fact: + php_version: "{{php_version_cmd.stdout}}" + +############################# +# PHP 5.x +############################# + +- name: Set php main file (RedHat, PHP 5.x) + set_fact: + php_main_conf: /etc/php-fpm.conf + php_pool_conf: www.conf + php_pool_dir: /etc/php-fpm.d + php_fpm_bin: /usr/sbin/php-fpm + when: ansible_os_family == 'RedHat' and ( php_version | version_compare('7.0.0', '<') ) + +- name: Set php main file (Debian, PHP 5.x) + set_fact: + php_etc_dir: /etc/php5 + php_main_conf: /etc/php5/fpm/php-fpm.conf + php_pool_conf: www.conf + php_pool_dir: /etc/php5/fpm/pool.d + php_fpm_bin: /usr/sbin/php5-fpm + when: ansible_os_family == 'Debian' and ( php_version | version_compare('7.0.0', '<') ) + +- name: Set php main file (Alpine, PHP 5.x) + set_fact: + php_etc_dir: /etc/php5 + php_main_conf: /etc/php5/php-fpm.conf + php_pool_conf: www.conf + php_pool_dir: /etc/php5/fpm.d + php_fpm_bin: /usr/bin/php-fpm5 + when: ansible_os_family == 'Alpine' and ( php_version | version_compare('7.0.0', '<') ) + +############################# +# PHP 7.x +############################# + +- name: Set php main file (RedHat, PHP 7.x) + set_fact: + php_main_conf: /etc/php-fpm.conf + php_pool_conf: www.conf + php_pool_dir: /etc/php-fpm.d + php_fpm_bin: /usr/sbin/php-fpm + when: ansible_os_family == 'RedHat' and ( php_version | version_compare('7.0.0', '>=') ) and ( php_version | version_compare('8.0.0', '<') ) + +- name: Set php main file (Debian, PHP 7.x) + set_fact: + php_etc_dir: /etc/php/7.0 + php_main_conf: /etc/php/7.0/fpm/php-fpm.conf + php_pool_conf: www.conf + php_pool_dir: /etc/php/7.0/fpm/pool.d + php_fpm_bin: /usr/sbin/php-fpm7.0 + when: ansible_os_family == 'Debian' and ( php_version | version_compare('7.0.0', '>=') ) and ( php_version | version_compare('8.0.0', '<') ) + +- name: Set php main file (Alpine, PHP 7.x) + set_fact: + php_etc_dir: /etc/php7 + php_main_conf: /etc/php7/php-fpm.conf + php_pool_conf: www.conf + php_pool_dir: /etc/php7/php-fpm.d + php_fpm_bin: /usr/sbin/php-fpm7 + when: ansible_os_family == 'Alpine' and ( php_version | version_compare('7.0.0', '>=') ) and ( php_version | version_compare('8.0.0', '<') ) diff --git a/docker/php/ubuntu-15.04/conf/provision/roles/webdevops-php/tasks/bootstrap/php-fpm.main.yml b/docker/php/ubuntu-15.04/conf/provision/roles/webdevops-php/tasks/bootstrap/php-fpm.main.yml index 1a2c7861f..c149d8728 100644 --- a/docker/php/ubuntu-15.04/conf/provision/roles/webdevops-php/tasks/bootstrap/php-fpm.main.yml +++ b/docker/php/ubuntu-15.04/conf/provision/roles/webdevops-php/tasks/bootstrap/php-fpm.main.yml @@ -1,19 +1,14 @@ --- -- name: Set php main file - set_fact: - php_main_conf: /etc/php-fpm.conf - when: ansible_os_family == 'RedHat' - -- name: Set php main file - set_fact: - php_main_conf: /etc/php5/fpm/php-fpm.conf - when: ansible_os_family == 'Debian' - -- name: Set php main file - set_fact: - php_main_conf: /etc/php5/php-fpm.conf - when: ansible_os_family == 'Alpine' +- name: Create php directories + file: + path: "{{ item }}" + state: directory + mode: 0755 + owner: "root" + group: "root" + with_items: + - /opt/docker/etc/php/fpm/ - name: Move php-fpm main file to /opt/docker/etc/php/fpm/ command: "mv {{ php_main_conf }} /opt/docker/etc/php/fpm/php-fpm.conf" @@ -33,12 +28,22 @@ owner: "root" group: "root" -- name: Configure php-fpm main +- name: Configure php-fpm main (all versions) lineinfile: dest: '/opt/docker/etc/php/fpm/php-fpm.conf' regexp: '^[\s;]*{{ item.key }}[\s]*=' line: '{{ item.key }} = {{ item.value }}' + insertafter: '\[global\]' with_items: - - { key: 'error_log', value: "syslog" } + - { key: 'error_log', value: "/docker.stderr" } - { key: 'pid', value: "/var/run/php-fpm.pid" } + +- name: Configure php-fpm main (php 5.x) + lineinfile: + dest: '/opt/docker/etc/php/fpm/php-fpm.conf' + regexp: '^[\s;]*{{ item.key }}[\s]*=' + line: '{{ item.key }} = {{ item.value }}' + insertbefore: '[\s]*include[\s]*=' + with_items: - { key: 'daemonize', value: 'no' } + when: ( php_version | version_compare('7.0.0', '<') ) diff --git a/docker/php/ubuntu-15.04/conf/provision/roles/webdevops-php/tasks/bootstrap/php-fpm.pool.yml b/docker/php/ubuntu-15.04/conf/provision/roles/webdevops-php/tasks/bootstrap/php-fpm.pool.yml index 53ee9dfe1..ab0b7b02c 100644 --- a/docker/php/ubuntu-15.04/conf/provision/roles/webdevops-php/tasks/bootstrap/php-fpm.pool.yml +++ b/docker/php/ubuntu-15.04/conf/provision/roles/webdevops-php/tasks/bootstrap/php-fpm.pool.yml @@ -1,18 +1,5 @@ --- -- name: Get php version - command: "php -r 'echo phpversion();'" - changed_when: true - register: php_version_cmd - ignore_errors: true - -- name: Set php_version version - set_fact: - php_version: "{{php_version_cmd.stdout}}" - -- debug: - msg: "PHP-Version: {{php_version}}" - - set_fact: php_clear_env_available: False @@ -22,23 +9,10 @@ ( php_version | version_compare('5.5', 'eq') and php_version | version_compare('5.5.11', 'ge') ) or ( php_version | version_compare('5.6', 'ge') ) -- name: Set php pool file - set_fact: - php_pool_conf: www.conf - php_pool_dir: /etc/php-fpm.d - when: ansible_os_family == 'RedHat' - -- name: Set php pool file - set_fact: - php_pool_conf: www.conf - php_pool_dir: /etc/php5/fpm/pool.d - when: ansible_os_family == 'Debian' - -- name: Set php pool file - set_fact: - php_pool_conf: www.conf - php_pool_dir: /etc/php5/fpm.d - when: ansible_os_family == 'Alpine' +- name: Create /opt/docker/etc/php/fpm directory + file: + path: "/opt/docker/etc/php/fpm" + state: directory - name: Move php-fpm pool directory file to /opt/docker/etc/php/ command: "mv {{ php_pool_dir }} /opt/docker/etc/php/fpm/pool.d" @@ -55,7 +29,7 @@ path: "{{ php_pool_dir }}" state: absent -- name: Symlink php-fpm main file +- name: Symlink php-fpm pool file file: path: "{{ php_pool_dir }}" src: "/opt/docker/etc/php/fpm/pool.d" @@ -69,15 +43,25 @@ regexp: '^[\s;]*{{ item.key }}[\s]*=' line: '{{ item.key }} = {{ item.value }}' with_items: - - { key: 'listen', value: "0.0.0.0:9000" } + - { key: 'listen', value: "[::]:9000" } - { key: 'catch_workers_output', value: "yes" } - { key: 'access.format', value: '[php-fpm:access] %R - %u %t "%m %r%Q%q" %s %f %{mili}d %{kilo}M %C%%' } + - { key: 'access.log', value: "/docker.stdout" } - { key: 'slowlog', value: "/docker.stderr" } - { key: 'php_admin_value[error_log]', value: "/docker.stderr" } - { key: 'php_admin_value[log_errors]', value: "on" } - { key: 'user', value: "{{ APPLICATION_USER }}" } - { key: 'group', value: "{{ APPLICATION_GROUP }}" } +- name: Configure php-fpm pool user (application.conf) + lineinfile: + dest: '/opt/docker/etc/php/fpm/pool.d/application.conf' + regexp: '^[\s;]*{{ item.key }}[\s]*=' + line: '{{ item.key }} = {{ item.value }}' + with_items: + - { key: 'listen', value: "0.0.0.0:9000" } + when: php_version | version_compare('5.5.99', '<=') + - name: Configure php-fpm pool user (application.conf) lineinfile: dest: '/opt/docker/etc/php/fpm/pool.d/application.conf' diff --git a/docker/php/ubuntu-15.04/conf/provision/roles/webdevops-php/tasks/bootstrap/php-fpm.yml b/docker/php/ubuntu-15.04/conf/provision/roles/webdevops-php/tasks/bootstrap/php-fpm.yml index d83edb3ae..41c1b33dc 100644 --- a/docker/php/ubuntu-15.04/conf/provision/roles/webdevops-php/tasks/bootstrap/php-fpm.yml +++ b/docker/php/ubuntu-15.04/conf/provision/roles/webdevops-php/tasks/bootstrap/php-fpm.yml @@ -1,45 +1,9 @@ --- -- name: Symlink php-fpm binary [Alpine family] +- name: Symlink php-fpm binary file: - path: "/usr/sbin/php-fpm" - src: "/usr/bin/php-fpm" + path: "/usr/local/bin/php-fpm" + src: "{{ php_fpm_bin }}" state: link owner: "root" group: "root" - when: ansible_os_family == 'Alpine' - -- name: Symlink php-fpm binary [Debian family] - file: - path: "/usr/sbin/php-fpm" - src: "/usr/sbin/php5-fpm" - state: link - owner: "root" - group: "root" - when: ansible_os_family == 'Debian' - -- name: Remove default php-fpm logrotate - file: - path: "/etc/logrotate.d/php-fpm" - state: absent - when: ansible_os_family == 'RedHat' - -- name: Create php-fpm log directory - file: - path: "/var/log/php5-fpm/" - state: directory - owner: "root" - group: "root" - -- name: Create php-fpm log files - file: - path: "/var/log/php5-fpm/{{ item }}" - state: touch - owner: "root" - group: "root" - mode: 0600 - with_items: - - slow.log - - access.log - - error.log - - fpm.log diff --git a/docker/php/ubuntu-15.04/conf/provision/roles/webdevops-php/tasks/bootstrap/php.alpine.yml b/docker/php/ubuntu-15.04/conf/provision/roles/webdevops-php/tasks/bootstrap/php.alpine.yml new file mode 100644 index 000000000..4c16cdf0d --- /dev/null +++ b/docker/php/ubuntu-15.04/conf/provision/roles/webdevops-php/tasks/bootstrap/php.alpine.yml @@ -0,0 +1,12 @@ +--- + +- name: Create link for additional php.ini [Alpine family] + file: + src: '/opt/docker/etc/php/{{ item.file }}' + dest: '{{ php_etc_dir }}/conf.d/{{ item.target }}' + state: link + force: yes + with_items: + - { file: 'php.webdevops.ini', target: 'xzza-webdevops.ini'} + - { file: 'php.ini', target: 'xzzz-docker.ini'} + when: ansible_os_family == 'Alpine' diff --git a/docker/php/ubuntu-15.04/conf/provision/roles/webdevops-php/tasks/bootstrap/php.debian.yml b/docker/php/ubuntu-15.04/conf/provision/roles/webdevops-php/tasks/bootstrap/php.debian.yml new file mode 100644 index 000000000..d27037e33 --- /dev/null +++ b/docker/php/ubuntu-15.04/conf/provision/roles/webdevops-php/tasks/bootstrap/php.debian.yml @@ -0,0 +1,18 @@ +--- + +- name: Link php.ini for cli and fpm [Debian family] + file: + src: '{{ item.file }}' + dest: '{{ php_etc_dir }}/{{ item.category }}/conf.d/{{ item.target }}' + force: yes + state: link + with_items: + # PHP cli + - { category: 'cli', file: '{{ php_etc_dir }}/mods-available/mcrypt.ini', target: '20-mcrypt.ini' } + - { category: 'cli', file: '/opt/docker/etc/php/php.webdevops.ini', target: '98-webdevops.ini' } + - { category: 'cli', file: '/opt/docker/etc/php/php.ini', target: '99-docker.ini' } + # PHP fpm + - { category: 'fpm', file: '{{ php_etc_dir }}/mods-available/mcrypt.ini', target: '20-mcrypt.ini' } + - { category: 'fpm', file: '/opt/docker/etc/php/php.webdevops.ini', target: '98-webdevops.ini' } + - { category: 'fpm', file: '/opt/docker/etc/php/php.ini', target: '99-docker.ini' } + when: ansible_os_family == 'Debian' diff --git a/docker/php/ubuntu-15.04/conf/provision/roles/webdevops-php/tasks/bootstrap/php.redhat.yml b/docker/php/ubuntu-15.04/conf/provision/roles/webdevops-php/tasks/bootstrap/php.redhat.yml new file mode 100644 index 000000000..7e8810231 --- /dev/null +++ b/docker/php/ubuntu-15.04/conf/provision/roles/webdevops-php/tasks/bootstrap/php.redhat.yml @@ -0,0 +1,12 @@ +--- + +- name: Create link for additional php.ini [RedHat family] + file: + src: '/opt/docker/etc/php/{{ item.file }}' + dest: '/etc/php.d/{{ item.target }}' + state: link + force: yes + with_items: + - { file: 'php.webdevops.ini', target: 'zza-webdevops.ini'} + - { file: 'php.ini', target: 'zzz-docker.ini'} + when: ansible_os_family == 'RedHat' diff --git a/docker/php/ubuntu-15.04/conf/provision/roles/webdevops-php/tasks/bootstrap/php.yml b/docker/php/ubuntu-15.04/conf/provision/roles/webdevops-php/tasks/bootstrap/php.yml index 9816b2538..caac8f413 100644 --- a/docker/php/ubuntu-15.04/conf/provision/roles/webdevops-php/tasks/bootstrap/php.yml +++ b/docker/php/ubuntu-15.04/conf/provision/roles/webdevops-php/tasks/bootstrap/php.yml @@ -21,42 +21,3 @@ with_items: - "/opt/docker/etc/php/php.webdevops.ini" - "/opt/docker/etc/php/php.ini" - -- name: Link php.ini for cli and fpm [Debian family] - file: - src: '{{ item.file }}' - dest: '/etc/php5/{{ item.category }}/conf.d/{{ item.target }}' - force: yes - state: link - with_items: - # PHP cli - - { category: 'cli', file: '/etc/php5/mods-available/mcrypt.ini', target: '20-mcrypt.ini' } - - { category: 'cli', file: '/opt/docker/etc/php/php.webdevops.ini', target: '98-webdevops.ini' } - - { category: 'cli', file: '/opt/docker/etc/php/php.ini', target: '99-docker.ini' } - # PHP fpm - - { category: 'fpm', file: '/etc/php5/mods-available/mcrypt.ini', target: '20-mcrypt.ini' } - - { category: 'fpm', file: '/opt/docker/etc/php/php.webdevops.ini', target: '98-webdevops.ini' } - - { category: 'fpm', file: '/opt/docker/etc/php/php.ini', target: '99-docker.ini' } - when: ansible_os_family == 'Debian' - -- name: Create link for additional php.ini [RedHat family] - file: - src: '/opt/docker/etc/php/{{ item.file }}' - dest: '/etc/php.d/{{ item.target }}' - state: link - force: yes - with_items: - - { file: 'php.webdevops.ini', target: 'zza-webdevops.ini'} - - { file: 'php.ini', target: 'zzz-docker.ini'} - when: ansible_os_family == 'RedHat' - -- name: Create link for additional php.ini [Alpine family] - file: - src: '/opt/docker/etc/php/{{ item.file }}' - dest: '/etc/php5/conf.d/{{ item.target }}' - state: link - force: yes - with_items: - - { file: 'php.webdevops.ini', target: 'xzza-webdevops.ini'} - - { file: 'php.ini', target: 'xzzz-docker.ini'} - when: ansible_os_family == 'Alpine' diff --git a/docker/php/ubuntu-15.10/Dockerfile b/docker/php/ubuntu-15.10/Dockerfile index eb1b44bd5..54e798966 100644 --- a/docker/php/ubuntu-15.10/Dockerfile +++ b/docker/php/ubuntu-15.10/Dockerfile @@ -5,14 +5,9 @@ FROM webdevops/base-app:ubuntu-15.10 -MAINTAINER info@webdevops.io -LABEL vendor=WebDevOps.io -LABEL io.webdevops.layout=8 -LABEL io.webdevops.version=1.5.0 - -ENV WEB_DOCUMENT_ROOT /app -ENV WEB_DOCUMENT_INDEX index.php -ENV WEB_ALIAS_DOMAIN *.vm +ENV WEB_DOCUMENT_ROOT=/app \ + WEB_DOCUMENT_INDEX=index.php \ + WEB_ALIAS_DOMAIN=*.vm COPY conf/ /opt/docker/ @@ -48,8 +43,10 @@ RUN /usr/local/bin/apt-install \ && ln -sf /etc/php5/mods-available/mcrypt.in /etc/php5/cli/conf.d/20-mcrypt.ini \ && ln -sf /etc/php5/mods-available/mcrypt.in /etc/php5/fpm/conf.d/20-mcrypt.ini \ && curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin/ --filename=composer \ + # Enable php services + && docker-service-enable syslog cron \ && /opt/docker/bin/provision run --tag bootstrap --role webdevops-php \ - && /opt/docker/bin/bootstrap.sh - + && /opt/docker/bin/bootstrap.sh \ + && docker-image-cleanup EXPOSE 9000 diff --git a/docker/php/ubuntu-15.10/Dockerfile.jinja2 b/docker/php/ubuntu-15.10/Dockerfile.jinja2 index 01313c4f2..82ba14fd7 100644 --- a/docker/php/ubuntu-15.10/Dockerfile.jinja2 +++ b/docker/php/ubuntu-15.10/Dockerfile.jinja2 @@ -1,7 +1,5 @@ {{ docker.from("base-app", "ubuntu-15.10") }} -{{ docker.version() }} - {{ environment.web() }} {{ docker.copy('conf/', '/opt/docker/') }} diff --git a/docker/php/ubuntu-15.10/conf/bin/service.d/php-fpm.d/11-clear-env.sh b/docker/php/ubuntu-15.10/conf/bin/service.d/php-fpm.d/11-clear-env.sh index b17280ce6..ef6fd4016 100644 --- a/docker/php/ubuntu-15.10/conf/bin/service.d/php-fpm.d/11-clear-env.sh +++ b/docker/php/ubuntu-15.10/conf/bin/service.d/php-fpm.d/11-clear-env.sh @@ -30,5 +30,9 @@ for envVariable in $(printenv|cut -f1 -d=); do done # Replace ;#CLEAR_ENV_WORKAROUND# with environment variable list for all php-fpm pool files -find /opt/docker/etc/php/fpm/pool.d/ -iname '*.conf' -print0 | xargs -0 -r rpl --quiet ";#CLEAR_ENV_WORKAROUND#" "$VARIABLE_LIST" > /dev/null +go-replace \ + -s ";#CLEAR_ENV_WORKAROUND#" -r "$VARIABLE_LIST" \ + --path=/opt/docker/etc/php/fpm/pool.d/ \ + --path-pattern='*.conf' \ + --ignore-empty diff --git a/docker/php/ubuntu-15.10/conf/bin/service.d/php-fpm.sh b/docker/php/ubuntu-15.10/conf/bin/service.d/php-fpm.sh index 571f248d2..b25983bd3 100644 --- a/docker/php/ubuntu-15.10/conf/bin/service.d/php-fpm.sh +++ b/docker/php/ubuntu-15.10/conf/bin/service.d/php-fpm.sh @@ -4,4 +4,4 @@ source /opt/docker/bin/config.sh includeScriptDir "/opt/docker/bin/service.d/php-fpm.d/" -exec /usr/sbin/php-fpm --nodaemonize +exec /usr/local/bin/php-fpm --nodaemonize diff --git a/docker/php/ubuntu-15.10/conf/etc/php/php.webdevops.ini b/docker/php/ubuntu-15.10/conf/etc/php/php.webdevops.ini index 562b8d7e2..aa1545ab8 100644 --- a/docker/php/ubuntu-15.10/conf/etc/php/php.webdevops.ini +++ b/docker/php/ubuntu-15.10/conf/etc/php/php.webdevops.ini @@ -5,6 +5,7 @@ ; this file will overwrite default php.ini settings display_errors = 0 +log_errors = 1 short_open_tag = Off variables_order = 'GPCS' diff --git a/docker/php/ubuntu-15.10/conf/provision/roles/webdevops-php/tasks/bootstrap.yml b/docker/php/ubuntu-15.10/conf/provision/roles/webdevops-php/tasks/bootstrap.yml index 5883fa1fe..99a2e5191 100644 --- a/docker/php/ubuntu-15.10/conf/provision/roles/webdevops-php/tasks/bootstrap.yml +++ b/docker/php/ubuntu-15.10/conf/provision/roles/webdevops-php/tasks/bootstrap.yml @@ -1,6 +1,10 @@ --- +- include: bootstrap/init.yml - include: bootstrap/php.yml +- include: bootstrap/php.debian.yml +- include: bootstrap/php.redhat.yml +- include: bootstrap/php.alpine.yml - include: bootstrap/php-fpm.main.yml - include: bootstrap/php-fpm.pool.yml - include: bootstrap/php-fpm.yml diff --git a/docker/php/ubuntu-15.10/conf/provision/roles/webdevops-php/tasks/bootstrap/init.yml b/docker/php/ubuntu-15.10/conf/provision/roles/webdevops-php/tasks/bootstrap/init.yml new file mode 100644 index 000000000..a48bec675 --- /dev/null +++ b/docker/php/ubuntu-15.10/conf/provision/roles/webdevops-php/tasks/bootstrap/init.yml @@ -0,0 +1,71 @@ +--- + +- name: Get php version + command: "php -r 'echo phpversion();'" + changed_when: true + register: php_version_cmd + ignore_errors: true + +- name: Set php_version version + set_fact: + php_version: "{{php_version_cmd.stdout}}" + +############################# +# PHP 5.x +############################# + +- name: Set php main file (RedHat, PHP 5.x) + set_fact: + php_main_conf: /etc/php-fpm.conf + php_pool_conf: www.conf + php_pool_dir: /etc/php-fpm.d + php_fpm_bin: /usr/sbin/php-fpm + when: ansible_os_family == 'RedHat' and ( php_version | version_compare('7.0.0', '<') ) + +- name: Set php main file (Debian, PHP 5.x) + set_fact: + php_etc_dir: /etc/php5 + php_main_conf: /etc/php5/fpm/php-fpm.conf + php_pool_conf: www.conf + php_pool_dir: /etc/php5/fpm/pool.d + php_fpm_bin: /usr/sbin/php5-fpm + when: ansible_os_family == 'Debian' and ( php_version | version_compare('7.0.0', '<') ) + +- name: Set php main file (Alpine, PHP 5.x) + set_fact: + php_etc_dir: /etc/php5 + php_main_conf: /etc/php5/php-fpm.conf + php_pool_conf: www.conf + php_pool_dir: /etc/php5/fpm.d + php_fpm_bin: /usr/bin/php-fpm5 + when: ansible_os_family == 'Alpine' and ( php_version | version_compare('7.0.0', '<') ) + +############################# +# PHP 7.x +############################# + +- name: Set php main file (RedHat, PHP 7.x) + set_fact: + php_main_conf: /etc/php-fpm.conf + php_pool_conf: www.conf + php_pool_dir: /etc/php-fpm.d + php_fpm_bin: /usr/sbin/php-fpm + when: ansible_os_family == 'RedHat' and ( php_version | version_compare('7.0.0', '>=') ) and ( php_version | version_compare('8.0.0', '<') ) + +- name: Set php main file (Debian, PHP 7.x) + set_fact: + php_etc_dir: /etc/php/7.0 + php_main_conf: /etc/php/7.0/fpm/php-fpm.conf + php_pool_conf: www.conf + php_pool_dir: /etc/php/7.0/fpm/pool.d + php_fpm_bin: /usr/sbin/php-fpm7.0 + when: ansible_os_family == 'Debian' and ( php_version | version_compare('7.0.0', '>=') ) and ( php_version | version_compare('8.0.0', '<') ) + +- name: Set php main file (Alpine, PHP 7.x) + set_fact: + php_etc_dir: /etc/php7 + php_main_conf: /etc/php7/php-fpm.conf + php_pool_conf: www.conf + php_pool_dir: /etc/php7/php-fpm.d + php_fpm_bin: /usr/sbin/php-fpm7 + when: ansible_os_family == 'Alpine' and ( php_version | version_compare('7.0.0', '>=') ) and ( php_version | version_compare('8.0.0', '<') ) diff --git a/docker/php/ubuntu-15.10/conf/provision/roles/webdevops-php/tasks/bootstrap/php-fpm.main.yml b/docker/php/ubuntu-15.10/conf/provision/roles/webdevops-php/tasks/bootstrap/php-fpm.main.yml index 1a2c7861f..c149d8728 100644 --- a/docker/php/ubuntu-15.10/conf/provision/roles/webdevops-php/tasks/bootstrap/php-fpm.main.yml +++ b/docker/php/ubuntu-15.10/conf/provision/roles/webdevops-php/tasks/bootstrap/php-fpm.main.yml @@ -1,19 +1,14 @@ --- -- name: Set php main file - set_fact: - php_main_conf: /etc/php-fpm.conf - when: ansible_os_family == 'RedHat' - -- name: Set php main file - set_fact: - php_main_conf: /etc/php5/fpm/php-fpm.conf - when: ansible_os_family == 'Debian' - -- name: Set php main file - set_fact: - php_main_conf: /etc/php5/php-fpm.conf - when: ansible_os_family == 'Alpine' +- name: Create php directories + file: + path: "{{ item }}" + state: directory + mode: 0755 + owner: "root" + group: "root" + with_items: + - /opt/docker/etc/php/fpm/ - name: Move php-fpm main file to /opt/docker/etc/php/fpm/ command: "mv {{ php_main_conf }} /opt/docker/etc/php/fpm/php-fpm.conf" @@ -33,12 +28,22 @@ owner: "root" group: "root" -- name: Configure php-fpm main +- name: Configure php-fpm main (all versions) lineinfile: dest: '/opt/docker/etc/php/fpm/php-fpm.conf' regexp: '^[\s;]*{{ item.key }}[\s]*=' line: '{{ item.key }} = {{ item.value }}' + insertafter: '\[global\]' with_items: - - { key: 'error_log', value: "syslog" } + - { key: 'error_log', value: "/docker.stderr" } - { key: 'pid', value: "/var/run/php-fpm.pid" } + +- name: Configure php-fpm main (php 5.x) + lineinfile: + dest: '/opt/docker/etc/php/fpm/php-fpm.conf' + regexp: '^[\s;]*{{ item.key }}[\s]*=' + line: '{{ item.key }} = {{ item.value }}' + insertbefore: '[\s]*include[\s]*=' + with_items: - { key: 'daemonize', value: 'no' } + when: ( php_version | version_compare('7.0.0', '<') ) diff --git a/docker/php/ubuntu-15.10/conf/provision/roles/webdevops-php/tasks/bootstrap/php-fpm.pool.yml b/docker/php/ubuntu-15.10/conf/provision/roles/webdevops-php/tasks/bootstrap/php-fpm.pool.yml index 53ee9dfe1..ab0b7b02c 100644 --- a/docker/php/ubuntu-15.10/conf/provision/roles/webdevops-php/tasks/bootstrap/php-fpm.pool.yml +++ b/docker/php/ubuntu-15.10/conf/provision/roles/webdevops-php/tasks/bootstrap/php-fpm.pool.yml @@ -1,18 +1,5 @@ --- -- name: Get php version - command: "php -r 'echo phpversion();'" - changed_when: true - register: php_version_cmd - ignore_errors: true - -- name: Set php_version version - set_fact: - php_version: "{{php_version_cmd.stdout}}" - -- debug: - msg: "PHP-Version: {{php_version}}" - - set_fact: php_clear_env_available: False @@ -22,23 +9,10 @@ ( php_version | version_compare('5.5', 'eq') and php_version | version_compare('5.5.11', 'ge') ) or ( php_version | version_compare('5.6', 'ge') ) -- name: Set php pool file - set_fact: - php_pool_conf: www.conf - php_pool_dir: /etc/php-fpm.d - when: ansible_os_family == 'RedHat' - -- name: Set php pool file - set_fact: - php_pool_conf: www.conf - php_pool_dir: /etc/php5/fpm/pool.d - when: ansible_os_family == 'Debian' - -- name: Set php pool file - set_fact: - php_pool_conf: www.conf - php_pool_dir: /etc/php5/fpm.d - when: ansible_os_family == 'Alpine' +- name: Create /opt/docker/etc/php/fpm directory + file: + path: "/opt/docker/etc/php/fpm" + state: directory - name: Move php-fpm pool directory file to /opt/docker/etc/php/ command: "mv {{ php_pool_dir }} /opt/docker/etc/php/fpm/pool.d" @@ -55,7 +29,7 @@ path: "{{ php_pool_dir }}" state: absent -- name: Symlink php-fpm main file +- name: Symlink php-fpm pool file file: path: "{{ php_pool_dir }}" src: "/opt/docker/etc/php/fpm/pool.d" @@ -69,15 +43,25 @@ regexp: '^[\s;]*{{ item.key }}[\s]*=' line: '{{ item.key }} = {{ item.value }}' with_items: - - { key: 'listen', value: "0.0.0.0:9000" } + - { key: 'listen', value: "[::]:9000" } - { key: 'catch_workers_output', value: "yes" } - { key: 'access.format', value: '[php-fpm:access] %R - %u %t "%m %r%Q%q" %s %f %{mili}d %{kilo}M %C%%' } + - { key: 'access.log', value: "/docker.stdout" } - { key: 'slowlog', value: "/docker.stderr" } - { key: 'php_admin_value[error_log]', value: "/docker.stderr" } - { key: 'php_admin_value[log_errors]', value: "on" } - { key: 'user', value: "{{ APPLICATION_USER }}" } - { key: 'group', value: "{{ APPLICATION_GROUP }}" } +- name: Configure php-fpm pool user (application.conf) + lineinfile: + dest: '/opt/docker/etc/php/fpm/pool.d/application.conf' + regexp: '^[\s;]*{{ item.key }}[\s]*=' + line: '{{ item.key }} = {{ item.value }}' + with_items: + - { key: 'listen', value: "0.0.0.0:9000" } + when: php_version | version_compare('5.5.99', '<=') + - name: Configure php-fpm pool user (application.conf) lineinfile: dest: '/opt/docker/etc/php/fpm/pool.d/application.conf' diff --git a/docker/php/ubuntu-15.10/conf/provision/roles/webdevops-php/tasks/bootstrap/php-fpm.yml b/docker/php/ubuntu-15.10/conf/provision/roles/webdevops-php/tasks/bootstrap/php-fpm.yml index d83edb3ae..41c1b33dc 100644 --- a/docker/php/ubuntu-15.10/conf/provision/roles/webdevops-php/tasks/bootstrap/php-fpm.yml +++ b/docker/php/ubuntu-15.10/conf/provision/roles/webdevops-php/tasks/bootstrap/php-fpm.yml @@ -1,45 +1,9 @@ --- -- name: Symlink php-fpm binary [Alpine family] +- name: Symlink php-fpm binary file: - path: "/usr/sbin/php-fpm" - src: "/usr/bin/php-fpm" + path: "/usr/local/bin/php-fpm" + src: "{{ php_fpm_bin }}" state: link owner: "root" group: "root" - when: ansible_os_family == 'Alpine' - -- name: Symlink php-fpm binary [Debian family] - file: - path: "/usr/sbin/php-fpm" - src: "/usr/sbin/php5-fpm" - state: link - owner: "root" - group: "root" - when: ansible_os_family == 'Debian' - -- name: Remove default php-fpm logrotate - file: - path: "/etc/logrotate.d/php-fpm" - state: absent - when: ansible_os_family == 'RedHat' - -- name: Create php-fpm log directory - file: - path: "/var/log/php5-fpm/" - state: directory - owner: "root" - group: "root" - -- name: Create php-fpm log files - file: - path: "/var/log/php5-fpm/{{ item }}" - state: touch - owner: "root" - group: "root" - mode: 0600 - with_items: - - slow.log - - access.log - - error.log - - fpm.log diff --git a/docker/php/ubuntu-15.10/conf/provision/roles/webdevops-php/tasks/bootstrap/php.alpine.yml b/docker/php/ubuntu-15.10/conf/provision/roles/webdevops-php/tasks/bootstrap/php.alpine.yml new file mode 100644 index 000000000..4c16cdf0d --- /dev/null +++ b/docker/php/ubuntu-15.10/conf/provision/roles/webdevops-php/tasks/bootstrap/php.alpine.yml @@ -0,0 +1,12 @@ +--- + +- name: Create link for additional php.ini [Alpine family] + file: + src: '/opt/docker/etc/php/{{ item.file }}' + dest: '{{ php_etc_dir }}/conf.d/{{ item.target }}' + state: link + force: yes + with_items: + - { file: 'php.webdevops.ini', target: 'xzza-webdevops.ini'} + - { file: 'php.ini', target: 'xzzz-docker.ini'} + when: ansible_os_family == 'Alpine' diff --git a/docker/php/ubuntu-15.10/conf/provision/roles/webdevops-php/tasks/bootstrap/php.debian.yml b/docker/php/ubuntu-15.10/conf/provision/roles/webdevops-php/tasks/bootstrap/php.debian.yml new file mode 100644 index 000000000..d27037e33 --- /dev/null +++ b/docker/php/ubuntu-15.10/conf/provision/roles/webdevops-php/tasks/bootstrap/php.debian.yml @@ -0,0 +1,18 @@ +--- + +- name: Link php.ini for cli and fpm [Debian family] + file: + src: '{{ item.file }}' + dest: '{{ php_etc_dir }}/{{ item.category }}/conf.d/{{ item.target }}' + force: yes + state: link + with_items: + # PHP cli + - { category: 'cli', file: '{{ php_etc_dir }}/mods-available/mcrypt.ini', target: '20-mcrypt.ini' } + - { category: 'cli', file: '/opt/docker/etc/php/php.webdevops.ini', target: '98-webdevops.ini' } + - { category: 'cli', file: '/opt/docker/etc/php/php.ini', target: '99-docker.ini' } + # PHP fpm + - { category: 'fpm', file: '{{ php_etc_dir }}/mods-available/mcrypt.ini', target: '20-mcrypt.ini' } + - { category: 'fpm', file: '/opt/docker/etc/php/php.webdevops.ini', target: '98-webdevops.ini' } + - { category: 'fpm', file: '/opt/docker/etc/php/php.ini', target: '99-docker.ini' } + when: ansible_os_family == 'Debian' diff --git a/docker/php/ubuntu-15.10/conf/provision/roles/webdevops-php/tasks/bootstrap/php.redhat.yml b/docker/php/ubuntu-15.10/conf/provision/roles/webdevops-php/tasks/bootstrap/php.redhat.yml new file mode 100644 index 000000000..7e8810231 --- /dev/null +++ b/docker/php/ubuntu-15.10/conf/provision/roles/webdevops-php/tasks/bootstrap/php.redhat.yml @@ -0,0 +1,12 @@ +--- + +- name: Create link for additional php.ini [RedHat family] + file: + src: '/opt/docker/etc/php/{{ item.file }}' + dest: '/etc/php.d/{{ item.target }}' + state: link + force: yes + with_items: + - { file: 'php.webdevops.ini', target: 'zza-webdevops.ini'} + - { file: 'php.ini', target: 'zzz-docker.ini'} + when: ansible_os_family == 'RedHat' diff --git a/docker/php/ubuntu-15.10/conf/provision/roles/webdevops-php/tasks/bootstrap/php.yml b/docker/php/ubuntu-15.10/conf/provision/roles/webdevops-php/tasks/bootstrap/php.yml index 9816b2538..caac8f413 100644 --- a/docker/php/ubuntu-15.10/conf/provision/roles/webdevops-php/tasks/bootstrap/php.yml +++ b/docker/php/ubuntu-15.10/conf/provision/roles/webdevops-php/tasks/bootstrap/php.yml @@ -21,42 +21,3 @@ with_items: - "/opt/docker/etc/php/php.webdevops.ini" - "/opt/docker/etc/php/php.ini" - -- name: Link php.ini for cli and fpm [Debian family] - file: - src: '{{ item.file }}' - dest: '/etc/php5/{{ item.category }}/conf.d/{{ item.target }}' - force: yes - state: link - with_items: - # PHP cli - - { category: 'cli', file: '/etc/php5/mods-available/mcrypt.ini', target: '20-mcrypt.ini' } - - { category: 'cli', file: '/opt/docker/etc/php/php.webdevops.ini', target: '98-webdevops.ini' } - - { category: 'cli', file: '/opt/docker/etc/php/php.ini', target: '99-docker.ini' } - # PHP fpm - - { category: 'fpm', file: '/etc/php5/mods-available/mcrypt.ini', target: '20-mcrypt.ini' } - - { category: 'fpm', file: '/opt/docker/etc/php/php.webdevops.ini', target: '98-webdevops.ini' } - - { category: 'fpm', file: '/opt/docker/etc/php/php.ini', target: '99-docker.ini' } - when: ansible_os_family == 'Debian' - -- name: Create link for additional php.ini [RedHat family] - file: - src: '/opt/docker/etc/php/{{ item.file }}' - dest: '/etc/php.d/{{ item.target }}' - state: link - force: yes - with_items: - - { file: 'php.webdevops.ini', target: 'zza-webdevops.ini'} - - { file: 'php.ini', target: 'zzz-docker.ini'} - when: ansible_os_family == 'RedHat' - -- name: Create link for additional php.ini [Alpine family] - file: - src: '/opt/docker/etc/php/{{ item.file }}' - dest: '/etc/php5/conf.d/{{ item.target }}' - state: link - force: yes - with_items: - - { file: 'php.webdevops.ini', target: 'xzza-webdevops.ini'} - - { file: 'php.ini', target: 'xzzz-docker.ini'} - when: ansible_os_family == 'Alpine' diff --git a/docker/php/ubuntu-16.04/Dockerfile b/docker/php/ubuntu-16.04/Dockerfile index a0d3162f3..f77f8ae51 100644 --- a/docker/php/ubuntu-16.04/Dockerfile +++ b/docker/php/ubuntu-16.04/Dockerfile @@ -5,14 +5,9 @@ FROM webdevops/base-app:ubuntu-16.04 -MAINTAINER info@webdevops.io -LABEL vendor=WebDevOps.io -LABEL io.webdevops.layout=8 -LABEL io.webdevops.version=1.5.0 - -ENV WEB_DOCUMENT_ROOT /app -ENV WEB_DOCUMENT_INDEX index.php -ENV WEB_ALIAS_DOMAIN *.vm +ENV WEB_DOCUMENT_ROOT=/app \ + WEB_DOCUMENT_INDEX=index.php \ + WEB_ALIAS_DOMAIN=*.vm COPY conf/ /opt/docker/ @@ -45,8 +40,10 @@ RUN /usr/local/bin/apt-install \ php-redis \ php-memcached \ && curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin/ --filename=composer \ + # Enable php services + && docker-service-enable syslog cron \ && /opt/docker/bin/provision run --tag bootstrap --role webdevops-php \ - && /opt/docker/bin/bootstrap.sh - + && /opt/docker/bin/bootstrap.sh \ + && docker-image-cleanup EXPOSE 9000 diff --git a/docker/php/ubuntu-16.04/Dockerfile.jinja2 b/docker/php/ubuntu-16.04/Dockerfile.jinja2 index 81a28f909..26d991b30 100644 --- a/docker/php/ubuntu-16.04/Dockerfile.jinja2 +++ b/docker/php/ubuntu-16.04/Dockerfile.jinja2 @@ -1,7 +1,5 @@ {{ docker.from("base-app", "ubuntu-16.04") }} -{{ docker.version() }} - {{ environment.web() }} {{ docker.copy('conf/', '/opt/docker/') }} diff --git a/docker/php/ubuntu-16.04/conf/bin/service.d/php-fpm.d/11-clear-env.sh b/docker/php/ubuntu-16.04/conf/bin/service.d/php-fpm.d/11-clear-env.sh index b17280ce6..ef6fd4016 100644 --- a/docker/php/ubuntu-16.04/conf/bin/service.d/php-fpm.d/11-clear-env.sh +++ b/docker/php/ubuntu-16.04/conf/bin/service.d/php-fpm.d/11-clear-env.sh @@ -30,5 +30,9 @@ for envVariable in $(printenv|cut -f1 -d=); do done # Replace ;#CLEAR_ENV_WORKAROUND# with environment variable list for all php-fpm pool files -find /opt/docker/etc/php/fpm/pool.d/ -iname '*.conf' -print0 | xargs -0 -r rpl --quiet ";#CLEAR_ENV_WORKAROUND#" "$VARIABLE_LIST" > /dev/null +go-replace \ + -s ";#CLEAR_ENV_WORKAROUND#" -r "$VARIABLE_LIST" \ + --path=/opt/docker/etc/php/fpm/pool.d/ \ + --path-pattern='*.conf' \ + --ignore-empty diff --git a/docker/php/ubuntu-16.04/conf/bin/service.d/php-fpm.sh b/docker/php/ubuntu-16.04/conf/bin/service.d/php-fpm.sh index 571f248d2..b25983bd3 100644 --- a/docker/php/ubuntu-16.04/conf/bin/service.d/php-fpm.sh +++ b/docker/php/ubuntu-16.04/conf/bin/service.d/php-fpm.sh @@ -4,4 +4,4 @@ source /opt/docker/bin/config.sh includeScriptDir "/opt/docker/bin/service.d/php-fpm.d/" -exec /usr/sbin/php-fpm --nodaemonize +exec /usr/local/bin/php-fpm --nodaemonize diff --git a/docker/php/ubuntu-16.04/conf/etc/logrotate.d/php7-fpm b/docker/php/ubuntu-16.04/conf/etc/logrotate.d/php7-fpm deleted file mode 100644 index 668f2545f..000000000 --- a/docker/php/ubuntu-16.04/conf/etc/logrotate.d/php7-fpm +++ /dev/null @@ -1,12 +0,0 @@ -/var/log/php7-fpm/fpm.log -/var/log/php7-fpm/access.log -/var/log/php7-fpm/slow.log -/var/log/php7-fpm/error.log { - missingok - notifempty - sharedscripts - delaycompress - postrotate - /bin/kill -SIGUSR1 `cat /var/run/php7-fpm.pid` 2>/dev/null || true - endscript -} diff --git a/docker/php/ubuntu-16.04/conf/etc/php/php.webdevops.ini b/docker/php/ubuntu-16.04/conf/etc/php/php.webdevops.ini index 562b8d7e2..aa1545ab8 100644 --- a/docker/php/ubuntu-16.04/conf/etc/php/php.webdevops.ini +++ b/docker/php/ubuntu-16.04/conf/etc/php/php.webdevops.ini @@ -5,6 +5,7 @@ ; this file will overwrite default php.ini settings display_errors = 0 +log_errors = 1 short_open_tag = Off variables_order = 'GPCS' diff --git a/docker/php/ubuntu-16.04/conf/provision/roles/webdevops-php/tasks/bootstrap.yml b/docker/php/ubuntu-16.04/conf/provision/roles/webdevops-php/tasks/bootstrap.yml index 5883fa1fe..99a2e5191 100644 --- a/docker/php/ubuntu-16.04/conf/provision/roles/webdevops-php/tasks/bootstrap.yml +++ b/docker/php/ubuntu-16.04/conf/provision/roles/webdevops-php/tasks/bootstrap.yml @@ -1,6 +1,10 @@ --- +- include: bootstrap/init.yml - include: bootstrap/php.yml +- include: bootstrap/php.debian.yml +- include: bootstrap/php.redhat.yml +- include: bootstrap/php.alpine.yml - include: bootstrap/php-fpm.main.yml - include: bootstrap/php-fpm.pool.yml - include: bootstrap/php-fpm.yml diff --git a/docker/php/ubuntu-16.04/conf/provision/roles/webdevops-php/tasks/bootstrap/init.yml b/docker/php/ubuntu-16.04/conf/provision/roles/webdevops-php/tasks/bootstrap/init.yml new file mode 100644 index 000000000..a48bec675 --- /dev/null +++ b/docker/php/ubuntu-16.04/conf/provision/roles/webdevops-php/tasks/bootstrap/init.yml @@ -0,0 +1,71 @@ +--- + +- name: Get php version + command: "php -r 'echo phpversion();'" + changed_when: true + register: php_version_cmd + ignore_errors: true + +- name: Set php_version version + set_fact: + php_version: "{{php_version_cmd.stdout}}" + +############################# +# PHP 5.x +############################# + +- name: Set php main file (RedHat, PHP 5.x) + set_fact: + php_main_conf: /etc/php-fpm.conf + php_pool_conf: www.conf + php_pool_dir: /etc/php-fpm.d + php_fpm_bin: /usr/sbin/php-fpm + when: ansible_os_family == 'RedHat' and ( php_version | version_compare('7.0.0', '<') ) + +- name: Set php main file (Debian, PHP 5.x) + set_fact: + php_etc_dir: /etc/php5 + php_main_conf: /etc/php5/fpm/php-fpm.conf + php_pool_conf: www.conf + php_pool_dir: /etc/php5/fpm/pool.d + php_fpm_bin: /usr/sbin/php5-fpm + when: ansible_os_family == 'Debian' and ( php_version | version_compare('7.0.0', '<') ) + +- name: Set php main file (Alpine, PHP 5.x) + set_fact: + php_etc_dir: /etc/php5 + php_main_conf: /etc/php5/php-fpm.conf + php_pool_conf: www.conf + php_pool_dir: /etc/php5/fpm.d + php_fpm_bin: /usr/bin/php-fpm5 + when: ansible_os_family == 'Alpine' and ( php_version | version_compare('7.0.0', '<') ) + +############################# +# PHP 7.x +############################# + +- name: Set php main file (RedHat, PHP 7.x) + set_fact: + php_main_conf: /etc/php-fpm.conf + php_pool_conf: www.conf + php_pool_dir: /etc/php-fpm.d + php_fpm_bin: /usr/sbin/php-fpm + when: ansible_os_family == 'RedHat' and ( php_version | version_compare('7.0.0', '>=') ) and ( php_version | version_compare('8.0.0', '<') ) + +- name: Set php main file (Debian, PHP 7.x) + set_fact: + php_etc_dir: /etc/php/7.0 + php_main_conf: /etc/php/7.0/fpm/php-fpm.conf + php_pool_conf: www.conf + php_pool_dir: /etc/php/7.0/fpm/pool.d + php_fpm_bin: /usr/sbin/php-fpm7.0 + when: ansible_os_family == 'Debian' and ( php_version | version_compare('7.0.0', '>=') ) and ( php_version | version_compare('8.0.0', '<') ) + +- name: Set php main file (Alpine, PHP 7.x) + set_fact: + php_etc_dir: /etc/php7 + php_main_conf: /etc/php7/php-fpm.conf + php_pool_conf: www.conf + php_pool_dir: /etc/php7/php-fpm.d + php_fpm_bin: /usr/sbin/php-fpm7 + when: ansible_os_family == 'Alpine' and ( php_version | version_compare('7.0.0', '>=') ) and ( php_version | version_compare('8.0.0', '<') ) diff --git a/docker/php/ubuntu-16.04/conf/provision/roles/webdevops-php/tasks/bootstrap/php-fpm.main.yml b/docker/php/ubuntu-16.04/conf/provision/roles/webdevops-php/tasks/bootstrap/php-fpm.main.yml index 36143a96f..c149d8728 100644 --- a/docker/php/ubuntu-16.04/conf/provision/roles/webdevops-php/tasks/bootstrap/php-fpm.main.yml +++ b/docker/php/ubuntu-16.04/conf/provision/roles/webdevops-php/tasks/bootstrap/php-fpm.main.yml @@ -1,20 +1,5 @@ --- -- name: Set php main file - set_fact: - php_main_conf: /etc/php-fpm.conf - when: ansible_os_family == 'RedHat' - -- name: Set php main file - set_fact: - php_main_conf: /etc/php/7.0/fpm/php-fpm.conf - when: ansible_os_family == 'Debian' - -- name: Set php main file - set_fact: - php_main_conf: /etc/php7/php-fpm.conf - when: ansible_os_family == 'Alpine' - - name: Create php directories file: path: "{{ item }}" @@ -43,11 +28,22 @@ owner: "root" group: "root" -- name: Configure php-fpm main +- name: Configure php-fpm main (all versions) + lineinfile: + dest: '/opt/docker/etc/php/fpm/php-fpm.conf' + regexp: '^[\s;]*{{ item.key }}[\s]*=' + line: '{{ item.key }} = {{ item.value }}' + insertafter: '\[global\]' + with_items: + - { key: 'error_log', value: "/docker.stderr" } + - { key: 'pid', value: "/var/run/php-fpm.pid" } + +- name: Configure php-fpm main (php 5.x) lineinfile: dest: '/opt/docker/etc/php/fpm/php-fpm.conf' regexp: '^[\s;]*{{ item.key }}[\s]*=' line: '{{ item.key }} = {{ item.value }}' + insertbefore: '[\s]*include[\s]*=' with_items: - - { key: 'error_log', value: "syslog" } - - { key: 'pid', value: "/var/run/php-fpm.pid" } + - { key: 'daemonize', value: 'no' } + when: ( php_version | version_compare('7.0.0', '<') ) diff --git a/docker/php/ubuntu-16.04/conf/provision/roles/webdevops-php/tasks/bootstrap/php-fpm.pool.yml b/docker/php/ubuntu-16.04/conf/provision/roles/webdevops-php/tasks/bootstrap/php-fpm.pool.yml index d91ecab7f..ab0b7b02c 100644 --- a/docker/php/ubuntu-16.04/conf/provision/roles/webdevops-php/tasks/bootstrap/php-fpm.pool.yml +++ b/docker/php/ubuntu-16.04/conf/provision/roles/webdevops-php/tasks/bootstrap/php-fpm.pool.yml @@ -1,44 +1,18 @@ --- -- name: Get php version - command: "php -r 'echo phpversion();'" - changed_when: true - register: php_version_cmd - ignore_errors: true -- name: Set php_version version - set_fact: - php_version: "{{php_version_cmd.stdout}}" +- set_fact: + php_clear_env_available: False -- debug: - msg: "PHP-Version: {{php_version}}" +- set_fact: + php_clear_env_available: True + when: ( php_version | version_compare('5.4', 'eq') and php_version | version_compare('5.4.27', 'ge') ) or + ( php_version | version_compare('5.5', 'eq') and php_version | version_compare('5.5.11', 'ge') ) or + ( php_version | version_compare('5.6', 'ge') ) -- name: Set php pool file - set_fact: - php_pool_conf: www.conf - php_pool_dir: /etc/php-fpm.d - when: ansible_os_family == 'RedHat' - -- name: Set php pool file - set_fact: - php_pool_conf: www.conf - php_pool_dir: /etc/php/7.0/fpm/pool.d - when: ansible_os_family == 'Debian' - -- name: Set php pool file - set_fact: - php_pool_conf: www.conf - php_pool_dir: /etc/php7/php-fpm.d - when: ansible_os_family == 'Alpine' - -- name: Create php directories +- name: Create /opt/docker/etc/php/fpm directory file: - path: "{{ item }}" + path: "/opt/docker/etc/php/fpm" state: directory - mode: 0755 - owner: "root" - group: "root" - with_items: - - /opt/docker/etc/php/fpm/ - name: Move php-fpm pool directory file to /opt/docker/etc/php/ command: "mv {{ php_pool_dir }} /opt/docker/etc/php/fpm/pool.d" @@ -55,7 +29,7 @@ path: "{{ php_pool_dir }}" state: absent -- name: Symlink php-fpm main file +- name: Symlink php-fpm pool file file: path: "{{ php_pool_dir }}" src: "/opt/docker/etc/php/fpm/pool.d" @@ -63,24 +37,60 @@ owner: "root" group: "root" - -- name: Configure php-fpm pool user (www.conf) +- name: Configure php-fpm pool user (application.conf) lineinfile: dest: '/opt/docker/etc/php/fpm/pool.d/application.conf' regexp: '^[\s;]*{{ item.key }}[\s]*=' line: '{{ item.key }} = {{ item.value }}' with_items: - - { key: 'listen', value: "0.0.0.0:9000" } + - { key: 'listen', value: "[::]:9000" } - { key: 'catch_workers_output', value: "yes" } - { key: 'access.format', value: '[php-fpm:access] %R - %u %t "%m %r%Q%q" %s %f %{mili}d %{kilo}M %C%%' } - { key: 'access.log', value: "/docker.stdout" } - { key: 'slowlog', value: "/docker.stderr" } - { key: 'php_admin_value[error_log]', value: "/docker.stderr" } - { key: 'php_admin_value[log_errors]', value: "on" } - - { key: 'clear_env', value: "no" } - { key: 'user', value: "{{ APPLICATION_USER }}" } - { key: 'group', value: "{{ APPLICATION_GROUP }}" } +- name: Configure php-fpm pool user (application.conf) + lineinfile: + dest: '/opt/docker/etc/php/fpm/pool.d/application.conf' + regexp: '^[\s;]*{{ item.key }}[\s]*=' + line: '{{ item.key }} = {{ item.value }}' + with_items: + - { key: 'listen', value: "0.0.0.0:9000" } + when: php_version | version_compare('5.5.99', '<=') + +- name: Configure php-fpm pool user (application.conf) + lineinfile: + dest: '/opt/docker/etc/php/fpm/pool.d/application.conf' + regexp: '^[\s;]*{{ item.key }}[\s]*=' + line: ';{{ item.key }} = {{ item.value }}' + with_items: + - { key: 'access.log', value: "/docker.stdout" } + +- name: Disable clear env in php-fpm pool + lineinfile: + dest: '/opt/docker/etc/php/fpm/pool.d/application.conf' + regexp: '^[\s;]*{{ item.key }}[\s]*=' + line: '{{ item.key }} = {{ item.value }}' + with_items: + - { key: 'clear_env', value: "no" } + when: php_clear_env_available == True + +- name: Remove clear env workaround + file: + path: "/opt/docker/bin/service.d/php-fpm.d/11-clear-env.sh" + state: absent + when: php_clear_env_available == True + +- name: Append clear env workaround in php-fpm pool (old php-fpm versions) + lineinfile: + dest: '/opt/docker/etc/php/fpm/pool.d/application.conf' + line: ';#CLEAR_ENV_WORKAROUND#' + when: php_clear_env_available == False + - name: Disable php-fpm connection limit lineinfile: dest: '/opt/docker/etc/php/fpm/pool.d/application.conf' diff --git a/docker/php/ubuntu-16.04/conf/provision/roles/webdevops-php/tasks/bootstrap/php-fpm.yml b/docker/php/ubuntu-16.04/conf/provision/roles/webdevops-php/tasks/bootstrap/php-fpm.yml index 130542f53..41c1b33dc 100644 --- a/docker/php/ubuntu-16.04/conf/provision/roles/webdevops-php/tasks/bootstrap/php-fpm.yml +++ b/docker/php/ubuntu-16.04/conf/provision/roles/webdevops-php/tasks/bootstrap/php-fpm.yml @@ -1,54 +1,9 @@ --- -- name: Symlink php-fpm binary [RedHat family] +- name: Symlink php-fpm binary file: - path: "/usr/sbin/php-fpm7.0" - src: "/usr/sbin/php-fpm" + path: "/usr/local/bin/php-fpm" + src: "{{ php_fpm_bin }}" state: link owner: "root" group: "root" - when: ansible_os_family == 'RedHat' - -- name: Symlink php-fpm binary [Alpine family] - file: - path: "/usr/sbin/php-fpm" - src: "/usr/sbin/php-fpm7" - state: link - owner: "root" - group: "root" - when: ansible_os_family == 'Alpine' - -- name: Symlink php-fpm binary [Debian family] - file: - path: "/usr/sbin/php-fpm" - src: "/usr/sbin/php-fpm7.0" - state: link - owner: "root" - group: "root" - when: ansible_os_family == 'Debian' - -- name: Remove default php-fpm logrotate - file: - path: "/etc/logrotate.d/php-fpm" - state: absent - when: ansible_os_family == 'RedHat' - -- name: Create php-fpm log directory - file: - path: "/var/log/php7-fpm/" - state: directory - owner: "root" - group: "root" - -- name: Create php-fpm log files - file: - path: "/var/log/php7-fpm/{{ item }}" - state: touch - owner: "root" - group: "root" - mode: 0600 - with_items: - - slow.log - - access.log - - error.log - - fpm.log diff --git a/docker/php/ubuntu-16.04/conf/provision/roles/webdevops-php/tasks/bootstrap/php.alpine.yml b/docker/php/ubuntu-16.04/conf/provision/roles/webdevops-php/tasks/bootstrap/php.alpine.yml new file mode 100644 index 000000000..4c16cdf0d --- /dev/null +++ b/docker/php/ubuntu-16.04/conf/provision/roles/webdevops-php/tasks/bootstrap/php.alpine.yml @@ -0,0 +1,12 @@ +--- + +- name: Create link for additional php.ini [Alpine family] + file: + src: '/opt/docker/etc/php/{{ item.file }}' + dest: '{{ php_etc_dir }}/conf.d/{{ item.target }}' + state: link + force: yes + with_items: + - { file: 'php.webdevops.ini', target: 'xzza-webdevops.ini'} + - { file: 'php.ini', target: 'xzzz-docker.ini'} + when: ansible_os_family == 'Alpine' diff --git a/docker/php/ubuntu-16.04/conf/provision/roles/webdevops-php/tasks/bootstrap/php.debian.yml b/docker/php/ubuntu-16.04/conf/provision/roles/webdevops-php/tasks/bootstrap/php.debian.yml new file mode 100644 index 000000000..d27037e33 --- /dev/null +++ b/docker/php/ubuntu-16.04/conf/provision/roles/webdevops-php/tasks/bootstrap/php.debian.yml @@ -0,0 +1,18 @@ +--- + +- name: Link php.ini for cli and fpm [Debian family] + file: + src: '{{ item.file }}' + dest: '{{ php_etc_dir }}/{{ item.category }}/conf.d/{{ item.target }}' + force: yes + state: link + with_items: + # PHP cli + - { category: 'cli', file: '{{ php_etc_dir }}/mods-available/mcrypt.ini', target: '20-mcrypt.ini' } + - { category: 'cli', file: '/opt/docker/etc/php/php.webdevops.ini', target: '98-webdevops.ini' } + - { category: 'cli', file: '/opt/docker/etc/php/php.ini', target: '99-docker.ini' } + # PHP fpm + - { category: 'fpm', file: '{{ php_etc_dir }}/mods-available/mcrypt.ini', target: '20-mcrypt.ini' } + - { category: 'fpm', file: '/opt/docker/etc/php/php.webdevops.ini', target: '98-webdevops.ini' } + - { category: 'fpm', file: '/opt/docker/etc/php/php.ini', target: '99-docker.ini' } + when: ansible_os_family == 'Debian' diff --git a/docker/php/ubuntu-16.04/conf/provision/roles/webdevops-php/tasks/bootstrap/php.redhat.yml b/docker/php/ubuntu-16.04/conf/provision/roles/webdevops-php/tasks/bootstrap/php.redhat.yml new file mode 100644 index 000000000..7e8810231 --- /dev/null +++ b/docker/php/ubuntu-16.04/conf/provision/roles/webdevops-php/tasks/bootstrap/php.redhat.yml @@ -0,0 +1,12 @@ +--- + +- name: Create link for additional php.ini [RedHat family] + file: + src: '/opt/docker/etc/php/{{ item.file }}' + dest: '/etc/php.d/{{ item.target }}' + state: link + force: yes + with_items: + - { file: 'php.webdevops.ini', target: 'zza-webdevops.ini'} + - { file: 'php.ini', target: 'zzz-docker.ini'} + when: ansible_os_family == 'RedHat' diff --git a/docker/php/ubuntu-16.04/conf/provision/roles/webdevops-php/tasks/bootstrap/php.yml b/docker/php/ubuntu-16.04/conf/provision/roles/webdevops-php/tasks/bootstrap/php.yml index 97f02eec3..caac8f413 100644 --- a/docker/php/ubuntu-16.04/conf/provision/roles/webdevops-php/tasks/bootstrap/php.yml +++ b/docker/php/ubuntu-16.04/conf/provision/roles/webdevops-php/tasks/bootstrap/php.yml @@ -11,7 +11,7 @@ - /opt/docker/etc/php/ - /opt/docker/etc/php/fpm/ -- name: Create /opt/docker/etc/php/php.ini" +- name: Create php.ini files file: path: "{{ item }}" state: touch @@ -21,40 +21,3 @@ with_items: - "/opt/docker/etc/php/php.webdevops.ini" - "/opt/docker/etc/php/php.ini" - -- name: Link php.ini for cli and fpm - file: - src: '{{ item.file }}' - dest: '/etc/php/7.0/{{ item.category }}/conf.d/{{ item.target }}' - force: yes - state: link - with_items: - # PHP cli - - { category: 'cli', file: '/opt/docker/etc/php/php.webdevops.ini', target: '98-webdevops.ini' } - - { category: 'cli', file: '/opt/docker/etc/php/php.ini', target: '99-docker.ini' } - # PHP fpm - - { category: 'fpm', file: '/opt/docker/etc/php/php.webdevops.ini', target: '98-webdevops.ini' } - - { category: 'fpm', file: '/opt/docker/etc/php/php.ini', target: '99-docker.ini' } - when: ansible_os_family == 'Debian' - -- name: Create link for additional php.ini [RedHat family] - file: - src: '/opt/docker/etc/php/{{ item.file }}' - dest: '/etc/php.d/{{ item.target }}' - state: link - force: yes - with_items: - - { file: 'php.webdevops.ini', target: 'zza-webdevops.ini'} - - { file: 'php.ini', target: 'zzz-docker.ini'} - when: ansible_os_family == 'RedHat' - -- name: Link php.ini - file: - src: '/opt/docker/etc/php/{{ item.file }}' - dest: '/etc/php7/conf.d/{{ item.target }}' - force: yes - state: link - with_items: - - { file: 'php.webdevops.ini', target: 'xzza-webdevops.ini'} - - { file: 'php.ini', target: 'xzzz-docker.ini'} - when: ansible_os_family == 'Alpine' diff --git a/docker/php/ubuntu-16.10/Dockerfile b/docker/php/ubuntu-16.10/Dockerfile index 15e960fe9..d46d4e546 100644 --- a/docker/php/ubuntu-16.10/Dockerfile +++ b/docker/php/ubuntu-16.10/Dockerfile @@ -5,14 +5,9 @@ FROM webdevops/base-app:ubuntu-16.10 -MAINTAINER info@webdevops.io -LABEL vendor=WebDevOps.io -LABEL io.webdevops.layout=8 -LABEL io.webdevops.version=1.5.0 - -ENV WEB_DOCUMENT_ROOT /app -ENV WEB_DOCUMENT_INDEX index.php -ENV WEB_ALIAS_DOMAIN *.vm +ENV WEB_DOCUMENT_ROOT=/app \ + WEB_DOCUMENT_INDEX=index.php \ + WEB_ALIAS_DOMAIN=*.vm COPY conf/ /opt/docker/ @@ -45,8 +40,10 @@ RUN /usr/local/bin/apt-install \ php-redis \ php-memcached \ && curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin/ --filename=composer \ + # Enable php services + && docker-service-enable syslog cron \ && /opt/docker/bin/provision run --tag bootstrap --role webdevops-php \ - && /opt/docker/bin/bootstrap.sh - + && /opt/docker/bin/bootstrap.sh \ + && docker-image-cleanup EXPOSE 9000 diff --git a/docker/php/ubuntu-16.10/Dockerfile.jinja2 b/docker/php/ubuntu-16.10/Dockerfile.jinja2 index 4934d769d..2ec2c6c3a 100644 --- a/docker/php/ubuntu-16.10/Dockerfile.jinja2 +++ b/docker/php/ubuntu-16.10/Dockerfile.jinja2 @@ -1,7 +1,5 @@ {{ docker.from("base-app", "ubuntu-16.10") }} -{{ docker.version() }} - {{ environment.web() }} {{ docker.copy('conf/', '/opt/docker/') }} diff --git a/docker/php/ubuntu-16.10/conf/bin/service.d/php-fpm.d/11-clear-env.sh b/docker/php/ubuntu-16.10/conf/bin/service.d/php-fpm.d/11-clear-env.sh index b17280ce6..ef6fd4016 100644 --- a/docker/php/ubuntu-16.10/conf/bin/service.d/php-fpm.d/11-clear-env.sh +++ b/docker/php/ubuntu-16.10/conf/bin/service.d/php-fpm.d/11-clear-env.sh @@ -30,5 +30,9 @@ for envVariable in $(printenv|cut -f1 -d=); do done # Replace ;#CLEAR_ENV_WORKAROUND# with environment variable list for all php-fpm pool files -find /opt/docker/etc/php/fpm/pool.d/ -iname '*.conf' -print0 | xargs -0 -r rpl --quiet ";#CLEAR_ENV_WORKAROUND#" "$VARIABLE_LIST" > /dev/null +go-replace \ + -s ";#CLEAR_ENV_WORKAROUND#" -r "$VARIABLE_LIST" \ + --path=/opt/docker/etc/php/fpm/pool.d/ \ + --path-pattern='*.conf' \ + --ignore-empty diff --git a/docker/php/ubuntu-16.10/conf/bin/service.d/php-fpm.sh b/docker/php/ubuntu-16.10/conf/bin/service.d/php-fpm.sh index 571f248d2..b25983bd3 100644 --- a/docker/php/ubuntu-16.10/conf/bin/service.d/php-fpm.sh +++ b/docker/php/ubuntu-16.10/conf/bin/service.d/php-fpm.sh @@ -4,4 +4,4 @@ source /opt/docker/bin/config.sh includeScriptDir "/opt/docker/bin/service.d/php-fpm.d/" -exec /usr/sbin/php-fpm --nodaemonize +exec /usr/local/bin/php-fpm --nodaemonize diff --git a/docker/php/ubuntu-16.10/conf/etc/logrotate.d/php7-fpm b/docker/php/ubuntu-16.10/conf/etc/logrotate.d/php7-fpm deleted file mode 100644 index 668f2545f..000000000 --- a/docker/php/ubuntu-16.10/conf/etc/logrotate.d/php7-fpm +++ /dev/null @@ -1,12 +0,0 @@ -/var/log/php7-fpm/fpm.log -/var/log/php7-fpm/access.log -/var/log/php7-fpm/slow.log -/var/log/php7-fpm/error.log { - missingok - notifempty - sharedscripts - delaycompress - postrotate - /bin/kill -SIGUSR1 `cat /var/run/php7-fpm.pid` 2>/dev/null || true - endscript -} diff --git a/docker/php/ubuntu-16.10/conf/etc/php/php.webdevops.ini b/docker/php/ubuntu-16.10/conf/etc/php/php.webdevops.ini index 562b8d7e2..aa1545ab8 100644 --- a/docker/php/ubuntu-16.10/conf/etc/php/php.webdevops.ini +++ b/docker/php/ubuntu-16.10/conf/etc/php/php.webdevops.ini @@ -5,6 +5,7 @@ ; this file will overwrite default php.ini settings display_errors = 0 +log_errors = 1 short_open_tag = Off variables_order = 'GPCS' diff --git a/docker/php/ubuntu-16.10/conf/provision/roles/webdevops-php/tasks/bootstrap.yml b/docker/php/ubuntu-16.10/conf/provision/roles/webdevops-php/tasks/bootstrap.yml index 5883fa1fe..99a2e5191 100644 --- a/docker/php/ubuntu-16.10/conf/provision/roles/webdevops-php/tasks/bootstrap.yml +++ b/docker/php/ubuntu-16.10/conf/provision/roles/webdevops-php/tasks/bootstrap.yml @@ -1,6 +1,10 @@ --- +- include: bootstrap/init.yml - include: bootstrap/php.yml +- include: bootstrap/php.debian.yml +- include: bootstrap/php.redhat.yml +- include: bootstrap/php.alpine.yml - include: bootstrap/php-fpm.main.yml - include: bootstrap/php-fpm.pool.yml - include: bootstrap/php-fpm.yml diff --git a/docker/php/ubuntu-16.10/conf/provision/roles/webdevops-php/tasks/bootstrap/init.yml b/docker/php/ubuntu-16.10/conf/provision/roles/webdevops-php/tasks/bootstrap/init.yml new file mode 100644 index 000000000..a48bec675 --- /dev/null +++ b/docker/php/ubuntu-16.10/conf/provision/roles/webdevops-php/tasks/bootstrap/init.yml @@ -0,0 +1,71 @@ +--- + +- name: Get php version + command: "php -r 'echo phpversion();'" + changed_when: true + register: php_version_cmd + ignore_errors: true + +- name: Set php_version version + set_fact: + php_version: "{{php_version_cmd.stdout}}" + +############################# +# PHP 5.x +############################# + +- name: Set php main file (RedHat, PHP 5.x) + set_fact: + php_main_conf: /etc/php-fpm.conf + php_pool_conf: www.conf + php_pool_dir: /etc/php-fpm.d + php_fpm_bin: /usr/sbin/php-fpm + when: ansible_os_family == 'RedHat' and ( php_version | version_compare('7.0.0', '<') ) + +- name: Set php main file (Debian, PHP 5.x) + set_fact: + php_etc_dir: /etc/php5 + php_main_conf: /etc/php5/fpm/php-fpm.conf + php_pool_conf: www.conf + php_pool_dir: /etc/php5/fpm/pool.d + php_fpm_bin: /usr/sbin/php5-fpm + when: ansible_os_family == 'Debian' and ( php_version | version_compare('7.0.0', '<') ) + +- name: Set php main file (Alpine, PHP 5.x) + set_fact: + php_etc_dir: /etc/php5 + php_main_conf: /etc/php5/php-fpm.conf + php_pool_conf: www.conf + php_pool_dir: /etc/php5/fpm.d + php_fpm_bin: /usr/bin/php-fpm5 + when: ansible_os_family == 'Alpine' and ( php_version | version_compare('7.0.0', '<') ) + +############################# +# PHP 7.x +############################# + +- name: Set php main file (RedHat, PHP 7.x) + set_fact: + php_main_conf: /etc/php-fpm.conf + php_pool_conf: www.conf + php_pool_dir: /etc/php-fpm.d + php_fpm_bin: /usr/sbin/php-fpm + when: ansible_os_family == 'RedHat' and ( php_version | version_compare('7.0.0', '>=') ) and ( php_version | version_compare('8.0.0', '<') ) + +- name: Set php main file (Debian, PHP 7.x) + set_fact: + php_etc_dir: /etc/php/7.0 + php_main_conf: /etc/php/7.0/fpm/php-fpm.conf + php_pool_conf: www.conf + php_pool_dir: /etc/php/7.0/fpm/pool.d + php_fpm_bin: /usr/sbin/php-fpm7.0 + when: ansible_os_family == 'Debian' and ( php_version | version_compare('7.0.0', '>=') ) and ( php_version | version_compare('8.0.0', '<') ) + +- name: Set php main file (Alpine, PHP 7.x) + set_fact: + php_etc_dir: /etc/php7 + php_main_conf: /etc/php7/php-fpm.conf + php_pool_conf: www.conf + php_pool_dir: /etc/php7/php-fpm.d + php_fpm_bin: /usr/sbin/php-fpm7 + when: ansible_os_family == 'Alpine' and ( php_version | version_compare('7.0.0', '>=') ) and ( php_version | version_compare('8.0.0', '<') ) diff --git a/docker/php/ubuntu-16.10/conf/provision/roles/webdevops-php/tasks/bootstrap/php-fpm.main.yml b/docker/php/ubuntu-16.10/conf/provision/roles/webdevops-php/tasks/bootstrap/php-fpm.main.yml index 36143a96f..c149d8728 100644 --- a/docker/php/ubuntu-16.10/conf/provision/roles/webdevops-php/tasks/bootstrap/php-fpm.main.yml +++ b/docker/php/ubuntu-16.10/conf/provision/roles/webdevops-php/tasks/bootstrap/php-fpm.main.yml @@ -1,20 +1,5 @@ --- -- name: Set php main file - set_fact: - php_main_conf: /etc/php-fpm.conf - when: ansible_os_family == 'RedHat' - -- name: Set php main file - set_fact: - php_main_conf: /etc/php/7.0/fpm/php-fpm.conf - when: ansible_os_family == 'Debian' - -- name: Set php main file - set_fact: - php_main_conf: /etc/php7/php-fpm.conf - when: ansible_os_family == 'Alpine' - - name: Create php directories file: path: "{{ item }}" @@ -43,11 +28,22 @@ owner: "root" group: "root" -- name: Configure php-fpm main +- name: Configure php-fpm main (all versions) + lineinfile: + dest: '/opt/docker/etc/php/fpm/php-fpm.conf' + regexp: '^[\s;]*{{ item.key }}[\s]*=' + line: '{{ item.key }} = {{ item.value }}' + insertafter: '\[global\]' + with_items: + - { key: 'error_log', value: "/docker.stderr" } + - { key: 'pid', value: "/var/run/php-fpm.pid" } + +- name: Configure php-fpm main (php 5.x) lineinfile: dest: '/opt/docker/etc/php/fpm/php-fpm.conf' regexp: '^[\s;]*{{ item.key }}[\s]*=' line: '{{ item.key }} = {{ item.value }}' + insertbefore: '[\s]*include[\s]*=' with_items: - - { key: 'error_log', value: "syslog" } - - { key: 'pid', value: "/var/run/php-fpm.pid" } + - { key: 'daemonize', value: 'no' } + when: ( php_version | version_compare('7.0.0', '<') ) diff --git a/docker/php/ubuntu-16.10/conf/provision/roles/webdevops-php/tasks/bootstrap/php-fpm.pool.yml b/docker/php/ubuntu-16.10/conf/provision/roles/webdevops-php/tasks/bootstrap/php-fpm.pool.yml index d91ecab7f..ab0b7b02c 100644 --- a/docker/php/ubuntu-16.10/conf/provision/roles/webdevops-php/tasks/bootstrap/php-fpm.pool.yml +++ b/docker/php/ubuntu-16.10/conf/provision/roles/webdevops-php/tasks/bootstrap/php-fpm.pool.yml @@ -1,44 +1,18 @@ --- -- name: Get php version - command: "php -r 'echo phpversion();'" - changed_when: true - register: php_version_cmd - ignore_errors: true -- name: Set php_version version - set_fact: - php_version: "{{php_version_cmd.stdout}}" +- set_fact: + php_clear_env_available: False -- debug: - msg: "PHP-Version: {{php_version}}" +- set_fact: + php_clear_env_available: True + when: ( php_version | version_compare('5.4', 'eq') and php_version | version_compare('5.4.27', 'ge') ) or + ( php_version | version_compare('5.5', 'eq') and php_version | version_compare('5.5.11', 'ge') ) or + ( php_version | version_compare('5.6', 'ge') ) -- name: Set php pool file - set_fact: - php_pool_conf: www.conf - php_pool_dir: /etc/php-fpm.d - when: ansible_os_family == 'RedHat' - -- name: Set php pool file - set_fact: - php_pool_conf: www.conf - php_pool_dir: /etc/php/7.0/fpm/pool.d - when: ansible_os_family == 'Debian' - -- name: Set php pool file - set_fact: - php_pool_conf: www.conf - php_pool_dir: /etc/php7/php-fpm.d - when: ansible_os_family == 'Alpine' - -- name: Create php directories +- name: Create /opt/docker/etc/php/fpm directory file: - path: "{{ item }}" + path: "/opt/docker/etc/php/fpm" state: directory - mode: 0755 - owner: "root" - group: "root" - with_items: - - /opt/docker/etc/php/fpm/ - name: Move php-fpm pool directory file to /opt/docker/etc/php/ command: "mv {{ php_pool_dir }} /opt/docker/etc/php/fpm/pool.d" @@ -55,7 +29,7 @@ path: "{{ php_pool_dir }}" state: absent -- name: Symlink php-fpm main file +- name: Symlink php-fpm pool file file: path: "{{ php_pool_dir }}" src: "/opt/docker/etc/php/fpm/pool.d" @@ -63,24 +37,60 @@ owner: "root" group: "root" - -- name: Configure php-fpm pool user (www.conf) +- name: Configure php-fpm pool user (application.conf) lineinfile: dest: '/opt/docker/etc/php/fpm/pool.d/application.conf' regexp: '^[\s;]*{{ item.key }}[\s]*=' line: '{{ item.key }} = {{ item.value }}' with_items: - - { key: 'listen', value: "0.0.0.0:9000" } + - { key: 'listen', value: "[::]:9000" } - { key: 'catch_workers_output', value: "yes" } - { key: 'access.format', value: '[php-fpm:access] %R - %u %t "%m %r%Q%q" %s %f %{mili}d %{kilo}M %C%%' } - { key: 'access.log', value: "/docker.stdout" } - { key: 'slowlog', value: "/docker.stderr" } - { key: 'php_admin_value[error_log]', value: "/docker.stderr" } - { key: 'php_admin_value[log_errors]', value: "on" } - - { key: 'clear_env', value: "no" } - { key: 'user', value: "{{ APPLICATION_USER }}" } - { key: 'group', value: "{{ APPLICATION_GROUP }}" } +- name: Configure php-fpm pool user (application.conf) + lineinfile: + dest: '/opt/docker/etc/php/fpm/pool.d/application.conf' + regexp: '^[\s;]*{{ item.key }}[\s]*=' + line: '{{ item.key }} = {{ item.value }}' + with_items: + - { key: 'listen', value: "0.0.0.0:9000" } + when: php_version | version_compare('5.5.99', '<=') + +- name: Configure php-fpm pool user (application.conf) + lineinfile: + dest: '/opt/docker/etc/php/fpm/pool.d/application.conf' + regexp: '^[\s;]*{{ item.key }}[\s]*=' + line: ';{{ item.key }} = {{ item.value }}' + with_items: + - { key: 'access.log', value: "/docker.stdout" } + +- name: Disable clear env in php-fpm pool + lineinfile: + dest: '/opt/docker/etc/php/fpm/pool.d/application.conf' + regexp: '^[\s;]*{{ item.key }}[\s]*=' + line: '{{ item.key }} = {{ item.value }}' + with_items: + - { key: 'clear_env', value: "no" } + when: php_clear_env_available == True + +- name: Remove clear env workaround + file: + path: "/opt/docker/bin/service.d/php-fpm.d/11-clear-env.sh" + state: absent + when: php_clear_env_available == True + +- name: Append clear env workaround in php-fpm pool (old php-fpm versions) + lineinfile: + dest: '/opt/docker/etc/php/fpm/pool.d/application.conf' + line: ';#CLEAR_ENV_WORKAROUND#' + when: php_clear_env_available == False + - name: Disable php-fpm connection limit lineinfile: dest: '/opt/docker/etc/php/fpm/pool.d/application.conf' diff --git a/docker/php/ubuntu-16.10/conf/provision/roles/webdevops-php/tasks/bootstrap/php-fpm.yml b/docker/php/ubuntu-16.10/conf/provision/roles/webdevops-php/tasks/bootstrap/php-fpm.yml index 130542f53..41c1b33dc 100644 --- a/docker/php/ubuntu-16.10/conf/provision/roles/webdevops-php/tasks/bootstrap/php-fpm.yml +++ b/docker/php/ubuntu-16.10/conf/provision/roles/webdevops-php/tasks/bootstrap/php-fpm.yml @@ -1,54 +1,9 @@ --- -- name: Symlink php-fpm binary [RedHat family] +- name: Symlink php-fpm binary file: - path: "/usr/sbin/php-fpm7.0" - src: "/usr/sbin/php-fpm" + path: "/usr/local/bin/php-fpm" + src: "{{ php_fpm_bin }}" state: link owner: "root" group: "root" - when: ansible_os_family == 'RedHat' - -- name: Symlink php-fpm binary [Alpine family] - file: - path: "/usr/sbin/php-fpm" - src: "/usr/sbin/php-fpm7" - state: link - owner: "root" - group: "root" - when: ansible_os_family == 'Alpine' - -- name: Symlink php-fpm binary [Debian family] - file: - path: "/usr/sbin/php-fpm" - src: "/usr/sbin/php-fpm7.0" - state: link - owner: "root" - group: "root" - when: ansible_os_family == 'Debian' - -- name: Remove default php-fpm logrotate - file: - path: "/etc/logrotate.d/php-fpm" - state: absent - when: ansible_os_family == 'RedHat' - -- name: Create php-fpm log directory - file: - path: "/var/log/php7-fpm/" - state: directory - owner: "root" - group: "root" - -- name: Create php-fpm log files - file: - path: "/var/log/php7-fpm/{{ item }}" - state: touch - owner: "root" - group: "root" - mode: 0600 - with_items: - - slow.log - - access.log - - error.log - - fpm.log diff --git a/docker/php/ubuntu-16.10/conf/provision/roles/webdevops-php/tasks/bootstrap/php.alpine.yml b/docker/php/ubuntu-16.10/conf/provision/roles/webdevops-php/tasks/bootstrap/php.alpine.yml new file mode 100644 index 000000000..4c16cdf0d --- /dev/null +++ b/docker/php/ubuntu-16.10/conf/provision/roles/webdevops-php/tasks/bootstrap/php.alpine.yml @@ -0,0 +1,12 @@ +--- + +- name: Create link for additional php.ini [Alpine family] + file: + src: '/opt/docker/etc/php/{{ item.file }}' + dest: '{{ php_etc_dir }}/conf.d/{{ item.target }}' + state: link + force: yes + with_items: + - { file: 'php.webdevops.ini', target: 'xzza-webdevops.ini'} + - { file: 'php.ini', target: 'xzzz-docker.ini'} + when: ansible_os_family == 'Alpine' diff --git a/docker/php/ubuntu-16.10/conf/provision/roles/webdevops-php/tasks/bootstrap/php.debian.yml b/docker/php/ubuntu-16.10/conf/provision/roles/webdevops-php/tasks/bootstrap/php.debian.yml new file mode 100644 index 000000000..d27037e33 --- /dev/null +++ b/docker/php/ubuntu-16.10/conf/provision/roles/webdevops-php/tasks/bootstrap/php.debian.yml @@ -0,0 +1,18 @@ +--- + +- name: Link php.ini for cli and fpm [Debian family] + file: + src: '{{ item.file }}' + dest: '{{ php_etc_dir }}/{{ item.category }}/conf.d/{{ item.target }}' + force: yes + state: link + with_items: + # PHP cli + - { category: 'cli', file: '{{ php_etc_dir }}/mods-available/mcrypt.ini', target: '20-mcrypt.ini' } + - { category: 'cli', file: '/opt/docker/etc/php/php.webdevops.ini', target: '98-webdevops.ini' } + - { category: 'cli', file: '/opt/docker/etc/php/php.ini', target: '99-docker.ini' } + # PHP fpm + - { category: 'fpm', file: '{{ php_etc_dir }}/mods-available/mcrypt.ini', target: '20-mcrypt.ini' } + - { category: 'fpm', file: '/opt/docker/etc/php/php.webdevops.ini', target: '98-webdevops.ini' } + - { category: 'fpm', file: '/opt/docker/etc/php/php.ini', target: '99-docker.ini' } + when: ansible_os_family == 'Debian' diff --git a/docker/php/ubuntu-16.10/conf/provision/roles/webdevops-php/tasks/bootstrap/php.redhat.yml b/docker/php/ubuntu-16.10/conf/provision/roles/webdevops-php/tasks/bootstrap/php.redhat.yml new file mode 100644 index 000000000..7e8810231 --- /dev/null +++ b/docker/php/ubuntu-16.10/conf/provision/roles/webdevops-php/tasks/bootstrap/php.redhat.yml @@ -0,0 +1,12 @@ +--- + +- name: Create link for additional php.ini [RedHat family] + file: + src: '/opt/docker/etc/php/{{ item.file }}' + dest: '/etc/php.d/{{ item.target }}' + state: link + force: yes + with_items: + - { file: 'php.webdevops.ini', target: 'zza-webdevops.ini'} + - { file: 'php.ini', target: 'zzz-docker.ini'} + when: ansible_os_family == 'RedHat' diff --git a/docker/php/ubuntu-16.10/conf/provision/roles/webdevops-php/tasks/bootstrap/php.yml b/docker/php/ubuntu-16.10/conf/provision/roles/webdevops-php/tasks/bootstrap/php.yml index 97f02eec3..caac8f413 100644 --- a/docker/php/ubuntu-16.10/conf/provision/roles/webdevops-php/tasks/bootstrap/php.yml +++ b/docker/php/ubuntu-16.10/conf/provision/roles/webdevops-php/tasks/bootstrap/php.yml @@ -11,7 +11,7 @@ - /opt/docker/etc/php/ - /opt/docker/etc/php/fpm/ -- name: Create /opt/docker/etc/php/php.ini" +- name: Create php.ini files file: path: "{{ item }}" state: touch @@ -21,40 +21,3 @@ with_items: - "/opt/docker/etc/php/php.webdevops.ini" - "/opt/docker/etc/php/php.ini" - -- name: Link php.ini for cli and fpm - file: - src: '{{ item.file }}' - dest: '/etc/php/7.0/{{ item.category }}/conf.d/{{ item.target }}' - force: yes - state: link - with_items: - # PHP cli - - { category: 'cli', file: '/opt/docker/etc/php/php.webdevops.ini', target: '98-webdevops.ini' } - - { category: 'cli', file: '/opt/docker/etc/php/php.ini', target: '99-docker.ini' } - # PHP fpm - - { category: 'fpm', file: '/opt/docker/etc/php/php.webdevops.ini', target: '98-webdevops.ini' } - - { category: 'fpm', file: '/opt/docker/etc/php/php.ini', target: '99-docker.ini' } - when: ansible_os_family == 'Debian' - -- name: Create link for additional php.ini [RedHat family] - file: - src: '/opt/docker/etc/php/{{ item.file }}' - dest: '/etc/php.d/{{ item.target }}' - state: link - force: yes - with_items: - - { file: 'php.webdevops.ini', target: 'zza-webdevops.ini'} - - { file: 'php.ini', target: 'zzz-docker.ini'} - when: ansible_os_family == 'RedHat' - -- name: Link php.ini - file: - src: '/opt/docker/etc/php/{{ item.file }}' - dest: '/etc/php7/conf.d/{{ item.target }}' - force: yes - state: link - with_items: - - { file: 'php.webdevops.ini', target: 'xzza-webdevops.ini'} - - { file: 'php.ini', target: 'xzzz-docker.ini'} - when: ansible_os_family == 'Alpine' diff --git a/docker/piwik/ubuntu-14.04/Dockerfile b/docker/piwik/ubuntu-14.04/Dockerfile index 6af99ead5..81eea3993 100644 --- a/docker/piwik/ubuntu-14.04/Dockerfile +++ b/docker/piwik/ubuntu-14.04/Dockerfile @@ -5,11 +5,6 @@ FROM webdevops/php-nginx:ubuntu-14.04 -MAINTAINER info@webdevops.io -LABEL vendor=WebDevOps.io -LABEL io.webdevops.layout=8 -LABEL io.webdevops.version=1.5.0 - ENV WEB_DOCUMENT_ROOT /app/piwik/ ENV PIWIK_URL http://example.com/ diff --git a/docker/piwik/ubuntu-14.04/Dockerfile.jinja2 b/docker/piwik/ubuntu-14.04/Dockerfile.jinja2 index d9972ec91..1e3e7f636 100644 --- a/docker/piwik/ubuntu-14.04/Dockerfile.jinja2 +++ b/docker/piwik/ubuntu-14.04/Dockerfile.jinja2 @@ -1,7 +1,5 @@ {{ docker.from("php-nginx", "ubuntu-14.04") }} -{{ docker.version() }} - ENV WEB_DOCUMENT_ROOT /app/piwik/ ENV PIWIK_URL http://example.com/ diff --git a/docker/postfix/latest/Dockerfile b/docker/postfix/latest/Dockerfile index ad9f8a153..853021e2c 100644 --- a/docker/postfix/latest/Dockerfile +++ b/docker/postfix/latest/Dockerfile @@ -5,16 +5,11 @@ FROM webdevops/base-app:latest -MAINTAINER info@webdevops.io -LABEL vendor=WebDevOps.io -LABEL io.webdevops.layout=8 -LABEL io.webdevops.version=1.5.0 - COPY conf/ /opt/docker/ -RUN /opt/docker/bin/control.sh service.enable postfix \ +RUN /opt/docker/bin/control.sh service.enable postfix syslog \ && /opt/docker/bin/provision run --tag bootstrap --role webdevops-postfix \ - && /opt/docker/bin/bootstrap.sh - + && /opt/docker/bin/bootstrap.sh \ + && docker-image-cleanup EXPOSE 25 465 587 diff --git a/docker/postfix/latest/Dockerfile.jinja2 b/docker/postfix/latest/Dockerfile.jinja2 index 8f0265caa..c5d6bafd5 100644 --- a/docker/postfix/latest/Dockerfile.jinja2 +++ b/docker/postfix/latest/Dockerfile.jinja2 @@ -1,7 +1,5 @@ {{ docker.from("base-app") }} -{{ docker.version() }} - {{ docker.copy('conf/', '/opt/docker/') }} {{ postfix.ubuntu() }} diff --git a/docker/samson-deployment/latest/Dockerfile b/docker/samson-deployment/latest/Dockerfile index 7b7203de6..99f59f60b 100644 --- a/docker/samson-deployment/latest/Dockerfile +++ b/docker/samson-deployment/latest/Dockerfile @@ -5,55 +5,31 @@ FROM zendesk/samson:latest -MAINTAINER info@webdevops.io -LABEL vendor=WebDevOps.io -LABEL io.webdevops.layout=8 -LABEL io.webdevops.version=1.5.0 - ############################################################################### # Bootstrap ############################################################################### -ENV TERM "xterm" -ENV LANG "en_US.UTF-8" -ENV LC_ALL "en_US.UTF-8" +ENV TERM="xterm" \ + LANG="C.UTF-8" \ + LC_ALL="C.UTF-8" ADD baselayout.tar / -# Init bootstrap (and install ansible) -RUN export DEBIAN_FRONTEND=noninteractive \ - && set -x \ - # Fix root terminal - && echo "export TERM=xterm" >> /root/.bashrc \ +# Init bootstrap +RUN set -x \ + && apt-update \ + && /usr/local/bin/generate-dockerimage-info \ # Enable non-free - && sed -ri 's/(deb.*\/debian jessie main)/\1 contrib non-free /' -- /etc/apt/sources.list \ - # System updatei + && sed -ri "s/(deb.*\/debian $(docker-image-info dist-codename) main)/\1 contrib non-free /" -- /etc/apt/sources.list \ + && apt-update \ + # System update && /usr/local/bin/apt-upgrade \ # Base stuff && /usr/local/bin/apt-install \ - lsb-release \ + apt-transport-https \ ca-certificates \ locales \ - apt-transport-https \ - # Generate base locale - && echo "en_US.UTF-8 UTF-8" > /etc/locale.gen \ - && locale-gen \ - && /usr/local/bin/apt-install \ - # Install ansible - python-minimal \ - python-setuptools \ - python-pip \ - python-paramiko \ - python-jinja2 \ - python-dev \ - libffi-dev \ - libssl-dev \ - build-essential \ - && pip install --upgrade pip \ - && hash -r \ - && pip install ansible \ - && chmod 750 /usr/local/bin/ansible* \ # Install gosu && GOSU_VERSION=1.10 \ && /usr/local/bin/apt-install wget gnupg dirmngr \ @@ -66,62 +42,73 @@ RUN export DEBIAN_FRONTEND=noninteractive \ && rm -rf "$GNUPGHOME" /usr/local/bin/gosu.asc \ && chmod +x /usr/local/bin/gosu \ && gosu nobody true \ + ## Install go-replace + && GOREPLACE_VERSION=0.5.4 \ + && wget -O /usr/local/bin/go-replace https://github.com/webdevops/goreplace/releases/download/$GOREPLACE_VERSION/gr-64-linux \ + && chmod +x /usr/local/bin/go-replace \ && apt-get purge -y -f --force-yes wget dirmngr \ - # Cleanup - && apt-get purge -y -f --force-yes \ - python-dev \ - build-essential \ - libssl-dev \ - libffi-dev \ - && apt-get autoremove -y -f \ - && apt-get clean -y \ - && find /var/log/ -mindepth 1 -delete + && docker-image-cleanup ############################################################################### # Base ############################################################################### -ENV DOCKER_CONF_HOME /opt/docker/ +ENV DOCKER_CONF_HOME=/opt/docker/ \ + LOG_STDOUT="" \ + LOG_STDERR="" COPY conf/ /opt/docker/ +# Install ansible +RUN /usr/local/bin/apt-install \ + # Install ansible + python-minimal \ + python-setuptools \ + python-pip \ + python-paramiko \ + python-jinja2 \ + python-dev \ + libffi-dev \ + libssl-dev \ + build-essential \ + && pip install --upgrade pip \ + && hash -r \ + && pip install --no-cache-dir ansible \ + && chmod 750 /usr/local/bin/ansible* \ + # Cleanup + && apt-get purge -y -f --force-yes \ + python-dev \ + build-essential \ + libssl-dev \ + libffi-dev \ + && docker-image-cleanup + # Install packages RUN chmod +x /opt/docker/bin/* \ && /usr/local/bin/apt-install \ supervisor \ - syslog-ng \ - syslog-ng-core \ - logrotate \ - cron \ wget \ curl \ net-tools \ gnupg \ && chmod +s /usr/local/bin/gosu \ && /opt/docker/bin/provision run --tag bootstrap --role webdevops-base \ - && /opt/docker/bin/bootstrap.sh - + && /opt/docker/bin/bootstrap.sh \ + && docker-image-cleanup ############################################################################### # Base-app ############################################################################### -ENV APPLICATION_USER application -ENV APPLICATION_GROUP application -ENV APPLICATION_PATH /app -ENV APPLICATION_UID 1000 -ENV APPLICATION_GID 1000 +ENV APPLICATION_USER=application \ + APPLICATION_GROUP=application \ + APPLICATION_PATH=/app \ + APPLICATION_UID=1000 \ + APPLICATION_GID=1000 # Install services RUN /usr/local/bin/apt-install \ - # Install services - openssh-server \ - mysql-client \ - sqlite \ - dnsmasq \ - postfix \ # Install common tools - sudo \ zip \ unzip \ bzip2 \ @@ -133,12 +120,10 @@ RUN /usr/local/bin/apt-install \ openssh-client \ rsync \ git \ - nano \ - vim \ && /usr/local/bin/generate-locales \ && /opt/docker/bin/provision run --tag bootstrap --role webdevops-base-app \ - && /opt/docker/bin/bootstrap.sh - + && /opt/docker/bin/bootstrap.sh \ + && docker-image-cleanup ############################################################################### # Samson @@ -151,7 +136,7 @@ ENV SQLITE_CLEANUP_DAYS=0 # NGINX reverse proxy RUN export DEBIAN_FRONTEND=noninteractive && set -x \ && echo deb https://apt.dockerproject.org/repo debian-jessie main > /etc/apt/sources.list.d/docker.list \ - && curl -fsSL https://yum.dockerproject.org/gpg | sudo apt-key add - \ + && curl -fsSL https://yum.dockerproject.org/gpg | apt-key add - \ && /usr/local/bin/apt-install \ # Install nginx nginx \ @@ -173,7 +158,8 @@ RUN export DEBIAN_FRONTEND=noninteractive && set -x \ python-dotenv \ && curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin/ --filename=composer \ ## Enable ansible for deployment user - && chmod 755 /usr/local/bin/ansible* + && chmod 755 /usr/local/bin/ansible* \ + && docker-image-cleanup # NPM stack RUN curl -sL https://deb.nodesource.com/setup_7.x | bash - \ @@ -182,7 +168,8 @@ RUN curl -sL https://deb.nodesource.com/setup_7.x | bash - \ && npm install -g gulp \ && npm install -g grunt-cli \ && npm install -g bower \ - && npm install -g npm-cache + && npm install -g npm-cache \ + && docker-image-cleanup # Deployer stack RUN set -x \ @@ -203,7 +190,8 @@ RUN set -x \ && tar -xzf /tmp/magallanes.tar.gz -C /tmp/ \ && /tmp/magallanes/bin/mage install --installDir=/opt/magallanes \ && rm -rf /tmp/magallanes.tar.gz /tmp/magallanes/ \ - && ln -s /opt/magallanes/latest/bin/mage /usr/bin/mage + && ln -s /opt/magallanes/latest/bin/mage /usr/bin/mage \ + && docker-image-cleanup # Upload ADD database.yml /app/config/database.yml @@ -216,7 +204,6 @@ RUN rake assets:precompile \ && /opt/docker/bin/provision run --tag bootstrap --role webdevops-base --role webdevops-base-app --role webdevops-samson-deployment \ && /opt/docker/bin/bootstrap.sh - EXPOSE 80 VOLUME /storage diff --git a/docker/samson-deployment/latest/Dockerfile.jinja2 b/docker/samson-deployment/latest/Dockerfile.jinja2 index 8edbd4da0..6752148b3 100644 --- a/docker/samson-deployment/latest/Dockerfile.jinja2 +++ b/docker/samson-deployment/latest/Dockerfile.jinja2 @@ -1,7 +1,5 @@ {{ docker.from("samson", user="zendesk") }} -{{ docker.version() }} - ############################################################################### # Bootstrap @@ -17,17 +15,19 @@ # Base ############################################################################### -{{ environment.homePath() }} +{{ environment.base() }} {{ docker.copy('conf/', '/opt/docker/') }} +{{ ansible.debian() }} + {{ base.debian() }} ############################################################################### # Base-app ############################################################################### -{{ environment.app() }} +{{ environment.baseApp() }} {{ baseapp.debian() }} diff --git a/docker/samson-deployment/latest/baselayout.tar b/docker/samson-deployment/latest/baselayout.tar index 9fe660194..dc5fbe08f 100644 Binary files a/docker/samson-deployment/latest/baselayout.tar and b/docker/samson-deployment/latest/baselayout.tar differ diff --git a/docker/samson-deployment/latest/conf/bin/bootstrap.sh b/docker/samson-deployment/latest/conf/bin/bootstrap.sh index 1d1a30f72..855c10782 100644 --- a/docker/samson-deployment/latest/conf/bin/bootstrap.sh +++ b/docker/samson-deployment/latest/conf/bin/bootstrap.sh @@ -17,10 +17,16 @@ rootCheck "$0" # Save the buildtime date +%s > /opt/docker/BUILDTIME +date +%s >/opt/docker/etc/.registry/image_info_buildtime # Make all scripts executable find /opt/docker/bin/ -type f -iname '*.sh' -print0 | xargs --no-run-if-empty -0 chmod +x +# Enable usr-bin executables +find /opt/docker/bin/usr-bin -type f | while read USR_BIN_FILE; do + chmod +x -- "$USR_BIN_FILE" + ln -n -f -- "$USR_BIN_FILE" "/usr/local/bin/$(basename "$USR_BIN_FILE")" +done case "$BOOTSTRAP_MODE" in ################################### @@ -44,6 +50,23 @@ case "$BOOTSTRAP_MODE" in echo "[ERROR] Bootstrap mode '$BOOTSTRAP_MODE' not defined" exit 1 ;; - esac + +###################### +# Check if entrypoint provisioning is available +###################### + +echo "Checking provision status..." +for PROVISION_TAG in onbuild build bootstrap entrypoint; do + ROLES=$(docker-provision list --tag "$PROVISION_TAG") + if [[ -n "$ROLES" ]]; then + PROVISION_ROLE_COUNT=$(echo "$ROLES" | wc -l) + echo " - found ${PROVISION_ROLE_COUNT} for provision tag ${PROVISION_TAG}, caching info for execution" + echo -n "$PROVISION_ROLE_COUNT" > "/opt/docker/etc/.registry/provision-availale.${PROVISION_TAG}" + else + echo " - no roles found for provision tag ${PROVISION_TAG}" + echo -n '' > "/opt/docker/etc/.registry/provision-availale.${PROVISION_TAG}" + fi +done + diff --git a/docker/samson-deployment/latest/conf/bin/config.sh b/docker/samson-deployment/latest/conf/bin/config.sh index 3155728e8..049756c26 100644 --- a/docker/samson-deployment/latest/conf/bin/config.sh +++ b/docker/samson-deployment/latest/conf/bin/config.sh @@ -15,44 +15,23 @@ function rootCheck() { } ### - # Create named pipe - # - # $1 -> name of file + # Create /docker.stdout and /docker.stderr # ## -function createNamedPipe() { - rm --force -- "$1" - mknod "$1" p -} - -### - # Escape value for sed usage - # - # $1 -> value - # STDOUT -> escaped value - # - ## -function sedEscape() { - echo "$(echo $* |sed -e 's/[]\/$*.^|[]/\\&/g')" -} +function createDockerStdoutStderr() { + # link stdout from docker + if [[ -z "$LOG_STDOUT" ]]; then + LOG_STDOUT="/proc/$$/fd/1" + fi -### - # Replace text inside a file - # - # $1 -> source value - # $2 -> target value - # $3 -> path to file - # - ## -function replaceTextInFile() { - SOURCE="$(sedEscape $1)" - REPLACE="$(sedEscape $2)" - TARGET="$3" + if [[ -z "$LOG_STDERR" ]]; then + LOG_STDERR="/proc/$$/fd/2" + fi - sed -i "s/${SOURCE}/${REPLACE}/" "${TARGET}" + ln -f -s "$LOG_STDOUT" /docker.stdout + ln -f -s "$LOG_STDERR" /docker.stderr + chmod 600 /docker.stdout /docker.stderr } - - ### # Include script directory text inside a file # @@ -104,7 +83,7 @@ function runEntrypoints() { . /opt/docker/bin/entrypoint.d/default.sh fi - exit + exit 1 } ### @@ -161,6 +140,12 @@ function runProvisionEntrypoint() { function runDockerProvision() { ANSIBLE_TAG="$1" - /opt/docker/bin/provision run --tag "$ANSIBLE_TAG" --use-registry + PROVISION_STATS_FILE="/opt/docker/etc/.registry/provision-stats.${ANSIBLE_TAG}" + + # run provision if stats file doesn't exists (unknown mode) + # or if stats file is not empty + if [[ ! -f "$PROVISION_STATS_FILE" ]] || [[ -s "$PROVISION_STATS_FILE" ]]; then + /opt/docker/bin/provision run --tag "${ANSIBLE_TAG}" --use-registry + fi } diff --git a/docker/samson-deployment/latest/conf/bin/control.sh b/docker/samson-deployment/latest/conf/bin/control.sh index a6697092d..22d189745 100644 --- a/docker/samson-deployment/latest/conf/bin/control.sh +++ b/docker/samson-deployment/latest/conf/bin/control.sh @@ -101,23 +101,13 @@ case "$CONTROL_COMMAND" in ## ------------------------------------------ "service.enable") - SERVICE_FILE="/opt/docker/etc/supervisor.d/$1.conf" - if [ -f "$SERVICE_FILE" ]; then - sed -i '/autostart = /c\autostart = true' -- "$SERVICE_FILE" - else - echo "[ERROR] Service '${1}' not found (tried ${SERVICE_FILE})" - exit 1 - fi + deprecationNotice " Please use >>docker-service-enable [service]<<" + docker-service-enable "$1" ;; "service.disable") - SERVICE_FILE="/opt/docker/etc/supervisor.d/$1.conf" - if [ -f "$SERVICE_FILE" ]; then - sed -i '/autostart = /c\autostart = false' -- "$SERVICE_FILE" - else - echo "[ERROR] Service '${1}' not found (tried ${SERVICE_FILE})" - exit 1 - fi + deprecationNotice " Please use >>docker-service-disable [service]<<" + docker-service-disable "$1" ;; ## ------------------------------------------ diff --git a/docker/samson-deployment/latest/conf/bin/entrypoint.d/cli.sh b/docker/samson-deployment/latest/conf/bin/entrypoint.d/cli.sh index 2ca68926c..fe212a8ea 100644 --- a/docker/samson-deployment/latest/conf/bin/entrypoint.d/cli.sh +++ b/docker/samson-deployment/latest/conf/bin/entrypoint.d/cli.sh @@ -8,7 +8,7 @@ if [ -n "${CLI_SCRIPT}" ]; then if [ -n "$APPLICATION_USER" ]; then # Run as EFFECTIVE_USER shift - exec sudo -H -E -u "${APPLICATION_USER}" ${CLI_SCRIPT} "$@" + exec gosu "${APPLICATION_USER}" ${CLI_SCRIPT} "$@" else # Run as root exec ${CLI_SCRIPT} "$@" diff --git a/docker/samson-deployment/latest/conf/bin/entrypoint.d/noop.sh b/docker/samson-deployment/latest/conf/bin/entrypoint.d/noop.sh index 967920837..092d55d8b 100644 --- a/docker/samson-deployment/latest/conf/bin/entrypoint.d/noop.sh +++ b/docker/samson-deployment/latest/conf/bin/entrypoint.d/noop.sh @@ -4,5 +4,4 @@ ## NOOP (no operation) ############################################# -tail -f /dev/null -exit +exec tail -f /dev/null diff --git a/docker/samson-deployment/latest/conf/bin/entrypoint.d/supervisord.sh b/docker/samson-deployment/latest/conf/bin/entrypoint.d/supervisord.sh index ead991551..f21489667 100644 --- a/docker/samson-deployment/latest/conf/bin/entrypoint.d/supervisord.sh +++ b/docker/samson-deployment/latest/conf/bin/entrypoint.d/supervisord.sh @@ -4,8 +4,6 @@ ## Supervisord (start daemons) ############################################# -rootCheck "supervisord" - ## Start services exec /opt/docker/bin/service.d/supervisor.sh diff --git a/docker/samson-deployment/latest/conf/bin/entrypoint.sh b/docker/samson-deployment/latest/conf/bin/entrypoint.sh index bbabcdddb..01f59660c 100644 --- a/docker/samson-deployment/latest/conf/bin/entrypoint.sh +++ b/docker/samson-deployment/latest/conf/bin/entrypoint.sh @@ -20,16 +20,13 @@ chmod -s /usr/local/bin/gosu trap 'echo sigterm ; exit' SIGTERM trap 'echo sigkill ; exit' SIGKILL -# link stdout from docker -ln -f -s "/proc/$$/fd/1" /docker.stdout -ln -f -s "/proc/$$/fd/2" /docker.stderr -chmod 600 /docker.stdout /docker.stderr - # sanitize input and set task TASK="$(echo $1| sed 's/[^-_a-zA-Z0-9]*//g')" source /opt/docker/bin/config.sh +createDockerStdoutStderr + if [[ "$UID" -eq 0 ]]; then # Only run provision if user is root diff --git a/docker/samson-deployment/latest/conf/bin/logwatch.sh b/docker/samson-deployment/latest/conf/bin/logwatch.sh deleted file mode 100644 index 1a5b486c7..000000000 --- a/docker/samson-deployment/latest/conf/bin/logwatch.sh +++ /dev/null @@ -1,14 +0,0 @@ -#!/usr/bin/env bash - -set -o pipefail # trace ERR through pipes -set -o errtrace # trace ERR through 'time command' and other functions -set -o nounset ## set -u : exit the script if you try to use an uninitialised variable -set -o errexit ## set -e : exit the script if any statement returns a non-true return value - -sleep 0.5 - -if [ -p "$2" ]; then - sed --unbuffered -e "s/^/\[$1\] /" -- "$2" -else - tail -n 0 -F -q "$2" | sed --unbuffered -e "s/^/\[$1\] /" -fi diff --git a/docker/samson-deployment/latest/conf/bin/provision b/docker/samson-deployment/latest/conf/bin/provision index f7b5ad0a8..d367c2812 100755 --- a/docker/samson-deployment/latest/conf/bin/provision +++ b/docker/samson-deployment/latest/conf/bin/provision @@ -19,6 +19,7 @@ PLAYBOOK = Template( - hosts: all vars_files: + - ./variables-webdevops.yml - ./variables.yml roles: - $roles @@ -188,7 +189,7 @@ def actionAdd(args): 'priority': args.priority } - saveJson(json); + saveJson(json) diff --git a/docker/samson-deployment/latest/conf/bin/provision.sh b/docker/samson-deployment/latest/conf/bin/provision.sh deleted file mode 100644 index 4079dd7f0..000000000 --- a/docker/samson-deployment/latest/conf/bin/provision.sh +++ /dev/null @@ -1,30 +0,0 @@ - #!/usr/bin/env bash - -# -# Example: -# provision.sh /opt/foobar/playbook.yml tag -# -# - -set -o pipefail # trace ERR through pipes -set -o errtrace # trace ERR through 'time command' and other functions -set -o nounset ## set -u : exit the script if you try to use an uninitialised variable -set -o errexit ## set -e : exit the script if any statement returns a non-true return value - -. config.sh - -deprecationNotice " Please use >>/opt/docker/bin/provision run --playbook playbook.yml --tag=bootstrap [args]<< for running provision" - - -if [ "$#" -lt 2 ]; then - echo "[ERROR] $0: Playbook or tag is missing" - exit 1 -fi - -ANSIBLE_PLAYBOOK="$1" -shift -ANSIBLE_TAG="$1" -shift -ANSIBLE_OPTS="$@" - -/opt/docker/bin/provision run --playbook "${ANSIBLE_PLAYBOOK}" --use-registry --tag "${ANSIBLE_TAG}" $ANSIBLE_OPTS diff --git a/docker/samson-deployment/latest/conf/bin/service.d/nginx.d/10-init.sh b/docker/samson-deployment/latest/conf/bin/service.d/nginx.d/10-init.sh index 52df52c8e..47e13a4d4 100644 --- a/docker/samson-deployment/latest/conf/bin/service.d/nginx.d/10-init.sh +++ b/docker/samson-deployment/latest/conf/bin/service.d/nginx.d/10-init.sh @@ -2,5 +2,9 @@ ln -f -s /var/lib/nginx/logs /var/log/nginx # Replace markers -find /opt/docker/etc/nginx/ -iname '*.conf' -print0 | xargs -0 -r rpl --quiet "" "$WEB_ALIAS_DOMAIN" > /dev/null -find /opt/docker/etc/nginx/ -iname '*.conf' -print0 | xargs -0 -r rpl --quiet "" "$HOSTNAME" > /dev/null +go-replace \ + -s "" -r "$WEB_ALIAS_DOMAIN" \ + -s "" -r "$HOSTNAME" \ + --path=/opt/docker/etc/nginx/ \ + --path-pattern='*.conf' \ + --ignore-empty diff --git a/docker/samson-deployment/latest/conf/bin/service.d/postfix.d/10-init.sh b/docker/samson-deployment/latest/conf/bin/service.d/postfix.d/10-init.sh index 7a604874f..cfd876955 100644 --- a/docker/samson-deployment/latest/conf/bin/service.d/postfix.d/10-init.sh +++ b/docker/samson-deployment/latest/conf/bin/service.d/postfix.d/10-init.sh @@ -22,3 +22,6 @@ if [[ -n "${POSTFIX_MYNETWORKS+x}" ]]; then sed -i '/mynetworks[ ]* =/c\' main.cf echo "mynetworks = $POSTFIX_MYNETWORKS" >> /etc/postfix/main.cf fi + +# generate aliases db +newaliases || : diff --git a/docker/samson-deployment/latest/conf/bin/service.d/ssh.d/10-init.sh b/docker/samson-deployment/latest/conf/bin/service.d/ssh.d/10-init.sh index e3192fe01..f2b600312 100644 --- a/docker/samson-deployment/latest/conf/bin/service.d/ssh.d/10-init.sh +++ b/docker/samson-deployment/latest/conf/bin/service.d/ssh.d/10-init.sh @@ -1,2 +1,7 @@ +# Init ssh privilege separation directory +mkdir -p /var/run/sshd +chown root:root /var/run/sshd +chmod 755 /var/run/sshd + # generate host keys ssh-keygen -A diff --git a/docker/samson-deployment/latest/conf/bin/service.d/syslog-ng.d/10-init.sh b/docker/samson-deployment/latest/conf/bin/service.d/syslog-ng.d/10-init.sh index 22621d2ad..326207e52 100644 --- a/docker/samson-deployment/latest/conf/bin/service.d/syslog-ng.d/10-init.sh +++ b/docker/samson-deployment/latest/conf/bin/service.d/syslog-ng.d/10-init.sh @@ -6,5 +6,5 @@ if [ ! -S /var/lib/syslog-ng/syslog-ng.ctl ]; then rm -f /var/lib/syslog-ng/sysl if [[ ! -p /docker.stdout ]]; then # Switch to file (tty docker mode) - rpl --quiet 'pipe("/docker.stdout")' 'file("/docker.stdout")' -- /opt/docker/etc/syslog-ng/syslog-ng.conf > /dev/null + go-replace -s 'pipe("/docker.stdout")' -r 'file("/docker.stdout")' -- /opt/docker/etc/syslog-ng/syslog-ng.conf fi diff --git a/docker/samson-deployment/latest/conf/bin/usr-bin/docker-provision b/docker/samson-deployment/latest/conf/bin/usr-bin/docker-provision new file mode 100644 index 000000000..4ee715c64 --- /dev/null +++ b/docker/samson-deployment/latest/conf/bin/usr-bin/docker-provision @@ -0,0 +1,9 @@ +#!/usr/bin/env bash + +set -o pipefail # trace ERR through pipes +set -o errtrace # trace ERR through 'time command' and other functions +set -o nounset ## set -u : exit the script if you try to use an uninitialised variable +set -o errexit ## set -e : exit the script if any statement returns a non-true return value + +# wrapper +exec /opt/docker/bin/provision "$@" diff --git a/docker/samson-deployment/latest/conf/bin/usr-bin/docker-service-disable b/docker/samson-deployment/latest/conf/bin/usr-bin/docker-service-disable new file mode 100644 index 000000000..2b5b31bb4 --- /dev/null +++ b/docker/samson-deployment/latest/conf/bin/usr-bin/docker-service-disable @@ -0,0 +1,30 @@ +#!/usr/bin/env bash + +set -o pipefail # trace ERR through pipes +set -o errtrace # trace ERR through 'time command' and other functions +set -o nounset ## set -u : exit the script if you try to use an uninitialised variable +set -o errexit ## set -e : exit the script if any statement returns a non-true return value + +source /opt/docker/bin/config.sh + +rootCheck "$0" + +if [[ "$#" -eq 0 ]]; then + echo "Usage: $0 " + exit 1 +fi + +for SERVICE in "$@"; do + SERVICE_FILE="/opt/docker/etc/supervisor.d/${SERVICE}.conf" + + ## Disable service + if [[ -f "$SERVICE_FILE" ]]; then + go-replace --mode=lineinfile \ + -s 'autostart =' -r 'autostart = false' \ + -- "$SERVICE_FILE" + else + echo "[ERROR] Service '${SERVICE}' not found (tried ${SERVICE_FILE})" + exit 1 + fi +done + diff --git a/docker/samson-deployment/latest/conf/bin/usr-bin/docker-service-enable b/docker/samson-deployment/latest/conf/bin/usr-bin/docker-service-enable new file mode 100644 index 000000000..8d36a14a9 --- /dev/null +++ b/docker/samson-deployment/latest/conf/bin/usr-bin/docker-service-enable @@ -0,0 +1,41 @@ +#!/usr/bin/env bash + +set -o pipefail # trace ERR through pipes +set -o errtrace # trace ERR through 'time command' and other functions +set -o nounset ## set -u : exit the script if you try to use an uninitialised variable +set -o errexit ## set -e : exit the script if any statement returns a non-true return value + +source /opt/docker/bin/config.sh + +rootCheck "$0" + +if [[ "$#" -eq 0 ]]; then + echo "Usage: $0 " + exit 1 +fi + +for SERVICE in "$@"; do + SERVICE_FILE="/opt/docker/etc/supervisor.d/${SERVICE}.conf" + PROVISION_FILE="/opt/docker/provision/service.d/${SERVICE}.sh" + + # Run on demand installation/provisioning + if [[ -f "$PROVISION_FILE" ]]; then + echo "Running provisioning for ${SERVICE}, please wait..." + + ## execute scripts + . "$PROVISION_FILE" + + ## remove directory (one run time) + rm -f -- "$PROVISION_FILE" + fi + + ## Enable service + if [[ -f "$SERVICE_FILE" ]]; then + go-replace --mode=lineinfile \ + -s 'autostart =' -r 'autostart = true' \ + -- "$SERVICE_FILE" + else + echo "[ERROR] Service '${SERVICE}' not found (tried ${SERVICE_FILE})" + exit 1 + fi +done diff --git a/docker/samson-deployment/latest/conf/bin/usr-bin/service b/docker/samson-deployment/latest/conf/bin/usr-bin/service new file mode 100755 index 000000000..55ea12bf7 --- /dev/null +++ b/docker/samson-deployment/latest/conf/bin/usr-bin/service @@ -0,0 +1,86 @@ +#!/bin/bash + +set -o pipefail # trace ERR through pipes +set -o errtrace # trace ERR through 'time command' and other functions +set -o nounset ## set -u : exit the script if you try to use an uninitialised variable +set -o errexit ## set -e : exit the script if any statement returns a non-true return value + +# Root check +if [ "$(/usr/bin/whoami)" != "root" ]; then + echo "[ERROR] Must be run as root" + exit 1 +fi + +function serviceHelp() { + echo "Usage: $(basename "$0") " +} + +function getServicePid() { + local serviceName="$1" + local servicePid=$(supervisorctl pid "${serviceName}:${serviceName}d") + + if [[ -z "$servicePid" ]] || [[ "$servicePid" == "0" ]]; then + echo "not running" + exit 1 + fi + + echo $servicePid +} + +# Param check +if [ "$#" -lt 2 ]; then + echo "[ERROR] Missing parameters" + serviceHelp + exit 1 +fi + +############################# +# Param init +############################# + +SERVICENAME="$1" +ACTION="$2" + +############################# +# Service aliases +############################# +case "$SERVICENAME" in + apache2|httpd) + SERVICENAME="apache" + ;; +esac + +############################# +# Action runner +############################# +case "$ACTION" in + stop|start|restart|status) + exec supervisorctl "$ACTION" "${SERVICENAME}:${SERVICENAME}d" + ;; + + pid) + echo $(getServicePid "${SERVICENAME}") + ;; + + check) + FIRST_PID=$(getServicePid "${SERVICENAME}") + sleep 5 + SECOND_PID=$(getServicePid "${SERVICENAME}") + + if [[ "$FIRST_PID" == "$SECOND_PID" ]]; then + echo "ok" + exit 0 + else + echo "not running" + exit 1 + fi + ;; + + + *) + echo "[ERROR] Invalid action" + serviceHelp + exit 1 + ;; + +esac diff --git a/docker/samson-deployment/latest/conf/etc/supervisor.conf b/docker/samson-deployment/latest/conf/etc/supervisor.conf index 7c109515a..479e0db08 100644 --- a/docker/samson-deployment/latest/conf/etc/supervisor.conf +++ b/docker/samson-deployment/latest/conf/etc/supervisor.conf @@ -2,9 +2,16 @@ nodaemon=true [unix_http_server] -file = /var/run/supervisor.sock -# username = root -# password = {SHA}e982f17bcbe0f724063b708a4f76db211a999304 +file = /.supervisor.sock +chmod = 0700 +chown = root:root +username = root +password = {SHA}e982f17bcbe0f724063b708a4f76db211a999304 + +[supervisorctl] +serverurl = unix:///.supervisor.sock +username = root +password = docker [rpcinterface:supervisor] supervisor.rpcinterface_factory = supervisor.rpcinterface:make_main_rpcinterface diff --git a/docker/samson-deployment/latest/conf/etc/supervisor.d/dnsmasq.conf b/docker/samson-deployment/latest/conf/etc/supervisor.d/dnsmasq.conf index a0ad2de88..9832ffca7 100644 --- a/docker/samson-deployment/latest/conf/etc/supervisor.d/dnsmasq.conf +++ b/docker/samson-deployment/latest/conf/etc/supervisor.d/dnsmasq.conf @@ -6,7 +6,7 @@ priority=15 command = /opt/docker/bin/service.d/dnsmasq.sh process_name=%(program_name)s startsecs = 0 -autostart = true +autostart = false autorestart = true stdout_logfile=/dev/stdout stdout_logfile_maxbytes=0 diff --git a/docker/samson-deployment/latest/conf/etc/supervisor.d/syslog-ng.conf b/docker/samson-deployment/latest/conf/etc/supervisor.d/syslog-ng.conf deleted file mode 100644 index 247fd1a25..000000000 --- a/docker/samson-deployment/latest/conf/etc/supervisor.d/syslog-ng.conf +++ /dev/null @@ -1,13 +0,0 @@ -[group:syslog] -programs=syslogd -priority=10 - -[program:syslogd] -command = /opt/docker/bin/service.d/syslog-ng.sh -process_name=%(program_name)s -autostart = true -autorestart = true -stdout_logfile=/dev/stdout -stdout_logfile_maxbytes=0 -stderr_logfile=/dev/stderr -stderr_logfile_maxbytes=0 diff --git a/docker/samson-deployment/latest/conf/etc/supervisor.d/syslog.conf b/docker/samson-deployment/latest/conf/etc/supervisor.d/syslog.conf new file mode 100644 index 000000000..20d1e238c --- /dev/null +++ b/docker/samson-deployment/latest/conf/etc/supervisor.d/syslog.conf @@ -0,0 +1,13 @@ +[group:syslog] +programs=syslogd +priority=10 + +[program:syslogd] +command = /opt/docker/bin/service.d/syslog-ng.sh +process_name=%(program_name)s +autostart = false +autorestart = true +stdout_logfile=/dev/stdout +stdout_logfile_maxbytes=0 +stderr_logfile=/dev/stderr +stderr_logfile_maxbytes=0 diff --git a/docker/samson-deployment/latest/conf/provision/roles/webdevops-base-app/tasks/bootstrap.yml b/docker/samson-deployment/latest/conf/provision/roles/webdevops-base-app/tasks/bootstrap.yml index ea9e54682..3fdce9a74 100644 --- a/docker/samson-deployment/latest/conf/provision/roles/webdevops-base-app/tasks/bootstrap.yml +++ b/docker/samson-deployment/latest/conf/provision/roles/webdevops-base-app/tasks/bootstrap.yml @@ -2,6 +2,3 @@ - include: bootstrap/user.yml - include: bootstrap/application.yml -- include: bootstrap/dnsmasq.yml -- include: bootstrap/postfix.yml -- include: bootstrap/ssh.yml diff --git a/docker/samson-deployment/latest/conf/provision/roles/webdevops-base-app/tasks/bootstrap/dnsmasq.yml b/docker/samson-deployment/latest/conf/provision/roles/webdevops-base-app/tasks/bootstrap/dnsmasq.yml deleted file mode 100644 index 962a7953a..000000000 --- a/docker/samson-deployment/latest/conf/provision/roles/webdevops-base-app/tasks/bootstrap/dnsmasq.yml +++ /dev/null @@ -1,10 +0,0 @@ ---- - -- name: Configure dnsmasq - lineinfile: - dest: /etc/dnsmasq.conf - regexp: '^[\s]*{{ item.key }}[\s]*=' - line: '{{ item.key }}={{ item.value }}' - with_items: - - { key: 'user', value: 'root' } - - { key: 'conf-dir', value: '/etc/dnsmasq.d' } diff --git a/docker/samson-deployment/latest/conf/provision/roles/webdevops-base-app/tasks/bootstrap/postfix.yml b/docker/samson-deployment/latest/conf/provision/roles/webdevops-base-app/tasks/bootstrap/postfix.yml deleted file mode 100644 index f05ff660c..000000000 --- a/docker/samson-deployment/latest/conf/provision/roles/webdevops-base-app/tasks/bootstrap/postfix.yml +++ /dev/null @@ -1,29 +0,0 @@ ---- - -- name: Link aliases file to postfix aliases - file: - src: '/etc/postfix/aliases' - dest: '/etc/aliases' - state: link - force: yes - when: ansible_os_family == 'Alpine' - -- name: Configure postfix - lineinfile: - dest: /etc/postfix/main.cf - regexp: '^[\s]*{{ item.key }}[\s]*=' - line: '{{ item.key }}={{ item.value }}' - with_items: - - { key: 'mydestination', value: '' } - - { key: 'message_size_limit', value: '15240000' } - # Hardening - - { key: 'smtp_use_tls', value: 'yes' } - - { key: 'smtp_tls_security_level', value: 'may' } - -- name: Remove dynamic configuration for postfix - lineinfile: - dest: /etc/postfix/main.cf - regexp: '^[\s]*{{ item }}[\s]*=' - state: absent - with_items: - - 'myhostname' diff --git a/docker/samson-deployment/latest/conf/provision/roles/webdevops-base-app/tasks/bootstrap/ssh.yml b/docker/samson-deployment/latest/conf/provision/roles/webdevops-base-app/tasks/bootstrap/ssh.yml deleted file mode 100644 index a69c72633..000000000 --- a/docker/samson-deployment/latest/conf/provision/roles/webdevops-base-app/tasks/bootstrap/ssh.yml +++ /dev/null @@ -1,12 +0,0 @@ ---- - -- name: Init ssh privilege separation directory - file: - path: "/var/run/sshd" - state: directory - mode: 0755 - owner: "root" - group: "root" - recurse: yes - - diff --git a/docker/samson-deployment/latest/conf/provision/roles/webdevops-base-app/tasks/bootstrap/user.yml b/docker/samson-deployment/latest/conf/provision/roles/webdevops-base-app/tasks/bootstrap/user.yml index cf6968a01..fd58b329f 100644 --- a/docker/samson-deployment/latest/conf/provision/roles/webdevops-base-app/tasks/bootstrap/user.yml +++ b/docker/samson-deployment/latest/conf/provision/roles/webdevops-base-app/tasks/bootstrap/user.yml @@ -1,11 +1,5 @@ --- -- name: Move dnsmasq group (Alpine family) - group: - name: dnsmasq - gid: 153 - when: ansible_distribution == 'Alpine' - - name: Create application group group: name: "{{ APPLICATION_GROUP }}" diff --git a/docker/samson-deployment/latest/conf/provision/roles/webdevops-base/tasks/bootstrap.yml b/docker/samson-deployment/latest/conf/provision/roles/webdevops-base/tasks/bootstrap.yml index 30be03c38..9f842336c 100644 --- a/docker/samson-deployment/latest/conf/provision/roles/webdevops-base/tasks/bootstrap.yml +++ b/docker/samson-deployment/latest/conf/provision/roles/webdevops-base/tasks/bootstrap.yml @@ -4,6 +4,5 @@ - include: bootstrap/misc.yml - include: bootstrap/root.yml - include: bootstrap/supervisor.yml -- include: bootstrap/syslog-ng.yml -- include: bootstrap/logrotate.yml - include: bootstrap/pam.yml +- include: bootstrap/entrypoint.yml diff --git a/docker/samson-deployment/latest/conf/provision/roles/webdevops-base/tasks/bootstrap/entrypoint.yml b/docker/samson-deployment/latest/conf/provision/roles/webdevops-base/tasks/bootstrap/entrypoint.yml new file mode 100644 index 000000000..d5d8809f4 --- /dev/null +++ b/docker/samson-deployment/latest/conf/provision/roles/webdevops-base/tasks/bootstrap/entrypoint.yml @@ -0,0 +1,8 @@ +--- + +- name: Create link for entrypoint + file: + src: '/opt/docker/bin/entrypoint.sh' + dest: '/entrypoint' + state: link + force: yes diff --git a/docker/samson-deployment/latest/conf/provision/roles/webdevops-base/tasks/bootstrap/logrotate.yml b/docker/samson-deployment/latest/conf/provision/roles/webdevops-base/tasks/bootstrap/logrotate.yml deleted file mode 100644 index d87926be2..000000000 --- a/docker/samson-deployment/latest/conf/provision/roles/webdevops-base/tasks/bootstrap/logrotate.yml +++ /dev/null @@ -1,33 +0,0 @@ ---- - -- name: Configure logrotate running user - lineinfile: - dest: /etc/logrotate.conf - regexp: '^su [-_a-zA-Z0-9]+ [-_a-zA-Z0-9]+' - line: 'su root adm' - -- name: Register logrotate configurations - file: - src: '{{ item }}' - dest: '/etc/logrotate.d/{{ item | basename }}' - state: link - force: yes - with_fileglob: - - /opt/docker/etc/logrotate.d/* - -- name: Remove system logrotates (not needed) - file: - path: '{{ item }}' - state: absent - with_items: - # Debian/Ubuntu - - /etc/cron.daily/logrotate - - /etc/cron.daily/apt-compat - - /etc/cron.daily/dpkg - - /etc/cron.daily/passwd - # RedHat - - /etc/cron.daily/0yum-daily.cron - - /etc/cron.daily/logrotate - - /etc/cron.hourly/0yum-hourly.cron - # Alpine - - /etc/periodic/daily/logrotate diff --git a/docker/samson-deployment/latest/conf/provision/roles/webdevops-base/tasks/bootstrap/supervisor.yml b/docker/samson-deployment/latest/conf/provision/roles/webdevops-base/tasks/bootstrap/supervisor.yml index bda0394b6..2ce07ac26 100644 --- a/docker/samson-deployment/latest/conf/provision/roles/webdevops-base/tasks/bootstrap/supervisor.yml +++ b/docker/samson-deployment/latest/conf/provision/roles/webdevops-base/tasks/bootstrap/supervisor.yml @@ -4,3 +4,10 @@ file: path: '/usr/sbin/service' state: absent + +- name: Create link for supervisor.conf + file: + src: '/opt/docker/etc/supervisor.conf' + dest: '/etc/supervisord.conf' + state: link + force: yes diff --git a/docker/samson-deployment/latest/conf/provision/roles/webdevops-base/tasks/bootstrap/syslog-ng.yml b/docker/samson-deployment/latest/conf/provision/roles/webdevops-base/tasks/bootstrap/syslog-ng.yml deleted file mode 100644 index 27c8f6a30..000000000 --- a/docker/samson-deployment/latest/conf/provision/roles/webdevops-base/tasks/bootstrap/syslog-ng.yml +++ /dev/null @@ -1,33 +0,0 @@ ---- - -- name: Get syslog-ng version - shell: "syslog-ng --version | grep -E -e '^syslog-ng[ ]+[0-9]+\\.[0-9]+' | head -n 1 | awk '{print $2}' | cut -f 1,2 -d ." - register: syslogng_version - -- name: Configure syslog-ng (default) - lineinfile: - dest: /etc/default/syslog-ng - regexp: '^[\s]*{{ item.key }}[\s]*=' - line: '{{ item.key }}="{{ item.value }}"' - create: yes - with_items: - - { key: 'SYSLOGNG_OPTS', value: '--no-caps' } - -- name: Enable syslog-ng config - file: - src: '/opt/docker/etc/syslog-ng/syslog-ng.conf' - dest: '/etc/syslog-ng/syslog-ng.conf' - state: link - force: yes - -- name: Set version of syslog-ng file - lineinfile: - dest: '/etc/syslog-ng/syslog-ng.conf' - regexp: '^@version:' - line: '@version: {{ syslogng_version.stdout }}' - -- name: Ensure /var/lib/syslog-ng exists - file: - path: '/var/lib/syslog-ng' - state: directory - recurse: yes diff --git a/docker/samson-deployment/latest/conf/provision/roles/webdevops-base/tasks/bootstrap/system.yml b/docker/samson-deployment/latest/conf/provision/roles/webdevops-base/tasks/bootstrap/system.yml index 8dfbf9665..0741d7cae 100644 --- a/docker/samson-deployment/latest/conf/provision/roles/webdevops-base/tasks/bootstrap/system.yml +++ b/docker/samson-deployment/latest/conf/provision/roles/webdevops-base/tasks/bootstrap/system.yml @@ -14,3 +14,20 @@ dest: '/entrypoint.cmd' state: link force: yes + +- name: Remove system logrotate and cronjobs (not needed) + file: + path: '{{ item }}' + state: absent + with_items: + # Debian/Ubuntu + - /etc/cron.daily/logrotate + - /etc/cron.daily/apt-compat + - /etc/cron.daily/dpkg + - /etc/cron.daily/passwd + # RedHat + - /etc/cron.daily/0yum-daily.cron + - /etc/cron.daily/logrotate + - /etc/cron.hourly/0yum-hourly.cron + # Alpine + - /etc/periodic/daily/logrotate diff --git a/docker/samson-deployment/latest/conf/provision/roles/webdevops-base/tasks/build/.gitkeep b/docker/samson-deployment/latest/conf/provision/roles/webdevops-base/tasks/build/.gitkeep new file mode 100644 index 000000000..e69de29bb diff --git a/docker/samson-deployment/latest/conf/provision/roles/webdevops-base/tasks/build/logrotate.yml b/docker/samson-deployment/latest/conf/provision/roles/webdevops-base/tasks/build/logrotate.yml deleted file mode 100644 index 10f7e6644..000000000 --- a/docker/samson-deployment/latest/conf/provision/roles/webdevops-base/tasks/build/logrotate.yml +++ /dev/null @@ -1,10 +0,0 @@ ---- - -- name: Register logrotate configurations - file: - src: '{{ item }}' - dest: '/etc/logrotate.d/{{ item | basename }}' - state: link - force: yes - with_fileglob: - - /opt/docker/etc/logrotate.d/* diff --git a/docker/samson-deployment/latest/conf/provision/service.d/.gitkeep b/docker/samson-deployment/latest/conf/provision/service.d/.gitkeep new file mode 100644 index 000000000..e69de29bb diff --git a/docker/samson-deployment/latest/conf/provision/service.d/cron.sh b/docker/samson-deployment/latest/conf/provision/service.d/cron.sh new file mode 100644 index 000000000..bd8a54781 --- /dev/null +++ b/docker/samson-deployment/latest/conf/provision/service.d/cron.sh @@ -0,0 +1,13 @@ +#!/usr/bin/env bash + +IMAGE_FAMILY=$(docker-image-info family) + +case "$IMAGE_FAMILY" in + Debian|Ubuntu) + apt-install cron + ;; + + RedHat) + yum-install cronie + ;; +esac diff --git a/docker/samson-deployment/latest/conf/provision/service.d/dnsmasq.sh b/docker/samson-deployment/latest/conf/provision/service.d/dnsmasq.sh new file mode 100644 index 000000000..9e5c3228c --- /dev/null +++ b/docker/samson-deployment/latest/conf/provision/service.d/dnsmasq.sh @@ -0,0 +1,24 @@ +#!/usr/bin/env bash + +IMAGE_FAMILY=$(docker-image-info family) + +# Installation +case "$IMAGE_FAMILY" in + Debian|Ubuntu) + apt-install dnsmasq + ;; + + RedHat) + yum-install dnsmasq + ;; + + Alpine) + apk-install dnsmasq + ;; +esac + +# Configuration +go-replace --mode=line \ + -s '^[\s]*user[\s]*=' -r 'user = root' \ + -s '^[\s]*conf-dir[\s]*=' -r 'conf-dir = /etc/dnsmasq.d' \ + -- /etc/dnsmasq.conf diff --git a/docker/samson-deployment/latest/conf/provision/service.d/postfix.sh b/docker/samson-deployment/latest/conf/provision/service.d/postfix.sh new file mode 100644 index 000000000..ff1879345 --- /dev/null +++ b/docker/samson-deployment/latest/conf/provision/service.d/postfix.sh @@ -0,0 +1,28 @@ +#!/usr/bin/env bash + +IMAGE_FAMILY=$(docker-image-info family) + +# Installation +case "$IMAGE_FAMILY" in + Debian|Ubuntu) + apt-install postfix + ;; + + RedHat) + yum-install postfix + ;; + + Alpine) + apk-install postfix + ln -s -f /etc/postfix/aliases /etc/aliases + ;; +esac + +# Configuration +go-replace --mode=line \ + -s '^[\s]*mydestination[\s]*=' -r 'mydestination = ' \ + -s '^[\s]*message_size_limit[\s]*=' -r 'message_size_limit = 15240000' \ + -s '^[\s]*smtp_use_tls[\s]*=' -r 'smtp_use_tls = yes' \ + -s '^[\s]*smtp_tls_security_level[\s]*=' -r 'smtp_tls_security_level = may' \ + -s '^[\s]*myhostname[\s]*=' -r '# myhostname' \ + -- /etc/postfix/main.cf diff --git a/docker/samson-deployment/latest/conf/provision/service.d/ssh.sh b/docker/samson-deployment/latest/conf/provision/service.d/ssh.sh new file mode 100644 index 000000000..63d7a9f3a --- /dev/null +++ b/docker/samson-deployment/latest/conf/provision/service.d/ssh.sh @@ -0,0 +1,17 @@ +#!/usr/bin/env bash + +IMAGE_FAMILY=$(docker-image-info family) + +case "$IMAGE_FAMILY" in + Debian|Ubuntu) + apt-install openssh-server + ;; + + RedHat) + yum-install openssh-server + ;; + + Alpine) + apk-install openssh + ;; +esac diff --git a/docker/samson-deployment/latest/conf/provision/service.d/syslog.sh b/docker/samson-deployment/latest/conf/provision/service.d/syslog.sh new file mode 100644 index 000000000..7e8b8e0a9 --- /dev/null +++ b/docker/samson-deployment/latest/conf/provision/service.d/syslog.sh @@ -0,0 +1,41 @@ +#!/usr/bin/env bash + +IMAGE_FAMILY=$(docker-image-info family) + +# Installation +case "$IMAGE_FAMILY" in + Debian|Ubuntu) + apt-install syslog-ng syslog-ng-core + ;; + + RedHat) + yum-install syslog-ng + + # remove logrotate (not needed for docker) + rm -f "/etc/cron.daily/logrotate" + ;; + + Alpine) + apk-install syslog-ng + ;; +esac + +## Configuration +SYSLOG_NG_VERSION=$(syslog-ng --version | grep -E -e '^syslog-ng[ ]+[0-9]+\.[0-9]+' | head -n 1 | awk '{print $2}' | cut -f 1,2 -d .) + +# Disable caps inside container +if [[ -f /etc/default/syslog-ng ]]; then + go-replace --mode=lineinfile \ + -s "SYSLOGNG_OPTS" -r "SYSLOGNG_OPTS = --no-caps" \ + -- /etc/default/syslog-ng +fi + +# Symlink configuration +ln -s -f /opt/docker/etc/syslog-ng/syslog-ng.conf /etc/syslog-ng/syslog-ng.conf + +go-replace --mode=lineinfile \ + -s "@version" -r "@version: ${SYSLOG_NG_VERSION}" \ + -- /etc/syslog-ng/syslog-ng.conf + +# Ensure /var/lib/syslog-ng exists +mkdir -p /var/lib/syslog-ng diff --git a/docker/samson-deployment/latest/conf/provision/variables-webdevops.yml b/docker/samson-deployment/latest/conf/provision/variables-webdevops.yml new file mode 100644 index 000000000..0b2a21a95 --- /dev/null +++ b/docker/samson-deployment/latest/conf/provision/variables-webdevops.yml @@ -0,0 +1,7 @@ +--- + +docker_image_info_family: "{{ lookup('pipe', 'docker-image-info family') }}" +docker_image_info_distribution: "{{ lookup('pipe', 'docker-image-info dist') }}" +docker_image_info_distribution_version: "{{ lookup('pipe', 'docker-image-info dist-version') }}" +docker_image_info_distribution_release: "{{ lookup('pipe', 'docker-image-info dist-release') }}" +docker_image_info_distribution_codename: "{{ lookup('pipe', 'docker-image-info dist-codename') }}" diff --git a/docker/samson-deployment/latest/conf/provision/variables.yml b/docker/samson-deployment/latest/conf/provision/variables.yml index ed97d539c..0b2a21a95 100644 --- a/docker/samson-deployment/latest/conf/provision/variables.yml +++ b/docker/samson-deployment/latest/conf/provision/variables.yml @@ -1 +1,7 @@ --- + +docker_image_info_family: "{{ lookup('pipe', 'docker-image-info family') }}" +docker_image_info_distribution: "{{ lookup('pipe', 'docker-image-info dist') }}" +docker_image_info_distribution_version: "{{ lookup('pipe', 'docker-image-info dist-version') }}" +docker_image_info_distribution_release: "{{ lookup('pipe', 'docker-image-info dist-release') }}" +docker_image_info_distribution_codename: "{{ lookup('pipe', 'docker-image-info dist-codename') }}" diff --git a/docker/sphinx/latest/Dockerfile b/docker/sphinx/latest/Dockerfile index 874b228b6..144735627 100644 --- a/docker/sphinx/latest/Dockerfile +++ b/docker/sphinx/latest/Dockerfile @@ -3,14 +3,13 @@ # -- automatically generated -- #+++++++++++++++++++++++++++++++++++++++ -FROM webdevops/bootstrap:alpine-3 - -MAINTAINER info@webdevops.io -LABEL vendor=WebDevOps.io -LABEL io.webdevops.layout=8 -LABEL io.webdevops.version=1.5.0 +FROM webdevops/bootstrap:alpine RUN /usr/local/bin/apk-install \ + # General python + python \ + py-crypto \ + py2-pip \ # General sphinx py-pillow \ py-yaml \ @@ -19,6 +18,8 @@ RUN /usr/local/bin/apk-install \ # GRAPHVIZ graphviz \ ttf-dejavu \ + && pip install --upgrade pip \ + && hash -r \ && pip install --upgrade sphinxcontrib-googlechart \ && pip install --upgrade sphinxcontrib-googlemaps \ && pip install --upgrade sphinxcontrib-httpdomain \ @@ -29,4 +30,5 @@ RUN /usr/local/bin/apk-install \ && pip install t3SphinxThemeRtd \ && pip install t3fieldlisttable \ && pip install t3tablerows \ - && pip install t3targets + && pip install t3targets \ + && docker-image-cleanup diff --git a/docker/sphinx/latest/Dockerfile.jinja2 b/docker/sphinx/latest/Dockerfile.jinja2 index 831b20ba5..d68cfdc20 100644 --- a/docker/sphinx/latest/Dockerfile.jinja2 +++ b/docker/sphinx/latest/Dockerfile.jinja2 @@ -1,5 +1,3 @@ -{{ docker.from("bootstrap","alpine-3") }} - -{{ docker.version() }} +{{ docker.from("bootstrap","alpine") }} {{ sphinx.alpine() }} diff --git a/docker/ssh/latest/Dockerfile b/docker/ssh/latest/Dockerfile index 5e512c23e..c3b35619b 100644 --- a/docker/ssh/latest/Dockerfile +++ b/docker/ssh/latest/Dockerfile @@ -5,11 +5,7 @@ FROM webdevops/base-app:latest -MAINTAINER info@webdevops.io -LABEL vendor=WebDevOps.io -LABEL io.webdevops.layout=8 -LABEL io.webdevops.version=1.5.0 - -RUN /opt/docker/bin/control.sh service.enable ssh +RUN /opt/docker/bin/control.sh service.enable ssh \ + && docker-image-cleanup EXPOSE 22 diff --git a/docker/ssh/latest/Dockerfile.jinja2 b/docker/ssh/latest/Dockerfile.jinja2 index 292efdb12..65b04d6be 100644 --- a/docker/ssh/latest/Dockerfile.jinja2 +++ b/docker/ssh/latest/Dockerfile.jinja2 @@ -1,7 +1,5 @@ {{ docker.from("base-app") }} -{{ docker.version() }} - {{ ssh.ubuntu() }} {{ docker.expose('22') }} diff --git a/docker/storage/latest/Dockerfile b/docker/storage/latest/Dockerfile index cedd850c9..f781ba889 100644 --- a/docker/storage/latest/Dockerfile +++ b/docker/storage/latest/Dockerfile @@ -5,11 +5,6 @@ FROM busybox:latest -MAINTAINER info@webdevops.io -LABEL vendor=WebDevOps.io -LABEL io.webdevops.layout=8 -LABEL io.webdevops.version=1.5.0 - RUN mkdir /storage/ \ && chmod 777 /storage/ diff --git a/docker/storage/latest/Dockerfile.jinja2 b/docker/storage/latest/Dockerfile.jinja2 index 3031e68e2..e23e33453 100644 --- a/docker/storage/latest/Dockerfile.jinja2 +++ b/docker/storage/latest/Dockerfile.jinja2 @@ -1,7 +1,5 @@ {{ docker.fromOfficial("busybox") }} -{{ docker.version() }} - RUN mkdir /storage/ \ && chmod 777 /storage/ diff --git a/docker/typo3-solr/3.1/Dockerfile b/docker/typo3-solr/3.1/Dockerfile index 80a87d88d..e0a2958fd 100644 --- a/docker/typo3-solr/3.1/Dockerfile +++ b/docker/typo3-solr/3.1/Dockerfile @@ -5,19 +5,21 @@ FROM guywithnose/solr:4.10.4 -MAINTAINER info@webdevops.io -LABEL vendor=WebDevOps.io -LABEL io.webdevops.layout=8 -LABEL io.webdevops.version=1.5.0 +LABEL maintainer=info@webdevops.io \ + vendor=WebDevOps.io \ + io.webdevops.layout=8 \ + io.webdevops.version=1.5.0 -ENV TERM "xterm" -ENV LANG "C.UTF-8" -ENV LC_ALL "C.UTF-8" +ENV TERM="xterm" \ + LANG="C.UTF-8" \ + LC_ALL="C.UTF-8" USER root COPY ./solr/ /tmp/solr +ADD baselayout.tar / + RUN pacman --sync --noconfirm --noprogressbar --quiet net-tools \ && rm -rf /opt/solr/server \ && mv /opt/solr/example/ /opt/solr/server/ \ diff --git a/docker/typo3-solr/3.1/Dockerfile.jinja2 b/docker/typo3-solr/3.1/Dockerfile.jinja2 index 7530f5ed6..de78ed477 100644 --- a/docker/typo3-solr/3.1/Dockerfile.jinja2 +++ b/docker/typo3-solr/3.1/Dockerfile.jinja2 @@ -2,12 +2,14 @@ {{ docker.version() }} -{{ environment.general(charset="C.UTF-8") }} +{{ environment.general() }} USER root COPY ./solr/ /tmp/solr +{{ docker.add('baselayout.tar', '/') }} + RUN pacman --sync --noconfirm --noprogressbar --quiet net-tools \ && rm -rf /opt/solr/server \ && mv /opt/solr/example/ /opt/solr/server/ \ diff --git a/docker/typo3-solr/3.1/baselayout.tar b/docker/typo3-solr/3.1/baselayout.tar new file mode 100644 index 000000000..dc5fbe08f Binary files /dev/null and b/docker/typo3-solr/3.1/baselayout.tar differ diff --git a/docker/typo3-solr/5.0/Dockerfile b/docker/typo3-solr/5.0/Dockerfile index c70ac4ffa..1582b8545 100644 --- a/docker/typo3-solr/5.0/Dockerfile +++ b/docker/typo3-solr/5.0/Dockerfile @@ -5,20 +5,25 @@ FROM guywithnose/solr:4.10.4 -MAINTAINER info@webdevops.io -LABEL vendor=WebDevOps.io -LABEL io.webdevops.layout=8 -LABEL io.webdevops.version=1.5.0 +LABEL maintainer=info@webdevops.io \ + vendor=WebDevOps.io \ + io.webdevops.layout=8 \ + io.webdevops.version=1.5.0 -ENV TERM "xterm" -ENV LANG "C.UTF-8" -ENV LC_ALL "C.UTF-8" +ENV TERM="xterm" \ + LANG="C.UTF-8" \ + LC_ALL="C.UTF-8" USER root COPY ./solr/ /tmp/solr +ADD baselayout.tar / + +WORKDIR / + RUN pacman --sync --noconfirm --noprogressbar --quiet net-tools \ + && /usr/local/bin/generate-dockerimage-info \ && rm -rf /opt/solr/server \ && mv /opt/solr/example/ /opt/solr/server/ \ && rm -rf /opt/solr/server/solr \ @@ -28,10 +33,12 @@ RUN pacman --sync --noconfirm --noprogressbar --quiet net-tools \ && ln -s /opt/solr/contrib /opt/solr/server/solr/contrib \ && mkdir -p /opt/solr/server/solr/data \ && ln -s /opt/solr/server/solr/data /opt/solr/server/solr/typo3cores/data \ - && chown -R solr:solr /opt/solr/server/solr/ + && chown -R solr:solr /opt/solr/server/solr/ \ + && docker-image-cleanup USER solr WORKDIR /opt/solr/server VOLUME ["/opt/solr/server/solr/data"] + diff --git a/docker/typo3-solr/5.0/Dockerfile.jinja2 b/docker/typo3-solr/5.0/Dockerfile.jinja2 index 7530f5ed6..0f69dea48 100644 --- a/docker/typo3-solr/5.0/Dockerfile.jinja2 +++ b/docker/typo3-solr/5.0/Dockerfile.jinja2 @@ -2,26 +2,7 @@ {{ docker.version() }} -{{ environment.general(charset="C.UTF-8") }} +{{ environment.general() }} -USER root +{{ typo3Solr.guywithnose(release="1.3.0") }} -COPY ./solr/ /tmp/solr - -RUN pacman --sync --noconfirm --noprogressbar --quiet net-tools \ - && rm -rf /opt/solr/server \ - && mv /opt/solr/example/ /opt/solr/server/ \ - && rm -rf /opt/solr/server/solr \ - && mv /tmp/solr /opt/solr/server/solr \ - && mkdir -p /opt/solr/server/solr/typo3lib \ - && curl -sf -o /opt/solr/server/solr/typo3lib/solr-typo3-plugin.jar -L https://github.com/TYPO3-Solr/solr-typo3-plugin/releases/download/release-1_3_0/solr-typo3-plugin-1.3.0.jar \ - && ln -s /opt/solr/contrib /opt/solr/server/solr/contrib \ - && mkdir -p /opt/solr/server/solr/data \ - && ln -s /opt/solr/server/solr/data /opt/solr/server/solr/typo3cores/data \ - && chown -R solr:solr /opt/solr/server/solr/ - -USER solr - -WORKDIR /opt/solr/server - -VOLUME ["/opt/solr/server/solr/data"] diff --git a/docker/typo3-solr/5.0/baselayout.tar b/docker/typo3-solr/5.0/baselayout.tar new file mode 100644 index 000000000..dc5fbe08f Binary files /dev/null and b/docker/typo3-solr/5.0/baselayout.tar differ diff --git a/docker/typo3-solr/6.0/Dockerfile b/docker/typo3-solr/6.0/Dockerfile index 7b9e18545..9b57abe2c 100644 --- a/docker/typo3-solr/6.0/Dockerfile +++ b/docker/typo3-solr/6.0/Dockerfile @@ -5,26 +5,29 @@ FROM solr:6.3.0 -MAINTAINER info@webdevops.io -LABEL vendor=WebDevOps.io -LABEL io.webdevops.layout=8 -LABEL io.webdevops.version=1.5.0 +LABEL maintainer=info@webdevops.io \ + vendor=WebDevOps.io \ + io.webdevops.layout=8 \ + io.webdevops.version=1.5.0 -ENV TERM "xterm" -ENV LANG "C.UTF-8" -ENV LC_ALL "C.UTF-8" - -COPY ./solr/ /tmp/solr +ENV TERM="xterm" \ + LANG="C.UTF-8" \ + LC_ALL="C.UTF-8" USER root -RUN apt-get update \ - && apt-get install -y -f --no-install-recommends lsb-release lsb-base net-tools \ - && apt-get clean -y \ +ADD baselayout.tar / + +COPY ./solr/ /tmp/solr + +RUN /usr/local/bin/apt-update \ + && /usr/local/bin/apt-install net-tools \ + && /usr/local/bin/generate-dockerimage-info \ && rm -rf /opt/solr/server/solr \ && mv /tmp/solr /opt/solr/server/solr \ && mkdir -p /opt/solr/server/solr/data \ - && chown -R solr:solr /opt/solr/server/solr + && chown -R solr:solr /opt/solr/server/solr \ + && docker-image-cleanup USER solr diff --git a/docker/typo3-solr/6.0/Dockerfile.jinja2 b/docker/typo3-solr/6.0/Dockerfile.jinja2 index 4a527990f..a144ca0a5 100644 --- a/docker/typo3-solr/6.0/Dockerfile.jinja2 +++ b/docker/typo3-solr/6.0/Dockerfile.jinja2 @@ -2,20 +2,6 @@ {{ docker.version() }} -{{ environment.general(charset="C.UTF-8") }} +{{ environment.general() }} -COPY ./solr/ /tmp/solr - -USER root - -RUN apt-get update \ - && apt-get install -y -f --no-install-recommends lsb-release lsb-base net-tools \ - && apt-get clean -y \ - && rm -rf /opt/solr/server/solr \ - && mv /tmp/solr /opt/solr/server/solr \ - && mkdir -p /opt/solr/server/solr/data \ - && chown -R solr:solr /opt/solr/server/solr - -USER solr - -VOLUME ["/opt/solr/server/solr/data"] +{{ typo3Solr.official() }} diff --git a/docker/typo3-solr/6.0/baselayout.tar b/docker/typo3-solr/6.0/baselayout.tar new file mode 100644 index 000000000..dc5fbe08f Binary files /dev/null and b/docker/typo3-solr/6.0/baselayout.tar differ diff --git a/docker/typo3/ubuntu-14.04/Dockerfile b/docker/typo3/ubuntu-14.04/Dockerfile index ad8d85491..aded6725d 100644 --- a/docker/typo3/ubuntu-14.04/Dockerfile +++ b/docker/typo3/ubuntu-14.04/Dockerfile @@ -5,11 +5,6 @@ FROM webdevops/php-apache:ubuntu-14.04 -MAINTAINER info@webdevops.io -LABEL vendor=WebDevOps.io -LABEL io.webdevops.layout=8 -LABEL io.webdevops.version=1.5.0 - ENV WEB_DOCUMENT_ROOT /app/web/ COPY conf/ /opt/docker/ diff --git a/docker/typo3/ubuntu-14.04/Dockerfile.jinja2 b/docker/typo3/ubuntu-14.04/Dockerfile.jinja2 index 3b5805449..1fc57744a 100644 --- a/docker/typo3/ubuntu-14.04/Dockerfile.jinja2 +++ b/docker/typo3/ubuntu-14.04/Dockerfile.jinja2 @@ -1,7 +1,5 @@ {{ docker.from("php-apache", "ubuntu-14.04") }} -{{ docker.version() }} - ENV WEB_DOCUMENT_ROOT /app/web/ {{ docker.copy('conf/', '/opt/docker/') }} diff --git a/docker/varnish/latest/Dockerfile b/docker/varnish/latest/Dockerfile index f3e49864b..ccb9fb188 100644 --- a/docker/varnish/latest/Dockerfile +++ b/docker/varnish/latest/Dockerfile @@ -3,12 +3,7 @@ # -- automatically generated -- #+++++++++++++++++++++++++++++++++++++++ -FROM webdevops/base:alpine-3 - -MAINTAINER info@webdevops.io -LABEL vendor=WebDevOps.io -LABEL io.webdevops.layout=8 -LABEL io.webdevops.version=1.5.0 +FROM webdevops/base:alpine ENV VARNISH_PORT 80 @@ -22,7 +17,8 @@ ENV VARNISH_BACKEND_PORT "80" COPY conf/ /opt/docker/ RUN /usr/local/bin/apk-install \ - varnish + varnish \ + && docker-image-cleanup CMD ["varnishd"] diff --git a/docker/varnish/latest/Dockerfile.jinja2 b/docker/varnish/latest/Dockerfile.jinja2 index 0d5a01926..be30c2d0f 100644 --- a/docker/varnish/latest/Dockerfile.jinja2 +++ b/docker/varnish/latest/Dockerfile.jinja2 @@ -1,6 +1,4 @@ -{{ docker.from("base","alpine-3") }} - -{{ docker.version() }} +{{ docker.from("base","alpine") }} {{ varnish.env() }} diff --git a/docker/varnish/latest/conf/bin/entrypoint.d/varnishd.sh b/docker/varnish/latest/conf/bin/entrypoint.d/varnishd.sh index d9854a5a2..8879926cd 100644 --- a/docker/varnish/latest/conf/bin/entrypoint.d/varnishd.sh +++ b/docker/varnish/latest/conf/bin/entrypoint.d/varnishd.sh @@ -33,13 +33,10 @@ if [[ -z "$VARNISH_PORT" ]]; then exit 1 fi -if [[ -n "$VARNISH_BACKEND_HOST" ]]; then - rpl --quiet "" "$VARNISH_BACKEND_HOST" "$VARNISH_CONFIG" > /dev/null -fi - -if [[ -n "$VARNISH_BACKEND_PORT" ]]; then - rpl --quiet "" "$VARNISH_BACKEND_PORT" "$VARNISH_CONFIG" > /dev/null -fi +go-replace \ + -s "" -r "$VARNISH_BACKEND_HOST" \ + -s "" -r "$VARNISH_BACKEND_PORT" \ + -- "$VARNISH_CONFIG" echo " Starting varnishd..." echo " listening on: 0.0.0.0:${VARNISH_PORT}" diff --git a/docker/vsftp/latest/Dockerfile b/docker/vsftp/latest/Dockerfile index 109f18f82..68a252eea 100644 --- a/docker/vsftp/latest/Dockerfile +++ b/docker/vsftp/latest/Dockerfile @@ -5,16 +5,11 @@ FROM webdevops/base:latest -MAINTAINER info@webdevops.io -LABEL vendor=WebDevOps.io -LABEL io.webdevops.layout=8 -LABEL io.webdevops.version=1.5.0 - -ENV FTP_USER application -ENV FTP_PASSWORD application -ENV FTP_UID 1000 -ENV FTP_GID 1000 -ENV FTP_PATH /data/ftp/ +ENV FTP_USER=application \ + FTP_PASSWORD=application \ + FTP_UID=1000 \ + FTP_GID=1000 \ + FTP_PATH=/data/ftp/ COPY conf/ /opt/docker/ @@ -27,7 +22,7 @@ RUN /usr/local/bin/apt-install \ /var/log/supervisor \ && /opt/docker/bin/provision add --tag entrypoint webdevops-vsftp \ && /opt/docker/bin/provision run --tag bootstrap --role webdevops-vsftp \ - && /opt/docker/bin/bootstrap.sh - + && /opt/docker/bin/bootstrap.sh \ + && docker-image-cleanup EXPOSE 20 21 12020 12021 12022 12023 12024 12025 diff --git a/docker/vsftp/latest/Dockerfile.jinja2 b/docker/vsftp/latest/Dockerfile.jinja2 index e4ff22d0b..fbf0db226 100644 --- a/docker/vsftp/latest/Dockerfile.jinja2 +++ b/docker/vsftp/latest/Dockerfile.jinja2 @@ -1,7 +1,5 @@ {{ docker.from("base", "latest") }} -{{ docker.version() }} - {{ environment.ftp() }} {{ docker.copy('conf/', '/opt/docker/') }} diff --git a/documentation/docs/content/Customization/supervisord.rst b/documentation/docs/content/Customization/supervisord.rst index 4be6eb9ce..7b43caf51 100644 --- a/documentation/docs/content/Customization/supervisord.rst +++ b/documentation/docs/content/Customization/supervisord.rst @@ -1,6 +1,6 @@ -================= -Supervisor Daemon -================= +============================ +Supervisor Daemon (Services) +============================ .. important:: Supervisor is only available in Docker images which are based on ``webdevops/base``! @@ -10,6 +10,17 @@ Introduction Supervisor daemon is used to start and supervise more than one process in Docker containers. More about supervisor can be found on supervisor homepage at http://supervisord.org/ +Enable and disable services +--------------------------- + +For enabling services run `docker-service-enable` or `docker-service-disable` inside your Dockerfile. + +eg:: + + RUN docker-service-enable ssh + +This task will also trigger an auto installation if the daemon is not installed. + Configuration ------------- diff --git a/documentation/docs/content/DockerImages/dockerfiles/base-app.rst b/documentation/docs/content/DockerImages/dockerfiles/base-app.rst index eabb507b9..551c67051 100644 --- a/documentation/docs/content/DockerImages/dockerfiles/base-app.rst +++ b/documentation/docs/content/DockerImages/dockerfiles/base-app.rst @@ -37,4 +37,5 @@ Docker image tags Environment variables --------------------- +.. include:: include/environment-base.rst .. include:: include/environment-base-app.rst diff --git a/documentation/docs/content/DockerImages/dockerfiles/base.rst b/documentation/docs/content/DockerImages/dockerfiles/base.rst index 98c6d3df0..029669f58 100644 --- a/documentation/docs/content/DockerImages/dockerfiles/base.rst +++ b/documentation/docs/content/DockerImages/dockerfiles/base.rst @@ -11,6 +11,11 @@ Docker image tags .. include:: include/image-tag-base.rst +Environment variables +--------------------- + +.. include:: include/environment-base.rst + Entrypoint ---------- diff --git a/documentation/docs/content/DockerImages/dockerfiles/hhvm-apache.rst b/documentation/docs/content/DockerImages/dockerfiles/hhvm-apache.rst index 00be291a3..06ebf9952 100644 --- a/documentation/docs/content/DockerImages/dockerfiles/hhvm-apache.rst +++ b/documentation/docs/content/DockerImages/dockerfiles/hhvm-apache.rst @@ -14,6 +14,7 @@ Docker image tags Environment variables --------------------- +.. include:: include/environment-base.rst .. include:: include/environment-base-app.rst .. include:: include/environment-web.rst diff --git a/documentation/docs/content/DockerImages/dockerfiles/hhvm-nginx.rst b/documentation/docs/content/DockerImages/dockerfiles/hhvm-nginx.rst index 62c1f2515..23d3ebf78 100644 --- a/documentation/docs/content/DockerImages/dockerfiles/hhvm-nginx.rst +++ b/documentation/docs/content/DockerImages/dockerfiles/hhvm-nginx.rst @@ -14,6 +14,7 @@ Docker image tags Environment variables --------------------- +.. include:: include/environment-base.rst .. include:: include/environment-base-app.rst .. include:: include/environment-web.rst diff --git a/documentation/docs/content/DockerImages/dockerfiles/hhvm.rst b/documentation/docs/content/DockerImages/dockerfiles/hhvm.rst index d87c2f055..154a73aed 100644 --- a/documentation/docs/content/DockerImages/dockerfiles/hhvm.rst +++ b/documentation/docs/content/DockerImages/dockerfiles/hhvm.rst @@ -14,6 +14,7 @@ Docker image tags Environment variables --------------------- +.. include:: include/environment-base.rst .. include:: include/environment-base-app.rst Docker image layout diff --git a/documentation/docs/content/DockerImages/dockerfiles/include/environment-base.rst b/documentation/docs/content/DockerImages/dockerfiles/include/environment-base.rst new file mode 100644 index 000000000..c8c6c2786 --- /dev/null +++ b/documentation/docs/content/DockerImages/dockerfiles/include/environment-base.rst @@ -0,0 +1,9 @@ +Base environment variables +^^^^^^^^^^^^^^^^^^^^^^^^^^ + +====================== ============================= ================ +Environment variable Description Default +====================== ============================= ================ +``LOG_STDOUT`` Destination of daemon output *empty* (stdout) +``LOG_STDERR`` Destination of daemon errors *empty* (stdout) +====================== ============================= ================ diff --git a/documentation/docs/content/DockerImages/dockerfiles/include/image-tag-php.rst b/documentation/docs/content/DockerImages/dockerfiles/include/image-tag-php.rst index b295a3401..2cbd7f09a 100644 --- a/documentation/docs/content/DockerImages/dockerfiles/include/image-tag-php.rst +++ b/documentation/docs/content/DockerImages/dockerfiles/include/image-tag-php.rst @@ -1,15 +1,23 @@ -====================== ========================== =============== -Tag Distribution name PHP Version -====================== ========================== =============== -``ubuntu-12.04`` precise PHP 5.3 -``ubuntu-14.04`` trusty (LTS) PHP 5.5 -``ubuntu-15.04`` vivid PHP 5.6 -``ubuntu-15.10`` wily PHP 5.6 -``ubuntu-16.04`` xenial (LTS) PHP 7.0 -``debian-7`` wheezy PHP 5.4 -``debian-8`` jessie PHP 5.6 -``debian-8-php7`` jessie with dotdeb PHP 7.x (via sury) -``debian-9`` stretch PHP 7.0 -``centos-7`` PHP 5.4 -``centos-7-php56`` PHP 5.6 -====================== ========================== =============== +====================== =================================== =============== +Tag Distribution name PHP Version +====================== =================================== =============== +``5.6`` *customized official php image* PHP 5.6 +``7.0`` *customized official php image* PHP 7.0 +``7.1`` *customized official php image* PHP 7.1 +``alpine`` *link to alpine-php7* PHP 7.x +``alpine-php7`` PHP 7.x +``alpine-php5`` PHP 5.6 +``alpine-3`` *deprecated* PHP 5.6 +``alpine-3-php7`` *deprecated* PHP 7.x +``ubuntu-12.04`` precise PHP 5.3 +``ubuntu-14.04`` trusty (LTS) PHP 5.5 +``ubuntu-15.04`` vivid PHP 5.6 +``ubuntu-15.10`` wily PHP 5.6 +``ubuntu-16.04`` xenial (LTS) PHP 7.0 +``debian-7`` wheezy PHP 5.4 +``debian-8`` jessie PHP 5.6 +``debian-8-php7`` jessie with dotdeb PHP 7.x (via sury) +``debian-9`` stretch PHP 7.0 +``centos-7`` PHP 5.4 +``centos-7-php56`` PHP 5.6 +====================== =================================== =============== diff --git a/documentation/docs/content/DockerImages/dockerfiles/liquidsoap.rst b/documentation/docs/content/DockerImages/dockerfiles/liquidsoap.rst new file mode 100644 index 000000000..cce5083c4 --- /dev/null +++ b/documentation/docs/content/DockerImages/dockerfiles/liquidsoap.rst @@ -0,0 +1,53 @@ +==================== +webdevops/liquidsoap +==================== + +The liquidsoap images are based on ``webdevops/base`` with liquidsoap multimedia streaming server with most plugins. + +Docker image tags +----------------- + +====================== ============================================= +Tag Distribution name +====================== ============================================= +``latest`` Based on `webdevops/base:latest` (Ubuntu) +====================== ============================================= + +Environment variables +--------------------- + +.. include:: include/environment-base.rst + + +Liquisoap environment variables +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +====================================================== ===================================== ============================================== +Environment variable Description Default +====================================================== ===================================== ============================================== +``LIQUIDSOAP_USER`` Daemon user ID ``liquidsoap`` +``LIQUIDSOAP_TELNET`` Open telnet (port 1234) ``1`` (enabled) +``LIQUIDSOAP_SCRIPT`` Configuration script for liquidsoap ``/opt/docker/etc/liquidsoap/default.liq`` +``LIQUIDSOAP_TEMPLATE`` Apply template to config script ``1/opt/docker/etc/liquidsoap/default.liq`` + +``LIQUIDSOAP_STREAM_INPUT`` Input stream (eg. icecast) ``http://icecast:8000/live`` + +``LIQUIDSOAP_PLAYLIST_DEFAULT`` Default stream when no other stream ``audio_to_stereo(single('/opt/docker/etc/liquidsoap/default.mp3'))`` + is active + +``LIQUIDSOAP_PLAYLIST_DAY`` Day input stream/playlist ``playlist('/opt/docker/etc/liquidsoap/playlist-day.pls')`` +``LIQUIDSOAP_PLAYLIST_DAY_TIMERANGE`` Timerange for day playlist ``4h-2h`` + +``LIQUIDSOAP_PLAYLIST_NIGHT`` Night input stream/playlist ``playlist('/opt/docker/etc/liquidsoap/playlist-night.pls')`` +``LIQUIDSOAP_PLAYLIST_NIGHT_TIMERANGE`` Timerange for night playlist ``2h-14h`` + +``LIQUIDSOAP_OUTPUT`` Output stream (eg. icecast) ``output.icecast(%mp3(bitrate=128),host='localhost',port=8000,password='secretpassword',mount='liquidsoap-128',name=META_name,genre=META_genre,url=META_url,description=META_desc,ALL_input)`` + +``LIQUIDSOAP_OUTPUT_1`` ... ``LIQUIDSOAP_OUTPUT_20`` More output stream lines *empty* + + +``LIQUIDSOAP_META_NAME`` Station name ``Liquidsoap Docker`` +``LIQUIDSOAP_META_GENRE`` Station genre *empty* +``LIQUIDSOAP_META_URL`` Station url *empty* +``LIQUIDSOAP_META_DESCRIPTION`` Station description *empty* +====================================================== ===================================== ============================================== + diff --git a/documentation/docs/content/DockerImages/dockerfiles/mail-sandbox.rst b/documentation/docs/content/DockerImages/dockerfiles/mail-sandbox.rst index ca7218842..bc9b21db7 100644 --- a/documentation/docs/content/DockerImages/dockerfiles/mail-sandbox.rst +++ b/documentation/docs/content/DockerImages/dockerfiles/mail-sandbox.rst @@ -19,11 +19,12 @@ Tag Distribution name Environment variables --------------------- +.. include:: include/environment-base.rst .. include:: include/environment-base-app.rst -Base environment variables -^^^^^^^^^^^^^^^^^^^^^^^^^^ +Mail sandbox environment variables +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ====================== ============================= ============= Environment variable Description Default diff --git a/documentation/docs/content/DockerImages/dockerfiles/nginx-dev.rst b/documentation/docs/content/DockerImages/dockerfiles/nginx-dev.rst index 574ef1f89..fd603bcbf 100644 --- a/documentation/docs/content/DockerImages/dockerfiles/nginx-dev.rst +++ b/documentation/docs/content/DockerImages/dockerfiles/nginx-dev.rst @@ -15,7 +15,7 @@ Docker image tags Environment variables --------------------- -.. include:: include/environment-base-app.rst +.. include:: include/environment-base.rst .. include:: include/environment-web-dev.rst diff --git a/documentation/docs/content/DockerImages/dockerfiles/nginx.rst b/documentation/docs/content/DockerImages/dockerfiles/nginx.rst index 2e1bad583..94aeb1eaf 100644 --- a/documentation/docs/content/DockerImages/dockerfiles/nginx.rst +++ b/documentation/docs/content/DockerImages/dockerfiles/nginx.rst @@ -13,6 +13,7 @@ Docker image tags Environment variables --------------------- +.. include:: include/environment-base.rst .. include:: include/environment-web.rst diff --git a/documentation/docs/content/DockerImages/dockerfiles/php-apache-dev.rst b/documentation/docs/content/DockerImages/dockerfiles/php-apache-dev.rst index 639d00737..1e80d8fb8 100644 --- a/documentation/docs/content/DockerImages/dockerfiles/php-apache-dev.rst +++ b/documentation/docs/content/DockerImages/dockerfiles/php-apache-dev.rst @@ -15,6 +15,7 @@ Docker image tags Environment variables --------------------- +.. include:: include/environment-base.rst .. include:: include/environment-base-app.rst .. include:: include/environment-php-dev.rst diff --git a/documentation/docs/content/DockerImages/dockerfiles/php-apache.rst b/documentation/docs/content/DockerImages/dockerfiles/php-apache.rst index a0deba3e0..f599e46d9 100644 --- a/documentation/docs/content/DockerImages/dockerfiles/php-apache.rst +++ b/documentation/docs/content/DockerImages/dockerfiles/php-apache.rst @@ -13,6 +13,7 @@ Docker image tags Environment variables --------------------- +.. include:: include/environment-base.rst .. include:: include/environment-base-app.rst .. include:: include/environment-web.rst diff --git a/documentation/docs/content/DockerImages/dockerfiles/php-dev.rst b/documentation/docs/content/DockerImages/dockerfiles/php-dev.rst index 1a2a61550..6e95f6806 100644 --- a/documentation/docs/content/DockerImages/dockerfiles/php-dev.rst +++ b/documentation/docs/content/DockerImages/dockerfiles/php-dev.rst @@ -15,6 +15,7 @@ Docker image tags Environment variables --------------------- +.. include:: include/environment-base.rst .. include:: include/environment-base-app.rst .. include:: include/environment-php-dev.rst diff --git a/documentation/docs/content/DockerImages/dockerfiles/php-nginx-dev.rst b/documentation/docs/content/DockerImages/dockerfiles/php-nginx-dev.rst index bd06053e5..16019d20e 100644 --- a/documentation/docs/content/DockerImages/dockerfiles/php-nginx-dev.rst +++ b/documentation/docs/content/DockerImages/dockerfiles/php-nginx-dev.rst @@ -15,6 +15,7 @@ Docker image tags Environment variables --------------------- +.. include:: include/environment-base.rst .. include:: include/environment-base-app.rst .. include:: include/environment-php-dev.rst diff --git a/documentation/docs/content/DockerImages/dockerfiles/php-nginx.rst b/documentation/docs/content/DockerImages/dockerfiles/php-nginx.rst index 9cbb2d21d..460dd0b28 100644 --- a/documentation/docs/content/DockerImages/dockerfiles/php-nginx.rst +++ b/documentation/docs/content/DockerImages/dockerfiles/php-nginx.rst @@ -13,6 +13,7 @@ Docker image tags Environment variables --------------------- +.. include:: include/environment-base.rst .. include:: include/environment-base-app.rst .. include:: include/environment-web.rst diff --git a/documentation/docs/content/DockerImages/dockerfiles/php.rst b/documentation/docs/content/DockerImages/dockerfiles/php.rst index 17d6e8071..8ce259130 100644 --- a/documentation/docs/content/DockerImages/dockerfiles/php.rst +++ b/documentation/docs/content/DockerImages/dockerfiles/php.rst @@ -12,6 +12,7 @@ Docker image tags Environment variables --------------------- +.. include:: include/environment-base.rst .. include:: include/environment-base-app.rst diff --git a/documentation/docs/content/DockerImages/dockerfiles/postfix.rst b/documentation/docs/content/DockerImages/dockerfiles/postfix.rst index 918890ec3..d0fabcab6 100644 --- a/documentation/docs/content/DockerImages/dockerfiles/postfix.rst +++ b/documentation/docs/content/DockerImages/dockerfiles/postfix.rst @@ -13,5 +13,6 @@ Docker image tags Environment variables --------------------- +.. include:: include/environment-base.rst .. include:: include/environment-base-app.rst diff --git a/documentation/docs/content/DockerImages/dockerfiles/samson-deployment.rst b/documentation/docs/content/DockerImages/dockerfiles/samson-deployment.rst index d977f4824..3bf4477ce 100644 --- a/documentation/docs/content/DockerImages/dockerfiles/samson-deployment.rst +++ b/documentation/docs/content/DockerImages/dockerfiles/samson-deployment.rst @@ -21,6 +21,7 @@ The original image is only the webbased deployment system and is extended by: Environment variables --------------------- +.. include:: include/environment-base.rst .. include:: include/environment-base-app.rst diff --git a/documentation/docs/content/DockerImages/index.rst b/documentation/docs/content/DockerImages/index.rst index b9066e142..33c711543 100644 --- a/documentation/docs/content/DockerImages/index.rst +++ b/documentation/docs/content/DockerImages/index.rst @@ -23,6 +23,7 @@ Docker images dockerfiles/hhvm-apache dockerfiles/hhvm-nginx dockerfiles/liquibase + dockerfiles/liquidsoap dockerfiles/mail-sandbox dockerfiles/nginx dockerfiles/nginx-dev diff --git a/foo b/foo new file mode 100644 index 000000000..d00491fd7 --- /dev/null +++ b/foo @@ -0,0 +1 @@ +1 diff --git a/provisioning/apache-dev/general/bin/service.d/httpd.d/12-development.sh b/provisioning/apache-dev/general/bin/service.d/httpd.d/12-development.sh index 299f67e2f..a9d2c6e92 100644 --- a/provisioning/apache-dev/general/bin/service.d/httpd.d/12-development.sh +++ b/provisioning/apache-dev/general/bin/service.d/httpd.d/12-development.sh @@ -1 +1,5 @@ -find /opt/docker/etc/httpd/ -iname '*.conf' -print0 | xargs -0 -r rpl --quiet "" "$WEB_NO_CACHE_PATTERN" > /dev/null +go-replace \ + -s "" -r "$WEB_NO_CACHE_PATTERN" \ + --path=/opt/docker/etc/httpd/ \ + --path-pattern='*.conf' \ + --ignore-empty diff --git a/provisioning/apache/general/bin/service.d/httpd.d/10-init.sh b/provisioning/apache/general/bin/service.d/httpd.d/10-init.sh index d3f1a0c9c..b9d57997e 100644 --- a/provisioning/apache/general/bin/service.d/httpd.d/10-init.sh +++ b/provisioning/apache/general/bin/service.d/httpd.d/10-init.sh @@ -5,15 +5,17 @@ if [[ ! -e "$WEB_DOCUMENT_ROOT" ]]; then fi # Replace markers -find /opt/docker/etc/httpd/ -iname '*.conf' -print0 | xargs -0 -r rpl --quiet "" "$WEB_DOCUMENT_INDEX" > /dev/null -find /opt/docker/etc/httpd/ -iname '*.conf' -print0 | xargs -0 -r rpl --quiet "" "$WEB_DOCUMENT_ROOT" > /dev/null -find /opt/docker/etc/httpd/ -iname '*.conf' -print0 | xargs -0 -r rpl --quiet "" "$WEB_ALIAS_DOMAIN" > /dev/null -find /opt/docker/etc/httpd/ -iname '*.conf' -print0 | xargs -0 -r rpl --quiet "" "$HOSTNAME" > /dev/null +go-replace \ + -s "" -r "$WEB_DOCUMENT_INDEX" \ + -s "" -r "$WEB_DOCUMENT_ROOT" \ + -s "" -r "$WEB_ALIAS_DOMAIN" \ + -s "" -r "$HOSTNAME" \ + -s "" -r "$WEB_PHP_SOCKET" \ + --path=/opt/docker/etc/httpd/ \ + --path-pattern='*.conf' \ + --ignore-empty -if [[ -n "${WEB_PHP_SOCKET+x}" ]]; then - ## WEB_PHP_SOCKET is set - find /opt/docker/etc/httpd/ -iname '*.conf' -print0 | xargs -0 -r rpl --quiet "" "$WEB_PHP_SOCKET" > /dev/null -else +if [[ -z "${WEB_PHP_SOCKET+x}" ]]; then ## WEB_PHP_SOCKET is not set, remove PHP files rm -f -- /opt/docker/etc/httpd/conf.d/10-php.conf fi diff --git a/provisioning/apache/general/etc/httpd/conf.d/10-log.conf b/provisioning/apache/general/etc/httpd/conf.d/10-log.conf index e4c4be4f2..ef0c73d38 100644 --- a/provisioning/apache/general/etc/httpd/conf.d/10-log.conf +++ b/provisioning/apache/general/etc/httpd/conf.d/10-log.conf @@ -1,4 +1,4 @@ LogFormat "[httpd:access] %V:%p %h %l %u %t \"%r\" %>s bytesIn:%I bytesOut:%O reqTime:%T" dockerlog LogLevel warn -CustomLog /proc/self/fd/1 dockerlog -ErrorLog /proc/self/fd/2 +CustomLog /docker.stdout dockerlog +ErrorLog /docker.stderr diff --git a/provisioning/apache/general/provision/roles/webdevops-apache/tasks/bootstrap.yml b/provisioning/apache/general/provision/roles/webdevops-apache/tasks/bootstrap.yml index 2be18b0e0..c285be286 100644 --- a/provisioning/apache/general/provision/roles/webdevops-apache/tasks/bootstrap.yml +++ b/provisioning/apache/general/provision/roles/webdevops-apache/tasks/bootstrap.yml @@ -84,7 +84,7 @@ with_items: - 'a2dismod mpm_event' - 'a2enmod mpm_event' - when: (ansible_distribution == 'Ubuntu' and ansible_lsb.major_release|int >= 14) or (ansible_distribution == 'Debian' and ansible_lsb.major_release|int >= 8) + when: (ansible_distribution == 'Ubuntu' and docker_image_info_distribution_version|int >= 14) or (ansible_distribution == 'Debian' and docker_image_info_distribution_version|int >= 8) - name: Manage modules [Alpine family] lineinfile: diff --git a/provisioning/base-app/general/bin/service.d/postfix.d/10-init.sh b/provisioning/base-app/general/bin/service.d/postfix.d/10-init.sh deleted file mode 100644 index 7a604874f..000000000 --- a/provisioning/base-app/general/bin/service.d/postfix.d/10-init.sh +++ /dev/null @@ -1,24 +0,0 @@ -# force new copy of hosts there (otherwise links could be outdated) -mkdir -p /var/spool/postfix/etc -cp -f /etc/hosts /var/spool/postfix/etc/hosts -cp -f /etc/resolv.conf /var/spool/postfix/etc/resolv.conf -cp -f /etc/services /var/spool/postfix/etc/services - -## MYHOSTNAME -# replace line -sed -i '/myhostname[ ]* =/c\' main.cf -echo "myhostname = $(hostname)" >> /etc/postfix/main.cf - -## REPLAYHOST -if [[ -n "${POSTFIX_RELAYHOST+x}" ]]; then - # replace line - sed -i '/relayhost[ ]* =/c\' main.cf - echo "relayhost = $POSTFIX_RELAYHOST" >> /etc/postfix/main.cf -fi - -## MYNETWORKS -if [[ -n "${POSTFIX_MYNETWORKS+x}" ]]; then - # replace line - sed -i '/mynetworks[ ]* =/c\' main.cf - echo "mynetworks = $POSTFIX_MYNETWORKS" >> /etc/postfix/main.cf -fi diff --git a/provisioning/base-app/general/bin/service.d/ssh.d/10-init.sh b/provisioning/base-app/general/bin/service.d/ssh.d/10-init.sh deleted file mode 100644 index e3192fe01..000000000 --- a/provisioning/base-app/general/bin/service.d/ssh.d/10-init.sh +++ /dev/null @@ -1,2 +0,0 @@ -# generate host keys -ssh-keygen -A diff --git a/provisioning/base-app/general/etc/supervisor.d/dnsmasq.conf b/provisioning/base-app/general/etc/supervisor.d/dnsmasq.conf deleted file mode 100644 index a0ad2de88..000000000 --- a/provisioning/base-app/general/etc/supervisor.d/dnsmasq.conf +++ /dev/null @@ -1,14 +0,0 @@ -[group:dnsmasq] -programs=dnsmasqd -priority=15 - -[program:dnsmasqd] -command = /opt/docker/bin/service.d/dnsmasq.sh -process_name=%(program_name)s -startsecs = 0 -autostart = true -autorestart = true -stdout_logfile=/dev/stdout -stdout_logfile_maxbytes=0 -stderr_logfile=/dev/stderr -stderr_logfile_maxbytes=0 diff --git a/provisioning/base-app/general/provision/roles/webdevops-base-app/tasks/bootstrap.yml b/provisioning/base-app/general/provision/roles/webdevops-base-app/tasks/bootstrap.yml index ea9e54682..3fdce9a74 100644 --- a/provisioning/base-app/general/provision/roles/webdevops-base-app/tasks/bootstrap.yml +++ b/provisioning/base-app/general/provision/roles/webdevops-base-app/tasks/bootstrap.yml @@ -2,6 +2,3 @@ - include: bootstrap/user.yml - include: bootstrap/application.yml -- include: bootstrap/dnsmasq.yml -- include: bootstrap/postfix.yml -- include: bootstrap/ssh.yml diff --git a/provisioning/base-app/general/provision/roles/webdevops-base-app/tasks/bootstrap/dnsmasq.yml b/provisioning/base-app/general/provision/roles/webdevops-base-app/tasks/bootstrap/dnsmasq.yml deleted file mode 100644 index 962a7953a..000000000 --- a/provisioning/base-app/general/provision/roles/webdevops-base-app/tasks/bootstrap/dnsmasq.yml +++ /dev/null @@ -1,10 +0,0 @@ ---- - -- name: Configure dnsmasq - lineinfile: - dest: /etc/dnsmasq.conf - regexp: '^[\s]*{{ item.key }}[\s]*=' - line: '{{ item.key }}={{ item.value }}' - with_items: - - { key: 'user', value: 'root' } - - { key: 'conf-dir', value: '/etc/dnsmasq.d' } diff --git a/provisioning/base-app/general/provision/roles/webdevops-base-app/tasks/bootstrap/postfix.yml b/provisioning/base-app/general/provision/roles/webdevops-base-app/tasks/bootstrap/postfix.yml deleted file mode 100644 index f05ff660c..000000000 --- a/provisioning/base-app/general/provision/roles/webdevops-base-app/tasks/bootstrap/postfix.yml +++ /dev/null @@ -1,29 +0,0 @@ ---- - -- name: Link aliases file to postfix aliases - file: - src: '/etc/postfix/aliases' - dest: '/etc/aliases' - state: link - force: yes - when: ansible_os_family == 'Alpine' - -- name: Configure postfix - lineinfile: - dest: /etc/postfix/main.cf - regexp: '^[\s]*{{ item.key }}[\s]*=' - line: '{{ item.key }}={{ item.value }}' - with_items: - - { key: 'mydestination', value: '' } - - { key: 'message_size_limit', value: '15240000' } - # Hardening - - { key: 'smtp_use_tls', value: 'yes' } - - { key: 'smtp_tls_security_level', value: 'may' } - -- name: Remove dynamic configuration for postfix - lineinfile: - dest: /etc/postfix/main.cf - regexp: '^[\s]*{{ item }}[\s]*=' - state: absent - with_items: - - 'myhostname' diff --git a/provisioning/base-app/general/provision/roles/webdevops-base-app/tasks/bootstrap/ssh.yml b/provisioning/base-app/general/provision/roles/webdevops-base-app/tasks/bootstrap/ssh.yml deleted file mode 100644 index a69c72633..000000000 --- a/provisioning/base-app/general/provision/roles/webdevops-base-app/tasks/bootstrap/ssh.yml +++ /dev/null @@ -1,12 +0,0 @@ ---- - -- name: Init ssh privilege separation directory - file: - path: "/var/run/sshd" - state: directory - mode: 0755 - owner: "root" - group: "root" - recurse: yes - - diff --git a/provisioning/base-app/general/provision/roles/webdevops-base-app/tasks/bootstrap/user.yml b/provisioning/base-app/general/provision/roles/webdevops-base-app/tasks/bootstrap/user.yml index cf6968a01..fd58b329f 100644 --- a/provisioning/base-app/general/provision/roles/webdevops-base-app/tasks/bootstrap/user.yml +++ b/provisioning/base-app/general/provision/roles/webdevops-base-app/tasks/bootstrap/user.yml @@ -1,11 +1,5 @@ --- -- name: Move dnsmasq group (Alpine family) - group: - name: dnsmasq - gid: 153 - when: ansible_distribution == 'Alpine' - - name: Create application group group: name: "{{ APPLICATION_GROUP }}" diff --git a/provisioning/base/alpine/etc/supervisor.conf b/provisioning/base/alpine/etc/supervisor.conf deleted file mode 100644 index 14a6223fc..000000000 --- a/provisioning/base/alpine/etc/supervisor.conf +++ /dev/null @@ -1,11 +0,0 @@ -[supervisord] -nodaemon=true - -[unix_http_server] -file = /run/supervisord.sock - -[rpcinterface:supervisor] -supervisor.rpcinterface_factory = supervisor.rpcinterface:make_main_rpcinterface - -[include] -files = /opt/docker/etc/supervisor.d/*.conf diff --git a/provisioning/base/centos/etc/logrotate.d/syslog b/provisioning/base/centos/etc/logrotate.d/syslog deleted file mode 100644 index 4597c7b48..000000000 --- a/provisioning/base/centos/etc/logrotate.d/syslog +++ /dev/null @@ -1 +0,0 @@ -# placeholder -> overwrite system default \ No newline at end of file diff --git a/provisioning/base/centos/etc/supervisor.conf b/provisioning/base/centos/etc/supervisor.conf deleted file mode 100644 index 440721076..000000000 --- a/provisioning/base/centos/etc/supervisor.conf +++ /dev/null @@ -1,11 +0,0 @@ -[supervisord] -nodaemon=true - -[unix_http_server] -file = /var/run/supervisor/supervisor.sock - -[rpcinterface:supervisor] -supervisor.rpcinterface_factory = supervisor.rpcinterface:make_main_rpcinterface - -[include] -files = /opt/docker/etc/supervisor.d/*.conf diff --git a/provisioning/base/general/bin/bootstrap.sh b/provisioning/base/general/bin/bootstrap.sh index 1d1a30f72..855c10782 100644 --- a/provisioning/base/general/bin/bootstrap.sh +++ b/provisioning/base/general/bin/bootstrap.sh @@ -17,10 +17,16 @@ rootCheck "$0" # Save the buildtime date +%s > /opt/docker/BUILDTIME +date +%s >/opt/docker/etc/.registry/image_info_buildtime # Make all scripts executable find /opt/docker/bin/ -type f -iname '*.sh' -print0 | xargs --no-run-if-empty -0 chmod +x +# Enable usr-bin executables +find /opt/docker/bin/usr-bin -type f | while read USR_BIN_FILE; do + chmod +x -- "$USR_BIN_FILE" + ln -n -f -- "$USR_BIN_FILE" "/usr/local/bin/$(basename "$USR_BIN_FILE")" +done case "$BOOTSTRAP_MODE" in ################################### @@ -44,6 +50,23 @@ case "$BOOTSTRAP_MODE" in echo "[ERROR] Bootstrap mode '$BOOTSTRAP_MODE' not defined" exit 1 ;; - esac + +###################### +# Check if entrypoint provisioning is available +###################### + +echo "Checking provision status..." +for PROVISION_TAG in onbuild build bootstrap entrypoint; do + ROLES=$(docker-provision list --tag "$PROVISION_TAG") + if [[ -n "$ROLES" ]]; then + PROVISION_ROLE_COUNT=$(echo "$ROLES" | wc -l) + echo " - found ${PROVISION_ROLE_COUNT} for provision tag ${PROVISION_TAG}, caching info for execution" + echo -n "$PROVISION_ROLE_COUNT" > "/opt/docker/etc/.registry/provision-availale.${PROVISION_TAG}" + else + echo " - no roles found for provision tag ${PROVISION_TAG}" + echo -n '' > "/opt/docker/etc/.registry/provision-availale.${PROVISION_TAG}" + fi +done + diff --git a/provisioning/base/general/bin/config.sh b/provisioning/base/general/bin/config.sh index 3155728e8..049756c26 100644 --- a/provisioning/base/general/bin/config.sh +++ b/provisioning/base/general/bin/config.sh @@ -15,44 +15,23 @@ function rootCheck() { } ### - # Create named pipe - # - # $1 -> name of file + # Create /docker.stdout and /docker.stderr # ## -function createNamedPipe() { - rm --force -- "$1" - mknod "$1" p -} - -### - # Escape value for sed usage - # - # $1 -> value - # STDOUT -> escaped value - # - ## -function sedEscape() { - echo "$(echo $* |sed -e 's/[]\/$*.^|[]/\\&/g')" -} +function createDockerStdoutStderr() { + # link stdout from docker + if [[ -z "$LOG_STDOUT" ]]; then + LOG_STDOUT="/proc/$$/fd/1" + fi -### - # Replace text inside a file - # - # $1 -> source value - # $2 -> target value - # $3 -> path to file - # - ## -function replaceTextInFile() { - SOURCE="$(sedEscape $1)" - REPLACE="$(sedEscape $2)" - TARGET="$3" + if [[ -z "$LOG_STDERR" ]]; then + LOG_STDERR="/proc/$$/fd/2" + fi - sed -i "s/${SOURCE}/${REPLACE}/" "${TARGET}" + ln -f -s "$LOG_STDOUT" /docker.stdout + ln -f -s "$LOG_STDERR" /docker.stderr + chmod 600 /docker.stdout /docker.stderr } - - ### # Include script directory text inside a file # @@ -104,7 +83,7 @@ function runEntrypoints() { . /opt/docker/bin/entrypoint.d/default.sh fi - exit + exit 1 } ### @@ -161,6 +140,12 @@ function runProvisionEntrypoint() { function runDockerProvision() { ANSIBLE_TAG="$1" - /opt/docker/bin/provision run --tag "$ANSIBLE_TAG" --use-registry + PROVISION_STATS_FILE="/opt/docker/etc/.registry/provision-stats.${ANSIBLE_TAG}" + + # run provision if stats file doesn't exists (unknown mode) + # or if stats file is not empty + if [[ ! -f "$PROVISION_STATS_FILE" ]] || [[ -s "$PROVISION_STATS_FILE" ]]; then + /opt/docker/bin/provision run --tag "${ANSIBLE_TAG}" --use-registry + fi } diff --git a/provisioning/base/general/bin/control.sh b/provisioning/base/general/bin/control.sh index a6697092d..22d189745 100644 --- a/provisioning/base/general/bin/control.sh +++ b/provisioning/base/general/bin/control.sh @@ -101,23 +101,13 @@ case "$CONTROL_COMMAND" in ## ------------------------------------------ "service.enable") - SERVICE_FILE="/opt/docker/etc/supervisor.d/$1.conf" - if [ -f "$SERVICE_FILE" ]; then - sed -i '/autostart = /c\autostart = true' -- "$SERVICE_FILE" - else - echo "[ERROR] Service '${1}' not found (tried ${SERVICE_FILE})" - exit 1 - fi + deprecationNotice " Please use >>docker-service-enable [service]<<" + docker-service-enable "$1" ;; "service.disable") - SERVICE_FILE="/opt/docker/etc/supervisor.d/$1.conf" - if [ -f "$SERVICE_FILE" ]; then - sed -i '/autostart = /c\autostart = false' -- "$SERVICE_FILE" - else - echo "[ERROR] Service '${1}' not found (tried ${SERVICE_FILE})" - exit 1 - fi + deprecationNotice " Please use >>docker-service-disable [service]<<" + docker-service-disable "$1" ;; ## ------------------------------------------ diff --git a/provisioning/base/general/bin/entrypoint.d/cli.sh b/provisioning/base/general/bin/entrypoint.d/cli.sh index 2ca68926c..fe212a8ea 100644 --- a/provisioning/base/general/bin/entrypoint.d/cli.sh +++ b/provisioning/base/general/bin/entrypoint.d/cli.sh @@ -8,7 +8,7 @@ if [ -n "${CLI_SCRIPT}" ]; then if [ -n "$APPLICATION_USER" ]; then # Run as EFFECTIVE_USER shift - exec sudo -H -E -u "${APPLICATION_USER}" ${CLI_SCRIPT} "$@" + exec gosu "${APPLICATION_USER}" ${CLI_SCRIPT} "$@" else # Run as root exec ${CLI_SCRIPT} "$@" diff --git a/provisioning/base/general/bin/entrypoint.d/noop.sh b/provisioning/base/general/bin/entrypoint.d/noop.sh index 967920837..092d55d8b 100644 --- a/provisioning/base/general/bin/entrypoint.d/noop.sh +++ b/provisioning/base/general/bin/entrypoint.d/noop.sh @@ -4,5 +4,4 @@ ## NOOP (no operation) ############################################# -tail -f /dev/null -exit +exec tail -f /dev/null diff --git a/provisioning/base/general/bin/entrypoint.d/supervisord.sh b/provisioning/base/general/bin/entrypoint.d/supervisord.sh index ead991551..f21489667 100644 --- a/provisioning/base/general/bin/entrypoint.d/supervisord.sh +++ b/provisioning/base/general/bin/entrypoint.d/supervisord.sh @@ -4,8 +4,6 @@ ## Supervisord (start daemons) ############################################# -rootCheck "supervisord" - ## Start services exec /opt/docker/bin/service.d/supervisor.sh diff --git a/provisioning/base/general/bin/entrypoint.sh b/provisioning/base/general/bin/entrypoint.sh index bbabcdddb..01f59660c 100644 --- a/provisioning/base/general/bin/entrypoint.sh +++ b/provisioning/base/general/bin/entrypoint.sh @@ -20,16 +20,13 @@ chmod -s /usr/local/bin/gosu trap 'echo sigterm ; exit' SIGTERM trap 'echo sigkill ; exit' SIGKILL -# link stdout from docker -ln -f -s "/proc/$$/fd/1" /docker.stdout -ln -f -s "/proc/$$/fd/2" /docker.stderr -chmod 600 /docker.stdout /docker.stderr - # sanitize input and set task TASK="$(echo $1| sed 's/[^-_a-zA-Z0-9]*//g')" source /opt/docker/bin/config.sh +createDockerStdoutStderr + if [[ "$UID" -eq 0 ]]; then # Only run provision if user is root diff --git a/provisioning/base/general/bin/logwatch.sh b/provisioning/base/general/bin/logwatch.sh deleted file mode 100644 index 1a5b486c7..000000000 --- a/provisioning/base/general/bin/logwatch.sh +++ /dev/null @@ -1,14 +0,0 @@ -#!/usr/bin/env bash - -set -o pipefail # trace ERR through pipes -set -o errtrace # trace ERR through 'time command' and other functions -set -o nounset ## set -u : exit the script if you try to use an uninitialised variable -set -o errexit ## set -e : exit the script if any statement returns a non-true return value - -sleep 0.5 - -if [ -p "$2" ]; then - sed --unbuffered -e "s/^/\[$1\] /" -- "$2" -else - tail -n 0 -F -q "$2" | sed --unbuffered -e "s/^/\[$1\] /" -fi diff --git a/provisioning/base/general/bin/provision b/provisioning/base/general/bin/provision index f7b5ad0a8..d367c2812 100755 --- a/provisioning/base/general/bin/provision +++ b/provisioning/base/general/bin/provision @@ -19,6 +19,7 @@ PLAYBOOK = Template( - hosts: all vars_files: + - ./variables-webdevops.yml - ./variables.yml roles: - $roles @@ -188,7 +189,7 @@ def actionAdd(args): 'priority': args.priority } - saveJson(json); + saveJson(json) diff --git a/provisioning/base/general/bin/provision.sh b/provisioning/base/general/bin/provision.sh deleted file mode 100644 index 4079dd7f0..000000000 --- a/provisioning/base/general/bin/provision.sh +++ /dev/null @@ -1,30 +0,0 @@ - #!/usr/bin/env bash - -# -# Example: -# provision.sh /opt/foobar/playbook.yml tag -# -# - -set -o pipefail # trace ERR through pipes -set -o errtrace # trace ERR through 'time command' and other functions -set -o nounset ## set -u : exit the script if you try to use an uninitialised variable -set -o errexit ## set -e : exit the script if any statement returns a non-true return value - -. config.sh - -deprecationNotice " Please use >>/opt/docker/bin/provision run --playbook playbook.yml --tag=bootstrap [args]<< for running provision" - - -if [ "$#" -lt 2 ]; then - echo "[ERROR] $0: Playbook or tag is missing" - exit 1 -fi - -ANSIBLE_PLAYBOOK="$1" -shift -ANSIBLE_TAG="$1" -shift -ANSIBLE_OPTS="$@" - -/opt/docker/bin/provision run --playbook "${ANSIBLE_PLAYBOOK}" --use-registry --tag "${ANSIBLE_TAG}" $ANSIBLE_OPTS diff --git a/provisioning/base/general/bin/service.d/dnsmasq.d/10-init.sh b/provisioning/base/general/bin/service.d/dnsmasq.d/10-init.sh new file mode 100644 index 000000000..03baba08f --- /dev/null +++ b/provisioning/base/general/bin/service.d/dnsmasq.d/10-init.sh @@ -0,0 +1,32 @@ +# Create dnsmasq.d directory if not exists +mkdir -p -- /etc/dnsmasq.d/ + +## clear dns file +echo > /etc/dnsmasq.d/webdevops + +if [ ! -f /etc/resolv.conf.original ]; then + cp -a /etc/resolv.conf /etc/resolv.conf.original + + ## set forward servers + cat /etc/resolv.conf.original | grep nameserver | sed 's/nameserver /server=/' > /etc/dnsmasq.d/forward + + ## set dnsmasq to main nameserver + echo "nameserver 127.0.0.1" > /etc/resolv.conf +fi + + +# Add own VIRTUAL_HOST as loopback +if [[ -n "${VIRTUAL_HOST+x}" ]]; then + # split comma by space + VIRTUAL_HOST_LIST=${VIRTUAL_HOST//,/$'\n'} + + # replace *.domain for dns specific .domain wildcard + VIRTUAL_HOST_LIST=${VIRTUAL_HOST_LIST/\*./.} + + # no support for .* + VIRTUAL_HOST_LIST=${VIRTUAL_HOST_LIST/.\*/.} + + for DOMAIN in $VIRTUAL_HOST_LIST; do + echo "address=/${DOMAIN}/127.0.0.1" >> /etc/dnsmasq.d/webdevops + done +fi diff --git a/provisioning/base/general/bin/service.d/dnsmasq.sh b/provisioning/base/general/bin/service.d/dnsmasq.sh new file mode 100644 index 000000000..d16b1acbc --- /dev/null +++ b/provisioning/base/general/bin/service.d/dnsmasq.sh @@ -0,0 +1,7 @@ +#!/usr/bin/env bash + +source /opt/docker/bin/config.sh + +includeScriptDir "/opt/docker/bin/service.d/dnsmasq.d/" + +exec dnsmasq --keep-in-foreground diff --git a/provisioning/base/general/bin/service.d/postfix.d/10-init.sh b/provisioning/base/general/bin/service.d/postfix.d/10-init.sh new file mode 100644 index 000000000..cfd876955 --- /dev/null +++ b/provisioning/base/general/bin/service.d/postfix.d/10-init.sh @@ -0,0 +1,27 @@ +# force new copy of hosts there (otherwise links could be outdated) +mkdir -p /var/spool/postfix/etc +cp -f /etc/hosts /var/spool/postfix/etc/hosts +cp -f /etc/resolv.conf /var/spool/postfix/etc/resolv.conf +cp -f /etc/services /var/spool/postfix/etc/services + +## MYHOSTNAME +# replace line +sed -i '/myhostname[ ]* =/c\' main.cf +echo "myhostname = $(hostname)" >> /etc/postfix/main.cf + +## REPLAYHOST +if [[ -n "${POSTFIX_RELAYHOST+x}" ]]; then + # replace line + sed -i '/relayhost[ ]* =/c\' main.cf + echo "relayhost = $POSTFIX_RELAYHOST" >> /etc/postfix/main.cf +fi + +## MYNETWORKS +if [[ -n "${POSTFIX_MYNETWORKS+x}" ]]; then + # replace line + sed -i '/mynetworks[ ]* =/c\' main.cf + echo "mynetworks = $POSTFIX_MYNETWORKS" >> /etc/postfix/main.cf +fi + +# generate aliases db +newaliases || : diff --git a/provisioning/base/general/bin/service.d/postfix.sh b/provisioning/base/general/bin/service.d/postfix.sh new file mode 100644 index 000000000..3ab608679 --- /dev/null +++ b/provisioning/base/general/bin/service.d/postfix.sh @@ -0,0 +1,37 @@ +#!/usr/bin/env bash +# postfix-wrapper.sh, version 0.1.0 +# +# You cannot start postfix in some foreground mode and +# it's more or less important that docker doesn't kill +# postfix and its chilren if you stop the container. +# +# Use this script with supervisord and it will take +# care about starting and stopping postfix correctly. +# +# supervisord config snippet for postfix-wrapper: +# +# [program:postfix] +# process_name = postfix +# command = /path/to/postfix-wrapper.sh +# startsecs = 0 +# autorestart = false +# + +source /opt/docker/bin/config.sh + +trap "postfix stop" SIGINT +trap "postfix stop" SIGTERM +trap "postfix reload" SIGHUP + +includeScriptDir "/opt/docker/bin/service.d/postfix.d/" + +# start postfix +postfix start + +# lets give postfix some time to start +sleep 3 + +# wait until postfix is dead (triggered by trap) +while kill -0 "$(cat /var/spool/postfix/pid/master.pid)"; do + sleep 5 +done diff --git a/provisioning/base/general/bin/service.d/ssh.d/10-init.sh b/provisioning/base/general/bin/service.d/ssh.d/10-init.sh new file mode 100644 index 000000000..f2b600312 --- /dev/null +++ b/provisioning/base/general/bin/service.d/ssh.d/10-init.sh @@ -0,0 +1,7 @@ +# Init ssh privilege separation directory +mkdir -p /var/run/sshd +chown root:root /var/run/sshd +chmod 755 /var/run/sshd + +# generate host keys +ssh-keygen -A diff --git a/provisioning/base/general/bin/service.d/ssh.sh b/provisioning/base/general/bin/service.d/ssh.sh new file mode 100644 index 000000000..ad855563f --- /dev/null +++ b/provisioning/base/general/bin/service.d/ssh.sh @@ -0,0 +1,7 @@ +#!/usr/bin/env bash + +source /opt/docker/bin/config.sh + +includeScriptDir "/opt/docker/bin/service.d/ssh.d/" + +exec /usr/sbin/sshd -D diff --git a/provisioning/base/general/bin/service.d/syslog-ng.d/10-init.sh b/provisioning/base/general/bin/service.d/syslog-ng.d/10-init.sh index 22621d2ad..326207e52 100644 --- a/provisioning/base/general/bin/service.d/syslog-ng.d/10-init.sh +++ b/provisioning/base/general/bin/service.d/syslog-ng.d/10-init.sh @@ -6,5 +6,5 @@ if [ ! -S /var/lib/syslog-ng/syslog-ng.ctl ]; then rm -f /var/lib/syslog-ng/sysl if [[ ! -p /docker.stdout ]]; then # Switch to file (tty docker mode) - rpl --quiet 'pipe("/docker.stdout")' 'file("/docker.stdout")' -- /opt/docker/etc/syslog-ng/syslog-ng.conf > /dev/null + go-replace -s 'pipe("/docker.stdout")' -r 'file("/docker.stdout")' -- /opt/docker/etc/syslog-ng/syslog-ng.conf fi diff --git a/provisioning/base/general/bin/usr-bin/docker-provision b/provisioning/base/general/bin/usr-bin/docker-provision new file mode 100644 index 000000000..4ee715c64 --- /dev/null +++ b/provisioning/base/general/bin/usr-bin/docker-provision @@ -0,0 +1,9 @@ +#!/usr/bin/env bash + +set -o pipefail # trace ERR through pipes +set -o errtrace # trace ERR through 'time command' and other functions +set -o nounset ## set -u : exit the script if you try to use an uninitialised variable +set -o errexit ## set -e : exit the script if any statement returns a non-true return value + +# wrapper +exec /opt/docker/bin/provision "$@" diff --git a/provisioning/base/general/bin/usr-bin/docker-service-disable b/provisioning/base/general/bin/usr-bin/docker-service-disable new file mode 100644 index 000000000..2b5b31bb4 --- /dev/null +++ b/provisioning/base/general/bin/usr-bin/docker-service-disable @@ -0,0 +1,30 @@ +#!/usr/bin/env bash + +set -o pipefail # trace ERR through pipes +set -o errtrace # trace ERR through 'time command' and other functions +set -o nounset ## set -u : exit the script if you try to use an uninitialised variable +set -o errexit ## set -e : exit the script if any statement returns a non-true return value + +source /opt/docker/bin/config.sh + +rootCheck "$0" + +if [[ "$#" -eq 0 ]]; then + echo "Usage: $0 " + exit 1 +fi + +for SERVICE in "$@"; do + SERVICE_FILE="/opt/docker/etc/supervisor.d/${SERVICE}.conf" + + ## Disable service + if [[ -f "$SERVICE_FILE" ]]; then + go-replace --mode=lineinfile \ + -s 'autostart =' -r 'autostart = false' \ + -- "$SERVICE_FILE" + else + echo "[ERROR] Service '${SERVICE}' not found (tried ${SERVICE_FILE})" + exit 1 + fi +done + diff --git a/provisioning/base/general/bin/usr-bin/docker-service-enable b/provisioning/base/general/bin/usr-bin/docker-service-enable new file mode 100644 index 000000000..8d36a14a9 --- /dev/null +++ b/provisioning/base/general/bin/usr-bin/docker-service-enable @@ -0,0 +1,41 @@ +#!/usr/bin/env bash + +set -o pipefail # trace ERR through pipes +set -o errtrace # trace ERR through 'time command' and other functions +set -o nounset ## set -u : exit the script if you try to use an uninitialised variable +set -o errexit ## set -e : exit the script if any statement returns a non-true return value + +source /opt/docker/bin/config.sh + +rootCheck "$0" + +if [[ "$#" -eq 0 ]]; then + echo "Usage: $0 " + exit 1 +fi + +for SERVICE in "$@"; do + SERVICE_FILE="/opt/docker/etc/supervisor.d/${SERVICE}.conf" + PROVISION_FILE="/opt/docker/provision/service.d/${SERVICE}.sh" + + # Run on demand installation/provisioning + if [[ -f "$PROVISION_FILE" ]]; then + echo "Running provisioning for ${SERVICE}, please wait..." + + ## execute scripts + . "$PROVISION_FILE" + + ## remove directory (one run time) + rm -f -- "$PROVISION_FILE" + fi + + ## Enable service + if [[ -f "$SERVICE_FILE" ]]; then + go-replace --mode=lineinfile \ + -s 'autostart =' -r 'autostart = true' \ + -- "$SERVICE_FILE" + else + echo "[ERROR] Service '${SERVICE}' not found (tried ${SERVICE_FILE})" + exit 1 + fi +done diff --git a/provisioning/base/general/bin/usr-bin/service b/provisioning/base/general/bin/usr-bin/service new file mode 100755 index 000000000..55ea12bf7 --- /dev/null +++ b/provisioning/base/general/bin/usr-bin/service @@ -0,0 +1,86 @@ +#!/bin/bash + +set -o pipefail # trace ERR through pipes +set -o errtrace # trace ERR through 'time command' and other functions +set -o nounset ## set -u : exit the script if you try to use an uninitialised variable +set -o errexit ## set -e : exit the script if any statement returns a non-true return value + +# Root check +if [ "$(/usr/bin/whoami)" != "root" ]; then + echo "[ERROR] Must be run as root" + exit 1 +fi + +function serviceHelp() { + echo "Usage: $(basename "$0") " +} + +function getServicePid() { + local serviceName="$1" + local servicePid=$(supervisorctl pid "${serviceName}:${serviceName}d") + + if [[ -z "$servicePid" ]] || [[ "$servicePid" == "0" ]]; then + echo "not running" + exit 1 + fi + + echo $servicePid +} + +# Param check +if [ "$#" -lt 2 ]; then + echo "[ERROR] Missing parameters" + serviceHelp + exit 1 +fi + +############################# +# Param init +############################# + +SERVICENAME="$1" +ACTION="$2" + +############################# +# Service aliases +############################# +case "$SERVICENAME" in + apache2|httpd) + SERVICENAME="apache" + ;; +esac + +############################# +# Action runner +############################# +case "$ACTION" in + stop|start|restart|status) + exec supervisorctl "$ACTION" "${SERVICENAME}:${SERVICENAME}d" + ;; + + pid) + echo $(getServicePid "${SERVICENAME}") + ;; + + check) + FIRST_PID=$(getServicePid "${SERVICENAME}") + sleep 5 + SECOND_PID=$(getServicePid "${SERVICENAME}") + + if [[ "$FIRST_PID" == "$SECOND_PID" ]]; then + echo "ok" + exit 0 + else + echo "not running" + exit 1 + fi + ;; + + + *) + echo "[ERROR] Invalid action" + serviceHelp + exit 1 + ;; + +esac diff --git a/provisioning/base/general/etc/supervisor.conf b/provisioning/base/general/etc/supervisor.conf index 7c109515a..479e0db08 100644 --- a/provisioning/base/general/etc/supervisor.conf +++ b/provisioning/base/general/etc/supervisor.conf @@ -2,9 +2,16 @@ nodaemon=true [unix_http_server] -file = /var/run/supervisor.sock -# username = root -# password = {SHA}e982f17bcbe0f724063b708a4f76db211a999304 +file = /.supervisor.sock +chmod = 0700 +chown = root:root +username = root +password = {SHA}e982f17bcbe0f724063b708a4f76db211a999304 + +[supervisorctl] +serverurl = unix:///.supervisor.sock +username = root +password = docker [rpcinterface:supervisor] supervisor.rpcinterface_factory = supervisor.rpcinterface:make_main_rpcinterface diff --git a/provisioning/base/general/etc/supervisor.d/dnsmasq.conf b/provisioning/base/general/etc/supervisor.d/dnsmasq.conf new file mode 100644 index 000000000..9832ffca7 --- /dev/null +++ b/provisioning/base/general/etc/supervisor.d/dnsmasq.conf @@ -0,0 +1,14 @@ +[group:dnsmasq] +programs=dnsmasqd +priority=15 + +[program:dnsmasqd] +command = /opt/docker/bin/service.d/dnsmasq.sh +process_name=%(program_name)s +startsecs = 0 +autostart = false +autorestart = true +stdout_logfile=/dev/stdout +stdout_logfile_maxbytes=0 +stderr_logfile=/dev/stderr +stderr_logfile_maxbytes=0 diff --git a/provisioning/base/general/etc/supervisor.d/postfix.conf b/provisioning/base/general/etc/supervisor.d/postfix.conf new file mode 100644 index 000000000..b8d70bb40 --- /dev/null +++ b/provisioning/base/general/etc/supervisor.d/postfix.conf @@ -0,0 +1,15 @@ +[group:postfix] +programs=postfixd +priority=30 + +[program:postfixd] +directory = /etc/postfix +command = /opt/docker/bin/service.d/postfix.sh +process_name=%(program_name)s +startsecs = 0 +autostart = false +autorestart = true +stdout_logfile=/dev/stdout +stdout_logfile_maxbytes=0 +stderr_logfile=/dev/stderr +stderr_logfile_maxbytes=0 diff --git a/provisioning/base/general/etc/supervisor.d/ssh.conf b/provisioning/base/general/etc/supervisor.d/ssh.conf new file mode 100644 index 000000000..0ecd798d6 --- /dev/null +++ b/provisioning/base/general/etc/supervisor.d/ssh.conf @@ -0,0 +1,14 @@ +[group:ssh] +programs=sshd +priority=30 + +[program:sshd] +command = /opt/docker/bin/service.d/ssh.sh +process_name=%(program_name)s +startsecs=0 +autostart = false +autorestart = true +stdout_logfile=/dev/stdout +stdout_logfile_maxbytes=0 +stderr_logfile=/dev/stderr +stderr_logfile_maxbytes=0 diff --git a/provisioning/base/general/etc/supervisor.d/syslog-ng.conf b/provisioning/base/general/etc/supervisor.d/syslog-ng.conf deleted file mode 100644 index 247fd1a25..000000000 --- a/provisioning/base/general/etc/supervisor.d/syslog-ng.conf +++ /dev/null @@ -1,13 +0,0 @@ -[group:syslog] -programs=syslogd -priority=10 - -[program:syslogd] -command = /opt/docker/bin/service.d/syslog-ng.sh -process_name=%(program_name)s -autostart = true -autorestart = true -stdout_logfile=/dev/stdout -stdout_logfile_maxbytes=0 -stderr_logfile=/dev/stderr -stderr_logfile_maxbytes=0 diff --git a/provisioning/base/general/etc/supervisor.d/syslog.conf b/provisioning/base/general/etc/supervisor.d/syslog.conf new file mode 100644 index 000000000..20d1e238c --- /dev/null +++ b/provisioning/base/general/etc/supervisor.d/syslog.conf @@ -0,0 +1,13 @@ +[group:syslog] +programs=syslogd +priority=10 + +[program:syslogd] +command = /opt/docker/bin/service.d/syslog-ng.sh +process_name=%(program_name)s +autostart = false +autorestart = true +stdout_logfile=/dev/stdout +stdout_logfile_maxbytes=0 +stderr_logfile=/dev/stderr +stderr_logfile_maxbytes=0 diff --git a/provisioning/base/general/provision/roles/webdevops-base/tasks/bootstrap.yml b/provisioning/base/general/provision/roles/webdevops-base/tasks/bootstrap.yml index 30be03c38..9f842336c 100644 --- a/provisioning/base/general/provision/roles/webdevops-base/tasks/bootstrap.yml +++ b/provisioning/base/general/provision/roles/webdevops-base/tasks/bootstrap.yml @@ -4,6 +4,5 @@ - include: bootstrap/misc.yml - include: bootstrap/root.yml - include: bootstrap/supervisor.yml -- include: bootstrap/syslog-ng.yml -- include: bootstrap/logrotate.yml - include: bootstrap/pam.yml +- include: bootstrap/entrypoint.yml diff --git a/provisioning/base/general/provision/roles/webdevops-base/tasks/bootstrap/entrypoint.yml b/provisioning/base/general/provision/roles/webdevops-base/tasks/bootstrap/entrypoint.yml new file mode 100644 index 000000000..d5d8809f4 --- /dev/null +++ b/provisioning/base/general/provision/roles/webdevops-base/tasks/bootstrap/entrypoint.yml @@ -0,0 +1,8 @@ +--- + +- name: Create link for entrypoint + file: + src: '/opt/docker/bin/entrypoint.sh' + dest: '/entrypoint' + state: link + force: yes diff --git a/provisioning/base/general/provision/roles/webdevops-base/tasks/bootstrap/logrotate.yml b/provisioning/base/general/provision/roles/webdevops-base/tasks/bootstrap/logrotate.yml deleted file mode 100644 index d87926be2..000000000 --- a/provisioning/base/general/provision/roles/webdevops-base/tasks/bootstrap/logrotate.yml +++ /dev/null @@ -1,33 +0,0 @@ ---- - -- name: Configure logrotate running user - lineinfile: - dest: /etc/logrotate.conf - regexp: '^su [-_a-zA-Z0-9]+ [-_a-zA-Z0-9]+' - line: 'su root adm' - -- name: Register logrotate configurations - file: - src: '{{ item }}' - dest: '/etc/logrotate.d/{{ item | basename }}' - state: link - force: yes - with_fileglob: - - /opt/docker/etc/logrotate.d/* - -- name: Remove system logrotates (not needed) - file: - path: '{{ item }}' - state: absent - with_items: - # Debian/Ubuntu - - /etc/cron.daily/logrotate - - /etc/cron.daily/apt-compat - - /etc/cron.daily/dpkg - - /etc/cron.daily/passwd - # RedHat - - /etc/cron.daily/0yum-daily.cron - - /etc/cron.daily/logrotate - - /etc/cron.hourly/0yum-hourly.cron - # Alpine - - /etc/periodic/daily/logrotate diff --git a/provisioning/base/general/provision/roles/webdevops-base/tasks/bootstrap/supervisor.yml b/provisioning/base/general/provision/roles/webdevops-base/tasks/bootstrap/supervisor.yml index bda0394b6..2ce07ac26 100644 --- a/provisioning/base/general/provision/roles/webdevops-base/tasks/bootstrap/supervisor.yml +++ b/provisioning/base/general/provision/roles/webdevops-base/tasks/bootstrap/supervisor.yml @@ -4,3 +4,10 @@ file: path: '/usr/sbin/service' state: absent + +- name: Create link for supervisor.conf + file: + src: '/opt/docker/etc/supervisor.conf' + dest: '/etc/supervisord.conf' + state: link + force: yes diff --git a/provisioning/base/general/provision/roles/webdevops-base/tasks/bootstrap/syslog-ng.yml b/provisioning/base/general/provision/roles/webdevops-base/tasks/bootstrap/syslog-ng.yml deleted file mode 100644 index 27c8f6a30..000000000 --- a/provisioning/base/general/provision/roles/webdevops-base/tasks/bootstrap/syslog-ng.yml +++ /dev/null @@ -1,33 +0,0 @@ ---- - -- name: Get syslog-ng version - shell: "syslog-ng --version | grep -E -e '^syslog-ng[ ]+[0-9]+\\.[0-9]+' | head -n 1 | awk '{print $2}' | cut -f 1,2 -d ." - register: syslogng_version - -- name: Configure syslog-ng (default) - lineinfile: - dest: /etc/default/syslog-ng - regexp: '^[\s]*{{ item.key }}[\s]*=' - line: '{{ item.key }}="{{ item.value }}"' - create: yes - with_items: - - { key: 'SYSLOGNG_OPTS', value: '--no-caps' } - -- name: Enable syslog-ng config - file: - src: '/opt/docker/etc/syslog-ng/syslog-ng.conf' - dest: '/etc/syslog-ng/syslog-ng.conf' - state: link - force: yes - -- name: Set version of syslog-ng file - lineinfile: - dest: '/etc/syslog-ng/syslog-ng.conf' - regexp: '^@version:' - line: '@version: {{ syslogng_version.stdout }}' - -- name: Ensure /var/lib/syslog-ng exists - file: - path: '/var/lib/syslog-ng' - state: directory - recurse: yes diff --git a/provisioning/base/general/provision/roles/webdevops-base/tasks/bootstrap/system.yml b/provisioning/base/general/provision/roles/webdevops-base/tasks/bootstrap/system.yml index 8dfbf9665..0741d7cae 100644 --- a/provisioning/base/general/provision/roles/webdevops-base/tasks/bootstrap/system.yml +++ b/provisioning/base/general/provision/roles/webdevops-base/tasks/bootstrap/system.yml @@ -14,3 +14,20 @@ dest: '/entrypoint.cmd' state: link force: yes + +- name: Remove system logrotate and cronjobs (not needed) + file: + path: '{{ item }}' + state: absent + with_items: + # Debian/Ubuntu + - /etc/cron.daily/logrotate + - /etc/cron.daily/apt-compat + - /etc/cron.daily/dpkg + - /etc/cron.daily/passwd + # RedHat + - /etc/cron.daily/0yum-daily.cron + - /etc/cron.daily/logrotate + - /etc/cron.hourly/0yum-hourly.cron + # Alpine + - /etc/periodic/daily/logrotate diff --git a/provisioning/base/general/provision/roles/webdevops-base/tasks/build/.gitkeep b/provisioning/base/general/provision/roles/webdevops-base/tasks/build/.gitkeep new file mode 100644 index 000000000..e69de29bb diff --git a/provisioning/base/general/provision/roles/webdevops-base/tasks/build/logrotate.yml b/provisioning/base/general/provision/roles/webdevops-base/tasks/build/logrotate.yml deleted file mode 100644 index 10f7e6644..000000000 --- a/provisioning/base/general/provision/roles/webdevops-base/tasks/build/logrotate.yml +++ /dev/null @@ -1,10 +0,0 @@ ---- - -- name: Register logrotate configurations - file: - src: '{{ item }}' - dest: '/etc/logrotate.d/{{ item | basename }}' - state: link - force: yes - with_fileglob: - - /opt/docker/etc/logrotate.d/* diff --git a/provisioning/base/general/provision/service.d/.gitkeep b/provisioning/base/general/provision/service.d/.gitkeep new file mode 100644 index 000000000..e69de29bb diff --git a/provisioning/base/general/provision/service.d/cron.sh b/provisioning/base/general/provision/service.d/cron.sh new file mode 100644 index 000000000..bd8a54781 --- /dev/null +++ b/provisioning/base/general/provision/service.d/cron.sh @@ -0,0 +1,13 @@ +#!/usr/bin/env bash + +IMAGE_FAMILY=$(docker-image-info family) + +case "$IMAGE_FAMILY" in + Debian|Ubuntu) + apt-install cron + ;; + + RedHat) + yum-install cronie + ;; +esac diff --git a/provisioning/base/general/provision/service.d/dnsmasq.sh b/provisioning/base/general/provision/service.d/dnsmasq.sh new file mode 100644 index 000000000..9e5c3228c --- /dev/null +++ b/provisioning/base/general/provision/service.d/dnsmasq.sh @@ -0,0 +1,24 @@ +#!/usr/bin/env bash + +IMAGE_FAMILY=$(docker-image-info family) + +# Installation +case "$IMAGE_FAMILY" in + Debian|Ubuntu) + apt-install dnsmasq + ;; + + RedHat) + yum-install dnsmasq + ;; + + Alpine) + apk-install dnsmasq + ;; +esac + +# Configuration +go-replace --mode=line \ + -s '^[\s]*user[\s]*=' -r 'user = root' \ + -s '^[\s]*conf-dir[\s]*=' -r 'conf-dir = /etc/dnsmasq.d' \ + -- /etc/dnsmasq.conf diff --git a/provisioning/base/general/provision/service.d/postfix.sh b/provisioning/base/general/provision/service.d/postfix.sh new file mode 100644 index 000000000..ff1879345 --- /dev/null +++ b/provisioning/base/general/provision/service.d/postfix.sh @@ -0,0 +1,28 @@ +#!/usr/bin/env bash + +IMAGE_FAMILY=$(docker-image-info family) + +# Installation +case "$IMAGE_FAMILY" in + Debian|Ubuntu) + apt-install postfix + ;; + + RedHat) + yum-install postfix + ;; + + Alpine) + apk-install postfix + ln -s -f /etc/postfix/aliases /etc/aliases + ;; +esac + +# Configuration +go-replace --mode=line \ + -s '^[\s]*mydestination[\s]*=' -r 'mydestination = ' \ + -s '^[\s]*message_size_limit[\s]*=' -r 'message_size_limit = 15240000' \ + -s '^[\s]*smtp_use_tls[\s]*=' -r 'smtp_use_tls = yes' \ + -s '^[\s]*smtp_tls_security_level[\s]*=' -r 'smtp_tls_security_level = may' \ + -s '^[\s]*myhostname[\s]*=' -r '# myhostname' \ + -- /etc/postfix/main.cf diff --git a/provisioning/base/general/provision/service.d/ssh.sh b/provisioning/base/general/provision/service.d/ssh.sh new file mode 100644 index 000000000..63d7a9f3a --- /dev/null +++ b/provisioning/base/general/provision/service.d/ssh.sh @@ -0,0 +1,17 @@ +#!/usr/bin/env bash + +IMAGE_FAMILY=$(docker-image-info family) + +case "$IMAGE_FAMILY" in + Debian|Ubuntu) + apt-install openssh-server + ;; + + RedHat) + yum-install openssh-server + ;; + + Alpine) + apk-install openssh + ;; +esac diff --git a/provisioning/base/general/provision/service.d/syslog.sh b/provisioning/base/general/provision/service.d/syslog.sh new file mode 100644 index 000000000..7e8b8e0a9 --- /dev/null +++ b/provisioning/base/general/provision/service.d/syslog.sh @@ -0,0 +1,41 @@ +#!/usr/bin/env bash + +IMAGE_FAMILY=$(docker-image-info family) + +# Installation +case "$IMAGE_FAMILY" in + Debian|Ubuntu) + apt-install syslog-ng syslog-ng-core + ;; + + RedHat) + yum-install syslog-ng + + # remove logrotate (not needed for docker) + rm -f "/etc/cron.daily/logrotate" + ;; + + Alpine) + apk-install syslog-ng + ;; +esac + +## Configuration +SYSLOG_NG_VERSION=$(syslog-ng --version | grep -E -e '^syslog-ng[ ]+[0-9]+\.[0-9]+' | head -n 1 | awk '{print $2}' | cut -f 1,2 -d .) + +# Disable caps inside container +if [[ -f /etc/default/syslog-ng ]]; then + go-replace --mode=lineinfile \ + -s "SYSLOGNG_OPTS" -r "SYSLOGNG_OPTS = --no-caps" \ + -- /etc/default/syslog-ng +fi + +# Symlink configuration +ln -s -f /opt/docker/etc/syslog-ng/syslog-ng.conf /etc/syslog-ng/syslog-ng.conf + +go-replace --mode=lineinfile \ + -s "@version" -r "@version: ${SYSLOG_NG_VERSION}" \ + -- /etc/syslog-ng/syslog-ng.conf + +# Ensure /var/lib/syslog-ng exists +mkdir -p /var/lib/syslog-ng diff --git a/provisioning/base/general/provision/variables-webdevops.yml b/provisioning/base/general/provision/variables-webdevops.yml new file mode 100644 index 000000000..0b2a21a95 --- /dev/null +++ b/provisioning/base/general/provision/variables-webdevops.yml @@ -0,0 +1,7 @@ +--- + +docker_image_info_family: "{{ lookup('pipe', 'docker-image-info family') }}" +docker_image_info_distribution: "{{ lookup('pipe', 'docker-image-info dist') }}" +docker_image_info_distribution_version: "{{ lookup('pipe', 'docker-image-info dist-version') }}" +docker_image_info_distribution_release: "{{ lookup('pipe', 'docker-image-info dist-release') }}" +docker_image_info_distribution_codename: "{{ lookup('pipe', 'docker-image-info dist-codename') }}" diff --git a/provisioning/base/general/provision/variables.yml b/provisioning/base/general/provision/variables.yml index ed97d539c..0b2a21a95 100644 --- a/provisioning/base/general/provision/variables.yml +++ b/provisioning/base/general/provision/variables.yml @@ -1 +1,7 @@ --- + +docker_image_info_family: "{{ lookup('pipe', 'docker-image-info family') }}" +docker_image_info_distribution: "{{ lookup('pipe', 'docker-image-info dist') }}" +docker_image_info_distribution_version: "{{ lookup('pipe', 'docker-image-info dist-version') }}" +docker_image_info_distribution_release: "{{ lookup('pipe', 'docker-image-info dist-release') }}" +docker_image_info_distribution_codename: "{{ lookup('pipe', 'docker-image-info dist-codename') }}" diff --git a/provisioning/development/general/provision/roles/webdevops-dev/tasks/bootstrap.yml b/provisioning/development/general/provision/roles/webdevops-dev/tasks/bootstrap.yml index 5c9eafbd0..3d7a494ad 100644 --- a/provisioning/development/general/provision/roles/webdevops-dev/tasks/bootstrap.yml +++ b/provisioning/development/general/provision/roles/webdevops-dev/tasks/bootstrap.yml @@ -1,8 +1,5 @@ --- -- name: Enable ssh daemon - shell: "/opt/docker/bin/control.sh service.enable ssh" - - name: Set application user password user: name: "{{ APPLICATION_USER }}" diff --git a/provisioning/nginx-dev/general/bin/service.d/nginx.d/12-development.sh b/provisioning/nginx-dev/general/bin/service.d/nginx.d/12-development.sh index fa4b601a9..f4695f059 100644 --- a/provisioning/nginx-dev/general/bin/service.d/nginx.d/12-development.sh +++ b/provisioning/nginx-dev/general/bin/service.d/nginx.d/12-development.sh @@ -1 +1,7 @@ -find /opt/docker/etc/nginx/ -iname '*.conf' -print0 | xargs -0 -r rpl --quiet "" "$WEB_NO_CACHE_PATTERN" > /dev/null +go-replace \ + -s "" \ + -r "$WEB_NO_CACHE_PATTERN" \ + --path=/opt/docker/etc/nginx/ \ + --path-pattern='*.conf' \ + --ignore-empty + diff --git a/provisioning/nginx-dev/general/etc/nginx/vhost.common.d/10-log.conf b/provisioning/nginx-dev/general/etc/nginx/vhost.common.d/10-log.conf new file mode 100644 index 000000000..a2cd929e7 --- /dev/null +++ b/provisioning/nginx-dev/general/etc/nginx/vhost.common.d/10-log.conf @@ -0,0 +1,2 @@ +access_log /docker.stdout; +error_log /docker.stderr info; diff --git a/provisioning/nginx/general/bin/service.d/nginx.d/10-init.sh b/provisioning/nginx/general/bin/service.d/nginx.d/10-init.sh index 75a84a4eb..27b9776cc 100644 --- a/provisioning/nginx/general/bin/service.d/nginx.d/10-init.sh +++ b/provisioning/nginx/general/bin/service.d/nginx.d/10-init.sh @@ -8,15 +8,17 @@ fi ln -f -s /var/lib/nginx/logs /var/log/nginx # Replace markers -find /opt/docker/etc/nginx/ -iname '*.conf' -print0 | xargs -0 -r rpl --quiet "" "$WEB_DOCUMENT_INDEX" > /dev/null -find /opt/docker/etc/nginx/ -iname '*.conf' -print0 | xargs -0 -r rpl --quiet "" "$WEB_DOCUMENT_ROOT" > /dev/null -find /opt/docker/etc/nginx/ -iname '*.conf' -print0 | xargs -0 -r rpl --quiet "" "$WEB_ALIAS_DOMAIN" > /dev/null -find /opt/docker/etc/nginx/ -iname '*.conf' -print0 | xargs -0 -r rpl --quiet "" "$HOSTNAME" > /dev/null +go-replace \ + -s "" -r "$WEB_DOCUMENT_INDEX" \ + -s "" -r "$WEB_DOCUMENT_ROOT" \ + -s "" -r "$WEB_ALIAS_DOMAIN" \ + -s "" -r "$HOSTNAME" \ + -s "" -r "$WEB_PHP_SOCKET" \ + --path=/opt/docker/etc/nginx/ \ + --path-pattern='*.conf' \ + --ignore-empty -if [[ -n "${WEB_PHP_SOCKET+x}" ]]; then - ## WEB_PHP_SOCKET is set - find /opt/docker/etc/nginx/ -iname '*.conf' -print0 | xargs -0 -r rpl --quiet "" "$WEB_PHP_SOCKET" > /dev/null -else +if [[ -z "${WEB_PHP_SOCKET+x}" ]]; then ## WEB_PHP_SOCKET is not set, remove PHP files rm -f -- /opt/docker/etc/nginx/conf.d/10-php.conf rm -f -- /opt/docker/etc/nginx/vhost.common.d/10-php.conf diff --git a/provisioning/nginx/general/etc/nginx/vhost.common.d/10-general.conf b/provisioning/nginx/general/etc/nginx/vhost.common.d/10-general.conf new file mode 100644 index 000000000..d3fd0aa5e --- /dev/null +++ b/provisioning/nginx/general/etc/nginx/vhost.common.d/10-general.conf @@ -0,0 +1 @@ +client_max_body_size 50m; diff --git a/provisioning/nginx/general/etc/nginx/vhost.common.d/10-log.conf b/provisioning/nginx/general/etc/nginx/vhost.common.d/10-log.conf new file mode 100644 index 000000000..9646c6826 --- /dev/null +++ b/provisioning/nginx/general/etc/nginx/vhost.common.d/10-log.conf @@ -0,0 +1,2 @@ +access_log /docker.stdout; +error_log /docker.stderr warn; diff --git a/provisioning/nginx/general/etc/nginx/vhost.conf b/provisioning/nginx/general/etc/nginx/vhost.conf index d07e27094..8225f314a 100644 --- a/provisioning/nginx/general/etc/nginx/vhost.conf +++ b/provisioning/nginx/general/etc/nginx/vhost.conf @@ -1,17 +1,11 @@ server { - listen 80 default_server; - listen 8000 default_server; + listen 80 default_server; server_name _ docker; - access_log /docker.stdout; - error_log /docker.stdout info; - root ""; index ; - client_max_body_size 50m; - include /opt/docker/etc/nginx/vhost.common.d/*.conf; } @@ -20,19 +14,13 @@ server { ############## server { - listen 443 default_server; - listen 8443 default_server; + listen 443 default_server; server_name _ docker; - access_log /docker.stdout; - error_log /docker.stdout info; - root ""; index ; - client_max_body_size 50m; - include /opt/docker/etc/nginx/vhost.common.d/*.conf; include /opt/docker/etc/nginx/vhost.ssl.conf; } diff --git a/provisioning/php-dev/general/provision/entrypoint.d/10-php-debugger.sh b/provisioning/php-dev/general/provision/entrypoint.d/10-php-debugger.sh index 7156e28aa..b5985a9ef 100644 --- a/provisioning/php-dev/general/provision/entrypoint.d/10-php-debugger.sh +++ b/provisioning/php-dev/general/provision/entrypoint.d/10-php-debugger.sh @@ -15,7 +15,8 @@ PHP_CONF_PATHS=" /etc/php5/fpm/conf.d /etc/php/7.0/mods-available /etc/php/7.0/cli/conf.d -/etc/php/7.0/fpm/conf.d" +/etc/php/7.0/fpm/conf.d +/usr/local/etc/php/conf.d/" function phpModuleRemove() { if [ "$#" -ne 1 ]; then @@ -40,7 +41,7 @@ if [[ -n "${PHP_DEBUGGER+x}" ]]; then blackfire) echo "PHP-Debugger: Blackfire enabled" phpModuleRemove "xdebug" - /opt/docker/bin/control.sh service.enable blackfire-agent + docker-service-enable blackfire-agent ;; none) diff --git a/provisioning/php-dev/general/provision/roles/webdevops-php-dev/tasks/bootstrap.yml b/provisioning/php-dev/general/provision/roles/webdevops-php-dev/tasks/bootstrap.yml index 2c5d76e3d..ff02b05fc 100644 --- a/provisioning/php-dev/general/provision/roles/webdevops-php-dev/tasks/bootstrap.yml +++ b/provisioning/php-dev/general/provision/roles/webdevops-php-dev/tasks/bootstrap.yml @@ -1,6 +1,5 @@ --- -- include: bootstrap/tools.yml - include: bootstrap/php-fpm.yml - include: bootstrap/php-module.yml - include: bootstrap/php-module.opcache.yml diff --git a/provisioning/php-dev/general/provision/roles/webdevops-php-dev/tasks/bootstrap/php-module.blackfire.yml b/provisioning/php-dev/general/provision/roles/webdevops-php-dev/tasks/bootstrap/php-module.blackfire.yml index 1a3db9bac..faf05f8de 100644 --- a/provisioning/php-dev/general/provision/roles/webdevops-php-dev/tasks/bootstrap/php-module.blackfire.yml +++ b/provisioning/php-dev/general/provision/roles/webdevops-php-dev/tasks/bootstrap/php-module.blackfire.yml @@ -7,4 +7,4 @@ with_items: - /etc/php5/cli/conf.d/zz-blackfire.ini - /etc/php5/fpm/conf.d/zz-blackfire.ini - when: ansible_distribution == 'Debian' and ansible_lsb.major_release|int >= 7 + when: ansible_distribution == 'Debian' and docker_image_info_distribution_version|int >= 7 diff --git a/provisioning/php-dev/general/provision/roles/webdevops-php-dev/tasks/bootstrap/tools.yml b/provisioning/php-dev/general/provision/roles/webdevops-php-dev/tasks/bootstrap/tools.yml deleted file mode 100644 index c49cb0e34..000000000 --- a/provisioning/php-dev/general/provision/roles/webdevops-php-dev/tasks/bootstrap/tools.yml +++ /dev/null @@ -1,23 +0,0 @@ ---- - -- name: Downloading Tools - shell: curl -o "{{ item.dest }}" "{{ item.url }}" && chmod 755 "{{ item.dest }}" - with_items: - - { url: "https://phar.phpunit.de/phploc.phar", dest: /usr/local/bin/phploc } - - { url: "https://phar.phpunit.de/phpunit.phar", dest: /usr/local/bin/phpunit } - - { url: "http://static.pdepend.org/php/latest/pdepend.phar", dest: /usr/local/bin/pdepend } - - { url: "http://static.phpmd.org/php/latest/phpmd.phar", dest: /usr/local/bin/phpmd } - - { url: "https://squizlabs.github.io/PHP_CodeSniffer/phpcs.phar", dest: /usr/local/bin/phpcs } - - { url: "https://squizlabs.github.io/PHP_CodeSniffer/phpcbf.phar", dest: /usr/local/bin/phpcbf } - - { url: "https://phar.phpunit.de/phpcpd.phar", dest: /usr/local/bin/phpcpd } - - { url: "https://phar.phpunit.de/phpdcd.phar", dest: /usr/local/bin/phpdcd } - - { url: "https://github.com/Halleck45/PhpMetrics/raw/master/build/phpmetrics.phar", dest: /usr/local/bin/phpmetrics } - - { url: "http://get.sensiolabs.org/php-cs-fixer.phar", dest: /usr/local/bin/php-cs-fixer } - - { url: "https://github.com/sensiolabs-de/deprecation-detector/releases/download/0.1.0-alpha4/deprecation-detector.phar", dest: /usr/local/bin/deprecation-detector } - - { url: "https://github.com/sensiolabs-de/deprecation-detector/releases/download/0.1.0-alpha4/deprecation-detector.phar", dest: /usr/local/bin/deprecation-detector } - -- name: Install Tools via composer - raw: COMPOSER_HOME="/usr/local/composer" COMPOSER_BIN_DIR="/usr/local/bin" composer global require "{{ item.package }}" "{{ item.version }}" - with_items: - - { package: "sstalle/php7cc" , version: "*" } - - { package: "phpspec/phpspec" , version: "~2.0" } diff --git a/provisioning/php/general/bin/service.d/php-fpm.d/11-clear-env.sh b/provisioning/php/general/bin/service.d/php-fpm.d/11-clear-env.sh index b17280ce6..ef6fd4016 100644 --- a/provisioning/php/general/bin/service.d/php-fpm.d/11-clear-env.sh +++ b/provisioning/php/general/bin/service.d/php-fpm.d/11-clear-env.sh @@ -30,5 +30,9 @@ for envVariable in $(printenv|cut -f1 -d=); do done # Replace ;#CLEAR_ENV_WORKAROUND# with environment variable list for all php-fpm pool files -find /opt/docker/etc/php/fpm/pool.d/ -iname '*.conf' -print0 | xargs -0 -r rpl --quiet ";#CLEAR_ENV_WORKAROUND#" "$VARIABLE_LIST" > /dev/null +go-replace \ + -s ";#CLEAR_ENV_WORKAROUND#" -r "$VARIABLE_LIST" \ + --path=/opt/docker/etc/php/fpm/pool.d/ \ + --path-pattern='*.conf' \ + --ignore-empty diff --git a/provisioning/php/general/bin/service.d/php-fpm.sh b/provisioning/php/general/bin/service.d/php-fpm.sh index 571f248d2..b25983bd3 100644 --- a/provisioning/php/general/bin/service.d/php-fpm.sh +++ b/provisioning/php/general/bin/service.d/php-fpm.sh @@ -4,4 +4,4 @@ source /opt/docker/bin/config.sh includeScriptDir "/opt/docker/bin/service.d/php-fpm.d/" -exec /usr/sbin/php-fpm --nodaemonize +exec /usr/local/bin/php-fpm --nodaemonize diff --git a/provisioning/php/general/etc/php/php.webdevops.ini b/provisioning/php/general/etc/php/php.webdevops.ini index 562b8d7e2..aa1545ab8 100644 --- a/provisioning/php/general/etc/php/php.webdevops.ini +++ b/provisioning/php/general/etc/php/php.webdevops.ini @@ -5,6 +5,7 @@ ; this file will overwrite default php.ini settings display_errors = 0 +log_errors = 1 short_open_tag = Off variables_order = 'GPCS' diff --git a/provisioning/php/general/provision/roles/webdevops-php/tasks/bootstrap.yml b/provisioning/php/general/provision/roles/webdevops-php/tasks/bootstrap.yml index 5883fa1fe..99a2e5191 100644 --- a/provisioning/php/general/provision/roles/webdevops-php/tasks/bootstrap.yml +++ b/provisioning/php/general/provision/roles/webdevops-php/tasks/bootstrap.yml @@ -1,6 +1,10 @@ --- +- include: bootstrap/init.yml - include: bootstrap/php.yml +- include: bootstrap/php.debian.yml +- include: bootstrap/php.redhat.yml +- include: bootstrap/php.alpine.yml - include: bootstrap/php-fpm.main.yml - include: bootstrap/php-fpm.pool.yml - include: bootstrap/php-fpm.yml diff --git a/provisioning/php/general/provision/roles/webdevops-php/tasks/bootstrap/init.yml b/provisioning/php/general/provision/roles/webdevops-php/tasks/bootstrap/init.yml new file mode 100644 index 000000000..a48bec675 --- /dev/null +++ b/provisioning/php/general/provision/roles/webdevops-php/tasks/bootstrap/init.yml @@ -0,0 +1,71 @@ +--- + +- name: Get php version + command: "php -r 'echo phpversion();'" + changed_when: true + register: php_version_cmd + ignore_errors: true + +- name: Set php_version version + set_fact: + php_version: "{{php_version_cmd.stdout}}" + +############################# +# PHP 5.x +############################# + +- name: Set php main file (RedHat, PHP 5.x) + set_fact: + php_main_conf: /etc/php-fpm.conf + php_pool_conf: www.conf + php_pool_dir: /etc/php-fpm.d + php_fpm_bin: /usr/sbin/php-fpm + when: ansible_os_family == 'RedHat' and ( php_version | version_compare('7.0.0', '<') ) + +- name: Set php main file (Debian, PHP 5.x) + set_fact: + php_etc_dir: /etc/php5 + php_main_conf: /etc/php5/fpm/php-fpm.conf + php_pool_conf: www.conf + php_pool_dir: /etc/php5/fpm/pool.d + php_fpm_bin: /usr/sbin/php5-fpm + when: ansible_os_family == 'Debian' and ( php_version | version_compare('7.0.0', '<') ) + +- name: Set php main file (Alpine, PHP 5.x) + set_fact: + php_etc_dir: /etc/php5 + php_main_conf: /etc/php5/php-fpm.conf + php_pool_conf: www.conf + php_pool_dir: /etc/php5/fpm.d + php_fpm_bin: /usr/bin/php-fpm5 + when: ansible_os_family == 'Alpine' and ( php_version | version_compare('7.0.0', '<') ) + +############################# +# PHP 7.x +############################# + +- name: Set php main file (RedHat, PHP 7.x) + set_fact: + php_main_conf: /etc/php-fpm.conf + php_pool_conf: www.conf + php_pool_dir: /etc/php-fpm.d + php_fpm_bin: /usr/sbin/php-fpm + when: ansible_os_family == 'RedHat' and ( php_version | version_compare('7.0.0', '>=') ) and ( php_version | version_compare('8.0.0', '<') ) + +- name: Set php main file (Debian, PHP 7.x) + set_fact: + php_etc_dir: /etc/php/7.0 + php_main_conf: /etc/php/7.0/fpm/php-fpm.conf + php_pool_conf: www.conf + php_pool_dir: /etc/php/7.0/fpm/pool.d + php_fpm_bin: /usr/sbin/php-fpm7.0 + when: ansible_os_family == 'Debian' and ( php_version | version_compare('7.0.0', '>=') ) and ( php_version | version_compare('8.0.0', '<') ) + +- name: Set php main file (Alpine, PHP 7.x) + set_fact: + php_etc_dir: /etc/php7 + php_main_conf: /etc/php7/php-fpm.conf + php_pool_conf: www.conf + php_pool_dir: /etc/php7/php-fpm.d + php_fpm_bin: /usr/sbin/php-fpm7 + when: ansible_os_family == 'Alpine' and ( php_version | version_compare('7.0.0', '>=') ) and ( php_version | version_compare('8.0.0', '<') ) diff --git a/provisioning/php/general/provision/roles/webdevops-php/tasks/bootstrap/php-fpm.main.yml b/provisioning/php/general/provision/roles/webdevops-php/tasks/bootstrap/php-fpm.main.yml index 1a2c7861f..c149d8728 100644 --- a/provisioning/php/general/provision/roles/webdevops-php/tasks/bootstrap/php-fpm.main.yml +++ b/provisioning/php/general/provision/roles/webdevops-php/tasks/bootstrap/php-fpm.main.yml @@ -1,19 +1,14 @@ --- -- name: Set php main file - set_fact: - php_main_conf: /etc/php-fpm.conf - when: ansible_os_family == 'RedHat' - -- name: Set php main file - set_fact: - php_main_conf: /etc/php5/fpm/php-fpm.conf - when: ansible_os_family == 'Debian' - -- name: Set php main file - set_fact: - php_main_conf: /etc/php5/php-fpm.conf - when: ansible_os_family == 'Alpine' +- name: Create php directories + file: + path: "{{ item }}" + state: directory + mode: 0755 + owner: "root" + group: "root" + with_items: + - /opt/docker/etc/php/fpm/ - name: Move php-fpm main file to /opt/docker/etc/php/fpm/ command: "mv {{ php_main_conf }} /opt/docker/etc/php/fpm/php-fpm.conf" @@ -33,12 +28,22 @@ owner: "root" group: "root" -- name: Configure php-fpm main +- name: Configure php-fpm main (all versions) lineinfile: dest: '/opt/docker/etc/php/fpm/php-fpm.conf' regexp: '^[\s;]*{{ item.key }}[\s]*=' line: '{{ item.key }} = {{ item.value }}' + insertafter: '\[global\]' with_items: - - { key: 'error_log', value: "syslog" } + - { key: 'error_log', value: "/docker.stderr" } - { key: 'pid', value: "/var/run/php-fpm.pid" } + +- name: Configure php-fpm main (php 5.x) + lineinfile: + dest: '/opt/docker/etc/php/fpm/php-fpm.conf' + regexp: '^[\s;]*{{ item.key }}[\s]*=' + line: '{{ item.key }} = {{ item.value }}' + insertbefore: '[\s]*include[\s]*=' + with_items: - { key: 'daemonize', value: 'no' } + when: ( php_version | version_compare('7.0.0', '<') ) diff --git a/provisioning/php/general/provision/roles/webdevops-php/tasks/bootstrap/php-fpm.pool.yml b/provisioning/php/general/provision/roles/webdevops-php/tasks/bootstrap/php-fpm.pool.yml index 53ee9dfe1..ab0b7b02c 100644 --- a/provisioning/php/general/provision/roles/webdevops-php/tasks/bootstrap/php-fpm.pool.yml +++ b/provisioning/php/general/provision/roles/webdevops-php/tasks/bootstrap/php-fpm.pool.yml @@ -1,18 +1,5 @@ --- -- name: Get php version - command: "php -r 'echo phpversion();'" - changed_when: true - register: php_version_cmd - ignore_errors: true - -- name: Set php_version version - set_fact: - php_version: "{{php_version_cmd.stdout}}" - -- debug: - msg: "PHP-Version: {{php_version}}" - - set_fact: php_clear_env_available: False @@ -22,23 +9,10 @@ ( php_version | version_compare('5.5', 'eq') and php_version | version_compare('5.5.11', 'ge') ) or ( php_version | version_compare('5.6', 'ge') ) -- name: Set php pool file - set_fact: - php_pool_conf: www.conf - php_pool_dir: /etc/php-fpm.d - when: ansible_os_family == 'RedHat' - -- name: Set php pool file - set_fact: - php_pool_conf: www.conf - php_pool_dir: /etc/php5/fpm/pool.d - when: ansible_os_family == 'Debian' - -- name: Set php pool file - set_fact: - php_pool_conf: www.conf - php_pool_dir: /etc/php5/fpm.d - when: ansible_os_family == 'Alpine' +- name: Create /opt/docker/etc/php/fpm directory + file: + path: "/opt/docker/etc/php/fpm" + state: directory - name: Move php-fpm pool directory file to /opt/docker/etc/php/ command: "mv {{ php_pool_dir }} /opt/docker/etc/php/fpm/pool.d" @@ -55,7 +29,7 @@ path: "{{ php_pool_dir }}" state: absent -- name: Symlink php-fpm main file +- name: Symlink php-fpm pool file file: path: "{{ php_pool_dir }}" src: "/opt/docker/etc/php/fpm/pool.d" @@ -69,15 +43,25 @@ regexp: '^[\s;]*{{ item.key }}[\s]*=' line: '{{ item.key }} = {{ item.value }}' with_items: - - { key: 'listen', value: "0.0.0.0:9000" } + - { key: 'listen', value: "[::]:9000" } - { key: 'catch_workers_output', value: "yes" } - { key: 'access.format', value: '[php-fpm:access] %R - %u %t "%m %r%Q%q" %s %f %{mili}d %{kilo}M %C%%' } + - { key: 'access.log', value: "/docker.stdout" } - { key: 'slowlog', value: "/docker.stderr" } - { key: 'php_admin_value[error_log]', value: "/docker.stderr" } - { key: 'php_admin_value[log_errors]', value: "on" } - { key: 'user', value: "{{ APPLICATION_USER }}" } - { key: 'group', value: "{{ APPLICATION_GROUP }}" } +- name: Configure php-fpm pool user (application.conf) + lineinfile: + dest: '/opt/docker/etc/php/fpm/pool.d/application.conf' + regexp: '^[\s;]*{{ item.key }}[\s]*=' + line: '{{ item.key }} = {{ item.value }}' + with_items: + - { key: 'listen', value: "0.0.0.0:9000" } + when: php_version | version_compare('5.5.99', '<=') + - name: Configure php-fpm pool user (application.conf) lineinfile: dest: '/opt/docker/etc/php/fpm/pool.d/application.conf' diff --git a/provisioning/php/general/provision/roles/webdevops-php/tasks/bootstrap/php-fpm.yml b/provisioning/php/general/provision/roles/webdevops-php/tasks/bootstrap/php-fpm.yml index d83edb3ae..41c1b33dc 100644 --- a/provisioning/php/general/provision/roles/webdevops-php/tasks/bootstrap/php-fpm.yml +++ b/provisioning/php/general/provision/roles/webdevops-php/tasks/bootstrap/php-fpm.yml @@ -1,45 +1,9 @@ --- -- name: Symlink php-fpm binary [Alpine family] +- name: Symlink php-fpm binary file: - path: "/usr/sbin/php-fpm" - src: "/usr/bin/php-fpm" + path: "/usr/local/bin/php-fpm" + src: "{{ php_fpm_bin }}" state: link owner: "root" group: "root" - when: ansible_os_family == 'Alpine' - -- name: Symlink php-fpm binary [Debian family] - file: - path: "/usr/sbin/php-fpm" - src: "/usr/sbin/php5-fpm" - state: link - owner: "root" - group: "root" - when: ansible_os_family == 'Debian' - -- name: Remove default php-fpm logrotate - file: - path: "/etc/logrotate.d/php-fpm" - state: absent - when: ansible_os_family == 'RedHat' - -- name: Create php-fpm log directory - file: - path: "/var/log/php5-fpm/" - state: directory - owner: "root" - group: "root" - -- name: Create php-fpm log files - file: - path: "/var/log/php5-fpm/{{ item }}" - state: touch - owner: "root" - group: "root" - mode: 0600 - with_items: - - slow.log - - access.log - - error.log - - fpm.log diff --git a/provisioning/php/general/provision/roles/webdevops-php/tasks/bootstrap/php.alpine.yml b/provisioning/php/general/provision/roles/webdevops-php/tasks/bootstrap/php.alpine.yml new file mode 100644 index 000000000..4c16cdf0d --- /dev/null +++ b/provisioning/php/general/provision/roles/webdevops-php/tasks/bootstrap/php.alpine.yml @@ -0,0 +1,12 @@ +--- + +- name: Create link for additional php.ini [Alpine family] + file: + src: '/opt/docker/etc/php/{{ item.file }}' + dest: '{{ php_etc_dir }}/conf.d/{{ item.target }}' + state: link + force: yes + with_items: + - { file: 'php.webdevops.ini', target: 'xzza-webdevops.ini'} + - { file: 'php.ini', target: 'xzzz-docker.ini'} + when: ansible_os_family == 'Alpine' diff --git a/provisioning/php/general/provision/roles/webdevops-php/tasks/bootstrap/php.debian.yml b/provisioning/php/general/provision/roles/webdevops-php/tasks/bootstrap/php.debian.yml new file mode 100644 index 000000000..d27037e33 --- /dev/null +++ b/provisioning/php/general/provision/roles/webdevops-php/tasks/bootstrap/php.debian.yml @@ -0,0 +1,18 @@ +--- + +- name: Link php.ini for cli and fpm [Debian family] + file: + src: '{{ item.file }}' + dest: '{{ php_etc_dir }}/{{ item.category }}/conf.d/{{ item.target }}' + force: yes + state: link + with_items: + # PHP cli + - { category: 'cli', file: '{{ php_etc_dir }}/mods-available/mcrypt.ini', target: '20-mcrypt.ini' } + - { category: 'cli', file: '/opt/docker/etc/php/php.webdevops.ini', target: '98-webdevops.ini' } + - { category: 'cli', file: '/opt/docker/etc/php/php.ini', target: '99-docker.ini' } + # PHP fpm + - { category: 'fpm', file: '{{ php_etc_dir }}/mods-available/mcrypt.ini', target: '20-mcrypt.ini' } + - { category: 'fpm', file: '/opt/docker/etc/php/php.webdevops.ini', target: '98-webdevops.ini' } + - { category: 'fpm', file: '/opt/docker/etc/php/php.ini', target: '99-docker.ini' } + when: ansible_os_family == 'Debian' diff --git a/provisioning/php/general/provision/roles/webdevops-php/tasks/bootstrap/php.redhat.yml b/provisioning/php/general/provision/roles/webdevops-php/tasks/bootstrap/php.redhat.yml new file mode 100644 index 000000000..7e8810231 --- /dev/null +++ b/provisioning/php/general/provision/roles/webdevops-php/tasks/bootstrap/php.redhat.yml @@ -0,0 +1,12 @@ +--- + +- name: Create link for additional php.ini [RedHat family] + file: + src: '/opt/docker/etc/php/{{ item.file }}' + dest: '/etc/php.d/{{ item.target }}' + state: link + force: yes + with_items: + - { file: 'php.webdevops.ini', target: 'zza-webdevops.ini'} + - { file: 'php.ini', target: 'zzz-docker.ini'} + when: ansible_os_family == 'RedHat' diff --git a/provisioning/php/general/provision/roles/webdevops-php/tasks/bootstrap/php.yml b/provisioning/php/general/provision/roles/webdevops-php/tasks/bootstrap/php.yml index 9816b2538..caac8f413 100644 --- a/provisioning/php/general/provision/roles/webdevops-php/tasks/bootstrap/php.yml +++ b/provisioning/php/general/provision/roles/webdevops-php/tasks/bootstrap/php.yml @@ -21,42 +21,3 @@ with_items: - "/opt/docker/etc/php/php.webdevops.ini" - "/opt/docker/etc/php/php.ini" - -- name: Link php.ini for cli and fpm [Debian family] - file: - src: '{{ item.file }}' - dest: '/etc/php5/{{ item.category }}/conf.d/{{ item.target }}' - force: yes - state: link - with_items: - # PHP cli - - { category: 'cli', file: '/etc/php5/mods-available/mcrypt.ini', target: '20-mcrypt.ini' } - - { category: 'cli', file: '/opt/docker/etc/php/php.webdevops.ini', target: '98-webdevops.ini' } - - { category: 'cli', file: '/opt/docker/etc/php/php.ini', target: '99-docker.ini' } - # PHP fpm - - { category: 'fpm', file: '/etc/php5/mods-available/mcrypt.ini', target: '20-mcrypt.ini' } - - { category: 'fpm', file: '/opt/docker/etc/php/php.webdevops.ini', target: '98-webdevops.ini' } - - { category: 'fpm', file: '/opt/docker/etc/php/php.ini', target: '99-docker.ini' } - when: ansible_os_family == 'Debian' - -- name: Create link for additional php.ini [RedHat family] - file: - src: '/opt/docker/etc/php/{{ item.file }}' - dest: '/etc/php.d/{{ item.target }}' - state: link - force: yes - with_items: - - { file: 'php.webdevops.ini', target: 'zza-webdevops.ini'} - - { file: 'php.ini', target: 'zzz-docker.ini'} - when: ansible_os_family == 'RedHat' - -- name: Create link for additional php.ini [Alpine family] - file: - src: '/opt/docker/etc/php/{{ item.file }}' - dest: '/etc/php5/conf.d/{{ item.target }}' - state: link - force: yes - with_items: - - { file: 'php.webdevops.ini', target: 'xzza-webdevops.ini'} - - { file: 'php.ini', target: 'xzzz-docker.ini'} - when: ansible_os_family == 'Alpine' diff --git a/provisioning/php/official/provision/roles/webdevops-php/defaults/main.yml b/provisioning/php/official/provision/roles/webdevops-php/defaults/main.yml new file mode 100644 index 000000000..81f5b7efd --- /dev/null +++ b/provisioning/php/official/provision/roles/webdevops-php/defaults/main.yml @@ -0,0 +1,6 @@ +--- + +APPLICATION_USER: "{{ lookup('env','APPLICATION_USER') }}" +APPLICATION_GROUP: "{{ lookup('env','APPLICATION_GROUP') }}" +APPLICATION_UID: "{{ lookup('env','APPLICATION_UID') }}" +APPLICATION_GID: "{{ lookup('env','APPLICATION_GID') }}" diff --git a/provisioning/php/official/provision/roles/webdevops-php/tasks/bootstrap/init.yml b/provisioning/php/official/provision/roles/webdevops-php/tasks/bootstrap/init.yml new file mode 100644 index 000000000..df39e4bd4 --- /dev/null +++ b/provisioning/php/official/provision/roles/webdevops-php/tasks/bootstrap/init.yml @@ -0,0 +1,23 @@ +--- + +- name: Get php version + command: "php -r 'echo phpversion();'" + changed_when: true + register: php_version_cmd + ignore_errors: true + +- name: Set php_version version + set_fact: + php_version: "{{php_version_cmd.stdout}}" + +############################# +# PHP +############################# + +- name: Set php main file (official) + set_fact: + php_etc_dir: /usr/local/etc/php + php_main_conf: /usr/local/etc/php-fpm.conf + php_pool_conf: www.conf + php_pool_dir: /usr/local/etc/php-fpm.d + php_fpm_bin: /usr/local/sbin/php-fpm diff --git a/provisioning/php/official/provision/roles/webdevops-php/tasks/bootstrap/php.debian.yml b/provisioning/php/official/provision/roles/webdevops-php/tasks/bootstrap/php.debian.yml new file mode 100644 index 000000000..411e736c8 --- /dev/null +++ b/provisioning/php/official/provision/roles/webdevops-php/tasks/bootstrap/php.debian.yml @@ -0,0 +1,11 @@ +--- + +- name: Link php.ini for cli and fpm [Official PHP] + file: + src: '{{ item.file }}' + dest: '{{ php_etc_dir }}/conf.d/{{ item.target }}' + force: yes + state: link + with_items: + - { category: 'cli', file: '/opt/docker/etc/php/php.webdevops.ini', target: '98-webdevops.ini' } + - { category: 'cli', file: '/opt/docker/etc/php/php.ini', target: '99-docker.ini' } diff --git a/provisioning/php/php7/etc/logrotate.d/php7-fpm b/provisioning/php/php7/etc/logrotate.d/php7-fpm deleted file mode 100644 index 668f2545f..000000000 --- a/provisioning/php/php7/etc/logrotate.d/php7-fpm +++ /dev/null @@ -1,12 +0,0 @@ -/var/log/php7-fpm/fpm.log -/var/log/php7-fpm/access.log -/var/log/php7-fpm/slow.log -/var/log/php7-fpm/error.log { - missingok - notifempty - sharedscripts - delaycompress - postrotate - /bin/kill -SIGUSR1 `cat /var/run/php7-fpm.pid` 2>/dev/null || true - endscript -} diff --git a/provisioning/php/php7/provision/roles/webdevops-php/tasks/bootstrap.yml b/provisioning/php/php7/provision/roles/webdevops-php/tasks/bootstrap.yml deleted file mode 100644 index 5883fa1fe..000000000 --- a/provisioning/php/php7/provision/roles/webdevops-php/tasks/bootstrap.yml +++ /dev/null @@ -1,6 +0,0 @@ ---- - -- include: bootstrap/php.yml -- include: bootstrap/php-fpm.main.yml -- include: bootstrap/php-fpm.pool.yml -- include: bootstrap/php-fpm.yml diff --git a/provisioning/php/php7/provision/roles/webdevops-php/tasks/bootstrap/php-fpm.main.yml b/provisioning/php/php7/provision/roles/webdevops-php/tasks/bootstrap/php-fpm.main.yml deleted file mode 100644 index 36143a96f..000000000 --- a/provisioning/php/php7/provision/roles/webdevops-php/tasks/bootstrap/php-fpm.main.yml +++ /dev/null @@ -1,53 +0,0 @@ ---- - -- name: Set php main file - set_fact: - php_main_conf: /etc/php-fpm.conf - when: ansible_os_family == 'RedHat' - -- name: Set php main file - set_fact: - php_main_conf: /etc/php/7.0/fpm/php-fpm.conf - when: ansible_os_family == 'Debian' - -- name: Set php main file - set_fact: - php_main_conf: /etc/php7/php-fpm.conf - when: ansible_os_family == 'Alpine' - -- name: Create php directories - file: - path: "{{ item }}" - state: directory - mode: 0755 - owner: "root" - group: "root" - with_items: - - /opt/docker/etc/php/fpm/ - -- name: Move php-fpm main file to /opt/docker/etc/php/fpm/ - command: "mv {{ php_main_conf }} /opt/docker/etc/php/fpm/php-fpm.conf" - args: - creates: /opt/docker/etc/php/fpm/php-fpm.conf - -- name: Remove php-fpm main file - file: - path: "{{ php_main_conf }}" - state: absent - -- name: Symlink php-fpm main file - file: - path: "{{ php_main_conf }}" - src: "/opt/docker/etc/php/fpm/php-fpm.conf" - state: link - owner: "root" - group: "root" - -- name: Configure php-fpm main - lineinfile: - dest: '/opt/docker/etc/php/fpm/php-fpm.conf' - regexp: '^[\s;]*{{ item.key }}[\s]*=' - line: '{{ item.key }} = {{ item.value }}' - with_items: - - { key: 'error_log', value: "syslog" } - - { key: 'pid', value: "/var/run/php-fpm.pid" } diff --git a/provisioning/php/php7/provision/roles/webdevops-php/tasks/bootstrap/php-fpm.pool.yml b/provisioning/php/php7/provision/roles/webdevops-php/tasks/bootstrap/php-fpm.pool.yml deleted file mode 100644 index d91ecab7f..000000000 --- a/provisioning/php/php7/provision/roles/webdevops-php/tasks/bootstrap/php-fpm.pool.yml +++ /dev/null @@ -1,91 +0,0 @@ ---- -- name: Get php version - command: "php -r 'echo phpversion();'" - changed_when: true - register: php_version_cmd - ignore_errors: true - -- name: Set php_version version - set_fact: - php_version: "{{php_version_cmd.stdout}}" - -- debug: - msg: "PHP-Version: {{php_version}}" - -- name: Set php pool file - set_fact: - php_pool_conf: www.conf - php_pool_dir: /etc/php-fpm.d - when: ansible_os_family == 'RedHat' - -- name: Set php pool file - set_fact: - php_pool_conf: www.conf - php_pool_dir: /etc/php/7.0/fpm/pool.d - when: ansible_os_family == 'Debian' - -- name: Set php pool file - set_fact: - php_pool_conf: www.conf - php_pool_dir: /etc/php7/php-fpm.d - when: ansible_os_family == 'Alpine' - -- name: Create php directories - file: - path: "{{ item }}" - state: directory - mode: 0755 - owner: "root" - group: "root" - with_items: - - /opt/docker/etc/php/fpm/ - -- name: Move php-fpm pool directory file to /opt/docker/etc/php/ - command: "mv {{ php_pool_dir }} /opt/docker/etc/php/fpm/pool.d" - args: - creates: /opt/docker/etc/php/fpm/pool.d - -- name: Rename pool file file to application.conf" - command: "mv /opt/docker/etc/php/fpm/pool.d/{{ php_pool_conf }} /opt/docker/etc/php/fpm/pool.d/application.conf" - args: - creates: /opt/docker/etc/php/fpm/pool.d/application.conf - -- name: Remove php-fpm pool directory - file: - path: "{{ php_pool_dir }}" - state: absent - -- name: Symlink php-fpm main file - file: - path: "{{ php_pool_dir }}" - src: "/opt/docker/etc/php/fpm/pool.d" - state: link - owner: "root" - group: "root" - - -- name: Configure php-fpm pool user (www.conf) - lineinfile: - dest: '/opt/docker/etc/php/fpm/pool.d/application.conf' - regexp: '^[\s;]*{{ item.key }}[\s]*=' - line: '{{ item.key }} = {{ item.value }}' - with_items: - - { key: 'listen', value: "0.0.0.0:9000" } - - { key: 'catch_workers_output', value: "yes" } - - { key: 'access.format', value: '[php-fpm:access] %R - %u %t "%m %r%Q%q" %s %f %{mili}d %{kilo}M %C%%' } - - { key: 'access.log', value: "/docker.stdout" } - - { key: 'slowlog', value: "/docker.stderr" } - - { key: 'php_admin_value[error_log]', value: "/docker.stderr" } - - { key: 'php_admin_value[log_errors]', value: "on" } - - { key: 'clear_env', value: "no" } - - { key: 'user', value: "{{ APPLICATION_USER }}" } - - { key: 'group', value: "{{ APPLICATION_GROUP }}" } - -- name: Disable php-fpm connection limit - lineinfile: - dest: '/opt/docker/etc/php/fpm/pool.d/application.conf' - regexp: '^[\s;]*{{ item.key }}[\s]*=' - line: ';{{ item.key }}' - with_items: - - { key: 'listen.allowed_clients' } - diff --git a/provisioning/php/php7/provision/roles/webdevops-php/tasks/bootstrap/php-fpm.yml b/provisioning/php/php7/provision/roles/webdevops-php/tasks/bootstrap/php-fpm.yml deleted file mode 100644 index 130542f53..000000000 --- a/provisioning/php/php7/provision/roles/webdevops-php/tasks/bootstrap/php-fpm.yml +++ /dev/null @@ -1,54 +0,0 @@ ---- - -- name: Symlink php-fpm binary [RedHat family] - file: - path: "/usr/sbin/php-fpm7.0" - src: "/usr/sbin/php-fpm" - state: link - owner: "root" - group: "root" - when: ansible_os_family == 'RedHat' - -- name: Symlink php-fpm binary [Alpine family] - file: - path: "/usr/sbin/php-fpm" - src: "/usr/sbin/php-fpm7" - state: link - owner: "root" - group: "root" - when: ansible_os_family == 'Alpine' - -- name: Symlink php-fpm binary [Debian family] - file: - path: "/usr/sbin/php-fpm" - src: "/usr/sbin/php-fpm7.0" - state: link - owner: "root" - group: "root" - when: ansible_os_family == 'Debian' - -- name: Remove default php-fpm logrotate - file: - path: "/etc/logrotate.d/php-fpm" - state: absent - when: ansible_os_family == 'RedHat' - -- name: Create php-fpm log directory - file: - path: "/var/log/php7-fpm/" - state: directory - owner: "root" - group: "root" - -- name: Create php-fpm log files - file: - path: "/var/log/php7-fpm/{{ item }}" - state: touch - owner: "root" - group: "root" - mode: 0600 - with_items: - - slow.log - - access.log - - error.log - - fpm.log diff --git a/provisioning/php/php7/provision/roles/webdevops-php/tasks/bootstrap/php.yml b/provisioning/php/php7/provision/roles/webdevops-php/tasks/bootstrap/php.yml deleted file mode 100644 index 97f02eec3..000000000 --- a/provisioning/php/php7/provision/roles/webdevops-php/tasks/bootstrap/php.yml +++ /dev/null @@ -1,60 +0,0 @@ ---- - -- name: Create php directories - file: - path: "{{ item }}" - state: directory - mode: 0755 - owner: "root" - group: "root" - with_items: - - /opt/docker/etc/php/ - - /opt/docker/etc/php/fpm/ - -- name: Create /opt/docker/etc/php/php.ini" - file: - path: "{{ item }}" - state: touch - mode: 0744 - owner: root - group: root - with_items: - - "/opt/docker/etc/php/php.webdevops.ini" - - "/opt/docker/etc/php/php.ini" - -- name: Link php.ini for cli and fpm - file: - src: '{{ item.file }}' - dest: '/etc/php/7.0/{{ item.category }}/conf.d/{{ item.target }}' - force: yes - state: link - with_items: - # PHP cli - - { category: 'cli', file: '/opt/docker/etc/php/php.webdevops.ini', target: '98-webdevops.ini' } - - { category: 'cli', file: '/opt/docker/etc/php/php.ini', target: '99-docker.ini' } - # PHP fpm - - { category: 'fpm', file: '/opt/docker/etc/php/php.webdevops.ini', target: '98-webdevops.ini' } - - { category: 'fpm', file: '/opt/docker/etc/php/php.ini', target: '99-docker.ini' } - when: ansible_os_family == 'Debian' - -- name: Create link for additional php.ini [RedHat family] - file: - src: '/opt/docker/etc/php/{{ item.file }}' - dest: '/etc/php.d/{{ item.target }}' - state: link - force: yes - with_items: - - { file: 'php.webdevops.ini', target: 'zza-webdevops.ini'} - - { file: 'php.ini', target: 'zzz-docker.ini'} - when: ansible_os_family == 'RedHat' - -- name: Link php.ini - file: - src: '/opt/docker/etc/php/{{ item.file }}' - dest: '/etc/php7/conf.d/{{ item.target }}' - force: yes - state: link - with_items: - - { file: 'php.webdevops.ini', target: 'xzza-webdevops.ini'} - - { file: 'php.ini', target: 'xzzz-docker.ini'} - when: ansible_os_family == 'Alpine' diff --git a/provisioning/php/ubuntu-12.04/bin/service.d/php-fpm.sh b/provisioning/php/ubuntu-12.04/bin/service.d/php-fpm.sh index 1653587a5..e5b667d49 100644 --- a/provisioning/php/ubuntu-12.04/bin/service.d/php-fpm.sh +++ b/provisioning/php/ubuntu-12.04/bin/service.d/php-fpm.sh @@ -4,4 +4,4 @@ source /opt/docker/bin/config.sh includeScriptDir "/opt/docker/bin/service.d/php-fpm.d/" -exec /usr/sbin/php5-fpm +exec /usr/local/bin/php-fpm diff --git a/provisioning/samson-deployment/general/bin/service.d/nginx.d/10-init.sh b/provisioning/samson-deployment/general/bin/service.d/nginx.d/10-init.sh index 52df52c8e..47e13a4d4 100644 --- a/provisioning/samson-deployment/general/bin/service.d/nginx.d/10-init.sh +++ b/provisioning/samson-deployment/general/bin/service.d/nginx.d/10-init.sh @@ -2,5 +2,9 @@ ln -f -s /var/lib/nginx/logs /var/log/nginx # Replace markers -find /opt/docker/etc/nginx/ -iname '*.conf' -print0 | xargs -0 -r rpl --quiet "" "$WEB_ALIAS_DOMAIN" > /dev/null -find /opt/docker/etc/nginx/ -iname '*.conf' -print0 | xargs -0 -r rpl --quiet "" "$HOSTNAME" > /dev/null +go-replace \ + -s "" -r "$WEB_ALIAS_DOMAIN" \ + -s "" -r "$HOSTNAME" \ + --path=/opt/docker/etc/nginx/ \ + --path-pattern='*.conf' \ + --ignore-empty diff --git a/provisioning/varnish/general/bin/entrypoint.d/varnishd.sh b/provisioning/varnish/general/bin/entrypoint.d/varnishd.sh index d9854a5a2..8879926cd 100644 --- a/provisioning/varnish/general/bin/entrypoint.d/varnishd.sh +++ b/provisioning/varnish/general/bin/entrypoint.d/varnishd.sh @@ -33,13 +33,10 @@ if [[ -z "$VARNISH_PORT" ]]; then exit 1 fi -if [[ -n "$VARNISH_BACKEND_HOST" ]]; then - rpl --quiet "" "$VARNISH_BACKEND_HOST" "$VARNISH_CONFIG" > /dev/null -fi - -if [[ -n "$VARNISH_BACKEND_PORT" ]]; then - rpl --quiet "" "$VARNISH_BACKEND_PORT" "$VARNISH_CONFIG" > /dev/null -fi +go-replace \ + -s "" -r "$VARNISH_BACKEND_HOST" \ + -s "" -r "$VARNISH_BACKEND_PORT" \ + -- "$VARNISH_CONFIG" echo " Starting varnishd..." echo " listening on: 0.0.0.0:${VARNISH_PORT}" diff --git a/template/Dockerfile/docker.jinja2 b/template/Dockerfile/docker.jinja2 index 51945f90b..dc17193b9 100644 --- a/template/Dockerfile/docker.jinja2 +++ b/template/Dockerfile/docker.jinja2 @@ -7,10 +7,10 @@ FROM {{ image }}:{{ tag }} {%- endmacro %} {% macro version() -%} -MAINTAINER info@webdevops.io -LABEL vendor=WebDevOps.io -LABEL io.webdevops.layout=8 -LABEL io.webdevops.version=1.5.0 +LABEL maintainer=info@webdevops.io \ + vendor=WebDevOps.io \ + io.webdevops.layout=8 \ + io.webdevops.version=1.5.0 {%- endmacro %} {%- macro add(source, target) -%} @@ -41,3 +41,7 @@ ENTRYPOINT ["{{ command }}"] {%- macro cmd(command) -%} CMD ["{{ command }}"] {%- endmacro -%} + +{%- macro cleanup() -%} + && docker-image-cleanup +{%- endmacro -%} diff --git a/template/Dockerfile/environment.jinja2 b/template/Dockerfile/environment.jinja2 index 6fdbf56c8..c043c76f1 100644 --- a/template/Dockerfile/environment.jinja2 +++ b/template/Dockerfile/environment.jinja2 @@ -1,56 +1,66 @@ -{% macro general(charset="en_US.UTF-8") -%} -ENV TERM "xterm" -ENV LANG "{{ charset }}" -ENV LC_ALL "{{ charset }}" +{% macro general(charset="C.UTF-8") -%} +ENV TERM="xterm" \ + LANG="{{ charset }}" \ + LC_ALL="{{ charset }}" {%- endmacro %} -{% macro homePath() -%} -ENV DOCKER_CONF_HOME /opt/docker/ -{%- endmacro %} {% macro mailbox() -%} -ENV MAILBOX_USERNAME "dev" -ENV MAILBOX_PASSWORD "dev" +ENV MAILBOX_USERNAME="dev" \ + MAILBOX_PASSWORD="dev" {%- endmacro %} + {% macro web() -%} -ENV WEB_DOCUMENT_ROOT /app -ENV WEB_DOCUMENT_INDEX index.php -ENV WEB_ALIAS_DOMAIN *.vm +ENV WEB_DOCUMENT_ROOT=/app \ + WEB_DOCUMENT_INDEX=index.php \ + WEB_ALIAS_DOMAIN=*.vm {%- endmacro %} + {% macro webPhp() -%} -ENV WEB_PHP_SOCKET 127.0.0.1:9000 +ENV WEB_PHP_SOCKET=127.0.0.1:9000 {%- endmacro %} + {% macro webDevelopment() -%} -ENV WEB_NO_CACHE_PATTERN "\.(css|js|gif|png|jpg|svg|json|xml)$" +ENV WEB_NO_CACHE_PATTERN="\.(css|js|gif|png|jpg|svg|json|xml)$" {%- endmacro %} + {% macro ftp() -%} -ENV FTP_USER application -ENV FTP_PASSWORD application -ENV FTP_UID 1000 -ENV FTP_GID 1000 -ENV FTP_PATH /data/ftp/ +ENV FTP_USER=application \ + FTP_PASSWORD=application \ + FTP_UID=1000 \ + FTP_GID=1000 \ + FTP_PATH=/data/ftp/ {%- endmacro %} -{% macro app() -%} -ENV APPLICATION_USER application -ENV APPLICATION_GROUP application -ENV APPLICATION_PATH /app -ENV APPLICATION_UID 1000 -ENV APPLICATION_GID 1000 + +{% macro base() -%} +ENV DOCKER_CONF_HOME=/opt/docker/ \ + LOG_STDOUT="" \ + LOG_STDERR="" {%- endmacro %} + +{% macro baseApp() -%} +ENV APPLICATION_USER=application \ + APPLICATION_GROUP=application \ + APPLICATION_PATH=/app \ + APPLICATION_UID=1000 \ + APPLICATION_GID=1000 +{%- endmacro %} + + {% macro liquibase(version, driver, classpath) -%} -ENV LIQUIBASE_VERSION "{{ version }}" -ENV LIQUIBASE_DRIVER "{{ driver }}" -ENV LIQUIBASE_CLASSPATH "{{ classpath }}" -ENV LIQUIBASE_URL "" -ENV LIQUIBASE_USERNAME "" -ENV LIQUIBASE_PASSWORD "" -ENV LIQUIBASE_CHANGELOG "liquibase.xml" -ENV LIQUIBASE_CONTEXTS "" -ENV LIQUIBASE_OPTS "" +ENV LIQUIBASE_VERSION="{{ version }}" \ + LIQUIBASE_DRIVER="{{ driver }}" \ + LIQUIBASE_CLASSPATH="{{ classpath }}" \ + LIQUIBASE_URL="" \ + LIQUIBASE_USERNAME="" \ + LIQUIBASE_PASSWORD="" \ + LIQUIBASE_CHANGELOG="liquibase.xml" \ + LIQUIBASE_CONTEXTS="" \ + LIQUIBASE_OPTS="" {%- endmacro %} diff --git a/template/Dockerfile/images/ansible.jinja2 b/template/Dockerfile/images/ansible.jinja2 new file mode 100644 index 000000000..99f16ed36 --- /dev/null +++ b/template/Dockerfile/images/ansible.jinja2 @@ -0,0 +1,104 @@ +{% import 'Dockerfile/docker.jinja2' as docker %} + +{% macro alpine() -%} +# Install ansible +RUN /usr/local/bin/apk-install \ + python \ + python-dev \ + py-setuptools \ + py-crypto \ + py2-pip \ + py-cparser \ + py-cryptography \ + py-markupsafe \ + py-cffi \ + py-yaml \ + py-jinja2 \ + py-paramiko \ + && pip install --upgrade pip \ + && hash -r \ + && pip install --no-cache-dir ansible \ + && chmod 750 /usr/bin/ansible* \ + # Cleanup + && apk del python-dev \ + {{ docker.cleanup() }} +{%- endmacro %} + + +{% macro centos() -%} +# Install ansible +RUN /usr/local/bin/yum-install \ + epel-release \ + PyYAML \ + python-jinja2 \ + python-httplib2 \ + python-keyczar \ + python-paramiko \ + python-setuptools \ + python-setuptools-devel \ + libffi \ + python-devel \ + libffi-devel \ + && easy_install pip \ + && pip install --upgrade pip \ + && hash -r \ + && pip install --no-cache-dir ansible \ + && chmod 750 /usr/bin/ansible* \ + # Cleanup + && yum erase -y python-devel \ + {{ docker.cleanup() }} +{%- endmacro %} + + +{% macro debian(distribution) -%} +# Install ansible +RUN /usr/local/bin/apt-install \ + # Install ansible + python-minimal \ + python-setuptools \ + python-pip \ + python-paramiko \ + python-jinja2 \ + python-dev \ + libffi-dev \ + libssl-dev \ + build-essential \ + && pip install --upgrade pip \ + && hash -r \ + && pip install --no-cache-dir ansible \ + && chmod 750 /usr/local/bin/ansible* \ + # Cleanup + && apt-get purge -y -f --force-yes \ + python-dev \ + build-essential \ + libssl-dev \ + libffi-dev \ + {{ docker.cleanup() }} +{%- endmacro %} + + +{% macro ubuntu() -%} +# Install ansible +RUN /usr/local/bin/apt-install \ + python-minimal \ + python-setuptools \ + python-pip \ + python-paramiko \ + python-jinja2 \ + python-dev \ + libffi-dev \ + libssl-dev \ + build-essential \ + && pip install --upgrade pip \ + && hash -r \ + && pip install --no-cache-dir ansible \ + && chmod 750 /usr/local/bin/ansible* \ + # Cleanup + && apt-get purge -y -f --force-yes \ + python-dev \ + build-essential \ + libssl-dev \ + libffi-dev \ + {{ docker.cleanup() }} +{%- endmacro %} + diff --git a/template/Dockerfile/images/apache-dev.jinja2 b/template/Dockerfile/images/apache-dev.jinja2 index 31c788030..4b272d746 100644 --- a/template/Dockerfile/images/apache-dev.jinja2 +++ b/template/Dockerfile/images/apache-dev.jinja2 @@ -1,7 +1,9 @@ +{% import 'Dockerfile/docker.jinja2' as docker %} {% import 'Dockerfile/provision.jinja2' as provision %} {% macro general(role='') -%} # Install apache RUN echo \ - {{ provision.runRoleInline('apache-dev', role) }} + {{ provision.runRoleInline('apache-dev', role) }} \ + {{ docker.cleanup() }} {%- endmacro %} diff --git a/template/Dockerfile/images/apache.jinja2 b/template/Dockerfile/images/apache.jinja2 index c1dc03abf..4e2268ef4 100644 --- a/template/Dockerfile/images/apache.jinja2 +++ b/template/Dockerfile/images/apache.jinja2 @@ -1,3 +1,4 @@ +{% import 'Dockerfile/docker.jinja2' as docker %} {% import 'Dockerfile/provision.jinja2' as provision %} {% macro alpine(role='') -%} @@ -11,7 +12,8 @@ RUN /usr/local/bin/apk-install \ s!^(\s*CustomLog)\s+\S+!\1 /proc/self/fd/1!g; \ s!^(\s*ErrorLog)\s+\S+!\1 /proc/self/fd/2!g; \ ' /etc/apache2/httpd.conf \ - {{ provision.runRoleInline('apache', role) }} + {{ provision.runRoleInline('apache', role) }} \ + {{ docker.cleanup() }} {%- endmacro %} @@ -24,7 +26,8 @@ RUN /usr/local/bin/yum-install \ s!^(\s*CustomLog)\s+\S+!\1 /proc/self/fd/1!g; \ s!^(\s*ErrorLog)\s+\S+!\1 /proc/self/fd/2!g; \ ' /etc/httpd/conf/httpd.conf /etc/httpd/conf.d/ssl.conf \ - {{ provision.runRoleInline('apache', role) }} + {{ provision.runRoleInline('apache', role) }} \ + {{ docker.cleanup() }} {%- endmacro %} @@ -40,7 +43,8 @@ RUN /usr/local/bin/apt-install \ ' /etc/apache2/apache2.conf \ && rm -f /etc/apache2/sites-enabled/* \ && a2enmod actions fastcgi ssl rewrite headers expires \ - {{ provision.runRoleInline('apache', role) }} + {{ provision.runRoleInline('apache', role) }} \ + {{ docker.cleanup() }} {%- endmacro %} {% macro debian8(role='') -%} @@ -54,7 +58,8 @@ RUN /usr/local/bin/apt-install \ ' /etc/apache2/apache2.conf \ && rm -f /etc/apache2/sites-enabled/* \ && a2enmod actions proxy proxy_fcgi ssl rewrite headers expires \ - {{ provision.runRoleInline('apache', role) }} + {{ provision.runRoleInline('apache', role) }} \ + {{ docker.cleanup() }} {%- endmacro %} @@ -68,7 +73,8 @@ RUN /usr/local/bin/apt-install \ ' /etc/apache2/apache2.conf \ && rm -f /etc/apache2/sites-enabled/* \ && a2enmod actions proxy proxy_fcgi ssl rewrite headers expires \ - {{ provision.runRoleInline('apache', role) }} + {{ provision.runRoleInline('apache', role) }} \ + {{ docker.cleanup() }} {%- endmacro %} @@ -85,7 +91,8 @@ RUN /usr/local/bin/apt-install \ && rm -f /etc/apache2/sites-enabled/* \ && a2enmod actions fastcgi ssl rewrite headers version expires \ && mkdir -p /var/lock/apache2 \ - {{ provision.runRoleInline('apache', role) }} + {{ provision.runRoleInline('apache', role) }} \ + {{ docker.cleanup() }} {%- endmacro %} @@ -102,7 +109,8 @@ RUN /usr/local/bin/apt-install \ && rm -f /etc/apache2/sites-enabled/* \ && a2enmod actions fastcgi ssl rewrite headers expires \ && mkdir -p /var/lock/apache2 \ - {{ provision.runRoleInline('apache', role) }} + {{ provision.runRoleInline('apache', role) }} \ + {{ docker.cleanup() }} {%- endmacro %} @@ -117,7 +125,8 @@ RUN /usr/local/bin/apt-install \ && rm -f /etc/apache2/sites-enabled/* \ && ln -sf /opt/docker/etc/httpd/main.conf /etc/apache2/sites-enabled/10-docker.conf \ && a2enmod actions proxy proxy_fcgi ssl rewrite headers expires \ - {{ provision.runRoleInline('apache', role) }} + {{ provision.runRoleInline('apache', role) }} \ + {{ docker.cleanup() }} {%- endmacro %} @@ -132,5 +141,6 @@ RUN /usr/local/bin/apt-install \ && rm -f /etc/apache2/sites-enabled/* \ && ln -sf /opt/docker/etc/httpd/main.conf /etc/apache2/sites-enabled/10-docker.conf \ && a2enmod actions proxy proxy_fcgi ssl rewrite headers expires \ - {{ provision.runRoleInline('apache', role) }} + {{ provision.runRoleInline('apache', role) }} \ + {{ docker.cleanup() }} {%- endmacro %} diff --git a/template/Dockerfile/images/base.jinja2 b/template/Dockerfile/images/base.jinja2 index 1700c1ebd..58ffaabf2 100644 --- a/template/Dockerfile/images/base.jinja2 +++ b/template/Dockerfile/images/base.jinja2 @@ -1,3 +1,4 @@ +{% import 'Dockerfile/docker.jinja2' as docker %} {% import 'Dockerfile/provision.jinja2' as provision %} {% macro alpine(role='') -%} @@ -5,14 +6,13 @@ RUN chmod +x /opt/docker/bin/* \ && /usr/local/bin/apk-install \ supervisor \ - syslog-ng \ - logrotate \ wget \ curl \ sed \ gnupg \ && chmod +s /usr/local/bin/gosu \ - {{ provision.runRoleInline('base', role) }} + {{ provision.runRoleInline('base', role) }} \ + {{ docker.cleanup() }} {%- endmacro %} @@ -20,16 +20,14 @@ RUN chmod +x /opt/docker/bin/* \ # Install services RUN chmod +x /opt/docker/bin/* \ && /usr/local/bin/yum-install \ - cronie \ supervisor \ - syslog-ng \ - logrotate \ wget \ curl \ net-tools \ gnupg2 \ && chmod +s /usr/local/bin/gosu \ - {{ provision.runRoleInline('base', role) }} + {{ provision.runRoleInline('base', role) }} \ + {{ docker.cleanup() }} {%- endmacro %} @@ -38,16 +36,13 @@ RUN chmod +x /opt/docker/bin/* \ RUN chmod +x /opt/docker/bin/* \ && /usr/local/bin/apt-install \ supervisor \ - syslog-ng \ - syslog-ng-core \ - logrotate \ - cron \ wget \ curl \ net-tools \ gnupg \ && chmod +s /usr/local/bin/gosu \ - {{ provision.runRoleInline('base', role) }} + {{ provision.runRoleInline('base', role) }} \ + {{ docker.cleanup() }} {%- endmacro %} @@ -56,14 +51,11 @@ RUN chmod +x /opt/docker/bin/* \ RUN chmod +x /opt/docker/bin/* \ && /usr/local/bin/apt-install \ supervisor \ - syslog-ng \ - syslog-ng-core \ - logrotate \ - cron \ wget \ curl \ net-tools \ gnupg \ && chmod +s /usr/local/bin/gosu \ - {{ provision.runRoleInline('base', role) }} + {{ provision.runRoleInline('base', role) }} \ + {{ docker.cleanup() }} {%- endmacro %} diff --git a/template/Dockerfile/images/baseapp.jinja2 b/template/Dockerfile/images/baseapp.jinja2 index 9779ffa3e..9bb80b19d 100644 --- a/template/Dockerfile/images/baseapp.jinja2 +++ b/template/Dockerfile/images/baseapp.jinja2 @@ -1,16 +1,10 @@ +{% import 'Dockerfile/docker.jinja2' as docker %} {% import 'Dockerfile/provision.jinja2' as provision %} {% macro alpine(role='') -%} RUN /usr/local/bin/apk-install-edge shadow \ && /usr/local/bin/apk-install \ - # Install services - openssh \ - mysql-client \ - sqlite \ - dnsmasq \ - postfix \ # Install common tools - sudo \ zip \ unzip \ bzip2 \ @@ -22,22 +16,15 @@ RUN /usr/local/bin/apk-install-edge shadow \ openssh-client \ rsync \ git \ - nano \ - vim \ - {{ provision.runRoleInline('base-app', role) }} + {{ provision.runRoleInline('base-app', role) }} \ + {{ docker.cleanup() }} {%- endmacro %} {% macro centos(role='') -%} # Install services RUN /usr/local/bin/yum-install \ - openssh-server \ - mysql \ - sqlite \ - dnsmasq \ - postfix \ # Install tools - sudo \ zip \ unzip \ bzip2 \ @@ -50,24 +37,16 @@ RUN /usr/local/bin/yum-install \ rsync \ git \ pygpgme \ - nano \ - vim \ && /usr/local/bin/generate-locales \ - {{ provision.runRoleInline('base-app', role) }} + {{ provision.runRoleInline('base-app', role) }} \ + {{ docker.cleanup() }} {%- endmacro %} {% macro debian(role='') -%} # Install services RUN /usr/local/bin/apt-install \ - # Install services - openssh-server \ - mysql-client \ - sqlite \ - dnsmasq \ - postfix \ # Install common tools - sudo \ zip \ unzip \ bzip2 \ @@ -79,23 +58,15 @@ RUN /usr/local/bin/apt-install \ openssh-client \ rsync \ git \ - nano \ - vim \ && /usr/local/bin/generate-locales \ - {{ provision.runRoleInline('base-app', role) }} + {{ provision.runRoleInline('base-app', role) }} \ + {{ docker.cleanup() }} {%- endmacro %} {% macro debian9(role='') -%} # Install services RUN /usr/local/bin/apt-install \ - # Install services - openssh-server \ - mariadb-client \ - sqlite \ - dnsmasq \ - postfix \ # Install common tools - sudo \ zip \ unzip \ bzip2 \ @@ -107,23 +78,15 @@ RUN /usr/local/bin/apt-install \ openssh-client \ rsync \ git \ - nano \ - vim \ && /usr/local/bin/generate-locales \ - {{ provision.runRoleInline('base-app', role) }} + {{ provision.runRoleInline('base-app', role) }} \ + {{ docker.cleanup() }} {%- endmacro %} {% macro ubuntu(role='') -%} # Install services RUN /usr/local/bin/apt-install \ - # Install services - openssh-server \ - mysql-client \ - sqlite \ - dnsmasq \ - postfix \ # Install common tools - sudo \ zip \ unzip \ bzip2 \ @@ -135,9 +98,8 @@ RUN /usr/local/bin/apt-install \ openssh-client \ rsync \ git \ - nano \ - vim \ && mkdir -p /var/lib/syslog-ng/ \ && /usr/local/bin/generate-locales \ - {{ provision.runRoleInline('base-app', role) }} + {{ provision.runRoleInline('base-app', role) }} \ + {{ docker.cleanup() }} {%- endmacro %} diff --git a/template/Dockerfile/images/bootstrap.jinja2 b/template/Dockerfile/images/bootstrap.jinja2 index 687adddc6..3177fa577 100644 --- a/template/Dockerfile/images/bootstrap.jinja2 +++ b/template/Dockerfile/images/bootstrap.jinja2 @@ -1,8 +1,9 @@ +{% import 'Dockerfile/docker.jinja2' as docker %} +{% import 'Dockerfile/tools.jinja2' as tools %} + {% macro alpine() -%} -# Init bootstrap (and install ansible) +# Init bootstrap RUN set -x \ - # Fix root terminal - && echo "export TERM=xterm" >> /root/.bashrc \ # Add community && echo http://dl-4.alpinelinux.org/alpine/v3.5/community/ >> /etc/apk/repositories \ # System update @@ -11,24 +12,9 @@ RUN set -x \ && /usr/local/bin/apk-install \ bash \ ca-certificates \ - # Install ansible - && /usr/local/bin/apk-install \ - python \ - python-dev \ - py-setuptools \ - py-crypto \ - py2-pip \ - py-cparser \ - py-cryptography \ - py-markupsafe \ - py-cffi \ - py-yaml \ - py-jinja2 \ - py-paramiko \ - && pip install --upgrade pip \ - && hash -r \ - && pip install ansible \ - && chmod 750 /usr/bin/ansible* \ + openssl \ + && update-ca-certificates \ + && /usr/local/bin/generate-dockerimage-info \ # Install gosu && GOSU_VERSION=1.10 \ && apk add --no-cache --virtual .gosu-deps \ @@ -45,38 +31,20 @@ RUN set -x \ && chmod +x /usr/local/bin/gosu \ && gosu nobody true \ && apk del .gosu-deps \ - # Cleanup - && apk del python-dev \ - && find /var/log/ -mindepth 1 -delete + {{ tools.goreplace() }} + {{ docker.cleanup() }} {%- endmacro %} {% macro centos() -%} -# Init bootstrap (and install ansible) +# Init bootstrap RUN set -x \ - # Fix root terminal - && echo "export TERM=xterm" >> /root/.bashrc \ # System update && /usr/local/bin/yum-upgrade \ - # Install ansible && /usr/local/bin/yum-install \ epel-release \ - PyYAML \ - python-jinja2 \ - python-httplib2 \ - python-keyczar \ - python-paramiko \ - python-setuptools \ - python-setuptools-devel \ - libffi \ - python-devel \ - libffi-devel \ - && easy_install pip \ - && pip install --upgrade pip \ - && hash -r \ - && pip install ansible \ - && chmod 750 /usr/bin/ansible* \ + && /usr/local/bin/generate-dockerimage-info \ # Install gosu && GOSU_VERSION=1.10 \ && /usr/local/bin/yum-install gpg wget \ @@ -89,48 +57,27 @@ RUN set -x \ && rm -r "$GNUPGHOME" /usr/local/bin/gosu.asc \ && chmod +x /usr/local/bin/gosu \ && gosu nobody true \ + {{ tools.goreplace() }} && yum erase -y wget \ - # Cleanup - && yum erase -y python-devel \ - && yum clean all \ - && find /var/log/ -mindepth 1 -delete + {{ docker.cleanup() }} {%- endmacro %} {% macro debian(distribution) -%} -# Init bootstrap (and install ansible) -RUN export DEBIAN_FRONTEND=noninteractive \ - && set -x \ - # Fix root terminal - && echo "export TERM=xterm" >> /root/.bashrc \ +# Init bootstrap +RUN set -x \ + && apt-update \ + && /usr/local/bin/generate-dockerimage-info \ # Enable non-free - && sed -ri 's/(deb.*\/debian {{ distribution }} main)/\1 contrib non-free /' -- /etc/apt/sources.list \ - # System updatei + && sed -ri "s/(deb.*\/debian $(docker-image-info dist-codename) main)/\1 contrib non-free /" -- /etc/apt/sources.list \ + && apt-update \ + # System update && /usr/local/bin/apt-upgrade \ # Base stuff && /usr/local/bin/apt-install \ - lsb-release \ + apt-transport-https \ ca-certificates \ locales \ - apt-transport-https \ - # Generate base locale - && echo "en_US.UTF-8 UTF-8" > /etc/locale.gen \ - && locale-gen \ - && /usr/local/bin/apt-install \ - # Install ansible - python-minimal \ - python-setuptools \ - python-pip \ - python-paramiko \ - python-jinja2 \ - python-dev \ - libffi-dev \ - libssl-dev \ - build-essential \ - && pip install --upgrade pip \ - && hash -r \ - && pip install ansible \ - && chmod 750 /usr/local/bin/ansible* \ # Install gosu && GOSU_VERSION=1.10 \ && /usr/local/bin/apt-install wget gnupg dirmngr \ @@ -143,54 +90,30 @@ RUN export DEBIAN_FRONTEND=noninteractive \ && rm -rf "$GNUPGHOME" /usr/local/bin/gosu.asc \ && chmod +x /usr/local/bin/gosu \ && gosu nobody true \ + {{ tools.goreplace() }} && apt-get purge -y -f --force-yes wget dirmngr \ - # Cleanup - && apt-get purge -y -f --force-yes \ - python-dev \ - build-essential \ - libssl-dev \ - libffi-dev \ - && apt-get autoremove -y -f \ - && apt-get clean -y \ - && find /var/log/ -mindepth 1 -delete + {{ docker.cleanup() }} {%- endmacro %} {% macro ubuntu12() -%} -# Init bootstrap (and install ansible) -RUN export DEBIAN_FRONTEND=noninteractive \ - && set -x \ +# Init bootstrap +RUN set -x \ # Add multiverse && echo "deb http://archive.ubuntu.com/ubuntu/ precise-security multiverse" >> /etc/apt/sources.list \ && echo "deb-src http://archive.ubuntu.com/ubuntu/ precise-security multiverse" >> /etc/apt/sources.list \ && echo "deb http://archive.ubuntu.com/ubuntu/ precise multiverse" >> /etc/apt/sources.list \ && echo "deb-src http://archive.ubuntu.com/ubuntu/ precise multiverse" >> /etc/apt/sources.list \ - # Fix root terminal - && echo "export TERM=xterm" >> /root/.bashrc \ - # Generate base locale - && locale-gen en_US.UTF-8 \ + && apt-update \ # System update && /usr/local/bin/apt-upgrade \ # Install base stuff && /usr/local/bin/apt-install \ + apt-transport-https \ python-software-properties \ - lsb-release \ ca-certificates \ - # Install ansible - python-minimal \ - python-setuptools \ - python-pip \ - python-paramiko \ - python-jinja2 \ - python-dev \ - libffi-dev \ - libssl-dev \ - build-essential \ apt-transport-https \ - && pip install --upgrade pip \ - && hash -r \ - && pip install ansible \ - && chmod 750 /usr/local/bin/ansible* \ + && /usr/local/bin/generate-dockerimage-info \ # Install gosu && GOSU_VERSION=1.10 \ && /usr/local/bin/apt-install wget gnupg \ @@ -203,52 +126,25 @@ RUN export DEBIAN_FRONTEND=noninteractive \ && rm -r "$GNUPGHOME" /usr/local/bin/gosu.asc \ && chmod +x /usr/local/bin/gosu \ && gosu nobody true \ + {{ tools.goreplace() }} && apt-get purge -y -f --force-yes wget \ - # Cleanup - && apt-get purge -y -f --force-yes \ - python-dev \ - build-essential \ - libssl-dev \ - libffi-dev \ - && apt-get autoremove -y -f \ - && apt-get clean -y \ - && find /var/log/ -mindepth 1 -delete + {{ docker.cleanup() }} {%- endmacro %} {% macro ubuntu() -%} -# Init bootstrap (and install ansible) -RUN export DEBIAN_FRONTEND=noninteractive \ - && set -x \ - # Fix root terminal - && echo "export TERM=xterm" >> /root/.bashrc \ - # Generate base locale - && locale-gen en_US.UTF-8 \ +# Init bootstrap +RUN set -x \ + && apt-update \ # System update && /usr/local/bin/apt-upgrade \ # Install base stuff && /usr/local/bin/apt-install \ - software-properties-common \ - lsb-release \ ca-certificates \ apt-transport-https \ && apt-add-repository multiverse \ - # Install ansible - && /usr/local/bin/apt-install \ - python-minimal \ - python-setuptools \ - python-pip \ - python-paramiko \ - python-jinja2 \ - python-cffi \ - python-dev \ - libffi-dev \ - libssl-dev \ - build-essential \ - && pip install --upgrade pip \ - && hash -r \ - && pip install ansible \ - && chmod 750 /usr/local/bin/ansible* \ + && apt-update \ + && /usr/local/bin/generate-dockerimage-info \ # Install gosu && GOSU_VERSION=1.10 \ && /usr/local/bin/apt-install wget gnupg \ @@ -261,15 +157,8 @@ RUN export DEBIAN_FRONTEND=noninteractive \ && rm -r "$GNUPGHOME" /usr/local/bin/gosu.asc \ && chmod +x /usr/local/bin/gosu \ && gosu nobody true \ + {{ tools.goreplace() }} && apt-get purge -y -f --force-yes wget \ - # Cleanup - && apt-get purge -y -f --force-yes \ - python-dev \ - build-essential \ - libssl-dev \ - libffi-dev \ - && apt-get autoremove -y -f \ - && apt-get clean -y \ - && find /var/log/ -mindepth 1 -delete + {{ docker.cleanup() }} {%- endmacro %} diff --git a/template/Dockerfile/images/certbot.jinja2 b/template/Dockerfile/images/certbot.jinja2 index 13a530523..e9918c92c 100644 --- a/template/Dockerfile/images/certbot.jinja2 +++ b/template/Dockerfile/images/certbot.jinja2 @@ -15,5 +15,6 @@ RUN /usr/local/bin/apk-install \ certbot \ && pip install --upgrade pip \ && hash -r \ - && pip install pyRFC3339 configobj ConfigArgParse + && pip install pyRFC3339 configobj ConfigArgParse \ + {{ docker.cleanup() }} {%- endmacro %} diff --git a/template/Dockerfile/images/hhvm.jinja2 b/template/Dockerfile/images/hhvm.jinja2 index 6fd9bb196..e55428550 100644 --- a/template/Dockerfile/images/hhvm.jinja2 +++ b/template/Dockerfile/images/hhvm.jinja2 @@ -1,10 +1,11 @@ +{% import 'Dockerfile/docker.jinja2' as docker %} {% import 'Dockerfile/provision.jinja2' as provision %} {% macro ubuntu14(role='') -%} # Install hhvm environment RUN export DEBIAN_FRONTEND=noninteractive && set -x \ && apt-key adv --recv-keys --keyserver hkp://keyserver.ubuntu.com:80 0x5a16e7281be7a449 \ - && add-apt-repository "deb http://dl.hhvm.com/ubuntu $(lsb_release -sc) main" \ + && echo "deb http://dl.hhvm.com/ubuntu $(docker-image-info dist-codename) main" >> /etc/apt/sources.list \ && /usr/local/bin/apt-install \ hhvm \ imagemagick \ @@ -12,7 +13,8 @@ RUN export DEBIAN_FRONTEND=noninteractive && set -x \ ghostscript \ && /usr/bin/update-alternatives --install /usr/bin/php php /usr/bin/hhvm 60 \ && curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin/ --filename=composer \ - {{ provision.runRoleInline('hhvm', role) }} + {{ provision.runRoleInline('hhvm', role) }} \ + {{ docker.cleanup() }} {%- endmacro %} @@ -25,5 +27,6 @@ RUN /usr/local/bin/apt-install \ ghostscript \ && /usr/bin/update-alternatives --install /usr/bin/php php /usr/bin/hhvm 60 \ && curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin/ --filename=composer \ - {{ provision.runRoleInline('hhvm', role) }} + {{ provision.runRoleInline('hhvm', role) }} \ + {{ docker.cleanup() }} {%- endmacro %} diff --git a/template/Dockerfile/images/liquibase.jinja2 b/template/Dockerfile/images/liquibase.jinja2 index 2940e88c8..50c2e7622 100644 --- a/template/Dockerfile/images/liquibase.jinja2 +++ b/template/Dockerfile/images/liquibase.jinja2 @@ -1,3 +1,4 @@ +{% import 'Dockerfile/docker.jinja2' as docker %} {% import 'Dockerfile/provision.jinja2' as provision %} {% macro mysql(role='') -%} diff --git a/template/Dockerfile/images/liquidsoap.jinja2 b/template/Dockerfile/images/liquidsoap.jinja2 new file mode 100644 index 000000000..1502e93eb --- /dev/null +++ b/template/Dockerfile/images/liquidsoap.jinja2 @@ -0,0 +1,9 @@ +{% import 'Dockerfile/docker.jinja2' as docker %} +{% import 'Dockerfile/provision.jinja2' as provision %} + +{% macro ubuntu(role='') -%} +# Install services +RUN /usr/local/bin/apt-install \ + liquidsoap \ + {{ docker.cleanup() }} +{%- endmacro %} diff --git a/template/Dockerfile/images/mail-sandbox.jinja2 b/template/Dockerfile/images/mail-sandbox.jinja2 index 62536f146..0393f04e3 100644 --- a/template/Dockerfile/images/mail-sandbox.jinja2 +++ b/template/Dockerfile/images/mail-sandbox.jinja2 @@ -1,3 +1,4 @@ +{% import 'Dockerfile/docker.jinja2' as docker %} {% import 'Dockerfile/provision.jinja2' as provision %} {% macro ubuntu(role='') -%} @@ -8,7 +9,8 @@ RUN /usr/local/bin/apt-install \ && /opt/docker/bin/control.sh service.enable postfix \ && /opt/docker/bin/control.sh service.enable dovecot \ && /opt/docker/bin/provision add --tag entrypoint webdevops-mail-sandbox \ - {{ provision.runRoleInline('mail-sandbox', role) }} + {{ provision.runRoleInline('mail-sandbox', role) }} \ + {{ docker.cleanup() }} {%- endmacro %} {% macro roundcube(role='') -%} @@ -21,5 +23,6 @@ RUN cd /app \ && ls -l \ && rm -rf .git installer \ && ln -s /opt/docker/etc/roundcube/plugins/webdevops_autologin/ plugins/webdevops_autologin \ - && ln -s /opt/docker/etc/roundcube/config.php config/config.inc.php + && ln -s /opt/docker/etc/roundcube/config.php config/config.inc.php \ + {{ docker.cleanup() }} {%- endmacro %} diff --git a/template/Dockerfile/images/nginx-dev.jinja2 b/template/Dockerfile/images/nginx-dev.jinja2 index 4c92aa67e..aed2d3400 100644 --- a/template/Dockerfile/images/nginx-dev.jinja2 +++ b/template/Dockerfile/images/nginx-dev.jinja2 @@ -1,7 +1,9 @@ +{% import 'Dockerfile/docker.jinja2' as docker %} {% import 'Dockerfile/provision.jinja2' as provision %} {% macro general(role='') -%} # Install apache RUN echo \ - {{ provision.runRoleInline('nginx-dev', role) }} + {{ provision.runRoleInline('nginx-dev', role) }} \ + {{ docker.cleanup() }} {%- endmacro %} diff --git a/template/Dockerfile/images/nginx.jinja2 b/template/Dockerfile/images/nginx.jinja2 index 81e1b6956..a81c5cdbd 100644 --- a/template/Dockerfile/images/nginx.jinja2 +++ b/template/Dockerfile/images/nginx.jinja2 @@ -1,10 +1,12 @@ +{% import 'Dockerfile/docker.jinja2' as docker %} {% import 'Dockerfile/provision.jinja2' as provision %} {% macro alpine(role='') -%} # Install nginx RUN /usr/local/bin/apk-install \ nginx \ - {{ provision.runRoleInline('nginx', role) }} + {{ provision.runRoleInline('nginx', role) }} \ + {{ docker.cleanup() }} {%- endmacro %} @@ -12,7 +14,8 @@ RUN /usr/local/bin/apk-install \ # Install tools RUN /usr/local/bin/yum-install \ nginx \ - {{ provision.runRoleInline('nginx', role) }} + {{ provision.runRoleInline('nginx', role) }} \ + {{ docker.cleanup() }} {%- endmacro %} @@ -20,7 +23,8 @@ RUN /usr/local/bin/yum-install \ # Install nginx RUN /usr/local/bin/apt-install \ nginx \ - {{ provision.runRoleInline('nginx', role) }} + {{ provision.runRoleInline('nginx', role) }} \ + {{ docker.cleanup() }} {%- endmacro %} @@ -28,5 +32,6 @@ RUN /usr/local/bin/apt-install \ # Install nginx RUN /usr/local/bin/apt-install \ nginx \ - {{ provision.runRoleInline('nginx', role) }} + {{ provision.runRoleInline('nginx', role) }} \ + {{ docker.cleanup() }} {%- endmacro %} diff --git a/template/Dockerfile/images/php.jinja2 b/template/Dockerfile/images/php.jinja2 new file mode 100644 index 000000000..d9a4273ba --- /dev/null +++ b/template/Dockerfile/images/php.jinja2 @@ -0,0 +1,93 @@ +{% import 'Dockerfile/docker.jinja2' as docker %} +{% import 'Dockerfile/provision.jinja2' as provision %} +{% import 'Dockerfile/services.jinja2' as services %} + +{% macro official(role='', version='') -%} +# Install php environment +RUN /usr/local/bin/apt-install \ + # Install tools + imagemagick \ + graphicsmagick \ + ghostscript \ + # Libraries + libldap-2.4-2 \ + libxslt1.1 \ + zlib1g \ + libpng12-0 \ + libmcrypt4 \ + # Dev and headers + libbz2-dev \ + libldap2-dev \ + libldb-dev \ + libmcrypt-dev \ + libxml2-dev \ + libxslt1-dev \ + zlib1g-dev \ + libpng12-dev \ + # Install extensions + && docker-php-ext-install \ + bcmath \ + bz2 \ + calendar \ + exif \ + gettext \ + mysqli \ + mcrypt \ + hash \ + pcntl \ + pdo_mysql \ + soap \ + sockets \ + tokenizer \ + sysvmsg \ + sysvsem \ + sysvshm \ + shmop \ + xsl \ + zip \ + gd \ + gettext \ + opcache \ + # Uninstall dev and header packages + && apt-get purge -y -f --force-yes \ + libbz2-dev \ + libldap2-dev \ + libldb-dev \ + libmcrypt-dev \ + libxml2-dev \ + libxslt1-dev \ + zlib1g-dev \ + libpng12-dev \ +{%- if version|int == 5 %} + # Install extensions for PHP 5.x + && pecl install apcu-4.0.11 redis \ + && echo extension=apcu.so > /usr/local/etc/php/conf.d/apcu.ini \ + && echo extension=redis.so > /usr/local/etc/php/conf.d/redis.ini \ +{%- else %} + # Install extensions for PHP 7.x + && pecl install apcu redis \ + && echo extension=apcu.so > /usr/local/etc/php/conf.d/apcu.ini \ + && echo extension=redis.so > /usr/local/etc/php/conf.d/redis.ini \ +{%- endif %} + && rm -f /usr/local/etc/php-fpm.d/zz-docker.conf \ + && curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin/ --filename=composer \ + {{ provision.runRoleInline('php', role) }} \ + {{ docker.cleanup() }} + +WORKDIR / +{%- endmacro %} + + +{% macro officialDevelopment(role='', version='') -%} +# Install development environment +RUN wget -O - https://packagecloud.io/gpg.key | apt-key add - \ + && echo "deb https://packages.blackfire.io/debian any main" | tee /etc/apt/sources.list.d/blackfire.list \ + && /usr/local/bin/apt-install \ + blackfire-php \ + blackfire-agent \ + && pecl install xdebug \ + && echo "zend_extension=xdebug.so" > /usr/local/etc/php/conf.d/xdebug.ini \ + {{ services.phpDev() }} \ + {{ provision.runRoleInline('dev', 'php-dev', role) }} \ + {{ docker.cleanup() }} +{%- endmacro %} diff --git a/template/Dockerfile/images/php5-dev.jinja2 b/template/Dockerfile/images/php5-dev.jinja2 index ee3892e03..9b43a7229 100644 --- a/template/Dockerfile/images/php5-dev.jinja2 +++ b/template/Dockerfile/images/php5-dev.jinja2 @@ -1,4 +1,7 @@ +{% import 'Dockerfile/docker.jinja2' as docker %} {% import 'Dockerfile/provision.jinja2' as provision %} +{% import 'Dockerfile/services.jinja2' as services %} + {% macro alpine(role='') -%} # Install development environment @@ -7,7 +10,12 @@ RUN /usr/local/bin/apk-install \ graphviz \ # Install php development stuff php5-xdebug \ - {{ provision.runRoleInline('dev', 'php-dev', role) }} + # Tools + nano \ + vim \ + {{ services.phpDev() }} \ + {{ provision.runRoleInline('dev', 'php-dev', role) }} \ + {{ docker.cleanup() }} {%- endmacro %} @@ -21,7 +29,12 @@ RUN wget -O - "https://packages.blackfire.io/fedora/blackfire.repo" | tee /etc/y php-pecl-xdebug \ blackfire-php \ blackfire-agent \ - {{ provision.runRoleInline('dev', 'php-dev', role) }} + # Tools + nano \ + vim \ + {{ services.phpDev() }} \ + {{ provision.runRoleInline('dev', 'php-dev', role) }} \ + {{ docker.cleanup() }} {%- endmacro %} {% macro webtatic(role='') -%} @@ -33,7 +46,12 @@ RUN wget -O - "https://packages.blackfire.io/fedora/blackfire.repo" | tee /etc/y php56w-pecl-xdebug \ blackfire-php \ blackfire-agent \ - {{ provision.runRoleInline('dev', 'php-dev', role) }} + # Tools + nano \ + vim \ + {{ services.phpDev() }} \ + {{ provision.runRoleInline('dev', 'php-dev', role) }} \ + {{ docker.cleanup() }} {%- endmacro %} {% macro debian(role='') -%} @@ -47,7 +65,12 @@ RUN wget -O - https://packagecloud.io/gpg.key | apt-key add - \ php5-xdebug \ blackfire-php \ blackfire-agent \ - {{ provision.runRoleInline('dev', 'php-dev', role) }} + # Tools + nano \ + vim \ + {{ services.phpDev() }} \ + {{ provision.runRoleInline('dev', 'php-dev', role) }} \ + {{ docker.cleanup() }} {%- endmacro %} @@ -62,5 +85,10 @@ RUN wget -O - https://packagecloud.io/gpg.key | apt-key add - \ php5-xdebug \ blackfire-php \ blackfire-agent \ - {{ provision.runRoleInline('dev', 'php-dev', role) }} + # Tools + nano \ + vim \ + {{ services.phpDev() }} \ + {{ provision.runRoleInline('dev', 'php-dev', role) }} \ + {{ docker.cleanup() }} {%- endmacro %} diff --git a/template/Dockerfile/images/php5.jinja2 b/template/Dockerfile/images/php5.jinja2 index e57c491dc..a68f247a6 100644 --- a/template/Dockerfile/images/php5.jinja2 +++ b/template/Dockerfile/images/php5.jinja2 @@ -1,4 +1,6 @@ +{% import 'Dockerfile/docker.jinja2' as docker %} {% import 'Dockerfile/provision.jinja2' as provision %} +{% import 'Dockerfile/services.jinja2' as services %} {% macro alpine(role='') -%} # Install php environment @@ -57,7 +59,9 @@ RUN /usr/local/bin/apk-install \ && curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin/ --filename=composer \ # PECL workaround, see webdevops/Dockerfile#78 && sed -i "s/ -n / /" $(which pecl) \ - {{ provision.runRoleInline('php', role) }} + {{ services.php() }} \ + {{ provision.runRoleInline('php', role) }} \ + {{ docker.cleanup() }} {%- endmacro %} @@ -103,8 +107,9 @@ RUN /usr/local/bin/yum-install \ && curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin/ --filename=composer \ # Cleanup && yum erase -y php-devel gcc \ - && yum clean all \ - {{ provision.runRoleInline('php', role) }} + {{ services.php() }} \ + {{ provision.runRoleInline('php', role) }} \ + {{ docker.cleanup() }} {%- endmacro %} {% macro centosWebtatic(role='') -%} @@ -145,8 +150,9 @@ RUN rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm \ && curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin/ --filename=composer \ # Cleanup && yum erase -y php-devel gcc \ - && yum clean all \ - {{ provision.runRoleInline('php', role) }} + {{ services.php() }} \ + {{ provision.runRoleInline('php', role) }} \ + {{ docker.cleanup() }} {%- endmacro %} {% macro debian7(role='') -%} @@ -180,7 +186,9 @@ RUN /usr/local/bin/apt-install \ && ln -sf /etc/php5/mods-available/mcrypt.in /etc/php5/cli/conf.d/20-mcrypt.ini \ && ln -sf /etc/php5/mods-available/mcrypt.in /etc/php5/fpm/conf.d/20-mcrypt.ini \ && curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin/ --filename=composer \ - {{ provision.runRoleInline('php', role) }} + {{ services.php() }} \ + {{ provision.runRoleInline('php', role) }} \ + {{ docker.cleanup() }} {%- endmacro %} @@ -217,7 +225,9 @@ RUN /usr/local/bin/apt-install \ && ln -sf /etc/php5/mods-available/mcrypt.in /etc/php5/cli/conf.d/20-mcrypt.ini \ && ln -sf /etc/php5/mods-available/mcrypt.in /etc/php5/fpm/conf.d/20-mcrypt.ini \ && curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin/ --filename=composer \ - {{ provision.runRoleInline('php', role) }} + {{ services.php() }} \ + {{ provision.runRoleInline('php', role) }} \ + {{ docker.cleanup() }} {%- endmacro %} @@ -253,7 +263,9 @@ RUN /usr/local/bin/apt-install \ && ln -sf /etc/php5/mods-available/mcrypt.in /etc/php5/cli/conf.d/20-mcrypt.ini \ && ln -sf /etc/php5/mods-available/mcrypt.in /etc/php5/fpm/conf.d/20-mcrypt.ini \ && curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin/ --filename=composer \ - {{ provision.runRoleInline('php', role) }} + {{ services.php() }} \ + {{ provision.runRoleInline('php', role) }} \ + {{ docker.cleanup() }} {%- endmacro %} {% macro ubuntu12(role='') -%} @@ -288,7 +300,9 @@ RUN /usr/local/bin/apt-install \ && ln -sf /etc/php5/mods-available/mcrypt.in /etc/php5/cli/conf.d/20-mcrypt.ini \ && ln -sf /etc/php5/mods-available/mcrypt.in /etc/php5/fpm/conf.d/20-mcrypt.ini \ && curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin/ --filename=composer \ - {{ provision.runRoleInline('php', role) }} + {{ services.php() }} \ + {{ provision.runRoleInline('php', role) }} \ + {{ docker.cleanup() }} {%- endmacro %} @@ -325,7 +339,9 @@ RUN /usr/local/bin/apt-install \ && ln -sf /etc/php5/mods-available/mcrypt.in /etc/php5/cli/conf.d/20-mcrypt.ini \ && ln -sf /etc/php5/mods-available/mcrypt.in /etc/php5/fpm/conf.d/20-mcrypt.ini \ && curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin/ --filename=composer \ - {{ provision.runRoleInline('php', role) }} + {{ services.php() }} \ + {{ provision.runRoleInline('php', role) }} \ + {{ docker.cleanup() }} {%- endmacro %} {% macro ubuntu16(role='') -%} @@ -355,6 +371,8 @@ RUN /usr/local/bin/apt-install \ && ln -sf /etc/php5/mods-available/mcrypt.in /etc/php5/cli/conf.d/20-mcrypt.ini \ && ln -sf /etc/php5/mods-available/mcrypt.in /etc/php5/fpm/conf.d/20-mcrypt.ini \ && curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin/ --filename=composer \ - {{ provision.runRoleInline('php', role) }} + {{ services.php() }} \ + {{ provision.runRoleInline('php', role) }} \ + {{ docker.cleanup() }} {%- endmacro %} diff --git a/template/Dockerfile/images/php7-dev.jinja2 b/template/Dockerfile/images/php7-dev.jinja2 index 7acf1dcb4..a2fb003b3 100644 --- a/template/Dockerfile/images/php7-dev.jinja2 +++ b/template/Dockerfile/images/php7-dev.jinja2 @@ -1,4 +1,6 @@ +{% import 'Dockerfile/docker.jinja2' as docker %} {% import 'Dockerfile/provision.jinja2' as provision %} +{% import 'Dockerfile/services.jinja2' as services %} {% macro alpine(role='') -%} # Install development environment @@ -7,7 +9,9 @@ RUN /usr/local/bin/apk-install \ graphviz \ # Install php development stuff php7-xdebug \ - {{ provision.runRoleInline('dev', 'php-dev', role) }} + {{ services.phpDev() }} \ + {{ provision.runRoleInline('dev', 'php-dev', role) }} \ + {{ docker.cleanup() }} {%- endmacro %} @@ -21,7 +25,9 @@ RUN wget -O - "https://packages.blackfire.io/fedora/blackfire.repo" | tee /etc/y php7-xdebug \ blackfire-php \ blackfire-agent \ - {{ provision.runRoleInline('dev', 'php-dev', role) }} + {{ services.phpDev() }} \ + {{ provision.runRoleInline('dev', 'php-dev', role) }} \ + {{ docker.cleanup() }} {%- endmacro %} {% macro webtatic(role='') -%} @@ -33,7 +39,9 @@ RUN wget -O - "https://packages.blackfire.io/fedora/blackfire.repo" | tee /etc/y php70w-pecl-xdebug \ blackfire-php \ blackfire-agent \ - {{ provision.runRoleInline('dev', 'php-dev', role) }} + {{ services.phpDev() }} \ + {{ provision.runRoleInline('dev', 'php-dev', role) }} \ + {{ docker.cleanup() }} {%- endmacro %} {% macro debian(role='') -%} @@ -47,7 +55,9 @@ RUN wget -O - https://packagecloud.io/gpg.key | apt-key add - \ php-xdebug \ blackfire-php \ blackfire-agent \ - {{ provision.runRoleInline('dev', 'php-dev', role) }} + {{ services.phpDev() }} \ + {{ provision.runRoleInline('dev', 'php-dev', role) }} \ + {{ docker.cleanup() }} {%- endmacro %} {% macro debianDotDeb(role='') -%} @@ -61,7 +71,9 @@ RUN wget -O - https://packagecloud.io/gpg.key | apt-key add - \ php7.0-xdebug \ blackfire-php \ blackfire-agent \ - {{ provision.runRoleInline('dev', 'php-dev', role) }} + {{ services.phpDev() }} \ + {{ provision.runRoleInline('dev', 'php-dev', role) }} \ + {{ docker.cleanup() }} {%- endmacro %} {% macro debianSury(role='') -%} @@ -75,7 +87,9 @@ RUN wget -O - https://packagecloud.io/gpg.key | apt-key add - \ # php7.0-xdebug \ # Is currently not available blackfire-php \ blackfire-agent \ - {{ provision.runRoleInline('dev', 'php-dev', role) }} + {{ services.phpDev() }} \ + {{ provision.runRoleInline('dev', 'php-dev', role) }} \ + {{ docker.cleanup() }} {%- endmacro %} {% macro ubuntu(role='') -%} @@ -89,5 +103,7 @@ RUN wget -O - https://packagecloud.io/gpg.key | apt-key add - \ php-xdebug \ blackfire-php \ blackfire-agent \ - {{ provision.runRoleInline('dev', 'php-dev', role) }} + {{ services.phpDev() }} \ + {{ provision.runRoleInline('dev', 'php-dev', role) }} \ + {{ docker.cleanup() }} {%- endmacro %} diff --git a/template/Dockerfile/images/php7.jinja2 b/template/Dockerfile/images/php7.jinja2 index e1782e5f2..744ecd431 100644 --- a/template/Dockerfile/images/php7.jinja2 +++ b/template/Dockerfile/images/php7.jinja2 @@ -1,4 +1,6 @@ +{% import 'Dockerfile/docker.jinja2' as docker %} {% import 'Dockerfile/provision.jinja2' as provision %} +{% import 'Dockerfile/services.jinja2' as services %} {% macro alpine(role='') -%} # Install php environment @@ -62,7 +64,9 @@ RUN /usr/local/bin/apk-install \ && curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin/ --filename=composer \ # PECL workaround, see webdevops/Dockerfile#78 && sed -i "s/ -n / /" $(which pecl) \ - {{ provision.runRoleInline('php', role) }} + {{ services.php() }} \ + {{ provision.runRoleInline('php', role) }} \ + {{ docker.cleanup() }} {%- endmacro %} {% macro debianDotDeb(distribution,role='') -%} @@ -94,7 +98,9 @@ RUN echo "deb http://packages.dotdeb.org {{ distribution }} all" >> /etc/apt/sou php7.0-memcached \ php-apcu \ && curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin/ --filename=composer \ - {{ provision.runRoleInline('php', role) }} + {{ services.php() }} \ + {{ provision.runRoleInline('php', role) }} \ + {{ docker.cleanup() }} {%- endmacro %} {% macro debianSury(distribution,role='') -%} @@ -139,7 +145,9 @@ RUN /usr/local/bin/apt-install apt-transport-https lsb-release \ php7.0-mbstring \ php-apcu \ && curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin/ --filename=composer \ - {{ provision.runRoleInline('php', role) }} + {{ services.php() }} \ + {{ provision.runRoleInline('php', role) }} \ + {{ docker.cleanup() }} {%- endmacro %} {% macro debian9(role='') -%} @@ -173,7 +181,9 @@ RUN /usr/local/bin/apt-install \ php-memcache \ php-memcached \ && curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin/ --filename=composer \ - {{ provision.runRoleInline('php', role) }} + {{ services.php() }} \ + {{ provision.runRoleInline('php', role) }} \ + {{ docker.cleanup() }} {%- endmacro %} {% macro ubuntu(role='') -%} @@ -206,7 +216,9 @@ RUN /usr/local/bin/apt-install \ php-redis \ php-memcached \ && curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin/ --filename=composer \ - {{ provision.runRoleInline('php', role) }} + {{ services.php() }} \ + {{ provision.runRoleInline('php', role) }} \ + {{ docker.cleanup() }} {%- endmacro %} {% macro centosWebtatic(role='') -%} @@ -254,5 +266,7 @@ RUN rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm \ && rm -rf /tmp/* \ && echo "extension=redis.so" > /etc/php.d/redis.ini \ && yum remove -y ImageMagick-devel php70w-devel gcc make \ - {{ provision.runRoleInline('php', role) }} + {{ services.php() }} \ + {{ provision.runRoleInline('php', role) }} \ + {{ docker.cleanup() }} {%- endmacro %} diff --git a/template/Dockerfile/images/postfix.jinja2 b/template/Dockerfile/images/postfix.jinja2 index 215afde6b..f57b8a570 100644 --- a/template/Dockerfile/images/postfix.jinja2 +++ b/template/Dockerfile/images/postfix.jinja2 @@ -1,6 +1,8 @@ +{% import 'Dockerfile/docker.jinja2' as docker %} {% import 'Dockerfile/provision.jinja2' as provision %} {% macro ubuntu(role='') -%} -RUN /opt/docker/bin/control.sh service.enable postfix \ - {{ provision.runRoleInline('postfix', role) }} +RUN /opt/docker/bin/control.sh service.enable postfix syslog \ + {{ provision.runRoleInline('postfix', role) }} \ + {{ docker.cleanup() }} {%- endmacro %} diff --git a/template/Dockerfile/images/samson-deployment.jinja2 b/template/Dockerfile/images/samson-deployment.jinja2 index 27f08bb37..52cb987f0 100644 --- a/template/Dockerfile/images/samson-deployment.jinja2 +++ b/template/Dockerfile/images/samson-deployment.jinja2 @@ -1,3 +1,4 @@ +{% import 'Dockerfile/docker.jinja2' as docker %} {% import 'Dockerfile/provision.jinja2' as provision %} {% macro general(role='') -%} @@ -8,7 +9,7 @@ ENV SQLITE_CLEANUP_DAYS=0 # NGINX reverse proxy RUN export DEBIAN_FRONTEND=noninteractive && set -x \ && echo deb https://apt.dockerproject.org/repo debian-jessie main > /etc/apt/sources.list.d/docker.list \ - && curl -fsSL https://yum.dockerproject.org/gpg | sudo apt-key add - \ + && curl -fsSL https://yum.dockerproject.org/gpg | apt-key add - \ && /usr/local/bin/apt-install \ # Install nginx nginx \ @@ -30,7 +31,8 @@ RUN export DEBIAN_FRONTEND=noninteractive && set -x \ python-dotenv \ && curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin/ --filename=composer \ ## Enable ansible for deployment user - && chmod 755 /usr/local/bin/ansible* + && chmod 755 /usr/local/bin/ansible* \ + {{ docker.cleanup() }} # NPM stack RUN curl -sL https://deb.nodesource.com/setup_7.x | bash - \ @@ -39,7 +41,8 @@ RUN curl -sL https://deb.nodesource.com/setup_7.x | bash - \ && npm install -g gulp \ && npm install -g grunt-cli \ && npm install -g bower \ - && npm install -g npm-cache + && npm install -g npm-cache \ + {{ docker.cleanup() }} # Deployer stack RUN set -x \ @@ -60,7 +63,8 @@ RUN set -x \ && tar -xzf /tmp/magallanes.tar.gz -C /tmp/ \ && /tmp/magallanes/bin/mage install --installDir=/opt/magallanes \ && rm -rf /tmp/magallanes.tar.gz /tmp/magallanes/ \ - && ln -s /opt/magallanes/latest/bin/mage /usr/bin/mage + && ln -s /opt/magallanes/latest/bin/mage /usr/bin/mage \ + {{ docker.cleanup() }} # Upload ADD database.yml /app/config/database.yml diff --git a/template/Dockerfile/images/sphinx.jinja2 b/template/Dockerfile/images/sphinx.jinja2 index 318bb2e63..499338408 100644 --- a/template/Dockerfile/images/sphinx.jinja2 +++ b/template/Dockerfile/images/sphinx.jinja2 @@ -1,7 +1,12 @@ +{% import 'Dockerfile/docker.jinja2' as docker %} {% import 'Dockerfile/provision.jinja2' as provision %} {% macro alpine() -%} RUN /usr/local/bin/apk-install \ + # General python + python \ + py-crypto \ + py2-pip \ # General sphinx py-pillow \ py-yaml \ @@ -10,6 +15,8 @@ RUN /usr/local/bin/apk-install \ # GRAPHVIZ graphviz \ ttf-dejavu \ + && pip install --upgrade pip \ + && hash -r \ && pip install --upgrade sphinxcontrib-googlechart \ && pip install --upgrade sphinxcontrib-googlemaps \ && pip install --upgrade sphinxcontrib-httpdomain \ @@ -20,5 +27,6 @@ RUN /usr/local/bin/apk-install \ && pip install t3SphinxThemeRtd \ && pip install t3fieldlisttable \ && pip install t3tablerows \ - && pip install t3targets + && pip install t3targets \ + {{ docker.cleanup() }} {%- endmacro %} diff --git a/template/Dockerfile/images/ssh.jinja2 b/template/Dockerfile/images/ssh.jinja2 index 4f9b14256..ba5111b0a 100644 --- a/template/Dockerfile/images/ssh.jinja2 +++ b/template/Dockerfile/images/ssh.jinja2 @@ -1,5 +1,7 @@ +{% import 'Dockerfile/docker.jinja2' as docker %} {% import 'Dockerfile/provision.jinja2' as provision %} {% macro ubuntu() -%} -RUN /opt/docker/bin/control.sh service.enable ssh +RUN /opt/docker/bin/control.sh service.enable ssh \ + {{ docker.cleanup() }} {%- endmacro %} diff --git a/template/Dockerfile/images/typo3-solr.jinja2 b/template/Dockerfile/images/typo3-solr.jinja2 new file mode 100644 index 000000000..aab380f68 --- /dev/null +++ b/template/Dockerfile/images/typo3-solr.jinja2 @@ -0,0 +1,54 @@ +{% import 'Dockerfile/docker.jinja2' as docker %} +{% import 'Dockerfile/provision.jinja2' as provision %} + +{% macro guywithnose(release) -%} +USER root + +COPY ./solr/ /tmp/solr + +{{ docker.add('baselayout.tar', '/') }} + +WORKDIR / + +RUN pacman --sync --noconfirm --noprogressbar --quiet net-tools \ + && /usr/local/bin/generate-dockerimage-info \ + && rm -rf /opt/solr/server \ + && mv /opt/solr/example/ /opt/solr/server/ \ + && rm -rf /opt/solr/server/solr \ + && mv /tmp/solr /opt/solr/server/solr \ + && mkdir -p /opt/solr/server/solr/typo3lib \ + && curl -sf -o /opt/solr/server/solr/typo3lib/solr-typo3-plugin.jar -L https://github.com/TYPO3-Solr/solr-typo3-plugin/releases/download/release-{{ release|replace(".", "_") }}/solr-typo3-plugin-{{ release }}.jar \ + && ln -s /opt/solr/contrib /opt/solr/server/solr/contrib \ + && mkdir -p /opt/solr/server/solr/data \ + && ln -s /opt/solr/server/solr/data /opt/solr/server/solr/typo3cores/data \ + && chown -R solr:solr /opt/solr/server/solr/ \ + {{ docker.cleanup() }} + +USER solr + +WORKDIR /opt/solr/server + +VOLUME ["/opt/solr/server/solr/data"] +{%- endmacro %} + + +{% macro official() -%} +USER root + +{{ docker.add('baselayout.tar', '/') }} + +COPY ./solr/ /tmp/solr + +RUN /usr/local/bin/apt-update \ + && /usr/local/bin/apt-install net-tools \ + && /usr/local/bin/generate-dockerimage-info \ + && rm -rf /opt/solr/server/solr \ + && mv /tmp/solr /opt/solr/server/solr \ + && mkdir -p /opt/solr/server/solr/data \ + && chown -R solr:solr /opt/solr/server/solr \ + {{ docker.cleanup() }} + +USER solr + +VOLUME ["/opt/solr/server/solr/data"] +{%- endmacro %} diff --git a/template/Dockerfile/images/varnish.jinja2 b/template/Dockerfile/images/varnish.jinja2 index 80ba54f4a..da59f81e2 100644 --- a/template/Dockerfile/images/varnish.jinja2 +++ b/template/Dockerfile/images/varnish.jinja2 @@ -1,3 +1,4 @@ +{% import 'Dockerfile/docker.jinja2' as docker %} {% import 'Dockerfile/provision.jinja2' as provision %} {% macro env() -%} @@ -14,5 +15,6 @@ ENV VARNISH_BACKEND_PORT "80" {% macro alpine() -%} RUN /usr/local/bin/apk-install \ - varnish + varnish \ + {{ docker.cleanup() }} {%- endmacro %} diff --git a/template/Dockerfile/images/vsftp.jinja2 b/template/Dockerfile/images/vsftp.jinja2 index 56ae0a27e..fb2973b17 100644 --- a/template/Dockerfile/images/vsftp.jinja2 +++ b/template/Dockerfile/images/vsftp.jinja2 @@ -1,3 +1,4 @@ +{% import 'Dockerfile/docker.jinja2' as docker %} {% import 'Dockerfile/provision.jinja2' as provision %} {% macro ubuntu(role='') -%} @@ -9,5 +10,6 @@ RUN /usr/local/bin/apt-install \ /var/run/vsftpd/empty \ /var/log/supervisor \ {{ provision.registerRole('vsftp', entrypoint=True) }} \ - {{ provision.runRoleInline('vsftp', role) }} + {{ provision.runRoleInline('vsftp', role) }} \ + {{ docker.cleanup() }} {%- endmacro %} diff --git a/template/Dockerfile/layout.jinja2 b/template/Dockerfile/layout.jinja2 index 8ab05431e..c446f6a64 100644 --- a/template/Dockerfile/layout.jinja2 +++ b/template/Dockerfile/layout.jinja2 @@ -1,7 +1,9 @@ {% import 'Dockerfile/docker.jinja2' as docker %} {% import 'Dockerfile/provision.jinja2' as provision %} {% import 'Dockerfile/environment.jinja2' as environment %} +{% import 'Dockerfile/services.jinja2' as services %} +{% import 'Dockerfile/images/ansible.jinja2' as ansible %} {% import 'Dockerfile/images/bootstrap.jinja2' as bootstrap %} {% import 'Dockerfile/images/base.jinja2' as base %} {% import 'Dockerfile/images/baseapp.jinja2' as baseapp %} @@ -11,7 +13,9 @@ {% import 'Dockerfile/images/nginx-dev.jinja2' as nginxdev %} {% import 'Dockerfile/images/hhvm.jinja2' as hhvm %} {% import 'Dockerfile/images/postfix.jinja2' as postfix %} +{% import 'Dockerfile/images/liquidsoap.jinja2' as liquidsoap %} {% import 'Dockerfile/images/mail-sandbox.jinja2' as mailsandbox %} +{% import 'Dockerfile/images/php.jinja2' as php %} {% import 'Dockerfile/images/php5.jinja2' as php5 %} {% import 'Dockerfile/images/php7.jinja2' as php7 %} {% import 'Dockerfile/images/php5-dev.jinja2' as php5dev %} @@ -20,6 +24,7 @@ {% import 'Dockerfile/images/ssh.jinja2' as ssh %} {% import 'Dockerfile/images/vsftp.jinja2' as vsftp %} {% import 'Dockerfile/images/samson-deployment.jinja2' as samsonDeployment %} +{% import 'Dockerfile/images/typo3-solr.jinja2' as typo3Solr %} {% import 'Dockerfile/images/varnish.jinja2' as varnish %} {% import 'Dockerfile/images/certbot.jinja2' as certbot %} {% import 'Dockerfile/images/liquibase.jinja2' as liquibase %} diff --git a/template/Dockerfile/provision.jinja2 b/template/Dockerfile/provision.jinja2 index e777c9559..6a57f83db 100644 --- a/template/Dockerfile/provision.jinja2 +++ b/template/Dockerfile/provision.jinja2 @@ -3,8 +3,7 @@ {% if role %}--role webdevops-{{ role }} {% endif %} {%- endfor -%}{%- endfor -%} \{%- endif %} - && /opt/docker/bin/bootstrap.sh -{% endmacro %} + && /opt/docker/bin/bootstrap.sh{% endmacro %} {% macro registerRole(role='',bootstrap=False,build=False,onbuild=False,entrypoint=False) %}&& /opt/docker/bin/provision add {%if bootstrap%}--tag bootstrap {% endif %}{%if build%}--tag build {% endif %}{%if onbuild%}--tag onbuild {% endif %}{%if entrypoint%}--tag entrypoint {% endif %} webdevops-{{ role }}{% endmacro %} diff --git a/template/Dockerfile/services.jinja2 b/template/Dockerfile/services.jinja2 new file mode 100644 index 000000000..ddb956683 --- /dev/null +++ b/template/Dockerfile/services.jinja2 @@ -0,0 +1,11 @@ +{% macro php() -%} + # Enable php services + && docker-service-enable syslog cron +{%- endmacro %} + + +{% macro phpDev() -%} + # Enable php development services + && docker-service-enable syslog ssh postfix +{%- endmacro %} + diff --git a/template/Dockerfile/tools.jinja2 b/template/Dockerfile/tools.jinja2 new file mode 100644 index 000000000..6e2b94444 --- /dev/null +++ b/template/Dockerfile/tools.jinja2 @@ -0,0 +1,6 @@ +{% macro goreplace() -%} + ## Install go-replace + && GOREPLACE_VERSION=0.5.4 \ + && wget -O /usr/local/bin/go-replace https://github.com/webdevops/goreplace/releases/download/$GOREPLACE_VERSION/gr-64-linux \ + && chmod +x /usr/local/bin/go-replace \ +{%- endmacro %} diff --git a/tests/serverspec/Gemfile.lock b/tests/serverspec/Gemfile.lock index 6ae9d55bf..ee81cb515 100644 --- a/tests/serverspec/Gemfile.lock +++ b/tests/serverspec/Gemfile.lock @@ -2,15 +2,15 @@ GEM remote: https://rubygems.org/ specs: diff-lcs (1.3) - docker-api (1.33.2) + docker-api (1.33.4) excon (>= 0.38.0) json - excon (0.54.0) - json (2.0.3) + excon (0.55.0) + json (2.0.4) multi_json (1.12.1) net-scp (1.2.1) net-ssh (>= 2.6.5) - net-ssh (4.0.1) + net-ssh (4.1.0) net-telnet (0.1.1) rake (12.0.0) rspec (3.5.0) @@ -37,7 +37,7 @@ GEM rspec-its specinfra (~> 2.53) sfl (2.3) - specinfra (2.66.8) + specinfra (2.67.8) net-scp net-ssh (>= 2.7, < 5.0) net-telnet diff --git a/tests/serverspec/spec/collection/ansible.rb b/tests/serverspec/spec/collection/ansible.rb new file mode 100644 index 000000000..f170ecc69 --- /dev/null +++ b/tests/serverspec/spec/collection/ansible.rb @@ -0,0 +1,4 @@ +shared_examples 'collection::ansible' do + include_examples 'python::toolchain' + include_examples 'ansible::toolchain' +end diff --git a/tests/serverspec/spec/collection/base.rb b/tests/serverspec/spec/collection/base.rb index fe0616f7e..611d3261b 100644 --- a/tests/serverspec/spec/collection/base.rb +++ b/tests/serverspec/spec/collection/base.rb @@ -2,5 +2,6 @@ include_examples 'base::layout' include_examples 'base::packages' include_examples 'base::supervisor' - include_examples 'base::syslog-ng' + include_examples 'base::toolchain' + include_examples 'ansible::toolchain' end diff --git a/tests/serverspec/spec/collection/bootstrap.rb b/tests/serverspec/spec/collection/bootstrap.rb index de5615584..0936aff20 100644 --- a/tests/serverspec/spec/collection/bootstrap.rb +++ b/tests/serverspec/spec/collection/bootstrap.rb @@ -2,7 +2,6 @@ include_examples 'bootstrap::layout' include_examples 'bootstrap::distribution' include_examples 'bootstrap::toolchain' - include_examples 'bootstrap::ansible' if (os[:family] == 'alpine') include_examples 'vendor::alpine::apk' diff --git a/tests/serverspec/spec/collection/certbot.rb b/tests/serverspec/spec/collection/certbot.rb index 766d45761..79de26a2d 100644 --- a/tests/serverspec/spec/collection/certbot.rb +++ b/tests/serverspec/spec/collection/certbot.rb @@ -1,4 +1,6 @@ shared_examples 'collection::certbot' do + include_examples 'python::toolchain' + include_examples 'misc::letsencrypt' include_examples 'certbot::layout' end diff --git a/tests/serverspec/spec/collection/liquidsoap.rb b/tests/serverspec/spec/collection/liquidsoap.rb new file mode 100644 index 000000000..6be2c4ef2 --- /dev/null +++ b/tests/serverspec/spec/collection/liquidsoap.rb @@ -0,0 +1,4 @@ +shared_examples 'collection::liquidsoap' do + include_examples 'liquidsoap::listening::public' +end + diff --git a/tests/serverspec/spec/collection/php-tools.rb b/tests/serverspec/spec/collection/php-tools.rb index d6e5d6d06..6f68d4e34 100644 --- a/tests/serverspec/spec/collection/php-tools.rb +++ b/tests/serverspec/spec/collection/php-tools.rb @@ -1,6 +1,5 @@ shared_examples 'collection::php-tools' do include_examples 'php::tools' - include_examples 'misc::graphviz' end diff --git a/tests/serverspec/spec/collection/samson-deployment.rb b/tests/serverspec/spec/collection/samson-deployment.rb index 47b75ea75..e17f2ccbe 100644 --- a/tests/serverspec/spec/collection/samson-deployment.rb +++ b/tests/serverspec/spec/collection/samson-deployment.rb @@ -1,4 +1,7 @@ shared_examples 'collection::samson-deployment' do + include_examples 'python::toolchain' + include_examples 'ansible::toolchain::public' + include_examples 'samson-deployment::layout' include_examples 'samson-deployment::deployment' diff --git a/tests/serverspec/spec/docker/ansible_spec.rb b/tests/serverspec/spec/docker/ansible_spec.rb index fcf450086..6624cc1d7 100644 --- a/tests/serverspec/spec/docker/ansible_spec.rb +++ b/tests/serverspec/spec/docker/ansible_spec.rb @@ -8,5 +8,6 @@ end include_examples 'collection::bootstrap' + include_examples 'collection::ansible' end diff --git a/tests/serverspec/spec/docker/liquidsoap_spec.rb b/tests/serverspec/spec/docker/liquidsoap_spec.rb new file mode 100644 index 000000000..be66c975e --- /dev/null +++ b/tests/serverspec/spec/docker/liquidsoap_spec.rb @@ -0,0 +1,14 @@ +require 'serverspec' +require 'docker' +require 'spec_init' + +describe "Dockerfile" do + before(:all) do + set :docker_image, ENV['DOCKERIMAGE_ID'] + end + + include_examples 'collection::bootstrap' + include_examples 'collection::base' + include_examples 'collection::liquidsoap' + +end diff --git a/tests/serverspec/spec/docker/php-official_spec.rb b/tests/serverspec/spec/docker/php-official_spec.rb new file mode 100644 index 000000000..1cf32ab50 --- /dev/null +++ b/tests/serverspec/spec/docker/php-official_spec.rb @@ -0,0 +1,24 @@ +require 'serverspec' +require 'docker' +require 'spec_init' + +describe "Dockerfile" do + before(:all) do + set :docker_image, ENV['DOCKERIMAGE_ID'] + end + + include_examples 'collection::bootstrap' + include_examples 'collection::base' + include_examples 'collection::base-app' + + if ($testConfiguration[:php] == 5) + include_examples 'collection::php5::production' + include_examples 'collection::php-fpm5' + include_examples 'collection::php-fpm5::public' + else + include_examples 'collection::php7::production' + include_examples 'collection::php-fpm7' + include_examples 'collection::php-fpm7::public' + end + +end diff --git a/tests/serverspec/spec/docker/samson-deployment_spec.rb b/tests/serverspec/spec/docker/samson-deployment_spec.rb index 943ece68d..9ec7cc44d 100644 --- a/tests/serverspec/spec/docker/samson-deployment_spec.rb +++ b/tests/serverspec/spec/docker/samson-deployment_spec.rb @@ -9,7 +9,6 @@ include_examples 'bootstrap::layout' include_examples 'bootstrap::distribution' - include_examples 'bootstrap::toolchain' include_examples 'collection::base-app' include_examples 'collection::samson-deployment::php' diff --git a/tests/serverspec/spec/shared/ansible/toolchain.rb b/tests/serverspec/spec/shared/ansible/toolchain.rb new file mode 100644 index 000000000..0d365fd76 --- /dev/null +++ b/tests/serverspec/spec/shared/ansible/toolchain.rb @@ -0,0 +1,95 @@ +shared_examples 'ansible::toolchain' do + + ansibleList = [ + $testConfiguration[:ansiblePath] + "/ansible", + $testConfiguration[:ansiblePath] + "/ansible-playbook", + $testConfiguration[:ansiblePath] + "/ansible-galaxy", + $testConfiguration[:ansiblePath] + "/ansible-pull", + $testConfiguration[:ansiblePath] + "/ansible-doc", + $testConfiguration[:ansiblePath] + "/ansible-vault", + ].each do |file| + describe file("#{file}") do + # Type check + it { should be_file } + + # Owner test + it { should be_owned_by 'root' } + it { should be_grouped_into 'root' } + + # Read test + it { should be_readable.by('owner') } + it { should be_readable.by('group') } + it { should_not be_readable.by('others') } + + # Write test + it { should be_writable.by('owner') } + it { should_not be_writable.by('group') } + it { should_not be_writable.by('others') } + + # Exectuable test + it { should be_executable.by('owner') } + it { should be_executable.by('group') } + it { should_not be_executable.by('others') } + end + end + + describe command('ansible --version') do + its(:stdout) { should match $packageVersions[:ansible] } + + its(:exit_status) { should eq 0 } + end + + describe command('ansible-playbook --version') do + its(:stdout) { should match $packageVersions[:ansiblePlaybook] } + + its(:exit_status) { should eq 0 } + end +end + +shared_examples 'ansible::toolchain::public' do + + ansibleList = [ + $testConfiguration[:ansiblePath] + "/ansible", + $testConfiguration[:ansiblePath] + "/ansible-playbook", + $testConfiguration[:ansiblePath] + "/ansible-galaxy", + $testConfiguration[:ansiblePath] + "/ansible-pull", + $testConfiguration[:ansiblePath] + "/ansible-doc", + $testConfiguration[:ansiblePath] + "/ansible-vault", + ].each do |file| + describe file("#{file}") do + # Type check + it { should be_file } + + # Owner test + it { should be_owned_by 'root' } + it { should be_grouped_into 'root' } + + # Read test + it { should be_readable.by('owner') } + it { should be_readable.by('group') } + it { should be_readable.by('others') } + + # Write test + it { should be_writable.by('owner') } + it { should_not be_writable.by('group') } + it { should_not be_writable.by('others') } + + # Exectuable test + it { should be_executable.by('owner') } + it { should be_executable.by('group') } + it { should be_executable.by('others') } + end + end + + describe command('ansible --version') do + its(:stdout) { should match $packageVersions[:ansible] } + + its(:exit_status) { should eq 0 } + end + + describe command('ansible-playbook --version') do + its(:stdout) { should match $packageVersions[:ansiblePlaybook] } + + its(:exit_status) { should eq 0 } + end +end diff --git a/tests/serverspec/spec/shared/base/layout.rb b/tests/serverspec/spec/shared/base/layout.rb index e476a1c62..901531d36 100644 --- a/tests/serverspec/spec/shared/base/layout.rb +++ b/tests/serverspec/spec/shared/base/layout.rb @@ -51,7 +51,7 @@ "/opt/docker/etc/supervisor.conf", "/opt/docker/etc/logrotate.d/syslog-ng", "/opt/docker/etc/supervisor.d/cron.conf", - "/opt/docker/etc/supervisor.d/syslog-ng.conf", + "/opt/docker/etc/supervisor.d/syslog.conf", "/opt/docker/etc/syslog-ng/syslog-ng.conf", "/opt/docker/etc/supervisor.conf", "/opt/docker/etc/logrotate.d/syslog-ng", @@ -89,8 +89,6 @@ "/opt/docker/bin/config.sh", "/opt/docker/bin/control.sh", "/opt/docker/bin/entrypoint.sh", - "/opt/docker/bin/logwatch.sh", - "/opt/docker/bin/provision.sh", "/opt/docker/bin/service.d/syslog-ng.sh", "/opt/docker/bin/service.d/supervisor.sh", "/opt/docker/bin/entrypoint.d/cli.sh", @@ -98,6 +96,10 @@ "/opt/docker/bin/entrypoint.d/noop.sh", "/opt/docker/bin/entrypoint.d/root.sh", "/opt/docker/bin/entrypoint.d/supervisord.sh", + "/usr/local/bin/service", + "/usr/local/bin/docker-service-enable", + "/usr/local/bin/docker-service-disable", + "/usr/local/bin/docker-provision", ].each do |file| describe file("#{file}") do # Type check diff --git a/tests/serverspec/spec/shared/base/toolchain.rb b/tests/serverspec/spec/shared/base/toolchain.rb new file mode 100644 index 000000000..9e363f8d6 --- /dev/null +++ b/tests/serverspec/spec/shared/base/toolchain.rb @@ -0,0 +1,5 @@ +shared_examples 'base::toolchain' do + describe command('rpl --version') do + its(:exit_status) { should eq 0 } + end +end diff --git a/tests/serverspec/spec/shared/bootstrap/ansible.rb b/tests/serverspec/spec/shared/bootstrap/ansible.rb deleted file mode 100644 index ed1423e14..000000000 --- a/tests/serverspec/spec/shared/bootstrap/ansible.rb +++ /dev/null @@ -1,47 +0,0 @@ -shared_examples 'bootstrap::ansible' do - - ansibleList = [ - $testConfiguration[:ansiblePath] + "/ansible", - $testConfiguration[:ansiblePath] + "/ansible-playbook", - $testConfiguration[:ansiblePath] + "/ansible-galaxy", - $testConfiguration[:ansiblePath] + "/ansible-pull", - $testConfiguration[:ansiblePath] + "/ansible-doc", - $testConfiguration[:ansiblePath] + "/ansible-vault", - ].each do |file| - describe file("#{file}") do - # Type check - it { should be_file } - - # Owner test - it { should be_owned_by 'root' } - it { should be_grouped_into 'root' } - - # Read test - it { should be_readable.by('owner') } - it { should be_readable.by('group') } - it { should_not be_readable.by('others') } - - # Write test - it { should be_writable.by('owner') } - it { should_not be_writable.by('group') } - it { should_not be_writable.by('others') } - - # Exectuable test - it { should be_executable.by('owner') } - it { should be_executable.by('group') } - it { should_not be_executable.by('others') } - end - end - - describe command('ansible --version') do - its(:stdout) { should match $packageVersions[:ansible] } - - its(:exit_status) { should eq 0 } - end - - describe command('ansible-playbook --version') do - its(:stdout) { should match $packageVersions[:ansiblePlaybook] } - - its(:exit_status) { should eq 0 } - end -end diff --git a/tests/serverspec/spec/shared/bootstrap/distribution.rb b/tests/serverspec/spec/shared/bootstrap/distribution.rb index 89f945f34..ab627b0cd 100644 --- a/tests/serverspec/spec/shared/bootstrap/distribution.rb +++ b/tests/serverspec/spec/shared/bootstrap/distribution.rb @@ -4,6 +4,24 @@ # CentOS ######################### + describe command('docker-image-info family'), :if => os[:family] == 'redhat' do + its(:stdout) { should contain("RedHat") } + + its(:exit_status) { should eq 0 } + end + + describe command('docker-image-info dist'), :if => os[:family] == 'redhat' do + its(:stdout) { should contain("CentOS") } + + its(:exit_status) { should eq 0 } + end + + describe command('docker-image-info dist-version'), :if => os[:family] == 'redhat' do + its(:stdout) { should contain(os[:version]) } + + its(:exit_status) { should eq 0 } + end + describe command('cat /etc/redhat-release'), :if => os[:family] == 'redhat' do its(:stdout) { should contain('CentOS') } its(:stdout) { should contain('Linux release ' + os[:version] + '.') } @@ -15,14 +33,32 @@ # Ubuntu ######################### - describe command('lsb_release -i | tr "\t" " " | tr -s " "'), :if => os[:family] == 'ubuntu' do - its(:stdout) { should contain('Distributor ID: Ubuntu') } + describe command('docker-image-info family'), :if => os[:family] == 'ubuntu' do + its(:stdout) { should contain("Debian") } its(:exit_status) { should eq 0 } end - describe command('lsb_release -r | tr "\t" " " | tr -s " "'), :if => os[:family] == 'debian' do - its(:stdout) { should contain('Release: ' + os[:version]) } + describe command('docker-image-info dist'), :if => os[:family] == 'ubuntu' do + its(:stdout) { should contain("Ubuntu") } + + its(:exit_status) { should eq 0 } + end + + describe command('docker-image-info lsb'), :if => os[:family] == 'ubuntu' do + its(:stdout) { should contain("Distributor ID:\tUbuntu") } + + its(:exit_status) { should eq 0 } + end + + describe command('docker-image-info dist-version'), :if => os[:family] == 'ubuntu' do + its(:stdout) { should contain(os[:version]) } + + its(:exit_status) { should eq 0 } + end + + describe command('docker-image-info lsb'), :if => os[:family] == 'ubuntu' do + its(:stdout) { should contain("Release:\t" + os[:version] + '.') } its(:exit_status) { should eq 0 } end @@ -31,15 +67,32 @@ # Debian ######################### - describe command('lsb_release -i | tr "\t" " " | tr -s " "'), :if => os[:family] == 'debian' do - its(:stdout) { should contain('Distributor ID: Debian') } + describe command('docker-image-info family'), :if => os[:family] == 'debian' do + its(:stdout) { should contain("Debian") } its(:exit_status) { should eq 0 } end + describe command('docker-image-info dist'), :if => os[:family] == 'debian' do + its(:stdout) { should contain("Debian") } - describe command('lsb_release -r | tr "\t" " " | tr -s " "'), :if => os[:family] == 'debian' do - its(:stdout) { should contain('Release: ' + os[:version] + '.') } + its(:exit_status) { should eq 0 } + end + + describe command('docker-image-info lsb'), :if => os[:family] == 'debian' do + its(:stdout) { should contain("Distributor ID:\tDebian") } + + its(:exit_status) { should eq 0 } + end + + describe command('docker-image-info dist-version'), :if => os[:family] == 'debian' do + its(:stdout) { should contain(os[:version]) } + + its(:exit_status) { should eq 0 } + end + + describe command('docker-image-info lsb'), :if => os[:family] == 'debian' do + its(:stdout) { should contain("Release:\t" + os[:version] + '.') } its(:exit_status) { should eq 0 } end @@ -48,6 +101,25 @@ # Alpine ######################### + describe command('docker-image-info family'), :if => os[:family] == 'alpine' do + its(:stdout) { should contain("Alpine") } + + its(:exit_status) { should eq 0 } + end + + + describe command('docker-image-info dist'), :if => os[:family] == 'alpine' do + its(:stdout) { should contain("Alpine") } + + its(:exit_status) { should eq 0 } + end + + describe command('docker-image-info dist-version'), :if => os[:family] == 'alpine' do + its(:stdout) { should contain(os[:version]) } + + its(:exit_status) { should eq 0 } + end + describe command('sed -e "s/^/Release: /" /etc/alpine-release'), :if => os[:family] == 'alpine' do its(:stdout) { should contain('Release: ' + os[:version] + '.') } diff --git a/tests/serverspec/spec/shared/bootstrap/layout.rb b/tests/serverspec/spec/shared/bootstrap/layout.rb index 99c63eb37..6058a80f3 100644 --- a/tests/serverspec/spec/shared/bootstrap/layout.rb +++ b/tests/serverspec/spec/shared/bootstrap/layout.rb @@ -40,7 +40,6 @@ "/usr/local/bin/apk-upgrade", "/usr/local/bin/apt-install", "/usr/local/bin/apt-upgrade", - "/usr/local/bin/service", "/usr/local/bin/yum-install", "/usr/local/bin/yum-upgrade", ].each do |file| diff --git a/tests/serverspec/spec/shared/bootstrap/toolchain.rb b/tests/serverspec/spec/shared/bootstrap/toolchain.rb index 2fa80796a..28df4dd01 100644 --- a/tests/serverspec/spec/shared/bootstrap/toolchain.rb +++ b/tests/serverspec/spec/shared/bootstrap/toolchain.rb @@ -1,22 +1,7 @@ shared_examples 'bootstrap::toolchain' do + describe command('go-replace --version') do + its(:stdout) { should match %r!goreplace[\s]+(version)?[\s]*[0-9]+\.[0-9]+\.[0-9]+! } - describe command('python --version') do - its(:exit_status) { should eq 0 } - end - - describe command('easy_install --version'), :if => ['debian', 'ubuntu', 'redhat'].include?(os[:family]) do - its(:exit_status) { should eq 0 } - end - - describe command('easy_install-2.7 --version'), :if => ['alpine'].include?(os[:family]) do - its(:exit_status) { should eq 0 } - end - - describe command('pip --help') do - its(:exit_status) { should eq 0 } - end - - describe command('rpl --version') do its(:exit_status) { should eq 0 } end end diff --git a/tests/serverspec/spec/shared/hhvm/listening.rb b/tests/serverspec/spec/shared/hhvm/listening.rb index 84b874e2f..fbfcc1f64 100644 --- a/tests/serverspec/spec/shared/hhvm/listening.rb +++ b/tests/serverspec/spec/shared/hhvm/listening.rb @@ -1,21 +1,17 @@ shared_examples 'hhvm::listening::public' do describe port(9000) do it "hhvm should be listening", :retry => 20, :retry_wait => 3 do - should be_listening.with('tcp') + should be_listening.on('::').or(be_listening.on('0.0.0.0')) end end end shared_examples 'hhvm::listening::local-only' do - describe port(9000) do - it "hhvm should NOT be listening public", :retry => 20, :retry_wait => 3 do - should_not be_listening - end - end - describe port(9000) do it "hhvm should be listening local", :retry => 20, :retry_wait => 3 do - should be_listening.on('::1').with('tcp') + should_not be_listening.on('::') + should_not be_listening.on('0.0.0.0') + should be_listening.on('::1').or(be_listening.on('127.0.0.1')) end end end diff --git a/tests/serverspec/spec/shared/liquidsoap/listening.rb b/tests/serverspec/spec/shared/liquidsoap/listening.rb new file mode 100644 index 000000000..035b8ab1c --- /dev/null +++ b/tests/serverspec/spec/shared/liquidsoap/listening.rb @@ -0,0 +1,7 @@ +shared_examples 'liquidsoap::listening::public' do + describe port(1234) do + it "hhvm should be listening", :retry => 20, :retry_wait => 3 do + should be_listening + end + end +end diff --git a/tests/serverspec/spec/shared/php/cli.rb b/tests/serverspec/spec/shared/php/cli.rb index 5f119ea61..9c221bf33 100644 --- a/tests/serverspec/spec/shared/php/cli.rb +++ b/tests/serverspec/spec/shared/php/cli.rb @@ -1,9 +1,5 @@ shared_examples 'php::cli' do - it "should include php cli" do - expect(file("/usr/bin/php")).to be_executable - end - - describe command('/usr/bin/php -i') do + describe command('php -i') do its(:exit_status) { should eq 0 } end end diff --git a/tests/serverspec/spec/shared/php/fpm.rb b/tests/serverspec/spec/shared/php/fpm.rb index fe59b23f8..33109ae98 100644 --- a/tests/serverspec/spec/shared/php/fpm.rb +++ b/tests/serverspec/spec/shared/php/fpm.rb @@ -12,7 +12,9 @@ shared_examples 'php-fpm5::layout' do it "should have local php-fpm 5.x layout" do - if os[:family] == 'redhat' + if $testConfiguration[:phpOfficialImage] + expect(file("/usr/local/etc/php-fpm.d")).to be_symlink + elsif os[:family] == 'redhat' expect(file("/etc/php-fpm.d")).to be_symlink elsif ['debian', 'ubuntu'].include?(os[:family]) expect(file("/etc/php5/fpm/pool.d")).to be_symlink @@ -23,7 +25,9 @@ shared_examples 'php-fpm7::layout' do it "should have local php-fpm 7.x layout" do - if os[:family] == 'redhat' + if $testConfiguration[:phpOfficialImage] + expect(file("/usr/local/etc/php-fpm.d")).to be_symlink + elsif os[:family] == 'redhat' expect(file("/etc/php-fpm.d")).to be_symlink elsif ['debian', 'ubuntu'].include?(os[:family]) expect(file("/etc/php/7.0/fpm/pool.d")).to be_symlink @@ -33,22 +37,18 @@ shared_examples 'php-fpm::listening::public' do describe port(9000) do - it "php-fpm should be listening", :retry => 20, :retry_wait => 3 do - should be_listening.on('0.0.0.0').with('tcp') + it "php-fpm should be listening", :retry => 10, :retry_wait => 3 do + should be_listening.on('::').or(be_listening.on('0.0.0.0')) end end end shared_examples 'php-fpm::listening::local-only' do describe port(9000) do - it "php-fpm should NOT be listening public", :retry => 20, :retry_wait => 3 do + it "php-fpm should be listening local", :retry => 10, :retry_wait => 3 do should_not be_listening.on('0.0.0.0') - end - end - - describe port(9000) do - it "php-fpm should be listening local", :retry => 20, :retry_wait => 3 do - should be_listening.on('127.0.0.1').with('tcp') + should_not be_listening.on('::') + should be_listening.on('::1').or(be_listening.on('127.0.0.1')) end end end diff --git a/tests/serverspec/spec/shared/php/modules.rb b/tests/serverspec/spec/shared/php/modules.rb index 1e1ae638e..717d5ef53 100644 --- a/tests/serverspec/spec/shared/php/modules.rb +++ b/tests/serverspec/spec/shared/php/modules.rb @@ -20,7 +20,7 @@ its(:stdout) { should contain('hash') } its(:stdout) { should contain('iconv') } its(:stdout) { should contain('json') } - its(:stdout) { should contain('ldap') } + #its(:stdout) { should contain('ldap') } its(:stdout) { should contain('libxml') } its(:stdout) { should contain('mbstring') } its(:stdout) { should contain('mysqli') } @@ -48,7 +48,7 @@ its(:stdout) { should contain('tokenizer') } its(:stdout) { should contain('xml') } its(:stdout) { should contain('xmlreader') } - its(:stdout) { should contain('xmlrpc') } + #its(:stdout) { should contain('xmlrpc') } its(:stdout) { should contain('xmlwriter') } its(:stdout) { should contain('xsl') } its(:stdout) { should contain('zip') } @@ -96,14 +96,6 @@ describe command('php -m') do its(:stdout) { should contain('shmop') } - if ( $testConfiguration[:phpMhash] ) - its(:stdout) { should contain('mhash') } - else - its(:stdout) { should_not contain('mhash') } - end - - its(:stdout) { should contain('wddx') } - if ( $testConfiguration[:phpRedis] ) its(:stdout) { should contain('redis') } else @@ -148,7 +140,7 @@ its(:stdout) { should contain('hash') } its(:stdout) { should contain('iconv') } its(:stdout) { should contain('json') } - its(:stdout) { should contain('ldap') } + #its(:stdout) { should contain('ldap') } its(:stdout) { should contain('libxml') } its(:stdout) { should contain('mbstring') } its(:stdout) { should contain('mysqli') } @@ -176,7 +168,7 @@ its(:stdout) { should contain('tokenizer') } its(:stdout) { should contain('xml') } its(:stdout) { should contain('xmlreader') } - its(:stdout) { should contain('xmlrpc') } + # its(:stdout) { should contain('xmlrpc') } its(:stdout) { should contain('xmlwriter') } its(:stdout) { should contain('xsl') } its(:stdout) { should contain('zip') } @@ -224,14 +216,6 @@ describe command('curl --insecure --silent --retry 10 --fail http://localhost/php-test.php?test=get_loaded_extensions') do its(:stdout) { should contain('shmop') } - if ( $testConfiguration[:phpMhash] ) - its(:stdout) { should contain('mhash') } - else - its(:stdout) { should_not contain('mhash') } - end - - its(:stdout) { should contain('wddx') } - if ( $testConfiguration[:phpRedis] ) its(:stdout) { should contain('redis') } else diff --git a/tests/serverspec/spec/shared/php/service.rb b/tests/serverspec/spec/shared/php/service.rb index 920500698..9e3203a87 100644 --- a/tests/serverspec/spec/shared/php/service.rb +++ b/tests/serverspec/spec/shared/php/service.rb @@ -1,6 +1,6 @@ shared_examples 'php-fpm::service::running' do describe "service php-fpm check" do - it "should have running php-fpm daemon", :retry => 20, :retry_wait => 3 do + it "should have running php-fpm daemon", :retry => 5, :retry_wait => 3 do cmd = command("service php-fpm check") expect(cmd.stdout).to match('ok') expect(cmd.exit_status).to eq 0 diff --git a/tests/serverspec/spec/shared/php/tools.rb b/tests/serverspec/spec/shared/php/tools.rb index e36c68f55..c03ef4eea 100644 --- a/tests/serverspec/spec/shared/php/tools.rb +++ b/tests/serverspec/spec/shared/php/tools.rb @@ -2,20 +2,6 @@ [ "/usr/local/bin/composer", - "/usr/local/bin/phploc", - "/usr/local/bin/pdepend", - "/usr/local/bin/phpmd", - "/usr/local/bin/phpcs", - "/usr/local/bin/phpcbf", - "/usr/local/bin/phpcpd", - "/usr/local/bin/phpdcd", - "/usr/local/bin/phpmetrics", - "/usr/local/bin/php-cs-fixer", - "/usr/local/bin/deprecation-detector", - "/usr/local/bin/php7cc", - "/usr/local/bin/phpunit", - "/usr/local/bin/phpspec" - ].each do |file| describe file("#{file}") do diff --git a/tests/serverspec/spec/shared/python/toolchain.rb b/tests/serverspec/spec/shared/python/toolchain.rb new file mode 100644 index 000000000..8eeb1ea68 --- /dev/null +++ b/tests/serverspec/spec/shared/python/toolchain.rb @@ -0,0 +1,18 @@ +shared_examples 'python::toolchain' do + + describe command('python --version') do + its(:exit_status) { should eq 0 } + end + + describe command('easy_install --version'), :if => ['debian', 'ubuntu', 'redhat'].include?(os[:family]) do + its(:exit_status) { should eq 0 } + end + + describe command('easy_install-2.7 --version'), :if => ['alpine'].include?(os[:family]) do + its(:exit_status) { should eq 0 } + end + + describe command('pip --help') do + its(:exit_status) { should eq 0 } + end +end diff --git a/tests/serverspec/spec/spec_config.rb b/tests/serverspec/spec/spec_config.rb index fbeec5655..1eae3ccc3 100644 --- a/tests/serverspec/spec/spec_config.rb +++ b/tests/serverspec/spec/spec_config.rb @@ -39,8 +39,8 @@ $testConfiguration[:phpXdebug] = true $testConfiguration[:phpApcu] = true $testConfiguration[:phpRedis] = true -$testConfiguration[:phpMhash] = true $testConfiguration[:phpBlackfire] = false +$testConfiguration[:phpOfficialImage] = false if ((os[:family] == 'ubuntu' and os[:version] == '12.04') or (os[:family] == 'ubuntu' and os[:version] == '14.04') or @@ -49,15 +49,22 @@ (os[:family] == 'redhat' and os[:version] == '7') or (os[:family] == 'debian' and os[:version] == '7') or (os[:family] == 'debian' and os[:version] == '8') or - (os[:family] == 'alpine' and os[:version] == '3') or - (ENV['DOCKER_TAG'].match('php5'))) + (ENV['DOCKER_TAG'].match('php5')) or + (ENV['DOCKER_TAG'].match('alpine-3')) or + (ENV['DOCKER_TAG'] =~ /^5\.[0-9]+/) + ) $testConfiguration[:php] = 5 end -if (ENV['DOCKER_TAG'].match('php7')) +if ((ENV['DOCKER_TAG'].match('php7')) or + (ENV['DOCKER_TAG'] =~ /^7\.[0-9]+/) + ) $testConfiguration[:php] = 7 end +if ENV['PHP_OFFICIAL'] and ENV['PHP_OFFICIAL'] == "1" + $testConfiguration[:phpOfficialImage] = true +end if ENV['PHP_XDEBUG'] and ENV['PHP_XDEBUG'] == "0" $testConfiguration[:phpXdebug] = false @@ -71,10 +78,6 @@ $testConfiguration[:phpRedis] = false end -if ENV['PHP_MHASH'] and ENV['PHP_MHASH'] == "0" - $testConfiguration[:phpMhash] = false -end - if ENV['PHP_BLACKFIRE'] and ENV['PHP_BLACKFIRE'] == "1" $testConfiguration[:phpBlackfire] = true $testConfiguration[:phpXdebug] = false diff --git a/tests/serverspec/spec/spec_init.rb b/tests/serverspec/spec/spec_init.rb index 5dff3719c..c23bb6e55 100644 --- a/tests/serverspec/spec/spec_init.rb +++ b/tests/serverspec/spec/spec_init.rb @@ -10,6 +10,12 @@ print "------------------------\n" print " DOCKERIMAGE_ID: " + ENV['DOCKERIMAGE_ID'] + "\n" print " DOCKER_IMAGE: " + ENV['DOCKER_IMAGE'] + "\n" +print " DOCKER_TAG: " + ENV['DOCKER_TAG'] + "\n" print " OS_FAMILY: " + ENV['OS_FAMILY'] + "\n" print " OS_VERSION: " + ENV['OS_VERSION'] + "\n" print "\n" +print "--- internal config -----\n" +$testConfiguration.each {|key, value| puts " #{key}: #{value}" } +print "\n" + +