Spaces:
Build error
Build error
| # GitHub Actions Workflow - Docker Build | |
| # Optional: Automate Docker image building and deployment | |
| name: Docker Build and Test | |
| on: | |
| push: | |
| branches: [ main, develop ] | |
| pull_request: | |
| branches: [ main ] | |
| jobs: | |
| build: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v3 | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@v2 | |
| - name: Build Docker image | |
| run: | | |
| docker build -t alpha-index-app:${{ github.sha }} . | |
| - name: Test Docker image | |
| run: | | |
| docker run -d --name test-app -p 8501:8501 alpha-index-app:${{ github.sha }} | |
| sleep 10 | |
| curl -f http://localhost:8501/_stcore/health || exit 1 | |
| docker stop test-app | |
| - name: Login to Docker Hub (optional) | |
| if: github.event_name == 'push' && github.ref == 'refs/heads/main' | |
| uses: docker/login-action@v2 | |
| with: | |
| username: ${{ secrets.DOCKER_USERNAME }} | |
| password: ${{ secrets.DOCKER_PASSWORD }} | |
| - name: Push to Docker Hub (optional) | |
| if: github.event_name == 'push' && github.ref == 'refs/heads/main' | |
| run: | | |
| docker tag alpha-index-app:${{ github.sha }} ${{ secrets.DOCKER_USERNAME }}/alpha-index-app:latest | |
| docker push ${{ secrets.DOCKER_USERNAME }}/alpha-index-app:latest | |