File tree Expand file tree Collapse file tree 3 files changed +17
-22
lines changed Expand file tree Collapse file tree 3 files changed +17
-22
lines changed Original file line number Diff line number Diff line change 11# ### Build Step ####
22FROM 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
55COPY . .
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 ####
109FROM alpine:3.7 as generator
@@ -21,13 +20,12 @@ RUN openssl req -subj '/CN=containerum.io/O=Containerum/C=LV' -new -newkey rsa:2
2120FROM 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
3331ENV GATEWAY_DEBUG=false \
@@ -41,5 +39,5 @@ ENV GATEWAY_DEBUG=false \
4139EXPOSE 8082 8282
4240
4341# run app
44- WORKDIR "/app "
42+ WORKDIR "/"
4543CMD "./api-gateway"
Original file line number Diff line number Diff line change 11PHONY : build test clean release single_release
22
33CMD_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
106BUILDS_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
1511build :
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
1920test :
2021 @echo " Running tests"
@@ -64,5 +65,4 @@ single_release:
6465
6566dev :
6667 @echo building $(VERSION )
67- @echo $(PACKAGE )
6868 go build -v --tags=" dev" --ldflags=" $( LDFLAGS) " ./$(CMD_DIR )
Original file line number Diff line number Diff 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." ,
You can’t perform that action at this time.
0 commit comments