-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit faaed6a
Showing
16 changed files
with
370 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
# Miscellaneous | ||
*.class | ||
*.lock | ||
*.log | ||
*.pyc | ||
*.swp | ||
.DS_Store | ||
.atom/ | ||
.buildlog/ | ||
.history | ||
.svn/ | ||
|
||
# IntelliJ related | ||
*.iml | ||
*.ipr | ||
*.iws | ||
.idea/ |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
module github.com/dave/cfag-server |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
FROM google/dart | ||
|
||
RUN apt-get update && \ | ||
apt-get install -y curl unzip wget | ||
|
||
######################################## | ||
### Install the dart protobuf plugin ### | ||
######################################## | ||
RUN cd / && \ | ||
git clone https://github.com/dart-lang/protobuf.git dart-pb && \ | ||
cd /dart-pb && \ | ||
git checkout 2f6fa9f97384ae4749e4f414d7d00d4b79f8fb01 && \ | ||
cd /dart-pb/protoc_plugin && \ | ||
pub install | ||
|
||
ENV PATH="/dart-pb/protoc_plugin/bin:${PATH}" | ||
|
||
################################################################################## | ||
### Copied from https://github.com/znly/docker-protobuf/blob/master/Dockerfile ### | ||
################################################################################## | ||
RUN mkdir -p /protobuf/google/protobuf && \ | ||
for f in any duration descriptor empty struct timestamp wrappers; do \ | ||
curl -L -o /protobuf/google/protobuf/${f}.proto https://raw.githubusercontent.com/google/protobuf/master/src/google/protobuf/${f}.proto; \ | ||
done && \ | ||
mkdir -p /protobuf/google/api && \ | ||
for f in annotations http; do \ | ||
curl -L -o /protobuf/google/api/${f}.proto https://raw.githubusercontent.com/grpc-ecosystem/grpc-gateway/master/third_party/googleapis/google/api/${f}.proto; \ | ||
done && \ | ||
mkdir -p /protobuf/github.com/gogo/protobuf/gogoproto && \ | ||
curl -L -o /protobuf/github.com/gogo/protobuf/gogoproto/gogo.proto https://raw.githubusercontent.com/gogo/protobuf/master/gogoproto/gogo.proto && \ | ||
mkdir -p /protobuf/github.com/mwitkow/go-proto-validators && \ | ||
curl -L -o /protobuf/github.com/mwitkow/go-proto-validators/validator.proto https://raw.githubusercontent.com/mwitkow/go-proto-validators/master/validator.proto | ||
|
||
################################## | ||
### Install the protoc command ### | ||
################################## | ||
RUN curl -OL https://github.com/google/protobuf/releases/download/v3.2.0/protoc-3.2.0-linux-x86_64.zip && \ | ||
unzip protoc-3.2.0-linux-x86_64.zip -d protoc3 && \ | ||
mv protoc3/bin/* /usr/bin/ && \ | ||
mv protoc3/include/* /usr/local/include/ | ||
|
||
################## | ||
### Install Go ### | ||
################## | ||
RUN wget https://storage.googleapis.com/golang/go1.11.4.linux-amd64.tar.gz && \ | ||
tar -C /usr/local -xzf go1.11.4.linux-amd64.tar.gz && \ | ||
mkdir /go | ||
|
||
ENV GOPATH /root/ | ||
ENV PATH $PATH:/root/bin | ||
ENV PATH $PATH:/usr/local/go/bin | ||
|
||
###################################### | ||
### Install the Go protobuf plugin ### | ||
###################################### | ||
RUN go get -u github.com/golang/protobuf/proto && \ | ||
go get -u github.com/golang/protobuf/protoc-gen-go | ||
|
||
##################################################### | ||
### Setup the entrypoint and default library path ### | ||
##################################################### | ||
ENTRYPOINT ["/usr/bin/protoc", "-I/protobuf"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
SRC_DIR=. | ||
GO_DST_DIR=./go/cfagproto | ||
DART_DST_DIR=./dart/cfagproto | ||
|
||
build: | ||
docker build -t protoc . | ||
|
||
compile: | ||
docker run --rm -v $(PWD):$(PWD) -w $(PWD) protoc --dart_out=${DART_DST_DIR} --go_out=${GO_DST_DIR} -I. cfag.proto |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
syntax = "proto3"; | ||
package cfagproto; | ||
|
||
message Person { | ||
string first_name = 1; | ||
string last_name = 2; | ||
string email = 3; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
/// | ||
// Generated code. Do not modify. | ||
// source: cfag.proto | ||
/// | ||
// ignore_for_file: non_constant_identifier_names,library_prefixes,unused_import | ||
|
||
// ignore: UNUSED_SHOWN_NAME | ||
import 'dart:core' show int, bool, double, String, List, Map, override; | ||
|
||
import 'package:protobuf/protobuf.dart' as $pb; | ||
|
||
class Person extends $pb.GeneratedMessage { | ||
static final $pb.BuilderInfo _i = new $pb.BuilderInfo('Person', package: const $pb.PackageName('cfagproto')) | ||
..aOS(1, 'firstName') | ||
..aOS(2, 'lastName') | ||
..aOS(3, 'email') | ||
..hasRequiredFields = false | ||
; | ||
|
||
Person() : super(); | ||
Person.fromBuffer(List<int> i, [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) : super.fromBuffer(i, r); | ||
Person.fromJson(String i, [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) : super.fromJson(i, r); | ||
Person clone() => new Person()..mergeFromMessage(this); | ||
Person copyWith(void Function(Person) updates) => super.copyWith((message) => updates(message as Person)); | ||
$pb.BuilderInfo get info_ => _i; | ||
static Person create() => new Person(); | ||
static $pb.PbList<Person> createRepeated() => new $pb.PbList<Person>(); | ||
static Person getDefault() => _defaultInstance ??= create()..freeze(); | ||
static Person _defaultInstance; | ||
static void $checkItem(Person v) { | ||
if (v is! Person) $pb.checkItemFailed(v, _i.qualifiedMessageName); | ||
} | ||
|
||
String get firstName => $_getS(0, ''); | ||
set firstName(String v) { $_setString(0, v); } | ||
bool hasFirstName() => $_has(0); | ||
void clearFirstName() => clearField(1); | ||
|
||
String get lastName => $_getS(1, ''); | ||
set lastName(String v) { $_setString(1, v); } | ||
bool hasLastName() => $_has(1); | ||
void clearLastName() => clearField(2); | ||
|
||
String get email => $_getS(2, ''); | ||
set email(String v) { $_setString(2, v); } | ||
bool hasEmail() => $_has(2); | ||
void clearEmail() => clearField(3); | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
/// | ||
// Generated code. Do not modify. | ||
// source: cfag.proto | ||
/// | ||
// ignore_for_file: non_constant_identifier_names,library_prefixes,unused_import | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
/// | ||
// Generated code. Do not modify. | ||
// source: cfag.proto | ||
/// | ||
// ignore_for_file: non_constant_identifier_names,library_prefixes,unused_import | ||
|
||
const Person$json = const { | ||
'1': 'Person', | ||
'2': const [ | ||
const {'1': 'first_name', '3': 1, '4': 1, '5': 9, '10': 'firstName'}, | ||
const {'1': 'last_name', '3': 2, '4': 1, '5': 9, '10': 'lastName'}, | ||
const {'1': 'email', '3': 3, '4': 1, '5': 9, '10': 'email'}, | ||
], | ||
}; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
/// | ||
// Generated code. Do not modify. | ||
// source: cfag.proto | ||
/// | ||
// ignore_for_file: non_constant_identifier_names,library_prefixes,unused_import | ||
|
||
export 'cfag.pb.dart'; | ||
|
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
# This file specifies files that are *not* uploaded to Google Cloud Platform | ||
# using gcloud. It follows the same syntax as .gitignore, with the addition of | ||
# "#!include" directives (which insert the entries of the given .gitignore-style | ||
# file at that point). | ||
# | ||
# For more information, run: | ||
# $ gcloud topic gcloudignore | ||
# | ||
.gcloudignore | ||
# If you would like to upload your .git directory, .gitignore file or files | ||
# from your .gitignore file, remove the corresponding line | ||
# below: | ||
.git | ||
.gitignore | ||
|
||
# Binaries for programs and plugins | ||
*.exe | ||
*.exe~ | ||
*.dll | ||
*.so | ||
*.dylib | ||
# Test binary, build with `go test -c` | ||
*.test | ||
# Output of the go coverage tool, specifically when used with LiteIDE | ||
*.out |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
VER=v1 | ||
PROJECT=cfag-a2ffd | ||
|
||
switch: | ||
gcloud config set project ${PROJECT} | ||
|
||
init: | ||
gcloud app create | ||
|
||
deploy: | ||
gcloud app deploy |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
runtime: go111 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
package main | ||
|
||
import ( | ||
"fmt" | ||
"log" | ||
"net/http" | ||
"os" | ||
) | ||
|
||
func main() { | ||
http.HandleFunc("/", indexHandler) | ||
|
||
port := os.Getenv("PORT") | ||
if port == "" { | ||
port = "8080" | ||
log.Printf("Defaulting to port %s", port) | ||
} | ||
|
||
log.Printf("Listening on port %s", port) | ||
log.Fatal(http.ListenAndServe(fmt.Sprintf(":%s", port), nil)) | ||
} | ||
|
||
func indexHandler(w http.ResponseWriter, r *http.Request) { | ||
if r.URL.Path != "/" { | ||
http.NotFound(w, r) | ||
return | ||
} | ||
fmt.Fprint(w, "Hello, World!") | ||
} |