Skip to content
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

Docker won't start #726

Open
benpate opened this issue Jul 4, 2023 · 9 comments
Open

Docker won't start #726

benpate opened this issue Jul 4, 2023 · 9 comments

Comments

@benpate
Copy link

benpate commented Jul 4, 2023

I'm trying to fire up WriteFreely in a Docker container using the instructions on the website. It seems to go pretty smoothly when I run docker-compose up -d but then the writefreely-web instance won't start, which prevents me from running the ./docker-setup.sh command.

The logs look like this:

2023-07-04 12:07:26 2023/07/04 18:07:26 Starting WriteFreely ...
2023-07-04 12:07:26 2023/07/04 18:07:26 Loading config.ini configuration...
2023-07-04 12:07:27 2023/07/04 18:07:27 Starting WriteFreely ...
2023-07-04 12:07:27 2023/07/04 18:07:27 Loading config.ini configuration...
2023-07-04 12:07:27 2023/07/04 18:07:27 Starting WriteFreely ...
2023-07-04 12:07:27 2023/07/04 18:07:27 Loading config.ini configuration...
2023-07-04 12:07:28 2023/07/04 18:07:28 Starting WriteFreely ...
2023-07-04 12:07:28 2023/07/04 18:07:28 Loading config.ini configuration...
2023-07-04 12:07:29 2023/07/04 18:07:29 Starting WriteFreely ...
2023-07-04 12:07:29 2023/07/04 18:07:29 Loading config.ini configuration...
2023-07-04 12:07:31 2023/07/04 18:07:31 Starting WriteFreely ...
2023-07-04 12:07:31 2023/07/04 18:07:31 Loading config.ini configuration...
2023-07-04 12:07:35 2023/07/04 18:07:35 Starting WriteFreely ...
2023-07-04 12:07:35 2023/07/04 18:07:35 Loading config.ini configuration...
2023-07-04 12:07:42 2023/07/04 18:07:42 Starting WriteFreely ...
2023-07-04 12:07:42 2023/07/04 18:07:42 Loading config.ini configuration...
2023-07-04 12:07:26 ERROR: 2023/07/04 18:07:26 app.go:146: Unable to load configuration: BOM: read config.ini: is a directory
2023-07-04 12:07:27 ERROR: 2023/07/04 18:07:27 app.go:146: Unable to load configuration: BOM: read config.ini: is a directory
2023-07-04 12:07:27 ERROR: 2023/07/04 18:07:27 app.go:146: Unable to load configuration: BOM: read config.ini: is a directory
2023-07-04 12:07:28 ERROR: 2023/07/04 18:07:28 app.go:146: Unable to load configuration: BOM: read config.ini: is a directory
2023-07-04 12:07:29 ERROR: 2023/07/04 18:07:29 app.go:146: Unable to load configuration: BOM: read config.ini: is a directory
2023-07-04 12:07:31 ERROR: 2023/07/04 18:07:31 app.go:146: Unable to load configuration: BOM: read config.ini: is a directory
2023-07-04 12:07:35 ERROR: 2023/07/04 18:07:35 app.go:146: Unable to load configuration: BOM: read config.ini: is a directory
2023-07-04 12:07:42 ERROR: 2023/07/04 18:07:42 app.go:146: Unable to load configuration: BOM: read config.ini: is a directory

Sure enough, when I go to the WriteFreely directory, there's a new folder called config.ini -- which doesn't seem right.

This seems to be created by the docker-compose.yml, with this config:

services:
  writefreely-web:
    volumes:
      - "web-keys:/go/keys"
      - "./config.ini:/go/config.ini"

Am I doing something wrong? Or is there a simple fix?

@thebaer
Copy link
Member

thebaer commented Jul 5, 2023

Unfortunately I'm not familiar with Docker... But yeah, config.ini should be a text file that persists after the container is shut down. I'm not sure why it's a directory here.

Normally / without Docker, this config file is dynamically generated with the writefreely config start command. Maybe you could run that and then use the config file it generates? Again I'm out of my element with Docker, so will need someone else to figure out what's going on here.

@benpate
Copy link
Author

benpate commented Jul 5, 2023

Hey.. thanks for getting back so quick! I don't really know Docker either :) I'll try to mess with it and see what I come up with. I'll send a PR if I can actually make Docker work.

@fnyu
Copy link

fnyu commented Jul 7, 2023

@benpate Is the config.ini on your host machine a file or a directory? Was it ever a directory? Maybe there's a volume that's been created before and it is not being recreated. Check the output from docker volume ls command.

@fyrfli
Copy link

fyrfli commented Jul 8, 2023

One thing I have noticed with docker is, if the file doesn't already exist, docker compose up will create the 'file' as a 'directory' instead.

I haven't tried running writefreely in docker yet, so I can't say for sure this will work for it, but try removing the directory and then touch config.ini before you docker compose up -d and see if that works?

@herzenschein
Copy link

herzenschein commented Jul 30, 2023

That's right, Docker (and Podman) will generate a directory with the volume name if it doesn't exist and if it starts with ./. The way to avoid this is with external: true for the volume IIRC, I might be wrong.

A config file can be generated for Podman at least with the instructions of this PR, in "Making the writefreely-config.ini". Something similar should work with Docker I suppose.

Here's a sample file with a few database things added:

Click to see file
[server]
hidden_host          = 
port                 = 8080
bind                 = localhost
tls_cert_path        = 
tls_key_path         = 
autocert             = false
templates_parent_dir = 
static_parent_dir    = 
pages_parent_dir     = 
keys_parent_dir      = 
hash_seed            = 
gopher_port          = 0

[database]
type     = mysql
filename = 
username = writefreely
password = writefreelypass
database = writefreelydb
host     = writefreely-db
port     = 3306
tls      = false

[app]
site_name             = 
site_description      = 
host                  = http://localhost:8080
theme                 = write
editor                = 
disable_js            = false
webfonts              = true
landing               = 
simple_nav            = false
wf_modesty            = false
chorus                = false
forest                = false
disable_drafts        = false
single_user           = true
open_registration     = false
open_deletion         = false
min_username_len      = 3
max_blogs             = 1
federation            = true
public_stats          = true
monetization          = false
notes_only            = false
private               = false
local_timeline        = false
user_invites          = 
default_visibility    = 
update_checks         = false
disable_password_auth = false

[oauth.slack]
client_id          = 
client_secret      = 
team_id            = 
callback_proxy     = 
callback_proxy_api = 

[oauth.writeas]
client_id          = 
client_secret      = 
auth_location      = 
token_location     = 
inspect_location   = 
callback_proxy     = 
callback_proxy_api = 

[oauth.gitlab]
client_id          = 
client_secret      = 
host               = 
display_name       = 
callback_proxy     = 
callback_proxy_api = 

[oauth.gitea]
client_id          = 
client_secret      = 
host               = 
display_name       = 
callback_proxy     = 
callback_proxy_api = 

[oauth.generic]
client_id          = 
client_secret      = 
host               = 
display_name       = 
callback_proxy     = 
callback_proxy_api = 
token_endpoint     = 
inspect_endpoint   = 
auth_endpoint      = 
scope              = 
allow_disconnect   = false
map_user_id        = 
map_username       = 
map_display_name   = 
map_email          = 

IMO it makes sense to have a sample config in the repository itself so users don't have to resort to automatic generation. It seems it was removed in 0eb1a2d#diff-03c62cb3e26f06d4d8277f11504a5121def68db562388cd769c2c6aaa234a811 for whatever reason.

FWIW I just pushed this: https://github.com/herzenschein/herz-podman/tree/main/writefreely. That's a WIP showing how far I managed to go with a modified compose file. Hope it helps.

@herzenschein
Copy link

herzenschein commented Aug 1, 2023

The compose file I created and linked above is now functional, in addition to mentioning instructions and encountered errors.

A PR will only be coming later, because I did this in my spare time.

I saw several potential improvements that can be done to the upstream Dockerfile, but that will have to be taken care of later.

@thebaer
Copy link
Member

thebaer commented Oct 6, 2023

Hey, any updates on this as far as a PR? Would love to get this resolved for the next release.

@herzenschein
Copy link

herzenschein commented Oct 6, 2023

I just made writefreely/documentation#50 (which actually solves this issue) and #784 (which just provides a few QoL fixes), but I'd like to test it one last time to confirm that I set the SELinux flags right and that the generated network name is correct for Docker and Podman. I have to read the CLA too.

I'll be busy for a while, though, so if someone else can test it it would be helpful.

More importantly, I also noticed that the container documentation is actually not reachable through the main website, as https://writefreely.org/docs is broken, install only mentions the standard installation, and I couldn't find a pathway from the mainpage to the Docker page.

@KhaaL
Copy link

KhaaL commented Oct 27, 2023

@herzenschein still need someone to test your release? Ping me and I'll look into it in the coming week(s).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

No branches or pull requests

6 participants