-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathDockerfile
53 lines (40 loc) · 1.42 KB
/
Dockerfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
FROM node:18 as front-builder
WORKDIR /app
# Copy package manager files, and vendor because that way laravel-mix knows that it's laravel
COPY package.json package-lock.json webpack.mix.js tailwind.config.js .babelrc postcss.config.js artisan ./
RUN npm ci
COPY resources ./resources
RUN npm run production
FROM composer:2 as back-builder
WORKDIR /app
COPY composer.json composer.lock ./
RUN composer install \
--ignore-platform-reqs \
--no-ansi \
--no-autoloader \
--no-dev \
--no-interaction \
--no-scripts
COPY . .
RUN composer dump-autoload -a
# Build app image
FROM php:8-apache
COPY --from=mlocati/php-extension-installer /usr/bin/install-php-extensions /usr/bin/
RUN install-php-extensions opcache pgsql pdo_pgsql bcmath mysqli pdo_mysql pcntl
RUN a2enmod rewrite
COPY .docker/apache.conf /etc/apache2/sites-available/000-default.conf
COPY .docker/php.ini ${PHP_INI_DIR}/conf.d/99-overrides.ini
COPY .docker/entrypoint.sh /usr/local/bin/entrypoint.sh
WORKDIR /app
COPY --chown=www-data:www-data --from=back-builder /app/ /app
COPY --chown=www-data:www-data --from=front-builder /app/public/ /app/public
VOLUME /app/storage/logs
VOLUME /app/storage/app
# Cache everything except config cache because .env is loaded at container creation time.
USER www-data
RUN php artisan route:cache \
&& php artisan event:cache \
&& php artisan view:cache
USER root
ENTRYPOINT ["entrypoint.sh"]
CMD ["apache2-foreground"]