Katri Turunen | 4b74f01 | 2019-08-15 10:49:36 +0300 | [diff] [blame] | 1 | # |
| 2 | # Copyright (c) 2019 AT&T Intellectual Property. |
| 3 | # Copyright (c) 2018-2019 Nokia. |
| 4 | # |
| 5 | # Licensed under the Apache License, Version 2.0 (the "License"); |
| 6 | # you may not use this file except in compliance with the License. |
| 7 | # You may obtain a copy of the License at |
| 8 | # |
| 9 | # http://www.apache.org/licenses/LICENSE-2.0 |
| 10 | # |
| 11 | # Unless required by applicable law or agreed to in writing, software |
| 12 | # distributed under the License is distributed on an "AS IS" BASIS, |
| 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 14 | # See the License for the specific language governing permissions and |
| 15 | # limitations under the License. |
| 16 | |
| 17 | # Start from golang v1.12 base image |
| 18 | FROM golang:1.12 as gobuild |
| 19 | |
| 20 | # Set the Working Directory for ves-agent inside the container |
| 21 | RUN mkdir -p $GOPATH/src/VESPA |
| 22 | WORKDIR $GOPATH/src/VESPA |
| 23 | |
| 24 | # Clone VES Agent v0.3.0 from github |
| 25 | RUN git clone -b v0.3.0 https://github.com/nokia/ONAP-VESPA.git $GOPATH/src/VESPA |
| 26 | |
| 27 | RUN GO111MODULE=on go mod download |
| 28 | |
| 29 | # Install VES Agent |
| 30 | RUN export GOPATH=$HOME/go && \ |
| 31 | export PATH=$GOPATH/bin:$GOROOT/bin:$PATH && \ |
| 32 | go install -v ./ves-agent |
| 33 | |
| 34 | # Set the Working Directory for vesmgr inside the container |
| 35 | RUN mkdir -p $GOPATH/src/vesmgr |
| 36 | WORKDIR $GOPATH/src/vesmgr |
| 37 | |
| 38 | # Copy vesmgr to the Working Directory |
| 39 | COPY $HOME/ . |
| 40 | |
| 41 | RUN GO111MODULE=on go mod download |
| 42 | |
Katri Turunen | 66b7813 | 2019-09-02 10:28:52 +0300 | [diff] [blame] | 43 | # Run vesmgr UT |
| 44 | RUN export GOPATH=$HOME/go && \ |
| 45 | export PATH=$GOPATH/bin:$GOROOT/bin:$PATH && \ |
| 46 | go test ./... |
| 47 | |
Katri Turunen | 4b74f01 | 2019-08-15 10:49:36 +0300 | [diff] [blame] | 48 | # Install vesmgr |
| 49 | RUN export GOPATH=$HOME/go && \ |
| 50 | export PATH=$GOPATH/bin:$GOROOT/bin:$PATH && \ |
| 51 | go install -v ./cmd/vesmgr |
| 52 | |
| 53 | ################# |
| 54 | # |
| 55 | # Second phase, copy compiled stuff to a runtime container |
| 56 | |
| 57 | # Ubuntu or something smaller? |
| 58 | FROM ubuntu:18.04 |
Roni Riska | 9a9ecfe | 2019-09-25 12:28:32 +0300 | [diff] [blame^] | 59 | # For trouble-shooting |
| 60 | RUN apt-get update; apt-get install -y \ |
| 61 | iputils-ping \ |
| 62 | net-tools \ |
| 63 | curl |
| 64 | |
Katri Turunen | 4b74f01 | 2019-08-15 10:49:36 +0300 | [diff] [blame] | 65 | # Create the configuration directory for ves agent |
| 66 | RUN mkdir -p /etc/ves-agent |
| 67 | COPY --from=gobuild root/go/bin /root/go/bin |
| 68 | |
| 69 | ENV PATH="/root/go/bin:${PATH}" |
| 70 | |
| 71 | ENTRYPOINT ["vesmgr"] |