crystal-helloworld
This simple web server, replies with a "Hello world" message, along with the HTTP parameter string.
Click on the below button to:
- Launch a Cloud Shell machine
- Download this GitHub repository
- Build a container using Docker
- Push the container into Google Container Regsitry
- Launch Cloud Run
All automatically...
If you are not familiar with Crystal, it is very similar to the Ruby language, but it is compiled. The following docker image is only a few MB in size.
I have added a Makefile to simply building and deploying the executable.
Test
curl http:<Cloud Run URL>/hi/nick
Hello world, got /hi/nick
Clean up
gcloud run services delete crystal-webserver
Don't forget to delete the GCR repo as well.
Available make commands
$ make
Available targets:
build/cloud Build docker container in Cloud
build/docker Build docker container locally
build/local Compiles source using shards command
clean/cloud Delete Cloud Run service and container
deploy Deploy container to Cloud Run
docker/login Configures Docker to authenticate to GCR
help This help screen
logs Examine the logs from the Cloud container
logs/stream Stream Cloud Run logs
watch Locally run program with dynamic recompile
Resources
Cloud Run
- https://github.com/GoogleCloudPlatform/cloud-run-button
GNU Make
Notes
Send authorization token, if unauthenticated is not allowed
curl --header "Authorization: Bearer $(gcloud auth print-identity-token)" [URL]
It is now possible to send requests via a local proxy, even if the service is authenticated.
gcloud beta run services proxy