twaxter
New member
Hello,
Based on documentation and various forum posts I've read, it seems very difficult (I've been trying past few days) to get Xenforo running with docker in a production environment.
The approaches I've seen is mounting the xenforo code base via a container inside a php container, but this is not good practice.
When using something like docker, the code base is supposed to be copied into the image - so when you make changes to it (install an add-on, update the xenforo version), you can test in lower environments, create a distinct tag for the image, and then deploy it in your production environments. You store any sort of state in a database that runs independently. This means that if perhaps you need to horizontally scale, you can do so quite easily, just increase the number of web containers + increase replicas of your db + upgrade your redis etc.
Upgrades should not be done in a live environment through a web GUI, and you should be able to start up the xenforo service with just a container + some secrets or environmental variables.
I understand that this is very difficult to support given that xenforo is built around running on a single VPS and using a GUI. So I'm just asking for some help on getting this to work. I do think that is a valuable addition to xenforo, cause you'd get customers to deploy this to cloud infrastructure quite easily.
Ideally, what I'd like to do is:
1. Download the Zip File
2. Copy the contents + any add-ons I installed into a docker container (that has a NGINX OR Apache + PHP dependencies), that I push to a private repository
3. Set up some environmental variables and secrets
Here is what I've got to so far:
This works locally, however, I need to always do localhost:8080/install...
I mount the code base, and copy my config.php (which has database credentials in it)
- ./xenforo:/var/www/html
- ./config.php:/var/www/html/src/config.php
I was trying to create a docker file that has the code base built in (it copies your zip file + config.php), but it appears that the code base is writing to an internal_data folder in /var/www/html. I think I could use some start up scripts (use the xenforo cli) that need to be run I think, that would help in installing add-ons or initializing the forum (kinda what /install)
I am a noob when it comes to apache/nginx/php configurations btw. I got lucky getting everything to work in that apache container.
So yeah, looking for help in this approach. I will comment on his if I make any progress so it could potentially help others.
Based on documentation and various forum posts I've read, it seems very difficult (I've been trying past few days) to get Xenforo running with docker in a production environment.
The approaches I've seen is mounting the xenforo code base via a container inside a php container, but this is not good practice.
When using something like docker, the code base is supposed to be copied into the image - so when you make changes to it (install an add-on, update the xenforo version), you can test in lower environments, create a distinct tag for the image, and then deploy it in your production environments. You store any sort of state in a database that runs independently. This means that if perhaps you need to horizontally scale, you can do so quite easily, just increase the number of web containers + increase replicas of your db + upgrade your redis etc.
Upgrades should not be done in a live environment through a web GUI, and you should be able to start up the xenforo service with just a container + some secrets or environmental variables.
I understand that this is very difficult to support given that xenforo is built around running on a single VPS and using a GUI. So I'm just asking for some help on getting this to work. I do think that is a valuable addition to xenforo, cause you'd get customers to deploy this to cloud infrastructure quite easily.
Ideally, what I'd like to do is:
1. Download the Zip File
2. Copy the contents + any add-ons I installed into a docker container (that has a NGINX OR Apache + PHP dependencies), that I push to a private repository
3. Set up some environmental variables and secrets
- Database Credentials
- License Key Secret etc
- Redis Credentials
- Add-ON settings
Here is what I've got to so far:
My Docker-compose:# Use the official PHP 8.1 image with Apache
FROM php:8.1-apache
# Install necessary PHP extensions
RUN apt-get update && apt-get install -y \
libpng-dev \
libjpeg-dev \
libfreetype6-dev \
libonig-dev \
libzip-dev \
zip \
unzip \
&& docker-php-ext-configure gd --with-freetype --with-jpeg \
&& docker-php-ext-install gd mysqli pdo pdo_mysql zip exif
# Enable Apache mod_rewrite
RUN a2enmod rewrite
# Copy custom PHP configuration
COPY php.ini /usr/local/etc/php/
# Set working directory
WORKDIR /var/www/html
services:
web:
image: php:8.1-apache
container_name: xenforo_web
build:
context: .
dockerfile: Dockerfile
ports:
- "8080:80"
volumes:
- ./xenforo:/var/www/html
- ./config.php:/var/www/html/src/config.php
depends_on:
- db
environment:
- APACHE_DOCUMENT_ROOT=/var/www/html
restart: always
db:
image: mysql:8.0
container_name: xenforo_db
ports:
- "3306:3306"
environment:
MYSQL_ROOT_PASSWORD: root
MYSQL_DATABASE: xenforo
MYSQL_USER: xenforo_user
MYSQL_PASSWORD: password
volumes:
- ./.db_volume:/var/lib/mysql
restart: always
This works locally, however, I need to always do localhost:8080/install...
I mount the code base, and copy my config.php (which has database credentials in it)
- ./xenforo:/var/www/html
- ./config.php:/var/www/html/src/config.php
I was trying to create a docker file that has the code base built in (it copies your zip file + config.php), but it appears that the code base is writing to an internal_data folder in /var/www/html. I think I could use some start up scripts (use the xenforo cli) that need to be run I think, that would help in installing add-ons or initializing the forum (kinda what /install)
I am a noob when it comes to apache/nginx/php configurations btw. I got lucky getting everything to work in that apache container.
So yeah, looking for help in this approach. I will comment on his if I make any progress so it could potentially help others.