Skip to content

Commit

Permalink
Improve docker layers (#844)
Browse files Browse the repository at this point in the history
* Improve docker layers

* fix: Embed LocalSettings.php in femiwiki image

* Load TorBlock

* Update Dockerfile

* Load RealMe and GoogleNewsSitemap

* Ignore phpactor

* actions: Reduce timeout to 2 minutes

* fix: Do not embed LocalSettings.php in mediawiki image

* fix: Docker name in github actions workflow
  • Loading branch information
lens0021 authored May 21, 2024
1 parent 3466c6e commit 6649b7c
Show file tree
Hide file tree
Showing 10 changed files with 57 additions and 18 deletions.
12 changes: 6 additions & 6 deletions .github/workflows/docker-femiwiki.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@ jobs:
- name: Edit configuration
run: |
mv development/secret.php.example development/secret.php
mv dockers/mediawiki/LocalSettings.php development
mv dockers/femiwiki/LocalSettings.php development
mv dockers/femiwiki/Hotfix.php development
sed -i -r 's~ghcr\.io\/femiwiki\/mediawiki:.+~ghcr\.io\/femiwiki\/mediawiki:docker-test~' docker-compose.yml
sed -i -r 's~ghcr\.io\/femiwiki\/femiwiki:.+~ghcr\.io\/femiwiki\/femiwiki:docker-test~' docker-compose.yml
- run: |
echo "version=$(date +%Y-%m-%dT%H-%M)-$(echo ${{ github.sha }} | cut -c1-8)" >> $GITHUB_OUTPUT
Expand All @@ -36,19 +36,19 @@ jobs:
with:
context: '{{ defaultContext }}:dockers/femiwiki'
platforms: linux/amd64
cache-from: ghcr.io/femiwiki/mediawiki:latest
cache-from: ghcr.io/femiwiki/femiwiki:latest
cache-to: mode=max,type=local,dest=/tmp/.buildx-cache
load: true
push: false
tags: ghcr.io/femiwiki/mediawiki:docker-test
tags: ghcr.io/femiwiki/femiwiki:docker-test

- name: Initialize docker swarm and start services
run: |
docker swarm init
docker stack deploy -c docker-compose.yml mediawiki
- name: Access 127.0.0.1:8080 until success
timeout-minutes: 3
timeout-minutes: 2
run: |
echo 'Waiting for http...'
until curl -sLfo /dev/null 127.0.0.1:8080; do
Expand Down Expand Up @@ -96,7 +96,7 @@ jobs:
context: '{{defaultContext}}:dockers/femiwiki'
platforms: linux/amd64,linux/arm64
cache-from: |
ghcr.io/femiwiki/mediawiki:latest
ghcr.io/femiwiki/femiwiki:latest
type=local,src=/tmp/.buildx-cache
cache-to: mode=max,type=inline
load: false
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/docker-mediawiki.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name: 'Docker: mediawiki'

env:
TAG: '2.0.0'
TAG: '2.0.1'

on:
push:
Expand Down
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@
/development/Hotfix.php
/development/analytics-credentials-file.json

# PHP
.phpactor.json

# Composer
/vendor

Expand Down
4 changes: 2 additions & 2 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
version: '3'
services:
http:
image: ghcr.io/femiwiki/femiwiki:latest
image: ghcr.io/femiwiki/femiwiki:dev
command: caddy run
ports:
- 8080:8080
Expand All @@ -21,7 +21,7 @@ services:
options:
max-size: '100m'
fastcgi:
image: ghcr.io/femiwiki/femiwiki:latest
image: ghcr.io/femiwiki/femiwiki:dev
volumes:
# Mount secret.php, LocalSettings.php and site-list.xml
- ./development:/a:ro
Expand Down
26 changes: 22 additions & 4 deletions dockers/femiwiki/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,21 @@
#
FROM --platform=$TARGETPLATFORM ghcr.io/femiwiki/caddy:1.0.0 AS caddy

FROM --platform=$TARGETPLATFORM ghcr.io/femiwiki/mediawiki:1.1.0
FROM --platform=$TARGETPLATFORM ghcr.io/femiwiki/femiwiki-extensions:1.2.0 AS extensions

FROM --platform=$TARGETPLATFORM ghcr.io/femiwiki/mediawiki:2.0.0

# Set timezone
ENV TZ=Asia/Seoul
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone

# Install Mediawiki and extensions
RUN mv /mediawiki /srv/femiwiki.com/ &&\
rm -rf /srv/femiwiki.com/extensions &&\
rm -rf /srv/femiwiki.com/skins
COPY --from=extensions /mediawiki/extensions /srv/femiwiki.com/extensions
COPY --from=extensions /mediawiki/skins /srv/femiwiki.com/skins

# Install Caddy
COPY --from=caddy /usr/bin/caddy /usr/bin/caddy

Expand All @@ -23,14 +32,23 @@ RUN mkdir -p \
/etc/caddy \
/usr/share/caddy

# Install MediaWiki
RUN mv /mediawiki /srv/femiwiki.com

WORKDIR /srv/femiwiki.com

COPY composer.local.json /srv/femiwiki.com

RUN COMPOSER_HOME=/composer /usr/bin/composer update --no-dev --working-dir /srv/femiwiki.com

# Web server should be able to write 'extensions/Widgets/compiled_templates'
# directory Required by 'Widgets' extension
# Reference: https://www.mediawiki.org/wiki/Extension:Widgets
RUN chmod o+w /srv/femiwiki.com/extensions/Widgets/compiled_templates

# Ship femiwiki resources
COPY --chown=www-data:www-data resources /srv/femiwiki.com/
COPY --chown=www-data:www-data ["site-list.xml", "Hotfix.php", "/a/"]
RUN mkdir /mediawiki/

COPY --chown=www-data LocalSettings.php /a/

EXPOSE 80
EXPOSE 443
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -590,6 +590,9 @@
$wgGrantPermissions['editinterface']['gadgets-edit'] = true;
$wgGrantPermissions['editinterface']['gadgets-definition-edit'] = true;

// GoogleNewsSitemap
wfLoadExtension( 'GoogleNewsSitemap' );

// GoogleSiteSearch
wfLoadExtension( 'GoogleSiteSearch' );
$wgGoogleSiteSearchCSEID = '44508684d5c0e489c';
Expand Down Expand Up @@ -767,6 +770,9 @@
// QuickInstantCommons
wfLoadExtension( 'QuickInstantCommons' );

// RealMe
wfLoadExtension( 'RealMe' );

// RelatedArticles
wfLoadExtension( 'RelatedArticles' );
$wgRelatedArticlesCardLimit = 6;
Expand Down Expand Up @@ -833,6 +839,9 @@
// TitleBlacklist
wfLoadExtension( 'TitleBlacklist' );

// TorBlock
wfLoadExtension( 'TorBlock' );

// Translate
wfLoadExtension( 'Translate' );
$wgGroupPermissions['autoconfirmed']['translate'] = true;
Expand Down
12 changes: 10 additions & 2 deletions dockers/femiwiki/README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
# femiwiki

## 1.1.0
## v1.1.1

- Bump mediawiki to v1.1.0
- Bump femiwiki/mediawiki to v2.0.0
- Run Composer
- Download extensions from femiwiki/femiwiki-extensions v1.1.1
- Embed LocalSettings.php in this image
- Load TorBlock, RealMe, GoogleNewsSitemap

## v1.1.0

- Bump femiwiki/mediawiki to v1.1.0
File renamed without changes.
3 changes: 0 additions & 3 deletions dockers/mediawiki/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,5 @@ COPY cron/generate-sitemap \
RUN mkdir -p /mediawiki/sitemap &&\
chown www-data:www-data /mediawiki/sitemap

# Ship femiwiki-specific mediawiki configurations
COPY --chown=www-data LocalSettings.php /a/

# secret.php should be mounted to '/a/secret.php'
VOLUME /a
4 changes: 4 additions & 0 deletions dockers/mediawiki/README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# docker-mediawiki

## 2.0.1

- Do not embed LocalSettings.php

## 2.0.0

- Remove extensions
Expand Down

0 comments on commit 6649b7c

Please sign in to comment.