Skip to content

Added Docker

Added Docker #6

Workflow file for this run

name: Docker Image CI
on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]
permissions:
contents: read
packages: write
jobs:
build-and-push-x86:
runs-on: ubuntu-latest
strategy:
matrix:
platform: [linux/amd64]
steps:
- name: Checkout Code
uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Log in to GitHub Container Registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and Push Docker Image
run: |
REPO_OWNER=$(echo "${{ github.repository_owner }}" | tr '[:upper:]' '[:lower:]')
REPO_NAME=$(echo "${{ github.event.repository.name }}" | tr '[:upper:]' '[:lower:]')
IMAGE_NAME="ghcr.io/$REPO_OWNER/$REPO_NAME"
PLATFORM_TAG=$(echo "${{ matrix.platform }}" | tr '/' '-')
docker buildx build \
--compress \
--platform ${{ matrix.platform }} \
--tag $IMAGE_NAME:latest-${PLATFORM_TAG} \
--push .
shell: bash
build-and-push-arm:
runs-on: ubuntu-24.04-arm
strategy:
matrix:
platform: [linux/arm/v7, linux/arm64/v8]
steps:
- name: Checkout Code
uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Log in to GitHub Container Registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and Push Docker Image
run: |
REPO_OWNER=$(echo "${{ github.repository_owner }}" | tr '[:upper:]' '[:lower:]')
REPO_NAME=$(echo "${{ github.event.repository.name }}" | tr '[:upper:]' '[:lower:]')
IMAGE_NAME="ghcr.io/$REPO_OWNER/$REPO_NAME"
PLATFORM_TAG=$(echo "${{ matrix.platform }}" | tr '/' '-')
docker buildx build \
--compress \
--platform ${{ matrix.platform }} \
--tag $IMAGE_NAME:latest-${PLATFORM_TAG} \
--push .
shell: bash
create-multiarch-latest:
runs-on: ubuntu-latest
needs: [build-and-push-x86, build-and-push-arm]
steps:
- name: Log in to GitHub Container Registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Create Multi-Architecture Latest Tag
run: |
REPO_OWNER=$(echo "${{ github.repository_owner }}" | tr '[:upper:]' '[:lower:]')
REPO_NAME=$(echo "${{ github.event.repository.name }}" | tr '[:upper:]' '[:lower:]')
IMAGE_NAME="ghcr.io/$REPO_OWNER/$REPO_NAME"
docker buildx imagetools create \
--tag $IMAGE_NAME:latest \
$IMAGE_NAME:latest-linux-amd64 \
$IMAGE_NAME:latest-linux-arm-v7 \
$IMAGE_NAME:latest-linux-arm64-v8
shell: bash