diff --git a/.github/workflows/docker-tests.yml b/.github/workflows/docker-tests.yml index 69e109d..d12fef3 100644 --- a/.github/workflows/docker-tests.yml +++ b/.github/workflows/docker-tests.yml @@ -9,15 +9,13 @@ on: - main jobs: - build: + build-and-publish: + runs-on: ubuntu-latest strategy: fail-fast: false matrix: - os: [ ubuntu-latest ] python-version: [ "3.9", "3.10", "3.11", "3.12" ] - runs-on: ${{ matrix.os }} - steps: - name: Checkout code uses: actions/checkout@v3 @@ -27,23 +25,35 @@ jobs: with: python-version: ${{ matrix.python-version }} - - name: Build Docker image - run: docker build -t ghcr.io/birchkwok/minvectordb/minvectordb:latest . - - - name: Run Docker container - run: docker run -d --name minvectordb -p 5403:7637 ghcr.io/birchkwok/minvectordb/minvectordb:latest + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v1 - name: Install Python dependencies run: | python -m pip install --upgrade pip - python -m pip install flake8 pytest numba torch - $reqFile = "requirements.txt" - if (Test-Path $reqFile) { pip install -r $reqFile } - shell: pwsh + pip install flake8 pytest numba torch + if [ -f "requirements.txt" ]; then pip install -r requirements.txt; fi - name: Run tests run: pytest test/docker_tests/ + - name: Login to Docker Hub + if: github.event_name == 'push' && github.ref == 'refs/heads/main' + uses: docker/login-action@v1 + with: + registry: docker.io + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + + - name: Build and push Docker images + if: github.event_name == 'push' && github.ref == 'refs/heads/main' + uses: docker/build-push-action@v2 + with: + context: . + push: true + tags: birchkwok/minvectordb:latest + platforms: linux/amd64, linux/arm64 + - name: Cleanup if: always() run: docker stop minvectordb && docker rm minvectordb diff --git a/.github/workflows/python-tests.yml b/.github/workflows/python-tests.yml index 2c7532c..22018cf 100644 --- a/.github/workflows/python-tests.yml +++ b/.github/workflows/python-tests.yml @@ -25,7 +25,7 @@ jobs: - name: Install dependencies run: | python -m pip install --upgrade pip - python -m pip install flake8 pytest numba torch + python -m pip install flake8 pytest numba $reqFile = "requirements.txt" if (Test-Path $reqFile) { pip install -r $reqFile } shell: pwsh