From 525391083ad7b9267af7c889e0d73129c67a0cbc Mon Sep 17 00:00:00 2001 From: Meritoo Date: Thu, 6 Sep 2018 23:33:23 +0200 Subject: [PATCH] Docker > update configuration --- .docker/config/Dockerfile | 64 ---------------- .env | 14 ++++ docker-compose.yml | 19 +++-- docker/config/Dockerfile | 103 ++++++++++++++++++++++++++ {.docker => docker}/config/php.ini | 0 {.docker => docker}/config/xdebug.ini | 0 6 files changed, 129 insertions(+), 71 deletions(-) delete mode 100644 .docker/config/Dockerfile create mode 100644 docker/config/Dockerfile rename {.docker => docker}/config/php.ini (100%) rename {.docker => docker}/config/xdebug.ini (100%) diff --git a/.docker/config/Dockerfile b/.docker/config/Dockerfile deleted file mode 100644 index cb2d05c..0000000 --- a/.docker/config/Dockerfile +++ /dev/null @@ -1,64 +0,0 @@ -FROM php:5.6-cli - -# -# Tools & libraries -# -RUN apt-get update \ - && apt-get install -y --no-install-recommends \ - vim \ - git \ - zip \ - unzip \ - zlib1g-dev \ - libicu-dev \ - && apt-get clean \ - && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* - -# -# PHP extensions -# -RUN docker-php-ext-install \ - zip \ - intl \ - mbstring - -# -# PHP configuration: -# - default configuration -# - timezone -# -COPY php.ini /usr/local/etc/php/php.ini -ARG TIMEZONE -RUN echo "\n""date.timezone = $TIMEZONE""\n" >> /usr/local/etc/php/php.ini - -# -# Xdebug -# -RUN pecl install xdebug \ - && docker-php-ext-enable xdebug -COPY xdebug.ini /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini - -# -# Phing -# -RUN pear channel-discover pear.phing.info \ - && pear install [--alldeps] phing/phing - -# -# Composer + https://packagist.org/packages/hirak/prestissimo package -# -RUN php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');" \ - && php -r "if (hash_file('SHA384', 'composer-setup.php') === \ - '544e09ee996cdf60ece3804abc52599c22b1f40f4323403c44d44fdfdd586475ca9813a858088ffbc1f233e9b180f061') { echo \ - 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;" \ - && php composer-setup.php --install-dir=/usr/local/bin --filename=composer \ - && php -r "unlink('composer-setup.php');" \ - && composer global require --no-plugins --no-scripts hirak/prestissimo \ - && rm -rf /root/.composer/cache/* - -# -# Bash -# -RUN sed -i 's/^# export/export/g' /root/.bashrc \ - && sed -i 's/^# alias/alias/g' /root/.bashrc \ - && echo "\n"'export PATH=/project/vendor/bin:$PATH'"\n" >> /root/.bashrc diff --git a/.env b/.env index c6eb126..c493cdb 100644 --- a/.env +++ b/.env @@ -1 +1,15 @@ +# ----------------------------------------------------------------------------- +### Docker +# ----------------------------------------------------------------------------- + +# +# All containers +# +DOCKER_CONTAINER_OWNER=meritoo +DOCKER_CONTAINER_PROJECT=limesurvey-api-client + +# +# PHP configuration: +# - timezone +# TIMEZONE=Europe/Warsaw diff --git a/docker-compose.yml b/docker-compose.yml index 050add2..701c8b2 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,15 +1,20 @@ version: '3' services: - php-cli: - image: meritoo/limesurvey-api-client - container_name: meritoo-limesurvey-api-client - working_dir: /project + php: + image: ${DOCKER_CONTAINER_OWNER}/${DOCKER_CONTAINER_PROJECT}-php + container_name: ${DOCKER_CONTAINER_OWNER}-${DOCKER_CONTAINER_PROJECT}-php entrypoint: php command: -S 0.0.0.0:9999 build: - context: ./.docker/config + context: ./docker/config args: - - TIMEZONE=$TIMEZONE + - TIMEZONE=${TIMEZONE} volumes: - - .:/project + - .:/project:cached + composer: + image: ${DOCKER_CONTAINER_OWNER}/${DOCKER_CONTAINER_PROJECT}-php + container_name: ${DOCKER_CONTAINER_OWNER}-${DOCKER_CONTAINER_PROJECT}-composer + entrypoint: composer + volumes: + - .:/project:cached diff --git a/docker/config/Dockerfile b/docker/config/Dockerfile new file mode 100644 index 0000000..a9b7873 --- /dev/null +++ b/docker/config/Dockerfile @@ -0,0 +1,103 @@ +FROM php:5.6-cli +MAINTAINER Meritoo + +# +# Tools & libraries +# +RUN apt-get update \ + && apt-get install -y --no-install-recommends \ + vim \ + git \ + zip \ + unzip \ + zlib1g-dev \ + libicu-dev \ + && apt-get clean \ + && rm -rf \ + /var/lib/apt/lists/* \ + /tmp/* \ + /var/tmp/* + +# +# PHP extensions +# +RUN docker-php-ext-install \ + zip \ + intl \ + mbstring + +# +# PHP extensions (PECL): +# - Xdebug +# +RUN pecl install \ + xdebug-2.5.5 \ + && docker-php-ext-enable \ + xdebug + +COPY xdebug.ini /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini + +# +# PHP configuration: +# - default configuration +# - timezone +# +COPY php.ini /usr/local/etc/php/php.ini +ARG TIMEZONE +RUN ln -snf /usr/share/zoneinfo/${TIMEZONE} /etc/localtime \ + && echo ${TIMEZONE} > /etc/timezone \ + && printf '[PHP]\ndate.timezone = "%s"\n' ${TIMEZONE} > /usr/local/etc/php/conf.d/tzone.ini \ + && "date" + +# +# Phing +# +RUN pear channel-discover pear.phing.info \ + && pear install [--alldeps] phing/phing + +# +# Composer - environment variables: +# - disable warning about running commands as root/super user +# - disable automatic clearing of sudo sessions +# +# More: +# https://getcomposer.org/doc/03-cli.md#composer-allow-superuser +# +ENV COMPOSER_ALLOW_SUPERUSER 1 + +# +# Composer + https://packagist.org/packages/hirak/prestissimo package +# +RUN php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');" \ + && php -r "if (hash_file('SHA384', 'composer-setup.php') === \ + '544e09ee996cdf60ece3804abc52599c22b1f40f4323403c44d44fdfdd586475ca9813a858088ffbc1f233e9b180f061') { echo \ + 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;" \ + && php composer-setup.php --install-dir=/usr/local/bin --filename=composer \ + && php -r "unlink('composer-setup.php');" \ + && composer global require \ + --no-plugins \ + --no-scripts \ + --no-progress \ + --no-suggest \ + --no-interaction \ + --prefer-dist \ + --optimize-autoloader \ + --classmap-authoritative \ + hirak/prestissimo \ + && rm -rf ~/.composer/cache/* \ + && composer clear-cache \ + && composer --version + +# +# Bash +# +RUN sed -i 's/^# export/export/g; \ + s/^# alias/alias/g;' ~/.bashrc \ + && echo 'COLUMNS=200'"\n" >> ~/.bashrc + +# +# Use project-related binaries globally +# +ENV PATH="/project/vendor/bin:${PATH}" + +WORKDIR /project diff --git a/.docker/config/php.ini b/docker/config/php.ini similarity index 100% rename from .docker/config/php.ini rename to docker/config/php.ini diff --git a/.docker/config/xdebug.ini b/docker/config/xdebug.ini similarity index 100% rename from .docker/config/xdebug.ini rename to docker/config/xdebug.ini