Google Cloud
Sorry-cypress installation instructions for Google Cloud Run
The suggested setup uses the following stack:
- MongoDB setup of your choice
Please make sure that you have
- recent version of Docker installed
Please use MongoDB provider of your choice. MongoDB Atlas is a simple and popular managed solution that also has a free tier.
Once you've created MongoDB cluster and a database, please obtain credentials and database name, you will need it in subsequent steps.
MinIO GCS Gateway allows to access Google Cloud Storage (GCS) with AWS S3-compatible APIs.
- 1.
- 2.Select a project or create a new project. Note the project ID.
- 3.Select the Create credentials drop-down on the Credentials page, and click Service account key.
- 4.Select New service account from the Service account drop-down.
- 5.Populate the Service account name and Service account ID.
- 6.Click the drop-down under Grant this service account access to the project, the Role and choose Storage > Storage Admin (Full control of GCS resources).
- 7.Click on the service account and select Add Key > Create New Key key
- 8.Download the JSON file and rename it as
credentials.json
The service account is granted admin access to all GC storage objects. Please refer to Google Cloud and Minio documentation to limit access.
Grab the following Dockerfile and place it in the same directory as created earlier
credentials.json
.
├── credentials.json
└── Dockerfile
Dockerfile
FROM minio/minio
COPY credentials.json ./
ENV GOOGLE_APPLICATION_CREDENTIALS=/credentials.json
ENV MINIO_ACCESS_KEY=<choose_access_key>
ENV MINIO_SECRET_KEY=<choose_secret_key>
CMD ["gateway", "gcs", "<project>"]
Replace
project
and choose secure MINIO_ACCESS_KEY
and MINIO_SECRET_KEY
, build the image and push to GCR.docker build -t gcr.io/<project>/minio .
docker push gcr.io/<project>/minio
Create and deploy Cloud Run
minio
service.gcloud run deploy minio \
--image gcr.io/<project>/minio \
--platform managed \
--allow-unauthenticated \
--port 9000
## Example output:
# Service [minio0demo] revision [minio2-00001-fab] has been deployed and is serving 100 percent of traffic.
# Service URL: https://minio-dwpifb4gla-uc.a.run.app
Upon successful deployment, note the
Service URL
of the deployed service. You'd be able to open browsers and access Minio dashboard with the credentials you've set in Dockerfile earlier.Run the next command to create a new bucket (
<bucket_name>
) and set policy using mc
- minio client Docker imagedocker run -it minio/mc \
mc config host add gcs <minio_service_url> <minio_access_key> <minio_secret_key> && \
mc mb gcs/<bucket_name> && \
mc policy set download gcs/<bucket_name>
## Example output:
# Bucket created successfully `gcs/sorry-cypress-demo`.
# Access permission for `gcs/sorry-cypress-demo` is set to `download`
🎉 You have setup Minio Gateway that sorry-cypress can use to store the recordings of your runs.
Let's create 3 Cloud Run Services and deploy sorry-cypress components. We are going to run the following sequence of commands for each service:
- 1.Pull latest docker image from Dockerhub
- 2.Tag and push image to GCR associated with your project
- 3.Deploy Google Cloud Run service using the newly generated image
Running a simple script hosted on GitHub would deploy the services.
-p
is the current Google Cloud project-n
is the name prefix for generated Google Cloud Run services
curl -sL https://git.io/Jt4cB \
| source /dev/stdin -p <project> -n <services-prefix>
## Example output:
# 🏁 Finished deployment to Google Cloud Run
#
# test001-director: https://test001-dashboard-dwpifb4gla-uc.a.run.app
# test001-api: https://test001-dashboard-dwpifb4gla-uc.a.run.app
# test001-dashboard: https://test001-dashboard-dwpifb4gla-uc.a.run.app
Note the URLs of the generated services, we'll use those in the next step to configure the services so they'll be able to communicate one with another.
Run the commands below, please be careful while substituting template strings with values obtained at previous steps
MINIO_ENDPOINT
is the hostname of Minio URL you've obtained while setting up Minio Gateway. E.g.# director configuration
gcloud run services update <services_prefix>-director \
--platform managed \
--set-env-vars DASHBOARD_URL="<dashboard_service_url>" \
--set-env-vars EXECUTION_DRIVER="../execution/mongo/driver" \
--set-env-vars MONGODB_URI="<mongodb_uri>" \
--set-env-vars MONGODB_DATABASE="<mongodb_dbname>" \
--set-env-vars MINIO_ACCESS_KEY="<minio_access_key>" \
--set-env-vars MINIO_SECRET_KEY="<minio_secret_key>" \
--set-env-vars MINIO_ENDPOINT="example-minio-dwpifb4gla-uc.a.run.app" \
--set-env-vars MINIO_URL="https://exampleminio-dwpifb4gla-uc.a.run.app" \
--set-env-vars MINIO_BUCKET="<minio_bucket_name>"
# api configuration
gcloud run services update <services_prefix>-api \
--platform managed \
--set-env-vars MONGODB_URI="<mongodb_uri>" \
--set-env-vars MONGODB_DATABASE="<mongodb_dbname>" \
--set-env-vars APOLLO_PLAYGROUND="<apollo_playground>"
# dashboard configuration
gcloud run services update <services_prefix>-dashboard \
--platform managed \
--set-env-vars GRAPHQL_SCHEMA_URL="<api_service_url>"
🎉 Congratulations!
You've finished setting up sorry-cypress on Google Cloud - now you can open the Dashboard URL to see the dashboard.
Last modified 9mo ago