From 5397b9b51be562d1fd33989d26ea7c80708afac9 Mon Sep 17 00:00:00 2001 From: Leonid Makarov Date: Fri, 11 Feb 2022 14:18:10 -0800 Subject: [PATCH 1/4] Dropped MariabDB 10.2 EOL as of 23 May 2022 --- .github/workflows/docker-build-push.yaml | 1 - 10.2/default.cnf | 20 -------------------- 10.2/mysql-variables.txt | 17 ----------------- README.md | 1 - 4 files changed, 39 deletions(-) delete mode 100644 10.2/default.cnf delete mode 100644 10.2/mysql-variables.txt diff --git a/.github/workflows/docker-build-push.yaml b/.github/workflows/docker-build-push.yaml index a2d3d4c..67d560a 100644 --- a/.github/workflows/docker-build-push.yaml +++ b/.github/workflows/docker-build-push.yaml @@ -26,7 +26,6 @@ jobs: fail-fast: false # Don't cancel other jobs if one fails matrix: version: - - 10.2 - 10.3 - 10.4 - 10.5 diff --git a/10.2/default.cnf b/10.2/default.cnf deleted file mode 100644 index b403a1b..0000000 --- a/10.2/default.cnf +++ /dev/null @@ -1,20 +0,0 @@ -[mysqld] -# Force utf8mb4 (multi-byte UTF) encoding (supports emojis, Asian symbols, mathematical symbols, etc.) -# Starting with mariadb 10.5, character-set-server and collation-server can only be set via command line arguments. -#character-set-server = utf8mb4 -#collation-server = utf8mb4_unicode_ci - -# Always use server character set settings -skip-character-set-client-handshake - -# Set innodb as default -default_storage_engine = InnoDB - -innodb_buffer_pool_size = 256M -innodb_log_buffer_size = 8M -innodb_log_file_size = 128MB - -innodb_file_per_table = 1 - -# Max packets -max_allowed_packet = 128M diff --git a/10.2/mysql-variables.txt b/10.2/mysql-variables.txt deleted file mode 100644 index 1604038..0000000 --- a/10.2/mysql-variables.txt +++ /dev/null @@ -1,17 +0,0 @@ -character_set_client utf8mb4 -character_set_connection utf8mb4 -character_set_database utf8mb4 -character_set_filesystem binary -character_set_results utf8mb4 -character_set_server utf8mb4 -character_set_system utf8 -collation_connection utf8mb4_unicode_ci -collation_database utf8mb4_unicode_ci -collation_server utf8mb4_unicode_ci -default_storage_engine InnoDB -innodb_buffer_pool_size 268435456 -innodb_file_per_table ON -innodb_flush_log_at_trx_commit 1 -innodb_log_buffer_size 8388608 -innodb_log_file_size 134217728 -max_allowed_packet 134217728 diff --git a/README.md b/README.md index cad0606..48e8590 100644 --- a/README.md +++ b/README.md @@ -18,7 +18,6 @@ This image(s) is part of the [Docksal](http://docksal.io) image library. ## Versions -- `docksal/mariadb:10.2` - `docksal/mariadb:10.3` - `docksal/mariadb:10.4` - `docksal/mariadb:10.5`, `docksal/mariadb:latest` From fa278b768506d09dc406aa53f53f6fe5f7957553 Mon Sep 17 00:00:00 2001 From: Leonid Makarov Date: Fri, 11 Feb 2022 14:18:25 -0800 Subject: [PATCH 2/4] Added MariaDB 10.6 Updated character_set_system variable value in tests for 10.6 - see https://stackoverflow.com/a/70717798 --- .github/workflows/docker-build-push.yaml | 1 + 10.6/default.cnf | 24 ++++++++++++++++++++++++ 10.6/mysql-variables.txt | 17 +++++++++++++++++ Makefile | 2 +- README.md | 3 ++- 5 files changed, 45 insertions(+), 2 deletions(-) create mode 100644 10.6/default.cnf create mode 100644 10.6/mysql-variables.txt diff --git a/.github/workflows/docker-build-push.yaml b/.github/workflows/docker-build-push.yaml index 67d560a..c44c65f 100644 --- a/.github/workflows/docker-build-push.yaml +++ b/.github/workflows/docker-build-push.yaml @@ -29,6 +29,7 @@ jobs: - 10.3 - 10.4 - 10.5 + - 10.6 env: IMAGE: docksal/mariadb UPSTREAM_IMAGE: mariadb diff --git a/10.6/default.cnf b/10.6/default.cnf new file mode 100644 index 0000000..2c66ed2 --- /dev/null +++ b/10.6/default.cnf @@ -0,0 +1,24 @@ +[mysqld] +# Force utf8mb4 (multi-byte UTF) encoding (supports emojis, Asian symbols, mathematical symbols, etc.) +# Starting with mariadb 10.5, character-set-server and collation-server can only be set via command line arguments. +#character-set-server = utf8mb4 +#collation-server = utf8mb4_unicode_ci + +# Always use server character set settings +skip-character-set-client-handshake + +# Set innodb as default +default_storage_engine = InnoDB + +innodb_buffer_pool_size = 256M +innodb_log_buffer_size = 8M +innodb_log_file_size = 128MB + +innodb_file_per_table = 1 + +# See https://github.com/docksal/service-db/pull/1 +#innodb_file_format = Barracuda +#innodb_large_prefix = 1 + +# Max packets +max_allowed_packet = 128M diff --git a/10.6/mysql-variables.txt b/10.6/mysql-variables.txt new file mode 100644 index 0000000..b81e9cc --- /dev/null +++ b/10.6/mysql-variables.txt @@ -0,0 +1,17 @@ +character_set_client utf8mb4 +character_set_connection utf8mb4 +character_set_database utf8mb4 +character_set_filesystem binary +character_set_results utf8mb4 +character_set_server utf8mb4 +character_set_system utf8mb3 +collation_connection utf8mb4_unicode_ci +collation_database utf8mb4_unicode_ci +collation_server utf8mb4_unicode_ci +default_storage_engine InnoDB +innodb_buffer_pool_size 268435456 +innodb_file_per_table ON +innodb_flush_log_at_trx_commit 1 +innodb_log_buffer_size 8388608 +innodb_log_file_size 134217728 +max_allowed_packet 134217728 diff --git a/Makefile b/Makefile index 6898c5c..ce80ae6 100644 --- a/Makefile +++ b/Makefile @@ -2,7 +2,7 @@ IMAGE ?= docksal/mariadb UPSTREAM_IMAGE ?= mariadb -VERSION ?= 10.5 +VERSION ?= 10.6 BUILD_TAG ?= build-$(VERSION) NAME = docksal-mariadb-$(VERSION) diff --git a/README.md b/README.md index 48e8590..f69631d 100644 --- a/README.md +++ b/README.md @@ -20,4 +20,5 @@ This image(s) is part of the [Docksal](http://docksal.io) image library. - `docksal/mariadb:10.3` - `docksal/mariadb:10.4` -- `docksal/mariadb:10.5`, `docksal/mariadb:latest` +- `docksal/mariadb:10.5` +- `docksal/mariadb:10.6`, `docksal/mariadb:latest` From 6df2e450d58fb4b7f4992ad75d1aec6983b59447 Mon Sep 17 00:00:00 2001 From: Leonid Makarov Date: Fri, 11 Feb 2022 14:43:55 -0800 Subject: [PATCH 3/4] Github Actions overhaul Split platform builds --- .github/scripts/docker-tag-delete.sh | 45 ++++ .github/scripts/docker-tags.sh | 77 ++++-- .github/workflows/default.yaml | 311 +++++++++++++++++++++++ .github/workflows/docker-build-push.yaml | 178 ------------- Dockerfile | 3 +- Makefile | 58 +++-- 6 files changed, 445 insertions(+), 227 deletions(-) create mode 100755 .github/scripts/docker-tag-delete.sh create mode 100644 .github/workflows/default.yaml delete mode 100644 .github/workflows/docker-build-push.yaml diff --git a/.github/scripts/docker-tag-delete.sh b/.github/scripts/docker-tag-delete.sh new file mode 100755 index 0000000..7ec78a8 --- /dev/null +++ b/.github/scripts/docker-tag-delete.sh @@ -0,0 +1,45 @@ +#!/usr/bin/env bash + +# Deletes an image tag from Docker Hub +# +# Expects USER, PASSWORD +# Expects IMAGE:TAG as argument. +# +# Example: docker-tag-delete.sh docksal/cli:php7.3-build-01c92a2-amd64 + +# Credit: +# https://devopsheaven.com/docker/dockerhub/2018/04/09/delete-docker-image-tag-dockerhub.html + +set -euo pipefail + +# Get IMAGE and TAG from first argument +if [[ "${1}" == "" ]]; then + echo "Usage: ${0} image:tag" + exit 1 +else + # Split image:tag + IFS=$':' read IMAGE TAG <<< ${1}; + # Remove registry prefix from image if present + IMAGE=${IMAGE#"docker.io/"} +fi + +login_data() { +cat < image:[version_prefix][version-]edge[-version_suffix] +# master => image:[version_prefix][version][-][version_suffix] +# semver tag => image:[version_prefix][version-]major.minor[-version_suffix] -declare -a registryArr -registryArr+=("docker.io") # Docker Hub -registryArr+=("ghcr.io") # GitHub Container Registry +# Declare expected variables +IMAGE=${IMAGE} # docksal/cli +VERSION_PREFIX=${VERSION_PREFIX} # php +VERSION=${VERSION} # 7.4 +VERSION_SUFFIX=${VERSION_SUFFIX} # ide +REGISTRY="${REGISTRY}" # ghcr.io +GITHUB_REF=${GITHUB_REF} # refs/heads/develop, refs/heads/master, refs/tags/v1.0.0 +# Join arguments with hyphen (-) as a delimiter +# Usage: join [] +join() { + local IFS='-' # join delimiter + echo "$*" +} + +# Prints resulting image tags and sets output variable +set_output() { + local -n inputArr=${1} + + declare -a outputArr + for imageTag in ${inputArr[@]}; do + # Prepend registry to imageTag if provided + [[ "${REGISTRY}" != "" ]] && imageTag="${REGISTRY}/${imageTag}" + outputArr+=("${imageTag}") + done + + # Print with new lines for output in build logs + (IFS=$'\n'; echo "${outputArr[*]}") + # Using newlines in output variables does not seem to work, so we'll use comas + (IFS=$','; echo "::set-output name=tags::${outputArr[*]}") +} + +# Image tags declare -a imageTagArr -# feature/* => sha-xxxxxxx -# Note: disabled -#if [[ "${GITHUB_REF}" =~ "refs/heads/feature/" ]]; then -# GIT_SHA7=$(echo ${GITHUB_SHA} | cut -c1-7) # Short SHA (7 characters) -# imageTagArr+=("${IMAGE}:sha-${GIT_SHA7}-${VERSION}") -# imageTagArr+=("ghcr.io/${IMAGE}:sha-${GIT_SHA7}-${VERSION}") -#fi +## On every build => build / build-sha7 +## Latest build tag (used with cache-from) +#imageTagArr+=("${IMAGE}:$(join ${VERSION_PREFIX}${VERSION} ${VERSION_SUFFIX} build)") +## Specific build tag - SHA7 (first 7 characters of commit SHA) +#imageTagArr+=("${IMAGE}:$(join ${VERSION_PREFIX}${VERSION} ${VERSION_SUFFIX} build ${GITHUB_SHA:0:7})") # develop => version-edge if [[ "${GITHUB_REF}" == "refs/heads/develop" ]]; then - imageTagArr+=("${IMAGE}:${VERSION}-edge") + imageTagArr+=("${IMAGE}:$(join ${VERSION_PREFIX}${VERSION} edge ${VERSION_SUFFIX})") fi # master => version if [[ "${GITHUB_REF}" == "refs/heads/master" ]]; then - imageTagArr+=("${IMAGE}:${VERSION}") + imageTagArr+=("${IMAGE}:$(join ${VERSION_PREFIX}${VERSION} ${VERSION_SUFFIX})") fi # tags/v1.0.0 => 1.0 @@ -32,20 +63,12 @@ if [[ "${GITHUB_REF}" =~ "refs/tags/" ]]; then IFS='.' read -a release_arr <<< "${GITHUB_REF#refs/tags/}" releaseMajor=${release_arr[0]#v*} # 2.7.0 => "2" releaseMinor=${release_arr[1]} # "2.7.0" => "7" - imageTagArr+=("${IMAGE}:${VERSION}") - imageTagArr+=("${IMAGE}:${VERSION}-${releaseMajor}") - imageTagArr+=("${IMAGE}:${VERSION}-${releaseMajor}.${releaseMinor}") + imageTagArr+=("${IMAGE}:$(join ${VERSION_PREFIX}${VERSION} ${VERSION_SUFFIX})") + imageTagArr+=("${IMAGE}:$(join ${VERSION_PREFIX}${VERSION} ${releaseMajor} ${VERSION_SUFFIX})") + imageTagArr+=("${IMAGE}:$(join ${VERSION_PREFIX}${VERSION} ${releaseMajor}.${releaseMinor} ${VERSION_SUFFIX})") fi -# Build an array of registry/image:tag values -declare -a repoImageTagArr -for registry in ${registryArr[@]}; do - for imageTag in ${imageTagArr[@]}; do - repoImageTagArr+=("${registry}/${imageTag}") - done -done - -# Print with new lines for output in build logs -(IFS=$'\n'; echo "${repoImageTagArr[*]}") -# Using newlines in outputs variables does not seem to work, so we'll use comas -(IFS=$','; echo "::set-output name=tags::${repoImageTagArr[*]}") +# Note: imageTagArr is passed as variable name ("reference") and then expanded inside the called function +# See https://stackoverflow.com/questions/16461656/how-to-pass-array-as-an-argument-to-a-function-in-bash/26443029#26443029 +# DockerHub tags +set_output imageTagArr diff --git a/.github/workflows/default.yaml b/.github/workflows/default.yaml new file mode 100644 index 0000000..408ab40 --- /dev/null +++ b/.github/workflows/default.yaml @@ -0,0 +1,311 @@ +name: Build, Test, Push + +on: + schedule: + - cron: "0 10 * * 0" # Every Sunday at 10AM + push: + branches: + - master + - develop + - feature/* + tags: + - "v*.*.*" + workflow_dispatch: # Allow manually triggering a build + +defaults: + run: + shell: bash + +env: + IMAGE: docksal/mariabdb + #DOCKSAL_VERSION: develop + +jobs: + build: + name: "Build: ${{ matrix.version }}/${{ matrix.arch }}" + runs-on: ubuntu-20.04 + + strategy: + fail-fast: false # Don't cancel other jobs if one fails + matrix: + include: + - + arch: amd64 + version: "10.3" + - + arch: arm64 + version: "10.3" + - + arch: amd64 + version: "10.4" + - + arch: arm64 + version: "10.4" + - + arch: amd64 + version: "10.5" + - + arch: arm64 + version: "10.5" + - + arch: amd64 + version: "10.6" + - + arch: arm64 + version: "10.6" + + env: + ARCH: ${{ matrix.arch }} + VERSION_PREFIX: "" + VERSION: ${{ matrix.version }} + UPSTREAM_IMAGE: mariadb:${{ matrix.version }} + BUILD_DIR: "." + + steps: + - + name: Checkout + uses: actions/checkout@v2 + - + name: Environment variables + run: | + # Export variables for further steps + echo GIT_SHA7="${GITHUB_SHA:0:7}" | tee -a ${GITHUB_ENV} + echo BUILD_IMAGE_TAG="${IMAGE}:${VERSION_PREFIX}${VERSION}-build" | tee -a ${GITHUB_ENV} + # Pull the host public SSH key at runtime instead of relying on a static value stored in secrets. + echo ARM64_HOST_SSH_CERT="$(ssh-keyscan -t rsa ${{ secrets.ARM64_HOST }} 2>/dev/null)" | tee -a ${GITHUB_ENV} +# - +# # Switch docker context to a remote arm64 host +# # Used for building heavy images that take too long to build using QEMU + for native arm64 testing. +# name: Switch to arm64 builder host +# if: ${{ env.ARCH == 'arm64' }} +# uses: arwynfr/actions-docker-context@v2 +# with: +# docker_host: "ssh://ubuntu@${{ secrets.ARM64_HOST }}" +# context_name: arm64-host +# ssh_key: "${{ secrets.ARM64_HOST_SSH_KEY }}" +# ssh_cert: "${{ env.ARM64_HOST_SSH_CERT }}" +# use_context: true + - + 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 Docker Hub + uses: docker/login-action@v1 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + - + # Build and cache image in the registry + name: Build image + uses: docker/build-push-action@v2 + with: + context: ${{ env.BUILD_DIR }} + file: ${{ env.BUILD_DIR }}/Dockerfile + build-args: | + UPSTREAM_IMAGE=${{ env.UPSTREAM_IMAGE }} + VERSION=${{ env.VERSION }} + platforms: linux/${{ env.ARCH }} + # Push intermediate arch-specific build tag to repo + tags: ${{ env.BUILD_IMAGE_TAG }}-${{ env.GIT_SHA7 }}-${{ env.ARCH }} + push: ${{ github.event_name != 'pull_request' }} # Don't push for PRs + # BUILD_IMAGE_TAG - persistent multi-arch tag, updated at the end of the build (success or failure) + cache-from: type=registry,ref=${{ env.BUILD_IMAGE_TAG }} + cache-to: type=inline # Write the cache metadata into the image configuration + + test: + name: "Test: ${{ matrix.version }}/${{ matrix.arch }}" + runs-on: ubuntu-20.04 + needs: build + + strategy: + fail-fast: false # Don't cancel other jobs if one fails + matrix: + include: + - + arch: amd64 + version: "10.3" + # Disabled arm64 tests. + # TODO: Refactor tests to be compatible with a remote host test runner. + # TODO: Remember to re-enabled the test results check in "push". +# - +# arch: arm64 +# version: "10.3" + - + arch: amd64 + version: "10.4" +# - +# arch: arm64 +# version: "10.4" + - + arch: amd64 + version: "10.5" +# - +# arch: arm64 +# version: "10.5" + - + arch: amd64 + version: "10.6" +# - +# arch: arm64 +# version: "10.6" + + env: + ARCH: ${{ matrix.arch }} + VERSION_PREFIX: "" + VERSION: ${{ matrix.version }} + + steps: + - + name: Setup Bats + uses: mig4/setup-bats@v1 + with: + bats-version: "1.3.0" + - + name: Checkout + uses: actions/checkout@v2 + - + name: Environment variables + run: | + # Export variables for further steps + echo GIT_SHA7="${GITHUB_SHA:0:7}" | tee -a ${GITHUB_ENV} + echo BUILD_IMAGE_TAG="${IMAGE}:${VERSION_PREFIX}${VERSION}-build" | tee -a ${GITHUB_ENV} + # Pull the host public SSH key at runtime instead of relying on a static value stored in secrets. + echo ARM64_HOST_SSH_CERT="$(ssh-keyscan -t rsa ${{ secrets.ARM64_HOST }} 2>/dev/null)" | tee -a ${GITHUB_ENV} + - + # Switch docker context to a remote arm64 host + # Used for building heavy images that take too long to build using QEMU + for native arm64 testing. + name: Switch to arm64 builder host + if: ${{ env.ARCH == 'arm64' }} + uses: arwynfr/actions-docker-context@v2 + with: + docker_host: "ssh://ubuntu@${{ secrets.ARM64_HOST }}" + context_name: arm64-host + ssh_key: "${{ secrets.ARM64_HOST_SSH_KEY }}" + ssh_cert: "${{ env.ARM64_HOST_SSH_CERT }}" + use_context: true + - + name: Check Docker + run: | + docker version + docker info +# - +# name: Test preparations +# working-directory: ${{ env.BUILD_CONTEXT }} +# env: +# BUILD_IMAGE_TAG: ${{ env.BUILD_IMAGE_TAG }}-${{ env.GIT_SHA7 }}-${{ env.ARCH }} +# run: | +# # Install Docksal using the passed DOCKSAL_VERSION value +# curl -sSL http://get.docksal.io | bash +# # Start the service using the build image tag +# make start + - + # Run tests + name: Test + id: tests + working-directory: ${{ env.BUILD_DIR }} + env: + BUILD_IMAGE_TAG: ${{ env.BUILD_IMAGE_TAG }}-${{ env.GIT_SHA7 }}-${{ env.ARCH }} + VERSION: ${{ env.VERSION }} + run: | + make test + ([[ $? == 0 ]] && echo "pass" || echo "fail") | tee ${{ github.workspace }}/test-results-${VERSION_PREFIX}${VERSION}-${ARCH}.txt + # Store tests results as an artifact (used by downstream jobs) + # Note: Cannot use "::set-output name=var_name::var_value" as var_name would need to be dynamic here. + # Dynamic variable names cannot be used when mapping step outputs to job outputs. + # Step outputs cannot be accessed directly from other jobs. Dead end. + - name: Store test results + uses: actions/upload-artifact@v2 + with: + name: test-results + path: ${{ github.workspace }}/test-results-*.txt + + push: + name: "Push: ${{ matrix.version }}/multi" + runs-on: ubuntu-20.04 + + # Wait for test to either succeed or fail + needs: test + if: always() + + strategy: + matrix: + version: + - "10.3" + - "10.4" + - "10.5" + - "10.6" + + env: + VERSION_PREFIX: "" + VERSION: ${{ matrix.version }} + + steps: + - + name: Checkout + uses: actions/checkout@v2 + - + name: Environment variables + run: | + # Export variables for further steps + echo GIT_SHA7="${GITHUB_SHA:0:7}" | tee -a ${GITHUB_ENV} + echo BUILD_IMAGE_TAG="${IMAGE}:${VERSION_PREFIX}${VERSION}-build" | tee -a ${GITHUB_ENV} + # Pull the host public SSH key at runtime instead of relying on a static value stored in secrets. + echo ARM64_HOST_SSH_CERT="$(ssh-keyscan -t rsa ${{ secrets.ARM64_HOST }} 2>/dev/null)" | tee -a ${GITHUB_ENV} + - + # Login to Docker Hub + name: Login to Docker Hub + uses: docker/login-action@v1 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + - + name: Retrieve test results + uses: actions/download-artifact@v2 + with: + name: test-results + - + # Generate persistent tags (edge, stable, release) + name: Docker image tags + id: docker_tags + # Don't push broken builds to persistent tags (both amd64 and arm64 tests must pass) + # TODO: re-enable the arm64 test results check once those tests are re-enabled + run: | + amd64_tests=$(cat test-results-${VERSION_PREFIX}${VERSION}-amd64.txt) + #arm64_tests=$(cat test-results-${VERSION_PREFIX}${VERSION}-arm64.txt) + # && [[ "${arm64_tests}" == "pass" ]] + if [[ "${amd64_tests}" == "pass" ]]; then + .github/scripts/docker-tags.sh + fi + - + # Create and push multi-arch image manifests + name: Push multi-arch images + env: + # build tags are always pushed (build caching, debugging needs) + # edge, stage, release are only pushed if tests were successful (see docker_tags step) + TAGS: | + ${{ env.BUILD_IMAGE_TAG }} + ${{ steps.docker_tags.outputs.tags }} + DOCKERHUB_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }} # Needed for docker-tag-delete.sh + DOCKERHUB_PASSWORD: ${{ secrets.DOCKERHUB_PASSWORD }} # Needed for docker-tag-delete.sh + run: | + set -xeuo pipefail + IFS="${IFS}," # Also split strings by comma (in case list of tag is comma-separated) + for tag in ${TAGS}; do + if [[ "${tag}" == "" ]]; then continue; fi + docker manifest create --amend ${tag} \ + ${{ env.BUILD_IMAGE_TAG }}-${{ env.GIT_SHA7 }}-amd64 \ + ${{ env.BUILD_IMAGE_TAG }}-${{ env.GIT_SHA7 }}-arm64 + docker manifest inspect ${tag} + docker manifest push ${tag} + done + # Clean up intermediate arch-specific image tags (DockerHub only) + .github/scripts/docker-tag-delete.sh ${{ env.BUILD_IMAGE_TAG }}-${{ env.GIT_SHA7 }}-amd64 + .github/scripts/docker-tag-delete.sh ${{ env.BUILD_IMAGE_TAG }}-${{ env.GIT_SHA7 }}-arm64 diff --git a/.github/workflows/docker-build-push.yaml b/.github/workflows/docker-build-push.yaml deleted file mode 100644 index c44c65f..0000000 --- a/.github/workflows/docker-build-push.yaml +++ /dev/null @@ -1,178 +0,0 @@ -# Build a Docker image and push it to GitHub Container Registry -# See https://github.com/docker/build-push-action/blob/master/.github/workflows/example.yml - -name: Docker Build and Push - -on: - schedule: - - cron: '0 10 * * 0' # everyday sunday at 10am - push: - branches: - - master - - develop - - feature/* - tags: - - 'v*.*.*' - -defaults: - run: - shell: bash - -jobs: - build-push: - name: Build and Push - runs-on: ubuntu-20.04 - strategy: - fail-fast: false # Don't cancel other jobs if one fails - matrix: - version: - - 10.3 - - 10.4 - - 10.5 - - 10.6 - env: - IMAGE: docksal/mariadb - UPSTREAM_IMAGE: mariadb - VERSION: ${{ matrix.version }} - 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 Docker Hub - 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 }} - - - # Calculates docker image tags for the given build context - # The output is used in build and push step as `tags: ${{ steps.docker_meta.outputs.tags }}` - # See https://github.com/crazy-max/ghaction-docker-meta - name: Docker meta - id: docker_meta - uses: crazy-max/ghaction-docker-meta@v1 - with: - # List of Docker images to use as base name for tags - images: | - ${{ env.IMAGE }} - ghcr.io/${{ env.IMAGE }} - tag-sha: true # add git short SHA as Docker tag - - - # Generate image meta information - name: Docker image tags - id: docker_tags - run: make tags - - - # Build for local use - name: Build image (amd64) - id: docker_build_amd64 - uses: docker/build-push-action@v2 - env: - IMAGE_CACHE: ghcr.io/${{ env.IMAGE }}:build-${{ env.VERSION }} - with: - context: . - file: ./Dockerfile - build-args: | - UPSTREAM_IMAGE=${{ env.UPSTREAM_IMAGE }} - VERSION=${{ env.VERSION }} - platforms: linux/amd64 # Note: cannot use multi-platform with local image caching ("load: true") - tags: ${{ env.IMAGE }}:build-${{ env.VERSION }} - load: true # cache image locally for use by other steps - cache-from: type=registry,ref=${{ env.IMAGE_CACHE }} - cache-to: type=inline # Write the cache metadata into the image configuration - - - # Build for local use - name: Build image (arm64) - id: docker_build_arm64 - uses: docker/build-push-action@v2 - env: - IMAGE_CACHE: ghcr.io/${{ env.IMAGE }}:build-${{ env.VERSION }} - with: - context: . - file: ./Dockerfile - build-args: | - UPSTREAM_IMAGE=${{ env.UPSTREAM_IMAGE }} - VERSION=${{ env.VERSION }} - platforms: linux/arm64 # Note: cannot use multi-platform with local image caching ("load: true") - tags: ${{ env.IMAGE }}:build-${{ env.VERSION }} - load: true # cache image locally for use by other steps - cache-from: type=registry,ref=${{ env.IMAGE_CACHE }} - cache-to: type=inline # Write the cache metadata into the image configuration - - - # Print image info - name: Docker image info - run: | - set -xeuo pipefail - docker image ls | grep "${{ env.IMAGE }}" - docker image inspect "${{ env.IMAGE }}:build-${{ env.VERSION }}" - - - # Cache image layers in the registry - name: Push image cache (ghcr.io) - id: docker_push_cache - uses: docker/build-push-action@v2 - env: - IMAGE_CACHE: ghcr.io/${{ env.IMAGE }}:build-${{ env.VERSION }} - with: - context: . - file: ./Dockerfile - build-args: | - UPSTREAM_IMAGE=${{ env.UPSTREAM_IMAGE }} - VERSION=${{ env.VERSION }} - platforms: linux/amd64,linux/arm64 - tags: ${{ env.IMAGE_CACHE }} # 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 - run: make test - - - # Push final image to the registry - # This will pick-up the build cache from the local build step - name: Push image - id: docker_push_image - # Don't run if the list of tags is empty - # Note: using tags from docker_tags (custom) - if: ${{ steps.docker_tags.outputs.tags != '' }} - uses: docker/build-push-action@v2 - with: - context: . - file: ./Dockerfile - build-args: | - UPSTREAM_IMAGE=${{ env.UPSTREAM_IMAGE }} - VERSION=${{ env.VERSION }} - platforms: linux/amd64,linux/arm64 - tags: ${{ steps.docker_tags.outputs.tags }} # Note: using tags from docker_tags (custom script) - labels: ${{ steps.docker_meta.outputs.labels }} # Note: using lables from docker_meta - push: ${{ github.event_name != 'pull_request' }} # Don't push for PRs - cache-to: type=inline # Write the cache metadata into the image configuration diff --git a/Dockerfile b/Dockerfile index d682fe1..d70b575 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,6 +1,5 @@ ARG UPSTREAM_IMAGE -ARG VERSION -FROM ${UPSTREAM_IMAGE}:${VERSION} +FROM ${UPSTREAM_IMAGE} # Has to be set again after FROM ARG VERSION diff --git a/Makefile b/Makefile index ce80ae6..6be1c69 100644 --- a/Makefile +++ b/Makefile @@ -1,10 +1,17 @@ --include env_make +# Load test variables +-include tests/env_make + +# Allow using a different docker binary +DOCKER ?= docker + +# Force BuildKit mode for builds +# See https://docs.docker.com/buildx/working-with-buildx/ +DOCKER_BUILDKIT=1 IMAGE ?= docksal/mariadb -UPSTREAM_IMAGE ?= mariadb VERSION ?= 10.6 -BUILD_TAG ?= build-$(VERSION) - +UPSTREAM_IMAGE ?= mariadb:$(VERSION) +BUILD_IMAGE_TAG ?= $(IMAGE):$(VERSION)-build NAME = docksal-mariadb-$(VERSION) MYSQL_ROOT_PASSWORD = root @@ -14,45 +21,56 @@ MYSQL_DATABASE = default ENV = -e MYSQL_ROOT_PASSWORD=$(MYSQL_ROOT_PASSWORD) -e MYSQL_USER=$(MYSQL_USER) -e MYSQL_PASSWORD=$(MYSQL_PASSWORD) -e MYSQL_DATABASE=$(MYSQL_DATABASE) -e VERSION=$(VERSION) +# Make it possible to pass arguments to Makefile from command line +# https://stackoverflow.com/a/6273809/1826109 +ARGS = $(filter-out $@,$(MAKECMDGOALS)) + .EXPORT_ALL_VARIABLES: -.PHONY: build test push shell run start stop logs clean release +.PHONY: build test push shell run start stop logs clean + +default: build build: - docker build -t $(IMAGE):$(BUILD_TAG) --build-arg UPSTREAM_IMAGE=$(UPSTREAM_IMAGE) --build-arg VERSION=$(VERSION) . + $(DOCKER) build -t $(BUILD_IMAGE_TAG) --build-arg UPSTREAM_IMAGE=$(UPSTREAM_IMAGE) --build-arg VERSION=$(VERSION) . test: - IMAGE=$(IMAGE) BUILD_TAG=$(BUILD_TAG) NAME=$(NAME) VERSION=$(VERSION) ./tests/test.bats + IMAGE=$(BUILD_IMAGE_TAG) NAME=$(NAME) VERSION=$(VERSION) ./tests/test.bats push: - docker push $(IMAGE):$(BUILD_TAG) + $(DOCKER) push $(BUILD_IMAGE_TAG) shell: clean - docker run --rm --name $(NAME) -it $(PORTS) $(VOLUMES) $(ENV) $(IMAGE):$(BUILD_TAG) /bin/bash + $(DOCKER) run --rm --name $(NAME) -it $(PORTS) $(VOLUMES) $(ENV) $(BUILD_IMAGE_TAG) /bin/bash run: clean - docker run --rm --name $(NAME) -it $(PORTS) $(VOLUMES) $(ENV) $(IMAGE):$(BUILD_TAG) + $(DOCKER) run --rm --name $(NAME) -it $(PORTS) $(VOLUMES) $(ENV) $(BUILD_IMAGE_TAG) start: clean - docker run -d --name $(NAME) $(PORTS) $(VOLUMES) $(ENV) $(IMAGE):$(BUILD_TAG) + $(DOCKER) run -d --name $(NAME) $(PORTS) $(VOLUMES) $(ENV) $(BUILD_IMAGE_TAG) exec: - docker exec $(NAME) /bin/bash -c "$(CMD)" + $(DOCKER) exec $(NAME) /bin/bash -c "$(CMD)" mysql-query: # Usage: make mysql-query QUERY='SHOW DATABASES;' - docker exec $(NAME) bash -c "mysql --host=localhost --user=root --password=$(MYSQL_ROOT_PASSWORD) -e '$(QUERY)'" + $(DOCKER) exec $(NAME) bash -c "mysql --host=localhost --user=root --password=$(MYSQL_ROOT_PASSWORD) -e '$(QUERY)'" stop: - docker stop $(NAME) + $(DOCKER) stop $(NAME) logs: - docker logs $(NAME) + $(DOCKER) logs $(NAME) -clean: - docker rm -f $(NAME) >/dev/null 2>&1 || true +logs-follow: + $(DOCKER) logs -f $(NAME) -tags: - @.github/scripts/docker-tags.sh +debug: build start logs-follow -default: build +clean: + $(DOCKER) rm -vf $(NAME) || true + +# Make it possible to pass arguments to Makefile from command line +# https://stackoverflow.com/a/6273809/1826109 +%: + @: From 7c66f62aec5dda06415b05665d40a734538685dc Mon Sep 17 00:00:00 2001 From: Leonid Makarov Date: Fri, 11 Feb 2022 17:47:32 -0800 Subject: [PATCH 4/4] Updated LICENSE year --- LICENSE | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/LICENSE b/LICENSE index dea4c75..c0705c5 100644 --- a/LICENSE +++ b/LICENSE @@ -1,6 +1,6 @@ MIT License -Copyright (c) 2019 Docksal +Copyright (c) 2019-2022 Docksal Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal