Skip to content

Commit 8b7b2aa

Browse files
committed
address qodo review: scope packages:write to publish job, document GHCR
Two fixes from the qodo code review on #7569: 1. Overprivileged PR token (security). The original change set 'packages: write' at workflow level, which meant pull_request runs (whose Test step executes PR-controlled code) also inherited push access to GHCR. Splits the workflow into two jobs: - build-test: runs on pull_request and push with contents:read only. Does the single-arch load+test as before. - publish: needs build-test, runs only on push with packages:write. Does the multi-arch build-and-push, Docker Hub description update, and ether-charts bump. Docker Hub login is also now gated by job-level 'if' (same effect as the previous step-level 'if'). 2. Docs miss GHCR option. Updates doc/docker.md and README.md to document the GHCR mirror alongside Docker Hub with equivalent pull examples, so downstream users discovering via docs can choose the mirror to avoid Docker Hub rate limits.
1 parent a3fcd59 commit 8b7b2aa

3 files changed

Lines changed: 42 additions & 20 deletions

File tree

.github/workflows/docker.yml

Lines changed: 27 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,15 @@ on:
1212
- 'v?[0-9]+.[0-9]+.[0-9]+'
1313
env:
1414
TEST_TAG: etherpad/etherpad:test
15+
1516
permissions:
1617
contents: read
17-
packages: write
1818

1919
jobs:
20-
docker:
20+
build-test:
2121
runs-on: ubuntu-latest
22+
permissions:
23+
contents: read
2224
env:
2325
PNPM_HOME: ~/.pnpm-store
2426
steps:
@@ -27,11 +29,6 @@ jobs:
2729
uses: actions/checkout@v6
2830
with:
2931
path: etherpad
30-
31-
-
32-
name: Set up QEMU
33-
if: github.event_name == 'push'
34-
uses: docker/setup-qemu-action@v4
3532
-
3633
name: Set up Docker Buildx
3734
uses: docker/setup-buildx-action@v4
@@ -79,9 +76,28 @@ jobs:
7976
done
8077
(cd src && gnpm run test-container)
8178
git clean -dxf .
79+
80+
publish:
81+
needs: build-test
82+
if: github.event_name == 'push'
83+
runs-on: ubuntu-latest
84+
permissions:
85+
contents: read
86+
packages: write
87+
steps:
88+
-
89+
name: Check out
90+
uses: actions/checkout@v6
91+
with:
92+
path: etherpad
93+
-
94+
name: Set up QEMU
95+
uses: docker/setup-qemu-action@v4
96+
-
97+
name: Set up Docker Buildx
98+
uses: docker/setup-buildx-action@v4
8299
-
83100
name: Docker meta
84-
if: github.event_name == 'push'
85101
id: meta
86102
uses: docker/metadata-action@v6
87103
with:
@@ -95,14 +111,12 @@ jobs:
95111
type=semver,pattern={{major}}
96112
-
97113
name: Log in to Docker Hub
98-
if: github.event_name == 'push'
99114
uses: docker/login-action@v4
100115
with:
101116
username: ${{ secrets.DOCKERHUB_USERNAME }}
102117
password: ${{ secrets.DOCKERHUB_TOKEN }}
103118
-
104119
name: Log in to GHCR
105-
if: github.event_name == 'push'
106120
uses: docker/login-action@v4
107121
with:
108122
registry: ghcr.io
@@ -111,7 +125,6 @@ jobs:
111125
-
112126
name: Build and push
113127
id: build-docker
114-
if: github.event_name == 'push'
115128
uses: docker/build-push-action@v7
116129
with:
117130
context: ./etherpad
@@ -120,6 +133,7 @@ jobs:
120133
push: true
121134
tags: ${{ steps.meta.outputs.tags }}
122135
labels: ${{ steps.meta.outputs.labels }}
136+
cache-from: type=gha
123137
- name: Update repo description
124138
uses: peter-evans/dockerhub-description@v5
125139
if: github.ref == 'refs/heads/master'
@@ -129,8 +143,8 @@ jobs:
129143
password: ${{ secrets.DOCKERHUB_TOKEN }}
130144
repository: etherpad/etherpad
131145
enable-url-completion: true
132-
- name: Check out
133-
if: github.event_name == 'push' && github.ref == 'refs/heads/develop'
146+
- name: Check out ether-charts
147+
if: github.ref == 'refs/heads/develop'
134148
uses: actions/checkout@v6
135149
with:
136150
path: ether-charts

README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,11 +103,13 @@ $env:ETHERPAD_RUN=1; irm https://raw.githubusercontent.com/ether/etherpad/master
103103

104104
### Docker-Compose
105105

106+
The official image is published to both Docker Hub (`etherpad/etherpad`) and GitHub Container Registry (`ghcr.io/ether/etherpad`) with identical tags. Use whichever suits your environment; GHCR avoids Docker Hub's anonymous pull rate limits.
107+
106108
```yaml
107109
services:
108110
app:
109111
user: "0:0"
110-
image: etherpad/etherpad:latest
112+
image: etherpad/etherpad:latest # or: ghcr.io/ether/etherpad:latest
111113
tty: true
112114
stdin_open: true
113115
volumes:

doc/docker.md

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,21 @@
11
# Docker
22

3-
The official Docker image is available on https://hub.docker.com/r/etherpad/etherpad.
3+
The official Docker image is published to two registries with identical tags:
44

5-
## Downloading from Docker Hub
6-
If you are ok downloading a [prebuilt image from Docker Hub](https://hub.docker.com/r/etherpad/etherpad), these are the commands:
5+
- Docker Hub (canonical): https://hub.docker.com/r/etherpad/etherpad
6+
- GitHub Container Registry (mirror): https://github.com/ether/etherpad/pkgs/container/etherpad
7+
8+
The GHCR mirror is useful if you are hitting Docker Hub anonymous pull rate limits (for example on Kubernetes clusters).
9+
10+
## Downloading a prebuilt image
711
```bash
8-
# gets the latest published version
12+
# from Docker Hub
913
docker pull etherpad/etherpad
10-
11-
# gets a specific version
1214
docker pull etherpad/etherpad:2.6.1
15+
16+
# from GHCR (same image, same tags)
17+
docker pull ghcr.io/ether/etherpad
18+
docker pull ghcr.io/ether/etherpad:2.6.1
1319
```
1420

1521
## Build a personalized container

0 commit comments

Comments
 (0)