blob: aa454f3e0998e0e8e272cfb9e4a354ce1eb35802 [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
Akash Reddy Kankanala105581b2024-09-11 05:20:38 +053020FROM golang:1.23.1-alpine3.20 AS dev
Naveen Sampath04696f72022-06-13 15:19:14 +053021
Akash Reddy Kankanala105581b2024-09-11 05:20:38 +053022RUN adduser -h /home/voltha-go-controller -s /bin/bash -D voltha-go-controller && \
23 apk add --no-cache build-base=0.5-r3
Naveen Sampath04696f72022-06-13 15:19:14 +053024
25#chnaging the working dir to tmp
26WORKDIR /tmp
27ENV LD_LIBRARY_PATH=/usr/local/lib
28
29# Set the working directory
Sridhar Ravindra33d91f62023-11-09 12:05:02 +053030WORKDIR /go/src/voltha-go-controller
Naveen Sampath04696f72022-06-13 15:19:14 +053031# Copy required files
Sridhar Ravindra33d91f62023-11-09 12:05:02 +053032COPY database ./database
33COPY vendor ./vendor
34COPY voltha-go-controller ./voltha-go-controller
35COPY internal ./internal
36COPY log ./log
37COPY infra ./infra
38COPY go.mod ./
39COPY go.sum ./
Naveen Sampath04696f72022-06-13 15:19:14 +053040
41
Sridhar Ravindra33d91f62023-11-09 12:05:02 +053042WORKDIR /go/src/voltha-go-controller/voltha-go-controller
Naveen Sampath04696f72022-06-13 15:19:14 +053043#RUN go build
44#Set CGO_ENABLED flag to 0 to avoid DNS issue in alpine release
Sridhar Ravindra33d91f62023-11-09 12:05:02 +053045RUN CGO_ENABLED=0 go build -a -v -o /app/voltha-go-controller
Naveen Sampath04696f72022-06-13 15:19:14 +053046
Sridhar Ravindra33d91f62023-11-09 12:05:02 +053047WORKDIR /go/src/voltha-go-controller/voltha-go-controller/cli
48RUN CGO_ENABLED=0 go build -a -v -o /app/vgcctl
Naveen Sampath04696f72022-06-13 15:19:14 +053049
Akash Reddy Kankanala105581b2024-09-11 05:20:38 +053050FROM golang:1.23.1-alpine3.20 AS prod
Naveen Sampath04696f72022-06-13 15:19:14 +053051
Akash Reddy Kankanala105581b2024-09-11 05:20:38 +053052RUN adduser -h /home/voltha-go-controller -s /bin/bash -D voltha-go-controller && \
53 apk add --no-cache bash=5.2.26-r0
Naveen Sampath04696f72022-06-13 15:19:14 +053054# Set the working directory
Sridhar Ravindra33d91f62023-11-09 12:05:02 +053055WORKDIR /app
Naveen Sampath04696f72022-06-13 15:19:14 +053056
57# Copy required files
Sridhar Ravindra33d91f62023-11-09 12:05:02 +053058COPY --from=dev /app/voltha-go-controller /app
59COPY --from=dev /app/vgcctl /app
Naveen Sampath04696f72022-06-13 15:19:14 +053060
Akash Reddy Kankanala105581b2024-09-11 05:20:38 +053061RUN 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 Sampath04696f72022-06-13 15:19:14 +053063
Naveen Sampath04696f72022-06-13 15:19:14 +053064ENV NOTVISIBLE "in users profile"
65RUN echo "export VISIBLE=now" >> /etc/profile
66
67EXPOSE 22
Joey Armstrongec895f82024-04-25 14:26:07 -040068
Akash Reddy Kankanala105581b2024-09-11 05:20:38 +053069# [EOF]