Skip to content

Instantly share code, notes, and snippets.

@kevinzie
Created June 24, 2022 20:20
Show Gist options
  • Save kevinzie/c6716684d563b12f83364fdca38180b9 to your computer and use it in GitHub Desktop.
Save kevinzie/c6716684d563b12f83364fdca38180b9 to your computer and use it in GitHub Desktop.
Dockerfile Laravel php-apache MSSQL (SQL SERVER) & MYSQL multiple connections
FROM php:7.4.1-apache
# Arguments defined in docker-compose.yml
ARG user
ARG uid
RUN pear config-set php_ini "$PHP_INI_DIR"
# Install system dependencies
RUN apt-get update \
&& apt-get -y install libmagickwand-dev --no-install-recommends \
git \
curl \
libpng-dev \
libonig-dev \
libxml2-dev \
zip \
openssl \
unzip
COPY . /var/www/html
COPY ./docker-compose/apache/vhost.conf /etc/apache2/sites-available/000-default.conf
WORKDIR /var/www/html
RUN chown -R www-data:www-data /var/www/html \
&& a2enmod rewrite \
&& chown -R 775 /var/www/html \
&& ls -al /var/www/html \
RUN printf "\n" | pecl install imagick
RUN docker-php-ext-enable imagick
# libmagickwand-dev \
# --no-install-recommends \
# && yes '' | pecl install imagick || true \
# && echo "extension=imagick.so" > /usr/local/etc/php/conf.d/ext-imagick.ini \
# && docker-php-ext-enable imagick \
# && rm -r /var/lib/apt/lists/* \
#RUN mv "$PHP_INI_DIR/php.ini-development" "$PHP_INI_DIR/php.ini"
#
#RUN echo "extension=imagick.so" >> "$PHP_INI_DIR/php.ini"
# Clear cache
RUN apt-get clean && rm -rf /var/lib/apt/lists/*
# Install PHP extensions
RUN docker-php-ext-install pdo_mysql mbstring exif pcntl bcmath gd
ENV ACCEPT_EULA=Y
RUN apt-get update && apt-get install -y gnupg2
RUN curl https://packages.microsoft.com/keys/microsoft.asc | apt-key add -
RUN curl https://packages.microsoft.com/config/ubuntu/20.04/prod.list > /etc/apt/sources.list.d/mssql-release.list
RUN apt-get update
RUN ACCEPT_EULA=Y apt-get -y --no-install-recommends install msodbcsql17 unixodbc-dev
RUN pecl install sqlsrv
RUN pecl install pdo_sqlsrv
RUN docker-php-ext-install pdo pdo_mysql
RUN docker-php-ext-enable sqlsrv pdo_sqlsrv pdo pdo_mysql
# Get latest Composer
COPY --from=composer:latest /usr/bin/composer /usr/bin/composer
# Create system user to run Composer and Artisan Commands
RUN useradd -G www-data,root -u $uid -d /home/$user $user
RUN mkdir -p /home/$user/.composer && \
chown -R $user:$user /home/$user
# Set working directory
WORKDIR /var/www/html
ADD . /var/www/html
RUN chown -R www-data:www-data /var/www/html
RUN chmod -R 755 /var/www/html/storage /var/www/html/storage/*
RUN chmod o+w /var/www/html/storage/ -R
RUN chmod -R 777 /var/www/html/storage /var/www/html/bootstrap/cache
USER $user
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment