Skip to content

Instantly share code, notes, and snippets.

@steren
Created November 11, 2025 05:15
Show Gist options
  • Select an option

  • Save steren/a9daf53d9e81d5f004069dd1fe1989c0 to your computer and use it in GitHub Desktop.

Select an option

Save steren/a9daf53d9e81d5f004069dd1fe1989c0 to your computer and use it in GitHub Desktop.
Zip deploy
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
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