Skip to content

Docker Build

Docker Build #10

Workflow file for this run

name: Docker Build
on:
workflow_dispatch:
inputs:
tag_latest:
description: 'Tag as latest'
required: true
type: choice
options:
- 'true'
- 'false'
default: 'false'
push:
branches: [main]
paths:
- 'docker/**'
- 'scripts/setup_*.sh'
- 'src/holosoma_inference/docker/Dockerfile'
- 'src/holosoma_retargeting/docker/Dockerfile'
permissions:
contents: read
env:
ECR_REPO: 982423663241.dkr.ecr.us-west-2.amazonaws.com
jobs:
build:
strategy:
fail-fast: false # continue on one build failing
matrix:
include:
# CPU-buildable images
- environment: inference
dockerfile: 'src/holosoma_inference/docker/Dockerfile'
runner_prefix: 'codebuild-holosoma-cpu-build'
- environment: retargeting
dockerfile: 'src/holosoma_retargeting/docker/Dockerfile'
runner_prefix: 'codebuild-holosoma-cpu-build'
# GPU-required images (setup scripts build/link against CUDA/IsaacSim)
- environment: holosoma
dockerfile: 'docker/Dockerfile'
runner_prefix: 'codebuild-holosoma-a10g-x1-gpu-build'
- environment: isaacgym
dockerfile: 'docker/isaacgym.Dockerfile'
runner_prefix: 'codebuild-holosoma-a10g-x1-gpu-build'
- environment: isaacsim
dockerfile: 'docker/isaacsim.Dockerfile'
runner_prefix: 'codebuild-holosoma-a10g-x1-gpu-build'
- environment: mujoco
dockerfile: 'docker/mujoco.Dockerfile'
runner_prefix: 'codebuild-holosoma-a10g-x1-gpu-build'
#TODO: add mujoco warp
name: Build ${{ matrix.environment }} Docker Image
continue-on-error: true
runs-on: ${{ matrix.runner_prefix }}-${{ github.run_id }}-${{ github.run_attempt }}
steps:
- name: Checkout code
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
- name: Generate Image name and path
id: name
# image name should be `holosoma` or `holsoma-${environment}`
run: |
IMAGE_NAME="${{ case(matrix.environment == 'holosoma', '', 'holosoma-') }}${{ matrix.environment }}"
IMAGE_PATH="${{ env.ECR_REPO }}/${IMAGE_NAME}"
echo "image_path=${IMAGE_PATH}" >> "$GITHUB_OUTPUT"
# might be unnecessary
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@4d04d5d9486b7bd6fa91e7baf45bbb4f8b9deedd # v4
- name: Generate image tags
id: tags
run: |
short_sha="$(echo "${{ github.sha }}" | cut -c1-7)"
tags="${{ steps.name.outputs.image_path }}:$(date -u +%Y_%m%d_%H%M)"
tags="$tags,${{ steps.name.outputs.image_path }}:sha-${short_sha}"
if [[ "${{ inputs.tag_latest || 'false' }}" == "true" ]]; then
tags="$tags,${{ steps.name.outputs.image_path }}:latest"
fi
echo "tags=$tags" >> "$GITHUB_OUTPUT"
- name: Build and push Docker image
uses: docker/build-push-action@f9f3042f7e2789586610d6e8b85c8f03e5195baf # v7
with:
context: .
file: "${{ matrix.dockerfile }}"
push: true
tags: "${{ steps.tags.outputs.tags }}"
cache-from: type=registry,ref=${{ steps.name.outputs.image_path }}:buildcache
cache-to: type=registry,ref=${{ steps.name.outputs.image_path }}:buildcache,mode=max
- name: Summary
run: |
echo "## Docker Build Summary" >> "$GITHUB_STEP_SUMMARY"
echo "- **Tags:** \`${{ steps.tags.outputs.tags }}\`" >> "$GITHUB_STEP_SUMMARY"