Coder Social home page Coder Social logo

ci-agent's Introduction

CI agent Docker image for Docksal Sandboxes

An agent used to connect CI providers to a Docksal Sandbox Server.

Supported CI providers:

  • Bitbucket Pipelines (with build status integration)
  • CircleCI (with build status integration)
  • GitLab
  • Github Actions

This image(s) is part of the Docksal image library.

Docksal Sandboxes

Docksal Sandboxes are continuous integration environments powered by Docksal and deployed to a Docksal Sandbox Server. They can be provisioned for any git branch and are feature-wise identical to project's local Docksal environment.

Use cases:

  • automated testing (full stack)
  • manual testing
  • enhanced pull request review experience
  • demos

Build status updates (and sandbox URLs) can be posted to Github and Bitbucket via respective build status APIs.
URLs to sandbox environments can also be published to a Slack channel.

Image variants and versions

Stable

  • base - basic (bash, curl, git, etc.), latest version
  • php, latest - basic + php stack tools (composer, drush, drupal console, wp-cli, etc.), latest version
  • 1.2-base - basic, a specific stable version
  • 1.2-php - php, a specific stable version

Development

  • edge-base - base, latest development version
  • edge-php, php, latest development version

Global Configuration

Required

The following required variables are usually configured at the organization level. This way, all project repos will have access to them. They can as well be configured at the repo level.

DOCKSAL_HOST or DOCKSAL_HOST_IP

The address of the sandbox server. Configure one or the other.
If using DOCKSAL_HOST, make sure the domain is configured as a wildcard DNS entry.
If using DOCKSAL_HOST_IP, the agent will use nip.io for dynamic wildcard domain names for sandboxes.

DOCKSAL_HOST_SSH_KEY

A base64 encoded private SSH key, used to access the sandbox server.

Note: on macOS cat /path/to/<private_key_file> | base64 can be used to create a base64 encoded string from a private SSH key, while on Linux and in WSL on Windows 10 cat /path/to/<private_key_file> | base64 -w 0 should be used to avoid output wrapping of the base64 command).

Optional

BUILD_ENVIRONMENT

Used to set the environment built against. Defaults to local.

CI_SSH_KEY

A base64 encoded private SSH key, used by default for all hosts (set as Host * in ~/.ssh/config). This key will be used to clone/push to git, run commands over SSH on a remote deployment environment, etc.

DOCKSAL_HOST_SSH_PORT

Can be used to override the SSH port of the sandbox server where the agent connects (defaults to 22).

DOCKSAL_DOMAIN

Can be used to set the base URL for sandbox builds (defaults to DOCKSAL_HOST if not set), individually from DOCKSAL_HOST.
This is useful when working with CDNs/ELBs/WAFs/etc (when DOCKSAL_DOMAIN is different from the DOCKSAL_HOST).

DOCKSAL_HOST_USER

The user name used as the build user on the sandbox server. Defaults to build-agent. Must have SSH access to the server.

REMOTE_BUILD_BASE

The default directory location on the sandbox server where the repositories should be cloned down to and built. Defaults to /home/build-agent/builds.

REMOTE_CODEBASE_METHOD

Pick between rsync (default) and git for the codebase initialization method on the sandbox server.

The codebase is initialized on the sandbox server by the sandbox-init (or build-init) command.

git - code is checkout on the sandbox server via git. The server must have access to checkout from the repo. Any build settings and necessary code manipulations must happen on the sandbox server using build-exec commands.

rsync - code is rsync-ed to the sandbox server from the build agent. You can perform necessary code adjustments in the build agent after running build-env and before running sandbox-init (or build-init), which pushes the code to the sandbox server.

REMOTE_BUILD_DIR_CLEANUP

Whether or not the remote build directory is reset during the build. Only supported with REMOTE_CODEBASE_METHOD=git.

Defaults to 1 which wipes the remote build directory and produces a "clean build".
Set to 0 to produce "dirty builds", when file changes in the remote codebase should be preserved.

Note: Switching REMOTE_CODEBASE_METHOD mode will result in a clean build.

SANDBOX_PERMANENT

Set SANDBOX_PERMANENT=true to have a permanent sandbox provisioned.

Permanent sandboxes are exempt from scheduled garbage collection on the sandbox server. They would still hibernate after the configured period of inactivity, but won't be removed from the server after becoming dangling. See https://github.com/docksal/service-vhost-proxy#advanced-proxy-configuration for more information.

This variable is usually set at the branch level in the build settings to designate a specific (one or multiple) branch environments as permanent.

SANDBOX_DOMAIN

Sets a custom domain for a sandbox. Takes precedence over the automatic (branch name based) domain generation.

This can be used for sandbox environments which need a custom (nice) domain name.

GITHUB_TOKEN and BITBUCKET_TOKEN

Used for access to post sandbox URLs via build status API as well as comments on pull requests.

For Github, the token can be generated from the user's account.
Set access to "repo" (http://take.ms/nMqcW).

For Bitbucket, the token can be generated from the user's settings. Instructions on creating an app password.
Set access to "Repositories: Write", "Pull requests: Write" (http://take.ms/98BG5).
When storing the app password it is in the format: USER:PASSWORD.

GIT_USER_EMAIL

The user's email to perform Git operations as. Defaults to [email protected]

GIT_USER_NAME

The user's name to perform Git operations as. Defaults to Docksal CI

DOCKSAL_HOST_TUNNEL

If not empty, localhost:2374 in the agent is mapped to docker.sock on the remote DOCKSAL_HOST via a secure SSH tunnel.
The agent can then run docker commands against the remote DOCKSAL_HOST.

Other features and integrations are usually configured at the repo level. See below.

Project configuration

Bitbucket Pipelines

Here's the most basic configuration for Bitbucket Pipelines. Save it into bitbucket-pipelines.yml in your project repo.

image: docksal/ci-agent:base

pipelines:
  default:
    - step:
        script:
          - source build-env && sandbox-init

For a more advanced example see bitbucket-pipelines.yml.

CircleCI

Here's the most basic configuration for CircleCI. Save it into .circleci/config.yml in your project repo.

version: 2

jobs:
  build:
    working_directory: /home/agent/build
    docker:
      - image: docksal/ci-agent:base
    steps:
      - run:
          name: Configure agent environment
          command: echo 'source build-env' >> $BASH_ENV
      - checkout
      - run:
          name: Build sandbox
          command: sandbox-init

For a more advanced example see config.yml.

GitLab

Here's the most basic configuration for GitLab. Save it into .gitlab-ci.yml in your project repo.

stages:
  - sandbox

sandbox-launch:
  stage: sandbox
  image: docksal/ci-agent:base
  script:
    - export SANDBOX_DOMAIN=$CI_ENVIRONMENT_SLUG--$CI_PROJECT_NAME.$DOCKSAL_HOST
    - source build-env
    - sandbox-init
  environment:
    name: $CI_COMMIT_REF_NAME
    url: https://$CI_ENVIRONMENT_SLUG--$CI_PROJECT_NAME.$DOCKSAL_HOST

For a more advanced example see .gitlab-ci.yml.

Github Actions

Here's the most basic configuration for Github Actions. Save it into .github/workflows/sandbox.yml in your project repo.

You might need to add your ssh key to EC2 /home/build-agent/.ssh and the deploy(public) key to Github Actions for cloning the codebase via git.

name: Docksal sandbox

on:
  workflow_dispatch:

jobs:
  build:
    runs-on: ubuntu-latest
    container:
      image: docksal/ci-agent:base
    env:
      CI_SSH_KEY: ${{ secrets.CI_SSH_KEY }}
      DOCKSAL_HOST_IP: ${{ secrets.DOCKSAL_HOST_IP }}
      DOCKSAL_HOST_SSH_KEY: ${{ secrets.DOCKSAL_HOST_SSH_KEY }}
      GITHUB_TOKEN: ${{ github.token }}
      REMOTE_CODEBASE_METHOD: git
    steps:
      - name: Build sandbox
        shell: bash
        run: |
          source build-env
          sandbox-init

For a more advanced example see .sandbox.yml.

Build commands

For a complete list of built-in commands see base/bin.

  • build-env - configures build settings on the agent. Usage: source build-env (or DEBUG=1 source build-env)
  • build-init- initializes the sandbox codebase and settings on the sandbox server. Usage: build-init
  • build-exec - executes a shell command within the build directory on the sandbox server. Usage: build-init pwd
  • build-notify - see "Build status notifications" docs below
  • sandbox-init - a convenient shortcut to provision a basic sandbox. See sandbox-init

Build environment variables

The following variables are derived from the respective Bitbucket Pipelines, Circle CI, GitLab CI, and Github Actions build variables.

  • GIT_REPO_OWNER - git repo machine owner/slug name
  • GIT_REPO_NAME - git repo machine name
  • GIT_REPO_URL - git repo URL
  • GIT_BRANCH_NAME - git branch name
  • GIT_COMMIT_HASH - git commit hash
  • GIT_PR_NUMBER - git pull request / merge request number
  • GIT_REPO_SERVICE - github, bitbucket or gitlab (makes sense mostly for CircleCI)
  • BUILD_ID - The unique identifier for a build
  • BUILD_DIR - The full path where the repository is cloned and where the job is run in the agent container

REMOTE_BUILD_DIR

The directory location on the sandbox server where current build will happen. Defaults to:

${REMOTE_BUILD_BASE}/${REPO_NAME_SAFE}-${BRANCH_NAME_SAFE}

Feature: Basic HTTP Auth

Protect sandboxes from public access using Basic HTTP authentication.

Configuration

Set the following environment variables at the repo level:

  • HTTP_USER
  • HTTP_PASS

Feature: Build status notifications

This integration allows the agent to post build status updates and sandbox URL via Github/Bitbucket build status API.
For CircleCI, it is also possible to enable posting the sandbox URL as a comment in pull requests.

Configuration

GITHUB_TOKEN or BITBUCKET_TOKEN must be configured respectively (either globally or at the repo level).

Usage

build-notify <pending|success|failure>

Place the triggers right before and right after fin init call in your build script, e.g.,

build-notify pending 
ssh docker-host "cd $REMOTE_BUILD_DIR && fin init" || ( build-notify failure && exit 1 )
build-notify success

To enable posting sandbox URLs in comments on pull requests, do export PR_COMMENT=1 prior to calling build-notify

Feature: Slack notifications

This integrations allows the agent to post messages to a given Slack channel.
It can be used for notification purposes when a build is started, completed, failed, etc.

Configuration

SLACK_WEBHOOK_URL

The Incoming Webhook integration URL from Slack, e.g., SLACK_WEBHOOK_URL https://hooks.slack.com/services/XXXXXXXXX/XXXXXXXXX/XXxxXXXXxxXXXXxxXXXXxxXX

SLACK_CHANNEL

A public or private channel in Slack, e.g., SLACK_CHANNEL #project-name-bots

SLACK_USER

The username the message should post to Slack as. Defaults to Docksal CI

SLACK_ICON

The icon the message should use to accompany the message: Defaults to :desktop_computer:

Usage

slack 'message' ['#channel'] ['webhook_url'] ['slack_user'] ['slack_icon']

Channel and webhook url can be passed via environment variables. See above.

Limitations

Incoming Webhook integration won't work for private channels, which the owner of the integration does not belong to.

Feature: Build artifact storage

Build artifacts can be stored in an AWS S3 bucket.

Configuration

Set the following environment variables at the organization or repo level:

  • AWS_ACCESS_KEY_ID
  • AWS_SECRET_ACCESS_KEY
  • ARTIFACTS_BUCKET_NAME
  • ARTIFACTS_BASE_URL (optional)
  • GITHUB_TOKEN (optional)
  • BITBUCKET_TOKEN (optional)

Usage

To upload artifacts to the configured S3 bucket use the build-acp command.

build-acp /source/path/

There is no file browsing capability available for private S3 buckets.
An index.html file is used as the directory index, however it has to be created/generated manually.
When uploading a prepared artifacts folder with the index.html file in it, add a trailing slash to the source path to upload the contents of the source folder vs the folder itself.

You can upload additional folders/files by running the command multiple times.

The optional destination argument can be used to define a subdirectory at the destination in the bucket.

build-acp /source/path/ destination/path

Advanced usage

Base URL

The base URL is derived from ARTIFACTS_BUCKET_NAME as follows (assuming AWS S3 us-east-1 region by default):

https://${ARTIFACTS_BUCKET_NAME}.s3.amazonaws.com

It can be overridden via the optional ARTIFACTS_BASE_URL configuration variable at the organization/repo level:

ARTIFACTS_BASE_URL = https://artifacts.example.com

Upload path

The upload path is unique for each commit and is derived as follows:

${REPO_NAME_SAFE}/${BRANCH_NAME_SAFE}-${GIT_COMMIT_HASH}

In certain cases you may want to store build artifacts per branch instead of per commit.
To do this, override the ARTIFACTS_BUCKET_PATH variable before calling the build-acp command:

export ARTIFACTS_BUCKET_PATH="${REPO_NAME_SAFE}/${BRANCH_NAME_SAFE}"
build-acp my-artifacts/

Posting build artifact URLs to Bitbucket

If BITBUCKET_TOKEN is set, the URL to the artifacts will be posted back to Bitbucket via Bitbucket Build Status API.

Security

If a bucket does not exist, it will be created automatically (with no public access). Existing bucket access permissions are not automatically adjusted. It's up to you whether you want to keep them open or not.

When artifacts are uploaded, the destination artifact folder in the bucket is set to be publicly accessible. Anyone with the direct link will be able to access the artifacts, but will not be able to browse the list of all available artifact folders in the bucket (so long as the bucket itself is set to be private).

The URL by default includes a git commit hash, which serves as an authentication token (the URL is impossible to guess). This provides a simple yet efficient level of security for artifacts.

To add an additional level of security follow this guide to set up username/password access to S3 via CloudFront and Lambda@Edge.

Feature: Non-volatile environments

By combining the following configuration options you can get low overhead non-volatile environments.

SANDBOX_DOMAIN=<nice-domain>
SANDBOX_PERMANENT=true
REMOTE_CODEBASE_METHOD=git
REMOTE_BUILD_DIR_CLEANUP=0

Such environments can be used for non-critical production-ish workloads, whenever an on-demand delayed start (5-10s delay) is not a concern.

Feature: Secrets in environment variables

It is best security practice not to store secrets such as API keys in a code repository. Many CI systems already have the ability to set such environment variables during the build process. Any environment variables set at build time whose name starts with SECRET_ will be forwarded as-is to the built environment.

ci-agent's People

Contributors

achekulaev avatar aczietlow avatar haixiang avatar lmakarov avatar lpeabody avatar ms-marcus avatar phoang11 avatar savoiringfaire avatar sean-e-dietrich avatar sergey-zabolotny avatar shelane avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

ci-agent's Issues

Unable to install the latest version of squizlabs/php_codesniffer & drupal/coder

Problem:

I want to use the latest stable version (8.12) the coder module, as it has several bug fixes causing the code sniffer to throw false negatives. For example : To allow PHP 7 primitive type hints. (fixed in version 8.9)

I'm unable to install the latest version due to unmet php dependencies.

Loading composer repositories with package information
Updating dependencies (including require-dev)
Your requirements could not be resolved to an installable set of packages.

  Problem 1
    - squizlabs/php_codesniffer 2.9.1 requires ext-xmlwriter * -> the requested PHP extension xmlwriter is missing from your system.
    - squizlabs/php_codesniffer 2.9.0 requires ext-xmlwriter * -> the requested PHP extension xmlwriter is missing from your system.
    - squizlabs/php_codesniffer 2.8.1 requires ext-xmlwriter * -> the requested PHP extension xmlwriter is missing from your system.
    - drupal/coder 8.2.12 requires squizlabs/php_codesniffer >=2.8.1 <3.0 -> satisfiable by squizlabs/php_codesniffer[2.8.1, 2.9.0, 2.9.1].
    - Installation request for drupal/coder 8.2.12 -> satisfiable by drupal/coder[8.2.12].

  To enable extensions, verify that they are enabled in your .ini files:
    - /etc/php7/php.ini
    - /etc/php7/conf.d/00_ctype.ini
    - /etc/php7/conf.d/00_curl.ini
    - /etc/php7/conf.d/00_dom.ini
    - /etc/php7/conf.d/00_json.ini
    - /etc/php7/conf.d/00_mbstring.ini
    - /etc/php7/conf.d/00_openssl.ini
    - /etc/php7/conf.d/00_simplexml.ini
    - /etc/php7/conf.d/00_tokenizer.ini
    - /etc/php7/conf.d/00_xml.ini
    - /etc/php7/conf.d/00_zlib.ini
    - /etc/php7/conf.d/01_phar.ini
  You can also run `php --ini` inside terminal to see which files are used by PHP in CLI mode.

Solution:

Install php7-xmlwriter in the php pipeline container

build-init fails with error code 1

Affected ci-agent v1.3
Error occurs when no environment variable defined with a name beginning with SECRET_.

Fix: in file build-init replace line secrets="$(env | grep 'SECRET_')" with line secrets="$(env | grep 'SECRET_')" || true

source build-env fails with error code 1

Affected ci-agent v1.6

#!/bin/bash -eo pipefail
source build-env
Exited with code 1

/usr/local/bin/build-env: pop_scope: head of shell_variables not a temporary environment scope

Add gitlab support

The pipeline agent currently supports Bitbucket and Circle CI. Let's add Gitlab to the list

Domain names should be all lowercase

Per https://en.wikipedia.org/wiki/Domain_name:

Domain names may be formed from the set of alphanumeric ASCII characters (a-z, A-Z, 0-9), but characters are case-insensitive. In addition the hyphen (U+002D) is permitted if it is surrounded by characters, digits or hyphens, although it is not to start or end a label. Labels are always separated by the full stop (period) character in the textual name representation.

Even though uppercase letters are allowed in domain names, modern browsers convert domain names to all lowercase. In nginx, server_name is case sensitive and uppercase letters in it will always result in a virtual host miss.

In docksal/ci-agent domain (virtual host's server_name) is generated as $BRANCH_NAME_SAFE.$REPO_NAME_SAFE.$DOCKSAL_DOMAIN

The lowercase conversion is only applied to BRANCH_NAME_SAFE.
It should also be applied to REPO_NAME_SAFE and DOCKSAL_DOMAIN.

Related to docksal/docksal#430

Docksal CI Agent on GitLab issues

I use https://github.com/docksal/ci-agent/blob/develop/README.md as an instruction to establish Docksal CI Agent on GitLab. I have a sandbox server in Digital Ocean,

  1. I set up DOCKSAL_HOST_SSH_KEY as a variable in GitLab CI / CD Setting which contains private key for the Sandbox server build account. Is this correct? I have this

image

  1. There is no GitLab example in Project configuration. I suggest adding such an example to the README.md.

I use the following .gitlab-ci.yml:

build_test:
  image: docksal/ci-agent:php
  script:
    - source build-env  # Initialize the agent configuration
    - build-init  # Initialize the remote sandbox environment
    - build-exec "cd www && fin drush st"  # Test performing within the build 
  when: manual

Access to the Stage Server - SSH Permission denied

I want to run a remote script on my Stage server from the Bitbucket Docker Machine.

  1. I have an Public Key in Bitbucket Pipeline settings.
  2. I added this key to the Stage Server authorized_keys file.
  3. I created a Pipeline Environment Variable CI_SSH_KEY wich contains the value of this key.
  4. I have the pipeline.
image: docksal/bitbucket-pipelines-agent

pipelines:
  custom: # Pipelines that are triggered manually
    test:
      - step:
          script:
            - ssh [email protected] echo 'Run Test Pipeline'

I have such error:

 ssh [email protected] echo 'Run Test Pipeline'
Load key "/opt/atlassian/pipelines/agent/data/id_rsa": Permission denied
Permission denied, please try again.
Permission denied, please try again.
Permission denied (publickey,password).

What is wrong?

CircleCI Configuration

Workflows are not supported for free tier. Need to add variables to projects individually.

docksal/ci-agent v1.11.0 creates bitbucket pipeline code deployment issues for projects which use composer version 1

In our project we were using image: docksal/ci-agent:edge-php which uses latest development version. And with recent docksal image release docksal/ci-agent v1.11.0 switches Composer version from v1 to v2 in the php flavor of the image. This created a problem with our project build and Drush unable to detect aliaseswhen doing acquia deployments.

Errors:

  1. Source build error
  • source build-env
    bash: build-env: No such file or directory
  1. Drush Could not find the alias @myproject.test.platform

What i observed was drush could not find alias was because of my project was using Composer v1 but docksal/ci-agent v1.11.0 release uses composer v2 this created an issue.

Temporary Workaround : Pinning image version to the previous stable release (1.10) instead of edge (which points to the dev version):image: docksal/ci-agent:1.10-php

Thanks
Manjunath

Having issues with bitbucket pipelines after upgrading DRUSH 10

Recently we upgraded to DRUSH 10and after that we are having issues with bitbucket pipelines which is been used to deploy acquia server.
All Acquia relates drush commands are failing, please find the below details.
Using image: docksal/ci-agent:1.10-php

Please find the below command and error.

drush @test.platform --email=[email protected] --key=asdfashfasd --format=json ac-code-path-deploy release/10.2021.01

The drush command 'ac-code-path-deploy release/10.2021.01' could not [error] be found. Run drush cache-clear drush to clear the commandfile cache if you have installed new extensions.

Thanks

Support GitHub Actions

  • Add support for running docksal/ci-agent in Github Actions jobs
  • Update docs and examples

Setting REMOTE_BUILD_DIR

When setting up a remote machine having the ability to set the REMOTE_BUILD_DIR or allowing any other directory instead of /home/ubuntu/builds/

Allow settings SSH_PORT for docker-host

It is currently not possible to set another SSH_PORT for the docker-host then 22.

Current workaround in CI configuration:
- source /usr/local/bin/build-env && sed -i "s/HostName $DOCKSAL_HOST/HostName $DOCKSAL_HOST\nPort 22xx/g" $HOME/.ssh/config

Would be nice to have this supported in the ci-agent itself via Environment variables as $DOCKSAL_HOST.

Add php7-posix package to PHP version of image.

Image Version: docksal/ci-agent:1.6-php

This might be a niche issue, but when using Pantheon's Terminus command line tool to execute drush commands, it doesn't pipe the output to stdout as expected.

Instead, you just get a really generic message with an exit code when the command completes. like:
Command: mysite.dev -- drush status [Exit: 0]

It makes debugging really challenging, and can also cause some issues with timeouts on longer running scripts, since Pantheon kills the connection if no output is detected after 10 minutes.

It looks like installing the php7-posix package for Alpine Linux in my CircleCI job resolves the issue for me.
sudo apk add php7-posix

It would be great to have this package installed as part of the base image so it works out of the box.

Permission denied (publickey) with CI_SSH_KEY in CircleCI builds

Symptoms:

Cloning into '/home/agent/target'...
*********[email protected]: Permission denied (publickey).
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.

They key in ~/.ssh/id_rsa matches the private key configured via CI_SSH_KEY. The remote server is properly configured with the matching public key, yet the SSH connection responds with "Permission denied (publickey)".

Undocumented Variables

Variables found within the base scripts that have not been documented:

  • DOCKSAL_HOST_USER
  • GIT_USER_EMAIL
  • GIT_USER_NAME

Github Action workflow: bad function name

When using docksal/ci-agent:latest OR docksal/ci-agent:edge-php and using the github workflow example.

name: Docksal sandbox

on:
  workflow_dispatch:

jobs:
  build:
    runs-on: ubuntu-latest
    container:
      image: docksal/ci-agent:edge-php
    env:
      CI_SSH_KEY: ${{ secrets.CI_SSH_KEY }}
      DOCKSAL_HOST_IP: ${{ secrets.DOCKSAL_HOST_IP }}
      DOCKSAL_HOST_SSH_KEY: ${{ secrets.DOCKSAL_HOST_SSH_KEY }}
      GITHUB_TOKEN: ${{ github.token }}
      REMOTE_CODEBASE_METHOD: git
    steps:
      - name: Build sandbox
        run: |
          source build-env
          sandbox-init

Got the following error;
/__w/_temp/088f377d-c351-4fb2-a72b-53e3f1b60aa4.sh: /usr/local/bin/build-env: line 32: syntax error: bad function name Error: Process completed with exit code 2.

Support Git tags as well as branches

There doesn't seem to be any support for running ci-agent against tags. Branches are good but being able to build a sandbox based off a tag would be extremely helpful.

I have some thoughts around how I would do this, based on existing convention set in the project's code. Before I get started with it however, I'm wondering:

  1. Was there a specific reason tags aren't supported?
  2. If a previous attempt was made to include support for tagging, what were the difficulties surrounding it's implementation that inevitably lead to the feature not being supported?

Asking just so I know what issues I can expect to run into.

EDIT: It's probably worth mentioning this issue arises from a Bitbucket Pipelines project. It's possible this is a specific issue with Bitbucket. I have not used CI Agent on other systems.

DOCKSAL_HOST_SSH_PORT error when cloning repo

On the edge-php version I'm now getting this error

Cloning into '.'...
/home/agent/.ssh/config line 16: Bad port 'DOCKSAL_HOST_SSH_PORT'.
fatal: Could not read from remote repository.

reverting to stable version php has fixed the issue.

Create a Bitbucket Pipe

Bitbucket has just announced Bitbucket Pipes. Essentially, Pipes are the same things as Orbs in CircleCI.

We should add a Pipe for Docksal CI Agent. Instructions here.

ERROR: The key you are authenticating with has been marked as read only

Error occurs in case the code in the GitHub repo is about to change (git push). By default, CircleCI connects to GitHub using its own self-generated ssh key in read only mode. There is no way to change the key's mode to be r/w.

If you want to use your own ssh key with r/w permissions which is defined by the variable CI_SSH_KEY in CircleCI env or any other key added to the system, you can use one of the following methods:

  1. Remove all existing keys from ssh-agent (ssh-add -D) before git push command
  2. Add "IdentitiesOnly=yes" to your ~/.ssh/config into section "Host *"

Doing above, the system will try to pick a key from files ~/.ssh/(id_rsa|id_dsa|id_ecdsa|id_ed25519) or the by IdentityFile directive.

Allow settings a custom domain via an environment variable

Currently, the agent derives a sandbox domain from a git branch name and DOCKSAL_HOST (or DOCKSAL_DOMAIN).

It should be possible to manually set the resulting sandbox domain via the SANDBOX_DOMAIN environment variable. When set, it takes precedence over the automatically generated domain name for a sandbox environment.

This can be used for sandbox environments which need a custom (nice) domain name.
Coupled with SANDBOX_PERMANENT=true, this can be used for low overhead, production-ish or demo environments, where the on-demand (delayed) start is not a concern.

CircleCI: manifest for docksal/ci-agent:php not found

Trying to use the following image in my CircleCI configuration produces a not found error

Error message from CircleCI

Build-agent version 0.0.4645-fabac8a (2018-01-11T16:13:11+0000)
Starting container docksal/ci-agent:php
  image cache not found on this host, downloading docksal/ci-agent:php
Error response from daemon: manifest for docksal/ci-agent:php not found

CircleCI config.yml

defaults: &defaults
  working_directory: /home/agent/build
  docker:
    - image: docksal/ci-agent:php
  environment:
     BASH_ENV: /home/agent/.bashrc  # Tell CircleCI where to read the shared build environment variables from
  steps:
    - checkout

version: 2

jobs:
  sandbox:
    <<: *defaults
    steps:
      - run:
          name: Configure local build environment
          command: |
            touch $BASH_ENV
            echo 'source build-env' >> $BASH_ENV
      - run:
          name: Exporting Terminus Token
          command: ssh docker-host "cd $REMOTE_BUILD_DIR && echo TERMINUS_TOKEN=${TERMINUS_TOKEN} | tee -a .docksal/docksal-local.env"
      - run:
          name: Sandbox provisioning
          command: |
            slack "Started sandbox build for branch *${GIT_BRANCH_NAME}*"
            build-notify pending
            build-init
            ssh docker-host "cd $REMOTE_BUILD_DIR && fin init"
            slack "Completed sandbox build for branch *${GIT_BRANCH_NAME}*:\n<http://${DOMAIN}|http://${DOMAIN}>"
            if [[ $? == 0 ]]; then build-notify success; else build-notify failure; fi
  deploy:
    <<: *defaults
    steps:
      - run:
          name: Installing Terminus
          command: |
            composer -n global require -n "hirak/prestissimo:^0.3"
            /usr/bin/env COMPOSER_BIN_DIR=$HOME/bin composer -n --working-dir=$HOME require pantheon-systems/terminus "^1"
      - run:
          name: Deploying to provider
          command: |
            echo "Hello";

workflows:
  version: 2
  build_sandbox:
    jobs:
      - sandbox:
          filters:
            branches:
              ignore: master
          context: org-global

  deployment:
    jobs:
      - deploy:
          filters:
            branches:
              only: master
          context: org-global

Drupal 8.5.0 requires ext-gd

Starting from 8.5.0 the ext-gd extension is required, so when running composer install, it verifies if the extension is present on the agent and fails when it can't find it.
A temporary fix is to make composer ignore platform requirements with
composer install --prefer-dist --no-interaction --ignore-platform-reqs, but in a long run we probably need GD on the agent.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.