CPU Pooler version updated to 0.3.1
[ta/caas-cpupooler.git] / docker-build / cpupooler / Dockerfile
1 # Copyright 2019 Nokia
2 #
3 # Licensed under the Apache License, Version 2.0 (the "License");
4 # you may not use this file except in compliance with the License.
5 # You may obtain a copy of the License at
6 #
7 #     http://www.apache.org/licenses/LICENSE-2.0
8 #
9 # Unless required by applicable law or agreed to in writing, software
10 # distributed under the License is distributed on an "AS IS" BASIS,
11 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 # See the License for the specific language governing permissions and
13 # limitations under the License.
14
15 ARG BUILDER_BASE=golang:1.13-alpine
16 ARG FINAL_BASE=alpine:3.9.6
17 ARG PROJECT_PATH=github.com/nokia/CPU-Pooler
18
19 # Build stage
20 FROM ${BUILDER_BASE} AS builder
21 ARG PROJECT_PATH
22 ENV CGO_ENABLED=0
23 ENV GOOS=linux
24
25 RUN apk update && apk add --no-cache curl git
26 WORKDIR ${GOPATH}/src/${PROJECT_PATH}/bin
27 WORKDIR ${GOPATH}/src/${PROJECT_PATH}
28 ADD go.* ./
29 RUN go mod download
30 ADD . ./
31 RUN go build -a -ldflags '-extldflags "-static"' -o bin/ ${PROJECT_PATH}/cmd/...
32 RUN mv bin/cpusetter bin/cpu-setter
33 RUN mv bin/webhook bin/cpu-device-webhook
34 RUN mv bin/process-starter /process-starter
35
36 # Multi-binary image stage
37 FROM ${FINAL_BASE}
38 MAINTAINER Gabor Mate <gabor.mate@nokia.com>
39 ARG PROJECT_PATH
40
41 RUN apk update && apk add --no-cache curl util-linux && rm -f /var/cache/apk/*
42 COPY --from=builder /go/src/${PROJECT_PATH}/bin/cpu-* /
43
44 ENTRYPOINT ["/bin/sh"]