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
8 changes: 3 additions & 5 deletions api/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -31,24 +31,22 @@ __check-breaking_local:

.PHONY: proto lint format check-breaking
all proto lint format check-breaking:
../contrib/scripts/repo-docker-run.sh --rm \
../contrib/scripts/repo-docker-run.sh \
--volume $(CURDIR)/..:/src \
--workdir /src/api \
--user "$(shell id -u):$(shell id -g)" \
$(BUILDER_IMAGE) \
make -C /src/api __$@_local BUF_BREAKING_AGAINST_BRANCH=$(BUF_BREAKING_AGAINST_BRANCH)

.PHONY: debug
debug:
@echo ../contrib/scripts/repo-docker-run.sh --rm \
@echo ../contrib/scripts/repo-docker-run.sh \
--volume $(CURDIR)/..:/src \
--workdir /src/api \
--user "$(shell id -u):$(shell id -g)" \
$(BUILDER_IMAGE) \
buf $(EXTRA_BUF_FLAGS)

.PHONY: vendor
vendor:
$(GO) mod tidy
$(GO) mod vendor
$(GO) mod verify
$(GO) mod verify
16 changes: 9 additions & 7 deletions contrib/scripts/repo-docker-run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
#
# See: https://github.com/buildroot/buildroot/blob/master/utils/docker-run


CONTAINER_ENGINE="${CONTAINER_ENGINE:-docker}"
DIR=$(dirname "${0}")
MAIN_DIR=$(readlink -f "${DIR}/..")
MAIN_DIR=$(realpath "${DIR}/../..")
if [ -L "${MAIN_DIR}/.git/config" ]; then
# Support git-new-workdir
GIT_DIR="$(dirname "$(realpath "${MAIN_DIR}/.git/config")")"
Expand All @@ -24,19 +24,21 @@ declare -a mountpoints=(
# to know about worktrees, so we're not in a worktree either. So it means
# we're in the main git working copy, and thus we don't need to mount the
# .git directory.
if [ "${GIT_DIR}" ]; then
# If GID_DIR is ".git", then we are in the main git working copy, and ".git"
# directory will be included in the main Docker volume.
if [[ "${GIT_DIR}" && "${GIT_DIR}" != ".git" ]]; then
# GIT_DIR in the main working copy (when git supports worktrees) will
# be just '.git', but 'docker run' needs an absolute path. If it is
# not absolute, GIT_DIR is relative to MAIN_DIR. If it's an absolute
# path already (in a wordir), then that's a noop.
GIT_DIR="$(cd "${MAIN_DIR}"; readlink -e "${GIT_DIR}")"
GIT_DIR="$(cd "${MAIN_DIR}"; realpath "${GIT_DIR}")"
mountpoints+=( "${GIT_DIR}" )

# 'repo' stores .git/objects separately.
if [ -L "${GIT_DIR}/objects" ]; then
# GITDIR is already an absolute path, but for symetry
# with the above, keep the same cd+readlink construct.
OBJECTS_DIR="$(cd "${MAIN_DIR}"; readlink -e "${GIT_DIR}/objects")"
# with the above, keep the same cd+realpath construct.
OBJECTS_DIR="$(cd "${MAIN_DIR}"; realpath "${GIT_DIR}/objects")"
mountpoints+=( "${OBJECTS_DIR}" )
fi
fi
Expand All @@ -51,4 +53,4 @@ for dir in $(printf '%s\n' "${mountpoints[@]}" |LC_ALL=C sort -u); do
docker_opts+=( --mount "type=bind,src=${dir},dst=${dir}" )
done

docker run "${docker_opts[@]}" "${@}"
"${CONTAINER_ENGINE}" run "${docker_opts[@]}" "${@}"
Loading