The preferred way to run WriteFreely is by using the provided docker-compose.yml file.
The first step to run WriteFreely is to create the configuration file. It can be copied from the WriteFreely repository to the same folder containing the compose file:
cp config/sample-config.ini config.iniOr it can be generated by using the WriteFreely container:
touch config.ini
chmod 606 config.ini
docker run --name writefreely --rm --interactive --tty --mount type=bind,source=./config.ini,destination=/go/config.ini,rw,relabel=private docker.io/writeas/writefreely:latest config generateWhile running, the container will present you with several questions to set up your configuration file. Once it is complete, the configuration file should be present in your current folder and you should change it to make sure the following settings are correct:
bind = 0.0.0.0
username = writefreely # same as MYSQL_USER in writefreely-db.container
password = writefreelypass # same as MYSQL_PASSWORD in writefreely-db.container
database = writefreelydb # same as MYSQL_DATABASE in writefreely-db.container
hostname = writefreely-db # same as the container service name
single_user = false
open_registration = trueOnce the changes have been done, you may start the main containers:
docker compose --project-name writefreely up --detachThe MariaDB container should be running, but not WriteFreely yet. You will need to initialize the database using a disposable WriteFreely container connecting to the database:
docker run --network writefreely_writefreely --name writefreely --rm --interactive --tty --mount type=bind,source=./config.ini,destination=/go/config.ini,rw docker.io/writeas/writefreely:latest db initAfter that, simply start the WriteFreely container:
docker start writefreely-webCongratulations, your WriteFreely instance should be running under http://localhost:8080! 🎉
Remember that the first user to register in your instance will be the admin user.
The compose file follows best practices for SELinux flags such that it should run correctly under podman compose using the same instructions provided for docker compose.
The main differences here are that the use of Docker Networks is not required except for initializing the database, and you may instead use Kubernetes Pods instead. In other words:
- You don't need to use
networks:in the compose file - You can run
podman-compose --project-name writefreely --in-pod 1 up --detachto raise the containers under a pod - You can run
podman run --pod pod_writefreely --network writefreely_writefreely --name writefreely --rm --interactive --tty --mount type=bind,source=./config.ini,destination=/go/config.ini,rw docker.io/writeas/writefreely:latest db initto initialize the database while in a pod
Once your containers are running, you may then generate systemd service files using podman-generate-systemd, generate a Kubernetes Deployment using podman-kube-generate, or even better, use Podman Quadlets instead of compose files for easy integration with systemd.
WriteFreely will attempt to generate keys if you do not provide your own with
writefreely generate keys. If you fail to mount the volume correctly, you will see:
ERROR: 2023/07/31 02:52:02 main.go:120: init keys: open keys/email.aes256: no such file or directory
If you fail to initialize the database, you will see:
Error 1146: Table 'writefreelydb.collections' doesn't exist.
You should use 0.0.0.0 as your bind in the configuration file. Otherwise, you will see:
curl http://localhost:8080
curl: (56) Recv failure: Connection reset by peer
If your config file contains open_registration=false and single_user=true, you will see "Page not found".