diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml new file mode 100644 index 0000000..b5870e9 --- /dev/null +++ b/.github/workflows/docker.yml @@ -0,0 +1,92 @@ +name: Docker + +on: + push: + branches: [master] + workflow_dispatch: + +permissions: + contents: read + packages: write + +env: + IMAGE: ghcr.io/huebyte/echohub-server + +jobs: + docker: + name: Build & Push Docker Image + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Check for src/ changes + id: changes + env: + BEFORE: ${{ github.event.before }} + run: | + if [ -z "$BEFORE" ] || [ "$BEFORE" = "0000000000000000000000000000000000000000" ]; then + echo "src_changed=true" >> "$GITHUB_OUTPUT" + else + CHANGED=$(git diff --name-only "$BEFORE" HEAD -- 'src/' | wc -l) + [ "$CHANGED" -gt 0 ] && echo "src_changed=true" >> "$GITHUB_OUTPUT" || echo "src_changed=false" >> "$GITHUB_OUTPUT" + fi + + - name: Read version + if: steps.changes.outputs.src_changed == 'true' + id: version + run: | + VERSION=$(grep -oP '(?<=)[^<]+' src/Directory.Build.props) + echo "version=$VERSION" >> "$GITHUB_OUTPUT" + echo "tag=v$VERSION" >> "$GITHUB_OUTPUT" + + - name: Check if image tag exists + if: steps.changes.outputs.src_changed == 'true' + id: check_image + run: | + TAG="${{ steps.version.outputs.tag }}" + if docker manifest inspect "${{ env.IMAGE }}:${TAG}" &>/dev/null; then + echo "exists=true" >> "$GITHUB_OUTPUT" + else + echo "exists=false" >> "$GITHUB_OUTPUT" + fi + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + - name: Set up QEMU + if: steps.changes.outputs.src_changed == 'true' && steps.check_image.outputs.exists == 'false' + uses: docker/setup-qemu-action@v3 + + - name: Set up Docker Buildx + if: steps.changes.outputs.src_changed == 'true' && steps.check_image.outputs.exists == 'false' + uses: docker/setup-buildx-action@v3 + + - name: Log in to GHCR + if: steps.changes.outputs.src_changed == 'true' && steps.check_image.outputs.exists == 'false' + uses: docker/login-action@v3 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Build and push + if: steps.changes.outputs.src_changed == 'true' && steps.check_image.outputs.exists == 'false' + uses: docker/build-push-action@v6 + with: + context: ./src + file: ./src/EchoHub.Server/Dockerfile + platforms: linux/amd64,linux/arm64 + push: true + tags: | + ${{ env.IMAGE }}:latest + ${{ env.IMAGE }}:${{ steps.version.outputs.tag }} + labels: | + org.opencontainers.image.title=EchoHub Server + org.opencontainers.image.description=Self-hosted IRC-style chat server + org.opencontainers.image.version=${{ steps.version.outputs.version }} + org.opencontainers.image.source=https://github.com/${{ github.repository }} + + - name: Skip notice + if: steps.changes.outputs.src_changed != 'true' || steps.check_image.outputs.exists == 'true' + run: echo "⏭️ Skipped — no src/ changes or image tag already exists." diff --git a/docker-compose.yml b/docker-compose.yml index 67fdd99..8135ebc 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -8,8 +8,8 @@ services: restart: unless-stopped ports: - "5000:5000" - # - "6667:6667" # IRC gateway (enable Irc__Enabled=true first) - # - "6697:6697" # IRC TLS + # - "6667:6667" # IRC (plain, no encryption) + # - "6697:6697" # IRC (TLS encrypted, preferred) volumes: - echohub-data:/app/data environment: diff --git a/docs/changelog/v0.2.7.md b/docs/changelog/v0.2.7.md index 687a90f..198ccfe 100644 --- a/docs/changelog/v0.2.7.md +++ b/docs/changelog/v0.2.7.md @@ -8,6 +8,10 @@ - Add Docker support for EchoHub.Server — `docker compose up -d` for easy self-hosting with persistent volume for database, uploads, and logs +## CI + +- Add Docker workflow — builds and pushes multi-arch (`amd64`/`arm64`) server image to GHCR on release + ## Infrastructure - Switch Terminal.Gui from local fork submodule back to NuGet package (`2.0.0-develop.5039`) — transparent color PR merged upstream