Docker file & compose for phpBB3

I needed a local instance to play around with phpBB, which I couldn’t find recent docker files for, so I just created my own. The below are the docker-compose.yml and Dockerfile for the latest version of phpBB as of now; 3.3.14.

Note: Make sure to change the variables inside the environment section in the docker-compose.yml file before installation.

Dockerfile

# Use the official PHP image with Apache
FROM php:8.2-apache 

# Install required PHP extensions and dependencies
RUN apt-get update && apt-get install -y \
    wget \
    mariadb-client \
    unzip \
    && docker-php-ext-install mysqli pdo pdo_mysql \
    && docker-php-ext-enable mysqli pdo pdo_mysql \
    && apt-get clean && rm -rf /var/lib/apt/lists/*

# Enable Apache modules
RUN a2enmod rewrite

# Set working directory
WORKDIR /var/www/html

# Download and extract phpBB
RUN wget https://download.phpbb.com/pub/release/3.3/3.3.14/phpBB-3.3.14.zip && \
    unzip phpBB-3.3.14.zip && \
    mv phpBB3 phpbb && \
    rm -rf phpBB-3.3.14.zip

# Set permissions
RUN chown -R www-data:www-data /var/www/html/phpbb && \
    chmod -R 755 /var/www/html/phpbb

# Expose Apache port
EXPOSE 80

CMD ["apache2-foreground"]

docker-compose.yml

services:
  phpbb:
    build: .
    container_name: phpbb
    restart: unless-stopped
    ports:
      - "8080:80"
    volumes:
      - phpbb-data:/var/www/html/phpbb
    depends_on:
      - mariadb
    environment:
      - MYSQL_HOST=mymariadb_host
      - MYSQL_USER=myphpbb_mymariadb_user
      - MYSQL_PASSWORD=MySuperStrongPassword12345
      - MYSQL_DATABASE=myphpbb_db

  mariadb:
    image: mariadb:10.11
    container_name: phpbb-mariadb
    restart: unless-stopped
    environment:
      MYSQL_ROOT_PASSWORD: rootpassword
      MYSQL_DATABASE: myphpbb_db
      MYSQL_USER: myphpbb_mymariadb_user
      MYSQL_PASSWORD: MySuperStrongPassword12345
    volumes:
      - db-data:/var/lib/mysql

volumes:
  phpbb-data:
  db-data:

Let’s get to action!

  • To build and start: docker-compose up -d --build
  • Access the installation at http://localhost:8080/phpbb/install and enter the parameters inside the first environment section in the docker-compose.yml file
  • After installation is complete from the above link, you have to run docker exec -it phpbb rm -rf /var/www/html/phpbb/install
  • To wipe it and start all over: docker-compose down -v

I’ve made these file also available on my GitHub repo here: https://github.com/ahmedatawfik/usefulscripts/tree/main/docker/phpBB

That’s it, Enjoy!

References:

Unknown's avatar

About Ahmed Tawfik

Cybersecurity Professional, Systems Engineer, OSS & Linux Geek
This entry was posted in docker, Linux and tagged , , , , , . Bookmark the permalink.

2 Responses to Docker file & compose for phpBB3

  1. ASHAR's avatar ASHAR says:

    This is a great guide for setting up a local instance of phpBB using Docker! Your step-by-step approach, including both the Dockerfile and docker-compose.yml, makes it easy to follow. The inclusion of MariaDB as the database and the necessary environment variables ensures a smooth setup. I also appreciate the reminder to remove the installation directory after setup. This setup looks efficient for local testing and development. Have you considered adding instructions for persistent data storage or SSL support for a production-like environment?

    Like

  2. maltokyo's avatar maltokyo says:

    Hi, I made some suggestions for improvements. Overall, thanks a lot, works well for me. But I would suggest to make some changes as I documented here: https://github.com/ahmedatawfik/usefulscripts/issues/1

    Like

Leave a reply to maltokyo Cancel reply