@@ -18,12 +18,14 @@ LABEL wiki.canasta.mediawiki.version="$MW_CORE_VERSION" \
1818 wiki.canasta.mediawiki.branch="$MW_VERSION"
1919
2020# System setup
21+ # Pinning system package versions is impractical on Debian
22+ # hadolint ignore=DL3008
2123RUN set x; \
2224 apt-get clean \
2325 && apt-get update \
24- && apt-get install -y aptitude \
26+ && apt-get install -y --no-install-recommends aptitude \
2527 && aptitude -y upgrade \
26- && aptitude install -y \
28+ && aptitude install -y --without-recommends \
2729 git \
2830 inotify-tools \
2931 apache2 \
@@ -85,44 +87,51 @@ RUN set -x; \
8587 && a2enmod mpm_event \
8688 && a2enmod proxy_fcgi \
8789 # Create directories
88- && mkdir -p $MW_HOME \
89- && mkdir -p $MW_LOG \
90- && mkdir -p $MW_ORIGIN_FILES \
91- && mkdir -p $MW_VOLUME
90+ && mkdir -p " $MW_HOME" \
91+ && mkdir -p " $MW_LOG" \
92+ && mkdir -p " $MW_ORIGIN_FILES" \
93+ && mkdir -p " $MW_VOLUME"
9294
9395# Composer
96+ SHELL ["/bin/bash" , "-o" , "pipefail" , "-c" ]
9497RUN set -x; \
9598 curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer \
9699 && composer self-update 2.1.3
97100
101+ # Pinning system package versions is impractical on Debian
102+ # hadolint ignore=DL3008
98103RUN set -x; \
99104 # Preconfigure Postfix to avoid the interactive prompt
100105 echo "postfix postfix/main_mailer_type select Internet Site" | debconf-set-selections \
101106 && echo "postfix postfix/mailname string $LOCAL_SMTP_MAILNAME" | debconf-set-selections \
102107 && apt-get update \
103- && apt-get install -y mailutils \
104- && apt install -y postfix
108+ && apt-get install -y --no-install-recommends mailutils postfix \
109+ && rm -rf /var/lib/apt/lists/*
105110
106111COPY main.cf /etc/postfix/main.cf
107112
108113FROM base AS source
109114
110115# MediaWiki core
116+ # cd is used within a multi-command && chain
117+ # hadolint ignore=DL3003
111118RUN set -x; \
112- git clone --depth 1 -b $MW_CORE_VERSION https://github.com/wikimedia/mediawiki $MW_HOME \
113- && cd $MW_HOME \
119+ git clone --depth 1 -b " $MW_CORE_VERSION" https://github.com/wikimedia/mediawiki " $MW_HOME" \
120+ && cd " $MW_HOME" \
114121 && git submodule update --init --recursive
115122
116123# Patch composer
117124RUN set -x; \
118- sed -i 's="monolog/monolog": "2.2.0",="monolog/monolog": "^2.2",=g' $MW_HOME/composer.json
125+ sed -i 's="monolog/monolog": "2.2.0",="monolog/monolog": "^2.2",=g' " $MW_HOME/composer.json"
119126
120127# Other patches
121128
122129# Generate gitinfo.json for core, extensions, and skins so that
123130# Special:Version can display git commit hashes after .git is removed
131+ # cd is used within a loop that returns to $MW_HOME
132+ # hadolint ignore=DL3003,SC2164
124133RUN set -x; \
125- cd $MW_HOME \
134+ cd " $MW_HOME" || exit \
126135 && for dir in . extensions/*/ skins/*/; do \
127136 if [ -d "$dir/.git" ] || [ -f "$dir/.git" ]; then \
128137 cd "$MW_HOME/$dir" \
@@ -138,45 +147,49 @@ RUN set -x; \
138147 done
139148
140149# Cleanup all .git leftovers
150+ # cd is used within a multi-command && chain
151+ # hadolint ignore=DL3003
141152RUN set -x; \
142- cd $MW_HOME \
153+ cd " $MW_HOME" \
143154 && find . \( -name ".git" -o -name ".gitignore" -o -name ".gitmodules" -o -name ".gitattributes" \) -exec rm -rf -- {} +
144155
145156# Generate sample files for installing extensions and skins in LocalSettings.php
157+ # cd switches between extensions/ and skins/; glob is safe here
158+ # hadolint ignore=DL3003,SC2035
146159RUN set -x; \
147- cd $MW_HOME/extensions \
148- && for i in $(ls -d */); do echo "#wfLoadExtension('${i%%/}');" ; done > $MW_ORIGIN_FILES/installedExtensions.txt \
149- && cd $MW_HOME/skins \
150- && for i in $(ls -d */); do echo "#wfLoadSkin('${i%%/}');" ; done > $MW_ORIGIN_FILES/installedSkins.txt \
160+ cd " $MW_HOME/extensions" \
161+ && for i in $(ls -d */); do echo "#wfLoadExtension('${i%%/}');" ; done > " $MW_ORIGIN_FILES/installedExtensions.txt" \
162+ && cd " $MW_HOME/skins" \
163+ && for i in $(ls -d */); do echo "#wfLoadSkin('${i%%/}');" ; done > " $MW_ORIGIN_FILES/installedSkins.txt" \
151164 # Load Vector skin by default in the sample file
152- && sed -i "s/#wfLoadSkin('Vector');/wfLoadSkin('Vector');/" $MW_ORIGIN_FILES/installedSkins.txt
165+ && sed -i "s/#wfLoadSkin('Vector');/wfLoadSkin('Vector');/" " $MW_ORIGIN_FILES/installedSkins.txt"
153166
154167# Move files around
155168RUN set -x; \
156169 # Move files to $MW_ORIGIN_FILES directory
157- mv $MW_HOME/images $MW_ORIGIN_FILES/ \
158- && mv $MW_HOME/cache $MW_ORIGIN_FILES/ \
170+ mv " $MW_HOME/images" " $MW_ORIGIN_FILES/" \
171+ && mv " $MW_HOME/cache" " $MW_ORIGIN_FILES/" \
159172 # Move extensions and skins to prefixed directories not intended to be volumed in
160- && mv $MW_HOME/extensions $MW_HOME/canasta-extensions \
161- && mv $MW_HOME/skins $MW_HOME/canasta-skins \
173+ && mv " $MW_HOME/extensions" " $MW_HOME/canasta-extensions" \
174+ && mv " $MW_HOME/skins" " $MW_HOME/canasta-skins" \
162175 # Permissions
163- && chown $WWW_USER:$WWW_GROUP -R $MW_HOME/canasta-extensions \
164- && chmod g+w -R $MW_HOME/canasta-extensions \
165- && chown $WWW_USER:$WWW_GROUP -R $MW_HOME/canasta-skins \
166- && chmod g+w -R $MW_HOME/canasta-skins \
176+ && chown " $WWW_USER:$WWW_GROUP" -R " $MW_HOME/canasta-extensions" \
177+ && chmod g+w -R " $MW_HOME/canasta-extensions" \
178+ && chown " $WWW_USER:$WWW_GROUP" -R " $MW_HOME/canasta-skins" \
179+ && chmod g+w -R " $MW_HOME/canasta-skins" \
167180 # Create symlinks from $MW_VOLUME to the wiki root for images, cache, and public_assets directories
168- && ln -s $MW_VOLUME/images $MW_HOME/images \
169- && ln -s $MW_VOLUME/cache $MW_HOME/cache \
170- && ln -s $MW_VOLUME/public_assets $MW_HOME/public_assets
181+ && ln -s " $MW_VOLUME/images" " $MW_HOME/images" \
182+ && ln -s " $MW_VOLUME/cache" " $MW_HOME/cache" \
183+ && ln -s " $MW_VOLUME/public_assets" " $MW_HOME/public_assets"
171184
172185# Create place where extensions and skins symlinks will live
173186RUN set -x; \
174- mkdir $MW_HOME/extensions/ \
175- && mkdir $MW_HOME/skins/ \
176- && chown $WWW_USER:$WWW_GROUP -R $MW_HOME/extensions \
177- && chmod g+w -R $MW_HOME/extensions \
178- && chown $WWW_USER:$WWW_GROUP -R $MW_HOME/skins \
179- && chmod g+w -R $MW_HOME/skins
187+ mkdir " $MW_HOME/extensions/" \
188+ && mkdir " $MW_HOME/skins/" \
189+ && chown " $WWW_USER:$WWW_GROUP" -R " $MW_HOME/extensions" \
190+ && chmod g+w -R " $MW_HOME/extensions" \
191+ && chown " $WWW_USER:$WWW_GROUP" -R " $MW_HOME/skins" \
192+ && chmod g+w -R " $MW_HOME/skins"
180193
181194FROM base AS final
182195
@@ -235,8 +248,8 @@ RUN set -x; \
235248 chmod -v +x /*.sh \
236249 && chmod -v +x /maintenance-scripts/*.sh \
237250 # Sitemap directory
238- && mkdir -p $MW_ORIGIN_FILES/sitemap \
239- && ln -s $MW_VOLUME/sitemap $MW_HOME/sitemap \
251+ && mkdir -p " $MW_ORIGIN_FILES/sitemap" \
252+ && ln -s " $MW_VOLUME/sitemap" " $MW_HOME/sitemap" \
240253 # Comment out ErrorLog and CustomLog parameters, we use rotatelogs in mediawiki.conf for the log files
241254 && sed -i 's/^\(\s *ErrorLog .*\) /# \1 /g' /etc/apache2/apache2.conf \
242255 && sed -i 's/^\(\s *CustomLog .*\) /# \1 /g' /etc/apache2/apache2.conf \
0 commit comments