Skip to content

Commit 332b3ab

Browse files
authored
fix(docker): ship git in the image and document the GitLab entrypoint override (#1109)
1 parent 17ec226 commit 332b3ab

5 files changed

Lines changed: 45 additions & 12 deletions

File tree

‎Dockerfile‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,10 @@ RUN mkdir -p benches && echo 'fn main() {}' > benches/ferrflow_benchmarks.rs \
2525

2626
# Runtime stage
2727
FROM alpine:3.24@sha256:28bd5fe8b56d1bd048e5babf5b10710ebe0bae67db86916198a6eec434943f8b
28-
RUN apk add --no-cache ca-certificates
28+
RUN apk add --no-cache ca-certificates git \
29+
&& git config --system --add safe.directory '*' \
30+
&& git config --system user.name FerrFlow \
31+
&& git config --system user.email bot@ferrflow.com
2932
RUN adduser -D -u 1000 ferrflow
3033
COPY --from=builder /app/target/release/ferrflow /usr/local/bin/ferrflow
3134
USER ferrflow

‎Dockerfile.release‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
FROM alpine:3.24@sha256:28bd5fe8b56d1bd048e5babf5b10710ebe0bae67db86916198a6eec434943f8b
2-
RUN apk upgrade --no-cache && apk add --no-cache ca-certificates
2+
RUN apk upgrade --no-cache && apk add --no-cache ca-certificates git \
3+
&& git config --system --add safe.directory '*' \
4+
&& git config --system user.name FerrFlow \
5+
&& git config --system user.email bot@ferrflow.com
36
RUN adduser -D -u 1000 ferrflow
47
ARG TARGETARCH
58
COPY ferrflow-${TARGETARCH} /usr/local/bin/ferrflow

‎README.md‎

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,8 +73,11 @@ npm install -D ferrflow
7373
docker run --rm -v "$PWD:/repo" ghcr.io/ferrlabs/ferrflow:latest check
7474
```
7575

76-
The image runs as a non-root user (`ferrflow`, uid 1000) and works on `/repo`.
77-
If your checkout is owned by a different uid, pass your own:
76+
The image runs as a non-root user (`ferrflow`, uid 1000) and works on `/repo`. It ships `git`,
77+
trusts the checkout whoever owns it, and signs release commits as `FerrFlow <bot@ferrflow.com>`
78+
unless `GIT_AUTHOR_NAME` / `GIT_AUTHOR_EMAIL` or the repository's own `user.*` config say otherwise.
79+
FerrFlow still needs write access to the files it bumps, so if your checkout is owned by a different
80+
uid, pass your own:
7881

7982
```bash
8083
docker run --rm -u "$(id -u):$(id -g)" -v "$PWD:/repo" ghcr.io/ferrlabs/ferrflow:latest check

‎docs/site/docs-en/ci/gitlab-ci.md‎

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,9 @@ The official FerrFlow Docker image ships the binary and can be used directly as
99

1010
```yaml title=".gitlab-ci.yml"
1111
release:
12-
image: ghcr.io/ferrlabs/ferrflow:latest
12+
image:
13+
name: ghcr.io/ferrlabs/ferrflow:latest
14+
entrypoint: [""]
1315
stage: release
1416
script:
1517
- ferrflow release
@@ -20,14 +22,20 @@ release:
2022
when: on_success
2123
```
2224
25+
The image's entrypoint is `ferrflow`, so `docker run ghcr.io/ferrlabs/ferrflow:latest check` works as is. GitLab runs a job's `script` through a shell instead, which is why every example here resets it with `entrypoint: [""]`. Without that line the job fails with `unrecognized subcommand 'sh'`.
26+
27+
The image ships `git`, trusts the checkout whatever user cloned it, and signs release commits as `FerrFlow <bot@ferrflow.com>`. To sign them as the person who triggered the pipeline instead, set `GIT_AUTHOR_NAME: $GITLAB_USER_NAME` and `GIT_AUTHOR_EMAIL: $GITLAB_USER_EMAIL` in the job variables.
28+
2329
<aside class="ferr-aside ferr-aside--warning"><div class="ferr-aside__body"><p>Make sure your CI runner clones with full history. Add <code>GIT_DEPTH: 0</code> to the job variables to disable shallow cloning.</p>
2430
</div></aside>
2531

2632
## Full history
2733

2834
```yaml title=".gitlab-ci.yml"
2935
release:
30-
image: ghcr.io/ferrlabs/ferrflow:latest
36+
image:
37+
name: ghcr.io/ferrlabs/ferrflow:latest
38+
entrypoint: [""]
3139
variables:
3240
GIT_DEPTH: 0 # full history: required for tag scanning
3341
GITLAB_TOKEN: $CI_JOB_TOKEN
@@ -43,7 +51,9 @@ If `CI_JOB_TOKEN` doesn't have permission to push tags, create a project deploy
4351

4452
```yaml title=".gitlab-ci.yml"
4553
release:
46-
image: ghcr.io/ferrlabs/ferrflow:latest
54+
image:
55+
name: ghcr.io/ferrlabs/ferrflow:latest
56+
entrypoint: [""]
4757
variables:
4858
GIT_DEPTH: 0
4959
GITLAB_TOKEN: $FERRFLOW_DEPLOY_TOKEN # CI variable with write_repository access
@@ -59,7 +69,9 @@ FerrFlow can post a comment on every merge request showing what versions will be
5969

6070
```yaml title=".gitlab-ci.yml"
6171
ferrflow-preview:
62-
image: ghcr.io/ferrlabs/ferrflow:latest
72+
image:
73+
name: ghcr.io/ferrlabs/ferrflow:latest
74+
entrypoint: [""]
6375
stage: test
6476
variables:
6577
GIT_DEPTH: 0

‎docs/site/docs-fr/ci/gitlab-ci.md‎

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,9 @@ L'image Docker officielle FerrFlow embarque le binaire et peut être utilisée d
99

1010
```yaml
1111
release:
12-
image: ghcr.io/ferrlabs/ferrflow:latest
12+
image:
13+
name: ghcr.io/ferrlabs/ferrflow:latest
14+
entrypoint: [""]
1315
stage: release
1416
script:
1517
- ferrflow release
@@ -20,14 +22,20 @@ release:
2022
when: on_success
2123
```
2224
25+
Le point d'entrée de l'image est `ferrflow`, donc `docker run ghcr.io/ferrlabs/ferrflow:latest check` fonctionne tel quel. GitLab, lui, exécute le `script` d'un job dans un shell : c'est pourquoi chaque exemple ici le réinitialise avec `entrypoint: [""]`. Sans cette ligne, le job échoue avec `unrecognized subcommand 'sh'`.
26+
27+
L'image embarque `git`, fait confiance au dépôt quel que soit l'utilisateur qui l'a cloné, et signe les commits de release `FerrFlow <bot@ferrflow.com>`. Pour les signer au nom de la personne qui a déclenché le pipeline, définissez `GIT_AUTHOR_NAME: $GITLAB_USER_NAME` et `GIT_AUTHOR_EMAIL: $GITLAB_USER_EMAIL` dans les variables du job.
28+
2329
<aside class="ferr-aside ferr-aside--warning"><div class="ferr-aside__body"><p>Assurez-vous que votre runner CI clone avec l&#39;historique complet. Ajoutez <code>GIT_DEPTH: 0</code> aux variables du job pour désactiver le clonage superficiel.</p>
2430
</div></aside>
2531

2632
## Historique complet
2733

2834
```yaml
2935
release:
30-
image: ghcr.io/ferrlabs/ferrflow:latest
36+
image:
37+
name: ghcr.io/ferrlabs/ferrflow:latest
38+
entrypoint: [""]
3139
variables:
3240
GIT_DEPTH: 0 # historique complet : requis pour le scan des tags
3341
GITLAB_TOKEN: $CI_JOB_TOKEN
@@ -43,7 +51,9 @@ Si `CI_JOB_TOKEN` n'a pas les permissions pour pousser des tags, créez un deplo
4351

4452
```yaml
4553
release:
46-
image: ghcr.io/ferrlabs/ferrflow:latest
54+
image:
55+
name: ghcr.io/ferrlabs/ferrflow:latest
56+
entrypoint: [""]
4757
variables:
4858
GIT_DEPTH: 0
4959
GITLAB_TOKEN: $FERRFLOW_DEPLOY_TOKEN # variable CI avec accès write_repository
@@ -59,7 +69,9 @@ FerrFlow peut poster un commentaire sur chaque merge request montrant quelles ve
5969

6070
```yaml title=".gitlab-ci.yml"
6171
ferrflow-preview:
62-
image: ghcr.io/ferrlabs/ferrflow:latest
72+
image:
73+
name: ghcr.io/ferrlabs/ferrflow:latest
74+
entrypoint: [""]
6375
stage: test
6476
variables:
6577
GIT_DEPTH: 0

0 commit comments

Comments
 (0)