Skip to content

Commit 2d28ad0

Browse files
author
Chuck Tang
committed
commit change
1 parent c1f953f commit 2d28ad0

File tree

1 file changed

+80
-0
lines changed

1 file changed

+80
-0
lines changed

.github/workflows/docker.yaml

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
name: Docker
2+
on:
3+
push:
4+
branches:
5+
- main
6+
pull_request:
7+
branches:
8+
- main
9+
paths:
10+
- Dockerfile
11+
- .github/workflows/docker.yaml
12+
workflow_dispatch: {}
13+
jobs:
14+
docker-build:
15+
runs-on: mosaic-8wide
16+
if: github.repository_owner == 'mosaicml'
17+
strategy:
18+
matrix:
19+
include:
20+
- name: "2.4.0_cu124"
21+
base_image: mosaicml/pytorch:2.4.0_cu124-python3.11-ubuntu20.04
22+
dep_groups: "[all]"
23+
- name: "2.4.0_cu124_aws"
24+
base_image: mosaicml/pytorch:2.4.0_cu124-python3.11-ubuntu20.04
25+
dep_groups: "[all]"
26+
steps:
27+
28+
- name: Checkout
29+
uses: actions/checkout@v3
30+
31+
- name: Setup QEMU
32+
uses: docker/setup-qemu-action@v2
33+
34+
- name: Setup Docker Buildx
35+
uses: docker/setup-buildx-action@v2
36+
37+
- name: Login to DockerHub
38+
uses: docker/login-action@v2
39+
with:
40+
username: ${{ secrets.DOCKER_HUB_USERNAME }}
41+
password: ${{ secrets.DOCKER_HUB_PASSWORD }}
42+
43+
- name: Calculate Docker Image Variables
44+
run: |
45+
set -euxo pipefail
46+
47+
###################
48+
# Calculate the tag
49+
###################
50+
GIT_SHA=$(echo ${{ github.sha }} | cut -c1-7)
51+
echo "IMAGE_TAG=${GIT_SHA}" >> ${GITHUB_ENV}
52+
53+
if [ "${{ github.event_name }}" == "pull_request" ]; then
54+
echo "Triggered by pull_request event."
55+
STAGING_REPO="mosaicml/ci-staging"
56+
IMAGE_TAG="${STAGING_REPO}:${{matrix.name}}-${GIT_SHA}"
57+
IMAGE_CACHE="${STAGING_REPO}:${{matrix.name}}-buildcache"
58+
else
59+
# Triggered by push or workflow_dispatch event
60+
echo "Triggered by ${{ github.event_name }} event, releasing to prod"
61+
PROD_REPO="mosaicml/diffusion"
62+
IMAGE_TAG="${PROD_REPO}:${{matrix.name}}-${GIT_SHA},${PROD_REPO}:${{matrix.name}}-latest"
63+
IMAGE_CACHE="${PROD_REPO}:${{matrix.name}}-buildcache"
64+
fi
65+
66+
echo "IMAGE_TAG=${IMAGE_TAG}" >> ${GITHUB_ENV}
67+
echo "IMAGE_CACHE=${IMAGE_CACHE}" >> ${GITHUB_ENV}
68+
69+
- name: Build and Push the Docker Image
70+
uses: docker/build-push-action@v3
71+
with:
72+
context: .
73+
tags: ${{ env.IMAGE_TAG }}
74+
push: true
75+
cache-from: type=registry,ref=${{ env.IMAGE_CACHE }}
76+
cache-to: type=registry,ref=${{ env.IMAGE_CACHE }},mode=max
77+
build-args: |
78+
BRANCH_NAME=${{ github.head_ref || github.ref_name }}
79+
BASE_IMAGE=${{ matrix.base_image }}
80+
DEP_GROUPS=${{ matrix.dep_groups }}

0 commit comments

Comments
 (0)