Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
149 changes: 149 additions & 0 deletions .github/workflows/ghcr.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,149 @@
name: Build and Push to GHCR

on:
push:
branches:
- main
tags:
- 'v*'
pull_request:
branches:
- main
workflow_dispatch:

env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}

jobs:
build:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
id-token: write

strategy:
fail-fast: false
matrix:
platform:
- linux/amd64
- linux/arm64
- linux/arm/v7
include:
- platform: linux/amd64
target: x86_64-unknown-linux-musl
- platform: linux/arm64
target: aarch64-unknown-linux-musl
- platform: linux/arm/v7
target: armv7-unknown-linux-musleabihf

steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Set up QEMU
uses: docker/setup-qemu-action@v3

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Log in to GitHub Container Registry
if: github.event_name != 'pull_request'
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Extract metadata (tags, labels)
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
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}}

- name: Build and push by digest
id: build
uses: docker/build-push-action@v5
with:
context: .
platforms: ${{ matrix.platform }}
file: ./Dockerfile.build
labels: ${{ steps.meta.outputs.labels }}
outputs: type=image,name=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }},push-by-digest=true,name-canonical=true,push=${{ github.event_name != 'pull_request' }}
cache-from: type=gha
cache-to: type=gha,mode=max
build-args: |
TARGET=${{ matrix.target }}

- name: Export digest
run: |
mkdir -p /tmp/digests
digest="${{ steps.build.outputs.digest }}"
touch "/tmp/digests/${digest#sha256:}"

- name: Upload digest
uses: actions/upload-artifact@v4
with:
name: digests-${{ matrix.target }}
path: /tmp/digests/*
if-no-files-found: error
retention-days: 1

merge:
runs-on: ubuntu-latest
needs: build
if: github.event_name != 'pull_request'
permissions:
contents: read
packages: write
id-token: write

steps:
- name: Download digests
uses: actions/download-artifact@v4.1.8
with:
path: /tmp/digests
pattern: digests-*
merge-multiple: true

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Log in to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Extract metadata (tags, labels)
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
tags: |
type=ref,event=branch
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=semver,pattern={{major}}
type=sha
type=raw,value=latest,enable={{is_default_branch}}

- name: Create manifest list and push
working-directory: /tmp/digests
run: |
docker buildx imagetools create $(jq -cr '.tags | map("-t " + .) | join(" ")' <<< "$DOCKER_METADATA_OUTPUT_JSON") \
$(printf '${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}@sha256:%s ' *)

- name: Inspect image
run: |
docker buildx imagetools inspect ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ steps.meta.outputs.version }}
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ bincode = "1.3.3"
base2048 = "2.0.2"
revision = "0.10.0"
fake_user_agent = "0.2.2"
rustls = "0.21.12"


[dev-dependencies]
Expand Down
148 changes: 148 additions & 0 deletions DEPLOYMENT.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,148 @@
# Deployment Checklist

## ✅ Pre-Merge Verification

- [x] Code compiles successfully (`cargo check`)
- [x] All files properly committed
- [x] Documentation complete (README.md, DOCKER.md, PR_SUMMARY.md)
- [x] Code review feedback addressed
- [x] Clean commit history
- [x] No sensitive information in code

## 📋 Post-Merge Actions

### 1. Merge the PR
Once you merge this PR to the `main` branch:
- The GitHub Actions workflow will automatically trigger
- Docker images will be built for all architectures
- Images will be published to GHCR

### 2. Verify the Workflow
After merging, check:
1. Go to Actions tab in your GitHub repository
2. Look for "Build and Push to GHCR" workflow
3. Verify all builds complete successfully
4. Check for green checkmarks on all architecture builds

### 3. Verify GHCR Packages
Once the workflow completes:
1. Go to your repository page
2. Look for "Packages" section on the right sidebar
3. You should see `redlib` package listed
4. Click on it to see available tags

### 4. Test the Docker Image
Pull and test the image:
```bash
# Pull the latest image
docker pull ghcr.io/mitchross/redlib:latest

# Run it
docker run -d -p 8080:8080 --name redlib-test ghcr.io/mitchross/redlib:latest

# Wait a few seconds for startup
sleep 5

# Test it
curl http://localhost:8080/settings

# Clean up
docker stop redlib-test
docker rm redlib-test
```

### 5. Verify Reddit Access
Test that the cipher suite fix works:
```bash
docker run -d -p 8080:8080 --name redlib ghcr.io/mitchross/redlib:latest
```

Then open your browser to:
- http://localhost:8080/r/popular
- http://localhost:8080/r/all

You should NOT see "Failed to parse page JSON data" errors.

## 🔧 Making Changes

### To Update the Image
Simply push to main branch:
```bash
git checkout main
# make your changes
git add .
git commit -m "Your changes"
git push origin main
```

The workflow will automatically rebuild and publish new images.

### To Create a Version Release
Create and push a version tag:
```bash
git tag -a v0.36.1 -m "Release v0.36.1"
git push origin v0.36.1
```

This will create images tagged as:
- `v0.36.1`
- `v0.36`
- `v0`

## 📊 Monitoring

### Check Workflow Status
- Actions: https://github.com/mitchross/redlib/actions
- Workflows: https://github.com/mitchross/redlib/actions/workflows/ghcr.yml

### Check Package
- Packages: https://github.com/mitchross/redlib/pkgs/container/redlib

### Download Statistics
GitHub provides download statistics for packages in the package settings.

## 🐛 Troubleshooting

### Build Fails
If the workflow fails:
1. Check the workflow logs in the Actions tab
2. Look for specific error messages
3. Common issues:
- Missing secrets (GITHUB_TOKEN is automatic)
- Package permissions (check repository settings)
- Build errors (check Rust code compiles locally)

### Image Won't Pull
If users can't pull the image:
1. Verify package visibility is set to "Public"
2. Go to package settings and ensure it's not private
3. Check that the image was published successfully

### Still Getting Rate Limited
If Reddit still blocks requests:
1. Verify the cipher suite fix was applied (check src/client.rs)
2. Consider using Tor/VPN (see upstream documentation)
3. Check if Reddit has changed their blocking mechanism

## 📝 Notes

- Images are automatically cleaned up after 30 days if untagged
- `latest` tag always points to the most recent main branch build
- Multi-arch manifests are created automatically
- Build cache is preserved between runs for faster builds

## 🎉 Success Criteria

Your deployment is successful when:
- [ ] GitHub Actions workflow completes without errors
- [ ] Package appears in GitHub Packages
- [ ] You can pull the image: `docker pull ghcr.io/mitchross/redlib:latest`
- [ ] The container starts successfully
- [ ] Reddit content loads without "Failed to parse JSON" errors
- [ ] All three architectures are available (amd64, arm64, armv7)

## 📚 Additional Resources

- [GitHub Packages Documentation](https://docs.github.com/en/packages)
- [Docker Multi-Platform Images](https://docs.docker.com/build/building/multi-platform/)
- [GitHub Actions Docker Build](https://docs.docker.com/build/ci/github-actions/)
78 changes: 78 additions & 0 deletions DOCKER.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
# Redlib Docker Images on GHCR

This fork publishes Docker images to GitHub Container Registry (GHCR) with the latest cipher suite fixes to avoid Reddit TLS fingerprinting.

## Quick Start

Pull and run the latest image:

```bash
docker pull ghcr.io/mitchross/redlib:latest
docker run -d -p 8080:8080 ghcr.io/mitchross/redlib:latest
```

Then visit http://localhost:8080 in your browser.

## Available Tags

- `latest` - Latest build from the main branch
- `main` - Latest build from the main branch
- `sha-<commit>` - Specific commit builds
- `v*` - Version tagged releases

## Multi-Architecture Support

Images are built for the following architectures:
- `linux/amd64` (x86_64)
- `linux/arm64` (aarch64)
- `linux/arm/v7` (armv7)

Docker will automatically pull the correct image for your platform.

## Docker Compose

Example `docker-compose.yml`:

```yaml
services:
redlib:
image: ghcr.io/mitchross/redlib:latest
ports:
- "8080:8080"
environment:
- REDLIB_DEFAULT_THEME=dark
- REDLIB_DEFAULT_FRONT_PAGE=popular
restart: unless-stopped
```

## Environment Variables

See the main [README](../README.md) for available environment variables.

## What's Different?

This fork includes the cipher suite fix from [PR #510](https://github.com/redlib-org/redlib/pull/510) that resolves Reddit's TLS fingerprinting blocking. The fix changes the TLS cipher suites to match Firefox's configuration.

## Building Locally

To build the image yourself:

```bash
# For amd64
docker build -f Dockerfile.build --build-arg TARGET=x86_64-unknown-linux-musl -t redlib:local .

# For arm64
docker build -f Dockerfile.build --build-arg TARGET=aarch64-unknown-linux-musl -t redlib:local .

# For armv7
docker build -f Dockerfile.build --build-arg TARGET=armv7-unknown-linux-musleabihf -t redlib:local .
```

## Automated Builds

Images are automatically built and pushed to GHCR when:
- Code is pushed to the `main` branch
- A version tag (v*) is created
- Manual workflow dispatch is triggered

The workflow uses GitHub Actions with multi-platform builds via Docker Buildx.
Loading
Loading