Newer
Older
# RUN composer install --no-dev --optimize-autoloader
RUN composer install --optimize-autoloader --ignore-platform-reqs
# RUN pecl install redis && docker-php-ext-enable redis
#### Step 2 : node
FROM node AS node
COPY . /var/www/html
WORKDIR /var/www/html
ENV NODE_OPTIONS=--openssl-legacy-provider
RUN npm --version && npm install && npm run prod
#### Step 3 : the actual docker image
FROM php:7.4-apache
### PHP
# we may need some other php modules, but we can first check the enabled
RUN pecl install -o -f redis \
&& rm -rf /tmp/pear \
&& docker-php-ext-enable redis
### Apache
# change the document root to /var/www/html/public
RUN sed -i -e "s/html/html\/public/g" \
/etc/apache2/sites-enabled/000-default.conf
# enable apache mod_rewrite
RUN a2enmod rewrite
### Laravel application
# copy source files
COPY . /var/www/html
COPY --from=composer /var/www/html/vendor /var/www/html/vendor
COPY --from=node /var/www/html/public/css /var/www/html/public/css
COPY --from=node /var/www/html/public/js /var/www/html/public/js
COPY --from=node /var/www/html/public/fonts /var/www/html/public/fonts
# copy env file for our Docker image
COPY env.docker /var/www/html/.env
# these directories need to be writable by Apache
RUN chown -R www-data:www-data /var/www/html/storage \
/var/www/html/bootstrap/cache
RUN php artisan config:clear
RUN php artisan route:clear
### Docker image metadata
VOLUME ["/var/www/html/storage", "/var/www/html/bootstrap/cache"]