Skip to content

Commit 466f7d9

Browse files
fix: standalone dockerized protoc alias (#438)
1 parent dd0928e commit 466f7d9

File tree

3 files changed

+19
-4
lines changed

3 files changed

+19
-4
lines changed

.gitattributes

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
*.sh text eol=lf
22
parameters.txt text eol=lf
33
protoc-gen-dump text eol=lf
4+
protoc-gen-ts_proto text eol=lf

aliases.sh

+17-4
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,23 @@
22
PROJECT_ROOT=$(realpath $(dirname "$BASH_SOURCE"))
33
PROJECT_ROOT_DOCKER="//ts-proto" # double slash to support git bash on windows
44

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

8-
function protoc() { _docker-compose run --rm protoc "$@"; }
9-
function protoc-sh() { _docker-compose run --rm --entrypoint sh -- protoc "$@"; }
8+
# Dockerized version of protoc.
9+
function protoc() { _docker-compose run --rm -w //host --entrypoint protoc -- protoc "$@"; }
10+
11+
# Open a shell in the dockerized version of protoc, useful for debugging.
12+
function protoc-sh() { _docker-compose run --rm -w //host -- protoc "$@"; }
13+
14+
# Rebuild the docker image.
1015
function protoc-build() { _docker-compose build protoc; }
11-
function ts-protoc { protoc --plugin=$PROJECT_ROOT_DOCKER/protoc-gen-ts_proto "$@"; }
16+
17+
# Run protoc with the plugin path pre-set.
18+
function ts-protoc {
19+
if [ ! -d "$PROJECT_ROOT/build" ]; then
20+
echo "Run 'yarn build' first"
21+
return 1
22+
fi
23+
protoc --plugin=$PROJECT_ROOT_DOCKER/protoc-gen-ts_proto "$@";
24+
}

docker-compose.yml

+1
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,4 @@ services:
66
dockerfile: "protoc.Dockerfile"
77
volumes:
88
- ".:/ts-proto"
9+
- "${PWD:-.}:/host"

0 commit comments

Comments
 (0)