A Road-Score , written in Node.js(20lts).
Docker Local Test시 GCP keyfile.json, docker-compose.yml이 필요하다.
-
key를 GCP 다운로드(IAM 및 관리자 - 서비스 계정에서 관리)하여 로컬 프로젝트 루트 디렉토리에 keyfile.json으로 파일명을 변경하여 저장한다.
-
docker-compose.yml을 로컬 프로젝트 루트 디렉토리에 저장한다.(비밀 키들이 저장되어있으므로 절대 인터넷 환경에 업로드하지 않는다.)
-
docker compose로 빌드
docker-compose up
-
api 요청시 api key 관리 무작위 base64 생성 in postgreSQL
CREATE EXTENSION IF NOT EXISTS pgcrypto; SELECT encode(gen_random_bytes(32), 'base64');
production은 Secret Manager의 TEST_API_KEYS로 관리, development는 docker-compose.yml의 environments TEST_API_KEYS로 관리한다.(json을 직접 load하지 못하여 트릭으로 적용. 값마다 \ 값이 들어가므로 주의) Secret Manager key 업데이트 후 해당 Cloud Run 서버에서 새 버전 수정 및 배포 후 배포버튼을 눌러야 적용됨.
- Enable the Cloud Run API via the console or CLI:
gcloud services enable run.googleapis.com
- Express: Web server framework
- Buildpack support Tooling to build production-ready container images from source code and without a Dockerfile
- Dockerfile: Container build instructions, if needed to replace buildpack for custom build
- SIGTERM handler: Catch termination signal for cleanup before Cloud Run stops the container
- Service metadata: Access service metadata, project Id and region, at runtime
- Local development utilities: Auto-restart with changes and prettify logs
- Structured logging w/ Log Correlation JSON formatted logger, parsable by Cloud Logging, with automatic correlation of container logs to a request log.
- Unit and System tests Basic unit and system tests setup for the microservice
This template works with Cloud Code, an IDE extension to let you rapidly iterate, debug, and run code on Kubernetes and Cloud Run.
Learn how to use Cloud Code for:
-
Creating a new application from a custom template (
.template/templates.json
allows for use as an app template) - VSCode, IntelliJ
- Set Project Id:
export GOOGLE_CLOUD_PROJECT=<GCP_PROJECT_ID>
- Start the server with hot reload:
npm run dev
-
Set Project Id:
export GOOGLE_CLOUD_PROJECT=<GCP_PROJECT_ID>
-
Enable the Artifact Registry API:
gcloud services enable artifactregistry.googleapis.com
-
Create an Artifact Registry repo:
export REPOSITORY="samples" export REGION=us-central1 gcloud artifacts repositories create $REPOSITORY --location $REGION --repository-format "docker"
-
Use the gcloud credential helper to authorize Docker to push to your Artifact Registry:
gcloud auth configure-docker
-
Build the container using a buildpack:
npm run build
-
Deploy to Cloud Run:
npm run deploy
-
Pass credentials via
GOOGLE_APPLICATION_CREDENTIALS
env var:export GOOGLE_APPLICATION_CREDENTIALS="[PATH]"
-
Set Project Id:
export GOOGLE_CLOUD_PROJECT=<GCP_PROJECT_ID>
-
Run unit tests
npm run test
-
Run system tests
gcloud builds submit \ --config test/advance.cloudbuild.yaml \ --substitutions 'COMMIT_SHA=manual'
The Cloud Build configuration file will build and deploy the containerized service to Cloud Run, run tests managed by NPM, then clean up testing resources. This configuration restricts public access to the test service. Therefore, service accounts need to have the permission to issue Id tokens for request authorization:
-
Enable Cloud Run, Cloud Build, Artifact Registry, and IAM APIs:
gcloud services enable run.googleapis.com cloudbuild.googleapis.com iamcredentials.googleapis.com artifactregistry.googleapis.com
-
Set environment variables.
export PROJECT_ID="$(gcloud config get-value project)" export PROJECT_NUMBER="$(gcloud projects describe $(gcloud config get-value project) --format='value(projectNumber)')"
-
Create an Artifact Registry repo (or use another already created repo):
export REPOSITORY="samples" export REGION=us-central1 gcloud artifacts repositories create $REPOSITORY --location $REGION --repository-format "docker"
-
Create service account
token-creator
withService Account Token Creator
andCloud Run Invoker
roles.gcloud iam service-accounts create token-creator gcloud projects add-iam-policy-binding $PROJECT_ID \ --member="serviceAccount:token-creator@$PROJECT_ID.iam.gserviceaccount.com" \ --role="roles/iam.serviceAccountTokenCreator" gcloud projects add-iam-policy-binding $PROJECT_ID \ --member="serviceAccount:token-creator@$PROJECT_ID.iam.gserviceaccount.com" \ --role="roles/run.invoker"
-
Add
Service Account Token Creator
role to the Cloud Build service account.gcloud projects add-iam-policy-binding $PROJECT_ID \ --member="serviceAccount:$PROJECT_NUMBER@cloudbuild.gserviceaccount.com" \ --role="roles/iam.serviceAccountTokenCreator"
-
This repo performs basic periodic testing for maintenance. Please use the issue tracker for bug reports, features requests and submitting pull requests.
Please see the contributing guidelines
This library is licensed under Apache 2.0. Full license text is available in LICENSE.
A Road-Score Project, written in Node.js(20lts).
Road-Score 메인 화면으로, 각 지역에 보행로 알고리즘으로 산출된 점수를 부여한 화면이 노출됩니다.
수집한 건물들의 빌딩 폴리곤을 보여줍니다. 해당건물들은 접근성 점수를 부여받고 점수에 따른 색상을 가지게됩니다.
선택한 건물의 상세 정보를 보여줍니다. 출입구 정보, 사진등 , 주소등 해당 건물의 데이터를 노출합니다.
- Enable the Cloud Run API via the console or CLI:
gcloud services enable run.googleapis.com