Introduction
Since I've gotten Flarum to run on a single docker container, I've learned a lot about docker and docker-compose.
In short, I was stupid back then. Now I think I got it right.
Code on GitHub
I worked on a fork from the official repository: https://github.com/nadi106/flarum
PR was made for the official repo: flarum/flarum61
Instructions
Assuming you've got Docker and docker-compose installed, run the following commands:
git clone https://github.com/nadi106/flarum.git -b feature/docker-compose
cd flarum
docker run --rm -it -v $PWD:/app composer install
# (windows powershell) docker run --rm -it -v ${pwd}:/app comopser install
docker-compose up -d
And access flarum from localhost:8080.
Initial setup
Use the following fields for the DB to work:
- MySQL Host: mariadb
- MySQL Username: flarum
- MySQL Password: flarumpass
Other fields can be of your choosing.
Please explain
- You should know what
cd and git clone do.
- (optional)
docker run --rm -it -v $PWD:/app composer install will install all of the dependencies required by Flarum, without downloading Composer (you can instead download and install composer if you'd like).
docker-compose up -d will read the docker-compose.yml file and start the containers inside.
More info
docker-compose.yml
The compose file specifies to run the following containers:
nginx:alpine - web server for handling http requests.
flarum-fpm - a custom image based on php:7.2-fpm-alpine which adds required PHP dependencies for Flarum to run.
mariadb:10.4 - a database container.
Docker volumes
- The DB container saves its data on a docker volume which is created by
docker-compose. This means the data will remain even if you delete the container.
- The git root directory is being mounted on both the
web and php containers so that they can serve the requested pages.
- Also,
nginx is configured with nginx/flarum.conf with a simple configuration which can be updated if need be.
Stopping the server
docker-compose down
Found Something Wrong?
Comment on the pull request on GitHub.