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 | |
Naveen Sampath | 04696f7 | 2022-06-13 15:19:14 +0530 | [diff] [blame] | 20 | FROM --platform=linux/amd64 golang:1.16.3-alpine3.13 AS dev |
| 21 | |
| 22 | RUN adduser -h /home/voltha-go-controller -s /bin/bash -D voltha-go-controller |
| 23 | # Install required packages |
| 24 | RUN apk add --no-cache build-base=0.5-r3 |
| 25 | |
| 26 | #adding git |
| 27 | #RUN apk add --no-cache bash=5.1.16-r0 |
| 28 | |
| 29 | #chnaging the working dir to tmp |
| 30 | WORKDIR /tmp |
| 31 | ENV LD_LIBRARY_PATH=/usr/local/lib |
| 32 | |
| 33 | # Set the working directory |
Sridhar Ravindra | 33d91f6 | 2023-11-09 12:05:02 +0530 | [diff] [blame] | 34 | WORKDIR /go/src/voltha-go-controller |
Naveen Sampath | 04696f7 | 2022-06-13 15:19:14 +0530 | [diff] [blame] | 35 | # Copy required files |
Sridhar Ravindra | 33d91f6 | 2023-11-09 12:05:02 +0530 | [diff] [blame] | 36 | COPY database ./database |
| 37 | COPY vendor ./vendor |
| 38 | COPY voltha-go-controller ./voltha-go-controller |
| 39 | COPY internal ./internal |
| 40 | COPY log ./log |
| 41 | COPY infra ./infra |
| 42 | COPY go.mod ./ |
| 43 | COPY go.sum ./ |
Naveen Sampath | 04696f7 | 2022-06-13 15:19:14 +0530 | [diff] [blame] | 44 | |
| 45 | |
Sridhar Ravindra | 33d91f6 | 2023-11-09 12:05:02 +0530 | [diff] [blame] | 46 | WORKDIR /go/src/voltha-go-controller/voltha-go-controller |
Naveen Sampath | 04696f7 | 2022-06-13 15:19:14 +0530 | [diff] [blame] | 47 | #RUN go build |
| 48 | #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] | 49 | 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] | 50 | |
Sridhar Ravindra | 33d91f6 | 2023-11-09 12:05:02 +0530 | [diff] [blame] | 51 | WORKDIR /go/src/voltha-go-controller/voltha-go-controller/cli |
| 52 | RUN CGO_ENABLED=0 go build -a -v -o /app/vgcctl |
Naveen Sampath | 04696f7 | 2022-06-13 15:19:14 +0530 | [diff] [blame] | 53 | |
| 54 | FROM --platform=linux/amd64 golang:1.16.3-alpine3.13 AS prod |
| 55 | |
| 56 | RUN adduser -h /home/voltha-go-controller -s /bin/bash -D voltha-go-controller |
| 57 | |
| 58 | RUN apk add --no-cache bash=5.1.16-r0 |
| 59 | # Set the working directory |
Sridhar Ravindra | 33d91f6 | 2023-11-09 12:05:02 +0530 | [diff] [blame] | 60 | WORKDIR /app |
Naveen Sampath | 04696f7 | 2022-06-13 15:19:14 +0530 | [diff] [blame] | 61 | |
| 62 | # Copy required files |
Sridhar Ravindra | 33d91f6 | 2023-11-09 12:05:02 +0530 | [diff] [blame] | 63 | COPY --from=dev /app/voltha-go-controller /app |
| 64 | COPY --from=dev /app/vgcctl /app |
Naveen Sampath | 04696f7 | 2022-06-13 15:19:14 +0530 | [diff] [blame] | 65 | |
Sridhar Ravindra | 33d91f6 | 2023-11-09 12:05:02 +0530 | [diff] [blame] | 66 | RUN chown -R voltha-go-controller.voltha-go-controller /app/voltha-go-controller /usr/local/bin/ |
Naveen Sampath | 04696f7 | 2022-06-13 15:19:14 +0530 | [diff] [blame] | 67 | RUN apk add --no-cache openssh=8.4_p1-r4 |
Naveen Sampath | 04696f7 | 2022-06-13 15:19:14 +0530 | [diff] [blame] | 68 | |
| 69 | RUN sed 's@session\s*required\s*pam_loginuid.so@session optional pam_loginuid.so@g' -i /etc/init.d/sshd |
| 70 | ENV NOTVISIBLE "in users profile" |
| 71 | RUN echo "export VISIBLE=now" >> /etc/profile |
| 72 | |
| 73 | EXPOSE 22 |
Joey Armstrong | ec895f8 | 2024-04-25 14:26:07 -0400 | [diff] [blame] | 74 | |
| 75 | # [EOF] |