Skip to content

Commit 83bbb2a

Browse files
Merge pull request #10 from containerum/develop
Develop
2 parents 82cc9b8 + 432bd14 commit 83bbb2a

File tree

3 files changed

+17
-22
lines changed

3 files changed

+17
-22
lines changed

Dockerfile

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
#### Build Step ####
22
FROM golang:1.10-alpine as builder
3-
4-
WORKDIR src/git.containerum.net/ch/api-gateway
3+
RUN apk add --update make git
4+
WORKDIR /go/src/git.containerum.net/ch/api-gateway
55
COPY . .
6-
7-
RUN go build -v -ldflags="-w -s" -o /bin/api-gateway ./cmd/api-gateway
6+
RUN VERSION=$(git describe --abbrev=0 --tags) make build-for-docker
87

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

2322
# Copy bin and migrations
24-
RUN mkdir -p /app
25-
COPY --from=builder /go/src/git.containerum.net/ch/api-gateway/charts/api-gateway/env/config.toml /app
26-
COPY --from=builder /go/src/git.containerum.net/ch/api-gateway/charts/api-gateway/env/routes /app/routes
27-
COPY --from=builder /bin/api-gateway /app
23+
COPY --from=builder /go/src/git.containerum.net/ch/api-gateway/charts/api-gateway/env/config.toml /
24+
COPY --from=builder /go/src/git.containerum.net/ch/api-gateway/charts/api-gateway/env/routes /routes
25+
COPY --from=builder /tmp/api-gateway /
2826

2927
# Copy certs
30-
COPY --from=generator /cert /app/cert
28+
COPY --from=generator /cert /cert
3129

3230
# Set envs
3331
ENV GATEWAY_DEBUG=false \
@@ -41,5 +39,5 @@ ENV GATEWAY_DEBUG=false \
4139
EXPOSE 8082 8282
4240

4341
# run app
44-
WORKDIR "/app"
42+
WORKDIR "/"
4543
CMD "./api-gateway"

Makefile

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,21 @@
11
PHONY: build test clean release single_release
22

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

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

1410
# go has build artifacts caching so soruce tracking not needed
1511
build:
16-
@echo "Building kube-api for current OS/architecture"
17-
@go build -v -ldflags="$(LDFLAGS)" -o $(BUILDS_DIR)/$(EXECUTABLE) ./$(CMD_DIR)
12+
@echo "Building mail-templater for current OS/architecture"
13+
@echo $(LDFLAGS)
14+
@CGO_ENABLED=0 go build -v -ldflags="$(LDFLAGS)" -tags="jsoniter" -o $(BUILDS_DIR)/$(EXECUTABLE) ./$(CMD_DIR)
15+
16+
build-for-docker:
17+
@echo $(LDFLAGS)
18+
@CGO_ENABLED=0 go build -v -ldflags="$(LDFLAGS)" -tags="jsoniter" -o /tmp/$(EXECUTABLE) ./$(CMD_DIR)
1819

1920
test:
2021
@echo "Running tests"
@@ -64,5 +65,4 @@ single_release:
6465

6566
dev:
6667
@echo building $(VERSION)
67-
@echo $(PACKAGE)
6868
go build -v --tags="dev" --ldflags="$(LDFLAGS)" ./$(CMD_DIR)

cmd/api-gateway/main.go

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,6 @@ func main() {
1818
app := cli.App{
1919
Name: "api-gateway",
2020
Version: func() string {
21-
if version == "" {
22-
return "1.0.0-dev"
23-
}
2421
return version
2522
}(),
2623
Usage: "Awesome Golang API Gateway.",

0 commit comments

Comments
 (0)