.proto 정의 파일을 Go 코드로 변환하는 컴파일러입니다.
- 다운로드: https://github.com/protocolbuffers/protobuf/releases
- 설치 후
PATH에 추가
protoc --version
# libprotoc 34.0# Go protobuf 코드 생성
go install google.golang.org/protobuf/cmd/protoc-gen-go@latest
# Go gRPC 코드 생성
go install google.golang.org/grpc/cmd/protoc-gen-go-grpc@latest
# gRPC Gateway (REST → gRPC 변환 프록시) 코드 생성
go install github.com/grpc-ecosystem/grpc-gateway/v2/protoc-gen-grpc-gateway@latestgRPC Gateway의 HTTP 어노테이션에 필요한 proto 파일입니다. api/proto/google/api/에 위치합니다.
mkdir -p api/proto/google/api
curl -sL https://raw.githubusercontent.com/googleapis/googleapis/master/google/api/annotations.proto \
-o api/proto/google/api/annotations.proto
curl -sL https://raw.githubusercontent.com/googleapis/googleapis/master/google/api/http.proto \
-o api/proto/google/api/http.proto# 클라이언트 바이너리 빌드
make build
# 전체 플랫폼 빌드
make build-all
# 서버 & 클라이언트 컨테이너 빌드
docker build -f delivery/container/server.Dockerfile -t delivery-server .
docker build -f delivery/container/client.Dockerfile -t delivery-client .make proto위 명령은 아래를 실행합니다:
protoc -I api/proto \
--go_out=api/gen/ --go-grpc_out=api/gen/ --grpc-gateway_out=api/gen/ \
--go_opt=paths=source_relative --go-grpc_opt=paths=source_relative --grpc-gateway_opt=paths=source_relative \
api/proto/deploy.proto생성되는 파일:
api/gen/deploy.pb.go— protobuf 메시지 정의api/gen/deploy_grpc.pb.go— gRPC 서버/클라이언트 stubapi/gen/deploy.pb.gw.go— REST gateway reverse proxy
| 패키지 | 용도 |
|---|---|
google.golang.org/grpc |
gRPC 프레임워크 |
google.golang.org/protobuf |
Protocol Buffers 런타임 |
github.com/grpc-ecosystem/grpc-gateway/v2 |
REST API gateway |
github.com/go-git/go-git/v5 |
Git 작업 (clone, fetch, commit, push) |
github.com/fatih/color |
터미널 컬러 출력 |
github.com/joho/godotenv |
.env 파일 로드 |
github.com/sirupsen/logrus |
로깅 |
gopkg.in/yaml.v3 |
YAML 파싱 |
| 도구 | 환경변수 | 기본 경로 | 용도 |
|---|---|---|---|
| kustomize | DELIVERY_KUSTOMIZE_PATH |
/usr/bin/kustomize |
kustomization.yaml 이미지 태그 변경 |
| yq | DELIVERY_YQ_PATH |
/usr/bin/yq |
YAML 파일 값 변경 |
| yamlfmt | DELIVERY_YAMLFMT_PATH |
/usr/bin/yamlfmt |
YAML 포맷팅 |
# 서버 시작
make start
# 클라이언트 실행
make client