Skip to content

Instantly share code, notes, and snippets.

@hashar
Last active June 18, 2025 16:41
Show Gist options
  • Save hashar/7463cf7e3a993736b2d3f55f351f29bd to your computer and use it in GitHub Desktop.
Save hashar/7463cf7e3a993736b2d3f55f351f29bd to your computer and use it in GitHub Desktop.
GPT-4o mini: build and publish a container image for project mediawiki/core

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:

Prerequisites

  1. Docker Installed: Ensure you have Docker installed on your machine.
  2. Git Installed: You will need Git to clone the MediaWiki repository.
  3. 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.

Steps to Build and Publish a Container Image

1. Clone the MediaWiki Repository

First, clone the MediaWiki core repository from GitHub:

git clone https://gerrit.wikimedia.org/r/mediawiki/core.git
cd core

2. Create a Dockerfile

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"]

3. Build the Docker Image

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 .

4. Test the Docker Image Locally

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.

5. Log in to Your Container Registry

If you are using Docker Hub, log in using:

docker login

6. Tag the Image

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

7. Push the Image to the Registry

Finally, push the image to your container registry:

docker push your-username/your-image-name:latest

Conclusion

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment