-
-
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.
Merge pull request #16 from ultreme/dev/moul/static-files
switch to gRPC + support static files
- Loading branch information
Showing
28 changed files
with
13,173 additions
and
701 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,20 @@ | ||
version: 2 | ||
|
||
jobs: | ||
docker.build: | ||
docker: | ||
- image: docker:17.05.0-ce-git | ||
steps: | ||
- run: apk --no-cache add make | ||
- checkout | ||
- setup_remote_docker | ||
- run: docker info | ||
- run: make docker.build | ||
- run: docker run -it --rm ultreme/calcbiz -h || true | ||
# FIXME: save cache | ||
|
||
workflows: | ||
version: 2 | ||
commit: | ||
jobs: | ||
- docker.build |
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 |
---|---|---|
|
@@ -2,4 +2,5 @@ | |
*~ | ||
*# | ||
.#* | ||
vendor/ | ||
vendor/ | ||
Dockerfile |
Empty file.
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
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 |
---|---|---|
@@ -1,8 +1,16 @@ | ||
FROM golang:1.11 | ||
COPY go.* /go/src/ultre.me/calcbiz/ | ||
WORKDIR /go/src/ultre.me/calcbiz | ||
RUN GO111MODULE=on go mod download | ||
COPY . /go/src/ultre.me/calcbiz | ||
RUN GO111MODULE=on go install -v ./cmd/calc-www | ||
CMD ["calc-www", "server"] | ||
EXPOSE 9000 | ||
FROM golang:1.11.4-alpine as builder | ||
WORKDIR /go/src/ultre.me/calcbiz | ||
RUN apk --no-cache --update add nodejs-npm make gcc g++ musl-dev openssl-dev git | ||
RUN go get -u github.com/gobuffalo/packr/packr | ||
ENV GO111MODULE=on | ||
COPY go.* /go/src/ultre.me/calcbiz/ | ||
RUN go mod download | ||
COPY . /go/src/ultre.me/calcbiz/ | ||
RUN make release | ||
|
||
FROM alpine:3.8 | ||
RUN apk --no-cache --update add ca-certificates && update-ca-certificates | ||
COPY --from=builder /go/bin/calcbiz /bin/calcbiz | ||
ENTRYPOINT ["/bin/calcbiz"] | ||
CMD ["server"] | ||
EXPOSE 9000 9001 |
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 |
---|---|---|
@@ -1,25 +1,105 @@ | ||
SOURCE := $(shell find . -name "*.go") | ||
## | ||
## functions | ||
## | ||
|
||
rwildcard = $(foreach d,$(wildcard $1*),$(call rwildcard,$d/,$2) $(filter $(subst *,%,$2),$d)) | ||
|
||
install: | ||
go install ./cmd/calc-www | ||
## | ||
## vars | ||
## | ||
|
||
GOPATH ?= $(HOME)/go | ||
BIN = $(GOPATH)/bin/calcbiz | ||
SOURCES = $(call rwildcard, ./, *.go) | ||
OUR_SOURCES = $(filter-out $(call rwildcard,vendor//,*.go),$(SOURCES)) | ||
PROTOS = $(call rwildcard, ./, *.proto) | ||
OUR_PROTOS = $(filter-out $(call rwildcard,vendor//,*.proto),$(PROTOS)) | ||
GENERATED_FILES = \ | ||
$(patsubst %.proto,%.pb.go,$(PROTOS)) \ | ||
$(call rwildcard .//, *.gen.go) \ | ||
$(call rwildcard .//, *.pb.gw.go) | ||
PROTOC_OPTS = -I/protobuf:vendor:. | ||
RUN_OPTS ?= | ||
|
||
run: up | ||
## | ||
## rules | ||
## | ||
|
||
up: | ||
docker-compose up -d --force-recreate --remove-orphans | ||
.PHONY: help | ||
help: | ||
@echo "Make commands:" | ||
@$(MAKE) -pRrq -f $(lastword $(MAKEFILE_LIST)) : 2>/dev/null | awk -v RS= -F: \ | ||
'/^# File/,/^# Finished Make data base/ {if ($$1 !~ "^[#.]") {print $$1}}' | \ | ||
sort | egrep -v -e '^[^[:alnum:]]' -e '^$@$$' | grep -v / | \ | ||
sed 's/^/ $(HELP_MSG_PREFIX)make /' | ||
|
||
.PHONY: dev | ||
dev: calc-www | ||
calc-www server | ||
.PHONY: run | ||
run: $(BIN) | ||
$(BIN) server $(RUN_OPTS) | ||
|
||
.PHONY: install | ||
install: $(BIN) | ||
$(BIN): .generated $(OUR_SOURCES) | ||
packr clean | ||
go install -v . | ||
|
||
.PHONY: docker | ||
docker: | ||
docker build -t ultreme/calcbiz . | ||
.PHONY: release | ||
release: | ||
packr | ||
go install -v . | ||
|
||
.PHONY: clean | ||
clean: | ||
rm -f $(GENERATED_FILES) .generated | ||
packr clean | ||
|
||
.PHONY: _ci_prepare | ||
_ci_prepare: | ||
touch $(OUR_PROTOS) $(GENERATED_FILES) | ||
sleep 1 | ||
touch .generated | ||
|
||
.PHONY: generate | ||
generate: .generated | ||
.generated: $(OUR_PROTOS) | ||
rm -f $(GENERATED_FILES) | ||
go mod vendor | ||
docker run \ | ||
--user="$(shell id -u)" \ | ||
--volume="$(PWD):/go/src/ultre.me/calcbiz" \ | ||
--workdir="/go/src/ultre.me/calcbiz" \ | ||
--entrypoint="sh" \ | ||
--rm \ | ||
pathwar/protoc:v1 \ | ||
-xec "make _generate" | ||
touch $@ | ||
|
||
.PHONY: _generate | ||
_generate: $(GENERATED_FILES) | ||
|
||
.PHONY: test | ||
test: | ||
test: .generated | ||
go test -v ./... | ||
|
||
%.pb.go: %.proto | ||
protoc \ | ||
$(PROTOC_OPTS) \ | ||
--grpc-gateway_out=logtostderr=true:"$(GOPATH)/src" \ | ||
--gogofaster_out=plugins=grpc:"$(GOPATH)/src" \ | ||
"$(dir $<)"/*.proto | ||
|
||
.PHONY: lint | ||
lint: | ||
golangci-lint run --verbose ./... | ||
|
||
## | ||
## production | ||
## | ||
|
||
.PHONY: docker.up | ||
docker.up: | ||
docker-compose up -d --force-recreate --remove-orphans | ||
|
||
.PHONY: docker.build | ||
docker.build: | ||
docker build -t ultreme/calcbiz . |
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 |
---|---|---|
@@ -1,2 +1,7 @@ | ||
# camembert-au-lait-crew | ||
# calcbiz - Camembert au lait crew's website | ||
:hamburger: Camembert au lait crew website & API | ||
|
||
--- | ||
|
||
Live: https://www.camembertaulaitcrew.biz | ||
Install/Dev: `go get ultre.me/calcbiz` |
Oops, something went wrong.