From 8127999afdbebbd453ae058654de6876fb351d61 Mon Sep 17 00:00:00 2001 From: Carlos Gomes Date: Fri, 12 Nov 2021 13:00:30 +0100 Subject: [PATCH] Move away from Alpine as it is smaller but its IO is 20% slower The overall gatsby pipeline can increase for more than 30 seconds --- .github/workflows/ci.yml | 4 +- Dockerfile | 87 ++++++++++++++++++++++++++++++++++++++++ Makefile | 8 ++-- 3 files changed, 93 insertions(+), 6 deletions(-) create mode 100644 Dockerfile diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 3c5bc78..361b009 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -45,7 +45,7 @@ jobs: with: push: true build-args: | - FROM_IMAGE=php:7-cli-alpine + FROM_IMAGE=php:7-cli tags: carlosalgms/composer-and-node-ci:php7 @@ -67,7 +67,7 @@ jobs: with: push: true build-args: | - FROM_IMAGE=php:7.1-cli-alpine + FROM_IMAGE=php:7.1-cli DEPLOYER_VERSION="v6.6.0" PECL_EXT="" ENABLE_EXT="" diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..e5caf9b --- /dev/null +++ b/Dockerfile @@ -0,0 +1,87 @@ +ARG FROM_IMAGE=php:8-cli +FROM $FROM_IMAGE + +LABEL maintainer="Carlos A. Gomes " + + +RUN apt-get update \ + && apt-get upgrade -y \ + && apt-get install -y --no-install-recommends \ + util-linux \ + zsh \ + vim \ + ca-certificates \ + zip \ + unzip \ + openssh-client \ + rsync \ + git \ + default-mysql-client \ + make \ + && apt-get autoclean \ + && apt-get clean \ + && rm -rf /var/cache/debconf/*-old \ + && rm -rf /usr/share/doc/* \ + && rm -rf /var/lib/apt/lists/* \ + && rm -rf /var/cache/apt/* + + +ARG PECL_EXT="mcrypt-1.0.4" +ARG PHP_EXT="mysqli pspell zip" +ARG ENABLE_EXT="mcrypt" + +RUN apt-get update \ + && apt-get install -y --no-install-recommends \ + libzip4 \ + libmcrypt4 \ + aspell \ + g++ \ + autoconf \ + libzip-dev \ + libmcrypt-dev \ + libaspell-dev \ + libpspell-dev \ + && ( \ + [ -z "$PECL_EXT" ] || \ + ( \ + pecl install $PECL_EXT \ + && docker-php-ext-enable $ENABLE_EXT \ + ) \ + ) \ + && docker-php-ext-install -j "$(nproc)" $PHP_EXT \ + && apt-get remove -y \ + g++ \ + autoconf \ + libzip-dev \ + libmcrypt-dev \ + libaspell-dev \ + libpspell-dev \ + && apt-get autoremove -y \ + && apt-get autoclean -y \ + && apt-get clean -y \ + && rm -rf /var/cache/debconf/*-old \ + && rm -rf /usr/share/doc/* \ + && rm -rf /var/lib/apt/lists/* \ + && rm -rf /var/cache/apt/* + + +RUN curl "https://getcomposer.org/installer" --output "composer-setup.php" \ + && php -r "if (hash_file('sha384', 'composer-setup.php') === '906a84df04cea2aa72f40b5f787e49f22d4c2f19492ac310e8cba5b96ac8b64115ac402c8cd292b8a03482574915d1a8') { echo 'Installer verified'; } else { echo 'Installer corrupt'; } echo PHP_EOL;" \ + && php composer-setup.php --install-dir=/usr/local/bin --filename=composer \ + && rm "composer-setup.php" + + +ARG DEPLOYER_VERSION="v6.8.0" +RUN curl -L https://deployer.org/releases/${DEPLOYER_VERSION}/deployer.phar --output /usr/local/bin/dep \ + && chmod +x /usr/local/bin/dep + + +# Install node, npm and yarn +ARG NODE_VERSION="v16.13.0" +RUN curl -O https://nodejs.org/dist/${NODE_VERSION}/node-${NODE_VERSION}-linux-x64.tar.xz \ + && tar xJf node-v*.xz -C /usr --strip-components=1 --no-same-owner \ + && rm node-v*.xz \ + && npm i -g yarn + + +COPY zshrc /root/.zshrc diff --git a/Makefile b/Makefile index f18e1b1..e9c2901 100644 --- a/Makefile +++ b/Makefile @@ -6,14 +6,14 @@ build_8: build_7: docker build . --rm \ - --build-arg=FROM_IMAGE="php:7-cli-alpine" \ + --build-arg=FROM_IMAGE="php:7-cli" \ -t carlosalgms/composer-and-node-ci:php7 build_71: docker build . --rm \ - -t carlosalgms/composer-and-node-ci:php7.1 \ - --build-arg=FROM_IMAGE="php:7.1-cli-alpine" \ + --build-arg=FROM_IMAGE="php:7.1-cli" \ --build-arg=DEPLOYER_VERSION="v6.6.0" \ --build-arg=PECL_EXT="" \ --build-arg=ENABLE_EXT="" \ - --build-arg=PHP_EXT="mysqli pspell zip mcrypt" + --build-arg=PHP_EXT="mysqli pspell zip mcrypt" \ + -t carlosalgms/composer-and-node-ci:php7.1 \