Skip to content

Latest commit

 

History

History
76 lines (51 loc) · 1.71 KB

DOCKER.md

File metadata and controls

76 lines (51 loc) · 1.71 KB

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.

Prerequisites

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 unzip

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
cd
curl -O -L https://github.com/google/protobuf/releases/download/v3.2.0rc2/protoc-3.2.0rc2-linux-x86_64.zip
unzip protoc-3.2.0rc2-linux-x86_64.zip -d /usr
# build the Swift gRPC plugin
cd
cd grpc-swift/Plugin
make
# set environment variables to allow protoc and the plugin to run 
export PATH=.:$PATH
# test the plugin by regenerating code for a sample .proto service
make test