I'm dockerizing a laravel application, my image is based on an apache image, this is being hosted in AKS, where I'm mounting azure files with images share inside /public/images, the problem is apache would add header inside the image resulting in corrupting the images
even if I exec inside the pod itself and try curl localhost, I get the same problem so I'm sure it's not a problem with routing or my ingress
FROM php:7.3-apache
#install all the system dependencies and enable PHP modules
RUN apt-get update -y && apt-get install -y libmcrypt-dev openssl
RUN apt-get update && apt-get install -y libmcrypt-dev \
&& pecl install mcrypt-1.0.2 \
&& docker-php-ext-enable mcrypt
RUN docker-php-ext-install pdo mbstring
RUN apt-get install -y \
libzip-dev \
zip \
&& docker-php-ext-install zip
RUN apt-get install -y libfreetype6-dev libjpeg62-turbo-dev libpng-dev && \
docker-php-ext-configure gd --with-freetype-dir=/usr/include/ --with-jpeg-dir=/usr/include/
RUN docker-php-ext-install gd
RUN docker-php-ext-install mysqli pdo pdo_mysql
# RUN apt-get install wget
RUN apt-get update; apt-get install curl -y
#install composer
RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/bin/ --filename=composer
#set our application folder as an environment variable
ENV APP_HOME /var/www/html
#change uid and gid of apache to docker user uid/gid
RUN usermod -u 1000 www-data && groupmod -g 1000 www-data
#change the web_root to laravel /var/www/html/public folder
#RUN sed -i -e "s/html/html\/public/g" /etc/apache2/sites-enabled/000-default.conf
COPY vhost.conf /etc/apache2/sites-available/000-default.conf
RUN echo "EnableSendfile off" >> /etc/apache2/apache2.conf
# enable apache module rewrite
RUN a2enmod rewrite
#copy source files and run composer
COPY . $APP_HOME
# install all PHP dependencies
RUN composer install --no-interaction
#change ownership of our applications
RUN chown -R www-data:www-data $APP_HOME
next using regular deployment yaml file to push this to kubernetes with the following Volume mounts:
volumeMounts:
- name: sessions
mountPath: /var/www/html/storage/framework/sessions
- name: cache
mountPath: /var/www/html/storage/framework/cache
- name: views
mountPath: /var/www/html/storage/framework/views
- name: images
mountPath: /var/www/html/public/images
volumes:
now the problem is if i try to access a static file from images folder, by example using a url like "https://www.somedomain.com/images/somefile.png"
the file will be download but apache will attach the above headers to the content resulting in corruption.
the web applications work perfectly fine, except for any files inside the volume mounts.
if i do "kubectl exec -it podname -- bash" and browse the files i can see the volume mounts are working fine, also if i try to upload files from the application interface, the file gets written in the write way inside the folder, only problem is with browsing the file.
We fixed the issue, simply in the vhost.conf, we needed to turn off EnableMMAP
EnableMMAP off