Skip to content

Commit

Permalink
Merge pull request #10 from containerum/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
MargoTuleninova authored Sep 4, 2018
2 parents 82cc9b8 + 432bd14 commit 83bbb2a
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 22 deletions.
18 changes: 8 additions & 10 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
#### Build Step ####
FROM golang:1.10-alpine as builder

WORKDIR src/git.containerum.net/ch/api-gateway
RUN apk add --update make git
WORKDIR /go/src/git.containerum.net/ch/api-gateway
COPY . .

RUN go build -v -ldflags="-w -s" -o /bin/api-gateway ./cmd/api-gateway
RUN VERSION=$(git describe --abbrev=0 --tags) make build-for-docker

#### Generate Cert Step ####
FROM alpine:3.7 as generator
Expand All @@ -21,13 +20,12 @@ RUN openssl req -subj '/CN=containerum.io/O=Containerum/C=LV' -new -newkey rsa:2
FROM alpine:3.7

# Copy bin and migrations
RUN mkdir -p /app
COPY --from=builder /go/src/git.containerum.net/ch/api-gateway/charts/api-gateway/env/config.toml /app
COPY --from=builder /go/src/git.containerum.net/ch/api-gateway/charts/api-gateway/env/routes /app/routes
COPY --from=builder /bin/api-gateway /app
COPY --from=builder /go/src/git.containerum.net/ch/api-gateway/charts/api-gateway/env/config.toml /
COPY --from=builder /go/src/git.containerum.net/ch/api-gateway/charts/api-gateway/env/routes /routes
COPY --from=builder /tmp/api-gateway /

# Copy certs
COPY --from=generator /cert /app/cert
COPY --from=generator /cert /cert

# Set envs
ENV GATEWAY_DEBUG=false \
Expand All @@ -41,5 +39,5 @@ ENV GATEWAY_DEBUG=false \
EXPOSE 8082 8282

# run app
WORKDIR "/app"
WORKDIR "/"
CMD "./api-gateway"
18 changes: 9 additions & 9 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,20 +1,21 @@
PHONY: build test clean release single_release

CMD_DIR:=cmd/api-gateway
CLI_DIR:=cmd/api-gateway
#get current package, assuming it`s in GOPATH sources
PACKAGE := $(shell go list -f '{{.ImportPath}}' ./$(CLI_DIR))
PACKAGE := $(PACKAGE:%/$(CLI_DIR)=%)

# make directory and store path to variable
BUILDS_DIR:=$(PWD)/build
EXECUTABLE:=kube-api
LDFLAGS=-X 'main.version=$(VERSION)'
EXECUTABLE:=api-gateway
LDFLAGS=-X 'main.version=$(VERSION)' -w -s -extldflags '-static'

# go has build artifacts caching so soruce tracking not needed
build:
@echo "Building kube-api for current OS/architecture"
@go build -v -ldflags="$(LDFLAGS)" -o $(BUILDS_DIR)/$(EXECUTABLE) ./$(CMD_DIR)
@echo "Building mail-templater for current OS/architecture"
@echo $(LDFLAGS)
@CGO_ENABLED=0 go build -v -ldflags="$(LDFLAGS)" -tags="jsoniter" -o $(BUILDS_DIR)/$(EXECUTABLE) ./$(CMD_DIR)

build-for-docker:
@echo $(LDFLAGS)
@CGO_ENABLED=0 go build -v -ldflags="$(LDFLAGS)" -tags="jsoniter" -o /tmp/$(EXECUTABLE) ./$(CMD_DIR)

test:
@echo "Running tests"
Expand Down Expand Up @@ -64,5 +65,4 @@ single_release:

dev:
@echo building $(VERSION)
@echo $(PACKAGE)
go build -v --tags="dev" --ldflags="$(LDFLAGS)" ./$(CMD_DIR)
3 changes: 0 additions & 3 deletions cmd/api-gateway/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,6 @@ func main() {
app := cli.App{
Name: "api-gateway",
Version: func() string {
if version == "" {
return "1.0.0-dev"
}
return version
}(),
Usage: "Awesome Golang API Gateway.",
Expand Down

0 comments on commit 83bbb2a

Please sign in to comment.