gabboman / wafrn

Wafrn is a federated social media inspired by tumblr. Join us and have fun
https://app.wafrn.net/dashboard/exploreLocal
107 stars 36 forks source link

Dockerize the backend #115

Open gabboman opened 3 weeks ago

gabboman commented 3 weeks ago

If you take a look to the install guide, besides being a bit outdated is hard to replicate. I need a way of easily serving the backend for people wanting to host their own wafrn.

Would be ok to add a initialize command that compiled the backend. I may need to add some changes so by default, the frontend always go for /api and stuff like that, but please let me know about this

CPlusPatch commented 3 weeks ago

I'll try to write a Dockerfile for it or something

CPlusPatch commented 3 weeks ago

Okay, so the issue is that the way Wafrn is configured is a bit annoying, because the installer script does a ton of work that should optimally be done by the user (editing the environment.ts file, setting up a reverse proxy and database, etc.)

So if you want a Docker build then users will have to also remember to set up a MySQL container (which is very easy) and Apache or their favorite reverse proxy (and certbot if they're using a Stone Age proxy)

Otherwise installation + running + healthcheck + running + updates can be done very easily with a Docker build.

gabboman commented 3 weeks ago

there is a docker-compose, it has a postgres thing i use for dev. if you can also use that container it would be neat @CPlusPatch

CPlusPatch commented 3 weeks ago

Oh totally, you'll be able to add the wafrn container to that docker-compose file fine.

CPlusPatch commented 3 weeks ago

Also, I'm not sure why you have to do that forceSync thing, but that will need to either be turned into a config option or outright removed (which would be better).

There are many ways to synchronize the database schema without losing any data

image

gabboman commented 3 weeks ago

Also, I'm not sure why you have to do that forceSync thing, but that will need to either be turned into a config option or outright removed (which would be better).

There are many ways to synchronize the database schema without losing any data

image

yeah probably there is a better way of doing this with sequelize but im not sure haha

CPlusPatch commented 3 weeks ago

Try looking for a feature called “migrations” in whatever ORM you use, that might solve the problem

gabboman commented 3 weeks ago

this basicaly is a "force first db creation" thing but yeah. I could create a script that is "setupDatabase" or something like that

CPlusPatch commented 3 weeks ago

Yeah it creates all the necessary tables and columns right?

gabboman commented 3 weeks ago

and the admin user (equivalent of instance actor lol) and deleted user

CPlusPatch commented 3 weeks ago

So you can fix this by setting forceSync to false and removing the instruction to set it to true (it will still create tables and columns if they don't exist).

Then, to create the relevant admin and deleted users, you can run a check on startup to see if they exist: if not, create them (this also acts as a brick protection I guess)

image

Relevant Sequelize docs -> https://sequelize.org/docs/v7/models/model-synchronization/

gabboman commented 3 weeks ago

@CPlusPatch I have improved the thing :D I hope this can help a bit

CPlusPatch commented 1 week ago

oh shit i forgot :trollface: