diff --git a/.github/workflows/build_and_push_docker_image.yml b/.github/workflows/build_and_push_docker_image.yml new file mode 100644 index 0000000..be6efff --- /dev/null +++ b/.github/workflows/build_and_push_docker_image.yml @@ -0,0 +1,38 @@ +name: "Build and Push Docker-Image" + +on: + push: + +env: + REGISTRY: ghcr.io + IMAGE_NAME: ${{ github.repository }} + + +jobs: + build: + name: Build and Push + runs-on: ubuntu-latest + permissions: + packages: write + steps: + - name: checkout + uses: actions/checkout@v4 + - name: Log into GH container registry + uses: docker/login-action@65b78e6e13532edd9afa3aa52ac7964289d1a9c1 + with: + registry: ${{ env.REGISTRY }} + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + - name: Extract metadata (tags, labels) for Docker + id: meta + uses: docker/metadata-action@9ec57ed1fcdbf14dcef7dfbe97b2010124a938b7 + with: + images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} + - name: Build and push Docker image + uses: docker/build-push-action@f2a1d5e99d037542a71f64918e516c093c6f3fc4 + with: + context: . + push: true + tags: ${{ github.event.release.tag_name || steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} + file: Dockerfile diff --git a/.gitignore b/.gitignore index d7d6e17..00b52c2 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ extensions/ master.tar.gz *.zip +/.idea/ diff --git a/Dockerfile b/Dockerfile index d671bc3..fb6957e 100644 --- a/Dockerfile +++ b/Dockerfile @@ -155,7 +155,7 @@ ENV MW_ROOT /var/www/html # TODO remove the /etc/apt/preferences.d/no-debian-php and apt-get -q install -y --no-install-recommends zip unzip php-zip once we upgrade to 1.36 because they are not necessary anymore. RUN set -ex && \ apt-get -q update && apt-get upgrade -y && \ - apt-get -q install -y --no-install-recommends nano vim ripgrep tig fd-find && \ + apt-get -q install -y --no-install-recommends wget nano vim ripgrep tig fd-find && \ rm /etc/apt/preferences.d/no-debian-php && \ apt-get -q install -y --no-install-recommends zip unzip php-zip && \ apt-get -q install -y --no-install-recommends mariadb-client && \ @@ -164,22 +164,24 @@ RUN set -ex && \ # Define working directory for the following commands WORKDIR ${MW_ROOT} -# Copy Tweeki skin to skins/ -COPY ./skins/Tweeki skins/Tweeki - -# Copy extensions -COPY ./extensions extensions - # Copy the php.ini with desired upload_max_filesize into the php directory. COPY ./resources/php.ini /usr/local/etc/php/php.ini # Copy more assets and composer file. COPY ./resources/aqua.png resources/assets/aqua.png COPY ./composer.local.json composer.local.json +COPY ./build.sh . +RUN chmod +x ./build.sh +RUN ./build.sh +RUN rm ./build.sh + # TODO hack to address https://github.com/inblockio/DataAccounting/issues/244. # Remove this once MediaWiki has made a patch release. RUN sed -i 's/$this->package->setProvides( \[ $link \] );/$this->package->setProvides( \[ self::MEDIAWIKI_PACKAGE_NAME => $link \] );/' ./includes/composer/ComposerPackageModifier.php +# If this environment is not set, Composer does not work as intended. +ENV COMPOSER_ALLOW_SUPERUSER=1 + # Install the latest version of PHP package manager "Composer" and install # MW-OAuth2Client from Git master. RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin/ --filename=composer && \ diff --git a/build.sh b/build.sh index 5d4c937..0503ed4 100755 --- a/build.sh +++ b/build.sh @@ -4,40 +4,22 @@ set -euo pipefail tweeki_version=2.0.3 pdfembed_version=2.0.2 -embedvideo_version=2.9.0 -mkdir -p skins if [ ! -d skins/Tweeki ]; then echo "Downloading Tweeki skin" wget https://github.com/thaider/Tweeki/archive/refs/tags/v${tweeki_version}.tar.gz tar xf v${tweeki_version}.tar.gz mv Tweeki-* skins/Tweeki + rm v${tweeki_version}.tar.gz fi -mkdir -p extensions +# TODO move to composer.local.json # https://www.mediawiki.org/wiki/Extension:PDFEmbed if [ ! -d extensions/PDFEmbed ]; then echo "Downloading PDFEmbed" wget https://gitlab.com/hydrawiki/extensions/PDFEmbed/-/archive/${pdfembed_version}/PDFEmbed-${pdfembed_version}.zip unzip PDFEmbed-${pdfembed_version}.zip mv PDFEmbed-${pdfembed_version}/ extensions/PDFEmbed + rm PDFEmbed-${pdfembed_version}.zip fi - -# https://github.com/wikimedia/mediawiki-extensions-intersection -# We have a problem getting a permanent download url for this extension. -#if [ ! -d extensions/intersection ]; then -# echo "Downloading intersection" -# wget -#fi - -# Is commented out because the extension is deprecated in it's current version in MW 1.37.X -# https://www.mediawiki.org/wiki/Extension:EmbedVideo -# Disabled per stakeholder request in DataAccounting/issues/189 -# if [ ! -d extensions/EmbedVideo ]; then -# echo "Downloading EmbedVideo" -# wget https://gitlab.com/hydrawiki/extensions/EmbedVideo/-/archive/v${embedvideo_version}/EmbedVideo-v${embedvideo_version}.zip -# unzip EmbedVideo-v${embedvideo_version}.zip -# mv EmbedVideo-v${embedvideo_version} extensions/EmbedVideo -# fip -docker build -t inblockio/micro-pkc-mediawiki .