gobengo / distbin

distributed social pastebin using Activitypub
https://distbin.com
Apache License 2.0
78 stars 8 forks source link

Prebuild docker image #14

Closed ivucica closed 5 years ago

ivucica commented 6 years ago

Hi,

there's a Dockerfile provided already. Would it make sense to build the project, and put the resulting image on Dockerhub or similar?

gobengo commented 5 years ago

Yeah, it makes sense.

I built and pushed to here. https://hub.docker.com/r/gobengo/distbin/

ivucica commented 5 years ago

Thank you for this. :)

For future readers, here's a hacky and insecure way to spin up distbin (mainly because of 777 on the database folder):

mkdir -p /tmp/distbin-db
chmod 777 /tmp/distbin-db # technically: user with UID 9001 needs to be able to write here
docker run -p 9999:80 -v /tmp/distbin:/distbin-db gobengo/distbin

See it on http://localhost:9999. Clearly, because database is in /tmp, this will go away on reboot.

For a more persistent setup, I think the correct way to go about it is to make use of environment variables mentioned in entrypoint.sh:

USER_NAME=distbin
PORT=9999
mkdir -p /var/lib/distbin
useradd --shell /bin/false -o -c "" -m ${USER_NAME} --system # passing --system so it gets a low UID
chown ${USER_NAME}:${USER_NAME} /var/lib/distbin
docker run -p ${PORT}:${PORT} \
    -e LOCAL_USER_ID=$(id -u ${USER_NAME}) \
    -e USER_NAME=${USER_NAME} \
    -e PORT=${PORT} \
    -v /var/lib/distbin:/distbin-db \
    gobengo/distbin

How does this look? :)