blob: ecfc87c5388567b88cdceed0cd83746357141065 [file] [log] [blame]
Joey Armstrongec895f82024-04-25 14:26:07 -04001# -----------------------------------------------------------------------
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 Sampath04696f72022-06-13 15:19:14 +053020FROM --platform=linux/amd64 golang:1.16.3-alpine3.13 AS dev
21
22RUN adduser -h /home/voltha-go-controller -s /bin/bash -D voltha-go-controller
23# Install required packages
24RUN 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
30WORKDIR /tmp
31ENV LD_LIBRARY_PATH=/usr/local/lib
32
33# Set the working directory
Sridhar Ravindra33d91f62023-11-09 12:05:02 +053034WORKDIR /go/src/voltha-go-controller
Naveen Sampath04696f72022-06-13 15:19:14 +053035# Copy required files
Sridhar Ravindra33d91f62023-11-09 12:05:02 +053036COPY database ./database
37COPY vendor ./vendor
38COPY voltha-go-controller ./voltha-go-controller
39COPY internal ./internal
40COPY log ./log
41COPY infra ./infra
42COPY go.mod ./
43COPY go.sum ./
Naveen Sampath04696f72022-06-13 15:19:14 +053044
45
Sridhar Ravindra33d91f62023-11-09 12:05:02 +053046WORKDIR /go/src/voltha-go-controller/voltha-go-controller
Naveen Sampath04696f72022-06-13 15:19:14 +053047#RUN go build
48#Set CGO_ENABLED flag to 0 to avoid DNS issue in alpine release
Sridhar Ravindra33d91f62023-11-09 12:05:02 +053049RUN CGO_ENABLED=0 go build -a -v -o /app/voltha-go-controller
Naveen Sampath04696f72022-06-13 15:19:14 +053050
Sridhar Ravindra33d91f62023-11-09 12:05:02 +053051WORKDIR /go/src/voltha-go-controller/voltha-go-controller/cli
52RUN CGO_ENABLED=0 go build -a -v -o /app/vgcctl
Naveen Sampath04696f72022-06-13 15:19:14 +053053
54FROM --platform=linux/amd64 golang:1.16.3-alpine3.13 AS prod
55
56RUN adduser -h /home/voltha-go-controller -s /bin/bash -D voltha-go-controller
57
58RUN apk add --no-cache bash=5.1.16-r0
59# Set the working directory
Sridhar Ravindra33d91f62023-11-09 12:05:02 +053060WORKDIR /app
Naveen Sampath04696f72022-06-13 15:19:14 +053061
62# Copy required files
Sridhar Ravindra33d91f62023-11-09 12:05:02 +053063COPY --from=dev /app/voltha-go-controller /app
64COPY --from=dev /app/vgcctl /app
Naveen Sampath04696f72022-06-13 15:19:14 +053065
Sridhar Ravindra33d91f62023-11-09 12:05:02 +053066RUN chown -R voltha-go-controller.voltha-go-controller /app/voltha-go-controller /usr/local/bin/
Naveen Sampath04696f72022-06-13 15:19:14 +053067RUN apk add --no-cache openssh=8.4_p1-r4
Naveen Sampath04696f72022-06-13 15:19:14 +053068
69RUN sed 's@session\s*required\s*pam_loginuid.so@session optional pam_loginuid.so@g' -i /etc/init.d/sshd
70ENV NOTVISIBLE "in users profile"
71RUN echo "export VISIBLE=now" >> /etc/profile
72
73EXPOSE 22
Joey Armstrongec895f82024-04-25 14:26:07 -040074
75# [EOF]