Skip to content

Commit 5dd8e04

Browse files
authored
[Dockerfiles] add: a workflow to check if docker containers can be built in case of modifications (#7129)
* add: a workflow to check if docker containers can be built if the files are modified. * type * unify docker image build test and push * make it run on prs too. * check * check * check * check again. * remove docker test build file. * remove extra dependencies./ * check
1 parent 165af7e commit 5dd8e04

File tree

2 files changed

+41
-5
lines changed

2 files changed

+41
-5
lines changed

.github/workflows/build_docker_images.yml

Lines changed: 40 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,58 @@
1-
name: Build Docker images (nightly)
1+
name: Test, build, and push Docker images
22

33
on:
4+
pull_request: # During PRs, we just check if the changes Dockerfiles can be successfully built
5+
branches:
6+
- main
7+
paths:
8+
- "docker/**"
49
workflow_dispatch:
510
schedule:
611
- cron: "0 0 * * *" # every day at midnight
712

813
concurrency:
9-
group: docker-image-builds
10-
cancel-in-progress: false
14+
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
15+
cancel-in-progress: true
1116

1217
env:
1318
REGISTRY: diffusers
1419
CI_SLACK_CHANNEL: ${{ secrets.CI_DOCKER_CHANNEL }}
1520

1621
jobs:
17-
build-docker-images:
22+
test-build-docker-images:
1823
runs-on: ubuntu-latest
24+
if: github.event_name == 'pull_request'
25+
steps:
26+
- name: Set up Docker Buildx
27+
uses: docker/setup-buildx-action@v1
28+
29+
- name: Check out code
30+
uses: actions/checkout@v3
31+
32+
- name: Find Changed Dockerfiles
33+
id: file_changes
34+
uses: jitterbit/get-changed-files@v1
35+
with:
36+
format: 'space-delimited'
37+
token: ${{ secrets.GITHUB_TOKEN }}
38+
39+
- name: Build Changed Docker Images
40+
run: |
41+
CHANGED_FILES="${{ steps.file_changes.outputs.all }}"
42+
for FILE in $CHANGED_FILES; do
43+
if [[ "$FILE" == docker/*Dockerfile ]]; then
44+
DOCKER_PATH="${FILE%/Dockerfile}"
45+
DOCKER_TAG=$(basename "$DOCKER_PATH")
46+
echo "Building Docker image for $DOCKER_TAG"
47+
docker build -t "$DOCKER_TAG" "$DOCKER_PATH"
48+
fi
49+
done
50+
if: steps.file_changes.outputs.all != ''
1951

52+
build-and-push-docker-images:
53+
runs-on: ubuntu-latest
54+
if: github.event_name != 'pull_request'
55+
2056
permissions:
2157
contents: read
2258
packages: write

docker/diffusers-pytorch-cpu/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,6 @@ RUN python3 -m pip install --no-cache-dir --upgrade pip uv==0.1.11 && \
4040
numpy \
4141
scipy \
4242
tensorboard \
43-
transformers
43+
transformers matplotlib
4444

4545
CMD ["/bin/bash"]

0 commit comments

Comments
 (0)