Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Oct 27, 2025

Adds validation that the Docker image can perform bidirectional image format conversion using utopia-php/image.

Changes

  • Dockerfile: No changes to production image - remains completely clean
  • Dockerfile.test: New dedicated test Dockerfile with multi-stage build that uses the main Dockerfile as base, installs dependencies via Composer in a separate stage, and copies tests
  • .github/workflows/test.yml: Updated to build both the main Dockerfile and Dockerfile.test, then runs container-structure-test against the test image
  • tests/composer.json: Define utopia-php/image ^0.8 dependency in tests folder
  • tests/run-image-conversion-test.sh: Wrapper script that checks for pre-installed dependencies and falls back to installing Composer/dependencies if needed
  • tests/image-conversion-test.php: PHP test script that performs bidirectional PNG ↔ WebP conversion
  • tests/: Add test images (PNG and WebP samples)
  • tests.yaml: Add commandTest that runs the wrapper script and validates conversion output

Test Coverage

The test validates:

  1. PNG → WebP conversion produces valid output
  2. WebP → PNG conversion produces valid output
  3. Converted images can be read back and are valid
// Test script performs conversions in both directions
$image = new Image(\file_get_contents('/tests/test.png'));
$image->save('/tmp/test_converted.webp', 'webp', IMAGE_QUALITY);

$image = new Image(\file_get_contents('/tests/test.webp'));
$image->save('/tmp/test_converted.png', 'png', IMAGE_QUALITY);

Implementation Details

The test infrastructure is completely separated from the production Docker image using a multi-stage build approach:

  • Dockerfile.test uses multi-stage builds with a dedicated Composer stage
  • The composer stage installs utopia-php/image dependencies from tests/composer.json
  • The test stage extends the main appwrite-base-test image (built from the main Dockerfile)
  • Pre-installed vendor directory and test files are copied into the test image
  • The production image remains clean without any test-related files or dependencies

This architecture leverages Docker's multi-stage builds for efficient dependency management while keeping the production image production-ready and unbloated.

Original prompt

Update container-structure-test to test using utopia-php/image to convert a png to webp and vice versa


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

@coderabbitai
Copy link

coderabbitai bot commented Oct 27, 2025

Important

Review skipped

Bot user detected.

To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Note

Other AI code review bot(s) detected

CodeRabbit has detected other AI code review bot(s) in this pull request and will avoid duplicating their findings in the review comments. This may lead to a less comprehensive review.


Comment @coderabbitai help to get the list of available commands and usage tips.

Copilot AI changed the title [WIP] Update container-structure-test with utopia-php/image conversion Add container structure tests for utopia-php/image PNG ↔ WebP conversion Oct 27, 2025
Copilot AI requested a review from stnguyen90 October 27, 2025 22:45
Dockerfile Outdated
Comment on lines 237 to 246
# Install Composer
RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer

# Copy composer.json and install dependencies
COPY composer.json /usr/src/code/composer.json
RUN composer install --no-dev --working-dir=/usr/src/code

# Copy test files
COPY tests /tests

Copy link
Contributor

Choose a reason for hiding this comment

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

@copilot don't install composer in the Dockerfile. install the composer as part of the test.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done! Composer installation moved to the test script (run-image-conversion-test.sh). The Dockerfile no longer installs Composer - it's now installed on-the-fly during test execution. (commit 4d82f3f)

Dockerfile Outdated
Comment on lines 237 to 239
# Copy test files
COPY tests /tests

Copy link
Contributor

Choose a reason for hiding this comment

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

@copilot don't copy tests in. Mount the tests in at runtime.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done! Tests are no longer copied into the Docker image. The workflow now creates a temporary test layer at runtime that includes the tests, keeping the base image clean. (commit 731125d)

Copy link
Contributor Author

Copilot AI commented Oct 28, 2025

Just as a heads up, I was blocked by some firewall rules while working on your feedback. Expand below for details.

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • https://api.github.com/repos/GoogleContainerTools/container-structure-test/readme
    • Triggering command: curl -s REDACTED (http block)

If you need me to access, download, or install something from one of these locations, you can either:

Comment on lines 27 to 30
cat > Dockerfile.test <<EOF
FROM appwrite-base-test
COPY tests /tests
EOF
Copy link
Contributor

Choose a reason for hiding this comment

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

@copilot Create a test Dockerfile alongside the main Dockerfile that uses the repo's Dockerfile as a base, copies tests in and uses a multi-stage build with a composer stage that installs the necessary dependencies for the test.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done! Created Dockerfile.test with:

  • Multi-stage build using composer:latest stage to install dependencies
  • Uses appwrite-base-test (built from main Dockerfile) as the base image
  • Pre-installs utopia-php/image via Composer in a separate stage
  • Copies pre-installed vendor directory and test files into final image
  • Test script now checks for pre-installed dependencies before attempting to install

The workflow simply builds both Dockerfiles in sequence. (commit fca4bb2)

@stnguyen90 stnguyen90 force-pushed the copilot/update-container-structure-test branch from fca4bb2 to 1a0f313 Compare October 28, 2025 05:28
@stnguyen90 stnguyen90 closed this Oct 28, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants