diff --git a/.gitea/workflows/docker-build.yml b/.gitea/workflows/docker-build.yml new file mode 100644 index 0000000..dd65727 --- /dev/null +++ b/.gitea/workflows/docker-build.yml @@ -0,0 +1,79 @@ +name: Build and Push Docker Image + +on: + push: + branches: + - main + tags: + - "v*" + pull_request: + branches: + - main + +jobs: + build-and-push: + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + with: + config-inline: | + [registry."10.0.0.2:3000"] + http = true + insecure = true + + - name: Log in to Gitea Container Registry + run: | + # Configure Docker to allow insecure registry for this session + mkdir -p ~/.docker + echo '{ + "auths": {}, + "insecure-registries": ["10.0.0.2:3000"] + }' > ~/.docker/config.json + + # Login using direct docker command + echo "${{ secrets.CI_RUNNER_TOKEN }}" | docker login 10.0.0.2:3000 --username "${{ gitea.actor }}" --password-stdin + + - name: Extract metadata + id: meta + uses: docker/metadata-action@v5 + with: + images: | + ${{ secrets.DOCKER_USERNAME }}/baby-monitor + tags: | + type=ref,event=branch + type=ref,event=pr + type=semver,pattern={{version}} + type=semver,pattern={{major}}.{{minor}} + type=semver,pattern={{major}} + type=sha + type=raw,value=latest,enable={{is_default_branch}} + labels: | + org.opencontainers.image.title=baby-monitor + org.opencontainers.image.description=Baby Monitor App with all optional dependencies included + org.opencontainers.image.authors=Brian Jensen + org.opencontainers.image.vendor=Brian Jensen + org.opencontainers.image.licenses=MIT + + - name: Build and push Docker image + uses: docker/build-push-action@v5 + with: + context: . + file: ./Dockerfile + push: true + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} + cache-from: type=gha + cache-to: type=gha,mode=max + platforms: linux/amd64,linux/arm64 + + - name: Update deployment info + run: | + echo "Docker image built and pushed successfully at $(date)" + echo "Image tags:" + echo "${{ steps.meta.outputs.tags }}" + echo "Image labels:" + echo "${{ steps.meta.outputs.labels }}"