Deploying WriteFreely with docker-compose
Sadly, their deployment guide is lacking, their docker hub image is 7 months old and their
docker-compose.yml is just wrong1, so here's a quick guide to get started using docker-compose.
Build the image
As mentioned above, the docker image is outdated, so the best way to get WriteFreely is to build the docker image yourself.
Clone the repository:
git clone https://github.com/writeas/writefreely cd writefreely
Then, build the image:
docker build -t writefreely:dev .
This will take a while, while still building you can start setting up the docker-compose file, create a
docker-compose.yml file with this:
version: "3" services: web: image: writefreely:dev volumes: - "./config.ini:/go/config.ini" - web-keys:/go/keys networks: - writefreely restart: unless-stopped ports: - "8080:8080" db: image: "mariadb:latest" volumes: - db-data:/var/lib/mysql networks: - writefreely environment: - MYSQL_DATABASE=writefreely - MYSQL_ROOT_PASSWORD=change-me restart: unless-stopped volumes: web-keys: db-data: networks: writefreely:
"2" if you want to run this on portainer)
Create an empty
config.ini file in the same directory.
When the build is done, use
docker-compose up -d to start everything.
However, it will not work.
This is because there is some setting up to do. I haven't found a better way to do this (mostly because setting up requires both containers to be up and connected), if you know a better way please let me know!2
Before running the configuration, make sure the database container is set up correctly:
- Check that you can connect to the database as
rootfrom outside the container
- Check that the
I don't know why, but both were not working out of the box for me. If you need help, check the Troubleshooting section at the bottom.
Create configuration and initialize database tables
Run this command and follow the interactive configuration process:
docker exec -u root -it writefreely_web_1 /go/cmd/writefreely/writefreely -config
If everything went well, your config.ini should be now filled and your
writefreely database should have been populated with tables.
If you selected a multi-instance you will need to create an admin user manually, do it with this command:
docker exec -u root -it writefreely_web_1 /go/cmd/writefreely/writefreely -create-admin USERNAME:PASSWORD
Running behind a reverse-proxy
The official guide contains a sample Nginx configuration for running Writefreely behind a reverse proxy, but otherwise, it's just your run-of-the-mill web service and doesn't require any special treatment.
Interaction with Mastodon and other Fediverse clients
After deploying WriteFreely and getting a blog started, you should be able to follow it from Mastodon/Pleroma/etc by searching for
@blogname@blogurl, for example, this blog is
Keep in mind that because of how ActivityPub works, you can't see posts from before the instance you're on started following the one you're trying to subscribe to.
If your database configuration came broken as it happened to me, here's how to fix it:
Connect to the database:
docker exec -it writefreely_db_1 /usr/bin/mysql
Run these commands, depending on the issue:
-- Table not found CREATE DATABASE "writefreely"; -- Cannot connect as root from outside GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY '<password>'; FLUSH PRIVILEGES;