Setting up auto deploy for PHP

3/18/2020

Good day,

Problem I have been trying to deploy my local PHP Code that is hosted in GitLab using Google Cloud Platform for my Kubernetes. I have managed to link the project to Kubernetes but I'm failing to deploy it to production as I have little or no knowledge on how to use .yml configs.

Tried Solutions and Code

.gitlab-ci.yml

image: google/cloud-sdk:alpine

deploy_production:
  stage: deploy
  environment: Production
  only:
  - master
  script:
  - echo $SERVICE_ACCOUNT > /tmp/$CI_PIPELINE_ID.json
  - gcloud auth activate-service-account --key-file /tmp/$CI_PIPELINE_ID.json
  - gcloud --quiet --project $PROJECT_ID app deploy app.yaml dispatch.yaml

after_script:
- rm /tmp/$CI_PIPELINE_ID.json

app.yaml

runtime: php73 # Replace with php73 to use the PHP 7.3 runtime

handlers:
# Serve a directory as a static resource.
- url: /stylesheets
  static_dir: stylesheets
  secure: always


# Serve images as static resources.
- url: /(.+\.(gif|png|jpg))$
  static_files: \1
  upload: .+\.(gif|png|jpg)$

# Serve your app through a front controller at index.php or public/index.php.
- url: .*
  script: auto

dispatch.yaml

dispatch:
  - url: "example.com/*"
    service: default

Outcome Trying to achieve So what I am trying to archive for starters is for production to install PHP with all dependencies, have an app staging, production stage and specifying the domain I want to serve the application at.

Recommendations are highly welcome

-- Henry Newman
gitlab
google-cloud-platform
kubernetes
php

0 Answers