Skip to content

Commit

Permalink
Merge pull request #206 from docksal/develop
Browse files Browse the repository at this point in the history
Release 2.13.0
  • Loading branch information
lmakarov authored Dec 12, 2020
2 parents 743811d + e98bb10 commit 813fcbb
Show file tree
Hide file tree
Showing 11 changed files with 335 additions and 74 deletions.
44 changes: 44 additions & 0 deletions .github/scripts/docker-tags.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
#!/usr/bin/env bash

# Generates docker images tags for the docker/build-push-action@v2 action depending on the branch/tag.

declare -a IMAGE_TAGS

# feature/* => sha-xxxxxxx
# Note: disabled
#if [[ "${GITHUB_REF}" =~ "refs/heads/feature/" ]]; then
# GIT_SHA7=$(echo ${GITHUB_SHA} | cut -c1-7) # Short SHA (7 characters)
# IMAGE_TAGS+=("${REPO}:sha-${GIT_SHA7}-php${VERSION}")
# IMAGE_TAGS+=("ghcr.io/${REPO}:sha-${GIT_SHA7}-php${VERSION}")
#fi

# develop => edge
if [[ "${GITHUB_REF}" == "refs/heads/develop" ]]; then
IMAGE_TAGS+=("${REPO}:edge-php${VERSION}")
IMAGE_TAGS+=("ghcr.io/${REPO}:edge-php${VERSION}")
fi

# master => stable
if [[ "${GITHUB_REF}" == "refs/heads/master" ]]; then
IMAGE_TAGS+=("${REPO}:stable-php${VERSION}")
IMAGE_TAGS+=("ghcr.io/${REPO}:stable-php${VERSION}")
fi

# tags/v1.0.0 => 1.0
if [[ "${GITHUB_REF}" =~ "refs/tags/" ]]; then
# Extract version parts from release tag
IFS='.' read -a ver_arr <<< "${GITHUB_REF#refs/tags/}"
VERSION_MAJOR=${ver_arr[0]#v*} # 2.7.0 => "2"
VERSION_MINOR=${ver_arr[1]} # "2.7.0" => "7"
IMAGE_TAGS+=("${REPO}:stable-php${VERSION}")
IMAGE_TAGS+=("${REPO}:${VERSION_MAJOR}-php${VERSION}")
IMAGE_TAGS+=("${REPO}:${VERSION_MAJOR}.${VERSION_MINOR}-php${VERSION}")
IMAGE_TAGS+=("ghcr.io/${REPO}:stable-php${VERSION}")
IMAGE_TAGS+=("ghcr.io/${REPO}:${VERSION_MAJOR}-php${VERSION}")
IMAGE_TAGS+=("ghcr.io/${REPO}:${VERSION_MAJOR}.${VERSION_MINOR}-php${VERSION}")
fi

# Output a comma concatenated list of image tags
IMAGE_TAGS_STR=$(IFS=,; echo "${IMAGE_TAGS[*]}")
echo "${IMAGE_TAGS_STR}"
echo "::set-output name=tags::${IMAGE_TAGS_STR}"
149 changes: 149 additions & 0 deletions .github/workflows/default.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,149 @@
name: Default (push)

on:
push:
branches:
- master
- develop
- feature/*
tags:
- v*

defaults:
run:
shell: bash

env:
REPO: docksal/cli
LATEST_VERSION: 7.3
DOCKSAL_VERSION: develop

jobs:
build-test-push:
name: Build, Test, Push
runs-on: ubuntu-20.04

strategy:
fail-fast: false # Don't cancel other jobs if one fails
matrix:
version:
- 7.3
- 7.4

steps:
-
name: Install prerequisites for tests
run: |
set -xeuo pipefail
sudo apt-get -qq update
# Install cgi-fcgi binary used in tests
sudo apt-get -y --no-install-recommends install libfcgi-bin
# Install bats for tests
git clone https://github.com/bats-core/bats-core.git
cd bats-core
sudo ./install.sh /usr/local
bats -v
-
name: Checkout
uses: actions/checkout@v2
-
name: Set up QEMU
uses: docker/setup-qemu-action@v1
-
name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
-
name: Check Docker
run: |
docker version
docker info
-
name: Login to DockerHub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
-
name: Login to GitHub Container Registry
uses: docker/login-action@v1
with:
registry: ghcr.io
username: ${{ secrets.GHCR_USERNAME }}
password: ${{ secrets.GHCR_TOKEN }}
# -
# name: Build
# working-directory: ${{ matrix.version }}
# run: make buildx-with-cache
-
# Build for local use
name: Build and cache image (local)
id: docker_build
uses: docker/build-push-action@v2
with:
context: ${{ matrix.version }}
file: ${{ matrix.version }}/Dockerfile
#platforms: linux/amd64,linux/arm64
tags: ${{ env.REPO }}:build-php${{ matrix.version }} # Tag used locally in tests
load: true # cache image locally for use by other steps
#push: true # cannot use "push" together with "load"
cache-from: type=registry,ref=ghcr.io/${{ env.REPO }}:build-php${{ matrix.version }}
cache-to: type=inline # Write the cache metadata into the image configuration
-
# Print image info
name: Image info
run: |
set -xeuo pipefail
docker image ls | grep "${{ env.REPO }}"
docker image inspect "${{ env.REPO }}:build-php${{ matrix.version }}"
-
# Cache image layers in the registry
name: Build and cache (ghcr.io)
uses: docker/build-push-action@v2
with:
context: ${{ matrix.version }}
file: ${{ matrix.version }}/Dockerfile
#platforms: linux/amd64,linux/arm64
tags: ghcr.io/${{ env.REPO }}:build-php${{ matrix.version }} # Build cache tag in ghcr.io
push: ${{ github.event_name != 'pull_request' }} # Don't push for PRs
cache-to: type=inline # Write the cache metadata into the image configuration
-
# Run tests
name: Test
working-directory: ${{ matrix.version }}
env:
SECRET_PLATFORMSH_CLI_TOKEN: ${{ secrets.SECRET_PLATFORMSH_CLI_TOKEN }}
SECRET_TERMINUS_TOKEN: ${{ secrets.SECRET_TERMINUS_TOKEN }}
run: make test
-
# Generate image meta information
name: Image tags
id: docker_tags
working-directory: ${{ matrix.version }}
env:
VERSION: ${{ matrix.version }}
run: make tags
# -
# # Push image to registries
# name: Push image (Docker Hub and GitHub Container Registry)
# working-directory: ${{ matrix.version }}
# run: make release
-
# Push image to registries
name: Push image to registries
id: docker_push
# Don't run if the list of tags is empty
# Tags are only generated for develop, master and release tag builds
if: ${{ steps.docker_tags.outputs.tags != '' }}
uses: docker/build-push-action@v2
with:
context: ${{ matrix.version }}
file: ${{ matrix.version }}/Dockerfile
#platforms: linux/amd64,linux/arm64
# Tag and push to Docker Hub and GitHub Container Registry
tags: ${{ steps.docker_tags.outputs.tags }}
labels: |
org.opencontainers.image.source=${{ github.event.repository.html_url }}
org.opencontainers.image.created=${{ steps.prep.outputs.created }}
org.opencontainers.image.revision=${{ github.sha }}
push: ${{ github.event_name != 'pull_request' }} # Don't push for PRs
cache-to: type=inline # Write the cache metadata into the image configuration
5 changes: 1 addition & 4 deletions .travis.yml → .travis-legacy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,8 @@ install:
- fin sysinfo

script:
# Pull the latest edge image to speed up builds (hoping for image layer cache hits)
- docker pull ${REPO}:edge-php${VERSION} || true
# Build the base image
- cd ${TRAVIS_BUILD_DIR}/${VERSION}
- travis_retry make # Retry builds, as pecl.php.net tends to time out often
- travis_retry make build # Retry builds, as pecl.php.net tends to time out often
- make test

after_success:
Expand Down
34 changes: 18 additions & 16 deletions 7.3/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -227,18 +227,18 @@ RUN set -xe; \

# PHP tools (installed globally)
ENV COMPOSER_DEFAULT_VERSION=2 \
COMPOSER_VERSION=1.10.17 \
COMPOSER2_VERSION=2.0.6 \
COMPOSER_VERSION=1.10.19 \
COMPOSER2_VERSION=2.0.8 \
DRUSH_VERSION=8.4.5 \
DRUSH_LAUNCHER_VERSION=0.8.0 \
# Pinned at 1.1.2 due to binaries not available for more recent releases on Github
DRUPAL_CHECK_VERSION=1.1.2 \
DRUPAL_CONSOLE_LAUNCHER_VERSION=1.9.4 \
DRUPAL_CONSOLE_LAUNCHER_VERSION=1.9.7 \
WPCLI_VERSION=2.4.0 \
BLACKFIRE_VERSION=1.44.1 \
PLATFORMSH_CLI_VERSION=3.63.0 \
ACQUIACLI_VERSION=2.0.9 \
TERMINUS_VERSION=2.4.1
PLATFORMSH_CLI_VERSION=3.63.3 \
ACQUIA_CLI_VERSION=1.3.0 \
TERMINUS_VERSION=2.4.1 \
JQ_VERSION=1.6 \
YQ_VERSION=3.4.1
RUN set -xe; \
# Composer 1.x
curl -fsSL "https://github.com/composer/composer/releases/download/${COMPOSER_VERSION}/composer.phar" -o /usr/local/bin/composer1; \
Expand All @@ -256,16 +256,18 @@ RUN set -xe; \
curl -fsSL "https://packages.blackfire.io/binaries/blackfire-agent/${BLACKFIRE_VERSION}/blackfire-cli-linux_static_amd64" -o /usr/local/bin/blackfire; \
# Platform.sh CLI
curl -fsSL "https://github.com/platformsh/platformsh-cli/releases/download/v${PLATFORMSH_CLI_VERSION}/platform.phar" -o /usr/local/bin/platform; \
# Drupal Check CLI
curl -fsSL "https://github.com/mglaman/drupal-check/releases/download/${DRUPAL_CHECK_VERSION}/drupal-check.phar" -o /usr/local/bin/drupal-check; \
# Acquia CLI
curl -fsSL "https://github.com/typhonius/acquia_cli/releases/download/${ACQUIACLI_VERSION}/acquiacli.phar" -o /usr/local/bin/acquiacli; \
curl -fsSL "https://github.com/acquia/cli/releases/download/${ACQUIA_CLI_VERSION}/acli.phar" -o /usr/local/bin/acli; \
# Pantheon Terminus
curl -fsSL "https://github.com/pantheon-systems/terminus/releases/download/${TERMINUS_VERSION}/terminus.phar" -o /usr/local/bin/terminus; \
# jq
curl -fsSL "https://github.com/stedolan/jq/releases/download/jq-${JQ_VERSION}/jq-linux64" -o /usr/local/bin/jq; \
# yq
curl -fsSL "https://github.com/mikefarah/yq/releases/download/${YQ_VERSION}/yq_linux_amd64" -o /usr/local/bin/yq; \
# Set Default Composer Version
ln -s /usr/local/bin/composer${COMPOSER_DEFAULT_VERSION} /usr/local/bin/composer; \
# Make all downloaded binaries executable in one shot
(cd /usr/local/bin && chmod +x composer1 composer2 drupal-check drush8 drush drupal wp blackfire platform acquiacli terminus);
(cd /usr/local/bin && chmod +x composer1 composer2 drush8 drush drupal wp blackfire platform acli terminus jq yq);

# All further RUN commands will run as the "docker" user
USER docker
Expand Down Expand Up @@ -312,8 +314,8 @@ $HOME/.composer/vendor/phpcompatibility/phpcompatibility-paragonie/PHPCompatibil

# Node.js (installed as user)
ENV \
NVM_VERSION=0.36.0 \
NODE_VERSION=14.15.0 \
NVM_VERSION=0.37.2 \
NODE_VERSION=14.15.1 \
YARN_VERSION=1.22.10
# Don't use -x here, as the output may be excessive
RUN set -e; \
Expand Down Expand Up @@ -451,11 +453,11 @@ USER docker
ARG HOME=/home/docker

ENV \
CODE_SERVER_VERSION=3.6.1 \
CODE_SERVER_VERSION=3.7.4 \
VSCODE_HOME="${HOME}/code-server" \
VSCODE_EXT_DIRECTORY="${HOME}/code-server/extensions" \
VSCODE_XDEBUG_VERSION=1.13.0 \
VSCODE_GITLENS_VERSION=10.2.2
VSCODE_GITLENS_VERSION=11.0.6

# Install code-server
RUN \
Expand Down
12 changes: 11 additions & 1 deletion 7.3/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,14 @@ VOLUMES += -v /home/docker
.PHONY: build test push shell run start stop logs clean release

build:
docker build --cache-from=$(REPO):edge-$(SOFTWARE_VERSION) -t $(REPO):$(BUILD_TAG) .
docker build -t $(REPO):$(BUILD_TAG) .

# See https://docs.docker.com/buildx/working-with-buildx/
# See https://github.com/docker/buildx
buildx:
docker buildx build --tag $(REPO):$(BUILD_TAG) .
buildx-with-cache:
docker buildx build --cache-from=type=registry,ref=ghcr.io/$(REPO):$(BUILD_TAG) --cache-to=type=inline --tag=$(REPO):$(BUILD_TAG) .

test:
IMAGE=$(REPO):$(BUILD_TAG) NAME=$(NAME) VERSION=$(VERSION) ../tests/test.bats
Expand Down Expand Up @@ -54,6 +61,9 @@ logs-follow:
clean:
docker rm -vf $(NAME) >/dev/null 2>&1 || true

tags:
@../.github/scripts/docker-tags.sh

release:
@../scripts/docker-push.sh

Expand Down
22 changes: 21 additions & 1 deletion 7.3/startup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,8 @@ render_tmpl ()

if [[ -f "${tmpl}" ]]; then
echo-debug "Rendering template: ${tmpl}..."
gomplate --file "${tmpl}" --out "${file}"
# gomplate started throwing an empty line into stderr in v3.7.0, so we have to mute it below
gomplate --file "${tmpl}" --out "${file}" &>/dev/null
else
echo-debug "Error: Template file not found: ${tmpl}"
return 1
Expand Down Expand Up @@ -129,6 +130,22 @@ terminus_login ()
fi
}

# Acquia CLI login
acli_login ()
{
echo-debug "Authenticating with Acquia..."
# This has to be done using the docker user via su to load the user environment
# Note: Using 'su -l' to initiate a login session and have .profile sourced for the docker user
local command="acli auth:login --key='${ACQUIA_CLI_KEY}' --secret='${ACQUIA_CLI_SECRET}' --no-interaction"
local output=$(su -l docker -c "${command}" 2>&1)
if [[ $? != 0 ]]; then
echo-debug "ERROR: Acquia authentication failed."
echo
echo "$output"
echo
fi
}

# Git settings
git_settings ()
{
Expand Down Expand Up @@ -177,6 +194,9 @@ chown "${HOST_UID:-1000}:${HOST_GID:-1000}" /var/www
# Automatically authenticate with Pantheon if Terminus token is present
[[ "$TERMINUS_TOKEN" != "" ]] && terminus_login

# Authenticate to Acquia CLI
[[ "$ACQUIA_CLI_KEY" != "" ]] && [[ "$ACQUIA_CLI_SECRET" != "" ]] && acli_login

# If crontab file is found within project add contents to user crontab file.
if [[ -f ${PROJECT_ROOT}/.docksal/services/cli/crontab ]]; then
echo-debug "Loading crontab..."
Expand Down
Loading

0 comments on commit 813fcbb

Please sign in to comment.