You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
59 lines
1.5 KiB
59 lines
1.5 KiB
name: Docker Test Build
|
|
|
|
on:
|
|
pull_request:
|
|
branches: [ "master" ]
|
|
workflow_dispatch:
|
|
|
|
env:
|
|
REGISTRY: docker.io
|
|
IMAGE_NAME: ${{ github.repository }}
|
|
|
|
jobs:
|
|
test-build:
|
|
runs-on: ubuntu-latest
|
|
permissions:
|
|
contents: read
|
|
|
|
steps:
|
|
- name: Checkout repository
|
|
uses: actions/checkout@v4
|
|
|
|
# Setup QEMU for multi-platform builds
|
|
- name: Set up QEMU
|
|
uses: docker/setup-qemu-action@v3
|
|
|
|
# Setup Docker BuildX
|
|
- name: Set up Docker Buildx
|
|
uses: docker/setup-buildx-action@v3
|
|
|
|
# Build Docker image (without pushing)
|
|
- name: Build Docker image
|
|
id: build
|
|
uses: docker/build-push-action@v6
|
|
with:
|
|
context: .
|
|
push: false
|
|
tags: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:test
|
|
platforms: linux/amd64
|
|
cache-from: type=gha
|
|
cache-to: type=gha,mode=max
|
|
build-args: |
|
|
BUILDKIT_INLINE_CACHE=1
|
|
|
|
# Test the built image
|
|
- name: Test Docker image
|
|
run: |
|
|
docker run --rm ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:test python test_docker.py
|
|
|
|
# Show image size
|
|
- name: Show image size
|
|
run: |
|
|
docker images ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:test --format "table {{.Repository}}\t{{.Tag}}\t{{.Size}}"
|
|
|
|
# Clean up test image
|
|
- name: Clean up test image
|
|
if: always()
|
|
run: |
|
|
docker rmi ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:test || true
|