Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Alpine 3.21 update #70

Merged
merged 2 commits into from
Dec 9, 2024
Merged

Alpine 3.21 update #70

merged 2 commits into from
Dec 9, 2024

Conversation

erseco
Copy link
Owner

@erseco erseco commented Dec 9, 2024

This pull request includes several updates to the project, focusing on upgrading the PHP version from 8.3 to 8.4, updating related configurations, and removing an outdated Nginx configuration file.

PHP Version Upgrade:

Documentation Updates:

  • README.md: Updated the PHP version badge from 8.3 to 8.4 and the Moodle version badge from 4.4.0 to 4.5.0. Additionally, updated the PHP version mentioned in the repository description. [1] [2]

Configuration Changes:

Removal of Outdated Configuration:

Summary by CodeRabbit

  • New Features

    • Updated Docker image to use PHP version 8.4.
    • Enhanced tagging process for Docker images based on branch naming conventions.
  • Bug Fixes

    • Corrected cron job to utilize the updated PHP version.
  • Documentation

    • Updated README to reflect new PHP and Moodle versions.
  • Chores

    • Modified configuration scripts to ensure compatibility with the new PHP version.

@erseco erseco self-assigned this Dec 9, 2024
Copy link

coderabbitai bot commented Dec 9, 2024

Walkthrough

This pull request introduces several updates primarily focused on upgrading the PHP version used in the Moodle Docker image from 8.3 to 8.4, alongside changes to the GitHub Actions workflow for Docker image tagging. The workflow now reflects the branch name change from "master" to "main," affecting how Docker image tags are generated. Additionally, updates are made to the README.md to reflect the new PHP and Moodle versions, and various scripts and configuration files are adjusted to ensure compatibility with PHP 8.4.

Changes

File Path Change Summary
.github/workflows/build.yml Updated branch name from "master" to "main" for Docker image tagging in the workflow configuration.
Dockerfile Changed PHP base image from php83 to php84 and updated related package installations accordingly.
README.md Updated version badges and descriptions for PHP (8.4) and Moodle (4.5.0).
rootfs/docker-entrypoint-init.d/02-configure-moodle.sh Updated PHP commands from php83 to php84 across various functions in the script.
rootfs/etc/crontabs/nobody Updated cron job command from /usr/bin/php83 to /usr/bin/php84.
rootfs/etc/nginx/nginx.conf Deleted Nginx configuration file that contained server settings and optimizations.

Possibly related PRs

  • Fixed path of the cache libs #69: The changes in the main PR regarding the Docker image versioning and tagging process are indirectly related to the modifications in the Redis configuration script in PR Fixed path of the cache libs #69, as both involve updates to the overall configuration and compatibility of the Moodle application, although they focus on different aspects (workflow vs. Redis configuration).

🐰 In the meadow, where changes bloom,
PHP 8.4 now lights up the room.
With Docker tags that dance and play,
The workflow's bright on this fine day!
Upgrading scripts, a joyful cheer,
Moodle's new version is finally here! 🎉


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🧹 Outside diff range and nitpick comments (5)
Dockerfile (2)

11-11: Consider pinning PHP package versions for reproducible builds.

The PHP packages are installed without version constraints, which could lead to unexpected updates. Consider pinning specific versions for better reproducibility.

-RUN apk add --no-cache dcron libcap php84-exif php84-pecl-redis php84-pecl-igbinary php84-ldap && \
+RUN apk add --no-cache dcron libcap \
+    php84-exif=8.4.0-r0 \
+    php84-pecl-redis=6.0.2-r0 \
+    php84-pecl-igbinary=3.2.15-r0 \
+    php84-ldap=8.4.0-r0 && \

Security: Update gnu-libiconv to version 1.17-r2 from the current Alpine repository

The current installation uses gnu-libiconv 1.15-r3 from an outdated Alpine v3.13 repository, while version 1.17-r2 is available in the latest stable Alpine repository. The issue #26 remains open and appears to be a Moodle-specific problem rather than a libiconv issue.

Consider:

  1. Update the package installation command to:
RUN apk add gnu-libiconv --update-cache --repository https://dl-cdn.alpinelinux.org/alpine/latest-stable/community/
  1. Remove the --allow-untrusted flag as it's not needed when using HTTPS
  2. Let the package manager select the latest available version (1.17-r2) instead of pinning to an old version
🔗 Analysis chain

Line range hint 15-16: Security concern: Using outdated Alpine repository and old libiconv version.

The Dockerfile installs an old version of gnu-libiconv (1.15-r3) from an outdated Alpine repository (v3.13). This could pose security risks.

Consider:

  1. Updating to a newer version of libiconv from the current Alpine repository
  2. Investigating if the hack for issue Unable to Create New Role with "Incorrect role short name" #26 is still necessary with PHP 8.4

Let me try another approach to get the available libiconv versions more effectively.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Check if issue #26 is still relevant with PHP 8.4
gh issue view 26

# Check available libiconv versions in current Alpine repositories
curl -s https://dl-cdn.alpinelinux.org/alpine/latest-stable/community/x86_64/APKINDEX.tar.gz | tar -xz -O | grep -A3 "gnu-libiconv"

Length of output: 1132


Script:

#!/bin/bash
# Check available libiconv versions in current Alpine repositories using a different approach
curl -s https://dl-cdn.alpinelinux.org/alpine/latest-stable/community/x86_64/APKINDEX.tar.gz | tar -xzf - APKINDEX && cat APKINDEX | grep -A3 "gnu-libiconv"

# Also check the version in edge repository as a reference
curl -s https://dl-cdn.alpinelinux.org/alpine/edge/community/x86_64/APKINDEX.tar.gz | tar -xzf - APKINDEX && cat APKINDEX | grep -A3 "gnu-libiconv"

# Let's also check the base image version being used
cat Dockerfile | grep -i "FROM"

Length of output: 1951

rootfs/docker-entrypoint-init.d/02-configure-moodle.sh (2)

58-58: Consider extracting PHP flags to variables.

The script repeatedly uses the same PHP flags (-d max_input_vars=10000). Consider extracting this to a variable for better maintainability.

+# At the beginning of the script
+PHP_FLAGS="-d max_input_vars=10000"
+PHP_CMD="php84 ${PHP_FLAGS}"

-    ENV_VAR='var' php84 -d max_input_vars=10000 /var/www/html/admin/cli/install.php \
+    ENV_VAR='var' ${PHP_CMD} /var/www/html/admin/cli/install.php \

Also applies to: 83-83, 142-150, 155-156, 159-160, 177-179, 212-212, 219-219, 233-233


142-150: Consider using a loop for repetitive configuration commands.

The script has multiple similar configuration commands that could be simplified using an array and loop.

+    # Define configurations as key-value pairs
+    declare -A configs=(
+        ["pathtophp"]="/usr/bin/php84"
+        ["pathtodu"]="/usr/bin/du"
+        ["enableblogs"]="0"
+        ["smtphosts"]="$SMTP_HOST:$SMTP_PORT"
+        ["smtpuser"]="$SMTP_USER"
+        ["smtppass"]="$SMTP_PASSWORD"
+        ["smtpsecure"]="$SMTP_PROTOCOL"
+        ["noreplyaddress"]="$MOODLE_MAIL_NOREPLY_ADDRESS"
+        ["emailsubjectprefix"]="$MOODLE_MAIL_PREFIX"
+    )
+
+    # Apply configurations in a loop
+    for key in "${!configs[@]}"; do
+        ${PHP_CMD} /var/www/html/admin/cli/cfg.php --name="$key" --set="${configs[$key]}"
+    done
README.md (1)

19-19: Consider adding performance metrics to support claims.

The description claims PHP 8.4 provides "better performance, lower cpu usage & memory footprint". Consider adding specific performance metrics or benchmarks to support these claims, helping users understand the concrete benefits of upgrading.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between dc1fa57 and f8ae82b.

📒 Files selected for processing (6)
  • .github/workflows/build.yml (1 hunks)
  • Dockerfile (1 hunks)
  • README.md (2 hunks)
  • rootfs/docker-entrypoint-init.d/02-configure-moodle.sh (6 hunks)
  • rootfs/etc/crontabs/nobody (1 hunks)
  • rootfs/etc/nginx/nginx.conf (0 hunks)
💤 Files with no reviewable changes (1)
  • rootfs/etc/nginx/nginx.conf
✅ Files skipped from review due to trivial changes (1)
  • rootfs/etc/crontabs/nobody
🔇 Additional comments (1)
.github/workflows/build.yml (1)

28-29: LGTM: Branch name update follows best practices.

The change from "master" to "main" aligns with current Git naming conventions and best practices.

Also applies to: 35-36

Comment on lines +212 to 215
if php84 -d max_input_vars=10000 /var/www/html/admin/cli/isinstalled.php ; then
install_database
configure_moodle_settings
final_configurations
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue

Critical: Database installation logic appears incorrect.

The condition seems reversed. It runs install_database when Moodle is already installed (isinstalled.php returns true).

-if php84 -d max_input_vars=10000 /var/www/html/admin/cli/isinstalled.php ; then
+if ! php84 -d max_input_vars=10000 /var/www/html/admin/cli/isinstalled.php ; then
     install_database
     configure_moodle_settings
     final_configurations
📝 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
if php84 -d max_input_vars=10000 /var/www/html/admin/cli/isinstalled.php ; then
install_database
configure_moodle_settings
final_configurations
if ! php84 -d max_input_vars=10000 /var/www/html/admin/cli/isinstalled.php ; then
install_database
configure_moodle_settings
final_configurations

Comment on lines +6 to +7
![php 8.4](https://img.shields.io/badge/php-8.4-brightgreen.svg)
![moodle-4.5.0](https://img.shields.io/badge/moodle-4.5-yellow)
Copy link

Choose a reason for hiding this comment

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

💡 Codebase verification

Version compatibility mismatch detected in implementation

The badge in README.md shows PHP 8.4, but there are inconsistencies in the implementation:

  • The Dockerfile uses php84 packages, correctly aligned with PHP 8.4
  • The Moodle version in Dockerfile is set to MOODLE_405_STABLE, which corresponds to Moodle 4.0.5, not Moodle 4.5.0 as shown in the badge
  • All PHP CLI commands in configuration scripts correctly use php84
🔗 Analysis chain

Verify version compatibility with implementation.

The badge updates reflect PHP 8.4 and Moodle 4.5.0. Let's verify these versions are correctly implemented across the codebase.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify PHP and Moodle versions in implementation files

# Check PHP version in Dockerfile and configuration scripts
echo "Checking PHP version references..."
rg -l 'php8[34]' 

# Check Moodle version references
echo "Checking Moodle version references..."
rg -l '4\.[45]\.0'

# Check if there are any remaining old version references
echo "Checking for any remaining old version references..."
rg -l 'php83|4\.4\.0'

Length of output: 445


Script:

#!/bin/bash
# Let's check the actual content of files to see version references

echo "=== Checking Dockerfile content ==="
cat Dockerfile

echo -e "\n=== Checking crontab configuration ==="
cat rootfs/etc/crontabs/nobody

echo -e "\n=== Checking Moodle configuration script ==="
cat rootfs/docker-entrypoint-init.d/02-configure-moodle.sh

echo -e "\n=== Checking composer.json for PHP version constraints ==="
if [ -f "composer.json" ]; then
    cat composer.json
fi

Length of output: 11489

@erseco erseco merged commit cc3c29a into main Dec 9, 2024
2 checks passed
@erseco erseco deleted the alpine-3.21-update branch December 9, 2024 13:11
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.

1 participant