-
Notifications
You must be signed in to change notification settings - Fork 1
/
Dockerfile
74 lines (50 loc) · 2 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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
# Stage: base
FROM php:8.1.8-apache-bullseye AS base
WORKDIR /var/www
ENV COMPOSER_ALLOW_SUPERUSER=1
ENV DEBIAN_FRONTEND=noninteractive
# Apache configuration
COPY build/apache-conf/000-default.conf /etc/apache2/sites-available/
# Enable Apache mod_rewrite
RUN a2enmod rewrite
# Install PHP Extensions
RUN docker-php-ext-install opcache pcntl
# intl extension (required by symfony)
RUN apt-get update \
&& apt-get install -y zlib1g-dev libicu-dev g++ \
&& docker-php-ext-configure intl \
&& docker-php-ext-install intl
# PHP Configuration
COPY build/php-conf/*.ini /usr/local/etc/php/conf.d/
# Stage: Development
FROM base as development
# Install node.js apt repository
RUN curl -sL https://deb.nodesource.com/setup_18.x | bash -
# Needed by composer / yarn
RUN apt-get update && apt-get install -y unzip nodejs
# Install yarn
RUN npm install -g yarn
COPY --from=composer /usr/bin/composer /usr/bin/composer
# Stage: composer_install
FROM development AS composer_install
COPY api/composer.* /var/www/api/
RUN APP_ENV=prod composer install --prefer-dist --no-scripts --no-dev --no-autoloader --working-dir=api
# Stage: Preproduction
FROM composer_install as preproduction
COPY . .
# Install nodejs dependencies
RUN yarn --cwd app/ install
# Build the frontend and copy it to the apache webroot
RUN yarn --cwd app/ encore production && cp -r app/assets api/public/
# Make sure we do not have any garbage in the var/ directory
RUN rm -rf /var/www/var/*
# Dump Composer Autoloader
RUN APP_ENV=prod composer dump-autoload --no-dev --classmap-authoritative --working-dir=api/
# Warmup symfony cache
RUN APP_ENV=prod api/bin/console --no-debug cache:warmup
# Load the calendars
RUN APP_ENV=prod api/bin/console calendars:load
# Stage: Proproduction
FROM base as production
# Copy the installed files from preproduction
COPY --from=preproduction /var/www/api /var/www/api