mirror of
https://github.com/plankanban/planka.git
synced 2026-02-24 19:08:59 +03:00
[PR #886] [MERGED] Configurable file storage locations #1135
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/plankanban/planka/pull/886
Author: @mtstickney
Created: 9/20/2024
Status: ✅ Merged
Merged: 9/20/2024
Merged by: @meltyshev
Base:
master← Head:configurable_file_locations📝 Commits (2)
94a8011feat: Make logfile location customizable13f0a68feat: Support alternate storage locations for uploaded files📊 Changes
11 files changed (+151 additions, -43 deletions)
View changed files
📝
server/.env.sample(+2 -0)📝
server/api/controllers/attachments/create.js(+1 -11)📝
server/api/controllers/boards/create.js(+1 -11)📝
server/api/controllers/projects/update-background-image.js(+1 -10)📝
server/api/controllers/users/update-avatar.js(+1 -10)➕
server/api/helpers/utils/receive-file.js(+41 -0)📝
server/config/custom.js(+3 -0)📝
server/config/routes.js(+65 -0)📝
server/package-lock.json(+33 -0)📝
server/package.json(+1 -0)📝
server/utils/logger.js(+2 -1)📄 Description
I wanted to package planka for deployment as a regular system service on linux (not in a container). Packaging standards and the filesystem conventions on linux require static code, configuration, and writable data directories to be separated.
Specifically, the directories for user-uploaded files (project backgrounds, user avatars), card attachments, and the server logfile need to be outside the main directory.
There are already custom-config properties to set the location of the upload directories, but they are served with the default static-file route in Sails, which means they can only be in subdirectories of the
public/directory (this contains the app code, so in a normal deploy this directory isn't going to be writable).To fix that, I've added two custom routes that will serve project backgrounds and user avatars from the configured directories (card attachments are already handled by a separate controller), which can now reside outside the app dir.
To make the file-upload directory configurable, I added a helper to receive files, which uses an optional custom config property to control that directory -- this gets us a configurable location for all uploaded files, including backgrounds, avatars, attachments and import files.
Finally, I added an environment variable to control the location the server tries to write logs (this doesn't seem to actually get used, but it will still try to create the file).
With those things in place, and with the right overrides of them, the app can be run from a write-only directory, with all the file-writing done elsewhere, as it would in a normal linux deployment. Without customizing any of the custom properties, the behavior should be the same as it was previously, so running it from a checkout in dev or in a container shouldn't be affected.
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.