From aeb06917debdd1badf9027b1e318e215725b4a77 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luis=20Alejandro=20Mart=C3=ADnez=20Faneyth?= Date: Sun, 23 Jun 2019 16:03:44 -0400 Subject: [PATCH 1/4] [REF] Adding PHP shelves. --- .gitignore | 2 + .travis.yml | 3 + php/7.0/Dockerfile | 23 ++++++ php/7.2/Dockerfile | 23 ++++++ php/7.3/Dockerfile | 23 ++++++ php/Dockerfile.template | 23 ++++++ php/README.md | 41 ++++++++++ php/README.md.template | 39 ++++++++++ php/build-image.sh | 138 ++++++++++++++++++++++++++++++++++ php/hooks/build | 3 + php/hooks/push | 2 + php/test-image.rb | 33 +++++++++ scripts/config.py | 6 +- scripts/update_php.py | 160 ++++++++++++++++++++++++++++++++++++++++ scripts/utils.py | 40 ++++++---- update_shelf.py | 5 ++ 16 files changed, 548 insertions(+), 16 deletions(-) create mode 100644 php/7.0/Dockerfile create mode 100644 php/7.2/Dockerfile create mode 100644 php/7.3/Dockerfile create mode 100644 php/Dockerfile.template create mode 100644 php/README.md create mode 100644 php/README.md.template create mode 100755 php/build-image.sh create mode 100644 php/hooks/build create mode 100644 php/hooks/push create mode 100644 php/test-image.rb create mode 100644 scripts/update_php.py diff --git a/.gitignore b/.gitignore index f608cafb..d6140f7f 100644 --- a/.gitignore +++ b/.gitignore @@ -73,6 +73,8 @@ ruby/*/*.sh node/*/*.sh mongo/*/*.sh postgres/*/*.sh +odoo/*/*.sh +php/*/*.sh # VSCode .vscode/ \ No newline at end of file diff --git a/.travis.yml b/.travis.yml index 632c40e3..6a511a49 100644 --- a/.travis.yml +++ b/.travis.yml @@ -60,6 +60,9 @@ env: - DOCKER_IMAGE_NAME="dockershelf/odoo:10.0" - DOCKER_IMAGE_NAME="dockershelf/odoo:11.0" - DOCKER_IMAGE_NAME="dockershelf/odoo:12.0" DOCKER_IMAGE_EXTRA_TAGS="dockershelf/odoo:latest" + - DOCKER_IMAGE_NAME="dockershelf/php:7.0" + - DOCKER_IMAGE_NAME="dockershelf/php:7.2" + - DOCKER_IMAGE_NAME="dockershelf/php:7.3" DOCKER_IMAGE_EXTRA_TAGS="dockershelf/php:latest" install: - gem install docker-api serverspec before_script: diff --git a/php/7.0/Dockerfile b/php/7.0/Dockerfile new file mode 100644 index 00000000..4fe1388f --- /dev/null +++ b/php/7.0/Dockerfile @@ -0,0 +1,23 @@ +FROM dockershelf/debian:sid +MAINTAINER Luis Alejandro Martínez Faneyth + +ARG BUILD_DATE +ARG VCS_REF +ARG VERSION + +LABEL org.label-schema.build-date=${BUILD_DATE} \ + org.label-schema.name="php7.0" \ + org.label-schema.description="A PHP 7.0 image based on Debian sid." \ + org.label-schema.url="https://github.com/LuisAlejandro/dockershelf" \ + org.label-schema.vcs-ref=${VCS_REF} \ + org.label-schema.vcs-url="https://github.com/LuisAlejandro/dockershelf" \ + org.label-schema.vendor="Luis Alejandro Martínez Faneyth" \ + org.label-schema.version=${VERSION} \ + org.label-schema.schema-version="1.0.0-rc.1" + +ENV PHP_VER_NUM="7.0" PHP_DEBIAN_SUITE="stretch" + +COPY build-image.sh library.sh /usr/share/dockershelf/php/ +RUN bash /usr/share/dockershelf/php/build-image.sh + +CMD ["php"] \ No newline at end of file diff --git a/php/7.2/Dockerfile b/php/7.2/Dockerfile new file mode 100644 index 00000000..008f7e60 --- /dev/null +++ b/php/7.2/Dockerfile @@ -0,0 +1,23 @@ +FROM dockershelf/debian:sid +MAINTAINER Luis Alejandro Martínez Faneyth + +ARG BUILD_DATE +ARG VCS_REF +ARG VERSION + +LABEL org.label-schema.build-date=${BUILD_DATE} \ + org.label-schema.name="php7.2" \ + org.label-schema.description="A PHP 7.2 image based on Debian sid." \ + org.label-schema.url="https://github.com/LuisAlejandro/dockershelf" \ + org.label-schema.vcs-ref=${VCS_REF} \ + org.label-schema.vcs-url="https://github.com/LuisAlejandro/dockershelf" \ + org.label-schema.vendor="Luis Alejandro Martínez Faneyth" \ + org.label-schema.version=${VERSION} \ + org.label-schema.schema-version="1.0.0-rc.1" + +ENV PHP_VER_NUM="7.2" PHP_DEBIAN_SUITE="sid" + +COPY build-image.sh library.sh /usr/share/dockershelf/php/ +RUN bash /usr/share/dockershelf/php/build-image.sh + +CMD ["php"] \ No newline at end of file diff --git a/php/7.3/Dockerfile b/php/7.3/Dockerfile new file mode 100644 index 00000000..71dbb5f7 --- /dev/null +++ b/php/7.3/Dockerfile @@ -0,0 +1,23 @@ +FROM dockershelf/debian:sid +MAINTAINER Luis Alejandro Martínez Faneyth + +ARG BUILD_DATE +ARG VCS_REF +ARG VERSION + +LABEL org.label-schema.build-date=${BUILD_DATE} \ + org.label-schema.name="php7.3" \ + org.label-schema.description="A PHP 7.3 image based on Debian sid." \ + org.label-schema.url="https://github.com/LuisAlejandro/dockershelf" \ + org.label-schema.vcs-ref=${VCS_REF} \ + org.label-schema.vcs-url="https://github.com/LuisAlejandro/dockershelf" \ + org.label-schema.vendor="Luis Alejandro Martínez Faneyth" \ + org.label-schema.version=${VERSION} \ + org.label-schema.schema-version="1.0.0-rc.1" + +ENV PHP_VER_NUM="7.3" PHP_DEBIAN_SUITE="sid" + +COPY build-image.sh library.sh /usr/share/dockershelf/php/ +RUN bash /usr/share/dockershelf/php/build-image.sh + +CMD ["php"] \ No newline at end of file diff --git a/php/Dockerfile.template b/php/Dockerfile.template new file mode 100644 index 00000000..7adc6c48 --- /dev/null +++ b/php/Dockerfile.template @@ -0,0 +1,23 @@ +FROM %%BASE_IMAGE%% +MAINTAINER Luis Alejandro Martínez Faneyth + +ARG BUILD_DATE +ARG VCS_REF +ARG VERSION + +LABEL org.label-schema.build-date=${BUILD_DATE} \ + org.label-schema.name="php%%PHP_VERSION%%" \ + org.label-schema.description="A PHP %%PHP_VERSION%% image based on Debian %%DEBIAN_RELEASE%%." \ + org.label-schema.url="https://github.com/LuisAlejandro/dockershelf" \ + org.label-schema.vcs-ref=${VCS_REF} \ + org.label-schema.vcs-url="https://github.com/LuisAlejandro/dockershelf" \ + org.label-schema.vendor="Luis Alejandro Martínez Faneyth" \ + org.label-schema.version=${VERSION} \ + org.label-schema.schema-version="1.0.0-rc.1" + +ENV PHP_VER_NUM="%%PHP_VERSION%%" PHP_DEBIAN_SUITE="%%PHP_DEBIAN_SUITE%%" + +COPY build-image.sh library.sh /usr/share/dockershelf/php/ +RUN bash /usr/share/dockershelf/php/build-image.sh + +CMD ["php"] \ No newline at end of file diff --git a/php/README.md b/php/README.md new file mode 100644 index 00000000..87dcb0ef --- /dev/null +++ b/php/README.md @@ -0,0 +1,41 @@ +![](https://cdn.rawgit.com/LuisAlejandro/dockershelf/master/images/banner.svg) + +--- + +[![](https://img.shields.io/github/release/LuisAlejandro/dockershelf.svg)](https://github.com/LuisAlejandro/dockershelf/releases) [![](https://img.shields.io/travis/LuisAlejandro/dockershelf.svg)](https://travis-ci.org/LuisAlejandro/dockershelf) [![](https://img.shields.io/docker/pulls/dockershelf/php.svg)](https://hub.docker.com/r/dockershelf/php) [![](https://img.shields.io/github/issues-raw/LuisAlejandro/dockershelf/in%20progress.svg?label=in%20progress)](https://github.com/LuisAlejandro/dockershelf/issues?q=is%3Aissue+is%3Aopen+label%3A%22in+progress%22) [![](https://badges.gitter.im/LuisAlejandro/dockershelf.svg)](https://gitter.im/LuisAlejandro/dockershelf) [![](https://cla-assistant.io/readme/badge/LuisAlejandro/dockershelf)](https://cla-assistant.io/LuisAlejandro/dockershelf) + +## PHP shelf + +|Image |Release |Dockerfile |Layers |Size | +|-------|---------|------------|--------|------| +|[`dockershelf/php:7.0`](https://hub.docker.com/r/dockershelf/php)|`7.0`|[![](https://img.shields.io/badge/-php%2F7.0%2FDockerfile-blue.svg?colorA=22313f&colorB=4a637b&maxAge=86400&logo=docker)](https://github.com/LuisAlejandro/dockershelf/blob/master/php/7.0/Dockerfile)|[![](https://img.shields.io/microbadger/layers/dockershelf/php/7.0.svg?colorA=22313f&colorB=4a637b&maxAge=86400)](https://microbadger.com/images/dockershelf/php:7.0)|[![](https://img.shields.io/microbadger/image-size/dockershelf/php/7.0.svg?colorA=22313f&colorB=4a637b&maxAge=86400)](https://microbadger.com/images/dockershelf/php:7.0)| +|[`dockershelf/php:7.2`](https://hub.docker.com/r/dockershelf/php)|`7.2`|[![](https://img.shields.io/badge/-php%2F7.2%2FDockerfile-blue.svg?colorA=22313f&colorB=4a637b&maxAge=86400&logo=docker)](https://github.com/LuisAlejandro/dockershelf/blob/master/php/7.2/Dockerfile)|[![](https://img.shields.io/microbadger/layers/dockershelf/php/7.2.svg?colorA=22313f&colorB=4a637b&maxAge=86400)](https://microbadger.com/images/dockershelf/php:7.2)|[![](https://img.shields.io/microbadger/image-size/dockershelf/php/7.2.svg?colorA=22313f&colorB=4a637b&maxAge=86400)](https://microbadger.com/images/dockershelf/php:7.2)| +|[`dockershelf/php:7.3`](https://hub.docker.com/r/dockershelf/php)|`7.3`|[![](https://img.shields.io/badge/-php%2F7.3%2FDockerfile-blue.svg?colorA=22313f&colorB=4a637b&maxAge=86400&logo=docker)](https://github.com/LuisAlejandro/dockershelf/blob/master/php/7.3/Dockerfile)|[![](https://img.shields.io/microbadger/layers/dockershelf/php/7.3.svg?colorA=22313f&colorB=4a637b&maxAge=86400)](https://microbadger.com/images/dockershelf/php:7.3)|[![](https://img.shields.io/microbadger/image-size/dockershelf/php/7.3.svg?colorA=22313f&colorB=4a637b&maxAge=86400)](https://microbadger.com/images/dockershelf/php:7.3)| + +![](https://cdn.rawgit.com/LuisAlejandro/dockershelf/master/images/table.svg) + +## Building process + +The PHP images are built using a bash script [`php/build-image.sh`](https://github.com/LuisAlejandro/dockershelf/blob/master/php/build-image.sh), you can check it out for details. + +Each php release is downloaded and installed from the debian official repositories. Some releases are not compiled against Debian Sid libraries, so some potentially old libraries could be installed in the process. + +We'll explain the overall process here: + +1. Built `FROM dockershelf/debian:sid`. +2. Labelled according to [label-schema.org](http://label-schema.org). +3. Install developer tools to handle the package installation. +4. Install PHP. +5. Uninstall developer tools and orphan packages. +6. Install `pip`. +7. Shrink image by deleting unnecessary files. + +## Made with :heart: and :hamburger: + +![Banner](http://huntingbears.com.ve/static/img/site/banner.svg) + +My name is Luis ([@LuisAlejandro](https://github.com/LuisAlejandro)) and I'm a Free and Open-Source Software developer living in Maracay, Venezuela. + +If you like what I do, please support me on [Patreon](https://www.patreon.com/luisalejandro), [Flattr](https://flattr.com/profile/luisalejandro), or donate via [PayPal](https://www.paypal.me/martinezfaneyth), so that I can continue doing what I love. + +> Blog [luisalejandro.org](http://luisalejandro.org) · GitHub [@LuisAlejandro](https://github.com/LuisAlejandro) · Twitter [@LuisAlejandro](https://twitter.com/LuisAlejandro) \ No newline at end of file diff --git a/php/README.md.template b/php/README.md.template new file mode 100644 index 00000000..08addf40 --- /dev/null +++ b/php/README.md.template @@ -0,0 +1,39 @@ +![](https://cdn.rawgit.com/LuisAlejandro/dockershelf/master/images/banner.svg) + +--- + +[![](https://img.shields.io/github/release/LuisAlejandro/dockershelf.svg)](https://github.com/LuisAlejandro/dockershelf/releases) [![](https://img.shields.io/travis/LuisAlejandro/dockershelf.svg)](https://travis-ci.org/LuisAlejandro/dockershelf) [![](https://img.shields.io/docker/pulls/dockershelf/php.svg)](https://hub.docker.com/r/dockershelf/php) [![](https://img.shields.io/github/issues-raw/LuisAlejandro/dockershelf/in%20progress.svg?label=in%20progress)](https://github.com/LuisAlejandro/dockershelf/issues?q=is%3Aissue+is%3Aopen+label%3A%22in+progress%22) [![](https://badges.gitter.im/LuisAlejandro/dockershelf.svg)](https://gitter.im/LuisAlejandro/dockershelf) [![](https://cla-assistant.io/readme/badge/LuisAlejandro/dockershelf)](https://cla-assistant.io/LuisAlejandro/dockershelf) + +## PHP shelf + +|Image |Release |Dockerfile |Layers |Size | +|-------|---------|------------|--------|------| +%%PHP_TABLE%% + +![](https://cdn.rawgit.com/LuisAlejandro/dockershelf/master/images/table.svg) + +## Building process + +The PHP images are built using a bash script [`php/build-image.sh`](https://github.com/LuisAlejandro/dockershelf/blob/master/php/build-image.sh), you can check it out for details. + +Each php release is downloaded and installed from the debian official repositories. Some releases are not compiled against Debian Sid libraries, so some potentially old libraries could be installed in the process. + +We'll explain the overall process here: + +1. Built `FROM dockershelf/debian:sid`. +2. Labelled according to [label-schema.org](http://label-schema.org). +3. Install developer tools to handle the package installation. +4. Install PHP. +5. Uninstall developer tools and orphan packages. +6. Install `pip`. +7. Shrink image by deleting unnecessary files. + +## Made with :heart: and :hamburger: + +![Banner](http://huntingbears.com.ve/static/img/site/banner.svg) + +My name is Luis ([@LuisAlejandro](https://github.com/LuisAlejandro)) and I'm a Free and Open-Source Software developer living in Maracay, Venezuela. + +If you like what I do, please support me on [Patreon](https://www.patreon.com/luisalejandro), [Flattr](https://flattr.com/profile/luisalejandro), or donate via [PayPal](https://www.paypal.me/martinezfaneyth), so that I can continue doing what I love. + +> Blog [luisalejandro.org](http://luisalejandro.org) · GitHub [@LuisAlejandro](https://github.com/LuisAlejandro) · Twitter [@LuisAlejandro](https://twitter.com/LuisAlejandro) \ No newline at end of file diff --git a/php/build-image.sh b/php/build-image.sh new file mode 100755 index 00000000..6f15491a --- /dev/null +++ b/php/build-image.sh @@ -0,0 +1,138 @@ +#!/usr/bin/env bash +# +# This file is part of Dockershelf. +# Copyright (C) 2016-2018, Dockershelf Developers. +# +# Please refer to AUTHORS.md for a complete list of Copyright holders. +# +# Dockershelf is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# Dockershelf is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see http://www.gnu.org/licenses. + +# Exit early if there are errors and be verbose. +set -exuo pipefail + +# Some default values. +BASEDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" + +PHP_VER_NUM_MAJOR="$( echo ${PHP_VER_NUM} | awk -F'.' '{print $1}' )" +PHP_VER_NUM_STR="php${PHP_VER_NUM}" +PHP_VER_NUM_MAJOR_STR="php${PHP_VER_NUM_MAJOR}" + +MIRROR="http://deb.debian.org/debian" +UBUNTUMIRROR="http://archive.ubuntu.com/ubuntu" + +# This is the list of php packages from debian that make up a minimal +# php installation. We will use them later. +PHP_PKGS="${PHP_VER_NUM_STR} \ + ${PHP_VER_NUM_STR}-cli \ + composer" + +# Some tools are needed. +DPKG_TOOLS_DEPENDS="aptitude deborphan debian-keyring dpkg-dev gnupg" + +# Load helper functions +source "${BASEDIR}/library.sh" + +# Apt: Install tools +# ------------------------------------------------------------------------------ +# We need to install the packages defined at ${DPKG_TOOLS_DEPENDS} because +# some commands are needed to download and process dependencies. + +msginfo "Installing tools and upgrading image ..." +cmdretry apt-get update +cmdretry apt-get -d upgrade +cmdretry apt-get upgrade +cmdretry apt-get install -d ${DPKG_TOOLS_DEPENDS} +cmdretry apt-get install ${DPKG_TOOLS_DEPENDS} + +# PHP: Configure sources +# ------------------------------------------------------------------------------ +# We will use Debian's repository to install the different versions of PHP. + +msginfo "Configuring /etc/apt/sources.list ..." +{ + echo "deb ${MIRROR} ${PHP_DEBIAN_SUITE} main" +} | tee /etc/apt/sources.list.d/php.list > /dev/null + +if [ "${PHP_VER_NUM}" == "7.2" ]; then + { + echo "deb ${UBUNTUMIRROR} bionic main" + } | tee /etc/apt/sources.list.d/ubuntu.list > /dev/null + + cmdretry apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 3B4FE6ACC0B21F32 +fi + +cmdretry apt-get update + +# Apt: Install runtime dependencies +# ------------------------------------------------------------------------------ +# Now we use some shell/apt plumbing to get runtime dependencies. + +msginfo "Installing php runtime dependencies ..." +DPKG_RUN_DEPENDS="$( aptitude search -F%p \ + $( printf '~RDepends:~n^%s$ ' ${PHP_PKGS} ) | xargs printf ' %s ' | \ + sed "$( printf 's/\s%s\s/ /g;' ${PHP_PKGS} )" )" +DPKG_DEPENDS="$( printf '%s\n' ${DPKG_RUN_DEPENDS} | \ + uniq | xargs )" + +cmdretry apt-get install -d ${DPKG_DEPENDS} +cmdretry apt-get install ${DPKG_DEPENDS} + +# PHP: Installation +# ------------------------------------------------------------------------------ +# We will install the packages listed in ${PHP_PKGS} + +msginfo "Installing PHP ..." +cmdretry apt-get install -d ${PHP_PKGS} +cmdretry apt-get install ${PHP_PKGS} + +# Apt: Remove unnecessary packages +# ------------------------------------------------------------------------------ +# We need to clear the filesystem of unwanted packages to shrink image size. + +msginfo "Removing unnecessary packages ..." +# This is clever uh? I figured it out myself, ha! +cmdretry apt-get purge $( apt-mark showauto $( deborphan -a -n \ + --no-show-section --guess-all --libdevel \ + -p standard ) ) +cmdretry apt-get autoremove + +# This too +cmdretry apt-get purge $( aptitude search -F%p ~c ~g ) +cmdretry apt-get autoremove + +cmdretry apt-get purge ${DPKG_TOOLS_DEPENDS} +cmdretry apt-get autoremove + +# Bash: Changing prompt +# ------------------------------------------------------------------------------ +# To distinguish images. + +cat >> "/etc/bash.bashrc" << 'EOF' + +COLOR_LILAC="\[\033[38;5;105m\]" +COLOR_PURPLE="\[\033[38;5;56m\]" +COLOR_OFF="\[\033[0m\]" +PS1="${COLOR_LILAC}[\u@${COLOR_PURPLE}\h]${COLOR_OFF}:\w\$ " +EOF + +# Final cleaning +# ------------------------------------------------------------------------------ +# Buncha files we won't use. + +msginfo "Removing unnecessary files ..." +find /usr -name "*.py[co]" -print0 | xargs -0r rm -rfv +find /usr -name "__pycache__" -type d -print0 | xargs -0r rm -rfv +rm -rfv "/tmp/"* "/usr/share/doc/"* "/usr/share/locale/"* "/usr/share/man/"* \ + "/var/cache/debconf/"* "/var/cache/apt/"* "/var/tmp/"* "/var/log/"* \ + "/var/lib/apt/lists/"* \ No newline at end of file diff --git a/php/hooks/build b/php/hooks/build new file mode 100644 index 00000000..db2bcccb --- /dev/null +++ b/php/hooks/build @@ -0,0 +1,3 @@ +#!/usr/bin/env bash +echo "This is a dummy build script that just allows to automatically fill the long description with the Readme from GitHub." +echo "No real building is done here." \ No newline at end of file diff --git a/php/hooks/push b/php/hooks/push new file mode 100644 index 00000000..a98aaa1c --- /dev/null +++ b/php/hooks/push @@ -0,0 +1,2 @@ +#!/usr/bin/env bash +echo "We arent really pushing." \ No newline at end of file diff --git a/php/test-image.rb b/php/test-image.rb new file mode 100644 index 00000000..9f665e89 --- /dev/null +++ b/php/test-image.rb @@ -0,0 +1,33 @@ +require "docker-api" +require "serverspec" + +describe "%s %s container" % [ENV["DOCKER_IMAGE_TYPE"], ENV["DOCKER_IMAGE_TAG"]] do + before(:all) do + @image = Docker::Image.get(ENV["DOCKER_IMAGE_NAME"]) + @container = Docker::Container.create('Image' => @image.id, 'Tty' => true, 'Cmd' => 'bash') + @container.start + + set :backend, :docker + set :docker_container, @container.id + end + + def php_version + command("php -r \"echo join('.', array_slice(explode('.', explode('-', PHP_VERSION)[0]), 0, -1));\"").stdout.strip + end + + it "should exist" do + expect(@container).not_to be_nil + end + + it "should have a php interpreter" do + expect(file("/usr/bin/php#{php_version()}")).to be_executable + expect(file("/usr/bin/php")).to be_symlink + expect(file("/usr/bin/php")).to be_linked_to("/usr/bin/php#{php_version()}") + end + + + after(:all) do + @container.kill + @container.delete(:force => true) + end +end \ No newline at end of file diff --git a/scripts/config.py b/scripts/config.py index eea281a8..20e1a0f1 100644 --- a/scripts/config.py +++ b/scripts/config.py @@ -22,10 +22,12 @@ from .utils import get_debian_versions, get_mongo_versions, \ get_mongo_versions_src_origin, get_node_versions, get_odoo_versions, \ get_postgres_versions, get_python_versions_src_origin, get_python_versions, \ - get_ruby_versions_src_origin, get_ruby_versions + get_ruby_versions_src_origin, get_ruby_versions, get_php_versions_src_origin, \ + get_php_versions debian_versions = get_debian_versions() latex_versions = ['basic', 'full'] +print(debian_versions) mongo_versions_src_origin = get_mongo_versions_src_origin(debian_versions) mongo_versions = get_mongo_versions(mongo_versions_src_origin) node_versions = get_node_versions() @@ -35,3 +37,5 @@ python_versions = get_python_versions(python_versions_src_origin) ruby_versions_src_origin = get_ruby_versions_src_origin() ruby_versions = get_ruby_versions(ruby_versions_src_origin) +php_versions_src_origin = get_php_versions_src_origin() +php_versions = get_php_versions(php_versions_src_origin) diff --git a/scripts/update_php.py b/scripts/update_php.py new file mode 100644 index 00000000..1b207d96 --- /dev/null +++ b/scripts/update_php.py @@ -0,0 +1,160 @@ +#!/usr/bin/env php3 +# -*- coding: utf-8 -*- +# +# This file is part of Dockershelf. +# Copyright (C) 2016-2018, Dockershelf Developers. +# +# Please refer to AUTHORS.md for a complete list of Copyright holders. +# +# Dockershelf is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# Dockershelf is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see http://www.gnu.org/licenses. + +import os +import re +import shutil + +from .config import php_versions, php_versions_src_origin +from .utils import find_dirs +from .logger import logger + + +def update_php(basedir): + + travis_matrixlist = [] + php_readme_tablelist = [] + phpdir = os.path.join(basedir, 'php') + php_dockerfile_template = os.path.join(phpdir, 'Dockerfile.template') + php_readme_template = os.path.join(phpdir, 'README.md.template') + php_readme = os.path.join(phpdir, 'README.md') + php_hooks_dir = os.path.join(phpdir, 'hooks') + php_build_hook = os.path.join(php_hooks_dir, 'build') + php_push_hook = os.path.join(php_hooks_dir, 'push') + + base_image = 'dockershelf/debian:sid' + docker_tag_holder = 'dockershelf/php:{0}' + docker_url = 'https://hub.docker.com/r/dockershelf/php' + dockerfile_badge_holder = ('https://img.shields.io/badge/' + '-php%2F{0}%2FDockerfile-blue.svg' + '?colorA=22313f&colorB=4a637b&maxAge=86400' + '&logo=docker') + dockerfile_url_holder = ('https://github.com/LuisAlejandro/dockershelf/' + 'blob/master/php/{0}/Dockerfile') + mb_layers_badge_holder = ('https://img.shields.io/microbadger/layers/' + 'dockershelf/php/{0}.svg' + '?colorA=22313f&colorB=4a637b&maxAge=86400') + mb_layers_url_holder = ('https://microbadger.com/images/dockershelf/' + 'php:{0}') + mb_size_badge_holder = ('https://img.shields.io/microbadger/image-size/' + 'dockershelf/php/{0}.svg' + '?colorA=22313f&colorB=4a637b&maxAge=86400') + mb_size_url_holder = ('https://microbadger.com/images/dockershelf/' + 'php:{0}') + travis_matrixlist_latest_str = ( + ' - DOCKER_IMAGE_NAME="dockershelf/php:{0}"' + ' DOCKER_IMAGE_EXTRA_TAGS="dockershelf/php:latest"') + travis_matrixlist_str = ( + ' - DOCKER_IMAGE_NAME="dockershelf/php:{0}"') + php_readme_tablelist_holder = ('|[`{0}`]({1})' + '|`{2}`' + '|[![]({3})]({4})' + '|[![]({5})]({6})' + '|[![]({7})]({8})' + '|') + php_latest_version = php_versions[-1] + + logger.info('Erasing current PHP folders') + for deldir in find_dirs(phpdir): + shutil.rmtree(deldir) + + for php_version in php_versions: + logger.info('Processing PHP {0}'.format(php_version)) + php_version_dir = os.path.join(phpdir, php_version) + php_dockerfile = os.path.join(php_version_dir, 'Dockerfile') + + docker_tag = docker_tag_holder.format(php_version) + dockerfile_badge = dockerfile_badge_holder.format(php_version) + dockerfile_url = dockerfile_url_holder.format(php_version) + mb_layers_badge = mb_layers_badge_holder.format(php_version) + mb_layers_url = mb_layers_url_holder.format(php_version) + mb_size_badge = mb_size_badge_holder.format(php_version) + mb_size_url = mb_size_url_holder.format(php_version) + + if php_version == php_latest_version: + travis_matrixlist.append( + travis_matrixlist_latest_str.format(php_version)) + else: + travis_matrixlist.append( + travis_matrixlist_str.format(php_version)) + + php_readme_tablelist.append( + php_readme_tablelist_holder.format( + docker_tag, docker_url, php_version, dockerfile_badge, + dockerfile_url, mb_layers_badge, mb_layers_url, + mb_size_badge, mb_size_url)) + + os.makedirs(php_version_dir) + + with open(php_dockerfile_template, 'r') as pdt: + php_dockerfile_template_content = pdt.read() + + php_dockerfile_content = php_dockerfile_template_content + php_dockerfile_content = re.sub('%%BASE_IMAGE%%', + base_image, + php_dockerfile_content) + php_dockerfile_content = re.sub('%%DEBIAN_RELEASE%%', + 'sid', + php_dockerfile_content) + php_dockerfile_content = re.sub('%%PHP_VERSION%%', + php_version, + php_dockerfile_content) + php_dockerfile_content = re.sub('%%PHP_DEBIAN_SUITE%%', + php_versions_src_origin[php_version], + php_dockerfile_content) + + with open(php_dockerfile, 'w') as pd: + pd.write(php_dockerfile_content) + + os.makedirs(php_hooks_dir) + + logger.info('Writing dummy hooks') + with open(php_build_hook, 'w') as pbh: + pbh.write('#!/usr/bin/env bash\n') + pbh.write('echo "This is a dummy build script that just allows to ' + 'automatically fill the long description with the Readme ' + 'from GitHub."\n') + pbh.write('echo "No real building is done here."') + + logger.info('Writing PHP Readme') + with open(php_push_hook, 'w') as pph: + pph.write('#!/usr/bin/env bash\n') + pph.write('echo "We arent really pushing."') + + with open(php_readme_template, 'r') as prt: + php_readme_template_content = prt.read() + + php_readme_table = '\n'.join(php_readme_tablelist) + + php_readme_content = php_readme_template_content + php_readme_content = re.sub('%%PHP_TABLE%%', + php_readme_table, + php_readme_content) + + with open(php_readme, 'w') as pr: + pr.write(php_readme_content) + + return travis_matrixlist, php_readme_table + + +if __name__ == '__main__': + basedir = os.path.dirname(os.path.dirname(os.path.realpath(__file__))) + update_php(basedir) diff --git a/scripts/utils.py b/scripts/utils.py index 46d35c88..d5f2e318 100644 --- a/scripts/utils.py +++ b/scripts/utils.py @@ -106,14 +106,13 @@ def get_debian_versions(): debian_release_content = d.read() debian_versions.append( - (s(re.findall('Codename: (.*)', u(debian_release_content))[0]), - s(debian_suite))) + (u(re.findall('Codename: (.*)', u(debian_release_content))[0]), + u(debian_suite))) return debian_versions def get_mongo_versions_src_origin(debian_versions): - logger.info('Getting Mongo versions') mongo_debian_releases_url = ('http://repo.mongodb.org/apt/debian/' 'dists/index.html') @@ -126,6 +125,7 @@ def get_mongo_versions_src_origin(debian_versions): mongo_debian_releases = [e.get('href') for e in mongo_debian_releases] mongo_debian_releases = [e for e in mongo_debian_releases if e != '..'] debian_codenames = list(map(lambda x: x[0], debian_versions)) + print(debian_codenames) mongo_debian_releases = sorted(mongo_debian_releases, reverse=True, key=lambda x: debian_codenames.index(x)) @@ -150,14 +150,13 @@ def get_mongo_versions(mongo_versions_src_origin): mongo_version_upper_limit = 4.0 mongo_versions = mongo_versions_src_origin.keys() mongo_versions = filter(lambda x: int(x[-1]) % 2 == 0, mongo_versions) - mongo_versions = [s(v) for v in mongo_versions + mongo_versions = [u(v) for v in mongo_versions if (float(v) >= mongo_version_lower_limit and float(v) <= mongo_version_upper_limit)] return sorted(set(mongo_versions), key=lambda x: Version(x)) def get_node_versions(): - logger.info('Getting Node versions') node_versions_list_file = ('https://raw.githubusercontent.com/nodesource/' 'distributions/master/deb/src/build.sh') @@ -169,7 +168,7 @@ def get_node_versions(): node_versions = re.findall(r'node_(\d*)\.x:_\d*\.x:nodejs:Node\.js \d*\.x', u(node_versions_list_content)) - node_versions = [s(v) for v in node_versions + node_versions = [u(v) for v in node_versions if (float(v) >= node_version_lower_limit and float(v) <= node_version_upper_limit)] return sorted(set(node_versions), key=lambda x: Version(x)) @@ -187,14 +186,13 @@ def get_odoo_versions(): odoo_versions = [e.replace('/nightly', '') for e in odoo_versions] odoo_versions = list(filter(lambda x: not is_string_a_string(x), odoo_versions)) - odoo_versions = [s(v) for v in odoo_versions + odoo_versions = [u(v) for v in odoo_versions if (float(v) >= odoo_version_lower_limit and float(v) <= odoo_version_upper_limit)] return sorted(set(odoo_versions), key=lambda x: Version(x)) def get_postgres_versions(): - logger.info('Getting Postgres versions') postgres_release_url = ('http://apt.postgresql.org/pub/repos/apt/' 'dists/sid-pgdg/Release') @@ -210,14 +208,29 @@ def get_postgres_versions(): u(postgres_release_content))[0] postgres_versions = list(filter(lambda x: not is_string_a_string(x), postgres_versions.split())) - postgres_versions = [s(v) for v in postgres_versions + postgres_versions = [u(v) for v in postgres_versions if (float(v) >= postgres_version_lower_limit and float(v) <= postgres_version_upper_limit)] return sorted(postgres_versions, key=lambda x: Version(x)) -def get_python_versions_src_origin(): +def get_php_versions_src_origin(): + php_versions_src_origin = { + '7.0': 'stretch', + '7.2': 'sid', + '7.3': 'sid', + } + return php_versions_src_origin + +def get_php_versions(php_versions_src_origin): + logger.info('Getting PHP versions') + php_versions = php_versions_src_origin.keys() + php_versions = [u(v) for v in php_versions] + return sorted(php_versions, key=lambda x: Version(x)) + + +def get_python_versions_src_origin(): python_versions_src_origin = { '2.6': 'wheezy-security', '2.7': 'sid', @@ -232,15 +245,13 @@ def get_python_versions_src_origin(): def get_python_versions(python_versions_src_origin): - logger.info('Getting Python versions') python_versions = python_versions_src_origin.keys() - python_versions = [s(v) for v in python_versions] + python_versions = [u(v) for v in python_versions] return sorted(python_versions, key=lambda x: Version(x)) def get_ruby_versions_src_origin(): - ruby_versions_src_origin = { '1.8': 'wheezy-security', '1.9.1': 'wheezy-security', @@ -252,8 +263,7 @@ def get_ruby_versions_src_origin(): def get_ruby_versions(ruby_versions_src_origin): - logger.info('Getting Ruby versions') ruby_versions = ruby_versions_src_origin.keys() - ruby_versions = [s(v) for v in ruby_versions] + ruby_versions = [u(v) for v in ruby_versions] return sorted(ruby_versions, key=lambda x: Version(x)) diff --git a/update_shelf.py b/update_shelf.py index bae0e273..0aa4d814 100644 --- a/update_shelf.py +++ b/update_shelf.py @@ -32,6 +32,7 @@ from scripts.update_mongo import update_mongo from scripts.update_postgres import update_postgres from scripts.update_odoo import update_odoo +from scripts.update_php import update_php if not sys.version_info < (3,): unicode = str @@ -59,6 +60,7 @@ mongo_matrix_list, mongo_readme_table = update_mongo(basedir) postgres_matrix_list, postgres_readme_table = update_postgres(basedir) odoo_matrix_list, odoo_readme_table = update_odoo(basedir) + php_matrix_list, php_readme_table = update_php(basedir) logger.info('Writing Travis CI matrix') travis_matrixlist.extend(debian_matrix_list) @@ -69,6 +71,7 @@ travis_matrixlist.extend(mongo_matrix_list) travis_matrixlist.extend(postgres_matrix_list) travis_matrixlist.extend(odoo_matrix_list) + travis_matrixlist.extend(php_matrix_list) with open(travis_template, 'r') as tt: travis_template_content = tt.read() @@ -102,6 +105,8 @@ readme_content) readme_content = re.sub('%%ODOO_TABLE%%', odoo_readme_table, readme_content) + readme_content = re.sub('%%PHP_TABLE%%', php_readme_table, + readme_content) with open(readme, 'w') as t: t.write(readme_content) From 9447e89123aeeb71fb4e734bb6fb2c77c7bba9ef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luis=20Alejandro=20Mart=C3=ADnez=20Faneyth?= Date: Mon, 24 Jun 2019 14:49:20 -0400 Subject: [PATCH 2/4] [REF] Improving PHP shelves. --- build-image.sh | 4 +- php/7.0/Dockerfile | 9 ++++- php/7.2/Dockerfile | 9 ++++- php/7.3/Dockerfile | 9 ++++- php/Dockerfile.template | 9 ++++- php/apache2-foreground | 40 ++++++++++++++++++ php/build-image.sh | 87 ++++++++++++++++++++++++++++++++++++++-- php/docker-entrypoint.sh | 9 +++++ php/test-image.rb | 3 -- 9 files changed, 167 insertions(+), 12 deletions(-) create mode 100644 php/apache2-foreground create mode 100644 php/docker-entrypoint.sh diff --git a/build-image.sh b/build-image.sh index 626bf165..72667881 100644 --- a/build-image.sh +++ b/build-image.sh @@ -91,8 +91,8 @@ if [ "${DOCKER_IMAGE_TYPE}" == "mongo" ]; then cp "${DOCKER_IMAGE_TYPE_DIR}/articles.js" "${DOCKER_IMAGE_DIR}" fi -# Copy entrypoint if we are building Postgres -if [ "${DOCKER_IMAGE_TYPE}" == "postgres" ]; then +# Copy entrypoint if we are building Postgres or PHP +if [ "${DOCKER_IMAGE_TYPE}" == "postgres" ] || [ "${DOCKER_IMAGE_TYPE}" == "php" ]; then cp "${DOCKER_IMAGE_TYPE_DIR}/docker-entrypoint.sh" "${DOCKER_IMAGE_DIR}" fi diff --git a/php/7.0/Dockerfile b/php/7.0/Dockerfile index 4fe1388f..35e1aa2a 100644 --- a/php/7.0/Dockerfile +++ b/php/7.0/Dockerfile @@ -17,7 +17,14 @@ LABEL org.label-schema.build-date=${BUILD_DATE} \ ENV PHP_VER_NUM="7.0" PHP_DEBIAN_SUITE="stretch" +COPY docker-entrypoint.sh apache2-foreground /usr/local/bin/ COPY build-image.sh library.sh /usr/share/dockershelf/php/ RUN bash /usr/share/dockershelf/php/build-image.sh -CMD ["php"] \ No newline at end of file +VOLUME /var/www/html +WORKDIR /var/www/html + +EXPOSE 80 + +ENTRYPOINT ["docker-entrypoint.sh"] +CMD ["apache2-foreground"] \ No newline at end of file diff --git a/php/7.2/Dockerfile b/php/7.2/Dockerfile index 008f7e60..c5344ad5 100644 --- a/php/7.2/Dockerfile +++ b/php/7.2/Dockerfile @@ -17,7 +17,14 @@ LABEL org.label-schema.build-date=${BUILD_DATE} \ ENV PHP_VER_NUM="7.2" PHP_DEBIAN_SUITE="sid" +COPY docker-entrypoint.sh apache2-foreground /usr/local/bin/ COPY build-image.sh library.sh /usr/share/dockershelf/php/ RUN bash /usr/share/dockershelf/php/build-image.sh -CMD ["php"] \ No newline at end of file +VOLUME /var/www/html +WORKDIR /var/www/html + +EXPOSE 80 + +ENTRYPOINT ["docker-entrypoint.sh"] +CMD ["apache2-foreground"] \ No newline at end of file diff --git a/php/7.3/Dockerfile b/php/7.3/Dockerfile index 71dbb5f7..43c4dd77 100644 --- a/php/7.3/Dockerfile +++ b/php/7.3/Dockerfile @@ -17,7 +17,14 @@ LABEL org.label-schema.build-date=${BUILD_DATE} \ ENV PHP_VER_NUM="7.3" PHP_DEBIAN_SUITE="sid" +COPY docker-entrypoint.sh apache2-foreground /usr/local/bin/ COPY build-image.sh library.sh /usr/share/dockershelf/php/ RUN bash /usr/share/dockershelf/php/build-image.sh -CMD ["php"] \ No newline at end of file +VOLUME /var/www/html +WORKDIR /var/www/html + +EXPOSE 80 + +ENTRYPOINT ["docker-entrypoint.sh"] +CMD ["apache2-foreground"] \ No newline at end of file diff --git a/php/Dockerfile.template b/php/Dockerfile.template index 7adc6c48..47b0d4b1 100644 --- a/php/Dockerfile.template +++ b/php/Dockerfile.template @@ -17,7 +17,14 @@ LABEL org.label-schema.build-date=${BUILD_DATE} \ ENV PHP_VER_NUM="%%PHP_VERSION%%" PHP_DEBIAN_SUITE="%%PHP_DEBIAN_SUITE%%" +COPY docker-entrypoint.sh apache2-foreground /usr/local/bin/ COPY build-image.sh library.sh /usr/share/dockershelf/php/ RUN bash /usr/share/dockershelf/php/build-image.sh -CMD ["php"] \ No newline at end of file +VOLUME /var/www/html +WORKDIR /var/www/html + +EXPOSE 80 + +ENTRYPOINT ["docker-entrypoint.sh"] +CMD ["apache2-foreground"] \ No newline at end of file diff --git a/php/apache2-foreground b/php/apache2-foreground new file mode 100644 index 00000000..5fe22e26 --- /dev/null +++ b/php/apache2-foreground @@ -0,0 +1,40 @@ +#!/bin/bash +set -e + +# Note: we don't just use "apache2ctl" here because it itself is just a shell-script wrapper around apache2 which provides extra functionality like "apache2ctl start" for launching apache2 in the background. +# (also, when run as "apache2ctl ", it does not use "exec", which leaves an undesirable resident shell process) + +: "${APACHE_CONFDIR:=/etc/apache2}" +: "${APACHE_ENVVARS:=$APACHE_CONFDIR/envvars}" +if test -f "$APACHE_ENVVARS"; then + . "$APACHE_ENVVARS" +fi + +# Apache gets grumpy about PID files pre-existing +: "${APACHE_RUN_DIR:=/var/run/apache2}" +: "${APACHE_PID_FILE:=$APACHE_RUN_DIR/apache2.pid}" +rm -f "$APACHE_PID_FILE" + +# create missing directories +# (especially APACHE_RUN_DIR, APACHE_LOCK_DIR, and APACHE_LOG_DIR) +for e in "${!APACHE_@}"; do + if [[ "$e" == *_DIR ]] && [[ "${!e}" == /* ]]; then + # handle "/var/lock" being a symlink to "/run/lock", but "/run/lock" not existing beforehand, so "/var/lock/something" fails to mkdir + # mkdir: cannot create directory '/var/lock': File exists + dir="${!e}" + while [ "$dir" != "$(dirname "$dir")" ]; do + dir="$(dirname "$dir")" + if [ -d "$dir" ]; then + break + fi + absDir="$(readlink -f "$dir" 2>/dev/null || :)" + if [ -n "$absDir" ]; then + mkdir -p "$absDir" + fi + done + + mkdir -p "${!e}" + fi +done + +exec apache2 -DFOREGROUND "$@" diff --git a/php/build-image.sh b/php/build-image.sh index 6f15491a..20942e30 100755 --- a/php/build-image.sh +++ b/php/build-image.sh @@ -35,6 +35,7 @@ UBUNTUMIRROR="http://archive.ubuntu.com/ubuntu" # php installation. We will use them later. PHP_PKGS="${PHP_VER_NUM_STR} \ ${PHP_VER_NUM_STR}-cli \ + apache2 \ composer" # Some tools are needed. @@ -60,9 +61,11 @@ cmdretry apt-get install ${DPKG_TOOLS_DEPENDS} # We will use Debian's repository to install the different versions of PHP. msginfo "Configuring /etc/apt/sources.list ..." -{ - echo "deb ${MIRROR} ${PHP_DEBIAN_SUITE} main" -} | tee /etc/apt/sources.list.d/php.list > /dev/null +if [ "${PHP_DEBIAN_SUITE}" != "sid" ]; then + { + echo "deb ${MIRROR} ${PHP_DEBIAN_SUITE} main" + } | tee /etc/apt/sources.list.d/php.list > /dev/null +fi if [ "${PHP_VER_NUM}" == "7.2" ]; then { @@ -74,6 +77,13 @@ fi cmdretry apt-get update +# PHP: Configure +# ------------------------------------------------------------------------------ + +mkdir -p /var/www/html +chown www-data:www-data /var/www/html +chmod 777 /var/www/html + # Apt: Install runtime dependencies # ------------------------------------------------------------------------------ # Now we use some shell/apt plumbing to get runtime dependencies. @@ -96,6 +106,77 @@ msginfo "Installing PHP ..." cmdretry apt-get install -d ${PHP_PKGS} cmdretry apt-get install ${PHP_PKGS} +# PHP: Configure +# ------------------------------------------------------------------------------ + +PHP_CONFDIR="/etc/php/conf.d" +APACHE_CONFDIR="/etc/apache2" +APACHE_CONF_AVAILABLE="${APACHE_CONFDIR}/conf-available" +APACHE_ENVVARS="${APACHE_CONFDIR}/envvars" + +mkdir -p "${APACHE_CONF_AVAILABLE}" "${PHP_CONFDIR}" + +# PHP files should be handled by PHP, and should be preferred over any other file type +{ + echo '' + echo '\tSetHandler application/x-httpd-php' + echo '' + echo + echo 'DirectoryIndex disabled' + echo 'DirectoryIndex index.php index.html' + echo + echo '' + echo '\tOptions -Indexes' + echo '\tAllowOverride All' + echo '' +} | tee "${APACHE_CONF_AVAILABLE}/docker-php.conf" + +{ + echo 'opcache.memory_consumption=128' + echo 'opcache.interned_strings_buffer=8' + echo 'opcache.max_accelerated_files=4000' + echo 'opcache.revalidate_freq=2' + echo 'opcache.fast_shutdown=1' + echo 'opcache.enable_cli=1' +} | tee "${PHP_CONFDIR}/opcache-recommended.ini" + +{ + echo 'error_reporting = 4339' + echo 'display_errors = Off' + echo 'display_startup_errors = Off' + echo 'log_errors = On' + echo 'error_log = /dev/stderr' + echo 'log_errors_max_len = 1024' + echo 'ignore_repeated_errors = On' + echo 'ignore_repeated_source = Off' + echo 'html_errors = Off' +} | tee "${PHP_CONFDIR}/error-logging.ini" + +sed -ri 's/^export ([^=]+)=(.*)$/: ${\1:=\2}\nexport \1/' "${APACHE_ENVVARS}" + +. "${APACHE_ENVVARS}" + +for DIR in "${APACHE_LOCK_DIR}" "${APACHE_RUN_DIR}" "${APACHE_LOG_DIR}"; do + rm -rvf "${DIR}" + mkdir -p "${DIR}" + chown "${APACHE_RUN_USER}:${APACHE_RUN_GROUP}" "${DIR}" + # allow running as an arbitrary user (https://github.com/docker-library/php/issues/743) + chmod 777 "${DIR}" +done + +# delete the "index.html" that installing Apache drops in here +rm -rvf /var/www/html/* + +# logs should go to stdout / stderr +ln -sfT /dev/stderr "${APACHE_LOG_DIR}/error.log" +ln -sfT /dev/stdout "${APACHE_LOG_DIR}/access.log" +ln -sfT /dev/stdout "${APACHE_LOG_DIR}/other_vhosts_access.log" +chown -R --no-dereference "${APACHE_RUN_USER}:${APACHE_RUN_GROUP}" "${APACHE_LOG_DIR}" + +a2dismod mpm_event +a2enmod mpm_prefork +a2enconf docker-php + # Apt: Remove unnecessary packages # ------------------------------------------------------------------------------ # We need to clear the filesystem of unwanted packages to shrink image size. diff --git a/php/docker-entrypoint.sh b/php/docker-entrypoint.sh new file mode 100644 index 00000000..3d36d5e8 --- /dev/null +++ b/php/docker-entrypoint.sh @@ -0,0 +1,9 @@ +#!/bin/sh +set -e + +# first arg is `-f` or `--some-option` +if [ "${1#-}" != "$1" ]; then + set -- apache2-foreground "$@" +fi + +exec "$@" diff --git a/php/test-image.rb b/php/test-image.rb index 9f665e89..d1ed51e4 100644 --- a/php/test-image.rb +++ b/php/test-image.rb @@ -21,11 +21,8 @@ def php_version it "should have a php interpreter" do expect(file("/usr/bin/php#{php_version()}")).to be_executable - expect(file("/usr/bin/php")).to be_symlink - expect(file("/usr/bin/php")).to be_linked_to("/usr/bin/php#{php_version()}") end - after(:all) do @container.kill @container.delete(:force => true) From b64866257c4cd9c78c08fcf6aa59568ceb385448 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luis=20Alejandro=20Mart=C3=ADnez=20Faneyth?= Date: Mon, 24 Jun 2019 15:17:45 -0400 Subject: [PATCH 3/4] [FIX] Fixing build. --- README.md.template | 9 +++++++++ build-image.sh | 10 ++++++++-- php/docker-entrypoint.sh | 0 3 files changed, 17 insertions(+), 2 deletions(-) mode change 100644 => 100755 php/docker-entrypoint.sh diff --git a/README.md.template b/README.md.template index fbd23562..98b1cf77 100644 --- a/README.md.template +++ b/README.md.template @@ -92,6 +92,15 @@ These images are similar to the official ones, but with some improved configurat ![](https://cdn.rawgit.com/LuisAlejandro/dockershelf/master/images/table.svg) +### PHP + + +|Image |Release |Dockerfile |Layers |Size | +|-------|---------|------------|--------|------| +%%PHP_TABLE%% + +![](https://cdn.rawgit.com/LuisAlejandro/dockershelf/master/images/table.svg) + ## How to download Pull one of the available images and start hacking! diff --git a/build-image.sh b/build-image.sh index 72667881..a38e9f3c 100644 --- a/build-image.sh +++ b/build-image.sh @@ -91,11 +91,17 @@ if [ "${DOCKER_IMAGE_TYPE}" == "mongo" ]; then cp "${DOCKER_IMAGE_TYPE_DIR}/articles.js" "${DOCKER_IMAGE_DIR}" fi -# Copy entrypoint if we are building Postgres or PHP -if [ "${DOCKER_IMAGE_TYPE}" == "postgres" ] || [ "${DOCKER_IMAGE_TYPE}" == "php" ]; then +# Copy entrypoint if we are building Postgres +if [ "${DOCKER_IMAGE_TYPE}" == "postgres" ]; then cp "${DOCKER_IMAGE_TYPE_DIR}/docker-entrypoint.sh" "${DOCKER_IMAGE_DIR}" fi +# Copy entrypoint if we are building PHP +if [ "${DOCKER_IMAGE_TYPE}" == "php" ]; then + cp "${DOCKER_IMAGE_TYPE_DIR}/docker-entrypoint.sh" "${DOCKER_IMAGE_DIR}" + cp "${DOCKER_IMAGE_TYPE_DIR}/apache2-foreground" "${DOCKER_IMAGE_DIR}" +fi + # Copy latex sample if we are building Latex if [ "${DOCKER_IMAGE_TYPE}" == "latex" ]; then cp "${DOCKER_IMAGE_TYPE_DIR}/sample.tex" "${DOCKER_IMAGE_DIR}" diff --git a/php/docker-entrypoint.sh b/php/docker-entrypoint.sh old mode 100644 new mode 100755 From 846946ea17655e5dc6e8590f1cc32d36700d7080 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luis=20Alejandro=20Mart=C3=ADnez=20Faneyth?= Date: Mon, 24 Jun 2019 17:19:28 -0400 Subject: [PATCH 4/4] Updating Changelog and version. --- .bumpversion.cfg | 2 +- HISTORY.md | 13 +++++++++++++ README.md | 2 +- README.md.template | 2 +- 4 files changed, 16 insertions(+), 3 deletions(-) diff --git a/.bumpversion.cfg b/.bumpversion.cfg index 4922adc2..3dcc5239 100644 --- a/.bumpversion.cfg +++ b/.bumpversion.cfg @@ -1,5 +1,5 @@ [bumpversion] -current_version = 2.1.5 +current_version = 2.2.0 tag_name = {new_version} commit = True tag = True diff --git a/HISTORY.md b/HISTORY.md index 505b96a6..6cc2ffde 100644 --- a/HISTORY.md +++ b/HISTORY.md @@ -1,6 +1,19 @@ # Changelog +## 2.2.0 (2019-06-24) + +### Changes + +* Improving PHP shelves. [Luis Alejandro Martínez Faneyth] + +* Adding PHP shelves. [Luis Alejandro Martínez Faneyth] + +### Fix + +* Fixing build. [Luis Alejandro Martínez Faneyth] + + ## 2.1.5 (2019-05-19) ### Changes diff --git a/README.md b/README.md index e3695e39..27e8a88b 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,7 @@ [![](https://img.shields.io/github/release/LuisAlejandro/dockershelf.svg)](https://github.com/LuisAlejandro/dockershelf/releases) [![](https://img.shields.io/travis/LuisAlejandro/dockershelf.svg)](https://travis-ci.org/LuisAlejandro/dockershelf) [![](https://img.shields.io/github/issues-raw/LuisAlejandro/dockershelf/in%20progress.svg?label=in%20progress)](https://github.com/LuisAlejandro/dockershelf/issues?q=is%3Aissue+is%3Aopen+label%3A%22in+progress%22) [![](https://badges.gitter.im/LuisAlejandro/dockershelf.svg)](https://gitter.im/LuisAlejandro/dockershelf) [![](https://cla-assistant.io/readme/badge/LuisAlejandro/dockershelf)](https://cla-assistant.io/LuisAlejandro/dockershelf) -Current version: 2.1.5 +Current version: 2.2.0 *Dockershelf* is a repository that serves as a collector for docker recipes that are universal, efficient and slim. We keep adding "shelves", which are holders for the different versions of a popular language or application. diff --git a/README.md.template b/README.md.template index 98b1cf77..f969de99 100644 --- a/README.md.template +++ b/README.md.template @@ -4,7 +4,7 @@ [![](https://img.shields.io/github/release/LuisAlejandro/dockershelf.svg)](https://github.com/LuisAlejandro/dockershelf/releases) [![](https://img.shields.io/travis/LuisAlejandro/dockershelf.svg)](https://travis-ci.org/LuisAlejandro/dockershelf) [![](https://img.shields.io/github/issues-raw/LuisAlejandro/dockershelf/in%20progress.svg?label=in%20progress)](https://github.com/LuisAlejandro/dockershelf/issues?q=is%3Aissue+is%3Aopen+label%3A%22in+progress%22) [![](https://badges.gitter.im/LuisAlejandro/dockershelf.svg)](https://gitter.im/LuisAlejandro/dockershelf) [![](https://cla-assistant.io/readme/badge/LuisAlejandro/dockershelf)](https://cla-assistant.io/LuisAlejandro/dockershelf) -Current version: 2.1.5 +Current version: 2.2.0 *Dockershelf* is a repository that serves as a collector for docker recipes that are universal, efficient and slim. We keep adding "shelves", which are holders for the different versions of a popular language or application.