mirror of
https://github.com/orhun/git-cliff.git
synced 2024-11-29 15:42:15 +03:00
refactor(docker): avoid copying volume inside container (#142)
* refactor(docker): avoid copying volume inside container * docs(readme): Fix Docker tips to mount project, not just repository Otherwise any project configs have no chance of being read...
This commit is contained in:
parent
870d31f3b2
commit
65d365c7b5
26
Dockerfile
26
Dockerfile
@ -15,12 +15,26 @@ RUN cargo build --release --locked --no-default-features
|
||||
RUN rm -f target/release/deps/git_cliff*
|
||||
|
||||
FROM debian:buster-slim as runner
|
||||
|
||||
# Everything inside this container will be explicitly mounted by the end user,
|
||||
# so we can sidestep some Git security restrictions. This app recommends
|
||||
# mounting data to /app, but this *can* be changed externally and *will* be
|
||||
# changed when run by GitHub Actions, so we need to cover our bases.
|
||||
RUN echo '[safe]\n\tdirectory = *' > /etc/gitconfig
|
||||
|
||||
COPY --from=builder /app/target/release/git-cliff /usr/local/bin
|
||||
WORKDIR git-home
|
||||
RUN cat <<'EOF' > entrypoint.sh
|
||||
WORKDIR app
|
||||
|
||||
# Even if the repository as marked as safe, GitHub Actions and some other
|
||||
# environments insist on running the entrypoint as root inside the container
|
||||
# even when being run by a non priviledged user on their own files. Here we
|
||||
# check the ownership of the workdir (which may or may not be /app) and change
|
||||
# our effective user/group ID to match.
|
||||
RUN cat <<'EOF' > /usr/local/bin/entrypoint.sh
|
||||
#!/bin/sh
|
||||
cp -r /app /git-home/app
|
||||
cd /git-home/app
|
||||
exec git-cliff "$@"
|
||||
if [ "$(id -u)" -ne "$(stat -c '%u' .)" ]; then
|
||||
eids="$(stat -c '--euid %u --egid %g' .)"
|
||||
fi
|
||||
exec ${eids:+setpriv --clear-groups $eids} git-cliff $@
|
||||
EOF
|
||||
ENTRYPOINT ["sh", "entrypoint.sh"]
|
||||
ENTRYPOINT ["sh", "/usr/local/bin/entrypoint.sh"]
|
||||
|
@ -15,13 +15,13 @@ Docker builds are [automated](https://github.com/orhun/git-cliff/tree/main/.gith
|
||||
The easiest way of running **git-cliff** (in the git root directory with [configuration file](/docs/configuration) present) is to use the available tags from [Docker Hub](https://hub.docker.com/r/orhunp/git-cliff):
|
||||
|
||||
```bash
|
||||
docker run -t -v "$(pwd)/.git":/app/ "orhunp/git-cliff:${TAG:-latest}"
|
||||
docker run -t -v "$(pwd)":/app/ "orhunp/git-cliff:${TAG:-latest}"
|
||||
```
|
||||
|
||||
Or you can use the image from the [GitHub Package Registry](https://github.com/orhun/git-cliff/pkgs/container/git-cliff%2Fgit-cliff):
|
||||
|
||||
```bash
|
||||
docker run -t -v "$(pwd)/.git":/app/ "ghcr.io/orhun/git-cliff/git-cliff:${TAG:-latest}"
|
||||
docker run -t -v "$(pwd)":/app/ "ghcr.io/orhun/git-cliff/git-cliff:${TAG:-latest}"
|
||||
```
|
||||
|
||||
### Building
|
||||
|
Loading…
Reference in New Issue
Block a user