Browse Source

Update Dockerfile

use golang as builder, update linker flags
Matthew R Kasun 3 years ago
parent
commit
3378c3cf1f
1 changed files with 3 additions and 10 deletions
  1. 3 10
      Dockerfile

+ 3 - 10
Dockerfile

@@ -1,26 +1,19 @@
 #first stage - builder
-FROM gravitl/builder as builder
-
+FROM golang:1.15 as builder
+ARG version
 WORKDIR /app
-
 COPY . .
-
 ENV GO111MODULE=auto
-
-RUN GOOS=linux GOARCH=amd64 CGO_ENABLED=1 /usr/local/go/bin/go build -ldflags="-w -s" -o netmaker main.go
+RUN GOOS=linux CGO_ENABLED=1 go build -ldflags="-s -X 'main.version=$version" -o netmaker main.go
 
 FROM alpine:3.13.6
 # add a c lib
 RUN apk add gcompat iptables
 # set the working directory
 WORKDIR /root/
-
 RUN mkdir -p /etc/netclient/config
-
 COPY --from=builder /app/netmaker .
 COPY --from=builder /app/config config
-
 EXPOSE 8081
 EXPOSE 50051
-
 ENTRYPOINT ["./netmaker"]