Skip to content

Commit

Permalink
composer update
Browse files Browse the repository at this point in the history
  • Loading branch information
4rthem committed Nov 20, 2024
1 parent 97fa815 commit 1c67e1d
Show file tree
Hide file tree
Showing 14 changed files with 511 additions and 592 deletions.
12 changes: 8 additions & 4 deletions bin/optimize-composer-docker-cache
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ function updateProject(string $project)
'export COMPOSER_MEMORY_LIMIT=-1',
'(cd %s',
'rm -rf composer.lock vendor',
'composer update --no-interaction --no-scripts --ansi --no-plugins',
'composer update --no-install --no-interaction --no-scripts --ansi --no-plugins',
'rm -rf vendor)',
'(cd %s && composer update --no-interaction --ansi)',
]), dirname($composerCacheSrc), $project));
Expand All @@ -74,22 +74,26 @@ function updateProject(string $project)
function flattenSubRequire(string $workingDir, array $composer): array {
$repositories = $composer['repositories'] ?? null;
if ($repositories) {
$localPackages = [];
foreach ($repositories as $repository) {
if ('path' === $repository['type']) {
$url = $repository['url'];
$path = $workingDir.'/'.preg_replace('#^\./#', '', $url);

$subComposer = json_decode(file_get_contents($path.'/composer.json'), true, 512, JSON_THROW_ON_ERROR);

unset($composer['require'][$subComposer['name']]);

$localPackages[$subComposer['name']] = true;
foreach ($subComposer['require'] as $lib => $version) {
if (str_contains($lib, '/')) {
$composer['require'][$lib] = $version;
$composer['require'][$lib] ??= $version;
}
}
}
}

foreach (array_keys($localPackages) as $localPackage) {
unset($composer['require'][$localPackage]);
}
}

return $composer;
Expand Down
13 changes: 9 additions & 4 deletions databox/api/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -47,23 +47,28 @@ RUN apk add --no-cache \
exif \
&& apk del build-essentials

RUN chown -R app:app .

USER app

# Warm up composer cache for faster builds
COPY ./databox/api/docker/caching/composer.* ./
RUN composer install --prefer-dist --no-dev --no-progress --classmap-authoritative --no-interaction --no-scripts \
&& rm -rf vendor composer.*
# End warm up

COPY --chown=app:app lib/php /lib/php
COPY --chown=app:app ./databox/api .
COPY lib/php /lib/php
COPY ./databox/api .

RUN mkdir -p var/cache var/logs var/sessions \
&& composer install --prefer-dist --no-dev --no-progress --classmap-authoritative --no-interaction \
&& composer clear-cache \
&& chown -R app: .
&& composer clear-cache

ARG SENTRY_RELEASE
ENV SENTRY_RELEASE=${SENTRY_RELEASE}

USER root

ENTRYPOINT ["/srv/app/docker/php-entrypoint.sh"]

CMD ["php-fpm"]
Expand Down
Loading

0 comments on commit 1c67e1d

Please sign in to comment.