Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .docker/clamav.dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ RUN apk add --no-cache tzdata

COPY .docker/config/clamav/clamav.conf /tmp/clamav.conf

RUN cat /tmp/clamav.conf >> /etc/clamav/clamd.conf && rm /tmp/clamav.conf && \
RUN cat /tmp/clamav.conf >> /etc/clamav/clamd.conf && \
rm /tmp/clamav.conf && \
sed -i "s/^LogFile /# LogFile /g" /etc/clamav/clamd.conf && \
sed -i "s/^#LogSyslog /LogSyslog /g" /etc/clamav/clamd.conf && \
sed -i "s/^UpdateLogFile /# UpdateLogFile /g" /etc/clamav/freshclam.conf && \
Expand Down
42 changes: 14 additions & 28 deletions .docker/cli.dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ ENV DRUPAL_PRIVATE_FILES=${DRUPAL_PRIVATE_FILES}
ARG DRUPAL_TEMPORARY_FILES="${TMP:-/tmp}"
ENV DRUPAL_TEMPORARY_FILES=${DRUPAL_TEMPORARY_FILES}

ARG DRUPAL_THEME="drevops"
ARG DRUPAL_THEME=""
ENV DRUPAL_THEME=${DRUPAL_THEME}

ENV COMPOSER_ALLOW_SUPERUSER=1 \
Expand All @@ -47,11 +47,11 @@ ENV COMPOSER_ALLOW_SUPERUSER=1 \
# earlier in the build process (near the top of this file).

# Add more tools.
RUN apk add --no-cache ncurses pv tzdata autoconf g++ make \
&& pecl install pcov \
&& docker-php-ext-enable pcov \
&& docker-php-ext-install pcntl \
&& apk del g++ make autoconf
RUN apk add --no-cache ncurses pv tzdata autoconf g++ make && \
pecl install pcov && \
docker-php-ext-enable pcov && \
docker-php-ext-install pcntl && \
apk del g++ make autoconf
Comment on lines 49 to +54
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick (assertive)

Shrink image by using a virtual build package group

You can avoid leaving behind g++, make, and autoconf layers by installing them as a temporary virtual package and deleting it in one shot:

-RUN apk add --no-cache ncurses pv tzdata autoconf g++ make && \
-    pecl install pcov && \
-    docker-php-ext-enable pcov && \
-    docker-php-ext-install pcntl && \
-    apk del g++ make autoconf
+RUN apk add --no-cache ncurses pv tzdata --virtual .build-deps g++ make autoconf && \
+    pecl install pcov && \
+    docker-php-ext-enable pcov && \
+    docker-php-ext-install pcntl && \
+    apk del .build-deps
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
# Add more tools.
RUN apk add --no-cache ncurses pv tzdata autoconf g++ make \
&& pecl install pcov \
&& docker-php-ext-enable pcov \
&& docker-php-ext-install pcntl \
&& apk del g++ make autoconf
RUN apk add --no-cache ncurses pv tzdata autoconf g++ make && \
pecl install pcov && \
docker-php-ext-enable pcov && \
docker-php-ext-install pcntl && \
apk del g++ make autoconf
# Add more tools.
RUN apk add --no-cache ncurses pv tzdata --virtual .build-deps g++ make autoconf && \
pecl install pcov && \
docker-php-ext-enable pcov && \
docker-php-ext-install pcntl && \
apk del .build-deps
🤖 Prompt for AI Agents
In .docker/cli.dockerfile around lines 49 to 54, the installation of build tools
g++, make, and autoconf leaves residual layers increasing image size. Refactor
the RUN command to install these tools as a virtual package group using apk's
--virtual option, then remove the entire virtual package group in the same RUN
step after use. This ensures all build dependencies are cleaned up in one layer,
shrinking the final image size.


# Add patches and scripts.
COPY patches /app/patches
Expand All @@ -72,33 +72,19 @@ COPY composer.json composer.* .env* auth* /app/
RUN if [ -n "${GITHUB_TOKEN}" ]; then export COMPOSER_AUTH="{\"github-oauth\": {\"github.com\": \"${GITHUB_TOKEN}\"}}"; fi && \
COMPOSER_MEMORY_LIMIT=-1 composer install -n --no-dev --ansi --prefer-dist --optimize-autoloader

# Install NodeJS dependencies.
# Install NodeJS dependencies.
# Note that package-lock.json is not explicitly copied, allowing to run the
# stack without existing lock file (this is not advisable, but allows to build
# using latest versions of packages). package-lock.json should be comitted to
# the repository.
# File Gruntfile.js is copied into image as it is required to generate
# front-end assets.
COPY ${WEBROOT}/themes/custom/${DRUPAL_THEME}/package.json ${WEBROOT}/themes/custom/${DRUPAL_THEME}/package* /app/${WEBROOT}/themes/custom/${DRUPAL_THEME}/
COPY ${WEBROOT}/themes/custom/${DRUPAL_THEME}/patches /app/${WEBROOT}/themes/custom/${DRUPAL_THEME}/patches

# Install NodeJS dependencies.
# Since Drupal does not use NodeJS in production, installing development
# dependencies here is fine — they are not exposed in any way.
RUN yarn --cwd="/app/${WEBROOT}/themes/custom/${DRUPAL_THEME}" install --frozen-lockfile --no-progress && yarn cache clean

# Copy all files into the application source directory. Existing files are
# always overwritten.
COPY . /app

# Create file directories and set correct permissions.
RUN mkdir -p "/app/${WEBROOT}/${DRUPAL_PUBLIC_FILES}" "/app/${WEBROOT}/${DRUPAL_PRIVATE_FILES}" "${DRUPAL_TEMPORARY_FILES}" && \
chmod 0770 "/app/${WEBROOT}/${DRUPAL_PUBLIC_FILES}" "/app/${WEBROOT}/${DRUPAL_PRIVATE_FILES}" "${DRUPAL_TEMPORARY_FILES}"

# Compile front-end assets. This runs after copying all files, as source files
# are needed for compilation.
WORKDIR /app/${WEBROOT}/themes/custom/${DRUPAL_THEME}
RUN yarn run build
chmod 0770 "/app/${WEBROOT}/${DRUPAL_PUBLIC_FILES}" "/app/${WEBROOT}/${DRUPAL_PRIVATE_FILES}" "${DRUPAL_TEMPORARY_FILES}"

RUN if [ -n "${DRUPAL_THEME}" ]; then \
theme_path="/app/${WEBROOT}/themes/custom/${DRUPAL_THEME}"; \
yarn --cwd="${theme_path}" install --frozen-lockfile --no-progress && \
yarn --cwd="${theme_path}" run build && \
yarn cache clean; \
fi
Comment on lines +83 to +88
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Guard against missing theme path to prevent build failures

If DRUPAL_THEME is set but the directory is misspelled or absent, the build will exit with a fatal Yarn error. Add an existence check so the image can still be built:

-RUN if [ -n "${DRUPAL_THEME}" ]; then \
-      theme_path="/app/${WEBROOT}/themes/custom/${DRUPAL_THEME}"; \
-      yarn --cwd="${theme_path}" install --frozen-lockfile --no-progress && \
-      yarn --cwd="${theme_path}" run build && \
-      yarn cache clean; \
-    fi
+RUN if [ -n "${DRUPAL_THEME}" ] && [ -d "/app/${WEBROOT}/themes/custom/${DRUPAL_THEME}" ]; then \
+      yarn --cwd="/app/${WEBROOT}/themes/custom/${DRUPAL_THEME}" install --frozen-lockfile --no-progress && \
+      yarn --cwd="/app/${WEBROOT}/themes/custom/${DRUPAL_THEME}" run build && \
+      yarn cache clean; \
+    else \
+      echo "Skipping theme asset build – DRUPAL_THEME empty or path missing"; \
+    fi
🤖 Prompt for AI Agents
In .docker/cli.dockerfile around lines 83 to 88, the current RUN command assumes
the theme directory exists if DRUPAL_THEME is set, causing build failures if the
directory is missing. Modify the script to check if the theme_path directory
actually exists before running yarn commands, so the build does not fail when
the directory is absent or misspelled.


WORKDIR /app
6 changes: 3 additions & 3 deletions .docker/solr.dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ COPY .docker/config/solr/config-set /solr-conf/conf/

USER root

RUN sed -i -e "s#<dataDir>\${solr.data.dir:}#<dataDir>/var/solr/\${solr.core.name}#g" /solr-conf/conf/solrconfig.xml \
&& sed -i -e "s#solr.lock.type:native#solr.lock.type:none#g" /solr-conf/conf/solrconfig.xml \
&& sed -i -e "s#solr.autoSoftCommit.MaxTime=5000#solr.autoSoftCommit.MaxTime=-1#g" /solr-conf/conf/solrcore.properties
RUN sed -i -e "s#<dataDir>\${solr.data.dir:}#<dataDir>/var/solr/\${solr.core.name}#g" /solr-conf/conf/solrconfig.xml && \
sed -i -e "s#solr.lock.type:native#solr.lock.type:none#g" /solr-conf/conf/solrconfig.xml && \
sed -i -e "s#solr.autoSoftCommit.MaxTime=5000#solr.autoSoftCommit.MaxTime=-1#g" /solr-conf/conf/solrcore.properties
Comment on lines +20 to +22
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick (assertive)

Minor perf nit – combine the three sed edits

Each sed -i rewrites the file, incurring three I/O passes. You can fuse them into one for a marginally smaller layer:

-RUN sed -i -e "s#<dataDir>\${solr.data.dir:}#<dataDir>/var/solr/\${solr.core.name}#g" /solr-conf/conf/solrconfig.xml && \
-    sed -i -e "s#solr.lock.type:native#solr.lock.type:none#g" /solr-conf/conf/solrconfig.xml && \
-    sed -i -e "s#solr.autoSoftCommit.MaxTime=5000#solr.autoSoftCommit.MaxTime=-1#g" /solr-conf/conf/solrcore.properties
+RUN sed -i \
+    -e "s#<dataDir>\${solr.data.dir:}#<dataDir>/var/solr/\${solr.core.name}#g" \
+    -e "s#solr.lock.type:native#solr.lock.type:none#g" \
+    -e "s#solr.autoSoftCommit.MaxTime=5000#solr.autoSoftCommit.MaxTime=-1#g" \
+    /solr-conf/conf/solrconfig.xml /solr-conf/conf/solrcore.properties
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
RUN sed -i -e "s#<dataDir>\${solr.data.dir:}#<dataDir>/var/solr/\${solr.core.name}#g" /solr-conf/conf/solrconfig.xml && \
sed -i -e "s#solr.lock.type:native#solr.lock.type:none#g" /solr-conf/conf/solrconfig.xml && \
sed -i -e "s#solr.autoSoftCommit.MaxTime=5000#solr.autoSoftCommit.MaxTime=-1#g" /solr-conf/conf/solrcore.properties
RUN sed -i \
-e "s#<dataDir>\${solr.data.dir:}#<dataDir>/var/solr/\${solr.core.name}#g" \
-e "s#solr.lock.type:native#solr.lock.type:none#g" \
-e "s#solr.autoSoftCommit.MaxTime=5000#solr.autoSoftCommit.MaxTime=-1#g" \
/solr-conf/conf/solrconfig.xml /solr-conf/conf/solrcore.properties
🤖 Prompt for AI Agents
In .docker/solr.dockerfile around lines 20 to 22, the three separate sed
commands each rewrite the file individually, causing unnecessary multiple I/O
operations. Combine all three sed expressions into a single sed command with
multiple -e options to perform all replacements in one pass, reducing the number
of file writes and improving build efficiency.


USER solr

Expand Down
12 changes: 12 additions & 0 deletions .github/workflows/build-test-deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,8 @@ jobs:
if: github.event_name == 'schedule'
run: |
echo "VORTEX_CI_DB_CACHE_FALLBACK=no" >> "$GITHUB_ENV"
# Do not build the Drupal front-end.
echo "DRUPAL_THEME=" >> "$GITHUB_ENV"

- name: Create cache keys files for database caching
run: |
Expand Down Expand Up @@ -217,6 +219,7 @@ jobs:
run: ./scripts/vortex/login-container-registry.sh

- name: Lint Dockerfiles with Hadolint
if: ${{ matrix.instance == 0 || strategy.job-total == 1 }}
run: |
find .docker -name 'Dockerfile' -o -name '*.dockerfile' | while read -r file; do
echo "Linting ${file}" && cat "${file}" | docker run --rm -i hadolint/hadolint
Expand All @@ -241,38 +244,47 @@ jobs:
docker compose exec $(env | cut -f1 -d= | sed 's/^/-e /') -T cli bash -c "yarn install --frozen-lockfile"

- name: Validate Composer configuration is normalized
if: ${{ matrix.instance == 0 || strategy.job-total == 1 }}
run: docker compose exec -T cli composer normalize --dry-run
continue-on-error: ${{ vars.VORTEX_CI_COMPOSER_NORMALIZE_IGNORE_FAILURE == '1' }}

- name: Lint code with PHPCS
if: ${{ matrix.instance == 0 || strategy.job-total == 1 }}
run: docker compose exec -T cli vendor/bin/phpcs
continue-on-error: ${{ vars.VORTEX_CI_PHPCS_IGNORE_FAILURE == '1' }}

- name: Lint code with PHPStan
if: ${{ matrix.instance == 0 || strategy.job-total == 1 }}
run: docker compose exec -T cli vendor/bin/phpstan
continue-on-error: ${{ vars.VORTEX_CI_PHPSTAN_IGNORE_FAILURE == '1' }}

- name: Lint code with Rector
if: ${{ matrix.instance == 0 || strategy.job-total == 1 }}
run: docker compose exec -T cli vendor/bin/rector --clear-cache --dry-run
continue-on-error: ${{ vars.VORTEX_CI_RECTOR_IGNORE_FAILURE == '1' }}

- name: Lint code with PHPMD
if: ${{ matrix.instance == 0 || strategy.job-total == 1 }}
run: docker compose exec -T cli vendor/bin/phpmd . text phpmd.xml
continue-on-error: ${{ vars.VORTEX_CI_PHPMD_IGNORE_FAILURE == '1' }}

- name: Lint code with Twig CS Fixer
if: ${{ matrix.instance == 0 || strategy.job-total == 1 }}
run: docker compose exec -T cli vendor/bin/twig-cs-fixer
continue-on-error: ${{ vars.VORTEX_CI_TWIG_CS_FIXER_IGNORE_FAILURE == '1' }}

- name: Lint code with Gherkin Lint
if: ${{ matrix.instance == 0 || strategy.job-total == 1 }}
run: docker compose exec -T cli vendor/bin/gherkinlint lint tests/behat/features
continue-on-error: ${{ vars.VORTEX_CI_GHERKIN_LINT_IGNORE_FAILURE == '1' }}

- name: Lint module code with NodeJS linters
if: ${{ matrix.instance == 0 || strategy.job-total == 1 }}
run: docker compose exec -T cli bash -c "yarn run lint"
continue-on-error: ${{ vars.VORTEX_CI_NODEJS_LINT_IGNORE_FAILURE == '1' }}

- name: Lint theme code with NodeJS linters
if: ${{ (matrix.instance == 0 || strategy.job-total == 1) && env.DRUPAL_THEME != '' }}
run: docker compose exec -T cli bash -c "yarn --cwd=\${WEBROOT}/themes/custom/\${DRUPAL_THEME} run lint"
continue-on-error: ${{ vars.VORTEX_CI_NODEJS_LINT_IGNORE_FAILURE == '1' }}

Expand Down
1 change: 1 addition & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ services:
DRUPAL_PUBLIC_FILES: ${DRUPAL_PUBLIC_FILES:-sites/default/files}
DRUPAL_PRIVATE_FILES: ${DRUPAL_PRIVATE_FILES:-sites/default/files/private}
DRUPAL_TEMPORARY_FILES: ${DRUPAL_TEMPORARY_FILES:-/tmp}
DRUPAL_THEME: ${DRUPAL_THEME:-}
image: &cli-image ${COMPOSE_PROJECT_NAME:-example_site}
user: root
<<: *default-volumes
Expand Down