|
|
@@ -0,0 +1,82 @@
|
|
|
+# Swift gRPC in Docker
|
|
|
+
|
|
|
+Swift gRPC works great within Docker.
|
|
|
+Follow these steps to build and run Swift gRPC in the Docker container
|
|
|
+from [swiftdocker](https://github.com/swiftdocker/docker-swift).
|
|
|
+
|
|
|
+## Prerequisites
|
|
|
+
|
|
|
+[Docker for Mac](https://docs.docker.com/docker-for-mac/).
|
|
|
+
|
|
|
+## Fetch the Docker image
|
|
|
+
|
|
|
+Run this command on your local system:
|
|
|
+
|
|
|
+`docker pull swiftdocker/swift`
|
|
|
+
|
|
|
+## Start Docker
|
|
|
+
|
|
|
+Start a docker instance with the swiftdocker image:
|
|
|
+
|
|
|
+`docker run -it --name swiftgrpc swiftdocker/swift:latest /bin/bash`
|
|
|
+
|
|
|
+## Install Dependencies
|
|
|
+
|
|
|
+ # update package list
|
|
|
+ apt-get update
|
|
|
+ # install a few missing pieces
|
|
|
+ apt-get install libz-dev
|
|
|
+
|
|
|
+## Configure git (optional)
|
|
|
+
|
|
|
+ git config --global user.email <your email address>
|
|
|
+ git config --global user.name "<your name>"
|
|
|
+
|
|
|
+## Get grpc-swift
|
|
|
+
|
|
|
+ cd
|
|
|
+ git clone https://github.com/grpc/grpc-swift
|
|
|
+
|
|
|
+## Run the grpc-swift unit tests
|
|
|
+
|
|
|
+ cd grpc-swift
|
|
|
+ make test
|
|
|
+
|
|
|
+## Build the Echo sample
|
|
|
+
|
|
|
+ cd
|
|
|
+ cd grpc-swift/Examples/Echo/Swift/SwiftPM
|
|
|
+ make
|
|
|
+
|
|
|
+## Run the test client and server
|
|
|
+
|
|
|
+ # start the server
|
|
|
+ .build/debug/Echo serve &
|
|
|
+ # run the client to test each Echo API
|
|
|
+ .build/debug/Echo get
|
|
|
+ .build/debug/Echo expand
|
|
|
+ .build/debug/Echo collect
|
|
|
+ .build/debug/Echo update
|
|
|
+
|
|
|
+## Test the Swift gRPC plugin
|
|
|
+
|
|
|
+ # install protoc build dependencies
|
|
|
+ apt-get install autoconf automake libtool curl make g++ unzip
|
|
|
+ # build and install protoc
|
|
|
+ cd
|
|
|
+ git clone https://github.com/google/protobuf.git
|
|
|
+ cd protobuf
|
|
|
+ autogen.sh
|
|
|
+ ./configure
|
|
|
+ make install
|
|
|
+ # build the Swift gRPC plugin
|
|
|
+ cd
|
|
|
+ cd grpc-swift/Plugin
|
|
|
+ make
|
|
|
+ # set envirinment variables to allow protoc and the plugin to run
|
|
|
+ export LD_LIBRARY_PATH=/usr/local/lib
|
|
|
+ export PATH=.:$PATH
|
|
|
+ # test the plugin by regenerating code for a sample .proto service
|
|
|
+ make test
|
|
|
+
|
|
|
+
|