Created
November 6, 2022 02:44
-
-
Save ryanhs/99ca2e7b369ab6785f24813ad2726b00 to your computer and use it in GitHub Desktop.
laravel dockerfile multistage /app folder, PHP+apache
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
app/vendor/ | |
app/public/js/ | |
app/public/css/ | |
app/node_modules/ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
FROM php:7.4.33-apache as base | |
USER root | |
# Get latest Composer | |
COPY --from=composer:latest /usr/bin/composer /usr/bin/composer | |
# Install system dependencies | |
RUN apt-get update && apt-get install -y \ | |
libmagickwand-dev \ | |
curl ca-certificates \ | |
zip unzip \ | |
nano less time | |
RUN apt-get clean && rm -rf /var/lib/apt/lists/* | |
# php imagick: https://bobcares.com/blog/install-imagick-in-php-docker/ | |
RUN printf "\n" | pecl install imagick | |
RUN docker-php-ext-enable imagick | |
# apache mods | |
RUN a2enmod rewrite | |
# change document root to sed /var/www/html/public | |
RUN sed -i 's/www\/html/www\/html\/public/g' /etc/apache2/sites-available/000-default.conf | |
RUN sed -i 's/www\/html/www\/html\/public/g' /etc/apache2/sites-available/default-ssl.conf | |
#################################################################### | |
FROM node:16.17-buster-slim as laravelmix | |
RUN mkdir -p /var/www/html | |
WORKDIR /var/www/html | |
# install dependencies with env DEVELOPMENT | |
ENV NODE_TLS_REJECT_UNAUTHORIZED=0 | |
ENV NODE_ENV=development | |
COPY app/package*.json ./ | |
RUN npm config set unsafe-perm true | |
RUN yarn --silent --non-interactive | |
# Bundle app source | |
COPY app . | |
RUN yarn dev | |
#################################################################### | |
FROM base as ship | |
WORKDIR /var/www/html | |
COPY app . | |
COPY --from=laravelmix /var/www/html/public /var/www/html/public | |
# install packages | |
RUN composer install --prefer-dist --no-dev --optimize-autoloader --no-interaction | |
RUN php artisan config:cache && \ | |
chmod 777 -R /var/www/html/storage/ && \ | |
chown -R www-data:www-data /var/www/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment