Multistag docker file

Hi ,have a doubt please share me multistag docker file for below docker file for this :slight_smile:

FROM php:7.2-apache-stretch

RUN docker-php-ext-install mysqli pdo_mysql
RUN a2enmod rewrite

ARG DEBIAN_FRONTEND=noninteractive
RUN apt-get update && apt-get install -y --fix-missing
apt-utils
gnupg
libmemcached-dev

RUN echo deb Index of /debian stretch main contrib non-free >> /etc/apt/sources.list
RUN echo deb-src Index of /debian stretch main contrib non-free >> /etc/apt/sources.list
RUN curl -sS --insecure http://200.201.11.14/dotdeb.gpg | apt-key update

#RUN echo “deb http://packages.dotdeb.org jessie all” >> /etc/apt/sources.list
#RUN echo “deb-src http://packages.dotdeb.org jessie all” >> /etc/apt/sources.list
#RUN curl -sS --insecure https://www.dotdeb.org/dotdeb.gpg | apt-key add -

Install Zip

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

Install Redis, Memcached

RUN pecl install redis && docker-php-ext-enable redis
RUN pecl install -f memcached && docker-php-ext-enable memcached

RUN apt-get update && apt-get install -y
imagemagick
graphicsmagick
libmemcached-dev
zip
unzip
wget
curl
–no-install-recommends
&& rm -r /var/lib/apt/lists/*

cron vim

RUN
apt-get update
&& apt-get install -y --no-install-recommends cron vim
&& apt-get install -y --no-install-recommends libc-client-dev libkrb5-dev
&& docker-php-ext-configure imap --with-imap --with-imap-ssl --with-kerberos
&& docker-php-ext-install imap
&& apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*

imap

RUN apt-get update && apt-get install -y libc-client-dev libkrb5-dev && rm -r /var/lib/apt/lists/*
RUN docker-php-ext-configure imap --with-kerberos --with-imap-ssl
&& docker-php-ext-install imap && docker-php-ext-install exif

GD & bcmath

RUN buildRequirements=“build-essential libpng-dev libjpeg-dev libfreetype6-dev”
&& apt-get update && apt-get install -y ${buildRequirements} \

&& docker-php-ext-configure gd \

&& docker-php-ext-configure gd --with-freetype-dir=/usr/include/ --with-jpeg-dir=/usr/include/ \
&& docker-php-ext-install gd bcmath \
&& docker-php-ext-enable bcmath \
&& apt-get purge -y ${buildRequirements} \
&& rm -rf /var/lib/apt/lists/*

Imagick

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

WORKDIR /var/www/html

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

COPY . /var/www/html

COPY .env /var/www/html

RUN /usr/local/bin/composer install --optimize-autoloader --ignore-platform-reqs

RUN /usr/local/bin/composer require league/flysystem-aws-s3-v3 ^1.0 --ignore-platform-reqs

RUN chmod -Rf 777 /var/www/html/storage
RUN chown -R www-data:www-data /var/www/html

RUN rm -rf /var/lib/apt/lists/ && curl -sL https://deb.nodesource.com/setup_10.x | bash -
RUN apt-get install nodejs -y
RUN echo “NODE Version:” && node --version
RUN echo “NPM Version:” && npm --version
RUN apt-get install -y libcurl4-openssl-dev pkg-config libssl-dev

RUN pecl config-set php_ini /etc/php.ini

RUN /usr/local/bin/composer dump-autoload --ignore-platform-reqs

RUN touch /usr/local/etc/php/conf.d/uploads.ini
&& echo “upload_max_filesize = 300M;” >> /usr/local/etc/php/conf.d/uploads.ini
&& echo “post_max_size = 350M;” >> /usr/local/etc/php/conf.d/uploads.ini
&& echo “memory_limit = 1024M;” >> /usr/local/etc/php/conf.d/uploads.ini
&& echo “max_input_time = -1;” >> /usr/local/etc/php/conf.d/uploads.ini
&& echo “max_execution_time = 0;” >> /usr/local/etc/php/conf.d/uploads.ini

RUN php artisan optimize:clear

#RUN php artisan migrate --force

#RUN php artisan db:seed --force

RUN npm install

RUN npm install gulp-cli -g

RUN npm install gulp

RUN npm run dev

RUN gulp default

#RUN php artisan passport:install

#RUN php artisan l5-swagger:generate

RUN chmod -R 777 storage

RUN php artisan storage:link

#RUN php artisan cache:clear
#RUN php artisan config:clear
#RUN php artisan view:clear
#RUN php artisan route:clear
#RUN /usr/local/bin/composer dump-autoload --ignore-platform-reqs

COPY ./000-default.conf /etc/apache2/sites-available/000-default.conf

please share it’s multistag docker file for this

i am waiting ,any update please

Hi @anu, can you share more details/context?

  • Is this a lab?
  • A KodeKloud Engineer task?
  • Can you share the link for this?
  • What’s your question?

Thanks,
KodeKloud Support

No it’s not a lab ,i just trying on ec2 instance with above share docker file ,it’s file for laravel admin,and build was successfully build but it’s image is 1.81 G i want to reduce through by converting docker file into multistaging docker file, please share me multistaging docker file for above one

@Vitor I am waiting for your solution ,please help me in this

Hi @anu, since this isn’t related to any course, lab, etc… I can’t just give you a solution. I don’t know your environment, and I can’t just assume something and send you to do. The only thing I can recommend is to check multi-stage documentations here: https://meet.google.com/usw-gdgf-eiz

Thanks,
KodeKloud Support

https://meet.google.com/usw-gdgf-eiz it’s not working

Hi @anu, sorry, but I won’t offer you support through meet. If you are doing our Docker training, review the related classes. If you’re not, check the documentation.

Thanks,
KodeKloud Support

ok but i have not found any how to create multistage docker file

@anu, here are some links:

Thanks,
KodeKloud Support