{"id":18258905,"url":"https://github.com/pottava/streamlit-with-firebase","last_synced_at":"2026-07-02T03:31:56.120Z","repository":{"id":147533313,"uuid":"597628316","full_name":"pottava/streamlit-with-firebase","owner":"pottava","description":null,"archived":false,"fork":false,"pushed_at":"2023-02-27T03:03:33.000Z","size":131,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-09-13T08:49:37.130Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/pottava.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-02-05T05:44:19.000Z","updated_at":"2025-02-24T08:59:06.000Z","dependencies_parsed_at":null,"dependency_job_id":"2c664364-7404-4863-bc18-d2362b4a2a8e","html_url":"https://github.com/pottava/streamlit-with-firebase","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/pottava/streamlit-with-firebase","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pottava%2Fstreamlit-with-firebase","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pottava%2Fstreamlit-with-firebase/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pottava%2Fstreamlit-with-firebase/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pottava%2Fstreamlit-with-firebase/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/pottava","download_url":"https://codeload.github.com/pottava/streamlit-with-firebase/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pottava%2Fstreamlit-with-firebase/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":35032145,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-07-02T02:00:06.368Z","response_time":173,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-05T10:35:22.678Z","updated_at":"2026-07-02T03:31:56.057Z","avatar_url":"https://github.com/pottava.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Streamlit \u0026 Firebase サンプル\n\n## Google Cloud services\n\n```sh\ngcloud services enable compute.googleapis.com run.googleapis.com \\\n    artifactregistry.googleapis.com secretmanager.googleapis.com \\\n    cloudbuild.googleapis.com iamcredentials.googleapis.com\n```\n\n### Firebase Authentication\n\n[認証を Firebase で](https://firebase.google.com/docs/auth)行います。\n\nhttps://console.firebase.google.com/\n\n1. \"Authentication\" の認証からメールアドレス / パスワードを有効化\n2. \"Authentication\" の Users でユーザーを登録\n3. \"プロジェクトの設定\" で確認できる内容を以下の形式で src/libs/config.py に保存\n\n```sh\nfirebase = {\n  \"apiKey\": \"apiKey\",\n  \"authDomain\": \"projectId.firebaseapp.com\",\n  \"databaseURL\": \"https://databaseName.firebaseio.com\",\n  \"storageBucket\": \"projectId.appspot.com\"\n}\n```\n\n### Cloud IAM\n\nアプリケーションのためのサービス アカウントを作成します。\n\n```sh\nexport project_id=$( gcloud config get-value project )\ngcloud iam service-accounts create sa-app \\\n    --display-name \"SA for the streamlit app\" \\\n    --description \"Service Account for the Streamlit application\"\ngcloud projects add-iam-policy-binding \"${project_id}\" \\\n    --member \"serviceAccount:sa-app@${project_id}.iam.gserviceaccount.com\" \\\n    --role \"roles/bigquery.jobUser\"\n```\n\n### Cloud Run\n\n公開 URL を取得するため、サンプルアプリケーションをデプロイしておきます。\n\n```sh\ngcloud run deploy dev-svc --image gcr.io/cloudrun/hello --region \"asia-northeast1\" \\\n    --platform \"managed\" --cpu 1.0 --memory 256Mi --max-instances 1 \\\n    --allow-unauthenticated\ngcloud run services add-iam-policy-binding dev-svc --region \"asia-northeast1\" \\\n    --member \"allUsers\" --role \"roles/run.invoker\"\n```\n\n## ローカル開発\n\n### リポジトリのクローン\n\n```sh\ngit clone https://github.com/pottava/streamlit-with-firebase.git\ncd streamlit-with-firebase\n```\n\n### アプリケーションの依存解決と起動\n\n```sh\ncd src\ngcloud auth application-default login\nexport GCLOUD_PROJECT=$( gcloud config get-value project )\npip install poetry\npoetry install\npoetry run streamlit run app.py\n```\n\n## CI / CD パイプライン\n\nArtifact Registry にリポジトリを作成します。\n\n```sh\ngcloud artifacts repositories create my-apps \\\n    --repository-format docker --location asia-northeast1 \\\n    --description=\"Containerized applications\"\n```\n\nSecret Manager に Firebase の設定を保存します。\n\n```sh\ngcloud secrets create firebase-configs --replication-policy \"automatic\" \\\n    --data-file src/libs/config.py\n```\n\n### Cloud Build の場合\n\nCloud Build に必要となる権限を付与します。\n\n```sh\nexport project_id=$( gcloud config get-value project )\nexport project_number=$(gcloud projects describe ${project_id} \\\n    --format=\"value(projectNumber)\")\ngcloud projects add-iam-policy-binding \"${project_id}\" \\\n    --member \"serviceAccount:${project_number}@cloudbuild.gserviceaccount.com\" \\\n    --role \"roles/run.developer\"\ngcloud secrets add-iam-policy-binding firebase-configs \\\n    --member \"serviceAccount:${project_number}@cloudbuild.gserviceaccount.com\" \\\n    --role \"roles/secretmanager.secretAccessor\"\ngcloud iam service-accounts add-iam-policy-binding \\\n    sa-app@${project_id}.iam.gserviceaccount.com \\\n    --member \"serviceAccount:${project_number}@cloudbuild.gserviceaccount.com\" \\\n    --role \"roles/iam.serviceAccountUser\"\n```\n\n一度ローカルからビルドを起動してみて、それを Cloud Run にデプロイしてみましょう。\n\n```sh\ncd src\ngcloud builds submit \\\n    --tag \"asia-northeast1-docker.pkg.dev/${project_id}/my-apps/streamlit\" .\ngcloud run deploy dev-svc --region \"asia-northeast1\" \\\n    --image \"asia-northeast1-docker.pkg.dev/${project_id}/my-apps/streamlit\" \\\n    --service-account \"sa-app@${project_id}.iam.gserviceaccount.com\" \\\n    --set-env-vars GCLOUD_PROJECT=${project_id}\nopen \"$( gcloud run services describe dev-svc --region \"asia-northeast1\" \\\n    --format 'value(status.url)')\"\n```\n\n[Cloud Build コンソール](https://console.cloud.google.com/cloud-build/triggers)から、リポジトリの連携とトリガーを設定します。\n\n- Cloud Run の dev-svc へのデプロイには deploy/cloudbuild-dev.yaml を指定します\n- サービス アカウントは空欄のまま\n\n### GitHub Actions または GitLab CI/CD 共通\n\nCI ツールで利用するサービスアカウントを作ります。\n\n```sh\nexport project_id=$( gcloud config get-value project )\ngcloud iam service-accounts create sa-cicd \\\n    --display-name \"SA for CI/CD\" \\\n    --description \"Service Account for CI/CD pipelines\"\ngcloud projects add-iam-policy-binding \"${project_id}\" \\\n    --member \"serviceAccount:sa-cicd@${project_id}.iam.gserviceaccount.com\" \\\n    --role \"roles/viewer\"\ngcloud projects add-iam-policy-binding \"${project_id}\" \\\n    --member \"serviceAccount:sa-cicd@${project_id}.iam.gserviceaccount.com\" \\\n    --role \"roles/run.admin\"\ngcloud projects add-iam-policy-binding \"${project_id}\" \\\n    --member \"serviceAccount:sa-cicd@${project_id}.iam.gserviceaccount.com\" \\\n    --role \"roles/storage.admin\"\ngcloud projects add-iam-policy-binding \"${project_id}\" \\\n    --member \"serviceAccount:sa-cicd@${project_id}.iam.gserviceaccount.com\" \\\n    --role \"roles/artifactregistry.writer\"\ngcloud projects add-iam-policy-binding \"${project_id}\" \\\n    --member \"serviceAccount:sa-cicd@${project_id}.iam.gserviceaccount.com\" \\\n    --role \"roles/cloudbuild.builds.editor\"\ngcloud iam service-accounts add-iam-policy-binding \\\n    sa-app@${project_id}.iam.gserviceaccount.com \\\n    --member \"serviceAccount:sa-cicd@${project_id}.iam.gserviceaccount.com\" \\\n    --role \"roles/iam.serviceAccountUser\"\ngcloud secrets add-iam-policy-binding firebase-configs \\\n    --member \"serviceAccount:sa-cicd@${project_id}.iam.gserviceaccount.com\" \\\n    --role \"roles/secretmanager.secretAccessor\"\n```\n\nCI ツールと連携する Workload Identity の設定をします。\n\n```sh\ngcloud iam workload-identity-pools create \"idpool-cicd\" --location \"global\" \\\n    --display-name \"Identity pool for CI/CD services\"\nidp_id=$( gcloud iam workload-identity-pools describe \"idpool-cicd\" \\\n    --location \"global\" --format \"value(name)\" )\n```\n\n### GitHub Actions の場合\n\n```sh\nrepo=\u003corg-id\u003e/\u003crepo-id\u003e\ngcloud iam workload-identity-pools providers create-oidc \"idp-github\" \\\n    --workload-identity-pool \"idpool-cicd\" --location \"global\" \\\n    --issuer-uri \"https://token.actions.githubusercontent.com\" \\\n    --attribute-mapping \"google.subject=assertion.sub,attribute.repository=assertion.repository\" \\\n    --display-name \"Workload IdP for GitHub\"\ngcloud iam service-accounts add-iam-policy-binding \\\n    sa-cicd@${project_id}.iam.gserviceaccount.com \\\n    --member \"principalSet://iam.googleapis.com/${idp_id}/attribute.repository/${repo}\" \\\n    --role \"roles/iam.workloadIdentityUser\"\ngcloud iam workload-identity-pools providers describe \"idp-github\" \\\n    --workload-identity-pool \"idpool-cicd\" --location \"global\" \\\n    --format \"value(name)\"\n```\n\nプロジェクトの Actions secrets and variables に以下の値を設定します。\n\n- GOOGLE_CLOUD_PROJECT: プロジェクト ID\n- GOOGLE_CLOUD_WORKLOAD_IDP: Workload Identity の IdP ID\n\n### GitLab CI/CD の場合\n\n```sh\nrepo=\u003corg-id\u003e/\u003crepo-id\u003e\ngcloud iam workload-identity-pools providers create-oidc \"idp-gitlab\" \\\n    --workload-identity-pool \"idpool-cicd\" --location \"global\" \\\n    --issuer-uri \"https://gitlab.com/\" \\\n    --allowed-audiences \"https://gitlab.com\" \\\n    --attribute-mapping \"google.subject=assertion.sub,attribute.project_path=assertion.project_path\" \\\n    --display-name \"Workload IdP for GitLab\"\ngcloud iam service-accounts add-iam-policy-binding \\\n    sa-cicd@${project_id}.iam.gserviceaccount.com \\\n    --member \"principalSet://iam.googleapis.com/${idp_id}/attribute.project_path/${repo}\" \\\n    --role \"roles/iam.workloadIdentityUser\"\ngcloud iam workload-identity-pools providers describe \"idp-gitlab\" \\\n    --workload-identity-pool \"idpool-cicd\" --location \"global\" \\\n    --format \"value(name)\"\n```\n\nプロジェクトの CI/CD Variables に以下の値を設定します。\n\n- GOOGLE_CLOUD_PROJECT: プロジェクト ID\n- GOOGLE_CLOUD_WORKLOAD_IDP: Workload Identity の IdP ID\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpottava%2Fstreamlit-with-firebase","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpottava%2Fstreamlit-with-firebase","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpottava%2Fstreamlit-with-firebase/lists"}