Skip to content

cpu only

cpu only #20

name: Build & Publish Docker Image
on:
pull_request:
branches: [ docker ]
paths:
- 'docker/Dockerfile'
- 'docker/requirements.txt'
- 'docker/docker-compose.yml'
- '.github/workflows/docker-publish.yml'
push:
branches: [ docker ]
paths:
- 'docker/Dockerfile'
- 'docker/requirements.txt'
- 'docker/docker-compose.yml'
- '.github/workflows/docker-publish.yml'
# ─────────────── global env ──────────────────────────────────────────────────
env:
REGISTRY: ghcr.io
IMAGE_NAME: deeptrackai/deep-learning-crash-course # change once here
jobs:
build-and-push:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write # needed to push to GHCR
steps:
- uses: actions/checkout@v4
- uses: docker/setup-qemu-action@v3 # multi-arch emulation
- uses: docker/setup-buildx-action@v3 # Buildx driver with cache support
# -------- optional, but speeds repeat builds -----------
- name: Restore Docker layer cache
uses: actions/cache@v4
with:
path: /tmp/.buildx-cache
key: ${{ runner.os }}-buildx-${{ github.sha }}
restore-keys: ${{ runner.os }}-buildx-
# --------------------------------------------------------
- name: Log in to GHCR
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build (and push on main branch)
uses: docker/build-push-action@v3
with:
context: .
file: docker/Dockerfile # adjust if your Dockerfile moves
platforms: linux/amd64,linux/arm64
push: ${{ github.event_name == 'push' }} # PRs build but don’t publish
tags: |
${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest
${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ github.sha }}
cache-from: type=local,src=/tmp/.buildx-cache
cache-to: type=local,dest=/tmp/.buildx-cache,mode=max