|
1 | 1 | name: Build-Push Kepler Model Server Image |
2 | 2 |
|
3 | | -on: |
| 3 | +on: # yamllint disable-line rule:truthy |
4 | 4 | workflow_call: |
5 | 5 | secrets: |
6 | 6 | docker_username: |
7 | | - description: 'Docker username' |
| 7 | + description: Docker username |
8 | 8 | required: false |
9 | 9 | docker_password: |
10 | | - description: 'Docker password' |
| 10 | + description: Docker password |
11 | 11 | required: false |
12 | 12 | inputs: |
13 | 13 | base_change: |
14 | | - description: 'Change flag on base image' |
| 14 | + description: Change flag on base image |
15 | 15 | required: true |
16 | 16 | type: string |
17 | 17 | s3_change: |
18 | | - description: 'Change flag on s3 image' |
| 18 | + description: Change flag on s3 image |
19 | 19 | required: true |
20 | 20 | type: string |
21 | 21 | image_repo: |
22 | | - description: 'The image repo to use' |
| 22 | + description: The image repo to use |
23 | 23 | required: true |
24 | 24 | type: string |
25 | 25 | image_tag: |
26 | | - description: 'The image tag to use' |
| 26 | + description: The image tag to use |
27 | 27 | required: true |
28 | 28 | type: string |
29 | 29 | push: |
30 | | - description: 'Push image' |
| 30 | + description: Push image |
31 | 31 | required: false |
32 | 32 | type: string |
33 | 33 | default: false |
@@ -68,58 +68,58 @@ jobs: |
68 | 68 | exists: ${{ steps.check-base-exist.outputs.exists }} |
69 | 69 |
|
70 | 70 | steps: |
71 | | - - name: Check if Docker base image exists |
72 | | - id: check-base-exist |
73 | | - run: | |
74 | | - if docker pull ${{ env.base_image }}; then |
75 | | - echo "exists=true" >> "$GITHUB_OUTPUT" |
76 | | - else |
77 | | - echo "exists=false" >> "$GITHUB_OUTPUT" |
78 | | - fi |
| 71 | + - name: Check if Docker base image exists |
| 72 | + id: check-base-exist |
| 73 | + run: | |
| 74 | + if docker pull ${{ env.base_image }}; then |
| 75 | + echo "exists=true" >> "$GITHUB_OUTPUT" |
| 76 | + else |
| 77 | + echo "exists=false" >> "$GITHUB_OUTPUT" |
| 78 | + fi |
79 | 79 |
|
80 | 80 | build: |
81 | 81 | runs-on: ubuntu-latest |
82 | 82 | needs: [check-secret, check-base-exist] |
83 | 83 | steps: |
84 | | - - name: checkout |
85 | | - uses: actions/checkout@v4 |
86 | | - - name: set up QEMU |
87 | | - uses: docker/setup-qemu-action@v3 |
88 | | - - name: set up Docker Buildx |
89 | | - uses: docker/setup-buildx-action@v3 |
90 | | - - name: Login to Docker |
91 | | - if: ${{ needs.check-secret.outputs.available == 'true' }} |
92 | | - uses: docker/login-action@v3 |
93 | | - with: |
| 84 | + - name: checkout |
| 85 | + uses: actions/checkout@v4 |
| 86 | + - name: set up QEMU |
| 87 | + uses: docker/setup-qemu-action@v3 |
| 88 | + - name: set up Docker Buildx |
| 89 | + uses: docker/setup-buildx-action@v3 |
| 90 | + - name: Login to Docker |
| 91 | + if: ${{ needs.check-secret.outputs.available == 'true' }} |
| 92 | + uses: docker/login-action@v3 |
| 93 | + with: |
94 | 94 | registry: ${{ inputs.image_repo }} |
95 | 95 | username: ${{ secrets.docker_username }} |
96 | 96 | password: ${{ secrets.docker_password }} |
97 | | - - name: Build-push s3 image |
98 | | - if: ${{ needs.check-secret.outputs.available == 'true' && env.s3_change == 'true' }} |
99 | | - uses: docker/build-push-action@v6 |
100 | | - with: |
101 | | - platforms: linux/amd64 |
102 | | - push: ${{ inputs.push }} |
103 | | - tags: ${{ env.s3_image }} |
104 | | - context: model_training/s3 |
105 | | - file: model_training/s3/Dockerfile |
106 | | - - name: Build-push base image |
107 | | - if: ${{ (needs.check-secret.outputs.available == 'true') && ((needs.check-base-exist.outputs.exists == 'false') || (env.base_change == 'true')) }} |
108 | | - uses: docker/build-push-action@v6 |
109 | | - with: |
110 | | - platforms: linux/amd64 |
111 | | - push: true |
112 | | - tags: ${{ env.base_image }} |
113 | | - file: dockerfiles/Dockerfile.base |
114 | | - - name: Replace value in file |
115 | | - if: ${{ (needs.check-secret.outputs.available == 'true') && ((needs.check-base-exist.outputs.exists == 'false') || (env.base_change == 'true')) }} |
116 | | - run: | |
117 | | - sed -i "s|quay.io/sustainable_computing_io/kepler_model_server_base:latest|${{ env.base_image }}|" dockerfiles/Dockerfile |
118 | | - - name: Build-push image |
119 | | - uses: docker/build-push-action@v6 |
120 | | - with: |
121 | | - context: . |
122 | | - platforms: linux/amd64 |
123 | | - push: ${{ inputs.push }} |
124 | | - tags: ${{ env.image }} |
125 | | - file: dockerfiles/Dockerfile |
| 97 | + - name: Build-push s3 image |
| 98 | + if: ${{ needs.check-secret.outputs.available == 'true' && env.s3_change == 'true' }} |
| 99 | + uses: docker/build-push-action@v6 |
| 100 | + with: |
| 101 | + platforms: linux/amd64 |
| 102 | + push: ${{ inputs.push }} |
| 103 | + tags: ${{ env.s3_image }} |
| 104 | + context: model_training/s3 |
| 105 | + file: model_training/s3/Dockerfile |
| 106 | + - name: Build-push base image |
| 107 | + if: ${{ (needs.check-secret.outputs.available == 'true') && ((needs.check-base-exist.outputs.exists == 'false') || (env.base_change == 'true')) }} |
| 108 | + uses: docker/build-push-action@v6 |
| 109 | + with: |
| 110 | + platforms: linux/amd64 |
| 111 | + push: true |
| 112 | + tags: ${{ env.base_image }} |
| 113 | + file: dockerfiles/Dockerfile.base |
| 114 | + - name: Replace value in file |
| 115 | + if: ${{ (needs.check-secret.outputs.available == 'true') && ((needs.check-base-exist.outputs.exists == 'false') || (env.base_change == 'true')) }} |
| 116 | + run: | |
| 117 | + sed -i "s|quay.io/sustainable_computing_io/kepler_model_server_base:latest|${{ env.base_image }}|" dockerfiles/Dockerfile |
| 118 | + - name: Build-push image |
| 119 | + uses: docker/build-push-action@v6 |
| 120 | + with: |
| 121 | + context: . |
| 122 | + platforms: linux/amd64 |
| 123 | + push: ${{ inputs.push }} |
| 124 | + tags: ${{ env.image }} |
| 125 | + file: dockerfiles/Dockerfile |
0 commit comments