-
-
Notifications
You must be signed in to change notification settings - Fork 191
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
🚀 Feature: Configurable ports and database through env #144
Comments
Good point. This shouldn't be much work but currently my laptop is in repair so it could take some time until I can implement this. When you're finished I would love if you add the NixOS installation instructions to the README :) |
I'm currently working on this. I think we don't need |
Do you start the frontend with |
Not strictly necessary, but I think it’s worth having the option, say you want to sandbox each service into its own network namespace. It’s a bit of a niche use-case, but it’s definitely something I’ve done in the past. |
I ship it without npm and start nodejs directly. I'm trying to deploy a minimal package, so shipping a package manager seemed unnecessary. |
Can't verify right now but I think the fronted server already supports the 'PORT' env var. |
Yes the frontend supports the
Is this correct? |
Yeah I think that's fine. Personally I don't mind the env var name clash as I run them in systemd where I can configure env vars per service. But I imagine it's useful in cases where you don't have that sort of isolation. |
Added in e5071cb. Let me know if this fits your needs :) Backend
Frontend
|
@stonith404 Thank you! Though I just tried the new version and it seems like the database path is still hardcoded in |
@szlend Oh yeah, I've forgot that and that's actually I problem. Currently I'm not sure how to solve this. I really don't have a knowledge about creating packages for Linux but do you think it matters where the database file is stored? If yes, we would have to create an env variable for the path where the uploaded files are stored, or I'm wrong? Because the database file is stored inside the same folder as the uploads. |
Actually, I think it could be worked around by placing an
From what I remember, the database file is placed relative to the prisma schema directory. At least when running migrations using the prisma client. If you package the app into a non-writable system path, that's a problem yeah.
The uploads folder is actually relative to the working directory which is really easy to change. You just execute the server from whatever path you want as the root, by |
Great idea! Creating a |
That's great! Yeah it's kinda janky but I think it's worth the cost. What do you think about also making the upload dir configurable? Currently I symlink it to another drive, but it would be nice if I could just configure it as well. |
I've just fixed the prisma issue and added an env variable that allows to specify the data directory. It isn't merged yet because it would be nice if you could check it out first if this works for you. The newest changes are in the Here are the added env variables again:
Frontend
|
Awesome, I tested the latest changes and everything seems to be working fine! Gonna try and package this for nix when I get the chance. Edit: Actually, let me check one more thing. It started successfully but the frontend is not responding. |
This part doesn't work for me:
Shouldn't this just resolve to |
That's strange I can't reproduce this. The problem is we can't use the const config = await (
await fetch(`${request.nextUrl.origin}/api/configs`)
).json(); with console.log(request.nextUrl);
let config: any;
try {
// Get config from backend
config = await (
await fetch(`${request.nextUrl.origin}/api/configs`)
).json();
} catch (e) {
console.log(e);
} so we can get a better error message? |
Two issues:
Nit:
|
I fixed the casting. Additionally I've debugged the error a bit and I found out that it it takes the runtime env variables with Sure it would be nice if the hoster can setup a reverse proxy by his own but it gets really complicated if I want to support the Docker version too. I think for the most of the users it's fine to use the current implemented reverse proxy. Do you think this is enough for the moment? |
I would prefer avoiding packaging unnecessary dependencies. But yeah, I can debug this myself.
Yeah, no worries. Thanks! |
Okay :) Let me know if you need anything |
Added in |
🔖 Feature description
The ports and database url could be configurable through environmental variables. I think at minimum you would want:
Frontend:
PORT=3000
API_URL=http://localhost:8080
Backend:
PORT=8080
DATABASE_URL=file:../data/pingvin-share.db?connection_limit=1
Right now to make this packagable for NixOS I need to apply the following patches:
Backend:
Frontend:
🎤 Pitch
Installing pingivin-share on a shared system (outside of containers, e.g. NixOS) is currently difficult because the ports are hardcoded and can easily clash with other applications. The database is also hardcoded to a path relative to prisma, which makes it impossible to ship the application into a non-writable prefix (e.g.
/nix/store
or/usr
).The text was updated successfully, but these errors were encountered: