Skip to content
This repository was archived by the owner on Jan 21, 2023. It is now read-only.

Improvements to CI action, and upgrade Alpine Versions #53

Open
wants to merge 11 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
167 changes: 75 additions & 92 deletions .github/workflows/docker-image.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,131 +8,114 @@ name: Publish Docker Image
on:
push:
branches:
- '**'
- 'master'

jobs:
push_to_registries:
name: Push Docker image to multiple registries
runs-on: ubuntu-latest
strategy:
matrix:
versions: [
{
name: "v5",
context: "5.6",
versions: "5 5.6 5.6.16"
},
{
name: "v6",
context: "6.8",
versions: "6 6.8 6.8.23"
},
{
name: "v7",
context: "7.17",
versions: "7 7.17 7.17.2"
},
{
name: "v8",
context: "8.1",
versions: "8 8.1 8.1.2"
}
]
permissions:
packages: write
contents: read
steps:
-
name: Check out the repo
- name: Check out the repo
uses: actions/checkout@v3

-
name: Extract metadata (tags, labels) for Docker
- name: Create images list for ${{ matrix.versions.name }}
shell: bash
id: imageListGenerator
env:
REPOSITORY_OWNER: ${{ github.repository_owner }}
VERSION_LIST: ${{ matrix.versions.versions }}
run: |
IMAGE_LIST=""
IMAGE_METADATA_LIST="ghcr.io/$REPOSITORY_OWNER/elasticsearch"
LOGIN_DOCKER_HUB=0

if [ "$REPOSITORY_OWNER" = "blacktop" ] ; then
LOGIN_DOCKER_HUB=1
IMAGE_METADATA_LIST="$IMAGE_METADATA_LIST\nblacktop/elasticsearch"
for version in $VERSION_LIST; do
if [ -z "$IMAGE_LIST" ]; then
IMAGE_LIST="blacktop/elasticsearch:$version"
else
IMAGE_LIST="$IMAGE_LIST,blacktop/elasticsearch:$version"
fi
done
fi

for version in $VERSION_LIST; do
if [ -z "$IMAGE_LIST" ]; then
IMAGE_LIST="ghcr.io/$REPOSITORY_OWNER/elasticsearch:$version"
else
IMAGE_LIST="$IMAGE_LIST,ghcr.io/$REPOSITORY_OWNER/elasticsearch:$version"
fi
done

IMAGE_METADATA_LIST="${IMAGE_METADATA_LIST//'%'/'%25'}"
IMAGE_METADATA_LIST="${IMAGE_METADATA_LIST//$'\n'/'%0A'}"
IMAGE_METADATA_LIST="${IMAGE_METADATA_LIST//$'\r'/'%0D'}"

echo "::set-output name=imageList::$IMAGE_LIST"
echo "::set-output name=imageMetadataList::$IMAGE_METADATA_LIST"
echo "::set-output name=loginDockerHub::$LOGIN_DOCKER_HUB"

- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v4
with:
images: |
blacktop/elasticsearch
ghcr.io/${{ github.repository }}
images: ${{ steps.imageListGenerator.outputs.imageMetadataList }}

-
name: Set up QEMU
- name: Set up QEMU
uses: docker/setup-qemu-action@v2

-
name: Set up Docker Buildx
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2

-
name: Docker Login
- name: Docker Login
uses: docker/login-action@v2
if: ${{ steps.imageListGenerator.outputs.loginDockerHub == '1' }}
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

-
name: Log in to the Container registry
- name: Log in to GHCR Container registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Build and push Docker image (v1)
id: docker_build_1
uses: docker/build-push-action@v3
timeout-minutes: 20
with:
context: ./1.7
push: ${{ github.event_name != 'pull_request' }}
tags: |
blacktop/elasticsearch:1
blacktop/elasticsearch:1.7
blacktop/elasticsearch:1.7.6
ghcr.io/blacktop/elasticsearch:1
ghcr.io/blacktop/elasticsearch:1.7
ghcr.io/blacktop/elasticsearch:1.7.6
platforms: linux/amd64,linux/arm64
labels: ${{ steps.meta.outputs.labels }}

- name: Build and push Docker image (v6)
id: docker_build_6
- name: Build and push Docker image
uses: docker/build-push-action@v3
timeout-minutes: 20
with:
context: ./6.8
context: ./${{ matrix.versions.context }}
push: ${{ github.event_name != 'pull_request' }}
tags: |
blacktop/elasticsearch:6
blacktop/elasticsearch:6.8
blacktop/elasticsearch:6.8.23
ghcr.io/blacktop/elasticsearch:6
ghcr.io/blacktop/elasticsearch:6.8
ghcr.io/blacktop/elasticsearch:6.8.23
tags: ${{ steps.imageListGenerator.outputs.imageList }}
platforms: linux/amd64,linux/arm64
labels: ${{ steps.meta.outputs.labels }}

- name: Build and push Docker image (v7)
id: docker_build_7
uses: docker/build-push-action@v3
timeout-minutes: 20
with:
context: ./7.17
push: ${{ github.event_name != 'pull_request' }}
tags: |
blacktop/elasticsearch:7
blacktop/elasticsearch:7.17
blacktop/elasticsearch:7.17.2
ghcr.io/blacktop/elasticsearch:7
ghcr.io/blacktop/elasticsearch:7.17
ghcr.io/blacktop/elasticsearch:7.17.2
platforms: linux/amd64,linux/arm64
labels: ${{ steps.meta.outputs.labels }}

- name: Build and push Docker image (v8)
id: docker_build_8
uses: docker/build-push-action@v3
timeout-minutes: 20
with:
context: ./8.1
push: ${{ github.event_name != 'pull_request' }}
tags: |
blacktop/elasticsearch:latest
blacktop/elasticsearch:8
blacktop/elasticsearch:8.1
blacktop/elasticsearch:8.1.2
ghcr.io/blacktop/elasticsearch:latest
ghcr.io/blacktop/elasticsearch:8
ghcr.io/blacktop/elasticsearch:8.1
ghcr.io/blacktop/elasticsearch:8.1.2
platforms: linux/amd64,linux/arm64
labels: ${{ steps.meta.outputs.labels }}

# - name: Build and push Docker image (X-Pack)
# id: docker_build_x_pack
# uses: docker/build-push-action@v3
# with:
# context: ./x-pack
# push: ${{ github.event_name != 'pull_request' }}
# tags: |
# blacktop/elasticsearch:x-pack
# blacktop/elasticsearch:x-pack-7
# blacktop/elasticsearch:x-pack-7.15
# blacktop/elasticsearch:x-pack-7.15.1
# labels: ${{ steps.meta.outputs.labels }}
13 changes: 6 additions & 7 deletions 2.4/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,20 +1,19 @@
FROM alpine:3.5
FROM alpine:3.14

LABEL maintainer "https://github.com/blacktop"

RUN apk add --no-cache openjdk8-jre tini su-exec

ENV ES_VERSION 2.4.4
ENV ES_VERSION 2.4.6

ENV DOWNLOAD_URL "https://download.elastic.co/elasticsearch/release/org/elasticsearch/distribution"
ENV ES_TARBAL "${DOWNLOAD_URL}/tar/elasticsearch/${ES_VERSION}/elasticsearch-${ES_VERSION}.tar.gz"
ENV ES_TARBALL_ASC "${DOWNLOAD_URL}/tar/elasticsearch/${ES_VERSION}/elasticsearch-${ES_VERSION}.tar.gz.asc"
ENV SHA1_URL "${DOWNLOAD_URL}/tar/elasticsearch/${ES_VERSION}/elasticsearch-${ES_VERSION}.tar.gz.sha1"
ENV ES_TARBALL_SHA1 "cdb5068d1baa07388e522c3bc04cca38aa8f3048"
ENV ES_TARBALL_SHA1 "c3441bef89cd91206edf3cf3bd5c4b62550e60a9"
ENV GPG_KEY "46095ACC8548582C1A2699A9D27D666CD88E42B4"

RUN apk add --no-cache bash
RUN apk add --no-cache -t .build-deps wget ca-certificates gnupg openssl \
RUN apk add --no-cache openjdk8-jre tini su-exec java-jna-native \
&& apk add --no-cache bash \
&& apk add --no-cache -t .build-deps wget ca-certificates gnupg openssl \
&& cd /tmp \
&& echo "===> Install Elasticsearch..." \
&& EXPECTED_SHA=$(wget -O - ${SHA1_URL}) \
Expand Down
26 changes: 20 additions & 6 deletions 2.4/elastic-entrypoint.sh
Original file line number Diff line number Diff line change
@@ -1,10 +1,24 @@
#!/bin/sh
#!/bin/bash

set -e

es_opts=''

while IFS='=' read -r envvar_key envvar_value
do
# Elasticsearch env vars need to have at least two dot separated lowercase words, e.g. `cluster.name`
if [[ "$envvar_key" =~ ^[a-z]+\.[a-z]+ ]]
then
if [[ ! -z $envvar_value ]]; then
es_opt="-D${envvar_key}=${envvar_value}"
es_opts+=" ${es_opt}"
fi
fi
done < <(env)

# Add elasticsearch as command if needed
if [ "${1:0:1}" = '-' ]; then
set -- elasticsearch "$@"
set -- elasticsearch "$@" ${es_opts}
fi

################################################
Expand All @@ -24,7 +38,7 @@ if [ "$1" = 'master' -a "$(id -u)" = '0' ]; then
chown -R elasticsearch:elasticsearch /usr/share/elasticsearch/data
chown -R elasticsearch:elasticsearch /usr/share/elasticsearch/logs

set -- su-exec elasticsearch "$@"
set -- su-exec elasticsearch "$@" ${es_opts}
fi

set -- su-exec elasticsearch /sbin/tini -- elasticsearch
Expand All @@ -51,7 +65,7 @@ if [ "$1" = 'client' -a "$(id -u)" = '0' ]; then
chown -R elasticsearch:elasticsearch /usr/share/elasticsearch/data
chown -R elasticsearch:elasticsearch /usr/share/elasticsearch/logs

set -- su-exec elasticsearch "$@"
set -- su-exec elasticsearch "$@" ${es_opts}
fi

set -- su-exec elasticsearch /sbin/tini -- elasticsearch
Expand All @@ -78,7 +92,7 @@ if [ "$1" = 'data' -a "$(id -u)" = '0' ]; then
chown -R elasticsearch:elasticsearch /usr/share/elasticsearch/data
chown -R elasticsearch:elasticsearch /usr/share/elasticsearch/logs

set -- su-exec elasticsearch "$@"
set -- su-exec elasticsearch "$@" ${es_opts}
fi

set -- su-exec elasticsearch /sbin/tini -- elasticsearch
Expand All @@ -91,7 +105,7 @@ if [ "$1" = 'elasticsearch' -a "$(id -u)" = '0' ]; then
chown -R elasticsearch:elasticsearch /usr/share/elasticsearch/data
chown -R elasticsearch:elasticsearch /usr/share/elasticsearch/logs

set -- su-exec elasticsearch "$@"
set -- su-exec elasticsearch "$@" ${es_opts}
fi

exec "$@"
9 changes: 4 additions & 5 deletions 5.0/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
FROM gliderlabs/alpine:3.4
FROM gliderlabs/alpine:3.14

MAINTAINER blacktop, https://github.com/blacktop

RUN apk-install openjdk8-jre tini su-exec

ENV ELASTIC 5.0.2

RUN apk-install bash
RUN apk-install -t build-deps wget ca-certificates \
RUN apk-install openjdk8-jre tini su-exec java-jna-native \
&& apk-install bash \
&& apk-install -t build-deps wget ca-certificates \
&& cd /tmp \
&& wget -O elasticsearch-$ELASTIC.tar.gz https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-$ELASTIC.tar.gz \
&& tar -xzf elasticsearch-$ELASTIC.tar.gz \
Expand Down