Skip to content

Commit

Permalink
remove apache and fix startup script
Browse files Browse the repository at this point in the history
  • Loading branch information
PiyushRaj927 committed Mar 27, 2023
1 parent bdd2902 commit 86b7b80
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 39 deletions.
30 changes: 7 additions & 23 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,7 @@ ENV MW_VERSION=REL1_39 \
MW_ORIGIN_FILES=/mw_origin_files \
MW_VOLUME=/mediawiki \
WWW_USER=www-data \
WWW_GROUP=www-data \
APACHE_LOG_DIR=/var/log/apache2
WWW_GROUP=www-data

# System setup
RUN set x; \
Expand All @@ -21,7 +20,6 @@ RUN set x; \
&& aptitude -y upgrade \
&& aptitude install -y \
git \
apache2 \
software-properties-common \
gpg \
apt-transport-https \
Expand Down Expand Up @@ -58,20 +56,15 @@ RUN set x; \
php7.4-apcu \
php7.4-redis \
php7.4-curl \
php7.4-zip \
php7.4-zip \
php7.4-fpm \
&& aptitude clean \
&& rm -rf /var/lib/apt/lists/*

# Post install configuration
RUN set -x; \
# Remove default config
rm /etc/apache2/sites-enabled/000-default.conf \
&& rm /etc/apache2/sites-available/000-default.conf \
&& rm -rf /var/www/html \
# Enable rewrite module
&& a2enmod rewrite \
# Create directories
&& mkdir -p $MW_HOME \
mkdir -p $MW_HOME \
&& mkdir -p $MW_ORIGIN_FILES \
&& mkdir -p $MW_VOLUME

Expand Down Expand Up @@ -631,34 +624,25 @@ ENV MW_ENABLE_JOB_RUNNER=true \
LOG_FILES_REMOVE_OLDER_THAN_DAYS=10

COPY _sources/configs/msmtprc /etc/
COPY _sources/configs/mediawiki.conf /etc/apache2/sites-enabled/
COPY _sources/configs/status.conf /etc/apache2/mods-available/
COPY _sources/configs/php_error_reporting.ini _sources/configs/php_upload_max_filesize.ini /etc/php/7.4/cli/conf.d/
COPY _sources/configs/php_error_reporting.ini _sources/configs/php_upload_max_filesize.ini /etc/php/7.4/apache2/conf.d/
COPY _sources/configs/php_max_input_vars.ini _sources/configs/php_max_input_vars.ini /etc/php/7.4/apache2/conf.d/
COPY _sources/configs/php_timeouts.ini /etc/php/7.4/apache2/conf.d/
COPY _sources/configs/php_error_reporting.ini _sources/configs/php_upload_max_filesize.ini /etc/php/7.4/fpm/conf.d/
COPY _sources/scripts/*.sh /
COPY _sources/scripts/*.php $MW_HOME/maintenance/
COPY _sources/configs/robots.txt $WWW_ROOT/
COPY _sources/configs/.htaccess $WWW_ROOT/
COPY _sources/images/favicon.ico $WWW_ROOT/
COPY _sources/canasta/LocalSettings.php _sources/canasta/CanastaUtils.php _sources/canasta/CanastaDefaultSettings.php $MW_HOME/
COPY _sources/canasta/getMediawikiSettings.php /
COPY _sources/configs/mpm_prefork.conf /etc/apache2/mods-available/mpm_prefork.conf

RUN set -x; \
chmod -v +x /*.sh \
# Sitemap directory
&& ln -s $MW_VOLUME/sitemap $MW_HOME/sitemap \
# Comment out ErrorLog and CustomLog parameters, we use rotatelogs in mediawiki.conf for the log files
&& sed -i 's/^\(\s*ErrorLog .*\)/# \1/g' /etc/apache2/apache2.conf \
&& sed -i 's/^\(\s*CustomLog .*\)/# \1/g' /etc/apache2/apache2.conf \
# Make web installer work with Canasta
&& cp "$MW_HOME/includes/NoLocalSettings.php" "$MW_HOME/includes/CanastaNoLocalSettings.php" \
&& sed -i 's/MW_CONFIG_FILE/CANASTA_CONFIG_FILE/g' "$MW_HOME/includes/CanastaNoLocalSettings.php" \
# Modify config
&& sed -i '/<Directory \/var\/www\/>/,/<\/Directory>/ s/AllowOverride None/AllowOverride All/' /etc/apache2/apache2.conf \
&& a2enmod expires
# Enable environment variables for FPM workers
&& sed -i '/clear_env/s/^;//' /etc/php/7.4/fpm/pool.d/www.conf

COPY _sources/images/Powered-by-Canasta.png /var/www/mediawiki/w/resources/assets/

Expand Down
27 changes: 11 additions & 16 deletions _sources/scripts/run-apache.sh
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ prepare_extensions_skins_symlinks
# note that this command will also set all the necessary permissions
echo "Syncing files..."
rsync -ah --inplace --ignore-existing --remove-source-files \
-og --chown=$WWW_GROUP:$WWW_USER --chmod=Fg=rw,Dg=rwx \
-og --chown=$WWW_USER:$WWW_GROUP --chmod=Fg=rw,Dg=rwx \
"$MW_ORIGIN_FILES"/ "$MW_VOLUME"/

# We don't need it anymore
Expand All @@ -122,17 +122,10 @@ echo "Checking permissions of $MW_VOLUME..."
if dir_is_writable $MW_VOLUME; then
echo "Permissions are OK!"
else
chown -R "$WWW_GROUP":"$WWW_GROUP" "$MW_VOLUME"
chown -R "$WWW_USER":"$WWW_GROUP" "$MW_VOLUME"
chmod -R g=rwX "$MW_VOLUME"
fi

echo "Checking permissions of $APACHE_LOG_DIR..."
if dir_is_writable $APACHE_LOG_DIR; then
echo "Permissions are OK!"
else
chown -R "$WWW_GROUP":"$WWW_GROUP" $APACHE_LOG_DIR
chmod -R g=rwX $APACHE_LOG_DIR
fi

jobrunner() {
sleep 3
Expand All @@ -157,6 +150,13 @@ transcoder() {
sitemapgen() {
sleep 3
if isTrue "$MW_ENABLE_SITEMAP_GENERATOR"; then
echo "Checking permissions of $MW_VOLUME/sitemap"
if dir_is_writable $MW_VOLUME/sitemap; then
echo "Permissions are OK!"
else
chown -R "$WWW_USER":"$WWW_GROUP" "$MW_VOLUME/sitemap"
chmod -R g=rwX "$MW_VOLUME/sitemap"
fi
# Fetch & export script path for sitemap generator
if [ -z "$MW_SCRIPT_PATH" ]; then
MW_SCRIPT_PATH=$(get_mediawiki_variable wgScriptPath)
Expand Down Expand Up @@ -223,10 +223,5 @@ jobrunner &
transcoder &
sitemapgen &

############### Run Apache ###############
# Make sure we're not confused by old, incompletely-shutdown httpd
# context after restarting the container. httpd won't start correctly
# if it thinks it is already running.
rm -rf /run/httpd/* /tmp/httpd*

exec /usr/sbin/apachectl -DFOREGROUND
# waiting for maintainenece scripts
wait

0 comments on commit 86b7b80

Please sign in to comment.