FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

php-docs-samples/run at main · shinigamitrinity/php-docs-samples · GitHub

Latest commit

 

History

History
 
 

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 

README.md

Google Cloud Run PHP Samples

Cloud Run runs stateless containers on a fully managed environment or in your own GKE cluster.

Samples

Sample Description Deploy
Hello World Quickstart
Laravel Deploy Laravel on Cloud Run -
Multi-container Multi-container samples (i.e nginx) -

For more Cloud Run samples beyond PHP, see the main list in the Cloud Run Samples repository.

Setup

  1. Set up for Cloud Run development

  2. Clone this repository:

    git clone https://github.com/GoogleCloudPlatform/php-docs-samples.git
    cd php-docs-samples/run

How to run a sample locally

  1. Install docker locally

  2. Build the sample container:

    export SAMPLE='helloworld'
    cd $SAMPLE
    docker build --tag $SAMPLE .
  3. Run containers locally

    With the built container:

    PORT=8080 && docker run --rm -p 8080:${PORT} -e PORT=${PORT} $SAMPLE

    Overriding the built container with local code:

    PORT=8080 && docker run --rm \
        -p 8080:${PORT} -e PORT=${PORT} \
        -v $PWD:/usr/src/app $SAMPLE

    Injecting your service account key:

    export SA_KEY_NAME=my-key-name-123
    PORT=8080 && docker run --rm \
        -p 8080:${PORT} -e PORT=${PORT} \
        -e GOOGLE_APPLICATION_CREDENTIALS=/tmp/keys/${SA_KEY_NAME}.json \
        -v $GOOGLE_APPLICATION_CREDENTIALS:/tmp/keys/${SA_KEY_NAME}.json:ro \
        -v $PWD:/usr/src/app $SAMPLE

    Opening a shell in the container:

    1. Build the container.

    2. Run the container with a shell:

      PORT=8080 && docker run --rm \
          --interactive --tty \
          -p 8080:${PORT} -e PORT=${PORT} \
          -v $PWD:/var/www/html $SAMPLE \
          /bin/bash
    3. Exit the container: Ctrl-D

Deploying

See Building containers and Deploying container images for more information.


Back | FazBrowse Home | New Git URL