11# ####### Clients [Screen|Admin] build ########
2- FROM node:24-alpine AS client_app_builder
2+ FROM --platform=$BUILDPLATFORM node:24-alpine AS client_app_builder
33LABEL maintainer="ITK Dev <itkdev@mkb.aarhus.dk>"
44
55ARG APP_VERSION="develop"
@@ -10,44 +10,37 @@ ENV APP_CLIENT_PATH=/app
1010WORKDIR ${APP_CLIENT_PATH}
1111
1212# Copy only necessary files for npm install
13- COPY --from=repository-root package.json package-lock.json vite.config.js ./
13+ COPY package.json package-lock.json vite.config.js ./
1414
1515# Install dependencies
1616RUN npm ci --no-audit --no-fund
1717
1818# Copy source files needed for build
19- COPY --from=repository-root assets/ ./assets/
20- COPY --from=repository-root public/client/ ./public/client/
19+ COPY assets/ ./assets/
20+ COPY public/client/ ./public/client/
2121
2222# Build the application with version info
2323RUN npm run build
2424
2525
2626# ######## API backend build ########
27- FROM itkdev/php8.4-fpm:alpine AS api_app_builder
27+ FROM --platform=$BUILDPLATFORM itkdev/php8.4-fpm:latest AS api_app_builder
2828LABEL maintainer="ITK Dev <itkdev@mkb.aarhus.dk>"
2929
3030ARG APP_VERSION="develop"
3131ENV APP_CLIENT_PATH=/app \
3232 APP_API_PATH=/var/www/html
3333
34- USER root
35-
36- # Add composer in from the official composer image (also alpine).
37- COPY --from=composer:2 /usr/bin/composer /usr/local/bin/composer
38-
3934WORKDIR ${APP_API_PATH}
4035
41- USER deploy
42-
4336# Copy only composer files first for better layer caching
44- COPY --chown=deploy:deploy --from=repository-root composer.json composer.lock symfony.lock ${APP_API_PATH}/
37+ COPY composer.json composer.lock symfony.lock ${APP_API_PATH}/
4538
4639# Pre-install composer packages first (better image layer caching) - application code not present so have to be re-run
4740RUN APP_ENV=prod composer install --no-dev -o --classmap-authoritative --no-scripts
4841
4942# Copy application source (needed for build step)
50- COPY --chown=deploy:deploy --from=repository-root ./ ${APP_API_PATH}/
43+ COPY ./ ${APP_API_PATH}/
5144
5245# Copy javascript build files. This ensures that vite manifest files are availiable when "composer insatll"
5346# triggers a "cache:clear" enabling the vite bundle to generate cache configuration files
@@ -57,43 +50,41 @@ COPY --chown=deploy:deploy --from=client_app_builder ${APP_CLIENT_PATH}/public/b
5750# Re-run composer install after application code copied to image to complete install
5851RUN APP_ENV=prod composer install --no-dev --optimize-autoloader --classmap-authoritative
5952
53+ # Remove files we do not need to the final image
54+ RUN rm -rf \
55+ docker-compose.* \
56+ package* \
57+ phpstan.dist.neon \
58+ psalm* \
59+ playwright.* \
60+ phpunit.* \
61+ rector.php \
62+ Taskfile.yml \
63+ .markdown* \
64+ .php-cs-fixer.dist.php \
65+ .twig-cs-fixer.dist.php \
66+ .prettier \
67+ vite.config.js
6068
6169# ####### PHP-FPM (API) production image ########
62- FROM itkdev/php8.4-fpm:alpine
70+ FROM --platform=$BUILDPLATFORM itkdev/php8.4-fpm:alpine
6371LABEL maintainer="ITK Dev <itkdev@mkb.aarhus.dk>"
6472
6573ENV APP_CLIENT_PATH=/app \
6674 APP_API_PATH=/var/www/html \
6775 APP_ENV=prod \
6876 COMPOSER_VERSION=2 \
69-
70- # OpCache
7177 PHP_OPCACHE_ENABLED=1 \
7278 PHP_OPCACHE_VALIDATE_TIMESTAMPS=0 \
7379 PHP_OPCACHE_MAX_ACCELERATED_FILES=20000 \
7480 PHP_OPCACHE_MEMORY_CONSUMPTION=256 \
75-
76- # FPM pool
7781 PHP_PM_TYPE="dynamic" \
7882 PHP_PM_MAX_CHILDREN="24" \
7983 PHP_PM_MAX_REQUESTS="0" \
8084 PHP_PM_START_SERVERS="5" \
8185 PHP_PM_MIN_SPARE_SERVERS="5" \
8286 PHP_PM_MAX_SPARE_SERVERS="10"
8387
84- USER root
85-
86- # Add composer needed to run optimizations after config is loaded.
87- COPY --from=composer:2 /usr/bin/composer /usr/local/bin/composer
88-
89- # Download Prometheus php-fpm export.
90- COPY --from=hipages/php-fpm_exporter:2.2.0 /php-fpm_exporter /usr/local/bin/php-fpm_exporter
91-
92- COPY docker-entrypoint.sh /usr/local/bin/
93- RUN chmod +x /usr/local/bin/docker-entrypoint.sh
94-
95- USER deploy
96-
9788WORKDIR ${APP_API_PATH}
9889
9990# Install the api application.
0 commit comments