ybizeul / hupload

Send and receive files from anyone. Integrate to your products. Minimalist.
GNU General Public License v3.0
46 stars 0 forks source link

Cannot Create Share #11

Closed dnburgess closed 3 months ago

dnburgess commented 3 months ago

Unable to create shares.

image

I've tried mapping a custom volume like:

I've tried docker volumes like (with the volume declared as well):

I've tried using your docker run script as it is. I've tried converting it to a docker-compose.

I've tried creating in command-line and in GUIs like Portainer.

Everything results in the same inability to create shares.

Also, I'm unable to docker exec into the container to modify the config or users

image

ybizeul commented 3 months ago

This error is returned when directory creation fails. I've added some logs, can you try the :main image instead of :latest ?

Regarding the container shell I usually consider a good practice to put as little as possible in the container image, but I recognize it's not great for troubleshooting that kind of things.

But for your specific case, if that's about editing configurations, as those should be stored in volumes, you should have some other way to edit (from host OS typically).

If you don't like the idea of mapping files, and rather map a directory, you can do so, and use CONFIG environment variable to point to config.yml.

For example, create a data/ and config/ directories on the host, and mount them on /data and /config respectively, then set CONFIG=/config/config.yml. In your config file, you would point auth > options > path to /config/users.yml.

Does that make sense ?

dnburgess commented 3 months ago

I tried manually creating the /config and /data folders:

image

I'm still unable to create shares.

The logs only give this error when I try to create a share:

time=2024-08-04T23:22:05.292Z level=ERROR source=routes.go:24 msg=putShare error="cannot create share"

walterzilla commented 3 months ago

Enabling data dir write permissions to others solves the issue, in fact seems that the image is configured to default to executing as nonroot user, am I wrong @ybizeul ?

root@test:/opt# ll data/
total 12K
drwxr-xrw- 3 root  root  4.0K Aug  5 07:03 ./
drwxr-xr-x 8 root  root  4.0K Aug  5 07:01 ../
drwxr-xr-x 2 65532 65532 4.0K Aug  5 07:11 yogu-fogi-hipu/
ybizeul commented 3 months ago

Ugh. I do remember something along those lines with the ko packager I use. That doesn’t explain why it’s working with my environment though, probably docker on the Mac is doing some abstraction sharing home directory.

It does work in a kubernetes environment though, mounting data for over nfs.

ybizeul commented 3 months ago

I did some research and it looks like standard practice to run containers as non root users. In this case, you would have to give the folder to user 65532 after creating the volume, would that make sense ?

I couldn't try it myself as docker for mac seems to be more permissive for some reason.

walterzilla commented 3 months ago

it looks like standard practice to run containers as non root users

In my experience not always, anyway not a docker-savvy here so I guess depends on purposes.

Your image is de facto configured to running as the specific nonroot user (≠ any other non root user) and morover I noticed is lacking shell access so it could be a so called distroless image: no problem with it, but maybe it worth to be specified in the readme 👍

ybizeul commented 3 months ago

You're totally right, and maybe I'll offer a root image alternative too

ybizeul commented 3 months ago

So I was able to reproduce on a linux docker environment.

chown 65532:65532 data does work and I updated the README

Can we consider this solved @dnburgess ?

dnburgess commented 3 months ago

Was able to verify that the chown command works.

In the readme, the chown command should be this: chown 65532:65532 data

I hope that this can be built into the container deployment in future releases.

I've run into a few other issues now that I'm able to create shares, but I'll open open those separately.

ybizeul commented 3 months ago

Thanks !