Last active
March 31, 2021 06:48
-
-
Save grantholle/f4ea826102eecb59cae59c1683dc1877 to your computer and use it in GitHub Desktop.
This multistage dockerfile only processes the last "stage"
This file contains 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
# PHP | |
FROM php:8.0-fpm-alpine AS php | |
# Install system dependencies | |
RUN apk update && apk add --no-cache \ | |
git \ | |
curl \ | |
libxml2-dev \ | |
libzip-dev \ | |
libpng-dev \ | |
zip \ | |
unzip \ | |
acl \ | |
fcgi \ | |
file \ | |
gettext \ | |
git \ | |
$PHPIZE_DEPS \ | |
icu-dev \ | |
libzip-dev \ | |
zlib-dev \ | |
postgresql-dev \ | |
oniguruma-dev \ | |
; | |
RUN set -eux; \ | |
docker-php-ext-configure zip; \ | |
docker-php-ext-install \ | |
intl \ | |
zip \ | |
opcache \ | |
pdo_pgsql \ | |
pgsql \ | |
mbstring \ | |
pcntl \ | |
exif \ | |
pcntl \ | |
bcmath \ | |
gd \ | |
; \ | |
pecl install \ | |
redis \ | |
; \ | |
pecl clear-cache; \ | |
docker-php-ext-enable \ | |
opcache \ | |
redis \ | |
; \ | |
runDeps="$( \ | |
scanelf --needed --nobanner --format '%n#p' --recursive /usr/local/lib/php/extensions \ | |
| tr ',' '\n' \ | |
| sort -u \ | |
| awk 'system("[ -e /usr/local/lib/" $1 " ]") == 0 { next } { print "so:" $1 }' \ | |
)"; \ | |
apk add --no-cache --virtual .api-phpexts-rundeps $runDeps; | |
COPY --from=composer:latest /usr/bin/composer /usr/bin/composer | |
RUN chmod +x /usr/bin/composer; sync | |
RUN ln -sf $PHP_INI_DIR/php.ini-production $PHP_INI_DIR/php.ini | |
COPY docker/php/conf.d/production.ini $PHP_INI_DIR/conf.d/config.ini | |
COPY docker/php/supervisord /var/supervisord | |
WORKDIR /var/www/html | |
ENV PATH="${PATH}:/root/.composer/vendor/bin" | |
# Copy needed resources of app. | |
COPY app app | |
COPY bootstrap/app.php bootstrap/app.php | |
COPY config config | |
COPY database database | |
COPY public public | |
COPY resources resources | |
COPY routes routes | |
COPY .env.example .env | |
COPY artisan artisan | |
COPY composer.json composer.json | |
COPY composer.lock composer.lock | |
RUN mkdir -p \ | |
bootstrap/cache \ | |
storage/app/public \ | |
storage/framework/cache/data \ | |
storage/framework/sessions \ | |
storage/framework/views \ | |
storage/logs \ | |
; | |
#RUN composer install --no-interaction --prefer-dist --optimize-autoloader --no-dev | |
RUN chmod +x artisan; sync | |
FROM node:14-alpine AS node | |
COPY package.json package.json | |
COPY package-lock.json package-lock.json | |
COPY webpack.config.js webpack.config.js | |
COPY webpack.mix.js webpack.mix.js | |
# Install deps the clean up unused files afterwards | |
RUN npm i && \ | |
npm run prod &&\ | |
rm -rf node_modules \ | |
resources/js \ | |
resources/css \ | |
package.json \ | |
package-lock.json \ | |
webpack.config.js \ | |
webpack.mix.js \ | |
; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment