Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Simplified and updated GH Actions #298

Open
wants to merge 19 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
118 changes: 118 additions & 0 deletions .github/workflows/containers-build-push.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
name: Build and push containers

on:
push:
# For push to main branch (PR merges)
branches:
- main
- master
paths:
- "elkserver/docker/**"
- ".github/workflows/containers-build-push.yml"
# For releases
tags:
- "*"
# For pull requests
pull_request:
branches:
- "*"
paths:
- "elkserver/docker/**"
- ".github/workflows/containers-build-push.yml"

permissions:
contents: read
packages: write

jobs:
docker:
runs-on: ubuntu-latest
strategy:
matrix:
container:
- base
- elasticsearch
- jupyter
- kibana
- logstash
steps:
- name: Checkout
uses: actions/checkout@v3

- name: Prepare
id: prepare
run: |
if [[ "x$DOCKER_REPO" == "x" ]]; then
DOCKER_REPO=outflanknl
fi
DOCKER_IMAGE="${DOCKER_REPO}/redelk-${{ matrix.container }}"
echo "name=docker_image::${DOCKER_IMAGE}" >> $GITHUB_OUTPUT
echo "name=docker_repo::${DOCKER_REPO}" >> $GITHUB_OUTPUT
echo "name=docker_file::elkserver/docker/redelk-${{ matrix.container }}/Dockerfile" >> $GITHUB_OUTPUT
env:
DOCKER_REPO: ${{ secrets.DOCKER_REPO }}

- name: Docker meta
id: docker_meta
uses: docker/metadata-action@v4
with:
images: |
${{ steps.prepare.outputs.docker_image }}
ghcr.io/${{ github.repository_owner }}/redelk-${{ matrix.container }}
labels: |
org.opencontainers.image.source=${{ github.event.repository.html_url }}
org.opencontainers.image.revision=${{ github.sha }}

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

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

- name: Login to Docker Hub
uses: docker/login-action@v2
# if: ${{ github.event_name != 'pull_request' }}
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}

- name: Login to GitHub Container Registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Cache Docker layers
uses: actions/cache@v3
id: cache
with:
path: /tmp/.buildx-cache
key: ${{ runner.os }}-buildx-${{ matrix.container }}-${{ hashFiles(steps.prepare.outputs.docker_file) }}
restore-keys: |
${{ runner.os }}-buildx-${{ matrix.container }}-${{ hashFiles(steps.prepare.outputs.docker_file) }}
${{ runner.os }}-buildx-${{ matrix.container }}-
${{ runner.os }}-buildx-

- name: Build and push
uses: docker/build-push-action@v4
with:
context: elkserver/docker/redelk-${{ matrix.container }}
file: ./elkserver/docker/redelk-${{ matrix.container }}/Dockerfile
platforms: linux/amd64,linux/arm64
push: true
tags: ${{ steps.docker_meta.outputs.tags }}
labels: ${{ steps.docker_meta.outputs.labels }}
build-args: |
DOCKER_METADATA_OUTPUT_JSON
cache-from: type=local,src=/tmp/.buildx-cache
cache-to: type=local,dest=/tmp/.buildx-cache-new,mode=max
outputs: type=image,name=target,annotation-index.org.opencontainers.image.description=${{ matrix.container }} container for RedELK

# Temp fix
# https://github.com/docker/build-push-action/issues/252
# https://github.com/moby/buildkit/issues/1896
- name: Move cache
run: |
rm -rf /tmp/.buildx-cache
mv /tmp/.buildx-cache-new /tmp/.buildx-cache
68 changes: 0 additions & 68 deletions .github/workflows/docker-build-dev-base.yml

This file was deleted.

64 changes: 0 additions & 64 deletions .github/workflows/docker-build-dev-elasticsearch.yml

This file was deleted.

64 changes: 0 additions & 64 deletions .github/workflows/docker-build-dev-jupyter.yml

This file was deleted.

64 changes: 0 additions & 64 deletions .github/workflows/docker-build-dev-kibana.yml

This file was deleted.

Loading