Building and publishing a container image for the MediaWiki core project involves several steps. Below is a general guide to help you through the process:
- Docker Installed: Ensure you have Docker installed on your machine.
- Git Installed: You will need Git to clone the MediaWiki repository.
- Access to a Container Registry: You need access to a container registry (like Docker Hub, GitHub Container Registry, or a private registry) to publish your image.
First, clone the MediaWiki core repository from GitHub:
git clone https://gerrit.wikimedia.org/r/mediawiki/core.git
cd core
Create a Dockerfile
in the root of the cloned repository. Here’s a basic example of what the Dockerfile
might look like:
# Use an official PHP runtime as a parent image
FROM php:8.0-apache
# Set the working directory
WORKDIR /var/www/html
# Install dependencies
RUN apt-get update && apt-get install -y \
git \
unzip \
&& docker-php-ext-install mysqli pdo pdo_mysql
# Copy the MediaWiki files into the container
COPY . .
# Set permissions
RUN chown -R www-data:www-data /var/www/html
# Expose the port the app runs on
EXPOSE 80
# Start Apache
CMD ["apache2-foreground"]
Run the following command to build the Docker image. Replace your-image-name
with your desired image name.
docker build -t your-image-name:latest .
You can run the image locally to test it:
docker run -d -p 8080:80 your-image-name:latest
Visit http://localhost:8080
in your web browser to see if MediaWiki is running.
If you are using Docker Hub, log in using:
docker login
Tag your image for the registry. Replace your-username
and your-image-name
accordingly.
docker tag your-image-name:latest your-username/your-image-name:latest
Finally, push the image to your container registry:
docker push your-username/your-image-name:latest
You have now built and published a container image for the MediaWiki core project. You can pull this image from your container registry on any machine with Docker installed. Adjust the Dockerfile
as necessary to include any additional extensions or configurations specific to your MediaWiki setup.