Skip to content

Commit abe4a57

Browse files
committed
Add doc around OAuth and direnv.
[skip ci]
1 parent be4abe1 commit abe4a57

File tree

3 files changed

+30
-10
lines changed

3 files changed

+30
-10
lines changed

.gitignore

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ __pycache__
77
.cache/*
88
**/.ipynb_checkpoints
99

10-
# Env variables
11-
.env
10+
# Env variables with direnv
11+
.envrc
1212

1313
# OS generated files
1414
.DS_Store*

CONTRIBUTING.md

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -178,10 +178,21 @@ A few helper commands are provided in the Makefile.
178178

179179
The dashboard can be run locally using:
180180

181-
make serve
181+
make serve-dev
182+
183+
If you want to test OAuth, you need to export the following env variables:
184+
185+
export PANEL_OAUTH_REDIRECT_URI=http://localhost:5006/app
186+
export PANEL_OAUTH_KEY=[VALUE IN GCP]
187+
export PANEL_OAUTH_SECRET=[VALUE IN GCP]
188+
189+
Use the CLI tool `direnv` for convenience. Then you can serve with
190+
OAuth support:
191+
192+
make serve-oauth
182193

183194
### Deployment
184195

185-
To deploy a new version:
196+
New version can either be deployed from the CI with `cloudbuild` or locally:
186197

187-
PANEL_TOKEN=... make production
198+
make production

Makefile

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,19 +27,23 @@ prepare: ## Install dependencies and pre-commit hook
2727
gcloud init
2828
gcloud auth configure-docker europe-north1-docker.pkg.dev
2929

30+
# Doc and tests
31+
3032
doc: ## Build Sphinx documentation
3133
sphinx-build -b html docs docs/html
3234

3335
test: ## Run tests with coverage
3436
pytest --cov simdec --cov-report term-missing
3537

38+
# Dashboard commands
39+
3640
serve-dev: ## Serve Panel dashboard - Dev mode
3741
panel serve panel/app.py \
3842
--show --autoreload \
3943
--static-dirs _static=docs/_static \
4044
--reuse-sessions --warm
4145

42-
serve: ## Serve Panel dashboard - Prod mode with basic auth
46+
serve: ## Serve Panel dashboard - Prod mode with basic auth. Needs: PANEL_TOKEN
4347
panel serve panel/app.py \
4448
--show \
4549
--cookie-secret panel_cookie_secret_oauth \
@@ -48,7 +52,7 @@ serve: ## Serve Panel dashboard - Prod mode with basic auth
4852
--static-dirs _static=docs/_static \
4953
--reuse-sessions --warm
5054

51-
serve-oauth: ## Serve Panel dashboard - Prod mode with OAuth2
55+
serve-oauth: ## Serve Panel dashboard - Prod mode with OAuth2. Needs: PANEL_OAUTH_REDIRECT_URI, PANEL_OAUTH_KEY, PANEL_OAUTH_SECRET
5256
panel serve panel/app.py \
5357
--show \
5458
--cookie-secret panel_cookie_secret_oauth \
@@ -57,22 +61,25 @@ serve-oauth: ## Serve Panel dashboard - Prod mode with OAuth2
5761
--static-dirs _static=docs/_static \
5862
--reuse-sessions --warm
5963

64+
# Deployment commands
65+
6066
build-local:
6167
docker build -f ./Dockerfile \
6268
--build-arg PANEL_TOKEN=$(PANEL_TOKEN) \
63-
--tag simdec-panel:$(version) \
69+
--tag simdec-panel-local:$(version) \
6470
--pull \
6571
./.
6672

6773
run-local: build-local
6874
docker run --rm -it \
69-
--name=simdec-panel \
75+
--name=simdec-panel-local \
7076
--memory=1g \
7177
--cpuset-cpus=0 \
7278
-e ENV=development \
7379
-p "8080:8080" \
74-
simdec-panel:$(version)
80+
simdec-panel-local:$(version)
7581

82+
# Need to specifically build on linux/amd64 to avoid issues on macOS M platform
7683
build:
7784
docker build -f ./Dockerfile \
7885
--platform linux/amd64 \
@@ -90,6 +97,8 @@ run: build
9097
-p "8080:8080" \
9198
simdec-panel:$(version)
9299

100+
# Ship
101+
93102
publish-production: build
94103
docker tag simdec-panel:$(version) $(region)-docker.pkg.dev/$(project)/simdec-panel/simdec-panel:$(version)
95104
docker push $(region)-docker.pkg.dev/$(project)/simdec-panel/simdec-panel:$(version)

0 commit comments

Comments
 (0)