Skip to content
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

(self-host|3): self-hostable platform! #982

Merged
merged 41 commits into from
Feb 27, 2025
Merged

(self-host|3): self-hostable platform! #982

merged 41 commits into from
Feb 27, 2025

Conversation

tefkah
Copy link
Member

@tefkah tefkah commented Feb 19, 2025

Issue(s) Resolved

Resolves #954

High-level Explanation of PR

Adds proper self-hosting support!

  1. Adds preconfigured docker-compose.yml in self-host
  2. Adds sort of extensive instructions on how to get setup
  3. Adds a script for generating an admin user (kind of finicky right now, requires a special mount until this PR is merged in)
  4. Adds default Caddy config so users can reverse proxy the app/files easily

Test Plan

Basic

Try to follow the instruction in self-host/README.md and get the app running at least.

Caddy config

Once you have the app up and running, try to get Caddy to serve the app and files over https locally.

All in self-host

  1. Copy the local test file
cp Caddyfile Caddyfile_bak
cp Caddyfile.test Caddyfile
  1. Uncomment all this

    # caddy:
    # image: caddy:latest
    # depends_on:
    # - platform
    # - platform-jobs
    # - minio
    # env_file:
    # - path: .env
    # required: true
    # ports:
    # - "443:443"
    # volumes:
    # - ./caddy:/etc/caddy
    # - caddy-data:/data
    # - caddy-config:/config
    # networks:
    # - app-network

  2. Configure local certificates

brew install mkcert
mkcert -install
  1. Add 127.0.0.1 example.com to your hosts (check whether it's not already there first)
sudo echo "127.0.0.1 example.com >> /etc/hosts"

(or just edit it like a normal person)

  1. Restart the containers
docker compose down
docker compose up -d
  1. Go to https://example.com in your browser

  2. Click away warnings blahblah

  3. Should be greeted by PubPub!

  4. Try to upload some files! They should be uploaded to example.com/assets/<bucket>/<etc..>

Screenshots (if applicable)

Notes

Desired feedback

My main concerns are about how easy this is to follow for a slightly technical person. The documentation can and should be leagues better, but is it good enough that someone slightly familiar with a docker-compose.yml could figure it out?

Also, what do you think of the default inclusion of Caddy? I think it's miles nicer than nginx, and it would be nice to provide a built in solution for exposing your files on the same domain as your main one (annoying to have to set up multiple sometimes), but I did not really do a good job yet explaining how it works in the docs, and it does make things slightly more complex. On the other hand, you will need to set up SSL certificates anyway, so it's good we offer (albeit maybe slightly clunky) a way to do it.

What is missing

  • Backups! Extremely important, we can't really call ourselves self-host ready if that's not a thing
  • Guides on how to set up hosting/domains etc
  • Guides on how to set up communities/default communities you can use. Currently it's very clunky.
  • Better migration strat

@tefkah tefkah changed the base branch from main to tfk/minio February 19, 2025 13:36
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i'm bad at writing bash scripts. it would be nice if just had a cli for these things

Comment on lines +43 to +59
platform-migrations:
platform: linux/amd64
depends_on:
db:
condition: service_started
image: ghcr.io/pubpub/platform-migrations:latest
env_file:
- path: .env
required: true
environment:
DATABASE_URL: postgresql://${POSTGRES_USER}:${POSTGRES_PASSWORD}@${POSTGRES_HOST}:${POSTGRES_PORT}/${POSTGRES_DB}
# FIXME: remove this once it's merged into main
volumes:
- ../core/prisma/create-admin-user.cts:/usr/src/app/core/prisma/create-admin-user.cts
command: ["pnpm", "--filter", "core", "migrate-docker"]
networks:
- app-network
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is used to, well, run the migrations when the app starts up. It's also used to generate the admin user.
I think we can probably get rid of this and put the important parts in platform instead, but for now I'm not sure what the best way of doing this would be.

Comment on lines +54 to +56
# FIXME: remove this once it's merged into main
volumes:
- ../core/prisma/create-admin-user.cts:/usr/src/app/core/prisma/create-admin-user.cts
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this should be removed before merging, it's just here for testing.

reason: the core/prisma/create-admin-user.cts does not exist yet on platform-migrations:latest, because i just now added it 😅
once this pr is merged to main all will be swell

Base automatically changed from tfk/minio to main February 20, 2025 09:54
@tefkah
Copy link
Member Author

tefkah commented Feb 25, 2025

Some feedback from @eastofesten: apparently the POSTGRES_USER needs to be POSTGRES in order for the migration script to work. will investigate

@eastofesten
Copy link
Contributor

also noting that step 4 for the caddy instructions didn't work (didn't say permission denied.) used sudo -- sh -c "echo 127.0.0.1 example.com >> /etc/hosts" instead to make it work.

Copy link
Member

@3mcd 3mcd left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for running through the steps with me!

@tefkah tefkah merged commit 61a0012 into main Feb 27, 2025
6 checks passed
@tefkah tefkah deleted the tfk/self-host-setup branch February 27, 2025 18:53
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.

Add minio and basic self-hosting guidance
3 participants