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

docs: update contributors guide #285

Merged
merged 9 commits into from
Dec 18, 2021
Merged

Conversation

kangmingtay
Copy link
Member

What kind of change does this PR introduce?

  • Improve the gotrue documentation

@kangmingtay
Copy link
Member Author

@HarryET & @riderx i've started a PR for improving the documentation for contributors. Since you guys have been helping out so much recently, i thought it would be good to get your opinions on what can be improved / what's lacking in the docs currently :)

@dthyresson
Copy link

Thanks @kangmingtay I had some mods, too which I can add to this branch or suggest here:

  1. In The Setup section

To install soda: 

go install github.com/gobuffalo/pop/soda@latest

...
> Important. If you happen to already have a local running instance of Postgres running on the port `5432`, perhaps if you have installed via [homebrew on OSX](https://formulae.brew.sh/formula/postgresql) then be certain to stop the process using:
>
> - `brew services stop postgresql`
>
> If you need to run the test environment on another port, you will need to modify several configuration files to use the custom port. See below [Customize Test Environment Postgres Port](#Customize_Test_Environment_Postgres_Port])

Few tips in:

## Running database migrations for supabase

- Create a `.env` file to store the custom gotrue environment variables. You can refer to an example of the `.env` file [here](hack/test.env)
- Start PostgreSQL inside a docker container running `hack/postgresd.sh`
- In your Docker dashboard, you should see `gotrue_postgresql` running on port 5432
- Build the gotrue binary `make build`
- Execute the binary `./gotrue`
  - gotrue runs any database migrations from `/migrations` on start

and then the section about if one has Postgres already running:

### Customize Test Environment Postgres Port

If you want to run your test environment Postgres on a port other than the standard 5432, you will need to update the following configuration and settings files:

///file: postgresd.sh
docker run --name gotrue_postgresql
-p 7432:5432 \ 👈 set the first value to your external facing port


The port you customize here can them be used in the subsequent configuration:

// file: database.yaml
test:
dialect: "postgres"
database: "postgres"
host: {{ envOr "POSTGRES_HOST" "127.0.0.1" }}
port: {{ envOr "POSTGRES_PORT" "7432" }} 👈 set to your port


// file: test.env
DATABASE_URL="postgres://supabase_auth_admin:root@localhost:7432/postgres" 👈 set to your port


//file: migrate.sh
export GOTRUE_DB_DATABASE_URL="postgres://supabase_auth_admin:root@localhost:5432/$DB_ENV"

Also, there are a few install and helpful commands you shared with me during installation:

brew install go@1.16 install Go

That make build will build 2 binaries:

$ make build                                                                                
go build -ldflags "-X github.com/supabase/gotrue/cmd.Version=`git rev-parse HEAD`"
GOOS=linux GOARCH=arm64 go build -ldflags "-X github.com/supabase/gotrue/cmd.Version=`git rev-parse HEAD`" -o gotrue-arm64

We set real GOTRUE_SMTP_HOST settings.

If people do not have access to that, what do they use?

docker exec -it gotrue_postgresql bash gets you into bash on the PostgreSQL container

docker container rm -f gotrue_postgresql removes
docker volume rm postgres_data removes volume

Copy link

@dthyresson dthyresson left a comment

Choose a reason for hiding this comment

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

I added some notes that I had been keeping in my Contribute and Readme that helped my install.

Le me know if you want me to work them into your PR and happy to.

@HarryET
Copy link
Contributor

HarryET commented Nov 22, 2021

A point on that @dthyresson, Make sure not to suggest brew as an install method as it doesn't work on M1 MacBooks/Macs and that would fix #280

@chimon2000
Copy link

@kangmingtay Should this PR include the guidelines for splitting work into PRs by feature or by individual bug fixes?

Mentioned here: #269 (comment)

@dthyresson dthyresson self-assigned this Dec 1, 2021
Copy link
Contributor

@riderx riderx left a comment

Choose a reason for hiding this comment

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

Thanks @kangmingtay for the improvement, i will try to play the install again to report better issue around install process

CONTRIBUTING.md Outdated Show resolved Hide resolved
CONTRIBUTING.md Outdated
* `go install github.com/gobuffalo/pop/soda@latest`
* Clone this repo: `git clone https://github.com/supabase/gotrue`
* `cd gotrue`
* To start the gotrue postgresql container running locally: `./hack/postgresd.sh`
Copy link
Contributor

Choose a reason for hiding this comment

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

./hack/postgresd.sh didn't work when we tried there error in the script from dbname I think @HarryET you remember ?

Copy link
Member Author

Choose a reason for hiding this comment

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

hey @riderx, sorry for the late reply, thanks for pointing this out, are you able to recall the error message you encountered? 🤔

CONTRIBUTING.md Outdated
- Execute the binary `./gotrue`
- gotrue runs any database migrations from `/migrations` on start
- Start PostgreSQL inside a docker container running `./hack/postgresd.sh`
- Run `make migrate_test`
Copy link
Contributor

Choose a reason for hiding this comment

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

Same in migration we need to check the script work from 0

Copy link
Member Author

Choose a reason for hiding this comment

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

could you elaborate by what you mean by "work from 0" ?

@dthyresson dthyresson self-requested a review December 15, 2021 16:20
@awalias awalias self-requested a review December 16, 2021 04:11
Copy link
Member

@awalias awalias left a comment

Choose a reason for hiding this comment

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

a huge improvement, thanks both!

CONTRIBUTING.md Outdated Show resolved Hide resolved
@kangmingtay kangmingtay force-pushed the docs/improve-contribution-guide branch from fb5ef9d to d9a6ede Compare December 17, 2021 07:05
Copy link

@dthyresson dthyresson left a comment

Choose a reason for hiding this comment

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

Approved.

@kangmingtay kangmingtay merged commit bae858d into master Dec 18, 2021
@kangmingtay kangmingtay deleted the docs/improve-contribution-guide branch December 18, 2021 01:32
@github-actions
Copy link
Contributor

🎉 This PR is included in version 2.2.14 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants