szabodanika / microbin

A secure, configurable file-sharing and URL shortening web app written in Rust.
https://microbin.eu
BSD 3-Clause "New" or "Revised" License
2.65k stars 163 forks source link

Add arg and/or environment variable to support changing the config and paste directory #46

Closed onedr0p closed 1 year ago

onedr0p commented 2 years ago

Hi 👋🏼

I am building a rootless Docker container for microbin and there doesn't seem to be a arg to set where the pastes or configuration is stored and appears to just be stored in the same dir as microbin binary.

https://github.com/szabodanika/microbin/blob/f55a5eba96209cf5d6b75dce3dfecd1f1effe3ca/src/main.rs#L66-L72

Logs in the Docker image I am building:

Couldn't create data directory ./pasta_data/public/: Os { code: 13, kind: PermissionDenied, message: "Permission denied" }

I would be great if you could add a arg called --config-dir and --paste-dir which would point to there the respected paths

e.g.

microbin --config-dir /config --paste-dir /data

onedr0p commented 1 year ago

@szabodanika Any update here? This makes microbin impossible to deploy via containers because you need to volume mount the data somewhere.

onedr0p commented 1 year ago

@szabodanika sorry to keep bothering you but this is a breaking container based deployments of your application.

szabodanika commented 1 year ago

Hi, I am kind of working on docker aspect these days as part of v2. With the current dockerfile and docker compose, you are able to set a volume or a mapping to any directory on your system. Would this solve your problem? I might be misunderstanding what the issue really is. Regardless, what you're asking is pretty simple to implement, I'll go ahead and do it anyways for v2.

onedr0p commented 1 year ago

Thanks for getting back to me, that would be excellent if you added that support

szabodanika commented 1 year ago

Let me know if you're having any trouble with getting the new arg to work the way you want!

onedr0p commented 1 year ago

Am I reading the changes correctly? Basically I want to set the path to the data to /config inside the container, looking over the changes that doesn't look possible still?

szabodanika commented 1 year ago

MicroBin does not have a config file other than the environment variables stored in .env. Am I misunderstanding something? Sorry, I am a bit confused now.

onedr0p commented 1 year ago

What about the database.json or microbin.conf, or where the pastes are stored?

See my issue description.

szabodanika commented 1 year ago

The database (.json or .sqlite, depending on your setup) and the file attachments will be stored in the directory you set with the new MICROBIN_DATA_DIR argument, and MicroBin will not touch any files outside of this directory.

I suggest also trying the setup script or the Docker compose that I provide, so you don't have to configure everything yourself. Please do let me know if even with the "official" Docker setup you're getting errors. Check here.

onedr0p commented 1 year ago

Thanks for this, I'll try to get it up and running tomorrow.

RemiWoler commented 10 months ago

Sorry for re-opening this, but it seems to be the best place to put it: this fix did not make it into the v2.0.4 docker image (which still has pasta_data/ hardcoded)