Hello,
I'm trying to figure out how to install and run this forum software as a docker container.
From what I see in the forum discussions and documentation, there is a lot of administrative tasks tasks that require running composer commands directly in the directory where live forum is installed.
I'm not sure if I could have a git repository, run composer on those files and when I think everything is right package the resulting repo into a docker container.
Also I've noticed that apache and nginx seem to be the most supported webservers. I'm more familiar with caddy, however I'm not sure if I can count on this forum engine to not expose by accident some sensitive data just because a .htacces file wasn't honored.
My setup so far:
.
├── caddy
│ └── Caddyfile
├── docker-compose.yml
├── Dockerfile.caddy
├── Dockerfile.flarum
├── flarum
│ ├── assets
│ ├── CHANGELOG.md
│ ├── composer.json
│ ├── composer.lock
│ ├── extend.php
│ ├── flarum
│ ├── index.php
│ ├── LICENSE
│ ├── public
│ ├── README.md
│ ├── site.php
│ ├── storage
│ ├── vendor
│ └── web.config
├── php-fpm-wrapper.sh
└── prepare-flarum-fs.sh
`
docker-compose.yml
`version: '3.3'
services:
caddy:
build:
context: ./
dockerfile: ./Dockerfile.caddy
restart: always
ports:
- "2137:2137"
- "443:443"
volumes:
- caddy_data:/data
- caddy_config:/config
- flarum_data:/persistent
depends_on:
- php-fpm
- database
networks:
- internal_reverse_proxy
php-fpm:
build:
context: ./
dockerfile: ./Dockerfile.flarum
restart: always
volumes:
- flarum_data:/persistent
networks:
- internal_reverse_proxy
- internal_db
database:
image: mariadb:10.5
container_name: mariadb
environment:
- MYSQL_ROOT_PASSWORD=flarum
- MYSQL_DATABASE=flarum
- MYSQL_USER=flarum
- MYSQL_PASSWORD=flarum
volumes:
- database_data:/var/lib/mysql
networks:
- internal_db
volumes:
caddy_data:
caddy_config:
database_data:
flarum_data:
networks:
internal_db:
external: false
internal_reverse_proxy:
external: false
Dockerfile.flarum
FROM bitnami/php-fpm:8.2.24-debian-12-r0
COPY ./flarum /flarum
COPY prepare-flarum-fs.sh /
RUN chmod +x /prepare-flarum-fs.sh
RUN /prepare-flarum-fs.sh
COPY /php-fpm-wrapper.sh /
RUN chmod +x /php-fpm-wrapper.sh
CMD ["bash", "/php-fpm-wrapper.sh"]
Dockerfile.caddy
FROM caddy:2.8.4
COPY ./caddy/Caddyfile /etc/caddy/Caddyfile
COPY ./flarum /flarum
RUN apk add --no-cache bash
COPY ./prepare-flarum-fs.sh /
RUN chmod +x /prepare-flarum-fs.sh
RUN /prepare-flarum-fs.sh
prepare-flarum-fs.sh
#!/bin/bash
rm -rfv /flarum/README.md /flarum/composer.lock /flarum/composer.json /flarum/LICENSE /flarum/CHANGELOG /flarum/.nginx.conf /flarum/.htaccess /flarum/.editorconfig && \
rm -rfv /flarum/assets && \
ln -s -T /persistent/assets /flarum/assets && \
ln -s -T /persistent/extensions /flarum/extensions && \
ln -s -T /persistent/logs /flarum/logs && \
chown $USER:root -R /flarum && \
chmod 777 -R /flarum && \
mkdir /persistent && \
mkdir /restore && \
mv /flarum/storage /restore/ && \
ln -s -T /persistent/storage /flarum/storage
php-fpm-wrapper.sh
#!/bin/bash
mkdir -p /persistent/assets
mkdir -p /persistent/extensions
mkdir -p /persistent/logs
if [ -d "/restore" ]; then
echo "restoring files from /restore to /persistent"
mv -v /restore/* /persistent
rm -rfv /restore
fi
chmod 777 -R /persistent
php-fpm -F --pid /opt/bitnami/php/tmp/php-fpm.pid -y /opt/bitnami/php/etc/php-fpm.conf
Caddyfile
{
admin off
auto_https off
persist_config off
log {
format console
}
}
:2137 {
root * /flarum
php_fastcgi php-fpm:9000
header /assets/* {
+Cache-Control "public, must-revalidate, proxy-revalidate"
+Cache-Control "max-age=25000"
Pragma "public"
}
file_server
}