diff --git a/.github/workflows/docker-build-push.yml b/.github/workflows/docker-build-push.yml new file mode 100644 index 0000000..a8749f8 --- /dev/null +++ b/.github/workflows/docker-build-push.yml @@ -0,0 +1,51 @@ +name: Build and Push Docker Images + +on: + workflow_dispatch: + inputs: + image: + description: "Select the image type to build" + required: true + type: choice + options: + - cpu + - gpu + tag: + description: "Docker image tag (e.g., latest, 2.53.0)" + required: true + type: string + +jobs: + build-and-push: + runs-on: ubuntu-latest + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + - name: Log in to cerit.io + uses: docker/login-action@v3 + with: + registry: cerit.io + username: ${{ secrets.REGISTRY_USERNAME }} + password: ${{ secrets.REGISTRY_PASSWORD }} + + - name: Determine exact image tag + id: set_tag + run: | + # Automatically append '-gpu' suffix for GPU images if not already present + if [ "${{ inputs.image }}" = "gpu" ] && [[ "${{ inputs.tag }}" != *"-gpu" ]]; then + echo "image_tag=${{ inputs.tag }}-gpu" >> $GITHUB_OUTPUT + else + echo "image_tag=${{ inputs.tag }}" >> $GITHUB_OUTPUT + fi + + - name: Build and push image + uses: docker/build-push-action@v5 + with: + context: . + file: ./docker/Dockerfile.${{ inputs.image }} + push: true + tags: cerit.io/rationai/model-service:${{ steps.set_tag.outputs.image_tag }}