Skip to content

Instantly share code, notes, and snippets.

@AlexSJ
Created April 25, 2024 23:05
Show Gist options
  • Save AlexSJ/430af10266646f12bc0340ec6c454df2 to your computer and use it in GitHub Desktop.
Save AlexSJ/430af10266646f12bc0340ec6c454df2 to your computer and use it in GitHub Desktop.
# --- base php ---
FROM php:8.1-fpm as base-php
ENV TZ="America/Sao_Paulo"
WORKDIR /app
# --- composer build ---
FROM base-php as composer
COPY ./ /app
# update apt and install base packages
RUN apt-get update -qq \
&& apt-get upgrade -qq -y \
&& apt-get install -qq -y \
libzip-dev
# install ext required by phpoffice/phpspreadsheet
RUN docker-php-ext-install zip
# install composer
RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer
ARG GIT_TOKEN
RUN composer config --global github-oauth.github.com $GIT_TOKEN
# --- app build ---
FROM base-php as app
# update apt and install base packages
RUN apt-get update -qq \
&& apt-get upgrade -qq -y \
&& apt-get install -qq -y \
libfreetype6-dev \
libjpeg62-turbo-dev \
libwebp-dev \
libpng-dev \
wget \
libzip-dev \
nano \
nginx
# install php modules required by laravel
RUN docker-php-ext-configure gd --with-freetype --with-jpeg --with-webp \
&& docker-php-ext-install -j$(nproc) gd pdo_mysql zip exif pcntl sockets opcache
# install xdebug
RUN pecl install xdebug-3.1.6 && docker-php-ext-enable xdebug
RUN echo "xdebug.coverage_enable" >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini
RUN echo "xdebug.mode=debug,coverage" >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini
RUN echo "xdebug.start_with_request=yes" >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini
RUN echo "xdebug.remote_port=9003" >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini
RUN echo "xdebug.remote_host=host.docker.internal" >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini
RUN echo "xdebug.log_level=0" >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini
# cleanup apt files
RUN apt-get clean -qq -y \
&& apt-get autoremove -qq -y \
&& rm -rf /var/lib/apt/lists/*
EXPOSE 80
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment