Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: dockerized protoc aliases #438

Merged
merged 1 commit into from
Dec 9, 2021
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
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
*.sh text eol=lf
parameters.txt text eol=lf
protoc-gen-dump text eol=lf
protoc-gen-ts_proto text eol=lf
21 changes: 17 additions & 4 deletions aliases.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,23 @@
PROJECT_ROOT=$(realpath $(dirname "$BASH_SOURCE"))
PROJECT_ROOT_DOCKER="//ts-proto" # double slash to support git bash on windows

# Alias docker-compose to make it usable from anywhere
# Alias docker-compose to make it usable from anywhere.
function _docker-compose() { docker-compose -f $PROJECT_ROOT/docker-compose.yml "$@"; }

function protoc() { _docker-compose run --rm protoc "$@"; }
function protoc-sh() { _docker-compose run --rm --entrypoint sh -- protoc "$@"; }
# Dockerized version of protoc.
function protoc() { _docker-compose run --rm -w //host --entrypoint protoc -- protoc "$@"; }

# Open a shell in the dockerized version of protoc, useful for debugging.
function protoc-sh() { _docker-compose run --rm -w //host -- protoc "$@"; }

# Rebuild the docker image.
function protoc-build() { _docker-compose build protoc; }
function ts-protoc { protoc --plugin=$PROJECT_ROOT_DOCKER/protoc-gen-ts_proto "$@"; }

# Run protoc with the plugin path pre-set.
function ts-protoc {
if [ ! -d "$PROJECT_ROOT/build" ]; then
echo "Run 'yarn build' first"
return 1
fi
protoc --plugin=$PROJECT_ROOT_DOCKER/protoc-gen-ts_proto "$@";
}
1 change: 1 addition & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@ services:
dockerfile: "protoc.Dockerfile"
volumes:
- ".:/ts-proto"
- "${PWD:-.}:/host"