Skip to content
This repository has been archived by the owner on Jun 28, 2024. It is now read-only.

alpine instructions #122

Closed
confor opened this issue Apr 5, 2020 · 6 comments
Closed

alpine instructions #122

confor opened this issue Apr 5, 2020 · 6 comments

Comments

@confor
Copy link

confor commented Apr 5, 2020

the instructions for getting the bot to run on alpine are really lacking. i can't edit the wiki so i figured i'd complain on an issue.

im successfully running the bot on a fresh alpine container. the following dependencies were installed:

python3 python3-dev opus opus-tools ffmpeg zlib-dev libjpeg tiff-dev make g++ libmagic

i installed Pillow separately (for no good reason)

these are the exact commands i used:

apk update
apk add python3 opus opus-tools ffmpeg zlib-dev
wget -O botamusique.tar.gz http://packages.azlux.fr/botamusique/sources.tar.gz
tar xzfv botamusique.tar.gz
cd botamusique/
python3 -m venv venv
source venv/bin/activate
apk add tiff-dev libjpeg make g++ gcc python3-dev
pip install Pillow
pip install wheel
pip install -r pymumble/requirements.txt
pip install -r requirements.txt
cp configuration.example.ini configuration.ini

additionally, i've created an openrc service:

vi /etc/init.d/botamusique
chmod 0755 /etc/init.d/botamusique

with the following content:

#!/sbin/openrc-run
command="/root/botamusique/venv/bin/python"
command_args="/root/botamusique/mumbleBot.py --config /root/botamusique/configuration.ini"
command_background="true"
pidfile="/run/${RC_SVCNAME}.pid"
output_log=/root/bot.stdout
error_log=/root/bot.stderr

i believe the last three lines are not needed. in fact, i encourage others to remove them.

warning: it runs as root.

@TerryGeng
Copy link
Collaborator

TerryGeng commented Apr 5, 2020

Hi, thank you for providing these information. I believe it would be helpful for people using alpine.

I will create a new wiki page and link it to here later.

However, out of curiosity, could you let me know that what error will occur if just following the instructions provided in README.md?

@Lartza
Copy link
Contributor

Lartza commented Apr 5, 2020

I was gonna complain about "running as root is fine" but seems you edited it out :P It's not fine even in a container really and should preferably be modified if included in the wiki.

Since I happened to look in the wiki doesn't the systemd script here run as root too? https://github.com/azlux/botamusique/wiki/Run-botamusique-as-a-daemon-In-the-background 🤔
(It could benefit from other systemd hardening too probably.)

@Lartza
Copy link
Contributor

Lartza commented Apr 5, 2020

@TerryGeng Mainly why they will fail is the required dependencies probably (for building some of the Python libraries like opuslib, and ffmpeg of course). But that's a given for any distro not just Alpine. Don't really see much other issue myself...

So it could in theory just be included in parts? OpenRC in daemon wiki page and have a wiki page for verified minimal package requirements for different distros.

@confor
Copy link
Author

confor commented Apr 6, 2020

sorry for the delay, i don't get any web or mail notifications from github.

regarding root, i guess it should use another user... but theres nothing else running in the container, so personally i don't care much.

i created a new container to show the errors if one follows the README.md instructions. its lxd with alpine 3.11. as @Lartza said, its because of missing dependencies, but not related to ffmpeg or opus, since those are already provided as binaries by the system's package manager and don't need to be compiled.

"Installation" section from README.md

the "Dependencies" section demands apk install python3 opus-tools ffmpeg, they install fine. the commands under "Stable release (recommended)" work fine (curl can be replaced by wget)

the main and only real issue with the installation process is the last pip line. the command fails horribly with about 1600 lines from Pillow.

this time i followed the instructions exactly as they appear on the readme, and documented/fixed errors as they appeared.

note: since i skipped the manual pip install Pillow from my first comment, it seems i installed a different version of Pillow and stumbled upon different errors.

dealing with Pillow

zlib and jpeg

Building wheel for Pillow (setup.py): finished with status 'error'
ERROR: Command errored out with exit status 1:
[...]
The headers or library files could not be found for zlib,
a required dependency when compiling Pillow from source.
[...]

fix: install zlib-dev jpeg-dev (seems to be tracked in Pillow #1763)

compiler

unable to execute 'gcc': No such file or directory
error: command 'gcc' failed with exit status 1

fix: install gcc

Python.h

src/_imagingmorph.c:14:10: fatal error: Python.h: No such file or directory
   14 | #include "Python.h"
      |          ^~~~~~~~~~
compilation terminated.
error: command 'gcc' failed with exit status 1

fix: install python3-dev

limits.h

/usr/include/python3.8/Python.h:11:10: fatal error: limits.h: No such file or directory
   11 | #include <limits.h>
      |          ^~~~~~~~~~
compilation terminated.
error: command 'gcc' failed with exit status 1

fix: install musl-lib (source)

running the bot

after installing the dependencies successfully, running the bot results in a crash:

# cp configuration.example.ini configuration.ini
# venv/bin/python mumbleBot.py
Traceback (most recent call last):
  [...]
ImportError: failed to find libmagic.  Check your installation

fix: install libmagic.

conclusion

on top of the obvious packages:

python3 ffmpeg opus-tools

a lot of undocumented packages are needed:

python3-dev musl-lib libmagic jpeg-dev zlib-dev gcc

@TerryGeng
Copy link
Collaborator

TerryGeng commented Apr 6, 2020

Thanks for explaining for us. I think your experience and solution is valuable, and I agree that @azlux and I can add your solution (python3-dev musl-lib libmagic jpeg-dev zlib-dev gcc) to the readme.

@TerryGeng
Copy link
Collaborator

Done. See the Known issues part in the readme. https://github.com/azlux/botamusique/blob/master/README.md

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants