modmail-dev / Modmail

A Discord bot that functions as a shared inbox between staff and members, similar to Reddit's Modmail.
https://docs.modmail.dev
GNU Affero General Public License v3.0
1.58k stars 4.59k forks source link

[BUG]: Unable to create folder in docker container #3319

Closed tim-schneider closed 5 months ago

tim-schneider commented 10 months ago

Bot Version

v4.1.0

How are you hosting Modmail?

Other

Error Logs

https://www.toptal.com/developers/hastebin

Screenshots

PermissionError: [Errno 13] Permission denied: '/modmailbot/temp' Traceback (most recent call last): File "/modmailbot/bot.py", line 57, in <module> os.mkdir(temp_dir) PermissionError: [Errno 13] Permission denied: '/modmailbot/temp'

Additional Information

With v4.1.0 somehow my docker container has issues letting the Python script creating the temp folder within the modmailbot folder. I did modify the Python image to reflect my OS. And solved the issue with:

@@ -1,4 +1,4 @@
-FROM python:3.10 as py
+FROM arm64v8/python:3.11 as py

 FROM py as build

@@ -13,6 +13,8 @@ COPY --from=build /inst /usr/local

 ENV USING_DOCKER yes
 RUN useradd --system --no-create-home modmail
+RUN mkdir -p /modmailbot/temp
+RUN chown -R modmail:modmail /modmailbot
 USER modmail

 WORKDIR /modmailbot
martinbndr commented 10 months ago

For me the logs are empty, can you try getting a new link? Screenshot_20231128_115532_Chrome

khakers commented 10 months ago

BTW, if you just want to have a docker image for arm, you don't need to change the dockerfile, the current one (in the past, at least) builds on arm with no changes. You can even build directly from the git link without downloading anything.

tim-schneider commented 10 months ago

BTW, if you just want to have a docker image for arm, you don't need to change the dockerfile, the current one (in the past, at least) builds on arm with no changes. You can even build directly from the git link without downloading anything.

I assume you referencing the ghcr image. I just rented a plain hetzner arm64/v8:

root@debian-4gb-hel1-2:~# docker run -it ghcr.io/modmail-dev/modmail:master
WARNING: The requested image's platform (linux/amd64) does not match the detected host platform (linux/arm64/v8) and no specific platform was requested
docker: Error response from daemon: AppArmor enabled on system but the docker-default profile could not be loaded: running `apparmor_parser apparmor_parser --version` failed with output:
error: exec: "apparmor_parser": executable file not found in $PATH.
ERRO[0000] error waiting for container: context canceled
tim-schneider commented 10 months ago

For me the logs are empty, can you try getting a new link?

Sorry, there aren't any other logs than what I have provided. Sadly it form did force me to put in a link.

PermissionError: [Errno 13] Permission denied: '/modmailbot/temp' Traceback (most recent call last): File "/modmailbot/bot.py", line 57, in <module> os.mkdir(temp_dir) PermissionError: [Errno 13] Permission denied: '/modmailbot/temp'
khakers commented 10 months ago

No as I said, you just need to build the image on your machine. The python:3.10 image is a multiplatform one with support for linux/arm64/v8. You do not need to modify the dockerfile in any way to get an arm64/v8 build.

Alternatively, modmail could supply a multiplatform image with arm support so this whole song and dance doesn't have to be done.

Taaku18 commented 5 months ago

The project's Dockerfile has been updated to fix the issue.