Skip to content

Latest commit

 

History

History

rails

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Rails Boot Script

Cloud-init file to boot a Rails app meant to be used with Google's Container Optimized OS.

See also, My own Heroku in 30 mins - Deploy Rails apps to Google Cloud Compute Engine.

Usage

  • Use asuser-data metadata field with a Compute Engine VM.
  • Search and replace the following variables:
    • ${{DOCKER_IMAGE}}
    • ${{SECRETS_PREFIX}}
  • Create Google Secret <SECRETS_PREFIX>_CLOUDSQL_INSTANCE with connection string value like my-project:region:my-sql-instance.

Helpers

This boot script installs a couple of helpers which can be accessed from within the VM:

  • rails - helps starting docker containers
  • console - Start a Rails console
  • project_id - Returns the VM's project
  • access_token - Returns a Access Token
  • fetch_secret <secret> - Fetches a secret from the Secret Manager
  • jq - Parses JSON.

Release

make build # will build dist/cloud-init.yml

Debugging

SSH into a machine that was started with this cloud-init file and you'll find the following commands useful for debugging:

sudo journalctl -f
cat /var/log/rails-cmd.log 
tail -n100 -f /var/log/cloud-init-output.log

References