From 7d26f8d0c5e7dd106cb08d648102e072690e51d4 Mon Sep 17 00:00:00 2001 From: Alex Tselegidis Date: Sat, 21 Jan 2023 12:41:05 +0100 Subject: [PATCH] Use the official php:8.0-alpine package and perform a composer and NPM installation every time the containers get started --- docker-compose.yml | 10 +++++----- docker/php-fpm/Dockerfile | 29 +++++++++++++++++------------ docker/php-fpm/start-container | 13 +++++++++++++ 3 files changed, 35 insertions(+), 17 deletions(-) create mode 100644 docker/php-fpm/start-container diff --git a/docker-compose.yml b/docker-compose.yml index a3ae26f0..b2023639 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -7,10 +7,10 @@ services: - host.docker.internal:host-gateway volumes: - '.:/var/www/html' - - './docker/php-fpm/php-ini-overrides.ini:/etc/php/8.0/fpm/conf.d/99-overrides.ini' + - './docker/php-fpm/php-ini-overrides.ini:/usr/local/etc/php/conf.d/99-overrides.ini' - webserver: - image: 'nginx:alpine' + nginx: + image: 'nginx:1.23.3-alpine' working_dir: /var/www/html volumes: - '.:/var/www/html' @@ -31,7 +31,7 @@ services: - '3001:3306' phpmyadmin: - image: phpmyadmin + image: 'phpmyadmin:5.2.0' restart: always ports: - '3002:80' @@ -39,6 +39,6 @@ services: - 'PMA_ARBITRARY=1' mailhog: - image: 'mailhog/mailhog:latest' + image: 'mailhog/mailhog:v1.0.1' ports: - '3003:8025' diff --git a/docker/php-fpm/Dockerfile b/docker/php-fpm/Dockerfile index 6754d317..5e9b682f 100644 --- a/docker/php-fpm/Dockerfile +++ b/docker/php-fpm/Dockerfile @@ -1,15 +1,20 @@ -FROM phpdockerio/php:8.0-fpm +FROM php:8.0-fpm + WORKDIR "/var/www/html" -RUN apt-get update; \ - apt-get -y --no-install-recommends install \ +RUN apt-get update \ + && apt-get install -y \ git \ - php8.0-gd \ - php8.0-intl \ - php8.0-ldap \ - php8.0-mcrypt \ - php8.0-mysql \ - php8.0-soap \ - php8.0-xdebug; \ - apt-get clean; \ - rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* /usr/share/doc/* + zip \ + unzip \ + && curl -sSL https://github.com/mlocati/docker-php-extension-installer/releases/latest/download/install-php-extensions -o - | sh -s \ + curl gd intl ldap mbstring mysqli odbc pdo soap sockets xml zip xdebug \ + && curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer \ + && curl -sLS https://deb.nodesource.com/setup_18.x | bash - \ + && apt-get install -y nodejs \ + && npm install -g npm \ + && apt-get -y autoremove \ + && apt-get clean \ + && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* + +CMD ["bash", "docker/php-fpm/start-container"] diff --git a/docker/php-fpm/start-container b/docker/php-fpm/start-container new file mode 100644 index 00000000..12af2efc --- /dev/null +++ b/docker/php-fpm/start-container @@ -0,0 +1,13 @@ +#!/bin/bash + +echo "➜ Install Composer Dependencies" +composer install + +echo "➜ Install NPM Dependencies" +npm install + +echo "➜ Build Project Assets" +gulp build + +echo "➜ Listen To Incoming Requests" +php-fpm