Created
November 11, 2025 05:15
-
-
Save steren/a9daf53d9e81d5f004069dd1fe1989c0 to your computer and use it in GitHub Desktop.
Zip deploy
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ACCESS_TOKEN=$(gcloud auth print-access-token) | |
| PROJECT_ID="steren-serverless" | |
| SERVICE_NAME="hello-zip-deploy-4" | |
| REGION="us-central1" | |
| GCS_BUCKET_NAME="steren-zip-deploy-test" | |
| tar -czf app.tar.gz . | |
| gcloud storage cp app.tar.gz gs://$GCS_BUCKET_NAME/app.tar.gz | |
| curl -H "Content-Type: application/json" \ | |
| -H "Authorization: Bearer $ACCESS_TOKEN" \ | |
| -X POST \ | |
| -d "{\"template\": {\"containers\": [{\"command\": [\"npm\"], \"args\": [\"start\"], \"image\": \"scratch\", \"baseImageUri\": \"google-22/nodejs22\", \"sourceCode\": {\"cloudStorageSource\": {\"bucket\": \"$GCS_BUCKET_NAME\", \"object\":\"app.tar.gz\"}}}]}}" \ | |
| https://run.googleapis.com/v2/projects/$PROJECT_ID/locations/$REGION/services?serviceId=$SERVICE_NAME |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const http = require('http'); | |
| const hostname = '0.0.0.0'; | |
| const port = process.env.PORT || 8080; | |
| const server = http.createServer((req, res) => { | |
| res.statusCode = 200; | |
| res.setHeader('Content-Type', 'text/plain'); | |
| res.end('Hello, World!\n'); | |
| }); | |
| server.listen(port, hostname, () => { | |
| console.log(`Server running at http://${hostname}:${port}/`); | |
| }); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment