ECS logging by Vector #319
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Docker Image CI | |
on: | |
push: | |
branches: [ main ] | |
pull_request: | |
branches: [ main ] | |
workflow_dispatch: | |
inputs: | |
misp_ref: | |
description: 'MISP branch or tag to build' | |
required: true | |
default: 'develop' | |
env: | |
TEST_TAG: misp:latest | |
# See https://github.com/goodwithtech/dockle/issues/188 | |
DOCKLE_HOST: "unix:///var/run/docker.sock" | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
timeout-minutes: 60 | |
steps: | |
- | |
name: Checkout | |
uses: actions/checkout@v4 | |
- | |
name: Set up QEMU | |
uses: docker/setup-qemu-action@v3 | |
- | |
name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
- | |
name: Fetch variables | |
run: python3 .github/workflows/docker-version.py ${{ github.event.inputs.misp_ref }} | |
id: variables | |
- | |
name: Cache Docker layers | |
uses: actions/cache@v3 | |
with: | |
path: /tmp/.buildx-cache | |
key: ${{ runner.os }}-buildx-${{ github.sha }} | |
restore-keys: | | |
${{ runner.os }}-buildx- | |
- | |
name: Build and export to Docker | |
uses: docker/build-push-action@v5 | |
with: | |
context: . | |
load: true | |
tags: ${{ env.TEST_TAG }} | |
cache-from: type=local,src=/tmp/.buildx-cache/amd64 | |
cache-to: type=local,dest=/tmp/.buildx-cache-new/amd64,mode=max | |
build-args: | | |
CACHEBUST=${{ steps.variables.outputs.MISP_COMMIT }} | |
MISP_VERSION=${{ steps.variables.outputs.MISP_VERSION }} | |
- | |
name: Test | |
run: | | |
docker history ${{ env.TEST_TAG }} | |
MISP_IMAGE=${{ env.TEST_TAG }} docker compose up --detach --quiet-pull | |
sleep 10 # Wait until container is ready | |
docker logs misp | |
AUTHKEY=$(docker exec misp su-exec apache /var/www/MISP/app/Console/cake userInit -q) | |
VERSION=$(curl --fail -v -H "Authorization: $AUTHKEY" -H "Accept: application/json" http://localhost:8080/servers/getVersion) | |
echo $VERSION | jq | |
docker compose down | |
- | |
name: Container scan | |
uses: azure/container-scan@v0 | |
with: | |
image-name: ${{ env.TEST_TAG }} | |
severity-threshold: CRITICAL | |
- | |
name: Build Docker for linux/arm64 | |
uses: docker/build-push-action@v5 | |
with: | |
context: . | |
platforms: linux/arm64 | |
tags: ${{ env.TEST_TAG }} | |
cache-from: type=local,src=/tmp/.buildx-cache/arm64 | |
cache-to: type=local,dest=/tmp/.buildx-cache-new/arm64,mode=max | |
build-args: | | |
CACHEBUST=${{ steps.variables.outputs.MISP_COMMIT }} | |
MISP_VERSION=${{ steps.variables.outputs.MISP_VERSION }} | |
- | |
# 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 | |
du -sh /tmp/.buildx-cache | |
- | |
name: Login to GitHub Container Registry | |
if: github.event_name != 'pull_request' | |
uses: docker/login-action@v3 | |
with: | |
registry: ghcr.io | |
username: ${{ github.repository_owner }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- | |
name: Login to DockerHub | |
if: github.event_name != 'pull_request' | |
uses: docker/login-action@v3 | |
with: | |
username: nukib | |
password: ${{ secrets.DOCKERHUB_TOKEN }} | |
- | |
name: Build and push | |
if: github.event_name != 'pull_request' | |
uses: docker/build-push-action@v5 | |
with: | |
context: . | |
platforms: linux/amd64,linux/arm64 | |
push: true | |
tags: | | |
nukib/misp:latest | |
ghcr.io/nukib/misp:latest | |
build-args: | | |
CACHEBUST=${{ steps.variables.outputs.MISP_COMMIT }} | |
MISP_VERSION=${{ steps.variables.outputs.MISP_VERSION }} |