Docker Image CI #94
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 ] | |
schedule: | |
- cron: '0 3 1,15 * *' | |
env: | |
TEST_TAG: misp-modules:latest | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
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: 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 | |
- | |
name: Test | |
run: | | |
docker run --name misp-modules --rm -p 127.0.0.1:6666:6666 ${{ env.TEST_TAG }} & | |
sleep 10 # Wait until container is ready | |
curl --fail http://localhost:6666/modules | jq | |
docker stop misp-modules | |
- | |
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 | |
- | |
# 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-modules:latest | |
ghcr.io/nukib/misp-modules:latest | |