Sign inSign up

helixtech/deployer-php

By helixtech

•Updated over 6 years ago

This image helps to deploy Applications with Deployer PHP official package. Useful for pipelines

Image
0

466

helixtech/deployer-php repository overview

⁠Bitbucket Pipelines Pipe: Deploy PHP application with Deployer Package

This pipe helps to deploy a PHP application with Official Deployer Package for PHP

⁠YAML Definition

Add the following snippet to the script section of your bitbucket-pipelines.yml file:

script:
  - pipe: docker://helixtech/deployer-php:0.1.0
    variables:
      HOST: "host-to-deploy"
      SSH_PRIVATE_KEY_TO_DEPLOY: "$PRIVATE_KEY_TO_DEPLOY"
      # DEPLOYER_VERSION: "v6.8.0" # Optional
      # PATH_DEPLOY_FILE: "path/to/file" # Optional
      # DOWNLOAD_DEPLOY_FILE: "true" # Optional
      # SSH_PRIVATE_KEY_TO_CLONE: "$PRIVATE_KEY_TO_CLONE" # Depends on DOWNLOAD_DEPLOY_FILE
      # REPO_DEPLOYER_URL: "[email protected]:username/repo-deployer-file.git" # Depends on DOWNLOAD_DEPLOY_FILE
      # REPO_DEPLOYER_BRANCH: "master" # Depends on DOWNLOAD_DEPLOY_FILE
      # EXTRA_ARGS: "<string>" # Optional
      # DEBUG: "<boolean>" # Optional

⁠Variables

VariableUsage
HOST (*)The host where you want to deploy. This parameter is required because before run the deploy, that host is added to known_hosts file
SSH_PRIVATE_KEY_TO_DEPLOY (*)The ssh key necessary to deploy into the HOST server
DEPLOYER_VERSIONThe Deployer that you want to use. Default: latest. If you want to use another version don't forget the version prefix "v", E.g: v6.7.2. For more information about versions you can see Deployer download⁠
DEBUGTurn on extra debug information. Default: false.
EXTRA_ARGS (Optional)Pass some extra options to the deployer command. For more information you can see Deployer PHP⁠
PATH_DEPLOY_FILE (Optional)Path to the Deployer file. [IMPORTANT] Avoid pass "--file[=FILE]" option in EXTRA_ARGS, because it's unnecesary. With this parameter the pipe locates the working directory in this value. Defult: "."
DOWNLOAD_DEPLOY_FILETurn on import the Deployer file from a git repository. Default: false.
REPO_DEPLOYER_URL (**)The git repository uri to import the Deployer file. If you use ssh method (E.g. [email protected]⁠:username/repo-deployer-file.git) you have to use the SSH_PRIVATE_KEY_TO_CLONE. If you use Https method you can use the oauth method for authenticate (E.g. git clone https://x-token-auth:{access_token}@bitbucket.org/user/repo.git⁠)
REPO_DEPLOYER_BRANCH (**)The repository branch where is the Deployer file
SSH_PRIVATE_KEY_TO_CLONE (**)The ssh key necessary to clone a repository where you have the Deployer file. This parameter is required ONLY if REPO_DEPLOYER_URL is for clone by ssh method (E.g. REPO_DEPLOYER_URL=[email protected]⁠:username/repo-deployer-file.git)

(*) = required variable.

(**) = required variable ONLY if DOWNLOAD_DEPLOY_FILE is set "true".

⁠Tips

  • Bitbucket don't allow break line in environment variables. For that reason, we recomended encode your ssh keys (SSH_PRIVATE_KEY_TO_DEPLOY, SSH_PRIVATE_KEY_TO_CLONE) in base64 before save it in an environment variable, and before pass it to the Pipe variable, decode it. See Use multiple SSH keys in your pipeline⁠.

⁠Prerequisites

  • Have a Deploy file, in the repository where the pipeline is running OR in another repository. Remenber, if you have the Deployer file (deploy.php) in another repository you have to set DOWNLOAD_DEPLOY_FILE="true" and use REPO_DEPLOYER_URL, SSH_PRIVATE_KEY_TO_CLONE and REPO_DEPLOYER_BRANCH as corresponding

⁠Examples

Basic example:

Deploy with Deployer file located in the repository root running the pipeline.

script:
  - export KEY_TO_DEPLOY=$(echo "$PRIVATE_KEY_TO_DEPLOY" | base64 --decode) // This line will decode the ssh key encoded
  - pipe: docker://helixtech/deployer-php:0.1.0
    variables:
      HOST: "host-to-deploy"
      SSH_PRIVATE_KEY_TO_DEPLOY: "$KEY_TO_DEPLOY"

Advanced example:

Clone the Deployer file from a git repository by ssh method.

script:
  - export KEY_TO_DEPLOY=$(echo "$PRIVATE_KEY_TO_DEPLOY" | base64 --decode) // This line will decode the ssh key encoded
  - export KEY_TO_CLONE=$(echo "$PRIVATE_KEY_TO_CLONE" | base64 --decode) // This line will decode the ssh key encoded
  - pipe: docker://helixtech/deployer-php:0.1.0
    variables:
      HOST: "host-to-deploy"
      SSH_PRIVATE_KEY_TO_DEPLOY: "$KEY_TO_DEPLOY"
      DEPLOYER_VERSION: "v6.3.0"
      PATH_DEPLOY_FILE: "path/to/file"
      DOWNLOAD_DEPLOY_FILE: "true"
      SSH_PRIVATE_KEY_TO_CLONE: "$KEY_TO_CLONE"
      REPO_DEPLOYER_URL: "[email protected]:username/repo-deployer-file.git"
      REPO_DEPLOYER_BRANCH: "master"
      EXTRA_ARGS: "dev --branch=develop"

Clone the Deployer file from a git repository by https method.

script:
  - export KEY_TO_DEPLOY=$(echo "$PRIVATE_KEY_TO_DEPLOY" | base64 --decode) // This line will decode the ssh key encoded
  - pipe: docker://helixtech/deployer-php:0.1.0
    variables:
      HOST: "host-to-deploy"
      SSH_PRIVATE_KEY_TO_DEPLOY: "$KEY_TO_DEPLOY"
      PATH_DEPLOY_FILE: "path/to/file"
      DOWNLOAD_DEPLOY_FILE: "true"
      REPO_DEPLOYER_URL: "https://x-token-auth:{access_token}@bitbucket.org/user/repo.git"
      EXTRA_ARGS: "dev --branch=develop"

⁠How use it with docker run command

  docker run \
      -e SSH_PRIVATE_KEY_TO_CLONE="$(cat ~/.ssh/id_rsa_to_clone_file)" \
      -e SSH_PRIVATE_KEY_TO_DEPLOY="$(cat ~/.ssh/id_rsa_to_deploy)" \
      -e HOST=host-to-deploy \
      -e PATH_DEPLOY_FILE="path/to/file" \
      -e [email protected]:username/repo-deployer-file.git \
      -e DOWNLOAD_DEPLOY_FILE="true" \
      -e REPO_DEPLOYER_BRANCH=master \
      -e EXTRA_ARGS="dev --branch=develop" \
      --name test_deployer \
      helixtech/deployer-php:0.1.0

⁠Support

If you’d like help with this pipe, or you have an issue or feature request, let us know. The pipe is maintained by [email protected]⁠.

If you’re reporting an issue, please include:

  • the version of the pipe
  • relevant logs and error messages
  • steps to reproduce

Tag summary

Content type

Image

Digest

Size

27.2 MB

Last updated

over 6 years ago

docker pull helixtech/deployer-php