Skip to content

Commit 89f7c61

Browse files
authored
Add docker release workflow (#1743)
1 parent b85628a commit 89f7c61

File tree

2 files changed

+92
-1
lines changed

2 files changed

+92
-1
lines changed
Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
name: Release - Docker
2+
3+
on:
4+
release:
5+
types: [published]
6+
workflow_dispatch:
7+
inputs:
8+
tag:
9+
description: 'Docker image tag (defaults to release tag or "manual")'
10+
required: false
11+
type: string
12+
pull_request:
13+
paths:
14+
- 'Dockerfile'
15+
16+
env:
17+
REGISTRY: ghcr.io
18+
IMAGE_NAME: ${{ github.repository }}
19+
20+
jobs:
21+
build-and-push:
22+
runs-on: ubuntu-latest
23+
permissions:
24+
contents: read
25+
packages: write
26+
id-token: write
27+
28+
steps:
29+
- name: Checkout repository
30+
uses: actions/checkout@v4
31+
with:
32+
# For releases, checkout the release tag; for workflow_dispatch, checkout the latest commit
33+
ref: ${{ github.event_name == 'release' && github.event.release.tag_name || github.sha }}
34+
35+
- name: Display checkout info
36+
run: |
37+
echo "Checked out commit: $(git rev-parse HEAD)"
38+
echo "Event name: ${{ github.event_name }}"
39+
echo "Release tag: ${{ github.event.release.tag_name }}"
40+
echo "GitHub SHA: ${{ github.sha }}"
41+
42+
- # Add support for more platforms with QEMU (optional)
43+
# https://github.com/docker/setup-qemu-action
44+
name: Set up QEMU
45+
uses: docker/setup-qemu-action@v3
46+
-
47+
name: Set up Docker Buildx
48+
uses: docker/setup-buildx-action@v3
49+
50+
- name: Log in to GitHub Container Registry
51+
uses: docker/login-action@v3
52+
with:
53+
registry: ${{ env.REGISTRY }}
54+
username: ${{ github.actor }}
55+
password: ${{ secrets.GITHUB_TOKEN }}
56+
57+
- name: Extract metadata
58+
id: meta
59+
uses: docker/metadata-action@v5
60+
with:
61+
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
62+
tags: |
63+
type=ref,event=branch
64+
type=ref,event=pr
65+
type=semver,pattern={{version}}
66+
type=semver,pattern={{major}}.{{minor}}
67+
type=semver,pattern={{major}}
68+
type=raw,value=${{ inputs.tag }},enable=${{ inputs.tag != '' }}
69+
type=raw,value=latest,enable=${{ github.event_name == 'release' }}
70+
71+
- name: Build and push Docker image
72+
uses: docker/build-push-action@v5
73+
with:
74+
context: .
75+
file: Dockerfile
76+
platforms: linux/amd64
77+
push: true
78+
tags: ${{ steps.meta.outputs.tags }}
79+
labels: ${{ steps.meta.outputs.labels }}
80+
build-args: |
81+
TARGETPLATFORM=linux/amd64
82+
OUMI_VERSION=${{ github.event.release.tag_name }}
83+
cache-from: type=gha
84+
cache-to: type=gha,mode=max

Dockerfile

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
ARG TARGETPLATFORM=linux/amd64
22
FROM --platform=${TARGETPLATFORM} pytorch/pytorch:2.5.1-cuda12.4-cudnn9-runtime
33

4+
# ARG for oumi version - defaults to empty string which will install latest
5+
ARG OUMI_VERSION=
46

57
WORKDIR /oumi_workdir
68

@@ -23,8 +25,13 @@ RUN apt-get update && \
2325

2426

2527
# Install Oumi dependencies
28+
# If OUMI_VERSION is provided, install that specific version, otherwise install latest
2629
RUN pip install --no-cache-dir uv && \
27-
uv pip install --system --no-cache-dir "oumi[gpu]"
30+
if [ -z "$OUMI_VERSION" ]; then \
31+
uv pip install --system --no-cache-dir "oumi[gpu]"; \
32+
else \
33+
uv pip install --system --no-cache-dir "oumi[gpu]==$OUMI_VERSION"; \
34+
fi
2835

2936
# Switch to oumi user
3037
USER oumi

0 commit comments

Comments
 (0)