Jotting one man's journey through software development, programming, and technology
◀️ Home
gcloud storage cp copies files between local storage and Google Cloud Storage (GCS) or between GCS buckets. The basic syntax is:
gcloud storage cp [OPTIONS] source destination
gcloud storage cp file.txt gs://my-bucket/
gcloud storage cp gs://my-bucket/file.txt .
gcloud storage cp gs://source-bucket/file.txt gs://destination-bucket/
gcloud storage cp ~/code/images/${IMAGE_NAME} gs://${UPLOAD_BUCKET}
gs://is a URI scheme used for Google Cloud Storage (GCS). It indicates that the following path refers to a bucket or object stored in GCS.
gcloud storage cp → Copies a file to or from a Google Cloud Storage bucket.~/code/images/${IMAGE_NAME} → Local file path (expands to something like neon.jpg).gs://${UPLOAD_BUCKET} → Destination bucket in GCS (expands to something like gs://uploaded-images-myproject).Common Options:
Run gcloud app deploy on the repository directory. Make sure to have a YAML configuration file within the folder.
For example, you could navigate the appropriate folder and pull the latest changes:
cd github_repos/<your_repo>
git switch main
git fetch origin
git pull
Then, deploy:
gcloud app deploy
A YAML file example:
runtime: python39
entrypoint: gunicorn -b :$PORT app:app
handlers:
- url: /static
static_dir: static
http_headers:
Cache-Control: "no-cache, no-store, must-revalidate"
Pragma: "no-cache"
Expires: "0"
- url: /.*
script: auto
This script helps to quickly stream logs from the latest deployed App Engine version in the default service of the your-project-name project. Very useful for debugging and monitoring new deployments.
gcloud config set project your-project-name
Sets the current project in your gcloud configuration to your-project-name, so subsequent commands are run against this project.
LATEST_VERSION=$(gcloud app versions list \
--service default \
--sort-by "~version.id" \
--limit 1 \
--format "value(version.id)")
This block:
default service~version.id)--limit 1)--format "value(version.id)")LATEST_VERSIONecho "Latest version: $LATEST_VERSION"
This line prints out which version was found, for clarity or debugging.
gcloud app logs tail \
--service default \
--version $LATEST_VERSION
Tails (continuously streams) logs for the most recent version of the default App Engine service.
To stop the gcloud app logs tail command from tailing logs, simply press:
Ctrl + C
docker stop cap-asset-check-container
docker rm cap-asset-check-container
docker build \
--platform linux/amd64 \
--no-cache \
-t eu.gcr.io/locaria-dev-asset-qc/cap-asset-check .
gcloud config set project locaria-dev-asset-qc
docker tag cap-asset-check eu.gcr.io/locaria-dev-asset-qc/cap-asset-check
docker push eu.gcr.io/locaria-dev-asset-qc/cap-asset-check
gcloud run deploy cap-asset-check \
--image eu.gcr.io/locaria-dev-asset-qc/cap-asset-check \
--platform managed \
--region europe-west1 \
--port 8080 \
gcloud run services update-traffic cap-asset-check \
--to-latest \
--region europe-west1 \
--platform managed