Joey Armstrong | ec895f8 | 2024-04-25 14:26:07 -0400 | [diff] [blame] | 1 | # ----------------------------------------------------------------------- |
| 2 | # Copyright 2017-2024 Open Networking Foundation Contributors |
| 3 | # |
| 4 | # Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | # you may not use this file except in compliance with the License. |
| 6 | # You may obtain a copy of the License at |
| 7 | # |
| 8 | # http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | # |
| 10 | # Unless required by applicable law or agreed to in writing, software |
| 11 | # distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | # See the License for the specific language governing permissions and |
| 14 | # limitations under the License. |
| 15 | # ----------------------------------------------------------------------- |
| 16 | # SPDX-FileCopyrightText: 2017-2024 Open Networking Foundation Contributors |
| 17 | # SPDX-License-Identifier: Apache-2.0 |
| 18 | # ----------------------------------------------------------------------- |
| 19 | |
Akash Reddy Kankanala | 105581b | 2024-09-11 05:20:38 +0530 | [diff] [blame] | 20 | FROM golang:1.23.1-alpine3.20 AS dev |
Naveen Sampath | 04696f7 | 2022-06-13 15:19:14 +0530 | [diff] [blame] | 21 | |
Akash Reddy Kankanala | 105581b | 2024-09-11 05:20:38 +0530 | [diff] [blame] | 22 | RUN adduser -h /home/voltha-go-controller -s /bin/bash -D voltha-go-controller && \ |
| 23 | apk add --no-cache build-base=0.5-r3 |
Naveen Sampath | 04696f7 | 2022-06-13 15:19:14 +0530 | [diff] [blame] | 24 | |
| 25 | #chnaging the working dir to tmp |
| 26 | WORKDIR /tmp |
| 27 | ENV LD_LIBRARY_PATH=/usr/local/lib |
| 28 | |
| 29 | # Set the working directory |
Sridhar Ravindra | 33d91f6 | 2023-11-09 12:05:02 +0530 | [diff] [blame] | 30 | WORKDIR /go/src/voltha-go-controller |
Naveen Sampath | 04696f7 | 2022-06-13 15:19:14 +0530 | [diff] [blame] | 31 | # Copy required files |
Sridhar Ravindra | 33d91f6 | 2023-11-09 12:05:02 +0530 | [diff] [blame] | 32 | COPY database ./database |
| 33 | COPY vendor ./vendor |
| 34 | COPY voltha-go-controller ./voltha-go-controller |
| 35 | COPY internal ./internal |
| 36 | COPY log ./log |
| 37 | COPY infra ./infra |
| 38 | COPY go.mod ./ |
| 39 | COPY go.sum ./ |
Naveen Sampath | 04696f7 | 2022-06-13 15:19:14 +0530 | [diff] [blame] | 40 | |
| 41 | |
Sridhar Ravindra | 33d91f6 | 2023-11-09 12:05:02 +0530 | [diff] [blame] | 42 | WORKDIR /go/src/voltha-go-controller/voltha-go-controller |
Naveen Sampath | 04696f7 | 2022-06-13 15:19:14 +0530 | [diff] [blame] | 43 | #RUN go build |
| 44 | #Set CGO_ENABLED flag to 0 to avoid DNS issue in alpine release |
Sridhar Ravindra | 33d91f6 | 2023-11-09 12:05:02 +0530 | [diff] [blame] | 45 | RUN CGO_ENABLED=0 go build -a -v -o /app/voltha-go-controller |
Naveen Sampath | 04696f7 | 2022-06-13 15:19:14 +0530 | [diff] [blame] | 46 | |
Sridhar Ravindra | 33d91f6 | 2023-11-09 12:05:02 +0530 | [diff] [blame] | 47 | WORKDIR /go/src/voltha-go-controller/voltha-go-controller/cli |
| 48 | RUN CGO_ENABLED=0 go build -a -v -o /app/vgcctl |
Naveen Sampath | 04696f7 | 2022-06-13 15:19:14 +0530 | [diff] [blame] | 49 | |
Akash Reddy Kankanala | 105581b | 2024-09-11 05:20:38 +0530 | [diff] [blame] | 50 | FROM golang:1.23.1-alpine3.20 AS prod |
Naveen Sampath | 04696f7 | 2022-06-13 15:19:14 +0530 | [diff] [blame] | 51 | |
Akash Reddy Kankanala | 105581b | 2024-09-11 05:20:38 +0530 | [diff] [blame] | 52 | RUN adduser -h /home/voltha-go-controller -s /bin/bash -D voltha-go-controller && \ |
| 53 | apk add --no-cache bash=5.2.26-r0 |
Naveen Sampath | 04696f7 | 2022-06-13 15:19:14 +0530 | [diff] [blame] | 54 | # Set the working directory |
Sridhar Ravindra | 33d91f6 | 2023-11-09 12:05:02 +0530 | [diff] [blame] | 55 | WORKDIR /app |
Naveen Sampath | 04696f7 | 2022-06-13 15:19:14 +0530 | [diff] [blame] | 56 | |
| 57 | # Copy required files |
Sridhar Ravindra | 33d91f6 | 2023-11-09 12:05:02 +0530 | [diff] [blame] | 58 | COPY --from=dev /app/voltha-go-controller /app |
| 59 | COPY --from=dev /app/vgcctl /app |
Naveen Sampath | 04696f7 | 2022-06-13 15:19:14 +0530 | [diff] [blame] | 60 | |
Akash Reddy Kankanala | 105581b | 2024-09-11 05:20:38 +0530 | [diff] [blame] | 61 | RUN chown -R voltha-go-controller.voltha-go-controller /app/voltha-go-controller /usr/local/bin/ && \ |
| 62 | apk add --no-cache openssh=9.7_p1-r5 |
Naveen Sampath | 04696f7 | 2022-06-13 15:19:14 +0530 | [diff] [blame] | 63 | |
Naveen Sampath | 04696f7 | 2022-06-13 15:19:14 +0530 | [diff] [blame] | 64 | ENV NOTVISIBLE "in users profile" |
| 65 | RUN echo "export VISIBLE=now" >> /etc/profile |
| 66 | |
| 67 | EXPOSE 22 |
Joey Armstrong | ec895f8 | 2024-04-25 14:26:07 -0400 | [diff] [blame] | 68 | |
Akash Reddy Kankanala | 105581b | 2024-09-11 05:20:38 +0530 | [diff] [blame] | 69 | # [EOF] |