dev-resources.site
for different kinds of informations.
Set Up PHP 8 Environment Using Docker with a Custom Dockerfile
Published at
11/27/2024
Categories
devops
webdev
php
laravel
Author
Hรฒa Nguyแป
n Coder
You use Docker to run PHP 8 through a custom Dockerfile. This process involves building an image from the Dockerfile, where PHP and necessary extensions are installed, then running a container based on that image to set up a PHP environment ready for development or deployment.
FROM php:8.2-fpm-alpine
ARG user
ARG uid
WORKDIR /var/www/html
RUN apk add --no-cache mysql-client msmtp perl wget procps shadow libzip libpng libjpeg-turbo libwebp freetype icu icu-data-full
RUN docker-php-ext-install pdo_mysql
RUN apk add --no-cache --virtual build-essentials \
icu-dev icu-libs zlib-dev g++ make automake autoconf libzip-dev \
libpng-dev libwebp-dev libjpeg-turbo-dev freetype-dev && \
docker-php-ext-configure gd --enable-gd --with-freetype --with-jpeg --with-webp && \
docker-php-ext-install gd && \
docker-php-ext-install mysqli && \
docker-php-ext-install pdo_mysql && \
docker-php-ext-install intl && \
docker-php-ext-install opcache && \
docker-php-ext-install exif && \
docker-php-ext-install zip && \
apk del build-essentials && rm -rf /usr/src/php*
RUN wget https://getcomposer.org/composer-stable.phar -O /usr/local/bin/composer && chmod +x /usr/local/bin/composer
RUN useradd -G www-data,root -u $uid -d /home/$user $user
RUN mkdir -p /home/$user/.composer && \
chown -R $user:$user /home/$user
COPY . /var/www/html
CMD ["php-fpm"]
๐ Youtube : Hoร Nguyแป n Coder
๐ Tiktok: https://www.tiktok.com/@hoanguyencoder
๐ Twitter: https://x.com/skipperhoa
๐ Fanpage: https://www.facebook.com/profile.php?id=100049475056780
Articles
12 articles in total
How to Connect Redis with PHP Using Docker Compose
read article
Factory Method Design Pattern Explained with PHP Examples
read article
Docker Compose Demo: Running Multiple Services with Two Domains on Localhost
read article
Set Up PHP 8 Environment Using Docker with a Custom Dockerfile
currently reading
PHP version 8.0 - Named Parameters
read article
Using ON DUPLICATE KEY UPDATE and NOT EXISTS in MySQL
read article
Mail Service using Singleton Design Pattern in PHP
read article
Sending Emails with Mailer in PHP + Symfony
read article
Fix Bug Search and Pagination in Vue.js: Dev Wants to Chill But Bug Doesn't Let
read article
Vue Tip : Setup Store Pinia + Custom Pagination
read article
โก MySecondApp - React Native with Expo (P24) - Animated Online Status for User
read article
โก MySecondApp - React Native with Expo (P23) - Layout My Account
read article
Featured ones: