Skip to content

Commit

Permalink
chore: fix permissions of files generated in docker (cosmos#1276)
Browse files Browse the repository at this point in the history
<!--
Please read and fill out this form before submitting your PR.

Please make sure you have reviewed our contributors guide before
submitting your
first PR.
-->

## Overview

Currently, docker is executed with default privileges (as root), which
makes it hard to deal with files generated by `make proto-gen`. As a
workaround, files are copied to a new directory (to get correct access
rights), and the original directory is a part of .gitignore.

The solution consists of three improvements:
 - -u flag added to docker command to run as the current user
- XDG_CHACHE_HOME modified, to mitigate access permissions (it's picked
up by buf process inside container)
 - buf output directory is set properly, so there is no need for copying


<!-- 
Please provide an explanation of the PR, including the appropriate
context,
background, goal, and rationale. If there is an issue with this
information,
please provide a tl;dr and link the issue. 
-->

## Checklist

<!-- 
Please complete the checklist to ensure that the PR is ready to be
reviewed.

IMPORTANT:
PRs should be left in Draft until the below checklist is completed.
-->

- [x] New and updated code has appropriate documentation
- [x] New and updated code has new and/or updated testing
- [ ] Required CI checks are passing
- [x] Visual proof for any user facing features like CLI or
documentation updates
- [ ] Linked issues closed with keywords


<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit

### Summary by CodeRabbit

- Chore: Updated the script used for generating protocol buffers. The
changes ensure that the script runs in a more secure and efficient
manner by using the current user's UID and GID, and by setting the cache
directory to a temporary location. This will help in maintaining the
cleanliness of the project directory and improve the overall development
experience. Please note that the copying of protocol buffer files to the
target directory has been removed, so you may need to adjust your
workflow accordingly.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
  • Loading branch information
tzdybal authored Oct 30, 2023
1 parent 66b4e9b commit d916f48
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 4 deletions.
4 changes: 2 additions & 2 deletions buf.gen.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ version: v1beta1
plugins:
# The name of the plugin.
- name: gogofaster
# The the relative output directory.
out: proto/pb
# The relative output directory.
out: types/pb
# Any options to provide to the plugin.
opt: plugins=grpc,paths=source_relative
3 changes: 1 addition & 2 deletions proto/gen.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@ TARGET_DIR=./types/pb
cd $SCRIPT_DIR
mkdir -p $TARGET_DIR
rm -rf $TARGET_DIR/*
docker run -v $PWD:/workspace --workdir /workspace tendermintdev/docker-build-proto sh ./proto/protoc.sh
docker run -u $UID:$(id -g) -e XDG_CACHE_HOME=/tmp/.cache -v $PWD:/workspace --workdir /workspace tendermintdev/docker-build-proto sh ./proto/protoc.sh

cp -r ./proto/pb/* $TARGET_DIR/

rm -rf $TARGET_DIR/tendermint

0 comments on commit d916f48

Please sign in to comment.