valentine / docker-sopel

A Docker image for sopel, a simple, lightweight, open source, easy-to-use IRC Utility bot, written in Python.
MIT License
0 stars 1 forks source link

Unable to start without a pre-existing config #2

Open oskapt opened 8 years ago

oskapt commented 8 years ago

I'm guessing that you built this because you were already running Sopel/Willie somewhere else and brought your config with you. In a default configuration it's not possible to start the container and generate a config. It loops with this:

wickerman    | Welcome to Sopel!
wickerman    | I can't seem to find the configuration file, so let's generate it!
wickerman    | There was a problem creating /.sopel:
wickerman    | <type 'exceptions.OSError'>, [Errno 13] Permission denied: '/.sopel'
wickerman    | Please fix this and then run Sopel again.

I'm not sure why it's ignoring your directive to start it with the config in /sobel/default.cfg, but it is.

The easy answer is to start it first in the foreground and complete the configuration wizard, and then restart it. This is not possible because you're using ENTRYPOINT instead of CMD. It's not possible to override the initialization of the container, dropping us into a Catch-22.

Expect a PR soon that resolves this.

oskapt commented 8 years ago

Yeah...so this isn't going to happen.

s6 starts no matter what, so even after changing ENTRYPOINT to CMD there is a loop of errors every second:

Welcome to Sopel!
I can't seem to find the configuration file, so let's generate it!

Please answer the following questions to create your configuration file:

Encountered an error while writing the config file. This shouldn't happen. Check permissions.
Traceback (most recent call last):
  File "/usr/bin/sopel", line 9, in <module>
    load_entry_point('sopel==6.3.1', 'console_scripts', 'sopel')()
  File "/usr/lib/python2.7/site-packages/sopel/run_script.py", line 132, in main
    _create_config(configpath)
  File "/usr/lib/python2.7/site-packages/sopel/config/__init__.py", line 252, in _create_config
    config = Config(configpath, validate=False)
  File "/usr/lib/python2.7/site-packages/sopel/config/__init__.py", line 64, in __init__
    validate=validate)
  File "/usr/lib/python2.7/site-packages/sopel/config/__init__.py", line 120, in define_section
    setattr(self, name, cls_(self, name, validate=validate))
  File "/usr/lib/python2.7/site-packages/sopel/config/types.py", line 63, in __init__
    e.message)
ValueError: Invalid value for core.logdir: Value must be an existing or creatable directory.

So we stop that with s6-svc -d /var/run/s6/services/sopel to stop the screen vomit. After that, it's not possible to generate a config manually. Sopel refuses to run as root, so we have to run it as the nobody user:

/ # s6-setuidgid nobody sopel -w
Creating a config directory at ~/.sopel...
There was a problem creating /root/.sopel:
<type 'exceptions.OSError'>, [Errno 13] Permission denied: '/root/.sopel'
Please fix this and then run Sopel again.
/ # chmod 777 /root
/ # s6-setuidgid nobody sopel -w
Creating a config directory at ~/.sopel...
There was a problem creating /root/.sopel:
<type 'exceptions.OSError'>, [Errno 13] Permission denied: '/root/.sopel'
Please fix this and then run Sopel again.

This happens even if /root and /root/.sopel are mode 0777.

So we have two issues:

It's not worth me digging further into it, and even if I do, the issues aren't with your container anymore (at least, not directly. Your container still doesn't start without a config).

My suggestion is that you give the user a default starting configuration that they can drop into their mount directory to at least get them going. They can change the options manually and restart the container.

Regarding using CMD I would suggest that you not call /init again, since that's already running. Instead, tail the sopel log, if there is one, or monitor the sopel process and exit if s6 exits or starts spewing errors.

I've spent 2h on this, which is more than I am willing to dedicate to making it work. I'll just go run hubot instead.