Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Solution: Docker with build for PHP 8.2 #143

Open
szabizs opened this issue Mar 3, 2023 · 0 comments
Open

Solution: Docker with build for PHP 8.2 #143

szabizs opened this issue Mar 3, 2023 · 0 comments

Comments

@szabizs
Copy link

szabizs commented Mar 3, 2023

Hello developers,

I would like to offer assistance to those who intend to use @gkralik's excellent package for PHP 8.2 with Docker. This is not a problem but rather a helpful suggestion, as the package also includes Xdebug for debugging purposes.

So here is a working Dockerfile

FROM php:8.2-fpm

# Arguments defined in docker-compose.yml
ARG user
ARG uid

ENV LD_LIBRARY_PATH=/usr/sap/nwrfcsdk/lib
ENV COMPOSER_ALLOW_SUPERUSER=1

RUN apt-get update && apt-get install -y \
        libfreetype6-dev \
        libjpeg62-turbo-dev \
        libpng-dev \
        libxml2-dev \
    && docker-php-ext-configure gd --with-freetype --with-jpeg \
    && docker-php-ext-install -j$(nproc) gd

RUN apt-get install -y libzip-dev \
    && docker-php-ext-install zip

RUN apt-get update && \
    apt-get install -y libxml2-dev && \
    docker-php-ext-install soap

# Install PHP extensions
RUN apt-get update && \
    docker-php-ext-install pdo_mysql exif pcntl bcmath opcache

RUN apt-get install git -y

RUN cd /usr \
    && mkdir sap \
    && mkdir nwrfcsdk

RUN cd /usr \
    && git clone https://github.com/szabizs/sapnwrfc_php_7_4_linux.git \
    && ls -1 \
    && mv /usr/sapnwrfc_php_7_4_linux /usr/sap/nwrfcsdk

RUN git clone https://github.com/gkralik/php7-sapnwrfc.git

RUN cd php7-sapnwrfc \
    && phpize \
    && ./configure \
    && make \
    && make install

RUN cd /usr/local/etc/php/conf.d \
    && touch ext-sapnwrfc.ini \
    && echo "extension=sapnwrfc.so" > ext-sapnwrfc.ini

# Install imagick library
RUN apt-get update && apt-get install -y \
    libmagickwand-dev --no-install-recommends \
    && pecl install imagick \
	&& docker-php-ext-enable imagick

RUN pecl install xdebug-3.2.0 \
    && docker-php-ext-enable xdebug \
    && echo "xdebug.mode=debug" >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini \
    && echo "xdebug.client_port=9003" >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini \
    && echo "xdebug.start_with_request=yes" >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini \
    && echo "xdebug.discover_client_host=0" >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini \
    && echo "xdebug.client_host=host.docker.internal" >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini

RUN apt-get update && apt-get install -y \
    software-properties-common \
    npm
RUN npm install npm@7 -g && \
    npm install n -g && \
    n latest

RUN npm install cross-env && \
    npm install -D tailwindcss postcss autoprefixer

RUN curl -sS https://getcomposer.org/installer | php -- \
    --install-dir=/usr/local/bin --filename=composer

# Clear cache
RUN apt-get clean && rm -rf /var/lib/apt/lists/*

COPY --from=composer:latest /usr/bin/composer /usr/bin/composer

# Create system user to run Composer and Artisan Commands
RUN mkdir -p /home/$user/.composer && \
    chown -R $user:$user /home/$user

# Expose port 9000 and start php-fpm server (for FastCGI Process Manager)
EXPOSE 4206

WORKDIR /var/wwww

COPY . .

#RUN composer install

USER $user
@gkralik gkralik pinned this issue May 14, 2024
@gkralik gkralik unpinned this issue Jun 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant