Skip to content

Commit

Permalink
Merge pull request #15 from docksal/develop
Browse files Browse the repository at this point in the history
Release 1.2.0
  • Loading branch information
lmakarov authored Mar 13, 2021
2 parents 849a227 + abd5d46 commit 7fa1c9a
Show file tree
Hide file tree
Showing 19 changed files with 288 additions and 280 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+=("${IMAGE}:sha-${GIT_SHA7}-${VERSION}")
# IMAGE_TAGS+=("ghcr.io/${IMAGE}:sha-${GIT_SHA7}-${VERSION}")
#fi

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

# master => stable
if [[ "${GITHUB_REF}" == "refs/heads/master" ]]; then
IMAGE_TAGS+=("${IMAGE}:stable-${VERSION}")
IMAGE_TAGS+=("ghcr.io/${IMAGE}:stable-${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+=("${IMAGE}:stable-${VERSION}")
IMAGE_TAGS+=("${IMAGE}:${VERSION_MAJOR}-${VERSION}")
IMAGE_TAGS+=("${IMAGE}:${VERSION_MAJOR}.${VERSION_MINOR}-${VERSION}")
IMAGE_TAGS+=("ghcr.io/${IMAGE}:stable-${VERSION}")
IMAGE_TAGS+=("ghcr.io/${IMAGE}:${VERSION_MAJOR}-${VERSION}")
IMAGE_TAGS+=("ghcr.io/${IMAGE}:${VERSION_MAJOR}.${VERSION_MINOR}-${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}"
157 changes: 157 additions & 0 deletions .github/workflows/docker-build-push.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,157 @@
# 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.2
- 10.3
- 10.4
- 10.5
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 + registry cache (ghcr.io)
name: Build and cache image (local)
id: docker_build_local
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 # 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=ghcr.io/${{ env.DOCKER_IMAGE }}:build-${{ matrix.version }}
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
# This will pick-up the build cache from the local build step
name: Build and push image cache (ghcr.io)
id: docker_build_cache
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: ghcr.io/${{ env.IMAGE }}:build-${{ env.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
run: make test
-
# Push final image to the registry
# This will pick-up the build cache from the local build step
name: Build and push image
id: docker_build_push
# 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
31 changes: 0 additions & 31 deletions .travis.yml

This file was deleted.

27 changes: 0 additions & 27 deletions 10.0/default.cnf

This file was deleted.

20 changes: 0 additions & 20 deletions 10.0/mysql-variables.txt

This file was deleted.

27 changes: 0 additions & 27 deletions 10.1/default.cnf

This file was deleted.

21 changes: 7 additions & 14 deletions 10.2/default.cnf
Original file line number Diff line number Diff line change
@@ -1,14 +1,11 @@
[client]
default-character-set = utf8mb4

[mysql]
default-character-set = utf8mb4

[mysqld]
# Use multi-byte UTF (utf8mb4) encoding by default (supports emojis, Asian symbols, mathematical symbols, etc.)
character_set_server = utf8mb4
collation_server = utf8mb4_unicode_ci
init_connect = 'SET NAMES utf8mb4'
# 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
Expand All @@ -19,9 +16,5 @@ 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
5 changes: 1 addition & 4 deletions 10.2/mysql-variables.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,13 @@ character_set_filesystem binary
character_set_results utf8mb4
character_set_server utf8mb4
character_set_system utf8
collation_connection utf8mb4_general_ci
collation_connection utf8mb4_unicode_ci
collation_database utf8mb4_unicode_ci
collation_server utf8mb4_unicode_ci
default_storage_engine InnoDB
init_connect SET NAMES utf8mb4
innodb_buffer_pool_size 268435456
innodb_file_format Barracuda
innodb_file_per_table ON
innodb_flush_log_at_trx_commit 1
innodb_large_prefix ON
innodb_log_buffer_size 8388608
innodb_log_file_size 134217728
max_allowed_packet 134217728
21 changes: 7 additions & 14 deletions 10.3/default.cnf
Original file line number Diff line number Diff line change
@@ -1,14 +1,11 @@
[client]
default-character-set = utf8mb4

[mysql]
default-character-set = utf8mb4

[mysqld]
# Use multi-byte UTF (utf8mb4) encoding by default (supports emojis, Asian symbols, mathematical symbols, etc.)
character_set_server = utf8mb4
collation_server = utf8mb4_unicode_ci
init_connect = 'SET NAMES utf8mb4'
# 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
Expand All @@ -19,9 +16,5 @@ 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
Loading

0 comments on commit 7fa1c9a

Please sign in to comment.