-
Notifications
You must be signed in to change notification settings - Fork 134
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Extension get disabled if container is recreated #81
Comments
Ok, same problem |
I've come up with a solution that may completely refactor https://github.com/mondediefr/docker-flarum/blob/master/rootfs/usr/local/bin/startup#L69-L125 rows |
The reason of disabled extensions comes from here |
For anyone else looking for a workaround, I've crafted a script that re-enables extensions that must be enabled: <?php
use Illuminate\Database\Capsule\Manager;
require_once 'vendor/autoload.php';
$config = include 'config.php';
$flarumDbPassword = $config['database']['password'] ? " -p{$config['database']['password']}" : '';
$db = new Manager();
$db->addConnection($config['database'], 'flarum');
// get supposed-to-be-enabled extensions
$extList = collect(explode("\n", file_get_contents('extensions/list')))
->map(function($ext) {
return str_replace('/', '-', $ext);
})
->filter(function ($ext) {
return $ext != '';
});
// get all currently enabled extensions and merge with supposed-to-be-enabled
$res = collect(json_decode($db->getConnection('flarum')
->table('settings')
->where('key', 'extensions_enabled')
->first()->value))
->merge($extList);
var_dump($res);
// save to database
$db->getConnection('flarum')
->table('settings')
->where('key', 'extensions_enabled')
->update(['value' => $res->values()->toJson(JSON_OBJECT_AS_ARRAY)]); We run flarum in Kubernetes, and the above script has to be executed after preparation steps in #...
command:
- /bin/sh
- -c
- |-
apk add --update mysql-client bash;
sed -i '/^exec su-exec.*/i php enable-extensions.php; php flarum migrate; php flarum assets:publish' /usr/local/bin/startup
/usr/local/bin/startup
#... I guess this could be contributed, but my PHP knowledge is not the best, so if anyone can improve it, feel free to raise a PR. |
I solved this problem by adding volumes for volumes:
- /mnt/docker/flarum/assets:/flarum/app/public/assets
- /mnt/docker/flarum/extensions:/flarum/app/extensions
- /mnt/docker/flarum/storage/logs:/flarum/app/storage/logs
- /mnt/docker/flarum/nginx:/etc/nginx/flarum
+ - /mnt/docker/flarum/vendor:/flarum/app/vendor
+ - /mnt/docker/flarum/composer.json:/flarum/app/composer.json
+ - /mnt/docker/flarum/composer.lock:/flarum/app/composer.lock |
Hi @PipecraftNet how exactly did you do this? Did you first start the container, copied the new three directories/files out of the container and mount them afterwards? I get errors when I mount these before the installation of flarum. |
I played around with the possibility to move the files However, when I mount the |
Same problem, have you solved this? |
I modified https://github.com/zzzhangqi/docker-flarum/blob/master/Dockerfile#L60-L61 use my image version: "3"
services:
flarum:
image: registry.cn-hangzhou.aliyuncs.com/zqqq/flarum:1.2.0
container_name: flarum
env_file:
- /mnt/docker/flarum/flarum.env
volumes:
- /mnt/flarum:/flarum/app
- /mnt/flarum/nginx:/etc/nginx/flarum
ports:
- 80:8888
depends_on:
- mariadb
mariadb:
image: mariadb:10.5
container_name: mariadb
environment:
- MYSQL_ROOT_PASSWORD=xxxxxxxxxx
- MYSQL_DATABASE=flarum
- MYSQL_USER=flarum
- MYSQL_PASSWORD=xxxxxxxxxx
volumes:
- /mnt/docker/mysql/db:/var/lib/mysql |
First time you'll need to go through the installation procedure without mounting
Then copy the content to your host, define the paths in your composer file and restart the container. |
This is my working solution: LoneDev6@9d753d6 |
This seems to solve issue mondediefr#81 as calling /flarum/app/flarum before extensions are installed will disable them, as per flarum/framework#2629
i do have copilot access - might be able to help I'm hoping most of these issues will just get fixed on setup - tbh tho could just make a free flarum on https://flarum.cloud i.e https://freeflarum.com/ as well. |
Hello, If the container is recreated (for example to toggle debug mode), all extension I added are disabled after restart. Any idea ?
The text was updated successfully, but these errors were encountered: