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
44 changes: 44 additions & 0 deletions .github/DOCKER_AUTH_SETUP.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# Docker Hub Authentication Setup for CI

## Problem
GitHub Actions CI workflows were failing with Docker Hub authentication errors:
```
unauthorized: authentication required
```

This happens when GitHub Actions tries to pull Docker images (postgres:15, redis:7) but hits Docker Hub rate limits for unauthenticated requests.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The PostgreSQL version postgres:15 mentioned here is inconsistent with the postgres:16-alpine version specified in the project's docker-compose.yml. While the CI environment might use a different version, this discrepancy can be confusing for developers. To improve clarity, please ensure the version number in the documentation is accurate for the context it describes (CI).


## Solution Implemented

### 1. CI Workflow Changes
- Added Docker Hub credential environment variables to the workflow
- Added Docker login step before jobs that use Docker service containers
- Made authentication optional with `continue-on-error: true` so CI still works without credentials

### 2. Required GitHub Secrets Setup

To enable Docker Hub authentication, add these secrets to your repository:

1. Go to Settings → Secrets and variables → Actions
2. Add two new repository secrets:
- `DOCKERHUB_USERNAME`: Your Docker Hub username
- `DOCKERHUB_TOKEN`: Your Docker Hub access token (NOT your password)

### 3. How to Create Docker Hub Access Token

1. Log in to [Docker Hub](https://hub.docker.com)
2. Click on your username → Account Settings
3. Select "Security" → "New Access Token"
4. Give it a descriptive name like "GitHub Actions CI"
5. Copy the token and save it as `DOCKERHUB_TOKEN` secret in GitHub

## Benefits
- Avoids Docker Hub rate limits (100 pulls/6hr for anonymous vs 200 pulls/6hr for authenticated)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

To provide an authoritative source for the rate limit figures, it's helpful to link to the official Docker Hub documentation. This allows users to verify the information and stay informed about any changes to Docker's policies.

Suggested change
- Avoids Docker Hub rate limits (100 pulls/6hr for anonymous vs 200 pulls/6hr for authenticated)
- Avoids Docker Hub rate limits ([100 pulls/6hr for anonymous vs 200 pulls/6hr for authenticated](https://docs.docker.com/docker-hub/download-rate-limit/))

- CI runs more reliably without authentication failures
- Optional - CI still works without credentials, just with lower rate limits

## Files Modified
- `.github/workflows/ci.yml`: Added Docker authentication steps

## Testing
After adding the secrets, the CI will automatically use Docker Hub authentication for all Docker image pulls.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

It is a standard convention for text files to end with a single newline character. Some tools may have issues processing files that lack a final newline. Please add one to adhere to this best practice.

Suggested change
After adding the secrets, the CI will automatically use Docker Hub authentication for all Docker image pulls.
After adding the secrets, the CI will automatically use Docker Hub authentication for all Docker image pulls.

19 changes: 19 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ permissions:
env:
FLUTTER_VERSION: '3.35.3'
RUST_VERSION: '1.89.0'
# Docker Hub credentials - optional but recommended to avoid rate limits
DOCKER_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }}
DOCKER_TOKEN: ${{ secrets.DOCKERHUB_TOKEN }}

concurrency:
group: core-ci-${{ github.ref }}-${{ github.event_name }}
Expand Down Expand Up @@ -275,6 +278,14 @@ jobs:
steps:
- uses: actions/checkout@v4

- name: Login to Docker Hub
if: env.DOCKER_USERNAME != '' && env.DOCKER_TOKEN != ''
Copy link

Copilot AI Sep 25, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The condition checks for non-empty strings, but GitHub Actions environment variables are undefined (not empty strings) when secrets don't exist. Use if: env.DOCKER_USERNAME && env.DOCKER_TOKEN instead to properly check for the existence of these variables.

Suggested change
if: env.DOCKER_USERNAME != '' && env.DOCKER_TOKEN != ''
if: env.DOCKER_USERNAME && env.DOCKER_TOKEN

Copilot uses AI. Check for mistakes.

uses: docker/login-action@v3
with:
username: ${{ env.DOCKER_USERNAME }}
password: ${{ env.DOCKER_TOKEN }}
continue-on-error: true

- name: Setup Rust
if: env.DOCS_ONLY != 'true'
uses: dtolnay/rust-toolchain@stable
Expand Down Expand Up @@ -508,6 +519,14 @@ jobs:
steps:
- uses: actions/checkout@v4

- name: Login to Docker Hub
if: env.DOCKER_USERNAME != '' && env.DOCKER_TOKEN != ''
Copy link

Copilot AI Sep 25, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same issue as the previous Docker login step - the condition checks for non-empty strings, but GitHub Actions environment variables are undefined when secrets don't exist. Use if: env.DOCKER_USERNAME && env.DOCKER_TOKEN instead.

Suggested change
if: env.DOCKER_USERNAME != '' && env.DOCKER_TOKEN != ''
if: env.DOCKER_USERNAME && env.DOCKER_TOKEN

Copilot uses AI. Check for mistakes.

uses: docker/login-action@v3
with:
username: ${{ env.DOCKER_USERNAME }}
password: ${{ env.DOCKER_TOKEN }}
continue-on-error: true

- name: Setup Rust
uses: dtolnay/rust-toolchain@stable
with:
Expand Down