feat/sg: prototype 'sg start sourcegraph-accounts' (#63894)

Prototype what it might be like to have `sg` run `sourcegraph-accounts`.
I think this would be a huge improvement over the multi-step,
many-things-to-install process that currently exists for SAMS.

There are a couple of quirks, but I think I'll leave this here for now,
as this is part https://linear.app/sourcegraph/issue/CORE-220, a
timeboxed spike into polishing some local-dev DX for SAMS.

Also see https://github.com/sourcegraph/sourcegraph-accounts/pull/262

## Test plan

```
sg start sourcegraph-accounts
```

Go to 127.0.0.1:9991 and try to log in
This commit is contained in:
Robert Lin 2024-07-19 13:30:08 -07:00 committed by GitHub
parent 924c5d263c
commit f53e211804
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -37,7 +37,6 @@ env:
REPO_UPDATER_URL: http://127.0.0.1:3182
REDIS_ENDPOINT: 127.0.0.1:6379
SYMBOLS_URL: http://localhost:3184
EMBEDDINGS_URL: http://localhost:9991
SRC_SYNTECT_SERVER: http://localhost:9238
SRC_FRONTEND_INTERNAL: localhost:3090
GRAFANA_SERVER_URL: http://localhost:3370
@ -1123,6 +1122,122 @@ commands:
- lib
- schema
sourcegraph-accounts-server:
description: |
Run SAMS from a clone of https://github.com/sourcegraph/sourcegraph-accounts
expected to be configured in '../sourcegraph-accounts'
install: |
if [ -d "../sourcegraph-accounts" ]; then
echo "../sourcegraph-accounts must be a clone of https://github.com/sourcegraph/sourcegraph-accounts"
fi
cd ../sourcegraph-accounts
createdb -h $PGHOST -p $PGPORT -U $PGUSER --encoding=UTF8 --template=template0 accounts || true
asdf install
go build -v -o ./.bin/accounts-server ./cmd/accounts-server
checkBinary: ../sourcegraph-accounts/.bin/accounts-server
cmd: |
export PGDSN="postgres://$PGUSER:$PGPASSWORD@$PGHOST:$PGPORT/{{ .Database }}?sslmode=$PGSSLMODE"
cd ../sourcegraph-accounts
./.bin/accounts-server
watch:
- ../sourcegraph-accounts/go.mod
- ../sourcegraph-accounts/cmd/accounts-server
- ../sourcegraph-accounts/backend
- ../sourcegraph-accounts/internal
externalSecrets:
GITHUB_CLIENT_ID:
project: sourcegraph-local-dev
name: SAMS_LOCAL_DEV_GITHUB_CLIENT_ID
GITHUB_CLIENT_SECRET:
project: sourcegraph-local-dev
name: SAMS_LOCAL_DEV_GITHUB_CLIENT_SECRET
GITLAB_CLIENT_ID:
project: sourcegraph-local-dev
name: SAMS_LOCAL_DEV_GITLAB_CLIENT_ID
GITLAB_CLIENT_SECRET:
project: sourcegraph-local-dev
name: SAMS_LOCAL_DEV_GITLAB_CLIENT_SECRET
GOOGLE_CLIENT_ID:
project: sourcegraph-local-dev
name: SAMS_LOCAL_DEV_GOOGLE_CLIENT_ID
GOOGLE_CLIENT_SECRET:
project: sourcegraph-local-dev
name: SAMS_LOCAL_DEV_GOOGLE_CLIENT_SECRET
env:
OTEL_SDK_DISABLED: true
# TODO: Port conflicts with embeddings, but all our pre-made credentials
# use this port as the redirect URL, so we just stick to it for now.
PORT: 9991
REDIS_HOST: localhost
REDIS_PORT: 6379
REDIS_ENDPOINT: 'redis://@127.0.0.1:6379' # Use
MANAGEMENT_SECRET: sekret # For authentication when using admin APIs to register new SAMS clients.
GITHUB_REDIRECT_URI: "http://localhost:$PORT/auth/github/callback"
GITLAB_REDIRECT_URI: http://localhost:$PORT/auth/gitlab/callback
GOOGLE_REDIRECT_URI: http://localhost:$PORT/auth/google/callback
IDENTITY_PROVIDER_INSECURE_DEBUG: true
IDENTITY_PROVIDER_OIDC_GLOBAL_SECRET: "some-cool-secret-that-is-32bytes"
# $ ssh-keygen -t rsa -m PEM -b 2048 -f temp.pem
IDENTITY_PROVIDER_OIDC_JWK_PRIVATE_KEY: |
-----BEGIN RSA PRIVATE KEY-----
MIIG4wIBAAKCAYEAw+3FnONYJcxkA539MhwawknBDOqgzM/QoiLNA6OD46uizJXn
Eyku2nVBtbUdjG3g6QwuYL0e8QKgTUOhIHlj8iOhad/A3p9dbY5RRoxLznezipaI
tcqLzjU+JVioLPro1Jl5nqeL5bjNf+/5LLKEbzyOkapSxqUK7IQ7j4OI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Kkr+ccnxrgDYcfNjKmcXu5lBJGruSom7Uw
-----END RSA PRIVATE KEY-----
sourcegraph-accounts-web:
description: |
Run SAMS from a clone of https://github.com/sourcegraph/sourcegraph-accounts
expected to be configured in '../sourcegraph-accounts'
install: |
if [ -d "../sourcegraph-accounts" ]; then
echo "../sourcegraph-accounts must be a clone of https://github.com/sourcegraph/sourcegraph-accounts"
fi
cd ../sourcegraph-accounts
asdf install
pnpm install
cmd: |
cd ../sourcegraph-accounts/web
pnpm run dev
watch:
- ../sourcegraph-accounts/pnpm-lock.yaml
bazelCommands:
blobstore:
target: //cmd/blobstore
@ -1886,6 +2001,15 @@ commandsets:
bazelCommands:
- cody-gateway
sourcegraph-accounts:
checks:
- redis
- postgres
- git
commands:
- sourcegraph-accounts-server
- sourcegraph-accounts-web
tests:
# These can be run with `sg test [name]`
backend: