Skip to content

Conversation

@Ryszard-Trojnacki
Copy link

This pull request adds new configuration variables that allow to set up embedded in code settings, adds missing service for file retrieval from Object Storage (S3).

Introduced variables:

  1. Production database settings: DATABASE_HOST, DATABASE, DATABASE_USER, DATABASE_PASSWORD, DATABASE_PORT same as other settings (DEV_DATABASE).
    This was done to make all modes equivalent. Old mode (DATABASE_URL) is supported.
  2. Custom ObjectStorage: S3_ENDPOINT, S3_PRIVATE_BUCKET_NAME, S3_PUBLIC_BUCKET_NAME, S3_ENDPOINT, S3_REGION, S3_ACCESS_KEY_ID, S3_SECRET_ACCESS_KEY, S3_FORCE_PATH_STYLE, S3_ENDPOINT_BUCKET.
    Till now all settings to S3 storage was embedded in code. Those variables allow to configure S3 storage. If they are not set, then old behavior is used.
  3. Configurable public URL: HOME_PUBLIC_URL.
    This allows to run LiteFarm on any domain not only embbed beta.litefarm.org and app.litefarm.org. If not provided then old behavior is used.
  4. Configurable API URL: API_PUBLIC_URL.
    Same as with HOME_PUBLIC_URL.
  5. Configurable email transport: EMAIL_TRANSPORT_USER, EMAIL_TRANSPORT_PASSWORD, EMAIL_TRANSPORT_HOST, EMAIL_TRANSPORT_PORT, EMAIL_TRANSPORT_SECURE, EMAIL_TRANSPORT_SERVICE).
    Till now all transport settings have been hardcoded. This introduces ability to change it to custom values.
  6. Configurable email addresses: EMAIL_SENDER.
    This allows to send e-mail from diffrent from address that hardcoded [email protected].
  7. Configurable URL of file service: VITE_S3_SERVICE (webapp module).
    Till now all requests for files where changed to images.litefarm.workers.dev. Now this is configurable.

New fileservice module. I have added missing fileservice module that check JWT token and if it is correct and farm_id is also correct then it returns requested file from Object Storage (S3). With the VITE_S3_SERVICE webapp parameter this allow to own S3 storage.

All changes are backwards compatible. If introduced variable is missing/not set, then old variable or hardcoded value is used.

With this pull requests there are also 2 fixes:

  • invalid path name to start in production in /packages/api/package.json: "start:prod": "node dist/api/src/server.js",
  • use of existing PORT variable for development mode.

Next step is to change current beta.litefarm.org and app.litefarm.org servers to use introduced variables and then remove the old code with hardcoded values, but this is out of scope of this pull request.

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

I have prepared example .env.self-hosting file with usage and description of new variables dedicated for self hosting scenario.

How Has This Been Tested?

Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list any relevant details for your test configuration

  • Passes test case
  • UI components visually reviewed on desktop view
  • UI components visually reviewed on mobile view
  • Other (please explain)

I have setup my own production installation of LiteFarm on my computer and on a public server.

Checklist:

  • I have commented my code, particularly in hard-to-understand areas
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • The precommit and linting ran successfully
  • I have added or updated language tags for text that's part of the UI
  • I have added "MISSING" for all new language tags to languages I don't speak
  • I have added the GNU General Public License to all new files

This change does not affect UI or language files.

@Ryszard-Trojnacki Ryszard-Trojnacki requested review from a team as code owners April 3, 2025 13:35
@Ryszard-Trojnacki Ryszard-Trojnacki requested review from Duncan-Brain and antsgar and removed request for a team April 3, 2025 13:35
@Duncan-Brain
Copy link
Collaborator

Hi @Ryszard-Trojnacki Thanks for making this PR, it looks pretty useful, I know we have had people wondering how to do this in the past and so that might be helpful.

I am not quite sure when we would be able to prioritize testing it, just as an FYI.

But basically on first look my main comment would be about adding a dropdown section in the README.md to describe the steps on how to self host. I think that will also help speed along any potential reviews here.

This looks pretty helpful though thank you for your efforts here!

@Ryszard-Trojnacki
Copy link
Author

In the next week I will install LiteFarm on target, fresh server for our project. It will be the third installation.
While installing I will check my notes and write a section in README.md.

@Ryszard-Trojnacki
Copy link
Author

@Duncan-Brain I have added README.md section with requested instructions.

@antsgar antsgar requested review from a team and SayakaOno and removed request for a team and antsgar April 16, 2025 14:42
@Ryszard-Trojnacki Ryszard-Trojnacki force-pushed the feature/ILOT-46-self-hosting branch from 2220e59 to 05b4fe6 Compare September 16, 2025 12:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants