diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 277fe1ba5752933ea7c015a559cf4ec4d4e5464f..b2d73d7ac5909d6554c455b7f23c77d6ab6c891b 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -4,7 +4,7 @@ before_script: php-7.0: stage: build script: - - docker build --pull -t $CI_REGISTRY_IMAGE:php-7.0 ./php-7.0 + - docker build --pull --build-arg ALPINE_VERSION=3.5 --build-arg PHP_VERSION=7.0 -t $CI_REGISTRY_IMAGE:php-7.0 . - docker push $CI_REGISTRY_IMAGE:php-7.0 only: - master @@ -12,7 +12,7 @@ php-7.0: php-7.1: stage: build script: - - docker build --pull -t $CI_REGISTRY_IMAGE:php-7.1 ./php-7.1 + - docker build --pull --build-arg ALPINE_VERSION=3.7 --build-arg PHP_VERSION=7.1 -t $CI_REGISTRY_IMAGE:php-7.1 . - docker push $CI_REGISTRY_IMAGE:php-7.1 only: - master @@ -20,7 +20,7 @@ php-7.1: php-7.2: stage: build script: - - docker build --pull -t $CI_REGISTRY_IMAGE:php-7.2 ./php-7.2 + - docker build --pull --build-arg ALPINE_VERSION=3.8 --build-arg PHP_VERSION=7.2 -t $CI_REGISTRY_IMAGE:php-7.2 . - docker push $CI_REGISTRY_IMAGE:php-7.2 only: - master diff --git a/php-7.1/Dockerfile b/Dockerfile similarity index 52% rename from php-7.1/Dockerfile rename to Dockerfile index 8e05d5231c01a45025f06962270cace04eb35817..0a819f1190ae662fa31d1a99fc7204c171a951b3 100644 --- a/php-7.1/Dockerfile +++ b/Dockerfile @@ -1,76 +1,56 @@ -FROM alpine:3.7 +ARG ALPINE_VERSION + +FROM alpine:${ALPINE_VERSION} LABEL com.example.vendor="LakeDrops" \ maintainer="juergen.haas@lakedrops.com" \ - version="1.4.0" \ + version="1.5.0" \ description="An image for GitLab runner to build and test Drupal projects." +ARG PHP_VERSION ARG compose_version=1.21.2 ARG glibc_version=2.28-r0 +ARG apkArch +ARG dockerArch +ARG DOCKER_CHANNEL=stable +ARG DOCKER_VERSION=18.06.1-ce -RUN apk add --no-cache \ - ca-certificates - -# set up nsswitch.conf for Go's "netgo" implementation (which Docker explicitly uses) -# - https://github.com/docker/docker-ce/blob/v17.09.0-ce/components/engine/hack/make.sh#L149 -# - https://github.com/golang/go/blob/go1.9.1/src/net/conf.go#L194-L275 -# - docker run --rm debian:stretch grep '^hosts:' /etc/nsswitch.conf -RUN [ ! -e /etc/nsswitch.conf ] && echo 'hosts: files dns' > /etc/nsswitch.conf - -ENV DOCKER_CHANNEL stable -ENV DOCKER_VERSION 18.06.1-ce -# TODO ENV DOCKER_SHA256 -# https://github.com/docker/docker-ce/blob/5b073ee2cf564edee5adca05eee574142f7627bb/components/packaging/static/hash_files !! -# (no SHA file artifacts on download.docker.com yet as of 2017-06-07 though) - -RUN set -eux; \ - \ -# this "case" statement is generated via "update.sh" - apkArch="$(apk --print-arch)"; \ - case "$apkArch" in \ - x86_64) dockerArch='x86_64' ;; \ - armhf) dockerArch='armel' ;; \ - aarch64) dockerArch='aarch64' ;; \ - ppc64le) dockerArch='ppc64le' ;; \ - s390x) dockerArch='s390x' ;; \ - *) echo >&2 "error: unsupported architecture ($apkArch)"; exit 1 ;;\ - esac; \ - \ - if ! wget -O docker.tgz "https://download.docker.com/linux/static/${DOCKER_CHANNEL}/${dockerArch}/docker-${DOCKER_VERSION}.tgz"; then \ - echo >&2 "error: failed to download 'docker-${DOCKER_VERSION}' from '${DOCKER_CHANNEL}' for '${dockerArch}'"; \ - exit 1; \ - fi; \ - \ - tar --extract \ - --file docker.tgz \ - --strip-components 1 \ - --directory /usr/local/bin/ \ - ; \ - rm docker.tgz; \ - \ - dockerd --version; \ - docker --version - -COPY modprobe.sh /usr/local/bin/modprobe -COPY docker-entrypoint.sh /usr/local/bin/ -COPY drush.sh /usr/local/bin/drush -COPY node /usr/local/bin/node -COPY npm /usr/local/bin/npm -COPY volume.php /usr/local/bin/volume.php -COPY gulp /usr/local/bin/gulp - -ENTRYPOINT ["docker-entrypoint.sh"] -CMD ["sh"] - -RUN mkdir -p /root/.ssh && \ +RUN echo 'hosts: files dns' > /etc/nsswitch.conf && \ + set -eux && \ + \ + apkArch="$(apk --print-arch)" && \ + case "$apkArch" in \ + x86_64) dockerArch='x86_64' ;; \ + armhf) dockerArch='armel' ;; \ + aarch64) dockerArch='aarch64' ;; \ + ppc64le) dockerArch='ppc64le' ;; \ + s390x) dockerArch='s390x' ;; \ + *) echo >&2 "error: unsupported architecture ($apkArch)"; exit 1 ;;\ + esac && \ + \ + apk add --no-cache ca-certificates curl openssl && \ + \ + if ! curl -fSL -o docker.tgz "https://download.docker.com/linux/static/${DOCKER_CHANNEL}/${dockerArch}/docker-${DOCKER_VERSION}.tgz"; then \ + echo >&2 "error: failed to download 'docker-${DOCKER_VERSION}' from '${DOCKER_CHANNEL}' for '${dockerArch}'"; \ + exit 1; \ + fi && \ + \ + tar --extract --file docker.tgz --strip-components 1 --directory /usr/local/bin/ && \ + rm docker.tgz; \ + \ + mkdir -p /root/.ssh && \ echo "StrictHostKeyChecking no" >> /root/.ssh/config && \ \ apk update && \ - apk add --no-cache curl openssl openssh ca-certificates wget make patch \ - bash fish python git unzip \ + apk add --no-cache openssh wget make patch bash fish python git unzip \ php7 php7-phar php7-json php7-dom php7-gd php7-mbstring php7-openssl \ - php7-pdo php7-curl php7-xml php7-zip php7-session php7-ctype php7-iconv php7-bcmath \ - php7-tokenizer php7-simplexml php7-xmlwriter && \ + php7-pdo php7-curl php7-xml php7-zip php7-session php7-ctype php7-iconv \ + php7-bcmath && \ + if [ "${PHP_VERSION}" = "7.0" ]; then \ + echo "no extra packages required" ; \ + else \ + apk add --no-cache php7-tokenizer php7-simplexml php7-xmlwriter ; \ + fi && \ \ sed -i -e 's/memory_limit = 128M/memory_limit = -1/g' /etc/php7/php.ini && \ \ @@ -109,4 +89,10 @@ RUN mkdir -p /root/.ssh && \ ln -s /usr/local/bin/docker-compose /usr/local/bin/d-c && \ ln -s /usr/local/bin/drush /usr/local/bin/d +ADD bin/* /usr/local/bin/ + ENV LAKEDROPS_DEV_DC_OPTIONS "-T" + +ENTRYPOINT ["docker-entrypoint.sh"] +CMD ["sh"] + diff --git a/php-7.0/Dockerfile b/bin/Dockerfile similarity index 100% rename from php-7.0/Dockerfile rename to bin/Dockerfile diff --git a/php-7.0/backstop b/bin/backstop similarity index 100% rename from php-7.0/backstop rename to bin/backstop diff --git a/php-7.0/docker-entrypoint.sh b/bin/docker-entrypoint.sh similarity index 100% rename from php-7.0/docker-entrypoint.sh rename to bin/docker-entrypoint.sh diff --git a/php-7.0/drush.sh b/bin/drush similarity index 100% rename from php-7.0/drush.sh rename to bin/drush diff --git a/php-7.0/gulp b/bin/gulp similarity index 100% rename from php-7.0/gulp rename to bin/gulp diff --git a/php-7.0/modprobe.sh b/bin/modprobe similarity index 100% rename from php-7.0/modprobe.sh rename to bin/modprobe diff --git a/php-7.0/node b/bin/node similarity index 100% rename from php-7.0/node rename to bin/node diff --git a/php-7.0/npm b/bin/npm similarity index 100% rename from php-7.0/npm rename to bin/npm diff --git a/php-7.0/volume.php b/bin/volume.php similarity index 100% rename from php-7.0/volume.php rename to bin/volume.php diff --git a/php-7.1/docker-entrypoint.sh b/php-7.1/docker-entrypoint.sh deleted file mode 100755 index 9c6fa052d82519ded4e230c689cf5cc8a99ab58a..0000000000000000000000000000000000000000 --- a/php-7.1/docker-entrypoint.sh +++ /dev/null @@ -1,30 +0,0 @@ -#!/bin/sh -set -e - -# first arg is `-f` or `--some-option` -if [ "${1#-}" != "$1" ]; then - set -- docker "$@" -fi - -# if our command is a valid Docker subcommand, let's invoke it through Docker instead -# (this allows for "docker run docker ps", etc) -if docker help "$1" > /dev/null 2>&1; then - set -- docker "$@" -fi - -# if we have "--link some-docker:docker" and not DOCKER_HOST, let's set DOCKER_HOST automatically -if [ -z "$DOCKER_HOST" -a "$DOCKER_PORT_2375_TCP" ]; then - export DOCKER_HOST='tcp://docker:2375' -fi - -if [ "$1" = 'dockerd' ]; then - cat >&2 <<-'EOW' - 📎 Hey there! It looks like you're trying to run a Docker daemon. - You probably should use the "dind" image variant instead, something like: - docker run --privileged --name some-overlay-docker -d docker:stable-dind --storage-driver=overlay - See https://hub.docker.com/_/docker/ for more documentation and usage examples. - EOW - sleep 3 -fi - -exec "$@" diff --git a/php-7.1/drush.sh b/php-7.1/drush.sh deleted file mode 100755 index 73d6186bcaccbdfd4a369f77efbee72d04d1068d..0000000000000000000000000000000000000000 --- a/php-7.1/drush.sh +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/sh - -docker-compose exec ${LAKEDROPS_DEV_DC_OPTIONS} --user root php drush $@ diff --git a/php-7.1/gulp b/php-7.1/gulp deleted file mode 100755 index ad293f311240496e7e21d004b12b305fb89f38fe..0000000000000000000000000000000000000000 --- a/php-7.1/gulp +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/bash - -./node_modules/gulp/bin/gulp.js diff --git a/php-7.1/modprobe.sh b/php-7.1/modprobe.sh deleted file mode 100755 index b357d893fda288e5ca49d29c4c5646726bd0eab1..0000000000000000000000000000000000000000 --- a/php-7.1/modprobe.sh +++ /dev/null @@ -1,20 +0,0 @@ -#!/bin/sh -set -eu - -# "modprobe" without modprobe -# https://twitter.com/lucabruno/status/902934379835662336 - -# this isn't 100% fool-proof, but it'll have a much higher success rate than simply using the "real" modprobe - -# Docker often uses "modprobe -va foo bar baz" -# so we ignore modules that start with "-" -for module; do - if [ "${module#-}" = "$module" ]; then - ip link show "$module" || true - lsmod | grep "$module" || true - fi -done - -# remove /usr/local/... from PATH so we can exec the real modprobe as a last resort -export PATH='/usr/sbin:/usr/bin:/sbin:/bin' -exec modprobe "$@" diff --git a/php-7.1/node b/php-7.1/node deleted file mode 100755 index f992a76c2da9a07ca2a0e491e9b2069f65c1c1de..0000000000000000000000000000000000000000 --- a/php-7.1/node +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/bash - -docker run -t -v $(php /usr/local/bin/volume.php) -w $PWD node:8-jessie-slim node $@ diff --git a/php-7.1/npm b/php-7.1/npm deleted file mode 100755 index 2de959949e7e024a8655ed7634239a0f8ea7ab7d..0000000000000000000000000000000000000000 --- a/php-7.1/npm +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/bash - -docker run -t -v $(php /usr/local/bin/volume.php) -w $PWD node:8-jessie-slim npm $@ diff --git a/php-7.1/volume.php b/php-7.1/volume.php deleted file mode 100644 index e2db5ee329d0a69490d21147b6196f483dbaed93..0000000000000000000000000000000000000000 --- a/php-7.1/volume.php +++ /dev/null @@ -1,30 +0,0 @@ -<?php - - -function readContainerConfig() { - try { - $output = []; - exec('basename "$(cat /proc/1/cpuset)"', $output); - $id = reset($output); - $output = []; - exec('docker container inspect ' . $id, $output); - return json_decode(implode('', $output), TRUE)[0]; - } - catch (\Exception $ex) { - // Ignore. - } - return []; -} - -function getDockerMountSource() { - $currentDir = getcwd(); - $container = readContainerConfig(); - foreach ($container['Mounts'] as $mount) { - if (strpos($currentDir, $mount['Destination']) === 0) { - return $mount['Source'] . ':' . $mount['Destination']; - } - } - return $currentDir . ':' . $currentDir; -} - -print(getDockerMountSource()); diff --git a/php-7.2/Dockerfile b/php-7.2/Dockerfile deleted file mode 100644 index 67c6c11e2c87aa88c241657d84fef122f9719812..0000000000000000000000000000000000000000 --- a/php-7.2/Dockerfile +++ /dev/null @@ -1,112 +0,0 @@ -FROM alpine:3.8 - -LABEL com.example.vendor="LakeDrops" \ - maintainer="juergen.haas@lakedrops.com" \ - version="1.4.0" \ - description="An image for GitLab runner to build and test Drupal projects." - -ARG compose_version=1.21.2 -ARG glibc_version=2.28-r0 - -RUN apk add --no-cache \ - ca-certificates - -# set up nsswitch.conf for Go's "netgo" implementation (which Docker explicitly uses) -# - https://github.com/docker/docker-ce/blob/v17.09.0-ce/components/engine/hack/make.sh#L149 -# - https://github.com/golang/go/blob/go1.9.1/src/net/conf.go#L194-L275 -# - docker run --rm debian:stretch grep '^hosts:' /etc/nsswitch.conf -RUN [ ! -e /etc/nsswitch.conf ] && echo 'hosts: files dns' > /etc/nsswitch.conf - -ENV DOCKER_CHANNEL stable -ENV DOCKER_VERSION 18.06.1-ce -# TODO ENV DOCKER_SHA256 -# https://github.com/docker/docker-ce/blob/5b073ee2cf564edee5adca05eee574142f7627bb/components/packaging/static/hash_files !! -# (no SHA file artifacts on download.docker.com yet as of 2017-06-07 though) - -RUN set -eux; \ - \ -# this "case" statement is generated via "update.sh" - apkArch="$(apk --print-arch)"; \ - case "$apkArch" in \ - x86_64) dockerArch='x86_64' ;; \ - armhf) dockerArch='armel' ;; \ - aarch64) dockerArch='aarch64' ;; \ - ppc64le) dockerArch='ppc64le' ;; \ - s390x) dockerArch='s390x' ;; \ - *) echo >&2 "error: unsupported architecture ($apkArch)"; exit 1 ;;\ - esac; \ - \ - if ! wget -O docker.tgz "https://download.docker.com/linux/static/${DOCKER_CHANNEL}/${dockerArch}/docker-${DOCKER_VERSION}.tgz"; then \ - echo >&2 "error: failed to download 'docker-${DOCKER_VERSION}' from '${DOCKER_CHANNEL}' for '${dockerArch}'"; \ - exit 1; \ - fi; \ - \ - tar --extract \ - --file docker.tgz \ - --strip-components 1 \ - --directory /usr/local/bin/ \ - ; \ - rm docker.tgz; \ - \ - dockerd --version; \ - docker --version - -COPY modprobe.sh /usr/local/bin/modprobe -COPY docker-entrypoint.sh /usr/local/bin/ -COPY drush.sh /usr/local/bin/drush -COPY node /usr/local/bin/node -COPY npm /usr/local/bin/npm -COPY volume.php /usr/local/bin/volume.php -COPY gulp /usr/local/bin/gulp - -ENTRYPOINT ["docker-entrypoint.sh"] -CMD ["sh"] - -RUN mkdir -p /root/.ssh && \ - echo "StrictHostKeyChecking no" >> /root/.ssh/config && \ - \ - apk update && \ - apk add --no-cache curl openssl openssh ca-certificates wget make patch \ - bash fish python git unzip \ - php7 php7-phar php7-json php7-dom php7-gd php7-mbstring php7-openssl \ - php7-pdo php7-curl php7-xml php7-zip php7-session php7-ctype php7-iconv php7-bcmath \ - php7-tokenizer php7-simplexml php7-xmlwriter && \ - \ - sed -i -e 's/memory_limit = 128M/memory_limit = -1/g' /etc/php7/php.ini && \ - \ - wget -q https://alpine-pkgs.sgerrand.com/sgerrand.rsa.pub -O /etc/apk/keys/sgerrand.rsa.pub && \ - wget -q https://github.com/sgerrand/alpine-pkg-glibc/releases/download/${glibc_version}/glibc-${glibc_version}.apk && \ - apk add --no-cache glibc-${glibc_version}.apk && \ - rm glibc-${glibc_version}.apk && \ - ln -s /lib/libz.so.1 /usr/glibc-compat/lib/ && \ - ln -s /lib/libc.musl-x86_64.so.1 /usr/glibc-compat/lib && \ - ln -s /usr/lib/libgcc_s.so.1 /lib/libgcc_s.so.1 && \ - ln -s /lib/libgcc_s.so.1 /usr/glibc-compat/lib/ && \ - \ - ln -s /usr/bin/php7 /usr/local/bin/php && \ - \ - wget -q https://github.com/ahoy-cli/ahoy/releases/download/2.0.0/ahoy-bin-`uname -s`-amd64 -O /usr/local/bin/ahoy && \ - chmod +x /usr/local/bin/ahoy && \ - \ - wget -q https://github.com/docker/compose/releases/download/${compose_version}/docker-compose-`uname -s`-`uname -m` -O /usr/local/bin/docker-compose && \ - chmod +x /usr/local/bin/docker-compose && \ - \ - wget -q https://getcomposer.org/composer.phar -O /usr/local/bin/composer && \ - chmod +x /usr/local/bin/composer && \ - composer selfupdate && \ - \ - git clone https://github.com/tj/git-extras.git && \ - cd git-extras && \ - git checkout $(git describe --tags $(git rev-list --tags --max-count=1)) && \ - make install && \ - cd .. && \ - rm -rf git-extras && \ - \ - composer global require "hirak/prestissimo:^0.3" && \ - \ - ln -s /usr/local/bin/ahoy /usr/local/bin/a && \ - ln -s /usr/local/bin/composer /usr/local/bin/c && \ - ln -s /usr/local/bin/docker-compose /usr/local/bin/d-c && \ - ln -s /usr/local/bin/drush /usr/local/bin/d - -ENV LAKEDROPS_DEV_DC_OPTIONS "-T" diff --git a/php-7.2/docker-entrypoint.sh b/php-7.2/docker-entrypoint.sh deleted file mode 100755 index 9c6fa052d82519ded4e230c689cf5cc8a99ab58a..0000000000000000000000000000000000000000 --- a/php-7.2/docker-entrypoint.sh +++ /dev/null @@ -1,30 +0,0 @@ -#!/bin/sh -set -e - -# first arg is `-f` or `--some-option` -if [ "${1#-}" != "$1" ]; then - set -- docker "$@" -fi - -# if our command is a valid Docker subcommand, let's invoke it through Docker instead -# (this allows for "docker run docker ps", etc) -if docker help "$1" > /dev/null 2>&1; then - set -- docker "$@" -fi - -# if we have "--link some-docker:docker" and not DOCKER_HOST, let's set DOCKER_HOST automatically -if [ -z "$DOCKER_HOST" -a "$DOCKER_PORT_2375_TCP" ]; then - export DOCKER_HOST='tcp://docker:2375' -fi - -if [ "$1" = 'dockerd' ]; then - cat >&2 <<-'EOW' - 📎 Hey there! It looks like you're trying to run a Docker daemon. - You probably should use the "dind" image variant instead, something like: - docker run --privileged --name some-overlay-docker -d docker:stable-dind --storage-driver=overlay - See https://hub.docker.com/_/docker/ for more documentation and usage examples. - EOW - sleep 3 -fi - -exec "$@" diff --git a/php-7.2/drush.sh b/php-7.2/drush.sh deleted file mode 100755 index 73d6186bcaccbdfd4a369f77efbee72d04d1068d..0000000000000000000000000000000000000000 --- a/php-7.2/drush.sh +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/sh - -docker-compose exec ${LAKEDROPS_DEV_DC_OPTIONS} --user root php drush $@ diff --git a/php-7.2/gulp b/php-7.2/gulp deleted file mode 100755 index ad293f311240496e7e21d004b12b305fb89f38fe..0000000000000000000000000000000000000000 --- a/php-7.2/gulp +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/bash - -./node_modules/gulp/bin/gulp.js diff --git a/php-7.2/modprobe.sh b/php-7.2/modprobe.sh deleted file mode 100755 index b357d893fda288e5ca49d29c4c5646726bd0eab1..0000000000000000000000000000000000000000 --- a/php-7.2/modprobe.sh +++ /dev/null @@ -1,20 +0,0 @@ -#!/bin/sh -set -eu - -# "modprobe" without modprobe -# https://twitter.com/lucabruno/status/902934379835662336 - -# this isn't 100% fool-proof, but it'll have a much higher success rate than simply using the "real" modprobe - -# Docker often uses "modprobe -va foo bar baz" -# so we ignore modules that start with "-" -for module; do - if [ "${module#-}" = "$module" ]; then - ip link show "$module" || true - lsmod | grep "$module" || true - fi -done - -# remove /usr/local/... from PATH so we can exec the real modprobe as a last resort -export PATH='/usr/sbin:/usr/bin:/sbin:/bin' -exec modprobe "$@" diff --git a/php-7.2/node b/php-7.2/node deleted file mode 100755 index f992a76c2da9a07ca2a0e491e9b2069f65c1c1de..0000000000000000000000000000000000000000 --- a/php-7.2/node +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/bash - -docker run -t -v $(php /usr/local/bin/volume.php) -w $PWD node:8-jessie-slim node $@ diff --git a/php-7.2/npm b/php-7.2/npm deleted file mode 100755 index 2de959949e7e024a8655ed7634239a0f8ea7ab7d..0000000000000000000000000000000000000000 --- a/php-7.2/npm +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/bash - -docker run -t -v $(php /usr/local/bin/volume.php) -w $PWD node:8-jessie-slim npm $@ diff --git a/php-7.2/volume.php b/php-7.2/volume.php deleted file mode 100644 index e2db5ee329d0a69490d21147b6196f483dbaed93..0000000000000000000000000000000000000000 --- a/php-7.2/volume.php +++ /dev/null @@ -1,30 +0,0 @@ -<?php - - -function readContainerConfig() { - try { - $output = []; - exec('basename "$(cat /proc/1/cpuset)"', $output); - $id = reset($output); - $output = []; - exec('docker container inspect ' . $id, $output); - return json_decode(implode('', $output), TRUE)[0]; - } - catch (\Exception $ex) { - // Ignore. - } - return []; -} - -function getDockerMountSource() { - $currentDir = getcwd(); - $container = readContainerConfig(); - foreach ($container['Mounts'] as $mount) { - if (strpos($currentDir, $mount['Destination']) === 0) { - return $mount['Source'] . ':' . $mount['Destination']; - } - } - return $currentDir . ':' . $currentDir; -} - -print(getDockerMountSource());