Skip to content

Commit

Permalink
fix: standalone dockerized protoc alias (#438)
Browse files Browse the repository at this point in the history
  • Loading branch information
boukeversteegh committed Dec 9, 2021
1 parent dd0928e commit 466f7d9
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 4 deletions.
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"

0 comments on commit 466f7d9

Please sign in to comment.