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
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
4 changes: 2 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,14 @@ jobs:

if [[ $GITHUB_REF == refs/tags/* ]]; then
TAGS="$TAGS,${GITHUB_REPOSITORY}:latest"
elif [[ $VERSION == "master" ]]; then
elif [[ $VERSION == "main" ]]; then
TAGS="$TAGS,${GITHUB_REPOSITORY}:beta"
fi

GHCR_TAGS="${GHCR_IMAGE}:${VERSION}"
if [[ $GITHUB_REF == refs/tags/* ]]; then
GHCR_TAGS="$GHCR_TAGS,${GHCR_IMAGE}:latest"
elif [[ $VERSION == "master" ]]; then
elif [[ $VERSION == "main" ]]; then
GHCR_TAGS="$GHCR_TAGS,${GHCR_IMAGE}:beta"
fi

Expand Down
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,18 @@

# crond needs root, so install dcron and cap package and set the capabilities
# on dcron binary https://github.com/inter169/systs/blob/master/alpine/crond/README.md
RUN apk add --no-cache dcron libcap php83-exif php83-pecl-redis php83-pecl-igbinary php83-ldap && \
RUN apk add --no-cache dcron libcap php84-exif php84-pecl-redis php84-pecl-igbinary php84-ldap && \
chown nobody:nobody /usr/sbin/crond && \
setcap cap_setgid=ep /usr/sbin/crond

# add a quick-and-dirty hack to fix https://github.com/erseco/alpine-moodle/issues/26
RUN apk add gnu-libiconv=1.15-r3 --update-cache --repository http://dl-cdn.alpinelinux.org/alpine/v3.13/community/ --allow-untrusted
ENV LD_PRELOAD /usr/lib/preloadable_libiconv.so

Check warning on line 17 in Dockerfile

View workflow job for this annotation

GitHub Actions / buildx

Legacy key/value format with whitespace separator should not be used

LegacyKeyValueFormat: "ENV key=value" should be used instead of legacy "ENV key value" format More info: https://docs.docker.com/go/dockerfile/rule/legacy-key-value-format/

Check warning on line 17 in Dockerfile

View workflow job for this annotation

GitHub Actions / buildx

Legacy key/value format with whitespace separator should not be used

LegacyKeyValueFormat: "ENV key=value" should be used instead of legacy "ENV key value" format More info: https://docs.docker.com/go/dockerfile/rule/legacy-key-value-format/

Check warning on line 17 in Dockerfile

View workflow job for this annotation

GitHub Actions / buildx

Legacy key/value format with whitespace separator should not be used

LegacyKeyValueFormat: "ENV key=value" should be used instead of legacy "ENV key value" format More info: https://docs.docker.com/go/dockerfile/rule/legacy-key-value-format/

USER nobody

# Change MOODLE_XX_STABLE for new versions
ENV MOODLE_URL=https://github.com/moodle/moodle/archive/MOODLE_405_STABLE.tar.gz \

Check warning on line 22 in Dockerfile

View workflow job for this annotation

GitHub Actions / buildx

Sensitive data should not be used in the ARG or ENV commands

SecretsUsedInArgOrEnv: Do not use ARG or ENV instructions for sensitive data (ENV "MOODLE_PASSWORD") More info: https://docs.docker.com/go/dockerfile/rule/secrets-used-in-arg-or-env/

Check warning on line 22 in Dockerfile

View workflow job for this annotation

GitHub Actions / buildx

Sensitive data should not be used in the ARG or ENV commands

SecretsUsedInArgOrEnv: Do not use ARG or ENV instructions for sensitive data (ENV "SMTP_PASSWORD") More info: https://docs.docker.com/go/dockerfile/rule/secrets-used-in-arg-or-env/

Check warning on line 22 in Dockerfile

View workflow job for this annotation

GitHub Actions / buildx

Sensitive data should not be used in the ARG or ENV commands

SecretsUsedInArgOrEnv: Do not use ARG or ENV instructions for sensitive data (ENV "SMTP_PASSWORD") More info: https://docs.docker.com/go/dockerfile/rule/secrets-used-in-arg-or-env/

Check warning on line 22 in Dockerfile

View workflow job for this annotation

GitHub Actions / buildx

Sensitive data should not be used in the ARG or ENV commands

SecretsUsedInArgOrEnv: Do not use ARG or ENV instructions for sensitive data (ENV "MOODLE_PASSWORD") More info: https://docs.docker.com/go/dockerfile/rule/secrets-used-in-arg-or-env/

Check warning on line 22 in Dockerfile

View workflow job for this annotation

GitHub Actions / buildx

Sensitive data should not be used in the ARG or ENV commands

SecretsUsedInArgOrEnv: Do not use ARG or ENV instructions for sensitive data (ENV "MOODLE_PASSWORD") More info: https://docs.docker.com/go/dockerfile/rule/secrets-used-in-arg-or-env/

Check warning on line 22 in Dockerfile

View workflow job for this annotation

GitHub Actions / buildx

Sensitive data should not be used in the ARG or ENV commands

SecretsUsedInArgOrEnv: Do not use ARG or ENV instructions for sensitive data (ENV "SMTP_PASSWORD") More info: https://docs.docker.com/go/dockerfile/rule/secrets-used-in-arg-or-env/
LANG=en_US.UTF-8 \
LANGUAGE=en_US:en \
SITE_URL=http://localhost \
Expand Down
7 changes: 3 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
[![Docker Pulls](https://img.shields.io/docker/pulls/erseco/alpine-moodle.svg)](https://hub.docker.com/r/erseco/alpine-moodle/)
![Docker Image Size](https://img.shields.io/docker/image-size/erseco/alpine-moodle)
![nginx 1.26](https://img.shields.io/badge/nginx-1.26-brightgreen.svg)
![php 8.3](https://img.shields.io/badge/php-8.3-brightgreen.svg)
![moodle-4.4.0](https://img.shields.io/badge/moodle-4.4-yellow)
![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)
Comment on lines +6 to +7
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

![License MIT](https://img.shields.io/badge/license-MIT-blue.svg)
<a href="https://www.buymeacoffee.com/erseco"><img src="https://www.buymeacoffee.com/assets/img/custom_images/orange_img.png" height="20px"></a>

Expand All @@ -16,7 +16,7 @@ Repository: https://github.com/erseco/alpine-moodle

* Built on the lightweight image https://github.com/erseco/alpine-php-webserver
* Very small Docker image size (+/-70MB)
* Uses PHP 8.3 for better performance, lower cpu usage & memory footprint
* Uses PHP 8.4 for better performance, lower cpu usage & memory footprint
* Support for HA installations: php-redis, php-ldap (also with self-signed certs)
* Multi-arch support: 386, amd64, arm/v6, arm/v7, arm64, ppc64le, s390x
* Optimized for 100 concurrent users
Expand Down Expand Up @@ -98,7 +98,6 @@ You can define commands to be executed before and after the configuration of Moo
Example `docker-compose.yml` configuration:

```yaml
version: '3'
services:
moodle:
image: erseco/alpine-moodle
Expand Down
42 changes: 21 additions & 21 deletions rootfs/docker-entrypoint-init.d/02-configure-moodle.sh
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ check_db_availability() {
# Function to generate config.php file
generate_config_file() {
echo "Generating config.php file..."
ENV_VAR='var' php83 -d max_input_vars=10000 /var/www/html/admin/cli/install.php \
ENV_VAR='var' php84 -d max_input_vars=10000 /var/www/html/admin/cli/install.php \
--lang=$MOODLE_LANGUAGE \
--wwwroot=$SITE_URL \
--dataroot=/var/www/moodledata/ \
Expand All @@ -80,7 +80,7 @@ generate_config_file() {
# Function to install the database
install_database() {
echo "Installing database..."
php83 -d max_input_vars=10000 /var/www/html/admin/cli/install_database.php \
php84 -d max_input_vars=10000 /var/www/html/admin/cli/install_database.php \
--lang=$MOODLE_LANGUAGE \
--adminuser=$MOODLE_USERNAME \
--adminpass=$MOODLE_PASSWORD \
Expand Down Expand Up @@ -139,25 +139,25 @@ upgrade_config_file() {
# Function to configure Moodle settings via CLI
configure_moodle_settings() {
echo "Configuring settings..."
php83 -d max_input_vars=10000 /var/www/html/admin/cli/cfg.php --name=pathtophp --set=/usr/bin/php83
php83 -d max_input_vars=10000 /var/www/html/admin/cli/cfg.php --name=pathtodu --set=/usr/bin/du
php83 -d max_input_vars=10000 /var/www/html/admin/cli/cfg.php --name=enableblogs --set=0
php83 -d max_input_vars=10000 /var/www/html/admin/cli/cfg.php --name=smtphosts --set="$SMTP_HOST:$SMTP_PORT"
php83 -d max_input_vars=10000 /var/www/html/admin/cli/cfg.php --name=smtpuser --set="$SMTP_USER"
php83 -d max_input_vars=10000 /var/www/html/admin/cli/cfg.php --name=smtppass --set="$SMTP_PASSWORD"
php83 -d max_input_vars=10000 /var/www/html/admin/cli/cfg.php --name=smtpsecure --set="$SMTP_PROTOCOL"
php83 -d max_input_vars=10000 /var/www/html/admin/cli/cfg.php --name=noreplyaddress --set="$MOODLE_MAIL_NOREPLY_ADDRESS"
php83 -d max_input_vars=10000 /var/www/html/admin/cli/cfg.php --name=emailsubjectprefix --set="$MOODLE_MAIL_PREFIX"
php84 -d max_input_vars=10000 /var/www/html/admin/cli/cfg.php --name=pathtophp --set=/usr/bin/php84
php84 -d max_input_vars=10000 /var/www/html/admin/cli/cfg.php --name=pathtodu --set=/usr/bin/du
php84 -d max_input_vars=10000 /var/www/html/admin/cli/cfg.php --name=enableblogs --set=0
php84 -d max_input_vars=10000 /var/www/html/admin/cli/cfg.php --name=smtphosts --set="$SMTP_HOST:$SMTP_PORT"
php84 -d max_input_vars=10000 /var/www/html/admin/cli/cfg.php --name=smtpuser --set="$SMTP_USER"
php84 -d max_input_vars=10000 /var/www/html/admin/cli/cfg.php --name=smtppass --set="$SMTP_PASSWORD"
php84 -d max_input_vars=10000 /var/www/html/admin/cli/cfg.php --name=smtpsecure --set="$SMTP_PROTOCOL"
php84 -d max_input_vars=10000 /var/www/html/admin/cli/cfg.php --name=noreplyaddress --set="$MOODLE_MAIL_NOREPLY_ADDRESS"
php84 -d max_input_vars=10000 /var/www/html/admin/cli/cfg.php --name=emailsubjectprefix --set="$MOODLE_MAIL_PREFIX"

# Check if DEBUG is set to true
if [ "${DEBUG:-false}" = "true" ]; then
echo "Enabling debug mode..."
php83 /var/www/html/admin/cli/cfg.php --name=debug --set=32767 # DEVELOPER
php83 /var/www/html/admin/cli/cfg.php --name=debugdisplay --set=1
php84 /var/www/html/admin/cli/cfg.php --name=debug --set=32767 # DEVELOPER
php84 /var/www/html/admin/cli/cfg.php --name=debugdisplay --set=1
else
echo "Disabling debug mode..."
php83 /var/www/html/admin/cli/cfg.php --name=debug --set=0 # NONE
php83 /var/www/html/admin/cli/cfg.php --name=debugdisplay --set=0
php84 /var/www/html/admin/cli/cfg.php --name=debug --set=0 # NONE
php84 /var/www/html/admin/cli/cfg.php --name=debugdisplay --set=0
fi

}
Expand All @@ -174,9 +174,9 @@ final_configurations() {
# Function to upgrade Moodle
upgrade_moodle() {
echo "Upgrading moodle..."
php83 -d max_input_vars=10000 /var/www/html/admin/cli/maintenance.php --enable
php83 -d max_input_vars=10000 /var/www/html/admin/cli/upgrade.php --non-interactive --allow-unstable
php83 -d max_input_vars=10000 /var/www/html/admin/cli/maintenance.php --disable
php84 -d max_input_vars=10000 /var/www/html/admin/cli/maintenance.php --enable
php84 -d max_input_vars=10000 /var/www/html/admin/cli/upgrade.php --non-interactive --allow-unstable
php84 -d max_input_vars=10000 /var/www/html/admin/cli/maintenance.php --disable
}

# Check the availability of the primary database
Expand Down Expand Up @@ -209,14 +209,14 @@ fi
upgrade_config_file

# Check if the database is already installed
if php83 -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
Comment on lines +212 to 215
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

else
configure_moodle_settings
echo "Upgrading admin user"
php83 -d max_input_vars=10000 /var/www/html/admin/cli/update_admin_user.php --username=$MOODLE_USERNAME --password=$MOODLE_PASSWORD --email=$MOODLE_EMAIL
php84 -d max_input_vars=10000 /var/www/html/admin/cli/update_admin_user.php --username=$MOODLE_USERNAME --password=$MOODLE_PASSWORD --email=$MOODLE_EMAIL
if [ -z "$AUTO_UPDATE_MOODLE" ] || [ "$AUTO_UPDATE_MOODLE" = true ]; then

upgrade_moodle
Expand All @@ -230,7 +230,7 @@ fi
# Check if REDIS_HOST is set and not empty
if [ -n "$REDIS_HOST" ]; then
echo "Configuring redis cache..."
php83 -d max_input_vars=10000 /var/www/html/admin/cli/configure_redis.php ${REDIS_HOST}
php84 -d max_input_vars=10000 /var/www/html/admin/cli/configure_redis.php ${REDIS_HOST}
fi

# Execute post-install commands if the variable is set
Expand Down
2 changes: 1 addition & 1 deletion rootfs/etc/crontabs/nobody
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@

* * * * * /usr/bin/php83 /var/www/html/admin/cli/cron.php > /dev/null
* * * * * /usr/bin/php84 /var/www/html/admin/cli/cron.php > /dev/null
117 changes: 0 additions & 117 deletions rootfs/etc/nginx/nginx.conf

This file was deleted.

Loading