Sign inSign up

ieferrari/go-ploy

By ieferrari

Updated 4 months ago

Image
0

330

ieferrari/go-ploy repository overview

go-ploy

golang cli tool for continuous deployment pipelines. Prepare deployment folder, inject secrets, deploy to remote server and run docker compose.

Usage example

go-ploy config -config_file deploy.yml

Config file example:

credentials:
  servers:
    server1:
        host: "123.4.5.67"
        user: "my_user"
        pswd: "my_pswd"
        port: "22"
  
  docker:
    registry1:
        host: "registry.my.org"
        user: "my_docker_user"
        pswd: "my_docker_pswd"
  
  credentials_file: "../cred.yml"


deployments:
  dev:
    actions:
      - check_condition:
          pre_check: true
          var_name: "BRANCH"
          valid_values: 
            - "dev"
            - "devops"
            - "$ENV_VARIABLE"
      - load_env_file:
          path: "../load.env"
          prefix: "SECRET_"
      - copy_files:
          dest_folder: "./dev_deploy"
          clean_folder: true
          files:
            - "../deploy_folder/docker-compose.yml"
            - "../deploy_folder/.env"
      - inject_secrets:
          files:
            - "./dev_deploy/.env"
      - deploy_to_server:
          servers: [server1]
          src_folder: "./dev_deploy"
          dest_folder: "/opt/deploy/my_service_dev"
          docker_login: [registry1]
          compose: true
      - remove_dir:
          path: "./dev_deploy"

Credentials file example:

servers:
  server2:
    host: "123.4.5.67"
    user: "my_user2"
    pswd: "my_pswd2"
    port: "22"
docker:
  registry2:
    host: "registry2.my.org"
    user: "my_docker_user2"
    pswd: "my_docker_pswd2"

Config file sections

credentials

First we need to define some credentials that will be used by the deployments. We can define credentials for servers and docker-registries. With the same format you can import them from a credentials file

deployments
  • You can define any number of deployments.
  • Inside each deployment you can define a list of actions to be executed in order.
Actions
  • check_condition: will check a variable agains valid values. If the valid value starts with $ will be replaced with the value in the corresponding env variable. When pre_check is true the condition will be evaluated before starting the deployment to decide if start or skip the deployment.
  • load_env_file: will load a .env file and set the variables in the environment.
  • copy_files: will copy files in the local server, useful to prepare deployment folder.
  • inject_secrets: will inject secrets into a file. Any variable starting with a prefix will be replaced with the value the corresponding environment variable. If no env variable found to replace, will fail the action and stop the deploy
  • deploy_to_server: will deploy the files to the remote server, in dest_folder. If compose: true will also run docker compose up -d in the remote server. The target servers must be defined in the credentials.servers section. In docker-login you can list all the registries to login, must be defined in the credentials.docker section.
  • remove_dir: will remove a local directory, useful to clean up after deployment any temp folder

Tag summary

Content type

Image

Digest

sha256:632c6e30a

Size

5.9 MB

Last updated

4 months ago

docker pull ieferrari/go-ploy:0.1.4