Skip to content

make docker

make docker #19

Workflow file for this run

# GitHub workflow for `make docker-*`.
name: make docker
# https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows
on:
# Trigger workflow in GitHub web frontend or from API.
workflow_dispatch:
inputs:
docker-image:
description: 'Docker image'
required: true
default: 'minimum'
type: choice
options:
- 'minimum'
- 'minimum-cuda'
- 'medium'
- 'medium-cuda'
- 'maximum'
- 'maximum-cuda'
upload-dockerhub:
description: 'Upload Docker image to Dockerhub'
default: False
type: boolean
upload-github:
description: 'Upload Docker image Github Container Registry'
default: False
type: boolean
upterm-session:
description: 'Run SSH login server for debugging'
default: False
type: boolean
# not yet:
#push:
# branches: [ "master" ]
jobs:
make:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Remove Docker images
run: |
df -h
docker images
docker rmi $(docker images --filter=reference="alpine:*" -q)
docker rmi $(docker images --filter=reference="debian:*" -q)
docker rmi $(docker images --filter=reference="node:*" -q)
df -h /
- name: Remove unneeded Debian packages
run: |
sudo apt-get install -y deborphan
sudo apt-get purge -y $(deborphan -a | fgrep -e main/cli-mono -e main/database -e main/devel -e main/httpd -e main/php -e main/vcs | while read _ pkg; do echo $package; done)
deborphan | sort
sudo du -mscx /* 2>/dev/null || true
sudo du -mscx /opt/* 2>/dev/null || true
sudo du -mscx /usr/* 2>/dev/null || true
df -h /
- name: Remove Homebrew, Android and .NET
run: |
# https://github.com/actions/virtual-environments/issues/2606#issuecomment-772683150
# NONINTERACTIVE=1 /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/uninstall.sh)"
sudo rm -rf /home/linuxbrew # will release Homebrew
sudo rm -rf /usr/local/lib/android # will release about 10 GB if you don't need Android
sudo rm -rf /usr/share/dotnet # will release about 20GB if you don't need .NET
sudo rm -rf /opt/ghc
sudo rm -rf /usr/local/share/boost
sudo rm -rf "$AGENT_TOOLSDIRECTORY"
sudo du -mscx /* 2>/dev/null || true
df -h /
- name: Setup upterm session
# interactive SSH logins for debugging
if: github.event.inputs.upterm-session == 'true'
uses: lhotari/action-upterm@v1
- name: Make Docker image
run: make docker-${{ github.event.inputs.docker-image }} GIT_DEPTH=--single-branch DOCKER_PARALLEL=-j4
- name: Generate ocrd-all-tool.json
# the Docker build will already have created this internally
# so just extract and store it here
run: |
id=$(docker create ocrd/all:${{ github.event.inputs.docker-image }})
docker cp $id:/build/ocrd-all-tool.json .
docker cp $id:/build/ocrd-all-module-dir.json .
wc -l ocrd-all-tool.json ocrd-all-module-dir.json
- name: Upload ocrd-all-tool.json
uses: actions/upload-artifact@v4
with:
name: ${{ github.event.inputs.docker-image }}_ocrd-all-tool.json
path: |
./ocrd-all-tool.json
./ocrd-all-module-dir.json
# if-no-files-found: error
- name: Login to Docker Hub
if: github.event.inputs.upload-dockerhub == 'true'
run: echo ${{ secrets.DOCKERHUB_PASSWORD }} | docker login --username ${{ secrets.DOCKERHUB_USERNAME }} --password-stdin
- name: Push to Docker Hub
if: github.event.inputs.upload-dockerhub == 'true'
run: |
docker push ocrd/all:${{ github.event.inputs.docker-image }}
if test ${{ github.event.inputs.docker-image }} = maximum; then
# Alias Docker image.
docker tag ocrd/all:maximum ocrd/all:latest
docker push ocrd/all:latest
fi
- name: Login to GitHub Container Registry
if: github.event.inputs.upload-github == 'true'
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Push to Github Container Registry
if: github.event.inputs.upload-github == 'true'
run: |
docker tag ocrd/all:${{ github.event.inputs.docker-image }} ghcr.io/ocr-d/all:${{ github.event.inputs.docker-image }}
docker push ghcr.io/ocr-d/all:${{ github.event.inputs.docker-image }}
if test ${{ github.event.inputs.docker-image }} = maximum; then
# Alias Docker image.
docker tag ocrd/all:maximum ghcr.io/ocr-d/all:latest
docker push ghcr.io/ocr-d/all:latest
fi